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
.
^^
This class supports the following styles:
wx.adv.ODCB_DCLICK_CYCLES
: Double-clicking cycles item if wx.CB_READONLY
is also used. Synonymous with wx.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 unless SetCustomPaintWidth
is called. ^^
^^
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. ^^
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). |
See |
|
wx.adv.
OwnerDrawnComboBox
(ComboCtrl, ItemContainer)¶Possible constructors:
OwnerDrawnComboBox()
OwnerDrawnComboBox(parent, id=ID_ANY, value="", pos=DefaultPosition,
size=DefaultSize, choices=[], style=0, validator=DefaultValidator,
name="comboBox")
OwnerDrawnComboBox is a combobox with owner-drawn list items.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__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.
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.
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.
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) –
bool
Note
Derived classes should call or replace this function.
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
VisualAttributes
GetWidestItem
(self)¶Returns index to the widest item in the list.
int
GetWidestItemWidth
(self)¶Returns width of the widest item in the list.
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.
bool
New 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.
bool
New 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.
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.
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.
item (int) –
wx.Coord
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.
item (int) –
wx.Coord
WidestItem
¶See GetWidestItem
WidestItemWidth
¶