# wx.DelegateRendererNative¶

wx.DelegateRendererNative allows reuse of renderers code by forwarding all the wx.RendererNative methods to the given object and thus allowing you to only modify some of its methods – without having to reimplement all of them.

Note that the “normal”, inheritance-based approach, doesn’t work with the renderers as it is impossible to derive from a class unknown at compile-time and the renderer is only chosen at run-time. So suppose that you want to only add something to the drawing of the tree control buttons but leave all the other methods unchanged – the only way to do it, considering that the renderer class which you want to customize might not even be written yet when you write your code (it could be written later and loaded from a DLL during run-time), is by using this class.

Except for the constructor, it has exactly the same methods as wx.RendererNative and their implementation is trivial: they are simply forwarded to the real renderer. Note that the “real” renderer may, in turn, be a wx.DelegateRendererNative as well and that there may be arbitrarily many levels like this – but at the end of the chain there must be a real renderer which does the drawing.

## Class Hierarchy¶

Inheritance diagram for class DelegateRendererNative:

## Methods Summary¶

 __init__ The default constructor does the same thing as the other one except that it uses the generic renderer instead of the user-specified rendererNative. DrawCheckBox Draw a check box. DrawCheckMark Draw a check mark. DrawComboBoxDropButton Draw a button like the one used by wx.ComboBox to show a drop down window. DrawDropArrow Draw a drop down arrow that is suitable for use outside a combo box. DrawFocusRect Draw a focus rectangle using the specified rectangle. DrawHeaderButton Draw the header control button (used, for example, by wx.ListCtrl). DrawHeaderButtonContents Draw the contents of a header control button (label, sort arrows, etc.). DrawItemSelectionRect Draw a selection rectangle underneath the text as used e.g. DrawPushButton Draw a blank push button that looks very similar to wx.Button. DrawSplitterBorder Draw the border for sash window: this border must be such that the sash drawn by DrawSplitterSash blends into it well. DrawSplitterSash Draw a sash. DrawTitleBarBitmap Draw a title bar button in the given state. DrawTreeItemButton Draw the expanded/collapsed icon for a tree control item. GetCheckBoxSize Returns the size of a check box. GetCheckMarkSize Returns the size of a check mark. GetExpanderSize Returns the size of the expander used in tree-like controls. GetHeaderButtonHeight 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. GetHeaderButtonMargin Returns the horizontal margin on the left and right sides of header button’s label. GetSplitterParams Get the splitter parameters, see wx.SplitterRenderParams. GetVersion This function is used for version checking: Load refuses to load any shared libraries implementing an older or incompatible version.

## Class API¶

class wx.DelegateRendererNative(RendererNative)

Possible constructors:

DelegateRendererNative()

DelegateRendererNative(rendererNative)


DelegateRendererNative allows reuse of renderers code by forwarding all the RendererNative methods to the given object and thus allowing you to only modify some of its methods without having to reimplement all of them.

### Methods¶

__init__(self, *args, **kw)

__init__ (self)

The default constructor does the same thing as the other one except that it uses the generic renderer instead of the user-specified rendererNative.

In any case, this sets up the delegate renderer object to follow all calls to the specified real renderer.

__init__ (self, rendererNative)

This constructor uses the user-specified rendererNative to set up the delegate renderer object to follow all calls to the specified real renderer.

Parameters

rendererNative (wx.RendererNative) –

Note

This object does not take ownership of (i.e. won’t delete) rendererNative.

DrawCheckBox(self, win, dc, rect, flags=0)

Draw a check box.

flags may have the CONTROL_CHECKED , CONTROL_CURRENT or CONTROL_UNDETERMINED bit set, see CONTROL_FLAGS.

Parameters

DrawCheckMark(self, win, dc, rect, flags=0)

Draw a check mark.

flags may have the CONTROL_DISABLED bit set, see CONTROL_FLAGS.

Parameters

New in version 4.1/wxWidgets-3.1.3.

DrawComboBoxDropButton(self, win, dc, rect, flags=0)

Draw a button like the one used by wx.ComboBox to show a drop down window.

The usual appearance is a downwards pointing arrow.

flags may have the CONTROL_PRESSED or CONTROL_CURRENT bit set, see CONTROL_FLAGS.

Parameters

DrawDropArrow(self, win, dc, rect, flags=0)

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 CONTROL_PRESSED or CONTROL_CURRENT bit set, see CONTROL_FLAGS.

Parameters

DrawFocusRect(self, win, dc, rect, flags=0)

Draw a focus rectangle using the specified rectangle.

The only supported flags is CONTROL_SELECTED for items which are selected. see CONTROL_FLAGS.

Parameters

DrawHeaderButton(self, win, dc, rect, flags=0, sortArrow=HDR_SORT_ICON_NONE, params=None)

Draw the header control button (used, for example, by wx.ListCtrl).

Depending on platforms the flags parameter may support the CONTROL_SELECTED CONTROL_DISABLED and CONTROL_CURRENT bits, see CONTROL_FLAGS.

Parameters
Return type

int

Returns

The optimal width to contain the unabbreviated label text or bitmap, the sort arrow if present, and internal margins.

DrawHeaderButtonContents(self, win, dc, rect, flags=0, sortArrow=HDR_SORT_ICON_NONE, params=None)

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 CONTROL_SELECTED CONTROL_DISABLED and CONTROL_CURRENT bits, see CONTROL_FLAGS.

Parameters
Return type

int

Returns

The optimal width to contain the unabbreviated label text or bitmap, the sort arrow if present, and internal margins.

DrawItemSelectionRect(self, win, dc, rect, flags=0)

Draw a selection rectangle underneath the text as used e.g.

in a wx.ListCtrl.

The supported flags are CONTROL_SELECTED for items which are selected (e.g. often a blue rectangle) and CONTROL_CURRENT for the item that has the focus (often a dotted line around the item’s text). CONTROL_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 CONTROL_CELL may be used to draw a cell inside a bigger selection area.

Parameters

DrawPushButton(self, win, dc, rect, flags=0)

Draw a blank push button that looks very similar to wx.Button.

flags may have the CONTROL_PRESSED , CONTROL_CURRENT or CONTROL_ISDEFAULT bit set, see CONTROL_FLAGS.

Parameters

DrawSplitterBorder(self, win, dc, rect, flags=0)

Draw the border for sash window: this border must be such that the sash drawn by DrawSplitterSash blends into it well.

Parameters

DrawSplitterSash(self, win, dc, size, position, orient, flags=0)

Draw a sash.

The orient parameter defines whether the sash should be vertical or horizontal and how the position should be interpreted.

Parameters

DrawTitleBarBitmap(self, win, dc, rect, button, flags=0)

Draw a title bar button in the given state.

DrawTreeItemButton(self, win, dc, rect, flags=0)

Draw the expanded/collapsed icon for a tree control item.

To draw an expanded button the flags parameter must contain CONTROL_EXPANDED bit, see CONTROL_FLAGS.

Parameters

GetCheckBoxSize(self, win, flags=0)

Returns the size of a check box.

Parameters
• win (wx.Window) – A valid, i.e. non-null, window pointer which is used to get the theme defining the checkbox size under some platforms.

• flags (int) – The only acceptable flag is CONTROL_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.

Return type

wx.Size

GetCheckMarkSize(self, win)

Returns the size of a check mark.

Parameters

win (wx.Window) – A valid, i.e. non-null, window pointer which is used to get the theme defining the checkmark size under some platforms.

Return type

wx.Size

New in version 4.1/wxWidgets-3.1.3.

GetExpanderSize(self, win)

Returns the size of the expander used in tree-like controls.

Parameters

win (wx.Window) – A valid, i.e. non-null, window pointer which is used to get the theme defining the expander size under some platforms.

Return type

wx.Size

New in version 4.1/wxWidgets-3.1.3.

GetHeaderButtonHeight(self, win)

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.

Parameters

win (wx.Window) –

Return type

int

GetHeaderButtonMargin(self, win)

Returns the horizontal margin on the left and right sides of header button’s label.

Parameters

win (wx.Window) –

Return type

int

New in version 2.9.2.

GetSplitterParams(self, win)

Get the splitter parameters, see wx.SplitterRenderParams.

The win parameter should be a wx.SplitterWindow.

Parameters

win (wx.Window) –

Return type

wx.SplitterRenderParams

GetVersion(self)

This function is used for version checking: Load refuses to load any shared libraries implementing an older or incompatible version.

Return type

wx.RendererVersion

Note

The implementation of this method is always the same in all renderers (simply construct wx.RendererVersion using the RendererVersion::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.

### Properties¶

Version