\membersection{wxRendererNative::DrawHeaderButton}\label{wxrenderernativedrawheaderbutton}
-\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}}
+\func{int}{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, 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\_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}.
+drawing of a text or bitmap label can be passed in \arg{params}. The
+value returned is the optimal width to contain the the unabreviated
+label text or bitmap, the sort arrow if present, and internal margins.
+
\membersection{wxRendererNative::DrawItemSelectionRect}\label{wxrenderernativedrawitemselectionrect}
// drawing functions
// -----------------
- // draw the header control button (used by wxListCtrl)
- virtual void DrawHeaderButton(wxWindow *win,
+ // draw the header control button (used by wxListCtrl) Returns optimal
+ // width for the label contents.
+ virtual int DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
// Draw the contents of a header control button (label, sort arrows, etc.)
// Normally only called by DrawHeaderButton.
- virtual void DrawHeaderButtonContents(wxWindow *win,
+ virtual int DrawHeaderButtonContents(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
: m_rendererNative(rendererNative) { }
- virtual void DrawHeaderButton(wxWindow *win,
+ virtual int DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL)
- { m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params); }
+ { return m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params); }
- virtual void DrawHeaderButtonContents(wxWindow *win,
+ virtual int 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, sortArrow, params); }
+ { return m_rendererNative.DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params); }
virtual int GetHeaderButtonHeight(wxWindow *win)
{ return m_rendererNative.GetHeaderButtonHeight(win); }
int flags) const
{ return m_renderer->HitTestFrame(rect, pt, flags); }
- virtual void DrawHeaderButton(wxWindow *win,
+ virtual int DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
wxHeaderSortIconType sortIcon = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL)
- { m_renderer->DrawHeaderButton(win, dc, rect, flags, sortIcon, params); }
+ { return m_renderer->DrawHeaderButton(win, dc, rect, flags, sortIcon, params); }
virtual void DrawTreeItemButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
public:
wxRendererGeneric();
- virtual void DrawHeaderButton(wxWindow *win,
+ virtual int DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL);
- virtual void DrawHeaderButtonContents(wxWindow *win,
+ virtual int DrawHeaderButtonContents(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
// tree/list ctrl drawing
// ----------------------------------------------------------------------------
-void
+int
wxRendererGeneric::DrawHeaderButton(wxWindow* win,
wxDC& dc,
const wxRect& rect,
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, sortArrow, params);
+ return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
}
-void
+int
wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
wxDC& dc,
const wxRect& rect,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params)
{
+ int labelWidth = 0;
+
// Mark this item as selected. For the generic version we'll just draw an
// underline
if ( flags & wxCONTROL_SELECTED )
dc.SetBrush(wxBrush(c));
dc.DrawPolygon( 3, triPt, ar.x, ar.y);
}
-
+ labelWidth += arrowSpace;
+
const int margin = 5; // number of pixels to reserve on either side of the label
int bmpWidth = 0;
int txtEnd = 0;
if ( params && params->m_labelBitmap.Ok() )
bmpWidth = params->m_labelBitmap.GetWidth() + 2;
-
+
+ labelWidth += bmpWidth + 2*margin;
+
// Draw a label if one is given
if ( params && !params->m_labelText.empty() )
{
int tw, th, td, x, y;
dc.GetTextExtent( label, &tw, &th, &td);
+ labelWidth += tw;
y = rect.y + wxMax(0, (rect.height - (th+td)) / 2);
-
+
// truncate and add an ellipsis (...) if the text is too wide.
int targetWidth = rect.width - arrowSpace - bmpWidth - 2*margin;
if ( tw > targetWidth )
}
dc.DrawBitmap(params->m_labelBitmap, x, y, true);
}
+ return labelWidth;
}
{
public:
// draw the header control button (used by wxListCtrl)
- virtual void DrawHeaderButton(wxWindow *win,
+ virtual int DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
// list/tree controls drawing
// ----------------------------------------------------------------------------
-void
+int
wxRendererGTK::DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
dc.LogicalToDeviceX(rect.x) - x_diff, rect.y, rect.width, rect.height
);
- DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
+ return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
}
// draw a ">" or "v" button
{
public:
// draw the header control button (used by wxListCtrl)
- virtual void DrawHeaderButton( wxWindow *win,
+ virtual int DrawHeaderButton( wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
return s_rendererMac;
}
-void wxRendererMac::DrawHeaderButton( wxWindow *win,
+int wxRendererMac::DrawHeaderButton( wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags,
}
flags &= ~wxCONTROL_SELECTED;
- DrawHeaderButtonContents(win, dc, newRect, flags, sortArrow, params);
+ return DrawHeaderButtonContents(win, dc, newRect, flags, sortArrow, params);
}
static wxRendererNative& Get();
- virtual void DrawHeaderButton(wxWindow *win,
+ virtual int DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0,
}
-void
+int
wxRendererXP::DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
wxUxThemeHandle hTheme(win, L"HEADER");
if ( !hTheme )
{
- m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params);
- return;
+ return m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params);
}
RECT r;
// and then clear those flags before calling DrawHeaderButtonContents.
// Add any extras that are specified in flags and params
- DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
+ return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
}
DocDeclStr(
- virtual void , DrawHeaderButton(wxWindow *win,
- 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.)", "");
+ virtual int , DrawHeaderButton(wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags = 0,
+ wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
+ wxHeaderButtonParams* params=NULL),
+ "Draw a header control button (such as what is used by `wx.ListCtrl` in report
+mode.) The optimal size of the label (text and icons) is returned.", "");
DocDeclStr(
- virtual void , DrawHeaderButtonContents(wxWindow *win,
- wxDC& dc,
- const wxRect& rect,
- int flags = 0,
- wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
- wxHeaderButtonParams* params=NULL),
+ virtual int , DrawHeaderButtonContents(wxWindow *win,
+ 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`.", "");