*************************** wx.combo.OwnerDrawnComboBox *************************** Inheritance diagram for `wx.combo.OwnerDrawnComboBox`: | .. inheritance-diagram:: wx.combo.OwnerDrawnComboBox | Description =========== `wx.combo.OwnerDrawnComboBox` is a combobox with owner-drawn list items. In essence, it is a `wx.combo.ComboCtrl `_ with `wx.VListBox <../Widgets/wx.VListBox.html>`_ popup and `wx.ControlWithItems <../Widgets/wx.ControlWithItems.html>`_ interface. Implementing item drawing and measuring is similar to `wx.VListBox <../Widgets/wx.VListBox.html>`_. Application needs to subclass `wx.combo.OwnerDrawnComboBox` and implement `OnDrawItem <#OnDrawItem>`_, `OnMeasureItem <#OnMeasureItem>`_ and `OnMeasureItemWidth <#OnMeasureItemWidth>`_. .. seealso:: `wx.combo.ComboCtrl `_, `wx.ComboBox <../Widgets/wx.ComboBox.html>`_, `wx.VListBox <../Widgets/wx.VListBox.html>`_, `wx.CommandEvent <../Events/wx.CommandEvent.html>`_ Derived From ^^^^^^^^^^^^^ * `wx.combo.ComboCtrl `_ * `wx.ControlWithItems <../Widgets/wx.ControlWithItems.html>`_ * `wx.Control <../Widgets/wx.Control.html>`_ * `wx.Window <../Widgets/wx.Window.html>`_ * `wx.EvtHandler <../Widgets/wx.EvtHandler.html>`_ * `wx.Object <../Widgets/wx.Object.html>`_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.combo.BitmapComboBox `_ Window Styles ^^^^^^^^^^^^^ ================================================== ================================================== Window Style Description ================================================== ================================================== ``wx.combo.ODCB_DCLICK_CYCLES`` Double-clicking cycles item if ``wx.CB_READONLY`` is also used. Synonymous with ``wx.combo.CC_SPECIAL_DCLICK``. ``wx.combo.ODCB_STD_CONTROL_PAINT`` Control itself is not custom painted using `OnDrawItem <#OnDrawItem>`_. Even if this style is not used, writable `wx.combo.OwnerDrawnComboBox` is never custom painted unless `SetCustomPaintWidth `_ is called. ================================================== ================================================== Event Handling ^^^^^^^^^^^^^^ ================================================== ================================================== Event Name Description ================================================== ================================================== wx.EVT_COMBOBOX(id, func) Process a ``wx.wxEVT_COMMAND_COMBOBOX_SELECTED`` event, when an item on the list is selected. Note that calling `GetValue `_ returns the new value of selection. ================================================== ================================================== .. seealso:: See also events emitted by `wx.combo.ComboCtrl `_ | Control Appearance ^^^^^^^^^^^^^^^^^^ | .. figure:: ../images/wxWidgets/wxmsw/ownerdrawncombobox.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: ../images/wxWidgets/wxmac/ownerdrawncombobox.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: ../images/wxWidgets/wxgtk/ownerdrawncombobox.png :alt: wxGTK :figclass: floatcenter **wxGTK** | Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `Create <#Create>`_ * `GetWidestItem <#GetWidestItem>`_ * `GetWidestItemWidth <#GetWidestItemWidth>`_ * `OnDrawBackground <#OnDrawBackground>`_ * `OnDrawItem <#OnDrawItem>`_ * `OnMeasureItem <#OnMeasureItem>`_ * `OnMeasureItemWidth <#OnMeasureItemWidth>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(parent, id=-1, value="", pos=wx.DefaultPosition, size=wx.DefaultSize, choices=[], style=0, validator=wx.DefaultValidator, name=wx.PyComboBoxNameStr) Standard constructor, creating and showing a owner-drawn combobox. **Parameters:** * `parent` (`wx.Window <../Widgets/wx.Window.html>`_) * `id` (int) * `value` (string) * `pos` (`wx.Point <../Widgets/wx.Point.html>`_) * `size` (`wx.Size <../Widgets/wx.Size.html>`_) * `choices` (list of strings) * `style` (long) * `validator` (`wx.Validator <../Widgets/wx.Validator.html>`_) * `name` (string) | **Returns:** `wx.combo.OwnerDrawnComboBox `_ -------- .. method:: Create(parent, id=-1, value="", pos=wx.DefaultPosition, size=wx.DefaultSize, choices=[], style=0, validator=wx.DefaultValidator, name=wx.PyComboBoxNameStr) Creates the combobox for two-step construction. Derived classes should call or replace this function. **Parameters:** * `parent` (`wx.Window <../Widgets/wx.Window.html>`_) * `id` (int) * `value` (string) * `pos` (`wx.Point <../Widgets/wx.Point.html>`_) * `size` (`wx.Size <../Widgets/wx.Size.html>`_) * `choices` (list of strings) * `style` (long) * `validator` (`wx.Validator <../Widgets/wx.Validator.html>`_) * `name` (string) | **Returns:** `bool` -------- .. method:: GetWidestItem() Returns index to the widest item in the list. | **Returns:** `int` -------- .. method:: GetWidestItemWidth() Returns width of the widest item in the list. | **Returns:** `int` -------- .. method:: OnDrawBackground(dc, rect, item, flags) This method is used to draw the items background and, maybe, a border around it. The base class version implements a reasonable default behaviour which consists in drawing the selected item with the standard background colour and drawing a border around the item if it is either selected or current. **Parameters:** * `dc` (`wx.DC <../Widgets/wx.DC.html>`_): The device context to use for drawing. * `rect` (`wx.Rect <../Widgets/wx.Rect.html>`_): The bounding rectangle for the item being drawn (DC clipping region is set to this rectangle before calling this function) * `item` (int): The index of the item to be drawn * `flags` (int): see `OnDrawItem <#OnDrawItem>`_ .. note:: `flags` has the same meaning as with `OnDrawItem <#OnDrawItem>`_ -------- .. method:: OnDrawItem(dc, rect, item, flags) The derived class may implement this function to actually draw the item with the given index on the provided DC. If function is not implemented, the item text is simply drawn, as if the control was a normal combobox. **Parameters:** * `dc` (`wx.DC <../Widgets/wx.DC.html>`_): The device context to use for drawing * `rect` (`wx.Rect <../Widgets/wx.Rect.html>`_): The bounding rectangle for the item being drawn (DC clipping region is set to this rectangle before calling this function) * `item` (int): The index of the item to be drawn * `flags` (int): Combines any of the following flag values: ============================== ===================================== Painting Flags Description ============================== ===================================== ``wx.ODCB_PAINTING_CONTROL`` Combo control is being painted, instead of a list item. Argument item may be ``wx.NOT_FOUND`` in this case. ``wx.ODCB_PAINTING_SELECTED`` An item with selection background is being painted. DC text colour should already be correct. ============================== ===================================== -------- .. method:: OnMeasureItem(item) The derived class may implement this method to return the height of the specified item (in pixels). The default implementation returns text height, as if this control was a normal combobox. **Parameters:** * `item` (long) | **Returns:** `int` -------- .. method:: OnMeasureItemWidth(item) The derived class may implement this method to return the width of the specified item (in pixels). If -1 is returned, then the item text width is used. The default implementation returns -1. **Parameters:** * `item` (long) | **Returns:** `int`