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
43 namespace CEGUI
44 {
45 
50 class CEGUIEXPORT Combobox : public Window
51 {
52 public:
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;
112  static const String EventEditboxFull;
119  static const String EventTextAccepted;
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 
222  Editbox* getEditbox() const;
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 
402  ListboxItem* getListboxItemFromIndex(size_t index) const;
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 
483  bool isVertScrollbarAlwaysShown(void) const;
484 
485 
494  bool isHorzScrollbarAlwaysShown(void) const;
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 
749  void clearAllSelections(void);
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 
869 protected:
870  /*************************************************************************
871  Implementation Methods
872  *************************************************************************/
878 
879 
885 
886 
892 
893 
899 
905  void itemSelectChangeTextUpdate(const ListboxItem* const item,
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 
963  virtual void onCaretMoved(WindowEventArgs& e);
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  *************************************************************************/
1049  virtual void onFontChanged(WindowEventArgs& e);
1050  virtual void onTextChanged(WindowEventArgs& e);
1053 
1054 
1055  /*************************************************************************
1056  Implementation Data
1057  *************************************************************************/
1059  bool d_autoSizeHeight;
1060  bool d_autoSizeWidth;
1061 
1062 private:
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_
CEGUI::Combobox::EventTextSelectionChanged
static const String EventTextSelectionChanged
Definition: Combobox.h:105
CEGUI::Combobox::isHorzScrollbarAlwaysShown
bool isHorzScrollbarAlwaysShown(void) const
Return whether the horizontal scroll bar is always shown.
CEGUI::Combobox::button_PressHandler
bool button_PressHandler(const EventArgs &e)
Handler function for button clicks.
CEGUI::Combobox::isSortEnabled
bool isSortEnabled(void) const
return whether list sorting is enabled
CEGUI::Combobox::isVertScrollbarAlwaysShown
bool isVertScrollbarAlwaysShown(void) const
Return whether the vertical scroll bar is always shown.
CEGUI::Combobox::setAutoSizeListHeightToContent
void setAutoSizeListHeightToContent(bool auto_size)
Sets whether the Combobox drop-down list will automatically resize it's height according to the total...
CEGUI::Combobox::hideDropList
void hideDropList(void)
Hide the drop-down list.
CEGUI::Combobox::setMaxTextLength
void setMaxTextLength(size_t max_len)
set the maximum text length for this Editbox.
CEGUI::Combobox::onVertScrollbarModeChanged
virtual void onVertScrollbarModeChanged(WindowEventArgs &e)
Handler called internally when the 'force' setting for the vertical scrollbar within the Combobox's d...
CEGUI::Combobox::isItemSelected
bool isItemSelected(size_t index) const
return whether the string at index position index is selected
CEGUI::Combobox::onValidationStringChanged
virtual void onValidationStringChanged(WindowEventArgs &e)
Handler called internally when the Combobox's Editbox validation string has been changed.
CEGUI::Combobox::getItemCount
size_t getItemCount(void) const
Return number of items attached to the list box.
CEGUI::Combobox::EditboxName
static const String EditboxName
Widget name for the editbox component.
Definition: Combobox.h:183
CEGUI::Combobox::insertItem
void insertItem(ListboxItem *item, const ListboxItem *position)
Insert an item into the list box after a specified item already in the list.
CEGUI::Combobox
Base class for the Combobox widget.
Definition: Combobox.h:51
CEGUI::Combobox::setItemSelectState
void setItemSelectState(ListboxItem *item, bool state)
Set the select state of an attached ListboxItem.
CEGUI::Combobox::onMaximumTextLengthChanged
virtual void onMaximumTextLengthChanged(WindowEventArgs &e)
Handler called internally when the Combobox's Editbox maximum text length is changed.
CEGUI::Combobox::getSelectionLength
size_t getSelectionLength(void) const
return the length of the current selection (in code points / characters).
CEGUI::Combobox::d_singleClickOperation
bool d_singleClickOperation
true if user can show and select from list in a single click.
Definition: Combobox.h:1058
CEGUI::ElementEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: Element.h:211
CEGUI::Combobox::Combobox
Combobox(const String &type, const String &name)
Constructor for Combobox base class.
CEGUI::Combobox::getTextMatchState
MatchState getTextMatchState() const
return the validation MatchState for the current Combobox text, given the currently set validation st...
CEGUI::Combobox::removeItem
void removeItem(const ListboxItem *item)
Removes the given item from the list box.
CEGUI::Combobox::setCaretIndex
void setCaretIndex(size_t caret_pos)
Set the current position of the caret.
CEGUI::Combobox::EventTextValidityChanged
static const String EventTextValidityChanged
Definition: Combobox.h:93
CEGUI::Combobox::setSortingEnabled
void setSortingEnabled(bool setting)
Set whether the list should be sorted.
CEGUI::Combobox::onTextSelectionChanged
virtual void onTextSelectionChanged(WindowEventArgs &e)
Handler called internally when the selection within the Combobox's Editbox changes.
CEGUI::Combobox::getSelectedItem
ListboxItem * getSelectedItem(void) const
Return a pointer to the currently selected item.
CEGUI::Combobox::onDropListDisplayed
virtual void onDropListDisplayed(WindowEventArgs &e)
Handler called internally when the Combobox's drop-down list has been displayed.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Combobox::isListboxItemInList
bool isListboxItemInList(const ListboxItem *item) const
Return whether the specified ListboxItem is in the List.
CEGUI::Combobox::getMaxTextLength
size_t getMaxTextLength(void) const
return the maximum text length set for this Editbox.
CEGUI::Combobox::initialiseComponents
virtual void initialiseComponents(void)
Initialise the Window based object ready for use.
CEGUI::Combobox::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: Combobox.h:55
CEGUI::Vector2< float >
CEGUI::RegexMatchStateEventArgs
Definition: RegexMatcher.h:70
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
CEGUI::Combobox::handleUpdatedListItemData
void handleUpdatedListItemData(void)
Causes the list box to update it's internal state after changes have been made to one or more attache...
CEGUI::Combobox::WidgetTypeName
static const String WidgetTypeName
Window factory name.
Definition: Combobox.h:56
CEGUI::Combobox::EventVertScrollbarModeChanged
static const String EventVertScrollbarModeChanged
Definition: Combobox.h:151
CEGUI::Combobox::onEditboxFullEvent
virtual void onEditboxFullEvent(WindowEventArgs &e)
Handler called internally when the maximum length is reached for text in the Combobox's Editbox.
CEGUI::Combobox::getDropList
ComboDropList * getDropList() const
Return a pointer to the ComboDropList component widget for this Combobox.
CEGUI::Combobox::getListboxItemFromIndex
ListboxItem * getListboxItemFromIndex(size_t index) const
Return the item at index position index.
CEGUI::Combobox::isHit
bool isHit(const Vector2f &position, const bool allow_disabled=false) const
check if the given pixel position would hit this window.
CEGUI::Combobox::EventHorzScrollbarModeChanged
static const String EventHorzScrollbarModeChanged
Definition: Combobox.h:158
CEGUI::Combobox::getSelectionEndIndex
size_t getSelectionEndIndex(void) const
return the current selection end point.
CEGUI::Editbox
Base class for an Editbox widget.
Definition: widgets/Editbox.h:70
CEGUI::Combobox::droplist_SelectionAcceptedHandler
bool droplist_SelectionAcceptedHandler(const EventArgs &e)
Handler for selections made in the drop-list.
CEGUI::Combobox::EventListSelectionChanged
static const String EventListSelectionChanged
Definition: Combobox.h:138
CEGUI::ActivationEventArgs
EventArgs based class that is used for Activated and Deactivated window events.
Definition: InputEvent.h:330
CEGUI::Combobox::resetList
void resetList(void)
Remove all items from the list.
CEGUI::Combobox::onReadOnlyChanged
virtual void onReadOnlyChanged(WindowEventArgs &e)
Handler called internally when the read only state of the Combobox's Editbox has been changed.
CEGUI::Combobox::onDroplistRemoved
virtual void onDroplistRemoved(WindowEventArgs &e)
Handler called internally when the Combobox's drop-down list has been hidden.
CEGUI::Combobox::setShowVertScrollbar
void setShowVertScrollbar(bool setting)
Set whether the vertical scroll bar should always be shown.
CEGUI::Combobox::isDropDownListVisible
bool isDropDownListVisible(void) const
returns true if the drop down list is visible.
CEGUI::Combobox::addItem
void addItem(ListboxItem *item)
Add the given ListboxItem to the list.
CEGUI::Combobox::onListSelectionChanged
virtual void onListSelectionChanged(WindowEventArgs &e)
Handler called internally when the selection within the Combobox's drop-down list changes (this is no...
CEGUI::Combobox::EventListSelectionAccepted
static const String EventListSelectionAccepted
Definition: Combobox.h:178
CEGUI::RegexMatcher::MatchState
MatchState
Enumeration of possible states when cosidering a regex match.
Definition: RegexMatcher.h:45
CEGUI::Combobox::EventMaximumTextLengthChanged
static const String EventMaximumTextLengthChanged
Definition: Combobox.h:79
CEGUI::Combobox::EventCaretMoved
static const String EventCaretMoved
Definition: Combobox.h:99
CEGUI::Combobox::findItemWithText
ListboxItem * findItemWithText(const String &text, const ListboxItem *start_item)
Search the list for an item with the specified text.
CEGUI::Combobox::onTextValidityChanged
virtual void onTextValidityChanged(RegexMatchStateEventArgs &e)
Handler called when something has caused the validity state of the current text to change.
CEGUI::Combobox::onCaretMoved
virtual void onCaretMoved(WindowEventArgs &e)
Handler called internally when the caret in the Comboxbox's Editbox moves.
CEGUI::Combobox::EventDropListDisplayed
static const String EventDropListDisplayed
Definition: Combobox.h:166
CEGUI::Combobox::onFontChanged
virtual void onFontChanged(WindowEventArgs &e)
Handler called when the window's font is changed.
CEGUI::Combobox::getSingleClickEnabled
bool getSingleClickEnabled(void) const
returns the mode of operation for the combo box.
CEGUI::Combobox::getPushButton
PushButton * getPushButton() const
Return a pointer to the PushButton component widget for this Combobox.
CEGUI::Combobox::setSingleClickEnabled
void setSingleClickEnabled(bool setting)
Set the mode of operation for the combo box.
CEGUI::Combobox::ButtonName
static const String ButtonName
Widget suffix for the button component.
Definition: Combobox.h:185
CEGUI::Combobox::setItemSelectState
void setItemSelectState(size_t item_index, bool state)
Set the select state of an attached ListboxItem.
CEGUI::Combobox::setShowHorzScrollbar
void setShowHorzScrollbar(bool setting)
Set whether the horizontal scroll bar should always be shown.
CEGUI::Combobox::EventTextAccepted
static const String EventTextAccepted
Definition: Combobox.h:119
CEGUI::Combobox::getAutoSizeListWidthToContent
bool getAutoSizeListWidthToContent() const
return whether the drop-list will horizontally auto size to content.
CEGUI::Combobox::EventValidationStringChanged
static const String EventValidationStringChanged
Definition: Combobox.h:73
CEGUI::Combobox::onSortModeChanged
virtual void onSortModeChanged(WindowEventArgs &e)
Handler called fired internally when the sort mode for the Combobox's drop-down list is changed.
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::Combobox::selectListItemWithEditboxText
void selectListItemWithEditboxText()
Select item in list matching editbox text, clear selection if none match.
CEGUI::Combobox::getItemIndex
size_t getItemIndex(const ListboxItem *item) const
Return the index of ListboxItem item.
CEGUI::Combobox::setValidationString
void setValidationString(const String &validation_string)
Set the text validation string.
CEGUI::Combobox::showDropList
void showDropList(void)
Show the drop-down list.
CEGUI::Combobox::setSelection
void setSelection(size_t start_pos, size_t end_pos)
Define the current selection for the Editbox.
CEGUI::Combobox::onListContentsChanged
virtual void onListContentsChanged(WindowEventArgs &e)
Handler called internally when the Combobox's Drop-down list contents are changed.
CEGUI::Combobox::onHorzScrollbarModeChanged
virtual void onHorzScrollbarModeChanged(WindowEventArgs &e)
Handler called internally when the 'force' setting for the horizontal scrollbar within the Combobox's...
CEGUI::Combobox::setSelectionLength
void setSelectionLength(size_t length)
Define the current selection for the Editbox.
CEGUI::Combobox::onTextAcceptedEvent
virtual void onTextAcceptedEvent(WindowEventArgs &e)
Handler called internally when the text in the Combobox's Editbox is accepted (by various means).
CEGUI::Combobox::setAutoSizeListWidthToContent
void setAutoSizeListWidthToContent(bool auto_size)
Sets whether the Combobox drop-down list will automatically resize it's width according to the width ...
CEGUI::Combobox::getSelectionStartIndex
size_t getSelectionStartIndex(void) const
return the current selection start point.
CEGUI::Combobox::EventSortModeChanged
static const String EventSortModeChanged
Definition: Combobox.h:144
CEGUI::Combobox::hasInputFocus
bool hasInputFocus(void) const
return true if the Editbox has input focus.
CEGUI::Combobox::updateAutoSizedDropList
void updateAutoSizedDropList()
update drop list size according to auto-size options.
CEGUI::Combobox::itemSelectChangeTextUpdate
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.
CEGUI::Combobox::EventDropListRemoved
static const String EventDropListRemoved
Definition: Combobox.h:172
CEGUI::Combobox::setReadOnly
void setReadOnly(bool setting)
Specify whether the Editbox is read-only.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Combobox::onActivated
virtual void onActivated(ActivationEventArgs &e)
Handler called when this window has become the active window.
CEGUI::Combobox::activateEditbox
void activateEditbox(void)
Activate the edit box component of the Combobox.
CEGUI::Combobox::editbox_MouseDownHandler
bool editbox_MouseDownHandler(const EventArgs &e)
Mouse button down handler attached to edit box.
CEGUI::Combobox::droplist_HiddenHandler
bool droplist_HiddenHandler(const EventArgs &e)
Handler for when drop-list hides itself.
CEGUI::Combobox::EventReadOnlyModeChanged
static const String EventReadOnlyModeChanged
Definition: Combobox.h:67
CEGUI::Combobox::clearAllSelections
void clearAllSelections(void)
Clear the selected state for all items.
CEGUI::Combobox::getAutoSizeListHeightToContent
bool getAutoSizeListHeightToContent() const
return whether the drop-list will vertically auto size to content.
CEGUI::Combobox::setSelectionStart
void setSelectionStart(size_t start_pos)
Define the current selection start for the Editbox.
CEGUI::PushButton
Base class to provide logic for push button type widgets.
Definition: PushButton.h:48
CEGUI::Combobox::~Combobox
virtual ~Combobox(void)
Destructor for Combobox base class.
CEGUI::ComboDropList
Base class for the combo box drop down list. This is a specialisation of the Listbox class.
Definition: ComboDropList.h:49
CEGUI::Combobox::getCaretIndex
size_t getCaretIndex(void) const
return the current position of the caret.
CEGUI::Combobox::onTextChanged
virtual void onTextChanged(WindowEventArgs &e)
Handler called when the window's text is changed.
CEGUI::Combobox::onSized
void onSized(ElementEventArgs &e)
Handler called when the window's size changes.
CEGUI::Combobox::onListSelectionAccepted
virtual void onListSelectionAccepted(WindowEventArgs &e)
Handler called internally when the user has confirmed a selection within the Combobox's drop-down lis...
CEGUI::Combobox::EventEditboxFull
static const String EventEditboxFull
Definition: Combobox.h:112
CEGUI::Combobox::getEditbox
Editbox * getEditbox() const
Return a pointer to the Editbox component widget for this Combobox.
CEGUI::Combobox::isReadOnly
bool isReadOnly(void) const
return true if the Editbox is read-only.
CEGUI::EventArgs
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
CEGUI::Combobox::getValidationString
const String & getValidationString(void) const
return the currently set validation string
CEGUI::Combobox::DropListName
static const String DropListName
Widget name for the drop list component.
Definition: Combobox.h:184
CEGUI::Combobox::EventListContentsChanged
static const String EventListContentsChanged
Definition: Combobox.h:127
CEGUI::ListboxItem
Base class for list box items.
Definition: ListboxItem.h:53