Crazy Eddies GUI System  0.7.1
CEGUICombobox.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 "../CEGUIBase.h"
34 #include "../CEGUIWindow.h"
35 #include "CEGUIComboboxProperties.h"
36 
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 
44 // Start of CEGUI namespace section
45 namespace CEGUI
46 {
47 
52 class CEGUIEXPORT Combobox : public Window
53 {
54 public:
55  static const String EventNamespace;
56  static const String WidgetTypeName;
57 
58  /*************************************************************************
59  Constants
60  *************************************************************************/
61  // event names from edit box
67  static const String EventCaratMoved;
69  static const String EventEditboxFull;
70  static const String EventTextAccepted;
71 
72  // event names from list box
78 
79  // events we produce / generate ourselves
83 
84  /*************************************************************************
85  Child Widget name suffix constants
86  *************************************************************************/
87  static const String EditboxNameSuffix;
88  static const String DropListNameSuffix;
89  static const String ButtonNameSuffix;
90 
91  // override from Window class
92  bool isHit(const Vector2& position,
93  const bool allow_disabled = false) const;
94 
103  bool getSingleClickEnabled(void) const;
104 
105 
113  bool isDropDownListVisible(void) const;
114 
115 
126  Editbox* getEditbox() const;
127 
138  PushButton* getPushButton() const;
139 
151  ComboDropList* getDropList() const;
152 
153 
154  /*************************************************************************
155  Editbox Accessors
156  *************************************************************************/
164  bool hasInputFocus(void) const;
165 
166 
175  bool isReadOnly(void) const;
176 
177 
194  bool isTextValid(void) const;
195 
196 
208  const String& getValidationString(void) const;
209 
210 
218  size_t getCaratIndex(void) const;
219 
220 
229  size_t getSelectionStartIndex(void) const;
230 
231 
240  size_t getSelectionEndIndex(void) const;
241 
242 
250  size_t getSelectionLength(void) const;
251 
252 
264  size_t getMaxTextLength(void) const;
265 
266 
267  /*************************************************************************
268  List Accessors
269  *************************************************************************/
277  size_t getItemCount(void) const;
278 
279 
288  ListboxItem* getSelectedItem(void) const;
289 
290 
303  ListboxItem* getListboxItemFromIndex(size_t index) const;
304 
305 
318  size_t getItemIndex(const ListboxItem* item) const;
319 
320 
328  bool isSortEnabled(void) const;
329 
330 
343  bool isItemSelected(size_t index) const;
344 
345 
363  ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item);
364 
365 
373  bool isListboxItemInList(const ListboxItem* item) const;
374 
375 
384  bool isVertScrollbarAlwaysShown(void) const;
385 
386 
395  bool isHorzScrollbarAlwaysShown(void) const;
396 
397 
398  /*************************************************************************
399  Combobox Manipulators
400  *************************************************************************/
411  virtual void initialiseComponents(void);
412 
413 
421  void showDropList(void);
422 
423 
431  void hideDropList(void);
432 
433 
445  void setSingleClickEnabled(bool setting);
446 
447 
448  /*************************************************************************
449  Editbox Manipulators
450  *************************************************************************/
462  void setReadOnly(bool setting);
463 
464 
479  void setValidationString(const String& validation_string);
480 
481 
493  void setCaratIndex(size_t carat_pos);
494 
495 
511  void setSelection(size_t start_pos, size_t end_pos);
512 
513 
528  void setMaxTextLength(size_t max_len);
529 
530 
538  void activateEditbox(void);
539 
540 
541  /*************************************************************************
542  List Manipulators
543  *************************************************************************/
550  void resetList(void);
551 
552 
564  void addItem(ListboxItem* item);
565 
566 
584  void insertItem(ListboxItem* item, const ListboxItem* position);
585 
586 
598  void removeItem(const ListboxItem* item);
599 
600 
608  void clearAllSelections(void);
609 
610 
621  void setSortingEnabled(bool setting);
622 
623 
635  void setShowVertScrollbar(bool setting);
636 
637 
649  void setShowHorzScrollbar(bool setting);
650 
651 
671  void setItemSelectState(ListboxItem* item, bool state);
672 
673 
693  void setItemSelectState(size_t item_index, bool state);
694 
695 
708  void handleUpdatedListItemData(void);
709 
710 
711  /*************************************************************************
712  Construction and Destruction
713  *************************************************************************/
718  Combobox(const String& type, const String& name);
719 
720 
725  virtual ~Combobox(void);
726 
727 
728 protected:
729  /*************************************************************************
730  Implementation Methods
731  *************************************************************************/
736  bool button_PressHandler(const EventArgs& e);
737 
738 
743  bool droplist_SelectionAcceptedHandler(const EventArgs& e);
744 
745 
750  bool droplist_HiddenHandler(const EventArgs& e);
751 
752 
757  bool editbox_MouseDownHandler(const EventArgs& e);
758 
759 
770  virtual bool testClassName_impl(const String& class_name) const
771  {
772  if (class_name=="Combobox") return true;
773  return Window::testClassName_impl(class_name);
774  }
775 
781  void itemSelectChangeTextUpdate(const ListboxItem* const item,
782  bool new_state, bool old_state);
783 
784  /*************************************************************************
785  Handlers to relay child widget events so they appear to come from us
786  *************************************************************************/
787  bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
788  bool editbox_ValidationStringChangedHandler(const EventArgs& e);
789  bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
790  bool editbox_TextInvalidatedEventHandler(const EventArgs& e);
791  bool editbox_InvalidEntryAttemptedHandler(const EventArgs& e);
792  bool editbox_CaratMovedHandler(const EventArgs& e);
793  bool editbox_TextSelectionChangedHandler(const EventArgs& e);
794  bool editbox_EditboxFullEventHandler(const EventArgs& e);
795  bool editbox_TextAcceptedEventHandler(const EventArgs& e);
796  bool editbox_TextChangedEventHandler(const EventArgs& e);
797  bool listbox_ListContentsChangedHandler(const EventArgs& e);
798  bool listbox_ListSelectionChangedHandler(const EventArgs& e);
799  bool listbox_SortModeChangedHandler(const EventArgs& e);
800  bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
801  bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
802 
803 
804  /*************************************************************************
805  New Events for Combobox
806  *************************************************************************/
811  virtual void onReadOnlyChanged(WindowEventArgs& e);
812 
813 
818  virtual void onValidationStringChanged(WindowEventArgs& e);
819 
820 
825  virtual void onMaximumTextLengthChanged(WindowEventArgs& e);
826 
827 
832  virtual void onTextInvalidatedEvent(WindowEventArgs& e);
833 
834 
839  virtual void onInvalidEntryAttempted(WindowEventArgs& e);
840 
841 
846  virtual void onCaratMoved(WindowEventArgs& e);
847 
848 
853  virtual void onTextSelectionChanged(WindowEventArgs& e);
854 
855 
860  virtual void onEditboxFullEvent(WindowEventArgs& e);
861 
862 
867  virtual void onTextAcceptedEvent(WindowEventArgs& e);
868 
869 
874  virtual void onListContentsChanged(WindowEventArgs& e);
875 
876 
882  virtual void onListSelectionChanged(WindowEventArgs& e);
883 
884 
889  virtual void onSortModeChanged(WindowEventArgs& e);
890 
891 
897  virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
898 
899 
905  virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
906 
907 
912  virtual void onDropListDisplayed(WindowEventArgs& e);
913 
914 
919  virtual void onDroplistRemoved(WindowEventArgs& e);
920 
921 
926  virtual void onListSelectionAccepted(WindowEventArgs& e);
927 
928 
929  /*************************************************************************
930  Overridden Event handlers
931  *************************************************************************/
932  virtual void onFontChanged(WindowEventArgs& e);
933  virtual void onTextChanged(WindowEventArgs& e);
934  virtual void onActivated(ActivationEventArgs& e);
935 
936 
937  /*************************************************************************
938  Implementation Data
939  *************************************************************************/
941 
942 
943 private:
944  /*************************************************************************
945  Static Properties for this class
946  *************************************************************************/
947  static ComboboxProperties::ReadOnly d_readOnlyProperty;
948  static ComboboxProperties::ValidationString d_validationStringProperty;
949  static ComboboxProperties::CaratIndex d_caratIndexProperty;
950  static ComboboxProperties::EditSelectionStart d_selStartProperty;
951  static ComboboxProperties::EditSelectionLength d_selLengthProperty;
952  static ComboboxProperties::MaxEditTextLength d_maxTextLengthProperty;
953  static ComboboxProperties::SortList d_sortProperty;
954  static ComboboxProperties::ForceVertScrollbar d_forceVertProperty;
955  static ComboboxProperties::ForceHorzScrollbar d_forceHorzProperty;
956  static ComboboxProperties::SingleClickMode d_singleClickOperationProperty;
957 
958  /*************************************************************************
959  Private methods
960  *************************************************************************/
961  void addComboboxProperties(void);
962 };
963 
964 } // End of CEGUI namespace section
965 
966 #if defined(_MSC_VER)
967 # pragma warning(pop)
968 #endif
969 
970 #endif // end of guard _CEGUICombobox_h_