]> git.saurik.com Git - wxWidgets.git/commitdiff
moved Arrow_ constants to the base class
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 Sep 2006 15:38:18 +0000 (15:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 Sep 2006 15:38:18 +0000 (15:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/univ/stdrend.h
src/univ/stdrend.cpp
src/univ/themes/win32.cpp

index 5248bfb5f9390baaf83f779a1d17dda4cf400397..9acd6e31bf33f141834244372f8b2a252d79177d 100644 (file)
@@ -104,6 +104,13 @@ public:
                                  wxAlignment align = wxALIGN_LEFT,
                                  int indexAccel = -1);
 
+    virtual void DrawScrollbarArrow(wxDC& dc,
+                                    wxDirection dir,
+                                    const wxRect& rect,
+                                    int flags = 0);
+    virtual void DrawScrollCorner(wxDC& dc,
+                                  const wxRect& rect);
+
 #if wxUSE_TEXTCTRL
     virtual void DrawTextLine(wxDC& dc,
                               const wxString& text,
@@ -142,6 +149,25 @@ public:
 
 protected:
     // various constants
+    enum ArrowDirection
+    {
+        Arrow_Left,
+        Arrow_Right,
+        Arrow_Up,
+        Arrow_Down,
+        Arrow_Max
+    };
+
+    enum ArrowStyle
+    {
+        Arrow_Normal,
+        Arrow_Disabled,
+        Arrow_Pressed,
+        Arrow_Inverted,
+        Arrow_InvertedDisabled,
+        Arrow_StateMax
+    };
+
     enum IndicatorType
     {
         IndicatorType_Check,
@@ -177,6 +203,10 @@ protected:
                                        IndicatorState& state,
                                        IndicatorStatus& status);
 
+    // translate wxDirection to ArrowDirection
+    static ArrowDirection GetArrowDirection(wxDirection dir);
+
+
     // fill the rectangle with a brush of given colour (must be valid)
     void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);
 
index 771b3a9052b42d9a1e1d4858506ef9602583fa55..14e2395353e109cf50e4e6e23dfeab07993fc4e0 100644 (file)
@@ -89,6 +89,55 @@ void wxStdRenderer::DrawShadedRect(wxDC& dc, wxRect *rect,
     rect->Inflate(-1);
 }
 
+// ----------------------------------------------------------------------------
+// translate various flags into corresponding renderer constants
+// ----------------------------------------------------------------------------
+
+/* static */
+void wxStdRenderer::GetIndicatorsFromFlags(int flags,
+                                           IndicatorState& state,
+                                           IndicatorStatus& status)
+{
+    if ( flags & wxCONTROL_SELECTED )
+        state = flags & wxCONTROL_DISABLED ? IndicatorState_SelectedDisabled
+                                           : IndicatorState_Selected;
+    else if ( flags & wxCONTROL_DISABLED )
+        state = IndicatorState_Disabled;
+    else if ( flags & wxCONTROL_PRESSED )
+        state = IndicatorState_Pressed;
+    else
+        state = IndicatorState_Normal;
+
+    status = flags & wxCONTROL_CHECKED ? IndicatorStatus_Checked
+                                       : flags & wxCONTROL_UNDETERMINED
+                                            ? IndicatorStatus_Undetermined
+                                            : IndicatorStatus_Unchecked;
+}
+
+/* static */
+wxStdRenderer::ArrowDirection wxStdRenderer::GetArrowDirection(wxDirection dir)
+{
+    switch ( dir )
+    {
+        case wxLEFT:
+            return Arrow_Left;
+
+        case wxRIGHT:
+            return Arrow_Right;
+
+        case wxUP:
+            return Arrow_Up;
+
+        case wxDOWN:
+            return Arrow_Down;
+
+        default:
+            wxFAIL_MSG(_T("unknown arrow direction"));
+    }
+
+    return Arrow_Max;
+}
+
 // ----------------------------------------------------------------------------
 // background
 // ----------------------------------------------------------------------------
@@ -560,27 +609,6 @@ void wxStdRenderer::DrawCheckItem(wxDC& dc,
 // check and radio bitmaps
 // ----------------------------------------------------------------------------
 
-/* static */
-void wxStdRenderer::GetIndicatorsFromFlags(int flags,
-                                           IndicatorState& state,
-                                           IndicatorStatus& status)
-{
-    if ( flags & wxCONTROL_SELECTED )
-        state = flags & wxCONTROL_DISABLED ? IndicatorState_SelectedDisabled
-                                           : IndicatorState_Selected;
-    else if ( flags & wxCONTROL_DISABLED )
-        state = IndicatorState_Disabled;
-    else if ( flags & wxCONTROL_PRESSED )
-        state = IndicatorState_Pressed;
-    else
-        state = IndicatorState_Normal;
-
-    status = flags & wxCONTROL_CHECKED ? IndicatorStatus_Checked
-                                       : flags & wxCONTROL_UNDETERMINED
-                                            ? IndicatorStatus_Undetermined
-                                            : IndicatorStatus_Unchecked;
-}
-
 void wxStdRenderer::DrawCheckButton(wxDC& dc,
                                     const wxString& label,
                                     const wxBitmap& bitmap,
@@ -738,6 +766,23 @@ wxRect wxStdRenderer::GetTextClientArea(const wxTextCtrl *text,
 
 #endif // wxUSE_TEXTCTRL
 
+// ----------------------------------------------------------------------------
+// scrollbars drawing
+// ----------------------------------------------------------------------------
+
+void wxStdRenderer::DrawScrollbarArrow(wxDC& dc,
+                                       wxDirection dir,
+                                       const wxRect& rect,
+                                       int flags)
+{
+    DrawArrow(dc, dir, rect, flags);
+}
+
+void wxStdRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
+{
+    DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
+}
+
 // ----------------------------------------------------------------------------
 // scrollbars geometry
 // ----------------------------------------------------------------------------
index 99919f87d1aa7d01dd79f3743316cca2155df77d..cca5284673b955d370ccf7c6a03cfbd63ed40ccc 100644 (file)
@@ -98,26 +98,6 @@ static const wxCoord SLIDER_TICK_LENGTH = 6;
 class wxWin32Renderer : public wxStdRenderer
 {
 public:
-    // constants
-    enum wxArrowDirection
-    {
-        Arrow_Left,
-        Arrow_Right,
-        Arrow_Up,
-        Arrow_Down,
-        Arrow_Max
-    };
-
-    enum wxArrowStyle
-    {
-        Arrow_Normal,
-        Arrow_Disabled,
-        Arrow_Pressed,
-        Arrow_Inverted,
-        Arrow_InvertedDisabled,
-        Arrow_StateMax
-    };
-
     enum wxFrameButtonType
     {
         FrameButton_Close,
@@ -151,15 +131,11 @@ public:
                                   const wxRect& rect,
                                   int flags = 0,
                                   wxRect *rectIn = NULL);
+
     virtual void DrawArrow(wxDC& dc,
                            wxDirection dir,
                            const wxRect& rect,
                            int flags = 0);
-    virtual void DrawScrollbarArrow(wxDC& dc,
-                                    wxDirection dir,
-                                    const wxRect& rect,
-                                    int flags = 0)
-        { DrawArrow(dc, dir, rect, flags); }
     virtual void DrawScrollbarThumb(wxDC& dc,
                                     wxOrientation orient,
                                     const wxRect& rect,
@@ -168,8 +144,6 @@ public:
                                     wxOrientation orient,
                                     const wxRect& rect,
                                     int flags = 0);
-    virtual void DrawScrollCorner(wxDC& dc,
-                                  const wxRect& rect);
 
 #if wxUSE_TOOLBAR
     virtual void DrawToolBarButton(wxDC& dc,
@@ -357,12 +331,12 @@ protected:
 
     // public DrawArrow()s helper
     void DrawArrow(wxDC& dc, const wxRect& rect,
-                   wxArrowDirection arrowDir, wxArrowStyle arrowStyle);
+                   ArrowDirection arrowDir, ArrowStyle arrowStyle);
 
     // DrawArrowButton is used by DrawScrollbar and DrawComboButton
     void DrawArrowButton(wxDC& dc, const wxRect& rect,
-                         wxArrowDirection arrowDir,
-                         wxArrowStyle arrowStyle);
+                         ArrowDirection arrowDir,
+                         ArrowStyle arrowStyle);
 
     // draw a normal or transposed line (useful for using the same code fo both
     // horizontal and vertical widgets)
@@ -1744,7 +1718,7 @@ wxBitmap wxWin32Renderer::GetIndicator(IndicatorType indType, int flags)
     IndicatorStatus indStatus;
     GetIndicatorsFromFlags(flags, indState, indStatus);
 
-    wxBitmap bmp = m_bmpIndicators[indType][indState][indStatus];
+    wxBitmap& bmp = m_bmpIndicators[indType][indState][indStatus];
     if ( !bmp.Ok() )
     {
         const char **xpm = ms_xpmIndicators[indType][indState][indStatus];
@@ -1752,7 +1726,6 @@ wxBitmap wxWin32Renderer::GetIndicator(IndicatorType indType, int flags)
         {
             // create and cache it
             bmp = wxBitmap(xpm);
-            m_bmpIndicators[indType][indState][indStatus] = bmp;
         }
     }
 
@@ -2512,7 +2485,7 @@ void wxWin32Renderer::DrawMenuItem(wxDC& dc,
         rect.x = geometryInfo.GetSize().x - MENU_RIGHT_MARGIN;
         rect.width = MENU_RIGHT_MARGIN;
 
-        wxArrowStyle arrowStyle;
+        ArrowStyle arrowStyle;
         if ( flags & wxCONTROL_DISABLED )
             arrowStyle = flags & wxCONTROL_SELECTED ? Arrow_InvertedDisabled
                                                     : Arrow_Disabled;
@@ -2800,21 +2773,7 @@ void wxWin32Renderer::DrawArrow(wxDC& dc,
                                 const wxRect& rect,
                                 int flags)
 {
-    // get the bitmap for this arrow
-    wxArrowDirection arrowDir;
-    switch ( dir )
-    {
-        case wxLEFT:    arrowDir = Arrow_Left; break;
-        case wxRIGHT:   arrowDir = Arrow_Right; break;
-        case wxUP:      arrowDir = Arrow_Up; break;
-        case wxDOWN:    arrowDir = Arrow_Down; break;
-
-        default:
-            wxFAIL_MSG(_T("unknown arrow direction"));
-            return;
-    }
-
-    wxArrowStyle arrowStyle;
+    ArrowStyle arrowStyle;
     if ( flags & wxCONTROL_PRESSED )
     {
         // can't be pressed and disabled
@@ -2825,13 +2784,13 @@ void wxWin32Renderer::DrawArrow(wxDC& dc,
         arrowStyle = flags & wxCONTROL_DISABLED ? Arrow_Disabled : Arrow_Normal;
     }
 
-    DrawArrowButton(dc, rect, arrowDir, arrowStyle);
+    DrawArrowButton(dc, rect, GetArrowDirection(dir), arrowStyle);
 }
 
 void wxWin32Renderer::DrawArrow(wxDC& dc,
                                 const wxRect& rect,
-                                wxArrowDirection arrowDir,
-                                wxArrowStyle arrowStyle)
+                                ArrowDirection arrowDir,
+                                ArrowStyle arrowStyle)
 {
     const wxBitmap& bmp = m_bmpArrows[arrowStyle][arrowDir];
 
@@ -2850,8 +2809,8 @@ void wxWin32Renderer::DrawArrow(wxDC& dc,
 
 void wxWin32Renderer::DrawArrowButton(wxDC& dc,
                                       const wxRect& rectAll,
-                                      wxArrowDirection arrowDir,
-                                      wxArrowStyle arrowStyle)
+                                      ArrowDirection arrowDir,
+                                      ArrowStyle arrowStyle)
 {
     wxRect rect = rectAll;
     DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
@@ -2881,11 +2840,6 @@ void wxWin32Renderer::DrawScrollbarShaft(wxDC& dc,
     DrawBackground(dc, m_scheme->Get(col), rectBar);
 }
 
-void wxWin32Renderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
-{
-    DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
-}
-
 // ----------------------------------------------------------------------------
 // top level windows
 // ----------------------------------------------------------------------------