]> git.saurik.com Git - wxWidgets.git/commitdiff
As per wx-dev, split the sort arrow options out to a separate parameter.
authorRobin Dunn <robin@alldunn.com>
Thu, 14 Sep 2006 19:42:41 +0000 (19:42 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 14 Sep 2006 19:42:41 +0000 (19:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41230 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/renderer.tex
include/wx/renderer.h
include/wx/univ/renderer.h
src/generic/renderg.cpp
src/gtk/renderer.cpp
src/mac/carbon/renderer.cpp
src/msw/renderer.cpp
wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp
wxPython/src/_renderer.i

index 7bb7e91223b7b265e1eef0810d96d60a5bd81144..3524cd8aeeacca09bc1ecf78c4a1ab2218a1d51e 100644 (file)
@@ -19,7 +19,7 @@ However not all controls exist under all (or even any) platforms and in this
 case wxWidgets provides a default, generic, implementation of them written in
 wxWidgets itself.
 
-These controls don't have the native appearance if only the standard
+These controls don't have the native appearance if only the tandard
 line drawing and other graphics primitives are used, because the native
 appearance is different under different platforms while the lines are always
 drawn in the same way.
@@ -75,9 +75,6 @@ enum
     wxCONTROL_CHECKED    = 0x00000040,  // (check/radio button) is checked
     wxCONTROL_CHECKABLE  = 0x00000080,  // (menu) item can be checked
     wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE  // (check) undetermined state
-    wxCONTROL_UPICON     = 0x00000100,  // header button has an up arrow icon
-    wxCONTROL_DOWNICON   = 0x00000200,  // header button has a down arrow icon
-
 };
 \end{verbatim}
 
@@ -134,9 +131,16 @@ rectangle of a drop down button which arrow matches the size you need.
 
 \membersection{wxRendererNative::DrawHeaderButton}\label{wxrenderernativedrawheaderbutton}
 
-\func{void}{DrawHeaderButton}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}, \param{wxHeaderButtonParams* }{params = NULL}}
+\func{void}{DrawHeaderButton}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}, \param{wxHeaderSortIconType }{sortArrow = wxHDR\_SORT\_ICON\_NONE}, \param{wxHeaderButtonParams* }{params = NULL}}
 
-Draw the header control button (used by \helpref{wxListCtrl}{wxlistctrl}).
+Draw the header control button (used, for example, by
+\helpref{wxListCtrl}{wxlistctrl}).  Depending on platforms the
+\arg{flags} parameter may support the \texttt{wxCONTROL\_SELECTED}
+\texttt{wxCONTROL\_DISABLED} and \texttt{wxCONTROL\_CURRENT} bits.
+The \arg{sortArrow} parameter can be one of
+\texttt{wxHDR\_SORT\_ICON\_NONE}, \texttt{wxHDR\_SORT\_ICON\_UP}, or 
+\texttt{wxHDR\_SORT\_ICON\_DOWN}.  Additional values controlling the
+drawing of a text or bitmap label can be passed in \arg{params}.
 
 
 \membersection{wxRendererNative::DrawPushButton}\label{wxrenderernativedrawpushbutton}
index 4fbcf21b1979b950a39005ff0cb2d0871d151001..82ca8ce7ce115255a607ec7cd999984921eff941 100644 (file)
@@ -59,10 +59,8 @@ enum
     wxCONTROL_CHECKED    = 0x00000040,  // (check/radio button) is checked
     wxCONTROL_CHECKABLE  = 0x00000080,  // (menu) item can be checked
     wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE, // (check) undetermined state
-    wxCONTROL_UPICON     = 0x00000100,  // header button has an up arrow icon
-    wxCONTROL_DOWNICON   = 0x00000200,  // header button has a down arrow icon
 
-    wxCONTROL_FLAGS_MASK = 0x000002ff,
+    wxCONTROL_FLAGS_MASK = 0x000000ff,
 
     // this is a pseudo flag not used directly by wxRenderer but rather by some
     // controls internally
@@ -109,6 +107,12 @@ struct WXDLLEXPORT wxHeaderButtonParams
     int         m_labelAlignment;
 };
 
+enum wxHeaderSortIconType {
+    wxHDR_SORT_ICON_NONE,        // Header button has no sort arrow
+    wxHDR_SORT_ICON_UP,          // Header button an an up sort arrow icon
+    wxHDR_SORT_ICON_DOWN         // Header button an a down sort arrow icon
+};
+
 
 // wxRendererNative interface version
 struct WXDLLEXPORT wxRendererVersion
@@ -156,6 +160,7 @@ public:
                                   wxDC& dc,
                                   const wxRect& rect,
                                   int flags = 0,
+                                  wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params=NULL) = 0;
 
 
@@ -165,6 +170,7 @@ public:
                                           wxDC& dc,
                                           const wxRect& rect,
                                           int flags = 0,
+                                          wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                           wxHeaderButtonParams* params=NULL) = 0;
 
     // Returns the default height of a header button, either a fixed platform
@@ -304,17 +310,17 @@ public:
                                   wxDC& dc,
                                   const wxRect& rect,
                                   int flags = 0,
+                                  wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params = NULL)
-        { m_rendererNative.DrawHeaderButton(win, dc, rect, flags, params); }
-
+        { m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params); }
 
     virtual void DrawHeaderButtonContents(wxWindow *win,
                                           wxDC& dc,
                                           const wxRect& rect,
                                           int flags = 0,
+                                          wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                           wxHeaderButtonParams* params = NULL)
-        { m_rendererNative.DrawHeaderButtonContents(win, dc, rect, flags, params); }
-
+        { m_rendererNative.DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params); }
 
     virtual int GetHeaderButtonHeight(wxWindow *win)
         { return m_rendererNative.GetHeaderButtonHeight(win); }
index c2ba148e262c321b797eea31bc113d704abd0bbb..60ac8bb934f32ac81ef8d363ab62f1809435632a 100644 (file)
@@ -889,8 +889,9 @@ public:
                                   wxDC& dc,
                                   const wxRect& rect,
                                   int flags = 0,
+                                  wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params=NULL)
-        { m_renderer->DrawHeaderButton(win, dc, rect, flags, params); }
+        { m_renderer->DrawHeaderButton(win, dc, rect, flags, sortArrow, params); }
     virtual void DrawTreeItemButton(wxWindow *win,
                                     wxDC& dc,
                                     const wxRect& rect,
index 6f84f6b90446429f2f3c82cbf7ee410188f3a584..758e36f472fdaa9d1717f82c5fb55f4f1ac129af 100644 (file)
@@ -50,12 +50,14 @@ public:
                                   wxDC& dc,
                                   const wxRect& rect,
                                   int flags = 0,
+                                  wxHBSortIconType sortArrow = wxHB_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params = NULL);
 
     virtual void DrawHeaderButtonContents(wxWindow *win,
                                           wxDC& dc,
                                           const wxRect& rect,
                                           int flags = 0,
+                                          wxHBSortIconType sortArrow = wxHB_SORT_ICON_NONE,
                                           wxHeaderButtonParams* params = NULL);
 
     virtual int GetHeaderButtonHeight(wxWindow *win);
@@ -207,6 +209,7 @@ wxRendererGeneric::DrawHeaderButton(wxWindow* win,
                                     wxDC& dc,
                                     const wxRect& rect,
                                     int flags,
+                                    wxHeaderSortIconType sortArrow,
                                     wxHeaderButtonParams* params)
 {
     const int CORNER = 1;
@@ -236,14 +239,16 @@ wxRendererGeneric::DrawHeaderButton(wxWindow* win,
     dc.DrawLine( x, y+h-1, x+1, y+h-1 );
     dc.DrawLine( x+w-1, y, x+w-1, y+1 );
 
-    DrawHeaderButtonContents(win, dc, rect, flags, params);
+    DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
 }
 
+
 void
 wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
                                             wxDC& dc,
                                             const wxRect& rect,
                                             int flags,
+                                            wxHeaderSortIconType sortArrow,
                                             wxHeaderButtonParams* params)
 {
     // Mark this item as selected.  For the generic version we'll just draw an
@@ -264,7 +269,7 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
 
     // Draw an up or down arrow
     int arrowSpace = 0;
-    if (flags & (wxCONTROL_UPICON | wxCONTROL_DOWNICON) )
+    if (sortArrow != wxHDR_SORT_ICON_NONE )
     {
         wxRect ar = rect;
 
@@ -276,7 +281,7 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
         arrowSpace = 3*ar.width/2; // space to preserve when drawing the label
         
         wxPoint triPt[3];
-        if ( flags & wxCONTROL_UPICON )
+        if ( sortArrow & wxHDR_SORT_ICON_UP )
         {
             triPt[0].x = ar.width / 2;
             triPt[0].y = 0;
index 133f7af1cf1537b6ecc27d7db3953b41802b303d..2c8c94ee1e4a269ad02aa70eb7ead03b8ff97330 100644 (file)
@@ -47,6 +47,7 @@ public:
                                   wxDC& dc,
                                   const wxRect& rect,
                                   int flags = 0,
+                                  wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params = NULL);
 
     // draw the expanded/collapsed icon for a tree control item
@@ -185,6 +186,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
                                 wxDC& dc,
                                 const wxRect& rect,
                                 int flags,
+                                wxHeaderSortIconType sortArrow,
                                 wxHeaderButtonParams* params)
 {
 
@@ -208,7 +210,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
         dc.LogicalToDeviceX(rect.x) - x_diff, rect.y, rect.width, rect.height
     );
 
-    DrawHeaderButtonContents(win, dc, rect, flags, params);
+    DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
 }
 
 // draw a ">" or "v" button
index ee4ec9022da75bdb4fec543d67bd55f31a995536..802ff8a81e08d6b2c29a86e5c7686168553b537e 100644 (file)
@@ -37,6 +37,7 @@ public:
         wxDC& dc,
         const wxRect& rect,
         int flags = 0,
+        wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
         wxHeaderButtonParams* params = NULL );
 
     virtual int GetHeaderButtonHeight(wxWindow *win);
@@ -129,6 +130,7 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win,
     wxDC& dc,
     const wxRect& rect,
     int flags,
+    wxHeaderSortIconType sortArrow,
     wxHeaderButtonParams* params )
 {
     const wxCoord x = dc.XLOG2DEV(rect.x /*- 1*/);
@@ -185,13 +187,13 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win,
             drawInfo.adornment = kThemeAdornmentNone;
 
             // The down arrow is drawn automatically, change it to an up arrow if needed.
-            if ( flags & wxCONTROL_UPICON )
+            if ( sortArrow == wxHDR_SORT_ICON_UP )
                 drawInfo.adornment = kThemeAdornmentHeaderButtonSortUp;
                 
             HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
 
             // If we don't want any arrows we need to draw over the one already there
-            if ( (flags & wxCONTROL_SELECTED) && !(flags & (wxCONTROL_UPICON|wxCONTROL_DOWNICON)) )
+            if ( (flags & wxCONTROL_SELECTED) && (sortArrow == wxHDR_SORT_ICON_NONE) )
             {
                 // clip to the header rectangle
                 CGContextSaveGState( cgContext );
@@ -212,13 +214,14 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win,
     // Reserve room for the arrows before writing the label, and turn off the
     // flags we've already handled
     wxRect newRect(rect);
-    if ( (flags & wxCONTROL_SELECTED) && (flags & (wxCONTROL_UPICON|wxCONTROL_DOWNICON)) )
+    if ( (flags & wxCONTROL_SELECTED) && (sortArrow != wxHDR_SORT_ICON_NONE) )
     {
         newRect.width -= 12;
+        sortArrow = wxHDR_SORT_ICON_NONE;
     }
-    flags &= ~(wxCONTROL_SELECTED | wxCONTROL_UPICON | wxCONTROL_DOWNICON);
+    flags &= ~wxCONTROL_SELECTED;
 
-    DrawHeaderButtonContents(win, dc, newRect, flags, params);
+    DrawHeaderButtonContents(win, dc, newRect, flags, sortArrow, params);
 }
 
 
index 15f86caaa3aa5a4a47e11f6608d2f9a00e286ea0..bba35b0154993da8f3e7b6e7d17b4fd9a09bdd7a 100644 (file)
@@ -122,6 +122,7 @@ public:
                                   wxDC& dc,
                                   const wxRect& rect,
                                   int flags = 0,
+                                  wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                   wxHeaderButtonParams* params = NULL);
     virtual int GetHeaderButtonHeight(wxWindow *win);
     
@@ -286,12 +287,13 @@ wxRendererXP::DrawHeaderButton(wxWindow *win,
                                wxDC& dc,
                                const wxRect& rect,
                                int flags,
+                               wxHeaderSortIconType sortArrow,
                                wxHeaderButtonParams* params)
 {
     wxUxThemeHandle hTheme(win, L"HEADER");
     if ( !hTheme )
     {
-        m_rendererNative.DrawHeaderButton(win, dc, rect, flags, params);
+        m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params);
         return;
     }
 
@@ -320,7 +322,7 @@ wxRendererXP::DrawHeaderButton(wxWindow *win,
     // and then clear those flags before calling DrawHeaderButtonContents.
     
     // Add any extras that are specified in flags and params
-    DrawHeaderButtonContents(win, dc, rect, flags, params);
+    DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
 }
 
 
index f815aa8dab505c26e2e84070edbe2bb9f81256af..5d97fe6f357ac95e9401e65d4f51ac40c5475fef 100644 (file)
@@ -1194,7 +1194,8 @@ void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
         if ((image != -1) && imageList) 
             params.m_labelBitmap = imageList->GetBitmap(image);
                 
-        wxRendererNative::Get().DrawHeaderButton(this, dc, rect, flags, &params);
+        wxRendererNative::Get().DrawHeaderButton(this, dc, rect, flags,
+                                                 wxHDR_SORT_ICON_NONE, &params);
     }
 
     if (x < w) {
index 705abbba80c1baa9e0439cb8a249d21690e36e5d..07106059c86c37efa74cf0eafb5d978c507c733f 100644 (file)
@@ -34,10 +34,8 @@ enum
     wxCONTROL_CHECKED    = 0x00000040,  // (check/radio button) is checked
     wxCONTROL_CHECKABLE  = 0x00000080,  // (menu) item can be checked
     wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE, // (check) undetermined state
-    wxCONTROL_UPICON     = 0x00000100,  // header button has an up arrow icon
-    wxCONTROL_DOWNICON   = 0x00000200,  // header button has a down arrow icon
 
-    wxCONTROL_FLAGS_MASK = 0x000002ff,
+    wxCONTROL_FLAGS_MASK = 0x000000ff,
 
     // this is a pseudo flag not used directly by wxRenderer but rather by some
     // controls internally
@@ -97,6 +95,11 @@ struct wxHeaderButtonParams
     int         m_labelAlignment;
 };
 
+enum wxHeaderSortIconType {
+    wxHDR_SORT_ICON_NONE,        // Header button has no sort arrow
+    wxHDR_SORT_ICON_UP,          // Header button an an up sort arrow icon
+    wxHDR_SORT_ICON_DOWN         // Header button an a down sort arrow icon
+};
 
 
 DocStr(wxRendererVersion,
@@ -155,6 +158,7 @@ public:
                                         wxDC& dc,
                                         const wxRect& rect,
                                         int flags = 0,
+                                        wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                         wxHeaderButtonParams* params=NULL),
         "Draw the header control button (such as what is used by `wx.ListCtrl`
 in report mode.)", "");
@@ -165,6 +169,7 @@ in report mode.)", "");
                                                 wxDC& dc,
                                                 const wxRect& rect,
                                                 int flags = 0,
+                                                wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
                                                 wxHeaderButtonParams* params=NULL),
         "Draw the contents of a header control button, (label, sort
 arrows, etc.)  Normally this is only called by `DrawHeaderButton`.", "");