Crazy Eddies GUI System  0.6.0
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 "elements/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 
101  virtual bool isHit(const Point& position) const {return false;}
102 
103 
112  bool getSingleClickEnabled(void) const;
113 
114 
122  bool isDropDownListVisible(void) const;
123 
124 
135  Editbox* getEditbox() const;
136 
147  PushButton* getPushButton() const;
148 
160  ComboDropList* getDropList() const;
161 
162 
163  /*************************************************************************
164  Editbox Accessors
165  *************************************************************************/
173  bool hasInputFocus(void) const;
174 
175 
184  bool isReadOnly(void) const;
185 
186 
203  bool isTextValid(void) const;
204 
205 
217  const String& getValidationString(void) const;
218 
219 
227  size_t getCaratIndex(void) const;
228 
229 
238  size_t getSelectionStartIndex(void) const;
239 
240 
249  size_t getSelectionEndIndex(void) const;
250 
251 
259  size_t getSelectionLength(void) const;
260 
261 
273  size_t getMaxTextLength(void) const;
274 
275 
276  /*************************************************************************
277  List Accessors
278  *************************************************************************/
286  size_t getItemCount(void) const;
287 
288 
297  ListboxItem* getSelectedItem(void) const;
298 
299 
312  ListboxItem* getListboxItemFromIndex(size_t index) const;
313 
314 
327  size_t getItemIndex(const ListboxItem* item) const;
328 
329 
337  bool isSortEnabled(void) const;
338 
339 
352  bool isItemSelected(size_t index) const;
353 
354 
372  ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item);
373 
374 
382  bool isListboxItemInList(const ListboxItem* item) const;
383 
384 
393  bool isVertScrollbarAlwaysShown(void) const;
394 
395 
404  bool isHorzScrollbarAlwaysShown(void) const;
405 
406 
407  /*************************************************************************
408  Combobox Manipulators
409  *************************************************************************/
420  virtual void initialiseComponents(void);
421 
422 
430  void showDropList(void);
431 
432 
440  void hideDropList(void);
441 
442 
454  void setSingleClickEnabled(bool setting);
455 
456 
457  /*************************************************************************
458  Editbox Manipulators
459  *************************************************************************/
471  void setReadOnly(bool setting);
472 
473 
488  void setValidationString(const String& validation_string);
489 
490 
502  void setCaratIndex(size_t carat_pos);
503 
504 
520  void setSelection(size_t start_pos, size_t end_pos);
521 
522 
537  void setMaxTextLength(size_t max_len);
538 
539 
547  void activateEditbox(void);
548 
549 
550  /*************************************************************************
551  List Manipulators
552  *************************************************************************/
559  void resetList(void);
560 
561 
573  void addItem(ListboxItem* item);
574 
575 
593  void insertItem(ListboxItem* item, const ListboxItem* position);
594 
595 
607  void removeItem(const ListboxItem* item);
608 
609 
617  void clearAllSelections(void);
618 
619 
630  void setSortingEnabled(bool setting);
631 
632 
644  void setShowVertScrollbar(bool setting);
645 
646 
658  void setShowHorzScrollbar(bool setting);
659 
660 
680  void setItemSelectState(ListboxItem* item, bool state);
681 
682 
702  void setItemSelectState(size_t item_index, bool state);
703 
704 
717  void handleUpdatedListItemData(void);
718 
719 
720  /*************************************************************************
721  Construction and Destruction
722  *************************************************************************/
727  Combobox(const String& type, const String& name);
728 
729 
734  virtual ~Combobox(void);
735 
736 
737 protected:
738  /*************************************************************************
739  Implementation Methods
740  *************************************************************************/
745  bool button_PressHandler(const EventArgs& e);
746 
747 
752  bool droplist_SelectionAcceptedHandler(const EventArgs& e);
753 
754 
759  bool droplist_HiddenHandler(const EventArgs& e);
760 
761 
766  bool editbox_MouseDownHandler(const EventArgs& e);
767 
768 
779  virtual bool testClassName_impl(const String& class_name) const
780  {
781  if (class_name=="Combobox") return true;
782  return Window::testClassName_impl(class_name);
783  }
784 
785 
786  /*************************************************************************
787  Handlers to relay child widget events so they appear to come from us
788  *************************************************************************/
789  bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
790  bool editbox_ValidationStringChangedHandler(const EventArgs& e);
791  bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
792  bool editbox_TextInvalidatedEventHandler(const EventArgs& e);
793  bool editbox_InvalidEntryAttemptedHandler(const EventArgs& e);
794  bool editbox_CaratMovedHandler(const EventArgs& e);
795  bool editbox_TextSelectionChangedHandler(const EventArgs& e);
796  bool editbox_EditboxFullEventHandler(const EventArgs& e);
797  bool editbox_TextAcceptedEventHandler(const EventArgs& e);
798  bool editbox_TextChangedEventHandler(const EventArgs& e);
799  bool listbox_ListContentsChangedHandler(const EventArgs& e);
800  bool listbox_ListSelectionChangedHandler(const EventArgs& e);
801  bool listbox_SortModeChangedHandler(const EventArgs& e);
802  bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
803  bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
804 
805 
806  /*************************************************************************
807  New Events for Combobox
808  *************************************************************************/
813  virtual void onReadOnlyChanged(WindowEventArgs& e);
814 
815 
820  virtual void onValidationStringChanged(WindowEventArgs& e);
821 
822 
827  virtual void onMaximumTextLengthChanged(WindowEventArgs& e);
828 
829 
834  virtual void onTextInvalidatedEvent(WindowEventArgs& e);
835 
836 
841  virtual void onInvalidEntryAttempted(WindowEventArgs& e);
842 
843 
848  virtual void onCaratMoved(WindowEventArgs& e);
849 
850 
855  virtual void onTextSelectionChanged(WindowEventArgs& e);
856 
857 
862  virtual void onEditboxFullEvent(WindowEventArgs& e);
863 
864 
869  virtual void onTextAcceptedEvent(WindowEventArgs& e);
870 
871 
876  virtual void onListContentsChanged(WindowEventArgs& e);
877 
878 
884  virtual void onListSelectionChanged(WindowEventArgs& e);
885 
886 
891  virtual void onSortModeChanged(WindowEventArgs& e);
892 
893 
899  virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
900 
901 
907  virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
908 
909 
914  virtual void onDropListDisplayed(WindowEventArgs& e);
915 
916 
921  virtual void onDroplistRemoved(WindowEventArgs& e);
922 
923 
928  virtual void onListSelectionAccepted(WindowEventArgs& e);
929 
930 
931  /*************************************************************************
932  Overridden Event handlers
933  *************************************************************************/
934  virtual void onFontChanged(WindowEventArgs& e);
935  virtual void onTextChanged(WindowEventArgs& e);
936  virtual void onActivated(ActivationEventArgs& e);
937 
938 
939  /*************************************************************************
940  Implementation Data
941  *************************************************************************/
943 
944 
945 private:
946  /*************************************************************************
947  Static Properties for this class
948  *************************************************************************/
949  static ComboboxProperties::ReadOnly d_readOnlyProperty;
950  static ComboboxProperties::ValidationString d_validationStringProperty;
951  static ComboboxProperties::CaratIndex d_caratIndexProperty;
952  static ComboboxProperties::EditSelectionStart d_selStartProperty;
953  static ComboboxProperties::EditSelectionLength d_selLengthProperty;
954  static ComboboxProperties::MaxEditTextLength d_maxTextLengthProperty;
955  static ComboboxProperties::SortList d_sortProperty;
956  static ComboboxProperties::ForceVertScrollbar d_forceVertProperty;
957  static ComboboxProperties::ForceHorzScrollbar d_forceHorzProperty;
958  static ComboboxProperties::SingleClickMode d_singleClickOperationProperty;
959 
960  /*************************************************************************
961  Private methods
962  *************************************************************************/
963  void addComboboxProperties(void);
964 };
965 
966 } // End of CEGUI namespace section
967 
968 #if defined(_MSC_VER)
969 # pragma warning(pop)
970 #endif
971 
972 #endif // end of guard _CEGUICombobox_h_