1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface for wxRendererNative
 
   7 // Created:     9-June-2005
 
   9 // Copyright:   (c) 2005 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  15 //---------------------------------------------------------------------------
 
  19 #include "wx/renderer.h"
 
  23 // control state flags used in wxRenderer and wxColourScheme
 
  26     wxCONTROL_DISABLED   = 0x00000001,  // control is disabled
 
  27     wxCONTROL_FOCUSED    = 0x00000002,  // currently has keyboard focus
 
  28     wxCONTROL_PRESSED    = 0x00000004,  // (button) is pressed
 
  29     wxCONTROL_SPECIAL    = 0x00000008,  // control-specific bit:
 
  30     wxCONTROL_ISDEFAULT  = wxCONTROL_SPECIAL, // only for the buttons
 
  31     wxCONTROL_ISSUBMENU  = wxCONTROL_SPECIAL, // only for the menu items
 
  32     wxCONTROL_EXPANDED   = wxCONTROL_SPECIAL, // only for the tree items
 
  33     wxCONTROL_SIZEGRIP   = wxCONTROL_SPECIAL, // only for the status bar panes
 
  34     wxCONTROL_FLAT       = wxCONTROL_SPECIAL, // checkboxes only: flat border
 
  35     wxCONTROL_CURRENT    = 0x00000010,  // mouse is currently over the control
 
  36     wxCONTROL_SELECTED   = 0x00000020,  // selected item in e.g. listbox
 
  37     wxCONTROL_CHECKED    = 0x00000040,  // (check/radio button) is checked
 
  38     wxCONTROL_CHECKABLE  = 0x00000080,  // (menu) item can be checked
 
  39     wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE, // (check) undetermined state
 
  41     wxCONTROL_FLAGS_MASK = 0x000000ff,
 
  43     // this is a pseudo flag not used directly by wxRenderer but rather by some
 
  44     // controls internally
 
  45     wxCONTROL_DIRTY      = 0x80000000
 
  50 DocStr(wxSplitterRenderParams,
 
  51 "This is just a simple struct used as a return value of
 
  52 `wx.RendererNative.GetSplitterParams` and contains some platform
 
  53 specific metrics about splitters.
 
  55     * widthSash: the width of the splitter sash.
 
  56     * border: the width of the border of the splitter window.
 
  57     * isHotSensitive: ``True`` if the splitter changes its
 
  58       appearance when the mouse is over it.
 
  62 struct wxSplitterRenderParams
 
  64     wxSplitterRenderParams(wxCoord widthSash_, wxCoord border_, bool isSens_);
 
  65     ~wxSplitterRenderParams();
 
  67     // the width of the splitter sash
 
  68     const wxCoord widthSash;
 
  70     // the width of the border of the splitter window
 
  73     // true if the splitter changes its appearance when the mouse is over it
 
  74     const bool isHotSensitive;
 
  79 DocStr(wxHeaderButtonParams,
 
  80 "Extra (optional) parameters for `wx.RendererNative.DrawHeaderButton`", "");
 
  82 struct wxHeaderButtonParams
 
  84     wxHeaderButtonParams();
 
  85     ~wxHeaderButtonParams();
 
  87     // So wxColour_helper will be used when assigning to the colour items in the struct
 
  88     %typemap(in) wxColour* (wxColour temp) {
 
  90         if ( ! wxColour_helper($input, &$1)) SWIG_fail;
 
  92     wxColour    m_arrowColour;
 
  93     wxColour    m_selectionColour;
 
  96     wxColour    m_labelColour;
 
  97     wxBitmap    m_labelBitmap;
 
 101 enum wxHeaderSortIconType {
 
 102     wxHDR_SORT_ICON_NONE,        // Header button has no sort arrow
 
 103     wxHDR_SORT_ICON_UP,          // Header button an an up sort arrow icon
 
 104     wxHDR_SORT_ICON_DOWN         // Header button an a down sort arrow icon
 
 108 DocStr(wxRendererVersion,
 
 109 "This simple struct represents the `wx.RendererNative` interface
 
 110 version and is only used as the return value of
 
 111 `wx.RendererNative.GetVersion`.", "");
 
 113 struct wxRendererVersion
 
 115     wxRendererVersion(int version_, int age_);
 
 116     ~wxRendererVersion();
 
 125     // check if the given version is compatible with the current one
 
 126     static bool IsCompatible(const wxRendererVersion& ver);
 
 132 //---------------------------------------------------------------------------
 
 135 DocStr(wxRendererNative,
 
 136 "One of the design principles of wxWidgets is to use the native
 
 137 widgets on every platform in order to be as close as possible to
 
 138 the native look and feel on every platform.  However there are
 
 139 still cases when some generic widgets are needed for various
 
 140 reasons, but it can sometimes take a lot of messy work to make
 
 141 them conform to the native LnF.
 
 143 The wx.RendererNative class is a collection of functions that have
 
 144 platform-specific implementations for drawing certain parts of
 
 145 genereic controls in ways that are as close to the native look as
 
 148 Note that each drawing function restores the `wx.DC` attributes if it
 
 149 changes them, so it is safe to assume that the same pen, brush and
 
 150 colours that were active before the call to this function are still in
 
 154 class wxRendererNative
 
 160         virtual int , DrawHeaderButton(wxWindow *win,
 
 164                                        wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
 
 165                                        wxHeaderButtonParams* params=NULL),
 
 166         "Draw a header control button (such as what is used by `wx.ListCtrl` in report
 
 167 mode.)  The optimal size of the label (text and icons) is returned.", "");
 
 171         virtual int , DrawHeaderButtonContents(wxWindow *win,
 
 175                                                wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
 
 176                                                wxHeaderButtonParams* params=NULL),
 
 177         "Draw the contents of a header control button, (label, sort
 
 178 arrows, etc.)  Normally this is only called by `DrawHeaderButton`.", "");
 
 181         virtual int , GetHeaderButtonHeight(wxWindow *win),
 
 182         "Returns the default height of a header button, either a fixed platform
 
 183 height if available, or a generic height based on the window's font.", "");    
 
 187         virtual void , DrawTreeItemButton(wxWindow *win,
 
 191         "Draw the expanded/collapsed icon for a tree control item.", "");
 
 195         virtual void , DrawSplitterBorder(wxWindow *win,
 
 199         "Draw the border for a sash window: this border must be such that the
 
 200 sash drawn by `DrawSplitterSash` blends into it well.", "");
 
 204         virtual void , DrawSplitterSash(wxWindow *win,
 
 208                                         wxOrientation orient,
 
 210         "Draw a sash. The orient parameter defines whether the sash should be
 
 211 vertical or horizontal and how the position should be interpreted.", "");
 
 215         virtual void , DrawComboBoxDropButton(wxWindow *win,
 
 219         "Draw a button like the one used by `wx.ComboBox` to show a drop down
 
 220 window. The usual appearance is a downwards pointing arrow.
 
 222 The ``flags`` parameter may have the ``wx.CONTROL_PRESSED`` or
 
 223 ``wx.CONTROL_CURRENT`` bits set.", "");
 
 227         virtual void , DrawDropArrow(wxWindow *win,
 
 231         "Draw a drop down arrow that is suitable for use outside a combo
 
 232 box. Arrow will have a transparent background.
 
 234 ``rect`` is not entirely filled by the arrow. Instead, you should use
 
 235 bounding rectangle of a drop down button which arrow matches the size
 
 236 you need. ``flags`` may have the ``wx.CONTROL_PRESSED`` or
 
 237 ``wx.CONTROL_CURRENT`` bit set.", "");
 
 241         virtual void , DrawCheckBox(wxWindow *win,
 
 245         "Draw a check button.  Flags may use wx.CONTROL_CHECKED,
 
 246 wx.CONTROL_UNDETERMINED and wx.CONTROL_CURRENT.", "");
 
 250         virtual void , DrawPushButton(wxWindow *win,
 
 254         "Draw a blank button.  Flags may be wx.CONTROL_PRESSED, wx.CONTROL_CURRENT and
 
 255 wx.CONTROL_ISDEFAULT", "");
 
 259         virtual void , DrawItemSelectionRect(wxWindow *win,
 
 263         "Draw rectangle indicating that an item in e.g. a list control has been
 
 266 The flags parameter may be:
 
 268     ====================  ============================================
 
 269     wx.CONTROL_SELECTED   item is selected, e.g. draw background
 
 270     wx.CONTROL_CURRENT    item is the current item, e.g. dotted border
 
 271     wx.CONTROL_FOCUSED    the whole control has focus, e.g. blue
 
 272                           background vs. grey otherwise
 
 273     ====================  ============================================
 
 278         virtual wxSplitterRenderParams , GetSplitterParams(const wxWindow *win),
 
 279         "Get the splitter parameters, see `wx.SplitterRenderParams`.", "");
 
 285         static wxRendererNative& , Get(),
 
 286         "Return the currently used renderer", "");
 
 289     MustHaveApp(GetGeneric);
 
 291         static wxRendererNative& , GetGeneric(),
 
 292         "Return the generic implementation of the renderer. Under some
 
 293 platforms, this is the default renderer implementation, others have
 
 294 platform-specific default renderer which can be retrieved by calling
 
 295 `wx.RendererNative.GetDefault`.", "");
 
 298     MustHaveApp(GetDefault);
 
 300         static wxRendererNative& , GetDefault(),
 
 301         "Return the default (native) implementation for this platform -- this
 
 302 is also the one used by default but this may be changed by calling
 
 303 `wx.RendererNative.Set` in which case the return value of this method
 
 304 may be different from the return value of `wx.RendererNative.Get`.", "");
 
 309 //     // load the renderer from the specified DLL, the returned pointer must be
 
 310 //     // deleted by caller if not NULL when it is not used any more
 
 311 //     static wxRendererNative *Load(const wxString& name);
 
 316         static wxRendererNative *, Set(wxRendererNative *renderer),
 
 317         "Set the renderer to use, passing None reverts to using the default
 
 318 renderer.  Returns the previous renderer used with Set or None.", "");
 
 323         virtual wxRendererVersion , GetVersion() const,
 
 324         "Returns the version of the renderer.  Will be used for ensuring
 
 325 compatibility of dynamically loaded renderers.", "");
 
 328     %property(SplitterParams, GetSplitterParams, doc="See `GetSplitterParams`");
 
 329     %property(Version, GetVersion, doc="See `GetVersion`");
 
 333 //---------------------------------------------------------------------------