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:
@@ -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}
|
||||
|
@@ -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); }
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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, ¶ms);
|
||||
wxRendererNative::Get().DrawHeaderButton(this, dc, rect, flags,
|
||||
wxHDR_SORT_ICON_NONE, ¶ms);
|
||||
}
|
||||
|
||||
if (x < w) {
|
||||
|
@@ -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`.", "");
|
||||
|
Reference in New Issue
Block a user