]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxStaticBox label redrawing when "Alt" is pressed in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 21 Sep 2010 11:44:41 +0000 (11:44 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 21 Sep 2010 11:44:41 +0000 (11:44 +0000)
The default handling for Alt key press in the standard control is to redraw
the label to account for showing of the keyboard queues (i.e. if the mnemonics
were initially hidden, they are shown when Alt is pressed) but it doesn't
redraw it in the correct colour resulting in any custom label colour being
lost whenever Alt is pressed anywhere in the window containing the box.

Fix this by forcing the box refresh which will result in repainting it using
our code which does use the correct colour.

Also update the static page of the widgets sample to allow changing the
colours of all static controls on this page, including the wxStaticBox, and
not just the main wxStaticText.

Closes #12497.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65579 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/widgets/static.cpp
src/msw/statbox.cpp

index 0dd3e385300f386f06227819233ad408d1cfe6c8..c305c4db8ef17e8245ee12811b95c3be7be3c449 100644 (file)
@@ -94,6 +94,18 @@ public:
     virtual ~StaticWidgetsPage(){};
 
     virtual wxControl *GetWidget() const { return m_statText; }
+    virtual Widgets GetWidgets() const
+    {
+        Widgets widgets;
+        widgets.push_back(m_sizerStatBox->GetStaticBox());
+        widgets.push_back(m_statText);
+        widgets.push_back(m_statMarkup);
+#if wxUSE_STATLINE
+        widgets.push_back(m_statLine);
+#endif // wxUSE_STATLINE
+
+        return widgets;
+    }
     virtual void RecreateWidget() { CreateStatic(); }
 
     // lazy creation of the content
index 3c2dfcf06d00a72faf08c8b3b91137649cb34c50..55f3b79cd1237218732ff3513567c6e9f53c226c 100644 (file)
@@ -237,6 +237,24 @@ WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPar
         return 0;
     }
 
+    if ( nMsg == WM_UPDATEUISTATE )
+    {
+        // DefWindowProc() redraws just the static box text when it gets this
+        // message and it does it using the standard (blue in standard theme)
+        // colour and not our own label colour that we use in PaintForeground()
+        // resulting in the label mysteriously changing the colour when e.g.
+        // "Alt" is pressed anywhere in the window, see #12497.
+        //
+        // To avoid this we simply refresh the window forcing our own code
+        // redrawing the label in the correct colour to be called. This is
+        // inefficient but there doesn't seem to be anything else we can do.
+        //
+        // Notice that the problem is XP-specific and doesn't arise under later
+        // systems.
+        if ( m_hasFgCol && wxGetWinVersion() == wxWinVersion_XP )
+            Refresh();
+    }
+
     return wxControl::MSWWindowProc(nMsg, wParam, lParam);
 }