1 | /************************************************************************
|
---|
2 | filename: CEGUICombobox.h
|
---|
3 | created: 13/4/2004
|
---|
4 | author: Paul D Turner
|
---|
5 |
|
---|
6 | purpose: Interface to base class for Combobox widget
|
---|
7 | *************************************************************************/
|
---|
8 | /*************************************************************************
|
---|
9 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
10 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
11 |
|
---|
12 | This library is free software; you can redistribute it and/or
|
---|
13 | modify it under the terms of the GNU Lesser General Public
|
---|
14 | License as published by the Free Software Foundation; either
|
---|
15 | version 2.1 of the License, or (at your option) any later version.
|
---|
16 |
|
---|
17 | This library is distributed in the hope that it will be useful,
|
---|
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | Lesser General Public License for more details.
|
---|
21 |
|
---|
22 | You should have received a copy of the GNU Lesser General Public
|
---|
23 | License along with this library; if not, write to the Free Software
|
---|
24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | *************************************************************************/
|
---|
26 | #ifndef _CEGUICombobox_h_
|
---|
27 | #define _CEGUICombobox_h_
|
---|
28 |
|
---|
29 | #include "CEGUIBase.h"
|
---|
30 | #include "CEGUIWindow.h"
|
---|
31 | #include "elements/CEGUIComboboxProperties.h"
|
---|
32 |
|
---|
33 |
|
---|
34 | #if defined(_MSC_VER)
|
---|
35 | # pragma warning(push)
|
---|
36 | # pragma warning(disable : 4251)
|
---|
37 | #endif
|
---|
38 |
|
---|
39 |
|
---|
40 | // Start of CEGUI namespace section
|
---|
41 | namespace CEGUI
|
---|
42 | {
|
---|
43 |
|
---|
44 | /*!
|
---|
45 | \brief
|
---|
46 | Base class for the Combobox widget
|
---|
47 | */
|
---|
48 | class CEGUIEXPORT Combobox : public Window
|
---|
49 | {
|
---|
50 | public:
|
---|
51 | static const String EventNamespace; //!< Namespace for global events
|
---|
52 |
|
---|
53 | /*************************************************************************
|
---|
54 | Constants
|
---|
55 | *************************************************************************/
|
---|
56 | // event names from edit box
|
---|
57 | static const String EventReadOnlyModeChanged; //!< The read-only mode for the edit box has been changed.
|
---|
58 | static const String EventValidationStringChanged; //!< The validation string has been changed.
|
---|
59 | static const String EventMaximumTextLengthChanged; //!< The maximum allowable string length has been changed.
|
---|
60 | static const String EventTextInvalidated; //!< Some operation has made the current text invalid with regards to the validation string.
|
---|
61 | static const String EventInvalidEntryAttempted; //!< The user attempted to modify the text in a way that would have made it invalid.
|
---|
62 | static const String EventCaratMoved; //!< The text carat (insert point) has changed.
|
---|
63 | static const String EventTextSelectionChanged; //!< The current text selection has changed.
|
---|
64 | static const String EventEditboxFull; //!< The number of characters in the edit box has reached the current maximum.
|
---|
65 | static const String EventTextAccepted; //!< The user has accepted the current text by pressing Return, Enter, or Tab.
|
---|
66 |
|
---|
67 | // event names from list box
|
---|
68 | static const String EventListContentsChanged; //!< Event triggered when the contents of the list is changed.
|
---|
69 | static const String EventListSelectionChanged; //!< Event triggered when there is a change to the currently selected item(s).
|
---|
70 | static const String EventSortModeChanged; //!< Event triggered when the sort mode setting changes.
|
---|
71 | static const String EventVertScrollbarModeChanged; //!< Event triggered when the vertical scroll bar 'force' setting changes.
|
---|
72 | static const String EventHorzScrollbarModeChanged; //!< Event triggered when the horizontal scroll bar 'force' setting changes.
|
---|
73 |
|
---|
74 | // events we produce / generate ourselves
|
---|
75 | static const String EventDropListDisplayed; //!< Event triggered when the drop-down list is displayed
|
---|
76 | static const String EventDropListRemoved; //!< Event triggered when the drop-down list is removed / hidden.
|
---|
77 | static const String EventListSelectionAccepted; //!< Event triggered when the user accepts a selection from the drop-down list
|
---|
78 |
|
---|
79 |
|
---|
80 | /*!
|
---|
81 | \brief
|
---|
82 | check if the given position would hit this window.
|
---|
83 |
|
---|
84 | \param position
|
---|
85 | Point object describing the position to check in screen pixels
|
---|
86 |
|
---|
87 | \return
|
---|
88 | true if \a position 'hits' this Window, else false.
|
---|
89 | */
|
---|
90 | virtual bool isHit(const Point& position) const {return false;}
|
---|
91 |
|
---|
92 |
|
---|
93 | /*!
|
---|
94 | \brief
|
---|
95 | returns the mode of operation for the combo box.
|
---|
96 |
|
---|
97 | \return
|
---|
98 | - true if the user can show the list and select an item with a single mouse click.
|
---|
99 | - false if the user must click to show the list and then click again to select an item.
|
---|
100 | */
|
---|
101 | bool getSingleClickEnabled(void) const;
|
---|
102 |
|
---|
103 |
|
---|
104 | /*!
|
---|
105 | \brief
|
---|
106 | returns true if the drop down list is visible.
|
---|
107 |
|
---|
108 | \return
|
---|
109 | true if the drop down list is visible, false otherwise.
|
---|
110 | */
|
---|
111 | bool isDropDownListVisible(void) const;
|
---|
112 |
|
---|
113 |
|
---|
114 | /*************************************************************************
|
---|
115 | Editbox Accessors
|
---|
116 | *************************************************************************/
|
---|
117 | /*!
|
---|
118 | \brief
|
---|
119 | return true if the Editbox has input focus.
|
---|
120 |
|
---|
121 | \return
|
---|
122 | true if the Editbox has keyboard input focus, false if the Editbox does not have keyboard input focus.
|
---|
123 | */
|
---|
124 | bool hasInputFocus(void) const;
|
---|
125 |
|
---|
126 |
|
---|
127 | /*!
|
---|
128 | \brief
|
---|
129 | return true if the Editbox is read-only.
|
---|
130 |
|
---|
131 | \return
|
---|
132 | true if the Editbox is read only and can't be edited by the user, false if the Editbox is not
|
---|
133 | read only and may be edited by the user.
|
---|
134 | */
|
---|
135 | bool isReadOnly(void) const;
|
---|
136 |
|
---|
137 |
|
---|
138 | /*!
|
---|
139 | \brief
|
---|
140 | return true if the Editbox text is valid given the currently set validation string.
|
---|
141 |
|
---|
142 | \note
|
---|
143 | It is possible to programmatically set 'invalid' text for the Editbox by calling setText. This has certain
|
---|
144 | implications since if invalid text is set, whatever the user types into the box will be rejected when the input
|
---|
145 | is validated.
|
---|
146 |
|
---|
147 | \note
|
---|
148 | Validation is performed by means of a regular expression. If the text matches the regex, the text is said to have passed
|
---|
149 | validation. If the text does not match with the regex then the text fails validation.
|
---|
150 |
|
---|
151 | \return
|
---|
152 | true if the current Editbox text passes validation, false if the text does not pass validation.
|
---|
153 | */
|
---|
154 | bool isTextValid(void) const;
|
---|
155 |
|
---|
156 |
|
---|
157 | /*!
|
---|
158 | \brief
|
---|
159 | return the currently set validation string
|
---|
160 |
|
---|
161 | \note
|
---|
162 | Validation is performed by means of a regular expression. If the text matches the regex, the text is said to have passed
|
---|
163 | validation. If the text does not match with the regex then the text fails validation.
|
---|
164 |
|
---|
165 | \return
|
---|
166 | String object containing the current validation regex data
|
---|
167 | */
|
---|
168 | const String& getValidationString(void) const;
|
---|
169 |
|
---|
170 |
|
---|
171 | /*!
|
---|
172 | \brief
|
---|
173 | return the current position of the carat.
|
---|
174 |
|
---|
175 | \return
|
---|
176 | Index of the insert carat relative to the start of the text.
|
---|
177 | */
|
---|
178 | size_t getCaratIndex(void) const;
|
---|
179 |
|
---|
180 |
|
---|
181 | /*!
|
---|
182 | \brief
|
---|
183 | return the current selection start point.
|
---|
184 |
|
---|
185 | \return
|
---|
186 | Index of the selection start point relative to the start of the text. If no selection is defined this function returns
|
---|
187 | the position of the carat.
|
---|
188 | */
|
---|
189 | size_t getSelectionStartIndex(void) const;
|
---|
190 |
|
---|
191 |
|
---|
192 | /*!
|
---|
193 | \brief
|
---|
194 | return the current selection end point.
|
---|
195 |
|
---|
196 | \return
|
---|
197 | Index of the selection end point relative to the start of the text. If no selection is defined this function returns
|
---|
198 | the position of the carat.
|
---|
199 | */
|
---|
200 | size_t getSelectionEndIndex(void) const;
|
---|
201 |
|
---|
202 |
|
---|
203 | /*!
|
---|
204 | \brief
|
---|
205 | return the length of the current selection (in code points / characters).
|
---|
206 |
|
---|
207 | \return
|
---|
208 | Number of code points (or characters) contained within the currently defined selection.
|
---|
209 | */
|
---|
210 | size_t getSelectionLength(void) const;
|
---|
211 |
|
---|
212 |
|
---|
213 | /*!
|
---|
214 | \brief
|
---|
215 | return the maximum text length set for this Editbox.
|
---|
216 |
|
---|
217 | \return
|
---|
218 | The maximum number of code points (characters) that can be entered into this Editbox.
|
---|
219 |
|
---|
220 | \note
|
---|
221 | Depending on the validation string set, the actual length of text that can be entered may be less than the value
|
---|
222 | returned here (it will never be more).
|
---|
223 | */
|
---|
224 | size_t getMaxTextLength(void) const;
|
---|
225 |
|
---|
226 |
|
---|
227 | /*!
|
---|
228 | \brief
|
---|
229 | return the currently set colour to be used for rendering Editbox text in the
|
---|
230 | normal, unselected state.
|
---|
231 |
|
---|
232 | \return
|
---|
233 | colour value describing the ARGB colour that is currently set.
|
---|
234 | */
|
---|
235 | colour getNormalTextColour(void) const;
|
---|
236 |
|
---|
237 |
|
---|
238 | /*!
|
---|
239 | \brief
|
---|
240 | return the currently set colour to be used for rendering the Editbox text when within the
|
---|
241 | selected region.
|
---|
242 |
|
---|
243 | \return
|
---|
244 | colour value describing the ARGB colour that is currently set.
|
---|
245 | */
|
---|
246 | colour getSelectedTextColour(void) const;
|
---|
247 |
|
---|
248 |
|
---|
249 | /*!
|
---|
250 | \brief
|
---|
251 | return the currently set colour to be used for rendering the Editbox selection highlight
|
---|
252 | when the Editbox is active.
|
---|
253 |
|
---|
254 | \return
|
---|
255 | colour value describing the ARGB colour that is currently set.
|
---|
256 | */
|
---|
257 | colour getNormalSelectBrushColour(void) const;
|
---|
258 |
|
---|
259 |
|
---|
260 | /*!
|
---|
261 | \brief
|
---|
262 | return the currently set colour to be used for rendering the Editbox selection highlight
|
---|
263 | when the Editbox is inactive.
|
---|
264 |
|
---|
265 | \return
|
---|
266 | colour value describing the ARGB colour that is currently set.
|
---|
267 | */
|
---|
268 | colour getInactiveSelectBrushColour(void) const;
|
---|
269 |
|
---|
270 |
|
---|
271 | /*************************************************************************
|
---|
272 | List Accessors
|
---|
273 | *************************************************************************/
|
---|
274 | /*!
|
---|
275 | \brief
|
---|
276 | Return number of items attached to the list box
|
---|
277 |
|
---|
278 | \return
|
---|
279 | the number of items currently attached to this list box.
|
---|
280 | */
|
---|
281 | size_t getItemCount(void) const;
|
---|
282 |
|
---|
283 |
|
---|
284 | /*!
|
---|
285 | \brief
|
---|
286 | Return a pointer to the currently selected item.
|
---|
287 |
|
---|
288 | \return
|
---|
289 | Pointer to a ListboxItem based object that is the selected item in the list. will return NULL if
|
---|
290 | no item is selected.
|
---|
291 | */
|
---|
292 | ListboxItem* getSelectedItem(void) const;
|
---|
293 |
|
---|
294 |
|
---|
295 | /*!
|
---|
296 | \brief
|
---|
297 | Return the item at index position \a index.
|
---|
298 |
|
---|
299 | \param index
|
---|
300 | Zero based index of the item to be returned.
|
---|
301 |
|
---|
302 | \return
|
---|
303 | Pointer to the ListboxItem at index position \a index in the list box.
|
---|
304 |
|
---|
305 | \exception InvalidRequestException thrown if \a index is out of range.
|
---|
306 | */
|
---|
307 | ListboxItem* getListboxItemFromIndex(size_t index) const;
|
---|
308 |
|
---|
309 |
|
---|
310 | /*!
|
---|
311 | \brief
|
---|
312 | Return the index of ListboxItem \a item
|
---|
313 |
|
---|
314 | \param item
|
---|
315 | Pointer to a ListboxItem whos zero based index is to be returned.
|
---|
316 |
|
---|
317 | \return
|
---|
318 | Zero based index indicating the position of ListboxItem \a item in the list box.
|
---|
319 |
|
---|
320 | \exception InvalidRequestException thrown if \a item is not attached to this list box.
|
---|
321 | */
|
---|
322 | size_t getItemIndex(const ListboxItem* item) const;
|
---|
323 |
|
---|
324 |
|
---|
325 | /*!
|
---|
326 | \brief
|
---|
327 | return whether list sorting is enabled
|
---|
328 |
|
---|
329 | \return
|
---|
330 | true if the list is sorted, false if the list is not sorted
|
---|
331 | */
|
---|
332 | bool isSortEnabled(void) const;
|
---|
333 |
|
---|
334 |
|
---|
335 | /*!
|
---|
336 | \brief
|
---|
337 | return whether the string at index position \a index is selected
|
---|
338 |
|
---|
339 | \param index
|
---|
340 | Zero based index of the item to be examined.
|
---|
341 |
|
---|
342 | \return
|
---|
343 | true if the item at \a index is selected, false if the item at \a index is not selected.
|
---|
344 |
|
---|
345 | \exception InvalidRequestException thrown if \a index is out of range.
|
---|
346 | */
|
---|
347 | bool isItemSelected(size_t index) const;
|
---|
348 |
|
---|
349 |
|
---|
350 | /*!
|
---|
351 | \brief
|
---|
352 | Search the list for an item with the specified text
|
---|
353 |
|
---|
354 | \param text
|
---|
355 | String object containing the text to be searched for.
|
---|
356 |
|
---|
357 | \param start_item
|
---|
358 | ListboxItem where the search is to begin, the search will not include \a item. If \a item is
|
---|
359 | NULL, the search will begin from the first item in the list.
|
---|
360 |
|
---|
361 | \return
|
---|
362 | Pointer to the first ListboxItem in the list after \a item that has text matching \a text. If
|
---|
363 | no item matches the criteria NULL is returned.
|
---|
364 |
|
---|
365 | \exception InvalidRequestException thrown if \a item is not attached to this list box.
|
---|
366 | */
|
---|
367 | ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item);
|
---|
368 |
|
---|
369 |
|
---|
370 | /*!
|
---|
371 | \brief
|
---|
372 | Return whether the specified ListboxItem is in the List
|
---|
373 |
|
---|
374 | \return
|
---|
375 | true if ListboxItem \a item is in the list, false if ListboxItem \a item is not in the list.
|
---|
376 | */
|
---|
377 | bool isListboxItemInList(const ListboxItem* item) const;
|
---|
378 |
|
---|
379 |
|
---|
380 | /*!
|
---|
381 | \brief
|
---|
382 | Return whether the vertical scroll bar is always shown.
|
---|
383 |
|
---|
384 | \return
|
---|
385 | - true if the scroll bar will always be shown even if it is not required.
|
---|
386 | - false if the scroll bar will only be shown when it is required.
|
---|
387 | */
|
---|
388 | bool isVertScrollbarAlwaysShown(void) const;
|
---|
389 |
|
---|
390 |
|
---|
391 | /*!
|
---|
392 | \brief
|
---|
393 | Return whether the horizontal scroll bar is always shown.
|
---|
394 |
|
---|
395 | \return
|
---|
396 | - true if the scroll bar will always be shown even if it is not required.
|
---|
397 | - false if the scroll bar will only be shown when it is required.
|
---|
398 | */
|
---|
399 | bool isHorzScrollbarAlwaysShown(void) const;
|
---|
400 |
|
---|
401 |
|
---|
402 | /*************************************************************************
|
---|
403 | Combobox Manipulators
|
---|
404 | *************************************************************************/
|
---|
405 | /*!
|
---|
406 | \brief
|
---|
407 | Initialise the Window based object ready for use.
|
---|
408 |
|
---|
409 | \note
|
---|
410 | This must be called for every window created. Normally this is handled automatically by the WindowFactory for each Window type.
|
---|
411 |
|
---|
412 | \return
|
---|
413 | Nothing
|
---|
414 | */
|
---|
415 | virtual void initialise(void);
|
---|
416 |
|
---|
417 |
|
---|
418 | /*!
|
---|
419 | \brief
|
---|
420 | Show the drop-down list
|
---|
421 |
|
---|
422 | \return
|
---|
423 | Nothing
|
---|
424 | */
|
---|
425 | void showDropList(void);
|
---|
426 |
|
---|
427 |
|
---|
428 | /*!
|
---|
429 | \brief
|
---|
430 | Hide the drop-down list
|
---|
431 |
|
---|
432 | \return
|
---|
433 | Nothing.
|
---|
434 | */
|
---|
435 | void hideDropList(void);
|
---|
436 |
|
---|
437 |
|
---|
438 | /*!
|
---|
439 | \brief
|
---|
440 | Set the mode of operation for the combo box.
|
---|
441 |
|
---|
442 | \param setting
|
---|
443 | - true if the user should be able to show the list and select an item with a single mouse click.
|
---|
444 | - false if the user must click to show the list and then click again to select an item.
|
---|
445 |
|
---|
446 | \return
|
---|
447 | Nothing.
|
---|
448 | */
|
---|
449 | void setSingleClickEnabled(bool setting);
|
---|
450 |
|
---|
451 |
|
---|
452 | /*************************************************************************
|
---|
453 | Editbox Manipulators
|
---|
454 | *************************************************************************/
|
---|
455 | /*!
|
---|
456 | \brief
|
---|
457 | Specify whether the Editbox is read-only.
|
---|
458 |
|
---|
459 | \param setting
|
---|
460 | true if the Editbox is read only and can't be edited by the user, false if the Editbox is not
|
---|
461 | read only and may be edited by the user.
|
---|
462 |
|
---|
463 | \return
|
---|
464 | Nothing.
|
---|
465 | */
|
---|
466 | void setReadOnly(bool setting);
|
---|
467 |
|
---|
468 |
|
---|
469 | /*!
|
---|
470 | \brief
|
---|
471 | Set the text validation string.
|
---|
472 |
|
---|
473 | \note
|
---|
474 | Validation is performed by means of a regular expression. If the text matches the regex, the text is said to have passed
|
---|
475 | validation. If the text does not match with the regex then the text fails validation.
|
---|
476 |
|
---|
477 | \param validation_string
|
---|
478 | String object containing the validation regex data to be used.
|
---|
479 |
|
---|
480 | \return
|
---|
481 | Nothing.
|
---|
482 | */
|
---|
483 | void setValidationString(const String& validation_string);
|
---|
484 |
|
---|
485 |
|
---|
486 | /*!
|
---|
487 | \brief
|
---|
488 | Set the current position of the carat.
|
---|
489 |
|
---|
490 | \param carat_pos
|
---|
491 | New index for the insert carat relative to the start of the text. If the value specified is greater than the
|
---|
492 | number of characters in the Editbox, the carat is positioned at the end of the text.
|
---|
493 |
|
---|
494 | \return
|
---|
495 | Nothing.
|
---|
496 | */
|
---|
497 | void setCaratIndex(size_t carat_pos);
|
---|
498 |
|
---|
499 |
|
---|
500 | /*!
|
---|
501 | \brief
|
---|
502 | Define the current selection for the Editbox
|
---|
503 |
|
---|
504 | \param start_pos
|
---|
505 | Index of the starting point for the selection. If this value is greater than the number of characters in the Editbox, the
|
---|
506 | selection start will be set to the end of the text.
|
---|
507 |
|
---|
508 | \param end_pos
|
---|
509 | Index of the ending point for the selection. If this value is greater than the number of characters in the Editbox, the
|
---|
510 | selection start will be set to the end of the text.
|
---|
511 |
|
---|
512 | \return
|
---|
513 | Nothing.
|
---|
514 | */
|
---|
515 | void setSelection(size_t start_pos, size_t end_pos);
|
---|
516 |
|
---|
517 |
|
---|
518 | /*!
|
---|
519 | \brief
|
---|
520 | set the maximum text length for this Editbox.
|
---|
521 |
|
---|
522 | \param max_len
|
---|
523 | The maximum number of code points (characters) that can be entered into this Editbox.
|
---|
524 |
|
---|
525 | \note
|
---|
526 | Depending on the validation string set, the actual length of text that can be entered may be less than the value
|
---|
527 | set here (it will never be more).
|
---|
528 |
|
---|
529 | \return
|
---|
530 | Nothing.
|
---|
531 | */
|
---|
532 | void setMaxTextLength(size_t max_len);
|
---|
533 |
|
---|
534 |
|
---|
535 | /*!
|
---|
536 | \brief
|
---|
537 | Set the colour to be used for rendering Editbox text in the normal, unselected state.
|
---|
538 |
|
---|
539 | \param col
|
---|
540 | colour value describing the ARGB colour that is to be used.
|
---|
541 |
|
---|
542 | \return
|
---|
543 | Nothing.
|
---|
544 | */
|
---|
545 | void setNormalTextColour(colour col);
|
---|
546 |
|
---|
547 |
|
---|
548 | /*!
|
---|
549 | \brief
|
---|
550 | Set the colour to be used for rendering the Editbox text when within the
|
---|
551 | selected region.
|
---|
552 |
|
---|
553 | \return
|
---|
554 | colour value describing the ARGB colour that is currently set.
|
---|
555 | */
|
---|
556 | void setSelectedTextColour(colour col);
|
---|
557 |
|
---|
558 |
|
---|
559 | /*!
|
---|
560 | \brief
|
---|
561 | Set the colour to be used for rendering the Editbox selection highlight
|
---|
562 | when the Editbox is active.
|
---|
563 |
|
---|
564 | \param col
|
---|
565 | colour value describing the ARGB colour that is to be used.
|
---|
566 |
|
---|
567 | \return
|
---|
568 | Nothing.
|
---|
569 | */
|
---|
570 | void setNormalSelectBrushColour(colour col);
|
---|
571 |
|
---|
572 |
|
---|
573 | /*!
|
---|
574 | \brief
|
---|
575 | Set the colour to be used for rendering the Editbox selection highlight
|
---|
576 | when the Editbox is inactive.
|
---|
577 |
|
---|
578 | \param col
|
---|
579 | colour value describing the ARGB colour that is to be used.
|
---|
580 |
|
---|
581 | \return
|
---|
582 | Nothing.
|
---|
583 | */
|
---|
584 | void setInactiveSelectBrushColour(colour col);
|
---|
585 |
|
---|
586 |
|
---|
587 | /*!
|
---|
588 | \brief
|
---|
589 | Activate the edit box component of the Combobox.
|
---|
590 |
|
---|
591 | \return
|
---|
592 | Nothing.
|
---|
593 | */
|
---|
594 | void activateEditbox(void);
|
---|
595 |
|
---|
596 |
|
---|
597 | /*************************************************************************
|
---|
598 | List Manipulators
|
---|
599 | *************************************************************************/
|
---|
600 | /*!
|
---|
601 | \brief
|
---|
602 | Remove all items from the list.
|
---|
603 |
|
---|
604 | Note that this will cause 'AutoDelete' items to be deleted.
|
---|
605 | */
|
---|
606 | void resetList(void);
|
---|
607 |
|
---|
608 |
|
---|
609 | /*!
|
---|
610 | \brief
|
---|
611 | Add the given ListboxItem to the list.
|
---|
612 |
|
---|
613 | \param item
|
---|
614 | Pointer to the ListboxItem to be added to the list. Note that it is the passed object that is added to the
|
---|
615 | list, a copy is not made. If this parameter is NULL, nothing happens.
|
---|
616 |
|
---|
617 | \return
|
---|
618 | Nothing.
|
---|
619 | */
|
---|
620 | void addItem(ListboxItem* item);
|
---|
621 |
|
---|
622 |
|
---|
623 | /*!
|
---|
624 | \brief
|
---|
625 | Insert an item into the list box after a specified item already in the list.
|
---|
626 |
|
---|
627 | Note that if the list is sorted, the item may not end up in the requested position.
|
---|
628 |
|
---|
629 | \param item
|
---|
630 | Pointer to the ListboxItem to be inserted. Note that it is the passed object that is added to the
|
---|
631 | list, a copy is not made. If this parameter is NULL, nothing happens.
|
---|
632 |
|
---|
633 | \param position
|
---|
634 | Pointer to a ListboxItem that \a item is to be inserted after. If this parameter is NULL, the item is
|
---|
635 | inserted at the start of the list.
|
---|
636 |
|
---|
637 | \return
|
---|
638 | Nothing.
|
---|
639 | */
|
---|
640 | void insertItem(ListboxItem* item, const ListboxItem* position);
|
---|
641 |
|
---|
642 |
|
---|
643 | /*!
|
---|
644 | \brief
|
---|
645 | Removes the given item from the list box.
|
---|
646 |
|
---|
647 | \param item
|
---|
648 | Pointer to the ListboxItem that is to be removed. If \a item is not attached to this list box then nothing
|
---|
649 | will happen.
|
---|
650 |
|
---|
651 | \return
|
---|
652 | Nothing.
|
---|
653 | */
|
---|
654 | void removeItem(const ListboxItem* item);
|
---|
655 |
|
---|
656 |
|
---|
657 | /*!
|
---|
658 | \brief
|
---|
659 | Clear the selected state for all items.
|
---|
660 |
|
---|
661 | \return
|
---|
662 | Nothing.
|
---|
663 | */
|
---|
664 | void clearAllSelections(void);
|
---|
665 |
|
---|
666 |
|
---|
667 | /*!
|
---|
668 | \brief
|
---|
669 | Set whether the list should be sorted.
|
---|
670 |
|
---|
671 | \param setting
|
---|
672 | true if the list should be sorted, false if the list should not be sorted.
|
---|
673 |
|
---|
674 | \return
|
---|
675 | Nothing.
|
---|
676 | */
|
---|
677 | void setSortingEnabled(bool setting);
|
---|
678 |
|
---|
679 |
|
---|
680 | /*!
|
---|
681 | \brief
|
---|
682 | Set whether the vertical scroll bar should always be shown.
|
---|
683 |
|
---|
684 | \param setting
|
---|
685 | true if the vertical scroll bar should be shown even when it is not required. false if the vertical
|
---|
686 | scroll bar should only be shown when it is required.
|
---|
687 |
|
---|
688 | \return
|
---|
689 | Nothing.
|
---|
690 | */
|
---|
691 | void setShowVertScrollbar(bool setting);
|
---|
692 |
|
---|
693 |
|
---|
694 | /*!
|
---|
695 | \brief
|
---|
696 | Set whether the horizontal scroll bar should always be shown.
|
---|
697 |
|
---|
698 | \param setting
|
---|
699 | true if the horizontal scroll bar should be shown even when it is not required. false if the horizontal
|
---|
700 | scroll bar should only be shown when it is required.
|
---|
701 |
|
---|
702 | \return
|
---|
703 | Nothing.
|
---|
704 | */
|
---|
705 | void setShowHorzScrollbar(bool setting);
|
---|
706 |
|
---|
707 |
|
---|
708 | /*!
|
---|
709 | \brief
|
---|
710 | Set the select state of an attached ListboxItem.
|
---|
711 |
|
---|
712 | This is the recommended way of selecting and deselecting items attached to a list box as it respects the
|
---|
713 | multi-select mode setting. It is possible to modify the setting on ListboxItems directly, but that approach
|
---|
714 | does not respect the settings of the list box.
|
---|
715 |
|
---|
716 | \param item
|
---|
717 | The ListboxItem to be affected. This item must be attached to the list box.
|
---|
718 |
|
---|
719 | \param state
|
---|
720 | true to select the item, false to de-select the item.
|
---|
721 |
|
---|
722 | \return
|
---|
723 | Nothing.
|
---|
724 |
|
---|
725 | \exception InvalidRequestException thrown if \a item is not attached to this list box.
|
---|
726 | */
|
---|
727 | void setItemSelectState(ListboxItem* item, bool state);
|
---|
728 |
|
---|
729 |
|
---|
730 | /*!
|
---|
731 | \brief
|
---|
732 | Set the select state of an attached ListboxItem.
|
---|
733 |
|
---|
734 | This is the recommended way of selecting and deselecting items attached to a list box as it respects the
|
---|
735 | multi-select mode setting. It is possible to modify the setting on ListboxItems directly, but that approach
|
---|
736 | does not respect the settings of the list box.
|
---|
737 |
|
---|
738 | \param item_index
|
---|
739 | The zero based index of the ListboxItem to be affected. This must be a valid index (0 <= index < getItemCount())
|
---|
740 |
|
---|
741 | \param state
|
---|
742 | true to select the item, false to de-select the item.
|
---|
743 |
|
---|
744 | \return
|
---|
745 | Nothing.
|
---|
746 |
|
---|
747 | \exception InvalidRequestException thrown if \a item_index is out of range for the list box
|
---|
748 | */
|
---|
749 | void setItemSelectState(size_t item_index, bool state);
|
---|
750 |
|
---|
751 |
|
---|
752 | /*!
|
---|
753 | \brief
|
---|
754 | Causes the list box to update it's internal state after changes have been made to one or more
|
---|
755 | attached ListboxItem objects.
|
---|
756 |
|
---|
757 | Client code must call this whenever it has made any changes to ListboxItem objects already attached to the
|
---|
758 | list box. If you are just adding items, or removed items to update them prior to re-adding them, there is
|
---|
759 | no need to call this method.
|
---|
760 |
|
---|
761 | \return
|
---|
762 | Nothing.
|
---|
763 | */
|
---|
764 | void handleUpdatedListItemData(void);
|
---|
765 |
|
---|
766 |
|
---|
767 | /*************************************************************************
|
---|
768 | Construction and Destruction
|
---|
769 | *************************************************************************/
|
---|
770 | /*!
|
---|
771 | \brief
|
---|
772 | Constructor for Combobox base class
|
---|
773 | */
|
---|
774 | Combobox(const String& type, const String& name);
|
---|
775 |
|
---|
776 |
|
---|
777 | /*!
|
---|
778 | \brief
|
---|
779 | Destructor for Combobox base class
|
---|
780 | */
|
---|
781 | virtual ~Combobox(void);
|
---|
782 |
|
---|
783 |
|
---|
784 | protected:
|
---|
785 | /*************************************************************************
|
---|
786 | Implementation Methods
|
---|
787 | *************************************************************************/
|
---|
788 | /*!
|
---|
789 | \brief
|
---|
790 | Add combo box specific events
|
---|
791 | */
|
---|
792 | void addComboboxEvents(void);
|
---|
793 |
|
---|
794 |
|
---|
795 | /*!
|
---|
796 | \brief
|
---|
797 | Create, initialise, and return a pointer to an Editbox widget to be used as part
|
---|
798 | of this Combobox.
|
---|
799 |
|
---|
800 | \return
|
---|
801 | Pointer to an Editbox derived class.
|
---|
802 | */
|
---|
803 | virtual Editbox* createEditbox(const String& name) const = 0;
|
---|
804 |
|
---|
805 |
|
---|
806 | /*!
|
---|
807 | \brief
|
---|
808 | Create, initialise, and return a pointer to a PushButton widget to be used as part
|
---|
809 | of this Combobox.
|
---|
810 |
|
---|
811 | \return
|
---|
812 | Pointer to a PushButton derived class.
|
---|
813 | */
|
---|
814 | virtual PushButton* createPushButton(const String& name) const = 0;
|
---|
815 |
|
---|
816 |
|
---|
817 | /*!
|
---|
818 | \brief
|
---|
819 | Create, initialise, and return a pointer to a ComboDropList widget to be used as part
|
---|
820 | of this Combobox.
|
---|
821 |
|
---|
822 | \return
|
---|
823 | Pointer to a ComboDropList derived class.
|
---|
824 | */
|
---|
825 | virtual ComboDropList* createDropList(const String& name) const = 0;
|
---|
826 |
|
---|
827 |
|
---|
828 | /*!
|
---|
829 | \brief
|
---|
830 | Handler function for button clicks.
|
---|
831 | */
|
---|
832 | bool button_PressHandler(const EventArgs& e);
|
---|
833 |
|
---|
834 |
|
---|
835 | /*!
|
---|
836 | \brief
|
---|
837 | Handler for selections made in the drop-list
|
---|
838 | */
|
---|
839 | bool droplist_SelectionAcceptedHandler(const EventArgs& e);
|
---|
840 |
|
---|
841 |
|
---|
842 | /*!
|
---|
843 | \brief
|
---|
844 | Handler for when drop-list hides itself
|
---|
845 | */
|
---|
846 | bool droplist_HiddenHandler(const EventArgs& e);
|
---|
847 |
|
---|
848 |
|
---|
849 | /*!
|
---|
850 | \brief
|
---|
851 | Mouse button down handler attached to edit box
|
---|
852 | */
|
---|
853 | bool editbox_MouseDownHandler(const EventArgs& e);
|
---|
854 |
|
---|
855 |
|
---|
856 | /*!
|
---|
857 | \brief
|
---|
858 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
859 |
|
---|
860 | \param class_name
|
---|
861 | The class name that is to be checked.
|
---|
862 |
|
---|
863 | \return
|
---|
864 | true if this window was inherited from \a class_name. false if not.
|
---|
865 | */
|
---|
866 | virtual bool testClassName_impl(const String& class_name) const
|
---|
867 | {
|
---|
868 | if (class_name==(const utf8*)"Combobox") return true;
|
---|
869 | return Window::testClassName_impl(class_name);
|
---|
870 | }
|
---|
871 |
|
---|
872 |
|
---|
873 | /*************************************************************************
|
---|
874 | Handlers to relay child widget events so they appear to come from us
|
---|
875 | *************************************************************************/
|
---|
876 | bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
|
---|
877 | bool editbox_ValidationStringChangedHandler(const EventArgs& e);
|
---|
878 | bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
|
---|
879 | bool editbox_TextInvalidatedEventHandler(const EventArgs& e);
|
---|
880 | bool editbox_InvalidEntryAttemptedHandler(const EventArgs& e);
|
---|
881 | bool editbox_CaratMovedHandler(const EventArgs& e);
|
---|
882 | bool editbox_TextSelectionChangedHandler(const EventArgs& e);
|
---|
883 | bool editbox_EditboxFullEventHandler(const EventArgs& e);
|
---|
884 | bool editbox_TextAcceptedEventHandler(const EventArgs& e);
|
---|
885 | bool editbox_TextChangedEventHandler(const EventArgs& e);
|
---|
886 | bool listbox_ListContentsChangedHandler(const EventArgs& e);
|
---|
887 | bool listbox_ListSelectionChangedHandler(const EventArgs& e);
|
---|
888 | bool listbox_SortModeChangedHandler(const EventArgs& e);
|
---|
889 | bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
|
---|
890 | bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
|
---|
891 |
|
---|
892 |
|
---|
893 | /*************************************************************************
|
---|
894 | New Events for Combobox
|
---|
895 | *************************************************************************/
|
---|
896 | /*!
|
---|
897 | \brief
|
---|
898 | Handler called internally when the read only state of the Combobox's Editbox has been changed.
|
---|
899 | */
|
---|
900 | virtual void onReadOnlyChanged(WindowEventArgs& e);
|
---|
901 |
|
---|
902 |
|
---|
903 | /*!
|
---|
904 | \brief
|
---|
905 | Handler called internally when the Combobox's Editbox validation string has been changed.
|
---|
906 | */
|
---|
907 | virtual void onValidationStringChanged(WindowEventArgs& e);
|
---|
908 |
|
---|
909 |
|
---|
910 | /*!
|
---|
911 | \brief
|
---|
912 | Handler called internally when the Combobox's Editbox maximum text length is changed.
|
---|
913 | */
|
---|
914 | virtual void onMaximumTextLengthChanged(WindowEventArgs& e);
|
---|
915 |
|
---|
916 |
|
---|
917 | /*!
|
---|
918 | \brief
|
---|
919 | Handler called internally when the Combobox's Editbox text has been invalidated.
|
---|
920 | */
|
---|
921 | virtual void onTextInvalidatedEvent(WindowEventArgs& e);
|
---|
922 |
|
---|
923 |
|
---|
924 | /*!
|
---|
925 | \brief
|
---|
926 | Handler called internally when an invalid entry was attempted in the Combobox's Editbox.
|
---|
927 | */
|
---|
928 | virtual void onInvalidEntryAttempted(WindowEventArgs& e);
|
---|
929 |
|
---|
930 |
|
---|
931 | /*!
|
---|
932 | \brief
|
---|
933 | Handler called internally when the carat in the Comboxbox's Editbox moves.
|
---|
934 | */
|
---|
935 | virtual void onCaratMoved(WindowEventArgs& e);
|
---|
936 |
|
---|
937 |
|
---|
938 | /*!
|
---|
939 | \brief
|
---|
940 | Handler called internally when the selection within the Combobox's Editbox changes.
|
---|
941 | */
|
---|
942 | virtual void onTextSelectionChanged(WindowEventArgs& e);
|
---|
943 |
|
---|
944 |
|
---|
945 | /*!
|
---|
946 | \brief
|
---|
947 | Handler called internally when the maximum length is reached for text in the Combobox's Editbox.
|
---|
948 | */
|
---|
949 | virtual void onEditboxFullEvent(WindowEventArgs& e);
|
---|
950 |
|
---|
951 |
|
---|
952 | /*!
|
---|
953 | \brief
|
---|
954 | Handler called internally when the text in the Combobox's Editbox is accepted (by various means).
|
---|
955 | */
|
---|
956 | virtual void onTextAcceptedEvent(WindowEventArgs& e);
|
---|
957 |
|
---|
958 |
|
---|
959 | /*!
|
---|
960 | \brief
|
---|
961 | Handler called internally when the Combobox's Drop-down list contents are changed.
|
---|
962 | */
|
---|
963 | virtual void onListContentsChanged(WindowEventArgs& e);
|
---|
964 |
|
---|
965 |
|
---|
966 | /*!
|
---|
967 | \brief
|
---|
968 | Handler called internally when the selection within the Combobox's drop-down list changes
|
---|
969 | (this is not the 'final' accepted selection, just the currently highlighted item).
|
---|
970 | */
|
---|
971 | virtual void onListSelectionChanged(WindowEventArgs& e);
|
---|
972 |
|
---|
973 |
|
---|
974 | /*!
|
---|
975 | \brief
|
---|
976 | Handler called fired internally when the sort mode for the Combobox's drop-down list is changed.
|
---|
977 | */
|
---|
978 | virtual void onSortModeChanged(WindowEventArgs& e);
|
---|
979 |
|
---|
980 |
|
---|
981 | /*!
|
---|
982 | \brief
|
---|
983 | Handler called internally when the 'force' setting for the vertical scrollbar within the Combobox's
|
---|
984 | drop-down list is changed.
|
---|
985 | */
|
---|
986 | virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
|
---|
987 |
|
---|
988 |
|
---|
989 | /*!
|
---|
990 | \brief
|
---|
991 | Handler called internally when the 'force' setting for the horizontal scrollbar within the Combobox's
|
---|
992 | drop-down list is changed.
|
---|
993 | */
|
---|
994 | virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
|
---|
995 |
|
---|
996 |
|
---|
997 | /*!
|
---|
998 | \brief
|
---|
999 | Handler called internally when the Combobox's drop-down list has been displayed.
|
---|
1000 | */
|
---|
1001 | virtual void onDropListDisplayed(WindowEventArgs& e);
|
---|
1002 |
|
---|
1003 |
|
---|
1004 | /*!
|
---|
1005 | \brief
|
---|
1006 | Handler called internally when the Combobox's drop-down list has been hidden.
|
---|
1007 | */
|
---|
1008 | virtual void onDroplistRemoved(WindowEventArgs& e);
|
---|
1009 |
|
---|
1010 |
|
---|
1011 | /*!
|
---|
1012 | \brief
|
---|
1013 | Handler called internally when the user has confirmed a selection within the Combobox's drop-down list.
|
---|
1014 | */
|
---|
1015 | virtual void onListSelectionAccepted(WindowEventArgs& e);
|
---|
1016 |
|
---|
1017 |
|
---|
1018 | /*************************************************************************
|
---|
1019 | Overridden Event handlers
|
---|
1020 | *************************************************************************/
|
---|
1021 | virtual void onFontChanged(WindowEventArgs& e);
|
---|
1022 | virtual void onTextChanged(WindowEventArgs& e);
|
---|
1023 | virtual void onActivated(ActivationEventArgs& e);
|
---|
1024 |
|
---|
1025 |
|
---|
1026 | /*************************************************************************
|
---|
1027 | Implementation Data
|
---|
1028 | *************************************************************************/
|
---|
1029 | Editbox* d_editbox; //!< Editbox widget sub-component.
|
---|
1030 | ComboDropList* d_droplist; //!< ComboDropList widget sub-component.
|
---|
1031 | PushButton* d_button; //!< PushButton widget sub-component.
|
---|
1032 | bool d_singleClickOperation; //!< true if user can show and select from list in a single click.
|
---|
1033 |
|
---|
1034 |
|
---|
1035 | private:
|
---|
1036 | /*************************************************************************
|
---|
1037 | Static Properties for this class
|
---|
1038 | *************************************************************************/
|
---|
1039 | static ComboboxProperties::ReadOnly d_readOnlyProperty;
|
---|
1040 | static ComboboxProperties::ValidationString d_validationStringProperty;
|
---|
1041 | static ComboboxProperties::CaratIndex d_caratIndexProperty;
|
---|
1042 | static ComboboxProperties::EditSelectionStart d_selStartProperty;
|
---|
1043 | static ComboboxProperties::EditSelectionLength d_selLengthProperty;
|
---|
1044 | static ComboboxProperties::MaxEditTextLength d_maxTextLengthProperty;
|
---|
1045 | static ComboboxProperties::NormalEditTextColour d_normalTextColourProperty;
|
---|
1046 | static ComboboxProperties::SelectedEditTextColour d_selectedTextColourProperty;
|
---|
1047 | static ComboboxProperties::ActiveEditSelectionColour d_activeSelectionColourProperty;
|
---|
1048 | static ComboboxProperties::InactiveEditSelectionColour d_inactiveSelectionColourProperty;
|
---|
1049 | static ComboboxProperties::SortList d_sortProperty;
|
---|
1050 | static ComboboxProperties::ForceVertScrollbar d_forceVertProperty;
|
---|
1051 | static ComboboxProperties::ForceHorzScrollbar d_forceHorzProperty;
|
---|
1052 | static ComboboxProperties::SingleClickMode d_singleClickOperationProperty;
|
---|
1053 |
|
---|
1054 | /*************************************************************************
|
---|
1055 | Private methods
|
---|
1056 | *************************************************************************/
|
---|
1057 | void addComboboxProperties(void);
|
---|
1058 | };
|
---|
1059 |
|
---|
1060 | } // End of CEGUI namespace section
|
---|
1061 |
|
---|
1062 | #if defined(_MSC_VER)
|
---|
1063 | # pragma warning(pop)
|
---|
1064 | #endif
|
---|
1065 |
|
---|
1066 | #endif // end of guard _CEGUICombobox_h_
|
---|