Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 
234  PushButton* getPushButton() const;
235 
247  ComboDropList* getDropList() const;
248 
250  bool getAutoSizeListHeightToContent() const;
251 
253  bool getAutoSizeListWidthToContent() const;
254 
255  /*************************************************************************
256  Editbox Accessors
257  *************************************************************************/
265  bool hasInputFocus(void) const;
266 
267 
276  bool isReadOnly(void) const;
277 
278 
293  MatchState getTextMatchState() const;
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 
387  ListboxItem* getSelectedItem(void) const;
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 
547  void selectListItemWithEditboxText();
548 
554  void setAutoSizeListHeightToContent(bool auto_size);
555 
561  void setAutoSizeListWidthToContent(bool auto_size);
562 
564  void updateAutoSizedDropList();
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 
849  void handleUpdatedListItemData(void);
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  *************************************************************************/
877  bool button_PressHandler(const EventArgs& e);
878 
879 
884  bool droplist_SelectionAcceptedHandler(const EventArgs& e);
885 
886 
891  bool droplist_HiddenHandler(const EventArgs& e);
892 
893 
898  bool editbox_MouseDownHandler(const EventArgs& e);
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  *************************************************************************/
934  virtual void onReadOnlyChanged(WindowEventArgs& e);
935 
936 
941  virtual void onValidationStringChanged(WindowEventArgs& e);
942 
943 
948  virtual void onMaximumTextLengthChanged(WindowEventArgs& e);
949 
950 
956  virtual void onTextValidityChanged(RegexMatchStateEventArgs& e);
957 
958 
963  virtual void onCaretMoved(WindowEventArgs& e);
964 
965 
970  virtual void onTextSelectionChanged(WindowEventArgs& e);
971 
972 
977  virtual void onEditboxFullEvent(WindowEventArgs& e);
978 
979 
984  virtual void onTextAcceptedEvent(WindowEventArgs& e);
985 
986 
991  virtual void onListContentsChanged(WindowEventArgs& e);
992 
993 
999  virtual void onListSelectionChanged(WindowEventArgs& e);
1000 
1001 
1006  virtual void onSortModeChanged(WindowEventArgs& e);
1007 
1008 
1014  virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
1015 
1016 
1022  virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
1023 
1024 
1029  virtual void onDropListDisplayed(WindowEventArgs& e);
1030 
1031 
1036  virtual void onDroplistRemoved(WindowEventArgs& e);
1037 
1038 
1043  virtual void onListSelectionAccepted(WindowEventArgs& e);
1044 
1045 
1046  /*************************************************************************
1047  Overridden Event handlers
1048  *************************************************************************/
1049  virtual void onFontChanged(WindowEventArgs& e);
1050  virtual void onTextChanged(WindowEventArgs& e);
1051  virtual void onActivated(ActivationEventArgs& e);
1052  void onSized(ElementEventArgs& 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_