]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
Initial revision
[wxWidgets.git] / src / msw / textctrl.cpp
index fa1c2a47c5006927d9bbaae2c8842745e2e905af..347fd91f7cf77de4ed719210ee1d8adb42153b07 100644 (file)
@@ -152,9 +152,6 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     if ( parent )
         parent->AddChild(this);
 
-    // set colours
-    SetupColours();
-
     // translate wxWin style flags to MSW ones, checking for consistency while
     // doing it
     long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
@@ -316,6 +313,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     }
 #endif
 
+    // set colours
+    SetupColours();
+
     SetSize(pos.x, pos.y, size.x, size.y);
 
     return TRUE;
@@ -353,8 +353,13 @@ void wxTextCtrl::AdoptAttributesFromHWND()
 
 void wxTextCtrl::SetupColours()
 {
-    // FIXME why is bg colour not inherited from parent?
-    SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+    wxColour bkgndColour;
+    if (IsEditable() || (m_windowStyle & wxTE_MULTILINE))
+        bkgndColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
+    else
+        bkgndColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+
+    SetBackgroundColour(bkgndColour);
     SetForegroundColour(GetParent()->GetForegroundColour());
 }
 
@@ -516,8 +521,16 @@ bool wxTextCtrl::CanPaste() const
 
 void wxTextCtrl::SetEditable(bool editable)
 {
+    bool isEditable = IsEditable();
+
     HWND hWnd = GetHwnd();
     SendMessage(hWnd, EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
+
+    if (editable != isEditable)
+    {
+       SetupColours();
+       Refresh();
+    }
 }
 
 void wxTextCtrl::SetInsertionPoint(long pos)