Crazy Eddie's GUI System 0.8.7
Combobox.h
1/***********************************************************************
2 created: 13/4/2004
3 author: Paul D Turner
4
5 purpose: Interface to base class for Combobox widget
6*************************************************************************/
7/***************************************************************************
8 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 ***************************************************************************/
29#ifndef _CEGUICombobox_h_
30#define _CEGUICombobox_h_
31
32#include "CEGUI/Base.h"
33#include "CEGUI/Window.h"
34#include "CEGUI/RegexMatcher.h"
35
36#if defined(_MSC_VER)
37# pragma warning(push)
38# pragma warning(disable : 4251)
39#endif
40
41
42// Start of CEGUI namespace section
43namespace CEGUI
44{
45
50class CEGUIEXPORT Combobox : public Window
51{
52public:
54
55 static const String EventNamespace;
56 static const String WidgetTypeName;
57
58 /*************************************************************************
59 Constants
60 *************************************************************************/
61 // event names from edit box
99 static const String EventCaretMoved;
120
121 // event names from list box
159
160 // events we produce / generate ourselves
179
180 /*************************************************************************
181 Child Widget name constants
182 *************************************************************************/
183 static const String EditboxName;
184 static const String DropListName;
185 static const String ButtonName;
186
187 // override from Window class
188 bool isHit(const Vector2f& position,
189 const bool allow_disabled = false) const;
190
199 bool getSingleClickEnabled(void) const;
200
201
209 bool isDropDownListVisible(void) const;
210
211
223
235
248
251
254
255 /*************************************************************************
256 Editbox Accessors
257 *************************************************************************/
265 bool hasInputFocus(void) const;
266
267
276 bool isReadOnly(void) const;
277
278
294
295
307 const String& getValidationString(void) const;
308
309
317 size_t getCaretIndex(void) const;
318
319
328 size_t getSelectionStartIndex(void) const;
329
330
339 size_t getSelectionEndIndex(void) const;
340
341
349 size_t getSelectionLength(void) const;
350
351
363 size_t getMaxTextLength(void) const;
364
365
366 /*************************************************************************
367 List Accessors
368 *************************************************************************/
376 size_t getItemCount(void) const;
377
378
388
389
403
404
417 size_t getItemIndex(const ListboxItem* item) const;
418
419
427 bool isSortEnabled(void) const;
428
429
442 bool isItemSelected(size_t index) const;
443
444
462 ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item);
463
464
472 bool isListboxItemInList(const ListboxItem* item) const;
473
474
484
485
495
496
497 /*************************************************************************
498 Combobox Manipulators
499 *************************************************************************/
510 virtual void initialiseComponents(void);
511
512
520 void showDropList(void);
521
522
530 void hideDropList(void);
531
532
544 void setSingleClickEnabled(bool setting);
545
548
554 void setAutoSizeListHeightToContent(bool auto_size);
555
561 void setAutoSizeListWidthToContent(bool auto_size);
562
565
566 /*************************************************************************
567 Editbox Manipulators
568 *************************************************************************/
580 void setReadOnly(bool setting);
581
582
597 void setValidationString(const String& validation_string);
598
599
611 void setCaretIndex(size_t caret_pos);
612
613
629 void setSelection(size_t start_pos, size_t end_pos);
641 void setSelectionStart(size_t start_pos);
642
653 void setSelectionLength(size_t length);
654
669 void setMaxTextLength(size_t max_len);
670
671
679 void activateEditbox(void);
680
681
682 /*************************************************************************
683 List Manipulators
684 *************************************************************************/
691 void resetList(void);
692
693
705 void addItem(ListboxItem* item);
706
707
725 void insertItem(ListboxItem* item, const ListboxItem* position);
726
727
739 void removeItem(const ListboxItem* item);
740
741
750
751
762 void setSortingEnabled(bool setting);
763
764
776 void setShowVertScrollbar(bool setting);
777
778
790 void setShowHorzScrollbar(bool setting);
791
792
812 void setItemSelectState(ListboxItem* item, bool state);
813
814
834 void setItemSelectState(size_t item_index, bool state);
835
836
850
851
852 /*************************************************************************
853 Construction and Destruction
854 *************************************************************************/
859 Combobox(const String& type, const String& name);
860
861
866 virtual ~Combobox(void);
867
868
869protected:
870 /*************************************************************************
871 Implementation Methods
872 *************************************************************************/
878
879
885
886
892
893
899
906 bool new_state, bool old_state);
907
908 /*************************************************************************
909 Handlers to relay child widget events so they appear to come from us
910 *************************************************************************/
911 bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
912 bool editbox_ValidationStringChangedHandler(const EventArgs& e);
913 bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
914 bool editbox_TextValidityChangedHandler(const EventArgs& e);
915 bool editbox_CaretMovedHandler(const EventArgs& e);
916 bool editbox_TextSelectionChangedHandler(const EventArgs& e);
917 bool editbox_EditboxFullEventHandler(const EventArgs& e);
918 bool editbox_TextAcceptedEventHandler(const EventArgs& e);
919 bool editbox_TextChangedEventHandler(const EventArgs& e);
920 bool listbox_ListContentsChangedHandler(const EventArgs& e);
921 bool listbox_ListSelectionChangedHandler(const EventArgs& e);
922 bool listbox_SortModeChangedHandler(const EventArgs& e);
923 bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
924 bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
925
926
927 /*************************************************************************
928 New Events for Combobox
929 *************************************************************************/
935
936
942
943
949
950
957
958
964
965
971
972
978
979
985
986
992
993
1000
1001
1007
1008
1015
1016
1023
1024
1030
1031
1037
1038
1044
1045
1046 /*************************************************************************
1047 Overridden Event handlers
1048 *************************************************************************/
1053
1054
1055 /*************************************************************************
1056 Implementation Data
1057 *************************************************************************/
1059 bool d_autoSizeHeight;
1060 bool d_autoSizeWidth;
1061
1062private:
1063 /*************************************************************************
1064 Private methods
1065 *************************************************************************/
1066 void addComboboxProperties(void);
1067};
1068
1069} // End of CEGUI namespace section
1070
1071#if defined(_MSC_VER)
1072# pragma warning(pop)
1073#endif
1074
1075#endif // end of guard _CEGUICombobox_h_
EventArgs based class that is used for Activated and Deactivated window events.
Definition: InputEvent.h:330
Base class for the combo box drop down list. This is a specialisation of the Listbox class.
Definition: ComboDropList.h:49
Base class for the Combobox widget.
Definition: Combobox.h:51
virtual void onSortModeChanged(WindowEventArgs &e)
Handler called fired internally when the sort mode for the Combobox's drop-down list is changed.
virtual void onEditboxFullEvent(WindowEventArgs &e)
Handler called internally when the maximum length is reached for text in the Combobox's Editbox.
void handleUpdatedListItemData(void)
Causes the list box to update it's internal state after changes have been made to one or more attache...
static const String EventValidationStringChanged
Definition: Combobox.h:73
void setAutoSizeListHeightToContent(bool auto_size)
Sets whether the Combobox drop-down list will automatically resize it's height according to the total...
size_t getMaxTextLength(void) const
return the maximum text length set for this Editbox.
PushButton * getPushButton() const
Return a pointer to the PushButton component widget for this Combobox.
size_t getSelectionStartIndex(void) const
return the current selection start point.
static const String EventNamespace
Namespace for global events.
Definition: Combobox.h:55
void setAutoSizeListWidthToContent(bool auto_size)
Sets whether the Combobox drop-down list will automatically resize it's width according to the width ...
bool isVertScrollbarAlwaysShown(void) const
Return whether the vertical scroll bar is always shown.
ListboxItem * findItemWithText(const String &text, const ListboxItem *start_item)
Search the list for an item with the specified text.
bool editbox_MouseDownHandler(const EventArgs &e)
Mouse button down handler attached to edit box.
const String & getValidationString(void) const
return the currently set validation string
void activateEditbox(void)
Activate the edit box component of the Combobox.
void addItem(ListboxItem *item)
Add the given ListboxItem to the list.
virtual void onCaretMoved(WindowEventArgs &e)
Handler called internally when the caret in the Comboxbox's Editbox moves.
static const String EventReadOnlyModeChanged
Definition: Combobox.h:67
void updateAutoSizedDropList()
update drop list size according to auto-size options.
void setValidationString(const String &validation_string)
Set the text validation string.
virtual ~Combobox(void)
Destructor for Combobox base class.
void insertItem(ListboxItem *item, const ListboxItem *position)
Insert an item into the list box after a specified item already in the list.
void resetList(void)
Remove all items from the list.
Combobox(const String &type, const String &name)
Constructor for Combobox base class.
void showDropList(void)
Show the drop-down list.
virtual void onHorzScrollbarModeChanged(WindowEventArgs &e)
Handler called internally when the 'force' setting for the horizontal scrollbar within the Combobox's...
void selectListItemWithEditboxText()
Select item in list matching editbox text, clear selection if none match.
void setReadOnly(bool setting)
Specify whether the Editbox is read-only.
virtual void onListSelectionChanged(WindowEventArgs &e)
Handler called internally when the selection within the Combobox's drop-down list changes (this is no...
virtual void onListContentsChanged(WindowEventArgs &e)
Handler called internally when the Combobox's Drop-down list contents are changed.
virtual void onReadOnlyChanged(WindowEventArgs &e)
Handler called internally when the read only state of the Combobox's Editbox has been changed.
void hideDropList(void)
Hide the drop-down list.
void removeItem(const ListboxItem *item)
Removes the given item from the list box.
size_t getSelectionEndIndex(void) const
return the current selection end point.
static const String EventEditboxFull
Definition: Combobox.h:112
bool isSortEnabled(void) const
return whether list sorting is enabled
static const String DropListName
Widget name for the drop list component.
Definition: Combobox.h:184
static const String EventListSelectionChanged
Definition: Combobox.h:138
bool droplist_HiddenHandler(const EventArgs &e)
Handler for when drop-list hides itself.
static const String EventListSelectionAccepted
Definition: Combobox.h:178
virtual void onDroplistRemoved(WindowEventArgs &e)
Handler called internally when the Combobox's drop-down list has been hidden.
void setCaretIndex(size_t caret_pos)
Set the current position of the caret.
static const String EventVertScrollbarModeChanged
Definition: Combobox.h:151
void setSortingEnabled(bool setting)
Set whether the list should be sorted.
ListboxItem * getListboxItemFromIndex(size_t index) const
Return the item at index position index.
bool getAutoSizeListHeightToContent() const
return whether the drop-list will vertically auto size to content.
static const String EventSortModeChanged
Definition: Combobox.h:144
virtual void onValidationStringChanged(WindowEventArgs &e)
Handler called internally when the Combobox's Editbox validation string has been changed.
virtual void onTextChanged(WindowEventArgs &e)
Handler called when the window's text is changed.
void itemSelectChangeTextUpdate(const ListboxItem *const item, bool new_state, bool old_state)
Update the Combobox text to reflect programmatically made changes to selected list item.
void setShowHorzScrollbar(bool setting)
Set whether the horizontal scroll bar should always be shown.
void setShowVertScrollbar(bool setting)
Set whether the vertical scroll bar should always be shown.
virtual void onActivated(ActivationEventArgs &e)
Handler called when this window has become the active window.
virtual void onDropListDisplayed(WindowEventArgs &e)
Handler called internally when the Combobox's drop-down list has been displayed.
ListboxItem * getSelectedItem(void) const
Return a pointer to the currently selected item.
bool button_PressHandler(const EventArgs &e)
Handler function for button clicks.
static const String EventMaximumTextLengthChanged
Definition: Combobox.h:79
static const String EventDropListDisplayed
Definition: Combobox.h:166
void setSelectionLength(size_t length)
Define the current selection for the Editbox.
static const String EventTextAccepted
Definition: Combobox.h:119
bool isListboxItemInList(const ListboxItem *item) const
Return whether the specified ListboxItem is in the List.
size_t getCaretIndex(void) const
return the current position of the caret.
void setItemSelectState(ListboxItem *item, bool state)
Set the select state of an attached ListboxItem.
virtual void onListSelectionAccepted(WindowEventArgs &e)
Handler called internally when the user has confirmed a selection within the Combobox's drop-down lis...
void setSelectionStart(size_t start_pos)
Define the current selection start for the Editbox.
void onSized(ElementEventArgs &e)
Handler called when the window's size changes.
bool isHit(const Vector2f &position, const bool allow_disabled=false) const
check if the given pixel position would hit this window.
static const String EventTextSelectionChanged
Definition: Combobox.h:105
bool isDropDownListVisible(void) const
returns true if the drop down list is visible.
virtual void onFontChanged(WindowEventArgs &e)
Handler called when the window's font is changed.
bool droplist_SelectionAcceptedHandler(const EventArgs &e)
Handler for selections made in the drop-list.
virtual void initialiseComponents(void)
Initialise the Window based object ready for use.
static const String EditboxName
Widget name for the editbox component.
Definition: Combobox.h:183
bool isItemSelected(size_t index) const
return whether the string at index position index is selected
virtual void onMaximumTextLengthChanged(WindowEventArgs &e)
Handler called internally when the Combobox's Editbox maximum text length is changed.
bool getAutoSizeListWidthToContent() const
return whether the drop-list will horizontally auto size to content.
static const String ButtonName
Widget suffix for the button component.
Definition: Combobox.h:185
size_t getItemIndex(const ListboxItem *item) const
Return the index of ListboxItem item.
static const String EventListContentsChanged
Definition: Combobox.h:127
static const String EventTextValidityChanged
Definition: Combobox.h:93
static const String EventDropListRemoved
Definition: Combobox.h:172
virtual void onTextValidityChanged(RegexMatchStateEventArgs &e)
Handler called when something has caused the validity state of the current text to change.
virtual void onVertScrollbarModeChanged(WindowEventArgs &e)
Handler called internally when the 'force' setting for the vertical scrollbar within the Combobox's d...
Editbox * getEditbox() const
Return a pointer to the Editbox component widget for this Combobox.
bool hasInputFocus(void) const
return true if the Editbox has input focus.
virtual void onTextSelectionChanged(WindowEventArgs &e)
Handler called internally when the selection within the Combobox's Editbox changes.
bool isReadOnly(void) const
return true if the Editbox is read-only.
static const String EventHorzScrollbarModeChanged
Definition: Combobox.h:158
static const String EventCaretMoved
Definition: Combobox.h:99
virtual void onTextAcceptedEvent(WindowEventArgs &e)
Handler called internally when the text in the Combobox's Editbox is accepted (by various means).
bool getSingleClickEnabled(void) const
returns the mode of operation for the combo box.
void setMaxTextLength(size_t max_len)
set the maximum text length for this Editbox.
void setItemSelectState(size_t item_index, bool state)
Set the select state of an attached ListboxItem.
static const String WidgetTypeName
Window factory name.
Definition: Combobox.h:56
size_t getSelectionLength(void) const
return the length of the current selection (in code points / characters).
bool isHorzScrollbarAlwaysShown(void) const
Return whether the horizontal scroll bar is always shown.
bool d_singleClickOperation
true if user can show and select from list in a single click.
Definition: Combobox.h:1058
void clearAllSelections(void)
Clear the selected state for all items.
void setSingleClickEnabled(bool setting)
Set the mode of operation for the combo box.
size_t getItemCount(void) const
Return number of items attached to the list box.
ComboDropList * getDropList() const
Return a pointer to the ComboDropList component widget for this Combobox.
MatchState getTextMatchState() const
return the validation MatchState for the current Combobox text, given the currently set validation st...
void setSelection(size_t start_pos, size_t end_pos)
Define the current selection for the Editbox.
Base class for an Editbox widget.
Definition: widgets/Editbox.h:70
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: Element.h:211
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
Base class for list box items.
Definition: ListboxItem.h:53
Base class to provide logic for push button type widgets.
Definition: PushButton.h:48
Definition: RegexMatcher.h:70
MatchState
Enumeration of possible states when cosidering a regex match.
Definition: RegexMatcher.h:45
String class used within the GUI system.
Definition: String.h:64
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1