fixes for handling WM_SYSCOLORCHANGE - now seems to work

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12922 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-12-08 00:26:30 +00:00
parent b32a1ead44
commit 23895080c2
6 changed files with 43 additions and 57 deletions

View 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

View 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;

View 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;
}

View 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

View 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);
}
}

View 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
// ----------------------------------------------------------------------------