Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Combobox.h
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  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUICombobox_h_
31 #define _CEGUICombobox_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/Window.h"
35 #include "CEGUI/RegexMatcher.h"
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
46 
51 class CEGUIEXPORT Combobox : public Window
52 {
53 public:
55 
56  static const String EventNamespace;
57  static const String WidgetTypeName;
58 
59  /*************************************************************************
60  Constants
61  *************************************************************************/
62  // event names from edit box
100  static const String EventCaretMoved;
113  static const String EventEditboxFull;
120  static const String EventTextAccepted;
121 
122  // event names from list box
160 
161  // events we produce / generate ourselves
180 
181  /*************************************************************************
182  Child Widget name constants
183  *************************************************************************/
184  static const String EditboxName;
185  static const String DropListName;
186  static const String ButtonName;
187 
188  // override from Window class
189  bool isHit(const Vector2f& position,
190  const bool allow_disabled = false) const;
191 
200  bool getSingleClickEnabled(void) const;
201 
202 
210  bool isDropDownListVisible(void) const;
211 
212 
223  Editbox* getEditbox() const;
224 
235  PushButton* getPushButton() const;
236 
248  ComboDropList* getDropList() const;
249 
251  bool getAutoSizeListHeightToContent() const;
252 
254  bool getAutoSizeListWidthToContent() const;
255 
256  /*************************************************************************
257  Editbox Accessors
258  *************************************************************************/
266  bool hasInputFocus(void) const;
267 
268 
277  bool isReadOnly(void) const;
278 
279 
294  MatchState getTextMatchState() const;
295 
296 
308  const String& getValidationString(void) const;
309 
310 
318  size_t getCaretIndex(void) const;
319 
320 
329  size_t getSelectionStartIndex(void) const;
330 
331 
340  size_t getSelectionEndIndex(void) const;
341 
342 
350  size_t getSelectionLength(void) const;
351 
352 
364  size_t getMaxTextLength(void) const;
365 
366 
367  /*************************************************************************
368  List Accessors
369  *************************************************************************/
377  size_t getItemCount(void) const;
378 
379 
388  ListboxItem* getSelectedItem(void) const;
389 
390 
403  ListboxItem* getListboxItemFromIndex(size_t index) const;
404 
405 
418  size_t getItemIndex(const ListboxItem* item) const;
419 
420 
428  bool isSortEnabled(void) const;
429 
430 
443  bool isItemSelected(size_t index) const;
444 
445 
463  ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item);
464 
465 
473  bool isListboxItemInList(const ListboxItem* item) const;
474 
475 
484  bool isVertScrollbarAlwaysShown(void) const;
485 
486 
495  bool isHorzScrollbarAlwaysShown(void) const;
496 
497 
498  /*************************************************************************
499  Combobox Manipulators
500  *************************************************************************/
511  virtual void initialiseComponents(void);
512 
513 
521  void showDropList(void);
522 
523 
531  void hideDropList(void);
532 
533 
545  void setSingleClickEnabled(bool setting);
546 
548  void selectListItemWithEditboxText();
549 
555  void setAutoSizeListHeightToContent(bool auto_size);
556 
562  void setAutoSizeListWidthToContent(bool auto_size);
563 
565  void updateAutoSizedDropList();
566 
567  /*************************************************************************
568  Editbox Manipulators
569  *************************************************************************/
581  void setReadOnly(bool setting);
582 
583 
598  void setValidationString(const String& validation_string);
599 
600 
612  void setCaretIndex(size_t caret_pos);
613 
614 
630  void setSelection(size_t start_pos, size_t end_pos);
642  void setSelectionStart(size_t start_pos);
643 
654  void setSelectionLength(size_t length);
655 
670  void setMaxTextLength(size_t max_len);
671 
672 
680  void activateEditbox(void);
681 
682 
683  /*************************************************************************
684  List Manipulators
685  *************************************************************************/
692  void resetList(void);
693 
694 
706  void addItem(ListboxItem* item);
707 
708 
726  void insertItem(ListboxItem* item, const ListboxItem* position);
727 
728 
740  void removeItem(const ListboxItem* item);
741 
742 
750  void clearAllSelections(void);
751 
752 
763  void setSortingEnabled(bool setting);
764 
765 
777  void setShowVertScrollbar(bool setting);
778 
779 
791  void setShowHorzScrollbar(bool setting);
792 
793 
813  void setItemSelectState(ListboxItem* item, bool state);
814 
815 
835  void setItemSelectState(size_t item_index, bool state);
836 
837 
850  void handleUpdatedListItemData(void);
851 
852 
853  /*************************************************************************
854  Construction and Destruction
855  *************************************************************************/
860  Combobox(const String& type, const String& name);
861 
862 
867  virtual ~Combobox(void);
868 
869 
870 protected:
871  /*************************************************************************
872  Implementation Methods
873  *************************************************************************/
878  bool button_PressHandler(const EventArgs& e);
879 
880 
885  bool droplist_SelectionAcceptedHandler(const EventArgs& e);
886 
887 
892  bool droplist_HiddenHandler(const EventArgs& e);
893 
894 
899  bool editbox_MouseDownHandler(const EventArgs& e);
900 
906  void itemSelectChangeTextUpdate(const ListboxItem* const item,
907  bool new_state, bool old_state);
908 
909  /*************************************************************************
910  Handlers to relay child widget events so they appear to come from us
911  *************************************************************************/
912  bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
913  bool editbox_ValidationStringChangedHandler(const EventArgs& e);
914  bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
915  bool editbox_TextValidityChangedHandler(const EventArgs& e);
916  bool editbox_CaretMovedHandler(const EventArgs& e);
917  bool editbox_TextSelectionChangedHandler(const EventArgs& e);
918  bool editbox_EditboxFullEventHandler(const EventArgs& e);
919  bool editbox_TextAcceptedEventHandler(const EventArgs& e);
920  bool editbox_TextChangedEventHandler(const EventArgs& e);
921  bool listbox_ListContentsChangedHandler(const EventArgs& e);
922  bool listbox_ListSelectionChangedHandler(const EventArgs& e);
923  bool listbox_SortModeChangedHandler(const EventArgs& e);
924  bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
925  bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
926 
927 
928  /*************************************************************************
929  New Events for Combobox
930  *************************************************************************/
935  virtual void onReadOnlyChanged(WindowEventArgs& e);
936 
937 
942  virtual void onValidationStringChanged(WindowEventArgs& e);
943 
944 
949  virtual void onMaximumTextLengthChanged(WindowEventArgs& e);
950 
951 
957  virtual void onTextValidityChanged(RegexMatchStateEventArgs& e);
958 
959 
964  virtual void onCaretMoved(WindowEventArgs& e);
965 
966 
971  virtual void onTextSelectionChanged(WindowEventArgs& e);
972 
973 
978  virtual void onEditboxFullEvent(WindowEventArgs& e);
979 
980 
985  virtual void onTextAcceptedEvent(WindowEventArgs& e);
986 
987 
992  virtual void onListContentsChanged(WindowEventArgs& e);
993 
994 
1000  virtual void onListSelectionChanged(WindowEventArgs& e);
1001 
1002 
1007  virtual void onSortModeChanged(WindowEventArgs& e);
1008 
1009 
1015  virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
1016 
1017 
1023  virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
1024 
1025 
1030  virtual void onDropListDisplayed(WindowEventArgs& e);
1031 
1032 
1037  virtual void onDroplistRemoved(WindowEventArgs& e);
1038 
1039 
1044  virtual void onListSelectionAccepted(WindowEventArgs& e);
1045 
1046 
1047  /*************************************************************************
1048  Overridden Event handlers
1049  *************************************************************************/
1050  virtual void onFontChanged(WindowEventArgs& e);
1051  virtual void onTextChanged(WindowEventArgs& e);
1052  virtual void onActivated(ActivationEventArgs& e);
1053  void onSized(ElementEventArgs& e);
1054 
1055 
1056  /*************************************************************************
1057  Implementation Data
1058  *************************************************************************/
1060  bool d_autoSizeHeight;
1061  bool d_autoSizeWidth;
1062 
1063 private:
1064  /*************************************************************************
1065  Private methods
1066  *************************************************************************/
1067  void addComboboxProperties(void);
1068 };
1069 
1070 } // End of CEGUI namespace section
1071 
1072 #if defined(_MSC_VER)
1073 # pragma warning(pop)
1074 #endif
1075 
1076 #endif // end of guard _CEGUICombobox_h_