.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.checkbox

.. highlight:: python



.. _wx.lib.checkbox.GenCheckBox:

==========================================================================================================================================
|phoenix_title|  **wx.lib.checkbox.GenCheckBox**
==========================================================================================================================================

A generic class that replicates some of the functionalities of :class:`wx.Checkbox`,
while being completely owner-drawn with a nice check bitmaps.



|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>GenCheckBox</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.lib.checkbox.GenCheckBox_inheritance.svg" alt="Inheritance diagram of GenCheckBox" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.checkbox.GenCheckBox.html" title="A generic class that replicates some of the functionalities of wx.Checkbox," alt="" coords="5,389,255,418"/> <area shape="rect" id="node2" href="wx.Control.html" title="This is the base class for a control or 'widget'." alt="" coords="78,313,183,341"/> <area shape="rect" id="node3" href="wx.Window.html" title="wx.Window  is the base class for all windows and represents any visible object on screen." alt="" coords="75,236,186,265"/> <area shape="rect" id="node4" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="56,159,204,188"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="A class that can handle events from the windowing system." alt="" coords="64,82,197,111"/> <area shape="rect" id="node6" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="14,5,113,34"/> <area shape="rect" id="node7" href="wx.Trackable.html" title="Add-on base class for a trackable object." alt="" coords="137,5,260,34"/> </map> 
   </p>
   </div>

|


|super_classes| Known Superclasses
==================================

:class:`wx.Control`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.checkbox.GenCheckBox.__init__`                                    Default class constructor.
:meth:`~wx.lib.checkbox.GenCheckBox.AcceptsFocus`                                Overridden base class virtual.
:meth:`~wx.lib.checkbox.GenCheckBox.AcceptsFocusFromKeyboard`                    Overridden base class virtual.
:meth:`~wx.lib.checkbox.GenCheckBox.DoGetBestSize`                               Overridden base class virtual.  Determines the best size of the control
:meth:`~wx.lib.checkbox.GenCheckBox.Draw`                                        Actually performs the drawing operations, for the bitmap and
:meth:`~wx.lib.checkbox.GenCheckBox.Enable`                                      Enables/Disables :class:`GenCheckBox`.
:meth:`~wx.lib.checkbox.GenCheckBox.GetBitmap`                                   Returns the appropriated bitmap depending on the checking state
:meth:`~wx.lib.checkbox.GenCheckBox.GetDefaultAttributes`                        Overridden base class virtual.  By default we should use
:meth:`~wx.lib.checkbox.GenCheckBox.GetSpacing`                                  Returns the spacing between the check bitmap and the text.
:meth:`~wx.lib.checkbox.GenCheckBox.GetValue`                                    Returns the state of :class:`GenCheckBox`, ``True`` if checked, ``False`` otherwise.
:meth:`~wx.lib.checkbox.GenCheckBox.HasFocus`                                    Returns whether or not we have the focus.
:meth:`~wx.lib.checkbox.GenCheckBox.InitializeBitmaps`                           Initializes the check bitmaps.
:meth:`~wx.lib.checkbox.GenCheckBox.InitializeColours`                           Initializes the focus indicator pen.
:meth:`~wx.lib.checkbox.GenCheckBox.IsChecked`                                   This is just a maybe more readable synonym for GetValue: just as the
:meth:`~wx.lib.checkbox.GenCheckBox.OnKeyEvent`                                  Handles the ``wx.EVT_KEY_UP`` or ``wx.EVT_KEY_UP`` event (depending on
:meth:`~wx.lib.checkbox.GenCheckBox.OnKillFocus`                                 Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`GenCheckBox`.
:meth:`~wx.lib.checkbox.GenCheckBox.OnMouseClick`                                Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`GenCheckBox`.
:meth:`~wx.lib.checkbox.GenCheckBox.OnPaint`                                     Handles the ``wx.EVT_PAINT`` event for :class:`GenCheckBox`.
:meth:`~wx.lib.checkbox.GenCheckBox.OnSetFocus`                                  Handles the ``wx.EVT_SET_FOCUS`` event for :class:`GenCheckBox`.
:meth:`~wx.lib.checkbox.GenCheckBox.OnSize`                                      Handles the ``wx.EVT_SIZE`` event for :class:`GenCheckBox`.
:meth:`~wx.lib.checkbox.GenCheckBox.SendCheckBoxEvent`                           Actually sends the wx.wxEVT_COMMAND_CHECKBOX_CLICKED event.
:meth:`~wx.lib.checkbox.GenCheckBox.SetBackgroundColour`                         Overridden base class virtual.
:meth:`~wx.lib.checkbox.GenCheckBox.SetFont`                                     Sets the :class:`GenCheckBox` text font and updates the control's
:meth:`~wx.lib.checkbox.GenCheckBox.SetForegroundColour`                         Overridden base class virtual.
:meth:`~wx.lib.checkbox.GenCheckBox.SetLabel`                                    Sets the :class:`GenCheckBox` text label and updates the control's
:meth:`~wx.lib.checkbox.GenCheckBox.SetSpacing`                                  Sets a new spacing between the check bitmap and the text.
:meth:`~wx.lib.checkbox.GenCheckBox.SetValue`                                    Sets the :class:`GenCheckBox` to the given state. This does not cause a
:meth:`~wx.lib.checkbox.GenCheckBox.ShouldInheritColours`                        Overridden base class virtual.  If the parent has non-default
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: GenCheckBox(wx.Control)

   A generic class that replicates some of the functionalities of :class:`wx.Checkbox`,
   while being completely owner-drawn with a nice check bitmaps.

   .. method:: __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator, name="GenCheckBox")

      Default class constructor.
      
      :param `parent`: Pointer to a parent window. Must not be ``None``.
      :type `parent`: `wx.Window`
      :param `id`: Window identifier. ``wx.ID_ANY`` indicates a default value.
      :type `id`: int
      :param `label`: Text to be displayed next to the checkbox.
      :type `label`: str
      :param `pos`: Window position. The value ``wx.DefaultPosition`` indicates
       a default position, chosen by either the windowing system or wxWidgets, depending on platform.
      :type `pos`: `wx.Point`
      :param `size`: Window size. The value ``wx.DefaultSize`` indicates a default size,
       chosen by either the windowing system or wxWidgets, depending on platform.
      :type `size`: `wx.Size`
      :param `style`: Window style. Not used in this widget, GenCheckBox has only 2 state.
      :type `style`: long
      :param `validator`: Window validator.
      :type `validator`: `wx.Validator`
      :param `name`: Window name.
      :type `name`: str


   .. method:: AcceptsFocus(self)

      Overridden base class virtual. 


   .. method:: AcceptsFocusFromKeyboard(self)

      Overridden base class virtual. 


   .. method:: DoGetBestSize(self)

      Overridden base class virtual.  Determines the best size of the control
      based on the label size, the bitmap size and the current font.


   .. method:: Draw(self, dc)

      Actually performs the drawing operations, for the bitmap and
      for the text, positioning them centered vertically.
      
      :param `dc`: device context to use.
      :type `dc`: `wx.DC`


   .. method:: Enable(self, enable=True)

      Enables/Disables :class:`GenCheckBox`.
      
      :param `enable`: Set the enabled state of the checkbox.
      :type `enable`: bool


   .. method:: GetBitmap(self)

      Returns the appropriated bitmap depending on the checking state
      (Checked/UnChecked) and the control state (Enabled/Disabled).


   .. method:: GetDefaultAttributes(self)

      Overridden base class virtual.  By default we should use
      the same font/colour attributes as the native wx.CheckBox.


   .. method:: GetSpacing(self)

      Returns the spacing between the check bitmap and the text. 


   .. method:: GetValue(self)

      Returns the state of :class:`GenCheckBox`, ``True`` if checked, ``False`` otherwise.


   .. method:: HasFocus(self)

      Returns whether or not we have the focus. 


   .. method:: InitializeBitmaps(self)

      Initializes the check bitmaps. 


   .. method:: InitializeColours(self)

      Initializes the focus indicator pen. 


   .. method:: IsChecked(self)

      This is just a maybe more readable synonym for GetValue: just as the
      latter, it returns ``True`` if the :class:`GenCheckBox` is checked and ``False`` otherwise.


   .. method:: OnKeyEvent(self, event)

      Handles the ``wx.EVT_KEY_UP`` or ``wx.EVT_KEY_UP`` event (depending on
      platform) for :class:`GenCheckBox`.
      
      :param `event`: A `wx.KeyEvent` to be processed.
      :type `event`: `wx.KeyEvent`


   .. method:: OnKillFocus(self, event)

      Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`GenCheckBox`.
      
      :param `event`: A `wx.FocusEvent` to be processed.
      :type `event`: `wx.FocusEvent`


   .. method:: OnMouseClick(self, event)

      Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`GenCheckBox`.
      
      :param `event`: A `wx.MouseEvent` to be processed.
      :type `event`: `wx.MouseEvent`


   .. method:: OnPaint(self, event)

      Handles the ``wx.EVT_PAINT`` event for :class:`GenCheckBox`.
      
      :param `event`: A `wx.PaintEvent` to be processed.
      :type `event`: `wx.PaintEvent`


   .. method:: OnSetFocus(self, event)

      Handles the ``wx.EVT_SET_FOCUS`` event for :class:`GenCheckBox`.
      
      :param `event`: A `wx.FocusEvent` to be processed.
      :type `event`: `wx.FocusEvent`


   .. method:: OnSize(self, event)

      Handles the ``wx.EVT_SIZE`` event for :class:`GenCheckBox`.
      
      :param `event`: A `wx.SizeEvent` to be processed.
      :type `event`: `wx.SizeEvent`


   .. method:: SendCheckBoxEvent(self)

      Actually sends the wx.wxEVT_COMMAND_CHECKBOX_CLICKED event. 


   .. method:: SetBackgroundColour(self, colour)

      Overridden base class virtual.
      
      :param `colour`: Set the background colour of the checkbox.
      :type `colour`: `wx.Colour`


   .. method:: SetFont(self, font)

      Sets the :class:`GenCheckBox` text font and updates the control's
      size to exactly fit the label plus the bitmap.
      
      :param `font`: Font to be used to render the checkboxs label.
      :type `font`: `wx.Font`


   .. method:: SetForegroundColour(self, colour)

      Overridden base class virtual.
      
      :param `colour`: Set the foreground colour of the checkboxs label.
      :type `colour`: `wx.Colour`


   .. method:: SetLabel(self, label)

      Sets the :class:`GenCheckBox` text label and updates the control's
      size to exactly fit the label plus the bitmap.
      
      :param `label`: Text to be displayed next to the checkbox.
      :type `label`: str


   .. method:: SetSpacing(self, spacing)

      Sets a new spacing between the check bitmap and the text.
      
      :param `spacing`: Set the amount of space between the checkboxs bitmap and text.
      :type `spacing`: int


   .. method:: SetValue(self, state)

      Sets the :class:`GenCheckBox` to the given state. This does not cause a
      ``wx.wxEVT_COMMAND_CHECKBOX_CLICKED`` event to get emitted.
      
      :param `state`: Set the value of the checkbox. ``True`` or False.
      :type `state`: bool


   .. method:: ShouldInheritColours(self)

      Overridden base class virtual.  If the parent has non-default
      colours then we want this control to inherit them.


