1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxOwnerDrawnComboBox docs
4 %% Author: Jaakko Salli
8 %% Copyright: (c) Jaakko Salli
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxOwnerDrawnComboBox
}}\label{wxownerdrawncombobox
}
14 wxOwnerDrawnComboBox is a combobox with owner-drawn list items.
15 In essence, it is a
\helpref{wxComboCtrl
}{wxcomboctrl
} with
16 \helpref{wxVListBox
}{wxvlistbox
} popup and
\helpref{wxControlWithItems
}{wxcontrolwithitems
}
19 Implementing item drawing and measuring is similar to
\helpref{wxVListBox
}{wxvlistbox
}.
20 Application needs to subclass wxOwnerDrawnComboBox and implement
21 \helpref{OnDrawItem()
}{wxownerdrawncomboboxondrawitem
},
\helpref{OnMeasureItem()
}{wxownerdrawncomboboxonmeasureitem
}
22 and
\helpref{OnMeasureItemWidth()
}{wxownerdrawncomboboxonmeasureitemwidth
}.
25 \wxheading{Derived from
}
27 \helpref{wxComboCtrl
}{wxcomboctrl
}\\
28 \helpref{wxControl
}{wxcontrol
}\\
29 \helpref{wxWindow
}{wxwindow
}\\
30 \helpref{wxEvtHandler
}{wxevthandler
}\\
31 \helpref{wxObject
}{wxobject
}
33 \wxheading{Include files
}
39 \helpref{wxAdv
}{librarieslist
}
41 \wxheading{Window styles
}
43 \begin{twocollist
}\itemsep=
0pt
44 \twocolitem{\windowstyle{wxODCB
\_DCLICK\_CYCLES}}{Double-clicking cycles item
45 if wxCB
\_READONLY is also used. Synonymous with wxCC
\_SPECIAL\_DCLICK.
}
46 \twocolitem{\windowstyle{wxODCB
\_STD\_CONTROL\_PAINT}}{Control itself is not
47 custom painted using OnDrawItem. Even if this style is not used, writable
48 wxOwnerDrawnComboBox is never custom painted unless SetCustomPaintWidth is
52 See also
\helpref{wxComboCtrl window styles
}{wxcomboctrl
} and
53 base
\helpref{window styles overview
}{windowstyles
}.
55 \wxheading{Event handling
}
58 \begin{twocollist
}\itemsep=
0pt
59 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
60 when an item on the list is selected. Note that calling
61 \helpref{GetValue
}{wxcomboctrlgetvalue
} returns the new value of selection.
}
64 See also events emitted by
\helpref{wxComboCtrl
}{wxcomboctrl
}.
68 \helpref{wxComboCtrl
}{wxcomboctrl
},
\helpref{wxComboBox
}{wxcombobox
},
\helpref{wxVListBox
}{wxvlistbox
},
69 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
72 \latexignore{\rtfignore{\wxheading{Members
}}}
75 \membersection{wxOwnerDrawnComboBox::wxOwnerDrawnComboBox
}\label{wxownerdrawncomboboxctor
}
77 \func{}{wxOwnerDrawnComboBox
}{\void}
81 \func{}{wxOwnerDrawnComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
82 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
83 \param{int
}{ n =
0},
\param{const wxString
}{choices
[] = NULL
},
\rtfsp
84 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
86 \func{}{wxOwnerDrawnComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
87 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
88 \param{const wxArrayString\&
}{choices
},
\rtfsp
89 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
91 Constructor, creating and showing a owner-drawn combobox.
93 \wxheading{Parameters
}
95 \docparam{parent
}{Parent window. Must not be NULL.
}
97 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
99 \docparam{value
}{Initial selection string. An empty string indicates no selection.
}
101 \docparam{pos
}{Window position.
}
103 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
106 \docparam{n
}{Number of strings with which to initialise the control.
}
108 \docparam{choices
}{An array of strings with which to initialise the control.
}
110 \docparam{style
}{Window style. See
\helpref{wxOwnerDrawnComboBox
}{wxownerdrawncombobox
}.
}
112 \docparam{validator
}{Window validator.
}
114 \docparam{name
}{Window name.
}
118 \helpref{wxOwnerDrawnComboBox::Create
}{wxownerdrawncomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
121 \membersection{wxOwnerDrawnComboBox::
\destruct{wxOwnerDrawnComboBox
}}\label{wxownerdrawncomboboxdtor
}
123 \func{}{\destruct{wxOwnerDrawnComboBox
}}{\void}
125 Destructor, destroying the owner-drawn combobox.
128 \membersection{wxOwnerDrawnComboBox::Create
}\label{wxownerdrawncomboboxcreate
}
130 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
131 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
132 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
133 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
135 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
136 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
137 \param{const wxArrayString\&
}{choices
},
\rtfsp
138 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
140 Creates the combobox for two-step construction. Derived classes
141 should call or replace this function. See
142 \helpref{wxOwnerDrawnComboBox::wxOwnerDrawnComboBox
}{wxownerdrawncomboboxctor
}\rtfsp
146 \membersection{wxOwnerDrawnComboBox::GetWidestItem
}\label{wxownerdrawncomboboxgetwidestitem
}
148 \constfunc{int
}{GetWidestItem
}{\void}
150 Returns index to the widest item in the list.
153 \membersection{wxOwnerDrawnComboBox::GetWidestItemWidth
}\label{wxownerdrawncomboboxgetwidestitemwidth
}
155 \constfunc{int
}{GetWidestItemWidth
}{\void}
157 Returns width of the widest item in the list.
160 \membersection{wxOwnerDrawnComboBox::OnDrawBackground
}\label{wxownerdrawncomboboxondrawbackground
}
162 \constfunc{void
}{OnDrawBackground
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{item
},
\param{int
}{flags
}}
164 This method is used to draw the items background and, maybe, a border around it.
166 The base class version implements a reasonable default behaviour which consists
167 in drawing the selected item with the standard background colour and drawing a
168 border around the item if it is either selected or current.
172 \arg{flags
} has the same meaning as with
\helpref{OnDrawItem
}{wxownerdrawncomboboxondrawitem
}.
175 \membersection{wxOwnerDrawnComboBox::OnDrawItem
}\label{wxownerdrawncomboboxondrawitem
}
177 \constfunc{void
}{OnDrawItem
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{item
},
\param{int
}{flags
}}
179 The derived class may implement this function to actually draw the item
180 with the given index on the provided DC. If function is not implemented,
181 the item text is simply drawn, as if the control was a normal combobox.
183 \wxheading{Parameters
}
185 \docparam{dc
}{The device context to use for drawing
}
187 \docparam{rect
}{The bounding rectangle for the item being drawn (DC clipping
188 region is set to this rectangle before calling this function)
}
190 \docparam{item
}{The index of the item to be drawn
}
192 \docparam{flags
}{Combines any of the following flag values:
}
195 \begin{twocollist
}\itemsep=
0pt
196 \twocolitem{{\tt wxODCB
\_PAINTING\_CONTROL}}{Combo control is being
197 painted, instead of a list item. Argument item may be wxNOT
\_FOUND in this
199 \twocolitem{{\tt wxODCB
\_PAINTING\_SELECTED}}{An item with selection
200 background is being painted. DC text colour should already be correct.
}
204 \membersection{wxOwnerDrawnComboBox::OnMeasureItem
}\label{wxownerdrawncomboboxonmeasureitem
}
206 \constfunc{wxCoord
}{OnMeasureItem
}{\param{size
\_t }{item
}}
208 The derived class may implement this method to return the height of the
209 specified item (in pixels).
211 The default implementation returns text height, as if this control was
215 \membersection{wxOwnerDrawnComboBox::OnMeasureItemWidth
}\label{wxownerdrawncomboboxonmeasureitemwidth
}
217 \constfunc{wxCoord
}{OnMeasureItemWidth
}{\param{size
\_t }{item
}}
219 The derived class may implement this method to return the width of the
220 specified item (in pixels). If -
1 is returned, then the item text width
223 The default implementation returns -
1.