#include <wx/renderer.h>
First, a brief introduction to wxRendererNative and why it is needed.
Usually wxWidgets uses the underlying low level GUI system to draw all the controls - this is what we mean when we say that it is a "native" framework. 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 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.
This is why we have renderers: wxRendererNative is a class which virtualizes the drawing, i.e. it abstracts the drawing operations and allows you to draw say, a button, without caring about exactly how this is done. Of course, as we can draw the button differently in different renderers, this also allows us to emulate the native look and feel.
So the renderers work by exposing a large set of high-level drawing functions which are used by the generic controls. There is always a default global renderer but it may be changed or extended by the user, see Render Sample.
All drawing functions take some standard parameters:
Note that each drawing function restores the wxDC attributes if it changes them, so it is safe to assume that the same pen, brush and colours that were active before the call to this function are still in effect after it.
Public Member Functions | |
virtual | ~wxRendererNative () |
Virtual destructor as for any base class. More... | |
virtual void | DrawCheckBox (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a check box. More... | |
virtual void | DrawComboBoxDropButton (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a button like the one used by wxComboBox to show a drop down window. More... | |
virtual void | DrawDropArrow (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a drop down arrow that is suitable for use outside a combo box. More... | |
virtual void | DrawFocusRect (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a focus rectangle using the specified rectangle. More... | |
virtual void | DrawGauge (wxWindow *win, wxDC &dc, const wxRect &rect, int value, int max, int flags=0)=0 |
Draw a progress bar in the specified rectangle. More... | |
virtual int | DrawHeaderButton (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0, wxHeaderSortIconType sortArrow=wxHDR_SORT_ICON_NONE, wxHeaderButtonParams *params=nullptr)=0 |
Draw the header control button (used, for example, by wxListCtrl). More... | |
virtual int | DrawHeaderButtonContents (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0, wxHeaderSortIconType sortArrow=wxHDR_SORT_ICON_NONE, wxHeaderButtonParams *params=nullptr)=0 |
Draw the contents of a header control button (label, sort arrows, etc.). More... | |
virtual void | DrawItemSelectionRect (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a selection rectangle underneath the text as used e.g. More... | |
virtual void | DrawItemText (wxWindow *win, wxDC &dc, const wxString &text, const wxRect &rect, int align=wxALIGN_LEFT|wxALIGN_TOP, int flags=0, wxEllipsizeMode ellipsizeMode=wxELLIPSIZE_END)=0 |
Draw item text in the correct color based on selection status. More... | |
virtual void | DrawPushButton (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a blank push button that looks very similar to wxButton. More... | |
virtual void | DrawCollapseButton (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a collapse button. More... | |
virtual wxSize | GetCollapseButtonSize (wxWindow *win, wxDC &dc)=0 |
Returns the size of a collapse button. More... | |
virtual void | DrawSplitterBorder (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw the border for sash window: this border must be such that the sash drawn by DrawSplitterSash() blends into it well. More... | |
virtual void | DrawSplitterSash (wxWindow *win, wxDC &dc, const wxSize &size, wxCoord position, wxOrientation orient, int flags=0)=0 |
Draw a sash. More... | |
virtual void | DrawTreeItemButton (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw the expanded/collapsed icon for a tree control item. More... | |
virtual void | DrawChoice (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a native wxChoice. More... | |
virtual void | DrawComboBox (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a native wxComboBox. More... | |
virtual void | DrawTextCtrl (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a native wxTextCtrl frame. More... | |
virtual void | DrawRadioBitmap (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a native wxRadioButton bitmap. More... | |
virtual void | DrawTitleBarBitmap (wxWindow *win, wxDC &dc, const wxRect &rect, wxTitleBarButton button, int flags=0)=0 |
Draw a title bar button in the given state. More... | |
virtual void | DrawCheckMark (wxWindow *win, wxDC &dc, const wxRect &rect, int flags=0)=0 |
Draw a check mark. More... | |
virtual wxSize | GetCheckBoxSize (wxWindow *win, int flags=0)=0 |
Returns the size of a check box. More... | |
virtual wxSize | GetCheckMarkSize (wxWindow *win)=0 |
Returns the size of a check mark. More... | |
virtual wxSize | GetExpanderSize (wxWindow *win)=0 |
Returns the size of the expander used in tree-like controls. More... | |
virtual int | GetHeaderButtonHeight (wxWindow *win)=0 |
Returns the height of a header button, either a fixed platform height if available, or a generic height based on the win window's font. More... | |
virtual int | GetHeaderButtonMargin (wxWindow *win)=0 |
Returns the horizontal margin on the left and right sides of header button's label. More... | |
virtual wxSplitterRenderParams | GetSplitterParams (const wxWindow *win)=0 |
Get the splitter parameters, see wxSplitterRenderParams. More... | |
virtual wxRendererVersion | GetVersion () const =0 |
This function is used for version checking: Load() refuses to load any shared libraries implementing an older or incompatible version. More... | |
Static Public Member Functions | |
static wxRendererNative & | Get () |
Return the currently used renderer. More... | |
static wxRendererNative & | GetDefault () |
Return the default (native) implementation for this platform – this is also the one used by default but this may be changed by calling Set() in which case the return value of this method may be different from the return value of Get(). More... | |
static wxRendererNative & | GetGeneric () |
Return the generic implementation of the renderer. More... | |
static wxRendererNative * | Load (const wxString &name) |
Load the renderer from the specified DLL, the returned pointer must be deleted by caller if not nullptr when it is not used any more. More... | |
static wxRendererNative * | Set (wxRendererNative *renderer) |
Set the renderer to use, passing nullptr reverts to using the default renderer (the global renderer must always exist). More... | |
|
virtual |
Virtual destructor as for any base class.
|
pure virtual |
Draw a check box.
flags may have the wxCONTROL_CHECKED
, wxCONTROL_CURRENT
or wxCONTROL_UNDETERMINED
bit set, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a check mark.
flags may have the wxCONTROL_DISABLED
bit set, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a native wxChoice.
|
pure virtual |
Draw a collapse button.
flags may have the wxCONTROL_EXPANDED
or wxCONTROL_CURRENT
bit set, see wxCONTROL_FLAGS.
|
pure virtual |
Draw a native wxComboBox.
|
pure virtual |
Draw a button like the one used by wxComboBox to show a drop down window.
The usual appearance is a downwards pointing arrow.
flags may have the wxCONTROL_PRESSED
or wxCONTROL_CURRENT
bit set, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a drop down arrow that is suitable for use outside a combo box.
Arrow will have transparent background.
rect is not entirely filled by the arrow. Instead, you should use bounding rectangle of a drop down button which arrow matches the size you need.
flags may have the wxCONTROL_PRESSED
or wxCONTROL_CURRENT
bit set, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a focus rectangle using the specified rectangle.
The only supported flags is wxCONTROL_SELECTED
for items which are selected. see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a progress bar in the specified rectangle.
The value and max arguments determine the part of the progress bar that is drawn as being filled in, max must be strictly positive and value must be between 0 and max.
wxCONTROL_SPECIAL
must be set in flags for the vertical gauges.
|
pure virtual |
Draw the header control button (used, for example, by wxListCtrl).
Depending on platforms the flags parameter may support the wxCONTROL_SELECTED
wxCONTROL_DISABLED
and wxCONTROL_CURRENT
bits, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw the contents of a header control button (label, sort arrows, etc.).
This function is normally only called by DrawHeaderButton().
Depending on platforms the flags parameter may support the wxCONTROL_SELECTED
wxCONTROL_DISABLED
and wxCONTROL_CURRENT
bits, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a selection rectangle underneath the text as used e.g.
in a wxListCtrl.
The supported flags are wxCONTROL_SELECTED
for items which are selected (e.g. often a blue rectangle) and wxCONTROL_CURRENT
for the item that has the focus (often a dotted line around the item's text). wxCONTROL_FOCUSED
may be used to indicate if the control has the focus (otherwise the selection rectangle is e.g. often grey and not blue). This may be ignored by the renderer or deduced by the code directly from the win. Additionally wxCONTROL_CELL
may be used to draw a cell inside a bigger selection area.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw item text in the correct color based on selection status.
Background of the text should be painted with DrawItemSelectionRect().
The supported flags are wxCONTROL_SELECTED
for items which are selected. wxCONTROL_FOCUSED
may be used to indicate if the control has the focus. wxCONTROL_DISABLED
may be used to indicate if the control is disabled.
|
pure virtual |
Draw a blank push button that looks very similar to wxButton.
flags may have the wxCONTROL_PRESSED
, wxCONTROL_CURRENT
or wxCONTROL_ISDEFAULT
bit set, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a native wxRadioButton bitmap.
|
pure virtual |
Draw the border for sash window: this border must be such that the sash drawn by DrawSplitterSash() blends into it well.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a sash.
The orient parameter defines whether the sash should be vertical or horizontal and how the position should be interpreted.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Draw a native wxTextCtrl frame.
|
pure virtual |
Draw a title bar button in the given state.
This function is currently only available under MSW and macOS (and only for wxTITLEBAR_BUTTON_CLOSE under the latter), its best replacement for the other platforms is to use wxArtProvider to retrieve the bitmaps for wxART_HELP
and wxART_CLOSE
(but not any other title bar buttons and not for any state but normal, i.e. not pressed and not current one).
The presence of this function is indicated by wxHAS_DRAW_TITLE_BAR_BITMAP
symbol being defined.
|
pure virtual |
Draw the expanded/collapsed icon for a tree control item.
To draw an expanded button the flags parameter must contain wxCONTROL_EXPANDED
bit, see wxCONTROL_FLAGS.
Implemented in wxDelegateRendererNative.
|
static |
Return the currently used renderer.
Returns the size of a check box.
win | A valid, i.e. non-null, window pointer which is used to get the theme defining the checkbox size under some platforms. |
flags | The only acceptable flag is wxCONTROL_CELL which means that just the size of the checkbox itself is returned, without any margins that are included by default. This parameter is only available in wxWidgets 3.1.4 or later. |
Implemented in wxDelegateRendererNative.
Returns the size of a check mark.
win | A valid, i.e. non-null, window pointer which is used to get the theme defining the checkmark size under some platforms. |
Implemented in wxDelegateRendererNative.
Returns the size of a collapse button.
|
static |
Returns the size of the expander used in tree-like controls.
win | A valid, i.e. non-null, window pointer which is used to get the theme defining the expander size under some platforms. |
Implemented in wxDelegateRendererNative.
|
static |
Return the generic implementation of the renderer.
Under some platforms, this is the default renderer implementation, others have platform-specific default renderer which can be retrieved by calling GetDefault().
|
pure virtual |
Returns the height of a header button, either a fixed platform height if available, or a generic height based on the win window's font.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Returns the horizontal margin on the left and right sides of header button's label.
Implemented in wxDelegateRendererNative.
|
pure virtual |
Get the splitter parameters, see wxSplitterRenderParams.
The win parameter should be a wxSplitterWindow.
Implemented in wxDelegateRendererNative.
|
pure virtual |
This function is used for version checking: Load() refuses to load any shared libraries implementing an older or incompatible version.
wxRendererVersion::Current_XXX
values), but it has to be in the derived, not base, class, to detect mismatches between the renderers versions and so you have to implement it anew in all renderers. Implemented in wxDelegateRendererNative.
|
static |
Load the renderer from the specified DLL, the returned pointer must be deleted by caller if not nullptr when it is not used any more.
The name should be just the base name of the renderer and not the full name of the DLL file which is constructed differently (using wxDynamicLibrary::CanonicalizePluginName()) on different systems.
|
static |
Set the renderer to use, passing nullptr reverts to using the default renderer (the global renderer must always exist).
Return the previous renderer used with Set() or nullptr if none.