As per wx-dev, split the sort arrow options out to a separate parameter.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41230 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-09-14 19:42:41 +00:00
parent 923608c3ac
commit 80752b57a9
9 changed files with 58 additions and 29 deletions

View 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 case wxWidgets provides a default, generic, implementation of them written in
wxWidgets itself. 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 line drawing and other graphics primitives are used, because the native
appearance is different under different platforms while the lines are always appearance is different under different platforms while the lines are always
drawn in the same way. drawn in the same way.
@@ -75,9 +75,6 @@ enum
wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE // (check) undetermined state 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} \end{verbatim}
@@ -134,9 +131,16 @@ rectangle of a drop down button which arrow matches the size you need.
\membersection{wxRendererNative::DrawHeaderButton}\label{wxrenderernativedrawheaderbutton} \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} \membersection{wxRendererNative::DrawPushButton}\label{wxrenderernativedrawpushbutton}

View File

@@ -59,10 +59,8 @@ enum
wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE, // (check) undetermined state 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 // this is a pseudo flag not used directly by wxRenderer but rather by some
// controls internally // controls internally
@@ -109,6 +107,12 @@ struct WXDLLEXPORT wxHeaderButtonParams
int m_labelAlignment; 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 // wxRendererNative interface version
struct WXDLLEXPORT wxRendererVersion struct WXDLLEXPORT wxRendererVersion
@@ -156,6 +160,7 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params=NULL) = 0; wxHeaderButtonParams* params=NULL) = 0;
@@ -165,6 +170,7 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params=NULL) = 0; wxHeaderButtonParams* params=NULL) = 0;
// Returns the default height of a header button, either a fixed platform // Returns the default height of a header button, either a fixed platform
@@ -304,17 +310,17 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL) 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, virtual void DrawHeaderButtonContents(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL) 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) virtual int GetHeaderButtonHeight(wxWindow *win)
{ return m_rendererNative.GetHeaderButtonHeight(win); } { return m_rendererNative.GetHeaderButtonHeight(win); }

View File

@@ -889,8 +889,9 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params=NULL) 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, virtual void DrawTreeItemButton(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,

View File

@@ -50,12 +50,14 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHBSortIconType sortArrow = wxHB_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL); wxHeaderButtonParams* params = NULL);
virtual void DrawHeaderButtonContents(wxWindow *win, virtual void DrawHeaderButtonContents(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHBSortIconType sortArrow = wxHB_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL); wxHeaderButtonParams* params = NULL);
virtual int GetHeaderButtonHeight(wxWindow *win); virtual int GetHeaderButtonHeight(wxWindow *win);
@@ -207,6 +209,7 @@ wxRendererGeneric::DrawHeaderButton(wxWindow* win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags, int flags,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params) wxHeaderButtonParams* params)
{ {
const int CORNER = 1; 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, y+h-1, x+1, y+h-1 );
dc.DrawLine( x+w-1, y, x+w-1, y+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 void
wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win, wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags, int flags,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params) wxHeaderButtonParams* params)
{ {
// Mark this item as selected. For the generic version we'll just draw an // 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 // Draw an up or down arrow
int arrowSpace = 0; int arrowSpace = 0;
if (flags & (wxCONTROL_UPICON | wxCONTROL_DOWNICON) ) if (sortArrow != wxHDR_SORT_ICON_NONE )
{ {
wxRect ar = rect; wxRect ar = rect;
@@ -276,7 +281,7 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
arrowSpace = 3*ar.width/2; // space to preserve when drawing the label arrowSpace = 3*ar.width/2; // space to preserve when drawing the label
wxPoint triPt[3]; wxPoint triPt[3];
if ( flags & wxCONTROL_UPICON ) if ( sortArrow & wxHDR_SORT_ICON_UP )
{ {
triPt[0].x = ar.width / 2; triPt[0].x = ar.width / 2;
triPt[0].y = 0; triPt[0].y = 0;

View File

@@ -47,6 +47,7 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL); wxHeaderButtonParams* params = NULL);
// draw the expanded/collapsed icon for a tree control item // draw the expanded/collapsed icon for a tree control item
@@ -185,6 +186,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags, int flags,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params) wxHeaderButtonParams* params)
{ {
@@ -208,7 +210,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
dc.LogicalToDeviceX(rect.x) - x_diff, rect.y, rect.width, rect.height 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 // draw a ">" or "v" button

View File

@@ -37,6 +37,7 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL ); wxHeaderButtonParams* params = NULL );
virtual int GetHeaderButtonHeight(wxWindow *win); virtual int GetHeaderButtonHeight(wxWindow *win);
@@ -129,6 +130,7 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags, int flags,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params ) wxHeaderButtonParams* params )
{ {
const wxCoord x = dc.XLOG2DEV(rect.x /*- 1*/); const wxCoord x = dc.XLOG2DEV(rect.x /*- 1*/);
@@ -185,13 +187,13 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win,
drawInfo.adornment = kThemeAdornmentNone; drawInfo.adornment = kThemeAdornmentNone;
// The down arrow is drawn automatically, change it to an up arrow if needed. // 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; drawInfo.adornment = kThemeAdornmentHeaderButtonSortUp;
HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect ); HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
// If we don't want any arrows we need to draw over the one already there // 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 // clip to the header rectangle
CGContextSaveGState( cgContext ); CGContextSaveGState( cgContext );
@@ -212,13 +214,14 @@ void wxRendererMac::DrawHeaderButton( wxWindow *win,
// Reserve room for the arrows before writing the label, and turn off the // Reserve room for the arrows before writing the label, and turn off the
// flags we've already handled // flags we've already handled
wxRect newRect(rect); wxRect newRect(rect);
if ( (flags & wxCONTROL_SELECTED) && (flags & (wxCONTROL_UPICON|wxCONTROL_DOWNICON)) ) if ( (flags & wxCONTROL_SELECTED) && (sortArrow != wxHDR_SORT_ICON_NONE) )
{ {
newRect.width -= 12; 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);
} }

View File

@@ -122,6 +122,7 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL); wxHeaderButtonParams* params = NULL);
virtual int GetHeaderButtonHeight(wxWindow *win); virtual int GetHeaderButtonHeight(wxWindow *win);
@@ -286,12 +287,13 @@ wxRendererXP::DrawHeaderButton(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags, int flags,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params) wxHeaderButtonParams* params)
{ {
wxUxThemeHandle hTheme(win, L"HEADER"); wxUxThemeHandle hTheme(win, L"HEADER");
if ( !hTheme ) if ( !hTheme )
{ {
m_rendererNative.DrawHeaderButton(win, dc, rect, flags, params); m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params);
return; return;
} }
@@ -320,7 +322,7 @@ wxRendererXP::DrawHeaderButton(wxWindow *win,
// and then clear those flags before calling DrawHeaderButtonContents. // and then clear those flags before calling DrawHeaderButtonContents.
// Add any extras that are specified in flags and params // Add any extras that are specified in flags and params
DrawHeaderButtonContents(win, dc, rect, flags, params); DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
} }

View File

@@ -1194,7 +1194,8 @@ void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
if ((image != -1) && imageList) if ((image != -1) && imageList)
params.m_labelBitmap = imageList->GetBitmap(image); 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) { if (x < w) {

View File

@@ -34,10 +34,8 @@ enum
wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE, // (check) undetermined state 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 // this is a pseudo flag not used directly by wxRenderer but rather by some
// controls internally // controls internally
@@ -97,6 +95,11 @@ struct wxHeaderButtonParams
int m_labelAlignment; 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, DocStr(wxRendererVersion,
@@ -155,6 +158,7 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params=NULL), wxHeaderButtonParams* params=NULL),
"Draw the header control button (such as what is used by `wx.ListCtrl` "Draw the header control button (such as what is used by `wx.ListCtrl`
in report mode.)", ""); in report mode.)", "");
@@ -165,6 +169,7 @@ in report mode.)", "");
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0, int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params=NULL), wxHeaderButtonParams* params=NULL),
"Draw the contents of a header control button, (label, sort "Draw the contents of a header control button, (label, sort
arrows, etc.) Normally this is only called by `DrawHeaderButton`.", ""); arrows, etc.) Normally this is only called by `DrawHeaderButton`.", "");