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{wxControlWithItems
}{wxcontrolwithitems
}\\
29 \helpref{wxControl
}{wxcontrol
}\\
30 \helpref{wxWindow
}{wxwindow
}\\
31 \helpref{wxEvtHandler
}{wxevthandler
}\\
32 \helpref{wxObject
}{wxobject
}
34 \wxheading{Include files
}
38 \wxheading{Window styles
}
40 \begin{twocollist
}\itemsep=
0pt
41 \twocolitem{\windowstyle{wxODCB
\_DCLICK\_CYCLES}}{Double-clicking cycles item
42 if wxCB
\_READONLY is also used. Synonymous with wxCC
\_SPECIAL\_DCLICK.
}
43 \twocolitem{\windowstyle{wxODCB
\_STD\_CONTROL\_PAINT}}{Control itself is not
44 custom painted using OnDrawItem. Even if this style is not used, writable
45 wxOwnerDrawnComboBox is never custom painted unless SetCustomPaintWidth is
49 See also
\helpref{wxComboCtrl window styles
}{wxcomboctrl
} and
50 base
\helpref{window styles overview
}{windowstyles
}.
52 \wxheading{Event handling
}
55 \begin{twocollist
}\itemsep=
0pt
56 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
57 when an item on the list is selected. Note that calling
58 \helpref{GetValue
}{wxcomboctrlgetvalue
} returns the new value of selection.
}
61 See also events emitted by
\helpref{wxComboCtrl
}{wxcomboctrl
}.
65 \helpref{wxComboCtrl
}{wxcomboctrl
},
\helpref{wxComboBox
}{wxcombobox
},
\helpref{wxVListBox
}{wxvlistbox
},
66 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
69 \latexignore{\rtfignore{\wxheading{Members
}}}
72 \membersection{wxOwnerDrawnComboBox::wxOwnerDrawnComboBox
}\label{wxownerdrawncomboboxctor
}
74 \func{}{wxOwnerDrawnComboBox
}{\void}
78 \func{}{wxOwnerDrawnComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
79 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
80 \param{int
}{ n =
0},
\param{const wxString
}{choices
[] = NULL
},
\rtfsp
81 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
83 \func{}{wxOwnerDrawnComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
84 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
85 \param{const wxArrayString\&
}{choices
},
\rtfsp
86 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
88 Constructor, creating and showing a owner-drawn combobox.
90 \wxheading{Parameters
}
92 \docparam{parent
}{Parent window. Must not be NULL.
}
94 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
96 \docparam{value
}{Initial selection string. An empty string indicates no selection.
}
98 \docparam{pos
}{Window position.
}
100 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
103 \docparam{n
}{Number of strings with which to initialise the control.
}
105 \docparam{choices
}{An array of strings with which to initialise the control.
}
107 \docparam{style
}{Window style. See
\helpref{wxOwnerDrawnComboBox
}{wxownerdrawncombobox
}.
}
109 \docparam{validator
}{Window validator.
}
111 \docparam{name
}{Window name.
}
115 \helpref{wxOwnerDrawnComboBox::Create
}{wxownerdrawncomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
118 \membersection{wxOwnerDrawnComboBox::
\destruct{wxOwnerDrawnComboBox
}}\label{wxownerdrawncomboboxdtor
}
120 \func{}{\destruct{wxOwnerDrawnComboBox
}}{\void}
122 Destructor, destroying the owner-drawn combobox.
125 \membersection{wxOwnerDrawnComboBox::Create
}\label{wxownerdrawncomboboxcreate
}
127 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
128 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
129 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
130 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
132 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
133 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
134 \param{const wxArrayString\&
}{choices
},
\rtfsp
135 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
137 Creates the combobox for two-step construction. Derived classes
138 should call or replace this function. See
139 \helpref{wxOwnerDrawnComboBox::wxOwnerDrawnComboBox
}{wxownerdrawncomboboxctor
}\rtfsp
143 \membersection{wxOwnerDrawnComboBox::GetWidestItem
}\label{wxownerdrawncomboboxgetwidestitem
}
145 \constfunc{int
}{GetWidestItem
}{\void}
147 Returns index to the widest item in the list.
150 \membersection{wxOwnerDrawnComboBox::GetWidestItemWidth
}\label{wxownerdrawncomboboxgetwidestitemwidth
}
152 \constfunc{int
}{GetWidestItemWidth
}{\void}
154 Returns width of the widest item in the list.
157 \membersection{wxOwnerDrawnComboBox::OnDrawBackground
}\label{wxownerdrawncomboboxondrawbackground
}
159 \constfunc{void
}{OnDrawBackground
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{item
},
\param{int
}{flags
}}
161 This method is used to draw the items background and, maybe, a border around it.
163 The base class version implements a reasonable default behaviour which consists
164 in drawing the selected item with the standard background colour and drawing a
165 border around the item if it is either selected or current.
169 \arg{flags
} has the same meaning as with
\helpref{OnDrawItem
}{wxownerdrawncomboboxondrawitem
}.
172 \membersection{wxOwnerDrawnComboBox::OnDrawItem
}\label{wxownerdrawncomboboxondrawitem
}
174 \constfunc{void
}{OnDrawItem
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{item
},
\param{int
}{flags
}}
176 The derived class may implement this function to actually draw the item
177 with the given index on the provided DC. If function is not implemented,
178 the item text is simply drawn, as if the control was a normal combobox.
180 \wxheading{Parameters
}
182 \docparam{dc
}{The device context to use for drawing
}
184 \docparam{rect
}{The bounding rectangle for the item being drawn (DC clipping
185 region is set to this rectangle before calling this function)
}
187 \docparam{item
}{The index of the item to be drawn
}
189 \docparam{flags
}{Combines any of the following flag values:
}
192 \begin{twocollist
}\itemsep=
0pt
193 \twocolitem{{\tt wxODCB
\_PAINTING\_CONTROL}}{Combo control is being
194 painted, instead of a list item. Argument item may be wxNOT
\_FOUND in this
196 \twocolitem{{\tt wxODCB
\_PAINTING\_SELECTED}}{An item with selection
197 background is being painted. DC text colour should already be correct.
}
201 \membersection{wxOwnerDrawnComboBox::OnMeasureItem
}\label{wxownerdrawncomboboxonmeasureitem
}
203 \constfunc{wxCoord
}{OnMeasureItem
}{\param{size
\_t }{item
}}
205 The derived class may implement this method to return the height of the
206 specified item (in pixels).
208 The default implementation returns text height, as if this control was
212 \membersection{wxOwnerDrawnComboBox::OnMeasureItemWidth
}\label{wxownerdrawncomboboxonmeasureitemwidth
}
214 \constfunc{wxCoord
}{OnMeasureItemWidth
}{\param{size
\_t }{item
}}
216 The derived class may implement this method to return the width of the
217 specified item (in pixels). If -
1 is returned, then the item text width
220 The default implementation returns -
1.