]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/renderer.cpp
fix more Borland release build warnings about unused variable/code without effect
[wxWidgets.git] / src / msw / renderer.cpp
index 2a63a4b0b5f2f3af1f8b5e54d8f3a7582734bf6e..c2b4173972b7683b7858a3771978a98d409e74e4 100644 (file)
     #include "wx/settings.h"
 #endif //WX_PRECOMP
 
     #include "wx/settings.h"
 #endif //WX_PRECOMP
 
+#include "wx/scopeguard.h"
 #include "wx/splitter.h"
 #include "wx/renderer.h"
 #include "wx/msw/private.h"
 #include "wx/splitter.h"
 #include "wx/renderer.h"
 #include "wx/msw/private.h"
+#include "wx/msw/dc.h"
 #include "wx/msw/uxtheme.h"
 
 // tmschema.h is in Win32 Platform SDK and might not be available with earlier
 #include "wx/msw/uxtheme.h"
 
 // tmschema.h is in Win32 Platform SDK and might not be available with earlier
     #define HSAS_SORTEDDOWN     2
 #endif
 
     #define HSAS_SORTEDDOWN     2
 #endif
 
-#if defined(__WXWINCE__) && !defined(DFCS_FLAT)
-    #define DFCS_FLAT 0
+#if defined(__WXWINCE__)
+    #ifndef DFCS_FLAT
+        #define DFCS_FLAT 0
+    #endif
+    #ifndef DFCS_MONO
+        #define DFCS_MONO 0
+    #endif
 #endif
 
 #ifndef DFCS_HOT
 #endif
 
 #ifndef DFCS_HOT
@@ -110,6 +117,15 @@ public:
                                 const wxRect& rect,
                                 int flags = 0);
 
                                 const wxRect& rect,
                                 int flags = 0);
 
+    virtual void DrawFocusRect(wxWindow* win,
+                               wxDC& dc,
+                               const wxRect& rect,
+                               int flags = 0);
+
+    virtual wxSize GetCheckBoxSize(wxWindow *win);
+
+    virtual int GetHeaderButtonHeight(wxWindow *win);
+
 private:
     DECLARE_NO_COPY_CLASS(wxRendererMSW)
 };
 private:
     DECLARE_NO_COPY_CLASS(wxRendererMSW)
 };
@@ -133,7 +149,6 @@ public:
                                   int flags = 0,
                                   wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params = NULL);
                                   int flags = 0,
                                   wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params = NULL);
-    virtual int GetHeaderButtonHeight(wxWindow *win);
 
     virtual void DrawTreeItemButton(wxWindow *win,
                                     wxDC& dc,
 
     virtual void DrawTreeItemButton(wxWindow *win,
                                     wxDC& dc,
@@ -207,10 +222,7 @@ wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
                                       int flags)
 {
     RECT r;
                                       int flags)
 {
     RECT r;
-    r.left = rect.GetLeft();
-    r.top = rect.GetTop();
-    r.bottom = rect.y + rect.height;
-    r.right = rect.x + rect.width;
+    wxCopyRectToRECT(rect, r);
 
     int style = DFCS_SCROLLCOMBOBOX;
     if ( flags & wxCONTROL_DISABLED )
 
     int style = DFCS_SCROLLCOMBOBOX;
     if ( flags & wxCONTROL_DISABLED )
@@ -218,7 +230,7 @@ wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
     if ( flags & wxCONTROL_PRESSED )
         style |= DFCS_PUSHED | DFCS_FLAT;
 
     if ( flags & wxCONTROL_PRESSED )
         style |= DFCS_PUSHED | DFCS_FLAT;
 
-    ::DrawFrameControl(GetHdcOf(dc), &r, DFC_SCROLL, style);
+    ::DrawFrameControl(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &r, DFC_SCROLL, style);
 }
 
 void
 }
 
 void
@@ -235,12 +247,14 @@ wxRendererMSW::DrawCheckBox(wxWindow * WXUNUSED(win),
         style |= DFCS_CHECKED;
     if ( flags & wxCONTROL_DISABLED )
         style |= DFCS_INACTIVE;
         style |= DFCS_CHECKED;
     if ( flags & wxCONTROL_DISABLED )
         style |= DFCS_INACTIVE;
+    if ( flags & wxCONTROL_FLAT )
+        style |= DFCS_MONO;
     if ( flags & wxCONTROL_PRESSED )
         style |= DFCS_PUSHED;
     if ( flags & wxCONTROL_CURRENT )
         style |= DFCS_HOT;
 
     if ( flags & wxCONTROL_PRESSED )
         style |= DFCS_PUSHED;
     if ( flags & wxCONTROL_CURRENT )
         style |= DFCS_HOT;
 
-    ::DrawFrameControl(GetHdcOf(dc), &r, DFC_BUTTON, style);
+    ::DrawFrameControl(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &r, DFC_BUTTON, style);
 }
 
 void
 }
 
 void
@@ -269,7 +283,47 @@ wxRendererMSW::DrawPushButton(wxWindow * WXUNUSED(win),
     RECT rc;
     wxCopyRectToRECT(rect, rc);
 
     RECT rc;
     wxCopyRectToRECT(rect, rc);
 
-    ::DrawFrameControl(GetHdcOf(dc), &rc, DFC_BUTTON, style);
+    ::DrawFrameControl(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &rc, DFC_BUTTON, style);
+}
+
+void wxRendererMSW::DrawFocusRect(wxWindow * WXUNUSED(win),
+                                  wxDC& dc,
+                                  const wxRect& rect,
+                                  int WXUNUSED(flags))
+{
+    RECT rc;
+    wxCopyRectToRECT(rect, rc);
+
+    ::DrawFocusRect(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &rc);
+}
+
+wxSize wxRendererMSW::GetCheckBoxSize(wxWindow * WXUNUSED(win))
+{
+    return wxSize(::GetSystemMetrics(SM_CXMENUCHECK),
+                  ::GetSystemMetrics(SM_CYMENUCHECK));
+}
+
+int wxRendererMSW::GetHeaderButtonHeight(wxWindow * WXUNUSED(win))
+{
+    // some "reasonable" value returned in case of error, it doesn't really
+    // correspond to anything but it's better than returning 0
+    static const int DEFAULT_HEIGHT = 20;
+
+
+    // create a temporary header window just to get its geometry
+    HWND hwndHeader = ::CreateWindow(WC_HEADER, NULL, 0,
+                                     0, 0, 0, 0, NULL, NULL, NULL, NULL);
+    if ( !hwndHeader )
+        return DEFAULT_HEIGHT;
+
+    wxON_BLOCK_EXIT1( ::DestroyWindow, hwndHeader );
+
+    // initialize the struct filled with the values by Header_Layout()
+    RECT parentRect = { 0, 0, 100, 100 };
+    WINDOWPOS wp = { 0, 0, 0, 0, 0, 0, 0 };
+    HDLAYOUT hdl = { &parentRect, &wp };
+
+    return Header_Layout(hwndHeader, &hdl) ? wp.cy : DEFAULT_HEIGHT;
 }
 
 // ============================================================================
 }
 
 // ============================================================================
@@ -318,7 +372,7 @@ wxRendererXP::DrawComboBoxDropButton(wxWindow * win,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
-                                GetHdcOf(dc),
+                                GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
                                 CP_DROPDOWNBUTTON,
                                 state,
                                 &r,
                                 CP_DROPDOWNBUTTON,
                                 state,
                                 &r,
@@ -354,7 +408,7 @@ wxRendererXP::DrawHeaderButton(wxWindow *win,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
-                                GetHdcOf(dc),
+                                GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
                                 HP_HEADERITEM,
                                 state,
                                 &r,
                                 HP_HEADERITEM,
                                 state,
                                 &r,
@@ -370,31 +424,6 @@ wxRendererXP::DrawHeaderButton(wxWindow *win,
 }
 
 
 }
 
 
-int
-wxRendererXP::GetHeaderButtonHeight(wxWindow *win)
-{
-    wxUxThemeHandle hTheme(win, L"HEADER");
-    if ( !hTheme )
-    {
-        return m_rendererNative.GetHeaderButtonHeight(win);
-    }
-
-    HRESULT hr;
-    int value = -1;
-
-    hr = wxUxThemeEngine::Get()->GetThemeMetric( hTheme,
-                                                 NULL,
-                                                 HP_HEADERITEM,
-                                                 HIS_NORMAL,
-                                                 TMT_HEIGHT,
-                                                 &value );
-    if ( hr == S_OK )
-        return value;
-    else
-        return 20;
-}
-
-
 void
 wxRendererXP::DrawTreeItemButton(wxWindow *win,
                                  wxDC& dc,
 void
 wxRendererXP::DrawTreeItemButton(wxWindow *win,
                                  wxDC& dc,
@@ -415,7 +444,7 @@ wxRendererXP::DrawTreeItemButton(wxWindow *win,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
-                                GetHdcOf(dc),
+                                GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
                                 TVP_GLYPH,
                                 state,
                                 &r,
                                 TVP_GLYPH,
                                 state,
                                 &r,
@@ -465,7 +494,7 @@ wxRendererXP::DrawCheckBox(wxWindow *win,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
-                                GetHdcOf(dc),
+                                GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
                                 BP_CHECKBOX,
                                 state,
                                 &r,
                                 BP_CHECKBOX,
                                 state,
                                 &r,
@@ -504,7 +533,7 @@ wxRendererXP::DrawPushButton(wxWindow * win,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
-                                GetHdcOf(dc),
+                                GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
                                 BP_PUSHBUTTON,
                                 state,
                                 &r,
                                 BP_PUSHBUTTON,
                                 state,
                                 &r,
@@ -514,7 +543,7 @@ wxRendererXP::DrawPushButton(wxWindow * win,
 }
 
 void
 }
 
 void
-wxRendererXP::DrawItemSelectionRect(wxWindow * WXUNUSED(win),
+wxRendererXP::DrawItemSelectionRect(wxWindow *win,
                                     wxDC& dc,
                                     const wxRect& rect,
                                     int flags)
                                     wxDC& dc,
                                     const wxRect& rect,
                                     int flags)
@@ -528,7 +557,7 @@ wxRendererXP::DrawItemSelectionRect(wxWindow * WXUNUSED(win),
         }
         else // !focused
         {
         }
         else // !focused
         {
-            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
+            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
         }
     }
     else // !selected
         }
     }
     else // !selected
@@ -537,12 +566,11 @@ wxRendererXP::DrawItemSelectionRect(wxWindow * WXUNUSED(win),
     }
 
     dc.SetBrush(brush);
     }
 
     dc.SetBrush(brush);
-
-    // unlike for wxRendererGeneric, on windows we _never_ want to draw
-    // the outline of the rectangle:
     dc.SetPen(*wxTRANSPARENT_PEN);
     dc.SetPen(*wxTRANSPARENT_PEN);
-
     dc.DrawRectangle( rect );
     dc.DrawRectangle( rect );
+
+    if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT))
+        DrawFocusRect( win, dc, rect, flags );
 }
 
 
 }