]> git.saurik.com Git - wxWidgets.git/commitdiff
Correct drawing of mnemonics in wxStaticBox label under wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 21 Sep 2010 11:44:47 +0000 (11:44 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 21 Sep 2010 11:44:47 +0000 (11:44 +0000)
Only show the mnemonics if they need to be shown, i.e. use the same logic as
the standard controls use, to avoid showing mnemonics in wxStaticBox with
custom label colour even when other wxStaticBoxes don't show it.

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

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

index c305c4db8ef17e8245ee12811b95c3be7be3c449..abeff873bf4cff4e27a275d08af66bd58f939cae 100644 (file)
@@ -308,7 +308,7 @@ void StaticWidgetsPage::CreateContent()
     // NB: must be done _before_ calling CreateStatic()
     Reset();
 
-    m_textBox->SetValue(wxT("This is a box"));
+    m_textBox->SetValue(wxT("This is a &box"));
     m_textLabel->SetValue(wxT("And this is a\n\tlabel inside the box with a &mnemonic.\n")
                           wxT("Only this text is affected by the ellipsize settings."));
     m_textLabelWithMarkup->SetValue(wxT("Another label, this time <b>decorated</b> ")
index 55f3b79cd1237218732ff3513567c6e9f53c226c..1058f381b91741d267ddba60b71d55c37a96d617 100644 (file)
@@ -512,18 +512,32 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc)
             PaintBackground(dc, dimensions);
         }
 
+        UINT drawTextFlags = DT_SINGLELINE | DT_VCENTER;
+
+        // determine the state of UI queues to draw the text correctly under XP
+        // and later systems
+        static const bool isXPorLater = wxGetWinVersion() >= wxWinVersion_XP;
+        if ( isXPorLater )
+        {
+            if ( ::SendMessage(GetHwnd(), WM_QUERYUISTATE, 0, 0) &
+                    UISF_HIDEACCEL )
+            {
+                drawTextFlags |= DT_HIDEPREFIX;
+            }
+        }
+
         // now draw the text
         if ( !rtl )
         {
             RECT rc2 = { x, 0, x + width, y };
             ::DrawText(hdc, label.wx_str(), label.length(), &rc2,
-                       DT_SINGLELINE | DT_VCENTER);
+                       drawTextFlags);
         }
         else // RTL
         {
             RECT rc2 = { x, 0, x - width, y };
             ::DrawText(hdc, label.wx_str(), label.length(), &rc2,
-                       DT_SINGLELINE | DT_VCENTER | DT_RTLREADING);
+                       drawTextFlags | DT_RTLREADING);
         }
     }
 }