wxRuby Documentation Home

# Wx::RendererNative

Firstly, note that this class is not constructed directly. To get a
Wx::RendererNative, call the class method Wx::RendererNative.get.

A brief introduction to Renderer and why it is needed.

Usually wxRuby 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 Widgets provides a default, generic, implementation of them written in
Widgets 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: Renderer 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.

All drawing functions take some standard parameters:

- win is the window being drawn. It is normally not used and when
  it is it should only be used as a generic Window
  (in order to get its low level handle, for example), but you should
  not assume that it is of some given type as the same renderer
  function may be reused for drawing different kinds of control.
- dc is the DC to draw on. Only this device
  context should be used for drawing. It is not necessary to restore
  pens and brushes for it on function exit but, on the other hand, you
  shouldn’t assume that it is in any specific state on function entry:
  the rendering functions should always prepare it.
- rect the bounding rectangle for the element to be drawn.
- flags the optional flags (none by default) which can be a
  combination of the `CONTROL_XXX` constants below.

Note that each drawing function restores the DC 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.

## Constants

The following rendering flags are defined:

CONTROL_DISABLED = 0×00000001, // control is disabled CONTROL_FOCUSED = 0×00000002, // currently has keyboard focus CONTROL_PRESSED = 0×00000004, // (button) is pressed CONTROL_ISDEFAULT = 0×00000008, // only applies to the buttons CONTROL_ISSUBMENU = CONTROL_ISDEFAULT, // only for menu items CONTROL_EXPANDED = CONTROL_ISDEFAULT, // only for the tree items CONTROL_CURRENT = 0×00000010, // mouse is currently over the control CONTROL_SELECTED = 0×00000020, // selected item in e.g. listbox CONTROL_CHECKED = 0×00000040, // (check/radio button) is checked CONTROL_CHECKABLE = 0×00000080, // (menu) item can be checked CONTROL_UNDETERMINED = CONTROL_CHECKABLE // (check) undetermined state

## Derived from

No base class

## Methods

- RendererNative#draw_check_box
- RendererNative#draw_combo_box_drop_button
- RendererNative#draw_drop_arrow
- RendererNative#draw_header_button
- RendererNative#draw_item_selection_rect
- RendererNative#draw_push_button
- RendererNative#draw_splitter_border
- RendererNative#draw_splitter_sash
- RendererNative#draw_tree_item_button
- RendererNative#get
- RendererNative#get_default
- RendererNative#get_generic
- RendererNative#get_header_button_height
- RendererNative#get_splitter_params
- RendererNative#get_version
- RendererNative#load
- RendererNative#set

### RendererNative#draw_check_box

draw_check_box(%(arg-type)Window% win, DC dc, Rect rect, Integer flags)

Draw a check box (used by DataViewCtrl).

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

### RendererNative#draw_combo_box_drop_button

draw_combo_box_drop_button(%(arg-type)Window% win, DC dc, Rect rect, Integer flags)

Draw a button like the one used by 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.

### RendererNative#draw_drop_arrow

draw_drop_arrow(%(arg-type)Window% win, DC dc, Rect rect, Integer flags)

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.

### RendererNative#draw_header_button

Integer draw_header_button(%(arg-type)Window% win, DC dc, Rect rect, Integer flags = 0, HeaderSortIconType sortArrow = HDR_SORT_ICON_NONE, HeaderButtonParams params = nil)

Draw the header control button (used, for example, by
ListCtrl). Depending on platforms the
flags parameter may support the `CONTROL_SELECTED`
`CONTROL_DISABLED` and `CONTROL_CURRENT` bits.
The sortArrow parameter can be one of
`HDR_SORT_ICON_NONE`, `HDR_SORT_ICON_UP`, or
`HDR_SORT_ICON_DOWN`. Additional values controlling the
drawing of a text or bitmap label can be passed in 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.

### RendererNative#draw_item_selection_rect

draw_item_selection_rect(%(arg-type)Window% win, DC dc, Rect rect, Integer flags = 0)

Draw a selection rectangle underneath the text as used e.g. in a
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 (othewise the 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.

### RendererNative#draw_push_button

draw_push_button(%(arg-type)Window% win, DC dc, Rect rect, Integer flags)

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

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

### RendererNative#draw_splitter_border

draw_splitter_border(%(arg-type)Window% win, DC dc, Rect rect, Integer flags = 0)

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

### RendererNative#draw_splitter_sash

draw_splitter_sash(%(arg-type)Window% win, DC dc, Size size, Integer position, Orientation orient, Integer flags = 0)

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

### RendererNative#draw_tree_item_button

draw_tree_item_button(%(arg-type)Window% win, DC dc, Rect rect, Integer 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.

### RendererNative#get

RendererNative get()

Return the currently used renderer.

### RendererNative#get_default

RendererNative get_default()

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.

### RendererNative#get_generic

RendererNative get_generic()

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 get_default.

### RendererNative#get_header_button_height

Integer get_header_button_height(%(arg-type)Window% win)

Returns the height of a header button, either a fixed platform height if available, or a
generic height based on the window’s font.

### RendererNative#get_splitter_params

SplitterRenderParams get_splitter_params(%(arg-type)Window% win)

Gets the parameters for platform-native splitter.

This return value is a structure containing the following fields:

- width_sash : the integer width of the sash
- border : the integer width of the border drawn by the splitter inside it, may be 0
- is_hot_sensitive : `true` if the sash changes appearance when the mouse passes over it, `false` otherwise

### RendererNative#get_version

RendererVersion get_version()

NOT CURRENTLY SUPPORTED

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

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

### RendererNative#load

RendererNative load(%(arg-type)String% name)

NOT CURRENTLY SUPPORTED

Load the renderer from the specified DLL, the returned pointer must be
deleted by caller if not `NULL` 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
DynamicLibrary#canonicalize_plugin_name)
on different systems.

### RendererNative#set

RendererNative set(%(arg-type)RendererNative% renderer)

Set the renderer to use, passing `NULL` reverts to using the default
renderer (the global renderer must always exist).

Return the previous renderer used with Set() or `NULL` if none.

[This page automatically generated from the Textile source at 2023-06-09 00:45:34 +0000]