wx.adv.OwnerDrawnComboBox¶
wx.adv.OwnerDrawnComboBox is a combobox with owner-drawn list items.
In essence, it is a wx.ComboCtrl with wx.VListBox popup and wx.ControlWithItems interface.
Implementing item drawing and measuring is similar to wx.VListBox. Application needs to subclass wx.adv.OwnerDrawnComboBox and implement OnDrawItem
, OnMeasureItem
and OnMeasureItemWidth
.
Window Styles¶
This class supports the following styles:
wx.adv.ODCB_DCLICK_CYCLES
: Double-clicking cycles item ifwx.CB_READONLY
is also used. Synonymous withwx.CC_SPECIAL_DCLICK
.wx.adv.ODCB_STD_CONTROL_PAINT
: Control itself is not custom painted using OnDrawItem. Even if this style is not used, writable wx.adv.OwnerDrawnComboBox is never custom painted unlessSetCustomPaintWidth
is called.
Events Emitted by this Class¶
Handlers bound for the following event types will receive a wx.CommandEvent parameter.
EVT_COMBOBOX: Process a wxEVT_COMBOBOX event, when an item on the list is selected. Note that calling
GetValue
returns the new value of selection.
See also
wx.ComboCtrl window styles and Window Styles.
See also
Events emitted by wx.ComboCtrl.
See also
Class Hierarchy¶
Control Appearance¶
Methods Summary¶
Default constructor. |
|
Creates the combobox for two-step construction. |
|
Returns index to the widest item in the list. |
|
Returns width of the widest item in the list. |
|
Returns |
|
Returns |
|
This method is used to draw the items background and, maybe, a border around it. |
|
The derived class may implement this function to actually draw the item with the given index on the provided DC. |
|
The derived class may implement this method to return the height of the specified item (in pixels). |
|
The derived class may implement this method to return the width of the specified item (in pixels). |
Properties Summary¶
See |
|
Class API¶
- class wx.adv.OwnerDrawnComboBox(ComboCtrl, ItemContainer)¶
Possible constructors:
OwnerDrawnComboBox() -> None OwnerDrawnComboBox(parent, id=ID_ANY, value='', pos=DefaultPosition, size=DefaultSize, choices=[], style=0, validator=DefaultValidator, name="comboBox") -> None
OwnerDrawnComboBox is a combobox with owner-drawn list items.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor.
- Return type:
None
__init__ (self, parent, id=ID_ANY, value=’’, pos=DefaultPosition, size=DefaultSize, choices=[], style=0, validator=DefaultValidator, name=”comboBox”)
Constructor, creating and showing a owner-drawn combobox.
- Parameters:
parent (wx.Window) – Parent window. Must not be
None
.id (wx.WindowID) – Window identifier. The value
ID_ANY
indicates a default value.value (string) – Initial selection string. An empty string indicates no selection.
pos (wx.Point) – Window position.
size (wx.Size) – Window size. If
wx.DefaultSize
is specified then the window is sized appropriately.choices (list of strings) – An array of strings with which to initialise the control.
style (long) – Window style. See wx.adv.OwnerDrawnComboBox.
validator (wx.Validator) – Window validator.
name (string) – Window name.
- Return type:
None
See also
- Create(self, parent, id=ID_ANY, value='', pos=DefaultPosition, size=DefaultSize, choices=[], style=0, validator=DefaultValidator, name=ComboBoxNameStr)¶
Creates the combobox for two-step construction.
See wx.adv.OwnerDrawnComboBox for further details.
- Parameters:
parent (wx.Window)
id (wx.WindowID)
value (string)
pos (wx.Point)
size (wx.Size)
choices (list of strings)
style (long)
validator (wx.Validator)
name (string)
- Return type:
bool
Note
Derived classes should call or replace this function.
- static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
- Parameters:
variant (WindowVariant)
- Return type:
VisualAttributes
- GetWidestItem(self)¶
Returns index to the widest item in the list.
- Return type:
int
- GetWidestItemWidth(self)¶
Returns width of the widest item in the list.
- Return type:
int
- IsListEmpty(self)¶
Returns
True
if the list of combobox choices is empty.Use this method instead of (not available in this class)
IsEmpty
to test if the list of items is empty.- Return type:
bool
Added in version 4.1/wxWidgets-3.1.0.
- IsTextEmpty(self)¶
Returns
True
if the text of the combobox is empty.Use this method instead of (not available in this class)
IsEmpty
to test if the text currently entered into the combobox is empty.- Return type:
bool
Added in version 4.1/wxWidgets-3.1.0.
- OnDrawBackground(self, 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.
Note
flags has the same meaning as with
OnDrawItem
.
- OnDrawItem(self, 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) – The device context to use for drawing
rect (wx.Rect) – 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) – A combination of the wx.adv.OwnerDrawnComboBoxPaintingFlags enumeration values.
- Return type:
None
- OnMeasureItem(self, 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 (int)
- Return type:
int
- OnMeasureItemWidth(self, 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 (int)
- Return type:
int
Properties¶
- WidestItem¶
See
GetWidestItem
- WidestItemWidth¶