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:
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.
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 stateNo base class
Draw a check box (used by DataViewCtrl).
flags may have the CONTROL_CHECKED
, CONTROL_CURRENT
or
CONTROL_UNDETERMINED
bit set.
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.
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.
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.
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.
Draw a blank push button that looks very similar to Button.
flags may have the CONTROL_PRESSED
, CONTROL_CURRENT
or
CONTROL_ISDEFAULT
bit set.
Draw the border for sash window: this border must be such that the sash
drawn by draw_sash blends into it
well.
Draw a sash. The orient parameter defines whether the sash should be
vertical or horizontal and how the position should be interpreted.
Draw the expanded/collapsed icon for a tree control item. To draw an expanded
button the flags parameter must contain CONTROL_EXPANDED
bit.
Return the currently used renderer.
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.
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.
Returns the height of a header button, either a fixed platform height if available, or a
generic height based on the window’s font.
Gets the parameters for platform-native splitter.
This return value is a structure containing the following fields:
true
if the sash changes appearance when the mouse passes over it, false
otherwiseNOT 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.
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.
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-03 08:07:39 +0000]