1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxVListBox documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxVListBox
}}\label{wxvlistbox
}
14 wxVListBox is a listbox-like control with the following two main differences
15 from a regular listbox: it can have an arbitrarily huge number of items because
16 it doesn't store them itself but uses
\helpref{OnDrawItem()
}{wxvlistboxondrawitem
}
17 callback to draw them (so it is a
{\Large V
}irtual listbox) and its items can
18 have variable height as determined by
19 \helpref{OnMeasureItem()
}{wxvlistboxonmeasureitem
} (so it is also a listbox
20 with the lines of
{\Large V
}ariable height).
22 Also, as a consequence of its virtual nature, it doesn't have any methods to
23 append or insert items in it as it isn't necessary to do it: you just have to
24 call
\helpref{SetItemCount()
}{wxvlistboxsetitemcount
} to tell the control how
25 many items it should display. Of course, this also means that you will never
26 use this class directly because it has pure virtual functions, but will need to
27 derive your own class, such as
\helpref{wxHtmlListBox
}{wxhtmllistbox
}, from it.
29 However it emits the same events as
\helpref{wxListBox
}{wxlistbox
} and the same
30 event macros may be used with it.
32 \wxheading{Derived from
}
34 \helpref{wxVScrolledWindow
}{wxvscrolledwindow
}
36 \wxheading{Include files
}
40 \latexignore{\rtfignore{\wxheading{Members
}}}
43 \membersection{wxVListBox::wxVListBox
}\label{wxvlistboxctor
}
45 \func{}{wxVListBox
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id = wxID
\_ANY},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{size
\_t }{countItems =
0},
\param{long
}{style =
0},
\param{const wxString\&
}{name = wxVListBoxNameStr
}}
47 Normal constructor which calls
\helpref{Create()
}{wxvlistboxcreate
} internally.
49 \func{}{wxVListBox
}{\void}
51 Default constructor, you must call
\helpref{Create()
}{wxvlistboxcreate
} later.
54 \membersection{wxVListBox::Clear
}\label{wxvlistboxclear
}
56 \func{void
}{Clear
}{\void}
58 Deletes all items from the control.
61 \membersection{wxVListBox::Create
}\label{wxvlistboxcreate
}
63 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id = wxID
\_ANY},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{size
\_t }{countItems =
0},
\param{long
}{style =
0},
\param{const wxString\&
}{name = wxVListBoxNameStr
}}
65 Creates the control and optionally sets the initial number of items in it
66 (it may also be set or changed later with
67 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
}).
69 There are no special styles defined for wxVListBox, in particular the wxListBox
70 styles can not be used here.
72 Returns
{\tt true
} on success or
{\tt false
} if the control couldn't be created
75 \membersection{wxVListBox::GetItemCount
}\label{wxvlistboxgetitemcount
}
77 \constfunc{size
\_t}{GetItemCount
}{\void}
79 Get the number of items in the control.
83 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
}
86 \membersection{wxVListBox::GetSelection
}\label{wxvlistboxgetselection
}
88 \constfunc{int
}{GetSelection
}{\void}
90 Get the currently selected item or $-
1$ if there is no selection.
93 \membersection{wxVListBox::IsSelected
}\label{wxvlistboxisselected
}
95 \constfunc{bool
}{IsSelected
}{\param{size
\_t }{line
}}
97 Returns
{\tt true
} if this item is selected,
{\tt false
} otherwise.
100 \membersection{wxVListBox::OnDrawItem
}\label{wxvlistboxondrawitem
}
102 \constfunc{void
}{OnDrawItem
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{size
\_t }{n
}}
104 The derived class must implement this function to actually draw the item
105 with the given index on the provided DC.
107 \wxheading{Parameters
}
109 \docparam{dc
}{The device context to use for drawing
}
111 \docparam{rect
}{The bounding rectangle for the item being drawn (DC clipping
112 region is set to this rectangle before calling this function)
}
114 \docparam{n
}{The index of the item to be drawn
}
117 \membersection{wxVListBox::OnDrawSeparator
}\label{wxvlistboxondrawseparator
}
119 \constfunc{void
}{OnDrawSeparator
}{\param{wxDC\&
}{dc
},
\param{wxRect\&
}{rect
},
\param{size
\_t }{n
}}
121 This method may be used to draw separators between the lines. The rectangle
122 passed to it may be modified, typically to deflate it a bit before passing to
123 \helpref{OnDrawItem()
}{wxvlistboxondrawitem
}.
125 The base class version of this method doesn't do anything.
127 \wxheading{Parameters
}
129 \docparam{dc
}{The device context to use for drawing
}
131 \docparam{rect
}{The bounding rectangle for the item
}
133 \docparam{n
}{The index of the item
}
136 \membersection{wxVListBox::OnMeasureItem
}\label{wxvlistboxonmeasureitem
}
138 \constfunc{wxCoord
}{OnMeasureItem
}{\param{size
\_t }{n
}}
140 The derived class must implement this method to return the height of the
141 specified item (in pixels).
144 \membersection{wxVListBox::SetItemCount
}\label{wxvlistboxsetitemcount
}
146 \func{void
}{SetItemCount
}{\param{size
\_t }{count
}}
148 Set the number of items to be shown in the control.
150 This is just a synonym for
151 \helpref{wxVScrolledWindow::SetLineCount()
}{wxvscrolledwindowsetlinecount
}.
154 \membersection{wxVListBox::SetMargins
}\label{wxvlistboxsetmargins
}
156 \func{void
}{SetMargins
}{\param{const wxPoint\&
}{pt
}}
158 \func{void
}{SetMargins
}{\param{wxCoord
}{x
},
\param{wxCoord
}{y
}}
160 Set the margins: horizontal margin is the distance between the window
161 border and the item contents while vertical margin is half of the
162 distance between items.
164 By default both margins are $
0$.
167 \membersection{wxVListBox::SetSelection
}\label{wxvlistboxsetselection
}
169 \func{void
}{SetSelection
}{\param{int
}{selection
}}
171 Set the selection to the specified item, if it is $-
1$ the selection is
172 unset. The selected item will be automatically scrolled into view if it isn't