]> git.saurik.com Git - wxWidgets.git/commitdiff
fixes for handling WM_SYSCOLORCHANGE - now seems to work
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 8 Dec 2001 00:26:30 +0000 (00:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 8 Dec 2001 00:26:30 +0000 (00:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12922 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/univ/window.h
include/wx/window.h
src/common/wincmn.cpp
src/msw/control.cpp
src/msw/window.cpp
src/univ/winuniv.cpp

index baabd5350204d2a2d49511fa31b7322b1a5da258..cfe3c89bb7e729cbed19fee165db2e2ffe8248bb 100644 (file)
@@ -200,11 +200,6 @@ public:
     // we refresh the window when it is dis/enabled
     virtual bool Enable(bool enable = TRUE);
 
-    // remember that the font/colour was changed
-    virtual bool SetBackgroundColour(const wxColour& colour);
-    virtual bool SetForegroundColour(const wxColour& colour);
-    virtual bool SetFont(const wxFont& font);
-
     // our Capture/ReleaseMouse() maintains the stack of windows which had
     // captured the mouse and when ReleaseMouse() is called, the mouse freed
     // only if the stack is empty, otherwise it is captured back by the window
@@ -272,11 +267,8 @@ protected:
     int       m_alignBgBitmap;
     wxStretch m_stretchBgBitmap;
 
-    // more flags
-    bool m_isCurrent:1; // is the mouse currently inside the window?
-    bool m_hasBgCol:1;  // was the bg colour explicitly changed by user?
-    bool m_hasFgCol:1;  //         fg
-    bool m_hasFont:1;   //         font
+    // is the mouse currently inside the window?
+    bool m_isCurrent:1;
 
 private:
     // the window scrollbars
index 4be6c62c9557121e74e89c73b72a9cd8b3a5b187..3abbf6a33029957f7dd474462f591e2543db901f 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        window.h
+// Name:        wx/window.h
 // Purpose:     wxWindowBase class - the interface of wxWindow
 // Author:      Vadim Zeitlin
 // Modified by:
@@ -823,6 +823,11 @@ protected:
     bool                 m_isEnabled:1;
     bool                 m_isBeingDeleted:1;
 
+    // was the window colours/font explicitly changed by user?
+    bool                 m_hasBgCol:1;
+    bool                 m_hasFgCol:1;
+    bool                 m_hasFont:1;
+
     // window attributes
     long                 m_windowStyle,
                          m_exStyle;
index 26df7cc81f50c2a4f6f9eef2596b0c5f3b5d631e..c052a11bb4d0a813de30a1aab92a38615f1a3e99 100644 (file)
@@ -637,6 +637,8 @@ bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
 
     m_backgroundColour = colour;
 
+    m_hasBgCol = TRUE;
+
     return TRUE;
 }
 
@@ -647,6 +649,8 @@ bool wxWindowBase::SetForegroundColour( const wxColour &colour )
 
     m_foregroundColour = colour;
 
+    m_hasFgCol = TRUE;
+
     return TRUE;
 }
 
@@ -678,6 +682,8 @@ bool wxWindowBase::SetFont(const wxFont& font)
 
     m_font = fontOk;
 
+    m_hasFont = TRUE;
+
     return TRUE;
 }
 
index b3f223c21001b4a00493442be8363b60d0d567c4..5454e029f9e633219be6bbfe51221104fdbb93c5 100644 (file)
@@ -46,9 +46,6 @@ END_EVENT_TABLE()
 // Item members
 wxControl::wxControl()
 {
-    m_backgroundColour = *wxWHITE;
-    m_foregroundColour = *wxBLACK;
-
 #if WXWIN_COMPATIBILITY
     m_callback = 0;
 #endif // WXWIN_COMPATIBILITY
index 5b4cbc254a5ddd644903b793c51d0ed15afbed27..2979f857d53402b70a0413ec1c853225fed2ad18 100644 (file)
@@ -3257,7 +3257,11 @@ bool wxWindowMSW::HandleSysColorChange()
     wxSysColourChangedEvent event;
     event.SetEventObject(this);
 
-    return GetEventHandler()->ProcessEvent(event);
+    (void)GetEventHandler()->ProcessEvent(event);
+
+    // always let the system carry on the default processing to allow the
+    // native controls to react to the colours update
+    return FALSE;
 }
 
 bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush,
@@ -3324,19 +3328,35 @@ bool wxWindowMSW::HandleQueryNewPalette()
 // Responds to colour changes: passes event on to children.
 void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
-    wxNode *node = GetChildren().First();
+    wxWindowList::Node *node = GetChildren().GetFirst();
     while ( node )
     {
-        // Only propagate to non-top-level windows
-        wxWindow *win = (wxWindow *)node->Data();
-        if ( win->GetParent() )
+        // Only propagate to non-top-level windows because Windows already
+        // sends this event to all top-level ones
+        wxWindow *win = node->GetData();
+        if ( !win->IsTopLevel() )
         {
-            wxSysColourChangedEvent event2;
-            event.m_eventObject = win;
-            win->GetEventHandler()->ProcessEvent(event2);
+            // we need to send the real WM_SYSCOLORCHANGE and not just trigger
+            // EVT_SYS_COLOUR_CHANGED call because the latter wouldn't work for
+            // the standard controls
+            ::SendMessage(GetHwndOf(win), WM_SYSCOLORCHANGE, 0, 0);
         }
 
-        node = node->Next();
+        node = node->GetNext();
+    }
+
+    // update the colours we use if they were not set explicitly by the user:
+    // this must be done or OnCtlColor() would continue to use the old colours
+    if ( !m_hasFgCol )
+    {
+        m_foregroundColour = wxSystemSettings::
+                                GetSystemColour(wxSYS_COLOUR_WINDOWTEXT);
+    }
+
+    if ( !m_hasBgCol )
+    {
+        m_backgroundColour = wxSystemSettings::
+                                GetSystemColour(wxSYS_COLOUR_BTNFACE);
     }
 }
 
index a7430cb2e4128654b20eede27c5c155e0899dcaf..2727e0b89a16c2ff3270975df19b2cfb68211ff8 100644 (file)
@@ -938,40 +938,6 @@ wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal)
     return rect;
 }
 
-// ----------------------------------------------------------------------------
-// colours/fonts
-// ----------------------------------------------------------------------------
-
-bool wxWindow::SetBackgroundColour(const wxColour& colour)
-{
-    if ( !wxWindowNative::SetBackgroundColour(colour) )
-        return FALSE;
-
-    m_hasBgCol = TRUE;
-
-    return TRUE;
-}
-
-bool wxWindow::SetForegroundColour(const wxColour& colour)
-{
-    if ( !wxWindowNative::SetForegroundColour(colour) )
-        return FALSE;
-
-    m_hasFgCol = TRUE;
-
-    return TRUE;
-}
-
-bool wxWindow::SetFont(const wxFont& font)
-{
-    if ( !wxWindowNative::SetFont(font) )
-        return FALSE;
-
-    m_hasFont = TRUE;
-
-    return TRUE;
-}
-
 // ----------------------------------------------------------------------------
 // mouse capture
 // ----------------------------------------------------------------------------