phoenix_title 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.

^^

styles Window Styles

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. ^^

^^

events 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.

class_hierarchy Class Hierarchy

Inheritance diagram for class OwnerDrawnComboBox:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__

Default constructor.

Create

Creates the combobox for two-step construction.

GetClassDefaultAttributes

GetWidestItem

Returns index to the widest item in the list.

GetWidestItemWidth

Returns width of the widest item in the list.

IsListEmpty

Returns True if the list of combobox choices is empty.

IsTextEmpty

Returns True if the text of the combobox is empty.

OnDrawBackground

This method is used to draw the items background and, maybe, a border around it.

OnDrawItem

The derived class may implement this function to actually draw the item with the given index on the provided DC.

OnMeasureItem

The derived class may implement this method to return the height of the specified item (in pixels).

OnMeasureItemWidth

The derived class may implement this method to return the width of the specified item (in pixels).


property_summary Properties Summary

WidestItem

See GetWidestItem

WidestItemWidth

See GetWidestItemWidth


api Class API

class 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.


Methods

__init__(self, *args, **kw)

overload Overloaded Implementations:



__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.

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.

See also

Create , wx.Validator





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

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.

Return type:

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.

Parameters:
  • dc (wx.DC) –

  • rect (wx.Rect) –

  • item (int) –

  • flags (int) –

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.



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:

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.

Parameters:

item (int) –

Return type:

wx.Coord


Properties

WidestItem

See GetWidestItem



WidestItemWidth

See GetWidestItemWidth