]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/htmllbox.h
few other fixes for wxChar => wxString
[wxWidgets.git] / interface / wx / htmllbox.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: htmllbox.h
e54c96f1 3// Purpose: interface of wxHtmlListBox
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxHtmlListBox
7c913512 11
9cc56d1f
FM
12 wxHtmlListBox is an implementation of wxVListBox which shows HTML content in
13 the listbox rows. This is still an abstract base class and you will need to
14 derive your own class from it (see htlbox sample for the example) but you will
15 only need to override a single wxHtmlListBox::OnGetItem function.
16
17 @beginEventTable{wxHtmlCellEvent,wxHtmlLinkEvent}
18 @event{EVT_HTML_CELL_CLICKED(id, func)}
19 A wxHtmlCell was clicked.
20 @event{EVT_HTML_CELL_HOVER(id, func)}
21 The mouse passed over a wxHtmlCell.
22 @event{EVT_HTML_LINK_CLICKED(id, func)}
23 A wxHtmlCell which contains an hyperlink was clicked.
24 @endEventTable
7c913512 25
23324ae1
FM
26 @library{wxhtml}
27 @category{ctrl}
7e59b885 28 @appearance{htmllistbox.png}
7c913512 29
e54c96f1 30 @see wxSimpleHtmlListBox
23324ae1
FM
31*/
32class wxHtmlListBox : public wxVListBox
33{
34public:
23324ae1 35 /**
9cc56d1f 36 Normal constructor which calls Create() internally.
23324ae1
FM
37 */
38 wxHtmlListBox(wxWindow* parent, wxWindowID id = wxID_ANY,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = 0,
42 const wxString& name = wxHtmlListBoxNameStr);
9cc56d1f
FM
43
44 /**
45 Default constructor, you must call Create() later.
46 */
7c913512 47 wxHtmlListBox();
23324ae1
FM
48
49 /**
50 Destructor cleans up whatever resources we use.
51 */
adaaa686 52 virtual ~wxHtmlListBox();
23324ae1
FM
53
54 /**
55 Creates the control and optionally sets the initial number of items in it
9cc56d1f
FM
56 (it may also be set or changed later with wxVListBox::SetItemCount).
57
23324ae1
FM
58 There are no special styles defined for wxHtmlListBox, in particular the
59 wxListBox styles (with the exception of @c wxLB_MULTIPLE) can not be used here.
9cc56d1f 60
23324ae1
FM
61 Returns @true on success or @false if the control couldn't be created
62 */
63 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
64 const wxPoint& pos = wxDefaultPosition,
65 const wxSize& size = wxDefaultSize,
66 long style = 0,
67 const wxString& name = wxHtmlListBoxNameStr);
68
69 //@{
70 /**
9cc56d1f
FM
71 Returns the wxFileSystem used by the HTML parser of this object.
72
73 The file system object is used to resolve the paths in HTML fragments
74 displayed in the control and you should use wxFileSystem::ChangePathTo
75 if you use relative paths for the images or other resources embedded in
76 your HTML.
23324ae1 77 */
9cc56d1f
FM
78 wxFileSystem& GetFileSystem() const;
79 const wxFileSystem& GetFileSystem() const;
23324ae1
FM
80 //@}
81
5e6e278d
FM
82protected:
83
84 /**
85 Called when the user clicks on hypertext link. Does nothing by default.
86 Overloading this method is deprecated; intercept the event instead.
87
88 @param n
89 Index of the item containing the link.
90 @param link
91 Description of the link.
92
93 @see See also wxHtmlLinkInfo.
94 */
95 virtual void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link);
96
23324ae1
FM
97 /**
98 This virtual function may be overridden to change the appearance of the
9cc56d1f
FM
99 background of the selected cells in the same way as GetSelectedTextColour().
100
101 It should be rarely, if ever, used because wxVListBox::SetSelectionBackground
102 allows to change the selection background for all cells at once and doing
103 anything more fancy is probably going to look strangely.
3c4f71cc 104
4cc4bfaf 105 @see GetSelectedTextColour()
23324ae1 106 */
0004982c 107 virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const;
23324ae1
FM
108
109 /**
110 This virtual function may be overridden to customize the appearance of the
4cc4bfaf 111 selected cells. It is used to determine how the colour @a colFg is going to
23324ae1
FM
112 look inside selection. By default all original colours are completely ignored
113 and the standard, system-dependent, selection colour is used but the program
114 may wish to override this to achieve some custom appearance.
3c4f71cc 115
4cc4bfaf
FM
116 @see GetSelectedTextBgColour(),
117 wxVListBox::SetSelectionBackground, wxSystemSettings::GetColour
23324ae1 118 */
0004982c 119 virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
23324ae1 120
23324ae1 121 /**
5e6e278d 122 This function may be overridden to decorate HTML returned by OnGetItem().
23324ae1 123 */
0004982c 124 virtual wxString OnGetItemMarkup(size_t n) const;
23324ae1 125
551266a9
FM
126 /**
127 This method must be implemented in the derived class and should return
128 the body (i.e. without @c html nor @c body tags) of the HTML fragment
129 for the given item.
9cc56d1f 130
551266a9
FM
131 Note that this function should always return a text fragment for the @a n item
132 which renders with the same height both when it is selected and when it's not:
133 i.e. if you call, inside your OnGetItem() implementation, @c IsSelected(n) to
134 make the items appear differently when they are selected, then you should make
9cc56d1f
FM
135 sure that the returned HTML fragment will render with the same height or else
136 you'll see some artifacts when the user selects an item.
551266a9 137 */
da1ed74c 138 virtual wxString OnGetItem(size_t n) const = 0;
23324ae1
FM
139};
140
141
e54c96f1 142
23324ae1
FM
143/**
144 @class wxSimpleHtmlListBox
7c913512 145
23324ae1
FM
146 wxSimpleHtmlListBox is an implementation of wxHtmlListBox which
147 shows HTML content in the listbox rows.
7c913512 148
9cc56d1f
FM
149 Unlike wxHtmlListBox, this is not an abstract class and thus it has the
150 advantage that you can use it without deriving your own class from it.
23324ae1 151 However, it also has the disadvantage that this is not a virtual control and
9cc56d1f
FM
152 thus it's not well-suited for those cases where you need to show a huge number
153 of items: every time you add/insert a string, it will be stored internally
154 and thus will take memory.
7c913512 155
23324ae1 156 The interface exposed by wxSimpleHtmlListBox fully implements the
9cc56d1f
FM
157 wxControlWithItems interface, thus you should refer to wxControlWithItems's
158 documentation for the API reference for adding/removing/retrieving items in
159 the listbox. Also note that the wxVListBox::SetItemCount function is
23324ae1 160 @c protected in wxSimpleHtmlListBox's context so that you cannot call it
9cc56d1f 161 directly, wxSimpleHtmlListBox will do it for you.
7c913512 162
23324ae1
FM
163 Note: in case you need to append a lot of items to the control at once, make
164 sure to use the
9cc56d1f 165 @ref wxControlWithItems::Append "Append(const wxArrayString&)" function.
7c913512 166
23324ae1
FM
167 Thus the only difference between a wxListBox and a wxSimpleHtmlListBox
168 is that the latter stores strings which can contain HTML fragments (see the
9cc56d1f 169 list of @ref overview_html_supptags "tags supported by wxHTML").
7c913512 170
23324ae1 171 Note that the HTML strings you fetch to wxSimpleHtmlListBox should not contain
9cc56d1f 172 the @c \<html\> or @c \<body\> tags.
7c913512 173
23324ae1 174 @beginStyleTable
8c6791e4 175 @style{wxHLB_DEFAULT_STYLE}
23324ae1 176 The default style: wxBORDER_SUNKEN
8c6791e4 177 @style{wxHLB_MULTIPLE}
9cc56d1f 178 Multiple-selection list: the user can toggle multiple items on and off.
23324ae1 179 @endStyleTable
7c913512 180
9cc56d1f
FM
181
182 A wxSimpleHtmlListBox emits the same events used by wxListBox and by wxHtmlListBox.
183
184 @beginEventTable{wxCommandEvent}
185 @event{EVT_LISTBOX(id, func)}
186 Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the list
187 is selected.
188 @event{EVT_LISTBOX_DCLICK(id, func)}
189 Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event, when the listbox is
190 double-clicked.
191 @endEventTable
192
193 @beginEventTable{wxHtmlCellEvent}
194 @event{EVT_HTML_CELL_CLICKED(id, func)}
195 A wxHtmlCell was clicked.
196 @event{EVT_HTML_CELL_HOVER(id, func)}
197 The mouse passed over a wxHtmlCell.
198 @endEventTable
199
200 @beginEventTable{wxHtmlLinkEvent}
201 @event{EVT_HTML_LINK_CLICKED(id, func)}
202 A wxHtmlCell which contains an hyperlink was clicked.
203 @endEventTable
204
23324ae1
FM
205 @library{wxhtml}
206 @category{ctrl}
7e59b885 207 @appearance{simplehtmllistbox.png}
7c913512 208
e54c96f1 209 @see wxSimpleHtmlListBox::Create
23324ae1
FM
210*/
211class wxSimpleHtmlListBox : public wxHtmlListBox
212{
213public:
23324ae1 214 /**
9cc56d1f
FM
215 Constructor, creating and showing the HTML list box.
216
217 @param parent
218 Parent window. Must not be NULL.
219 @param id
220 Window identifier. A value of -1 indicates a default value.
221 @param pos
222 Window position.
223 @param size
224 Window size. If wxDefaultSize is specified then the window is sized appropriately.
225 @param n
226 Number of strings with which to initialise the control.
227 @param choices
228 An array of strings with which to initialise the control.
229 @param style
230 Window style. See wxHLB_* flags.
231 @param validator
232 Window validator.
233 @param name
234 Window name.
23324ae1 235 */
11e3af6e
FM
236 wxSimpleHtmlListBox(wxWindow* parent, wxWindowID id,
237 const wxPoint& pos = wxDefaultPosition,
238 const wxSize& size = wxDefaultSize,
239 int n = 0,
240 const wxString choices[] = NULL,
241 long style = wxHLB_DEFAULT_STYLE,
242 const wxValidator& validator = wxDefaultValidator,
243 const wxString& name = wxSimpleHtmlListBoxNameStr);
9cc56d1f
FM
244
245 /**
246 Constructor, creating and showing the HTML list box.
247
248 @param parent
249 Parent window. Must not be NULL.
250 @param id
251 Window identifier. A value of -1 indicates a default value.
252 @param pos
253 Window position.
254 @param size
255 Window size. If wxDefaultSize is specified then the window is sized appropriately.
256 @param choices
257 An array of strings with which to initialise the control.
258 @param style
259 Window style. See wxHLB_* flags.
260 @param validator
261 Window validator.
262 @param name
263 Window name.
264 */
11e3af6e
FM
265 wxSimpleHtmlListBox(wxWindow* parent, wxWindowID id,
266 const wxPoint& pos,
267 const wxSize& size,
268 const wxArrayString& choices,
269 long style = wxHLB_DEFAULT_STYLE,
270 const wxValidator& validator = wxDefaultValidator,
271 const wxString& name = wxSimpleHtmlListBoxNameStr);
7c913512 272
9cc56d1f
FM
273 /**
274 Default constructor, you must call Create() later.
275 */
7c913512 276 wxSimpleHtmlListBox();
23324ae1
FM
277
278 /**
279 Frees the array of stored items and relative client data.
280 */
adaaa686 281 virtual ~wxSimpleHtmlListBox();
23324ae1
FM
282
283 //@{
284 /**
7c913512 285 Creates the HTML listbox for two-step construction.
23324ae1
FM
286 See wxSimpleHtmlListBox() for further details.
287 */
288 bool Create(wxWindow* parent, wxWindowID id,
289 const wxPoint& pos = wxDefaultPosition,
290 const wxSize& size = wxDefaultSize,
291 int n,
4cc4bfaf 292 const wxString choices[] = NULL,
23324ae1
FM
293 long style = wxHLB_DEFAULT_STYLE,
294 const wxValidator& validator = wxDefaultValidator,
11e3af6e 295 const wxString& name = wxSimpleHtmlListBoxNameStr);
7c913512
FM
296 bool Create(wxWindow* parent, wxWindowID id,
297 const wxPoint& pos,
298 const wxSize& size,
299 const wxArrayString& choices,
300 long style = wxHLB_DEFAULT_STYLE,
301 const wxValidator& validator = wxDefaultValidator,
11e3af6e 302 const wxString& name = wxSimpleHtmlListBoxNameStr);
23324ae1
FM
303 //@}
304};
e54c96f1 305