]> git.saurik.com Git - wxWidgets.git/commitdiff
Windows XP appearance fixes for status and tool bars (bug 501585)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 28 Jan 2002 01:38:39 +0000 (01:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 28 Jan 2002 01:38:39 +0000 (01:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/settings.h
src/msw/settings.cpp
src/msw/statbr95.cpp
src/msw/tbar95.cpp

index 1f016ada334d0d1edfc08a30ef2fb333e4b5ddd2..b55c0a54ba77923252150b0c69c8ac0db690f749 100644 (file)
@@ -87,6 +87,7 @@ All (GUI):
 
 wxMSW:
 
+- small appearance fixes for native look under Windows XP
 - huge (40*) speed up in wxMask::Create() (=> much faster toolbar creation)
 - fixed flicker in wxTreeCtrl::SetItemXXX()
 - fixed redraw problems in dynamically resized wxStaticText
index 8266bce44076894d23b979b5e1ecb1d65acb0bf7..1d3248d2c8012ce2117a18f0fcaa7d4e6630462c 100644 (file)
@@ -39,6 +39,7 @@ enum wxSystemColour
 {
     wxSYS_COLOUR_SCROLLBAR,
     wxSYS_COLOUR_BACKGROUND,
+    wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
     wxSYS_COLOUR_ACTIVECAPTION,
     wxSYS_COLOUR_INACTIVECAPTION,
     wxSYS_COLOUR_MENU,
@@ -53,23 +54,28 @@ enum wxSystemColour
     wxSYS_COLOUR_HIGHLIGHT,
     wxSYS_COLOUR_HIGHLIGHTTEXT,
     wxSYS_COLOUR_BTNFACE,
+    wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
     wxSYS_COLOUR_BTNSHADOW,
+    wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
     wxSYS_COLOUR_GRAYTEXT,
     wxSYS_COLOUR_BTNTEXT,
     wxSYS_COLOUR_INACTIVECAPTIONTEXT,
     wxSYS_COLOUR_BTNHIGHLIGHT,
+    wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
+    wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
+    wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
     wxSYS_COLOUR_3DDKSHADOW,
     wxSYS_COLOUR_3DLIGHT,
     wxSYS_COLOUR_INFOTEXT,
     wxSYS_COLOUR_INFOBK,
     wxSYS_COLOUR_LISTBOX,
+    wxSYS_COLOUR_HOTLIGHT,
+    wxSYS_COLOUR_GRADIENTACTIVECAPTION,
+    wxSYS_COLOUR_GRADIENTINACTIVECAPTION,
+    wxSYS_COLOUR_MENUHILIGHT,
+    wxSYS_COLOUR_MENUBAR,
 
-    wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
-    wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
-    wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
-    wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
-    wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
-    wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT
+    wxSYS_COLOUR_MAX
 };
 
 // possible values for wxSystemSettings::GetMetric() parameter
index 3e55d24dfeed9f3f708062e43c36ac9efc5a2d17..85d8b311f4377f2ba7d334eee345d868b8880d1c 100644 (file)
@@ -97,9 +97,98 @@ void wxSystemSettingsModule::OnExit()
 
 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 {
-    wxColour col;
-    wxRGBToColour(col, ::GetSysColor(index));
-    return col;
+    // we use 0 as the default value just to avoid compiler warnings, as there
+    // is no invalid colour value we use hasCol as the real indicator of
+    // whether colSys was initialized or not
+    COLORREF colSys = 0;
+    bool hasCol = FALSE;
+
+    // the default colours for the entries after BTNHIGHLIGHT
+    static const COLORREF s_defaultSysColors[] =
+    {
+        0x000000,   // 3DDKSHADOW
+        0xdfdfdf,   // 3DLIGHT
+        0x000000,   // INFOTEXT
+        0xe1ffff,   // INFOBK
+
+        0,          // filler - no std colour with this index
+
+        // TODO: please fill in the standard values of those, I don't have them
+        0,          // HOTLIGHT
+        0,          // GRADIENTACTIVECAPTION
+        0,          // GRADIENTINACTIVECAPTION
+        0,          // MENU
+        0,          // MENUBAR (unused)
+    };
+
+    if ( index == wxSYS_COLOUR_LISTBOX )
+    {
+        // there is no standard colour with this index, map to another one
+        index = wxSYS_COLOUR_WINDOW;
+    }
+    else if ( index > wxSYS_COLOUR_BTNHIGHLIGHT )
+    {
+        // the indices before BTNHIGHLIGHT are understood by GetSysColor() in
+        // all Windows version, for the other ones we have to check
+        bool useDefault;
+
+        // none of the is supported under Win16 anyhow
+#ifdef __WIN32__
+        int verMaj, verMin;
+        wxGetOsVersion(&verMaj, &verMin);
+        if ( verMaj < 4 )
+        {
+            // NT 3.5
+            useDefault = TRUE;
+        }
+        else if ( verMaj == 4 )
+        {
+            // Win95/NT 4.0
+            useDefault = index > wxSYS_COLOUR_INFOBK;
+        }
+        else if ( verMaj == 5 && verMin == 0 )
+        {
+            // Win98/Win2K
+            useDefault = index > wxSYS_COLOUR_GRADIENTINACTIVECAPTION;
+        }
+        else // >= 5.1
+        {
+            // 5.1 is Windows XP
+            useDefault = FALSE;
+        }
+#else
+        useDefault = TRUE;
+#endif // __WIN32__
+
+        if ( useDefault )
+        {
+            // special handling for MENUBAR colour: we use this in wxToolBar
+            // and wxStatusBar to have correct bg colour under Windows XP
+            // (which uses COLOR_MENUBAR for them) but they should still look
+            // correctly under previous Windows versions as well
+            if ( index == wxSYS_COLOUR_MENUBAR )
+            {
+                index = wxSYS_COLOUR_3DFACE;
+            }
+            else // replace with default colour
+            {
+                int n = index - wxSYS_COLOUR_BTNHIGHLIGHT;
+
+                wxASSERT_MSG( n < WXSIZEOF(s_defaultSysColors),
+                              _T("forgot tp update the default colours array") );
+
+                colSys = s_defaultSysColors[n];
+                hasCol = TRUE;
+            }
+        }
+    }
+
+    if ( !hasCol )
+    {
+        colSys = ::GetSysColor(index);
+    }
+
+    return wxRGBToColour(colSys);
 }
 
 // ----------------------------------------------------------------------------
index 5889081a5f904cf7d8c99d05cd03599b01ce34e5..45d66c2fcf10d022a20c38b8ca0f4f31b5bb07b5 100644 (file)
@@ -115,6 +115,8 @@ bool wxStatusBar95::Create(wxWindow *parent,
     SetFieldsCount(1);
     SubclassWin(m_hWnd);
 
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR));
+
     return TRUE;
 }
 
index 758426c5a53c6f525d9e2c7c83687c71274d08ec..0a8217a9ddfe82d0a1f5c37a79f1fc71a0158fea 100644 (file)
@@ -96,7 +96,6 @@
     #define TBSTYLE_FLAT            0x0800
     #define TBSTYLE_TRANSPARENT     0x8000
 #endif
- // use TBSTYLE_TRANSPARENT if you use TBSTYLE_FLAT
 
 // Messages
 #ifndef TB_GETSTYLE
@@ -232,8 +231,17 @@ bool wxToolBar::Create(wxWindow *parent,
 
     if (style & wxTB_FLAT)
     {
-        if (wxTheApp->GetComCtl32Version() > 400)
-            msflags |= TBSTYLE_FLAT;
+        // static as it doesn't change during the program lifetime
+        static int s_verComCtl = wxTheApp->GetComCtl32Version();
+
+        // comctl32.dll 4.00 doesn't support the flat toolbars and using this
+        // style with 6.00 (part of Windows XP) leads to the toolbar with
+        // incorrect background colour - and not using it still results in the
+        // correct (flat) toolbar, so don't use it there
+        if ( s_verComCtl > 400 && s_verComCtl < 600 )
+        {
+            msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT;
+        }
     }
 
     // MSW-specific initialisation
@@ -244,9 +252,7 @@ bool wxToolBar::Create(wxWindow *parent,
     ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
 
     // set up the colors and fonts
-    wxRGBToColour(m_backgroundColour, GetSysColor(COLOR_BTNFACE));
-    m_foregroundColour = *wxBLACK;
-
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR));
     SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
 
     // position it