Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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
99  static const String EventCaratMoved;
112  static const String EventEditboxFull;
119  static const String EventTextAccepted;
120 
121  // event names from list box
155 
156  // events we produce / generate ourselves
175 
176  /*************************************************************************
177  Child Widget name suffix constants
178  *************************************************************************/
179  static const String EditboxNameSuffix;
180  static const String DropListNameSuffix;
181  static const String ButtonNameSuffix;
182 
183  // override from Window class
184  bool isHit(const Vector2& position,
185  const bool allow_disabled = false) const;
186 
195  bool getSingleClickEnabled(void) const;
196 
197 
205  bool isDropDownListVisible(void) const;
206 
207 
218  Editbox* getEditbox() const;
219 
230  PushButton* getPushButton() const;
231 
243  ComboDropList* getDropList() const;
244 
245 
246  /*************************************************************************
247  Editbox Accessors
248  *************************************************************************/
256  bool hasInputFocus(void) const;
257 
258 
267  bool isReadOnly(void) const;
268 
269 
286  bool isTextValid(void) const;
287 
288 
300  const String& getValidationString(void) const;
301 
302 
310  size_t getCaratIndex(void) const;
311 
312 
321  size_t getSelectionStartIndex(void) const;
322 
323 
332  size_t getSelectionEndIndex(void) const;
333 
334 
342  size_t getSelectionLength(void) const;
343 
344 
356  size_t getMaxTextLength(void) const;
357 
358 
359  /*************************************************************************
360  List Accessors
361  *************************************************************************/
369  size_t getItemCount(void) const;
370 
371 
380  ListboxItem* getSelectedItem(void) const;
381 
382 
395  ListboxItem* getListboxItemFromIndex(size_t index) const;
396 
397 
410  size_t getItemIndex(const ListboxItem* item) const;
411 
412 
420  bool isSortEnabled(void) const;
421 
422 
435  bool isItemSelected(size_t index) const;
436 
437 
455  ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item);
456 
457 
465  bool isListboxItemInList(const ListboxItem* item) const;
466 
467 
476  bool isVertScrollbarAlwaysShown(void) const;
477 
478 
487  bool isHorzScrollbarAlwaysShown(void) const;
488 
489 
490  /*************************************************************************
491  Combobox Manipulators
492  *************************************************************************/
503  virtual void initialiseComponents(void);
504 
505 
513  void showDropList(void);
514 
515 
523  void hideDropList(void);
524 
525 
537  void setSingleClickEnabled(bool setting);
538 
539 
540  /*************************************************************************
541  Editbox Manipulators
542  *************************************************************************/
554  void setReadOnly(bool setting);
555 
556 
571  void setValidationString(const String& validation_string);
572 
573 
585  void setCaratIndex(size_t carat_pos);
586 
587 
603  void setSelection(size_t start_pos, size_t end_pos);
604 
605 
620  void setMaxTextLength(size_t max_len);
621 
622 
630  void activateEditbox(void);
631 
632 
633  /*************************************************************************
634  List Manipulators
635  *************************************************************************/
642  void resetList(void);
643 
644 
656  void addItem(ListboxItem* item);
657 
658 
676  void insertItem(ListboxItem* item, const ListboxItem* position);
677 
678 
690  void removeItem(const ListboxItem* item);
691 
692 
700  void clearAllSelections(void);
701 
702 
713  void setSortingEnabled(bool setting);
714 
715 
727  void setShowVertScrollbar(bool setting);
728 
729 
741  void setShowHorzScrollbar(bool setting);
742 
743 
763  void setItemSelectState(ListboxItem* item, bool state);
764 
765 
785  void setItemSelectState(size_t item_index, bool state);
786 
787 
800  void handleUpdatedListItemData(void);
801 
802 
803  /*************************************************************************
804  Construction and Destruction
805  *************************************************************************/
810  Combobox(const String& type, const String& name);
811 
812 
817  virtual ~Combobox(void);
818 
819 
820 protected:
821  /*************************************************************************
822  Implementation Methods
823  *************************************************************************/
828  bool button_PressHandler(const EventArgs& e);
829 
830 
835  bool droplist_SelectionAcceptedHandler(const EventArgs& e);
836 
837 
842  bool droplist_HiddenHandler(const EventArgs& e);
843 
844 
849  bool editbox_MouseDownHandler(const EventArgs& e);
850 
851 
862  virtual bool testClassName_impl(const String& class_name) const
863  {
864  if (class_name=="Combobox") return true;
865  return Window::testClassName_impl(class_name);
866  }
867 
873  void itemSelectChangeTextUpdate(const ListboxItem* const item,
874  bool new_state, bool old_state);
875 
876  /*************************************************************************
877  Handlers to relay child widget events so they appear to come from us
878  *************************************************************************/
879  bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
880  bool editbox_ValidationStringChangedHandler(const EventArgs& e);
881  bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
882  bool editbox_TextInvalidatedEventHandler(const EventArgs& e);
883  bool editbox_InvalidEntryAttemptedHandler(const EventArgs& e);
884  bool editbox_CaratMovedHandler(const EventArgs& e);
885  bool editbox_TextSelectionChangedHandler(const EventArgs& e);
886  bool editbox_EditboxFullEventHandler(const EventArgs& e);
887  bool editbox_TextAcceptedEventHandler(const EventArgs& e);
888  bool editbox_TextChangedEventHandler(const EventArgs& e);
889  bool listbox_ListContentsChangedHandler(const EventArgs& e);
890  bool listbox_ListSelectionChangedHandler(const EventArgs& e);
891  bool listbox_SortModeChangedHandler(const EventArgs& e);
892  bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
893  bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
894 
895 
896  /*************************************************************************
897  New Events for Combobox
898  *************************************************************************/
903  virtual void onReadOnlyChanged(WindowEventArgs& e);
904 
905 
910  virtual void onValidationStringChanged(WindowEventArgs& e);
911 
912 
917  virtual void onMaximumTextLengthChanged(WindowEventArgs& e);
918 
919 
924  virtual void onTextInvalidatedEvent(WindowEventArgs& e);
925 
926 
931  virtual void onInvalidEntryAttempted(WindowEventArgs& e);
932 
933 
938  virtual void onCaratMoved(WindowEventArgs& e);
939 
940 
945  virtual void onTextSelectionChanged(WindowEventArgs& e);
946 
947 
952  virtual void onEditboxFullEvent(WindowEventArgs& e);
953 
954 
959  virtual void onTextAcceptedEvent(WindowEventArgs& e);
960 
961 
966  virtual void onListContentsChanged(WindowEventArgs& e);
967 
968 
974  virtual void onListSelectionChanged(WindowEventArgs& e);
975 
976 
981  virtual void onSortModeChanged(WindowEventArgs& e);
982 
983 
989  virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
990 
991 
997  virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
998 
999 
1004  virtual void onDropListDisplayed(WindowEventArgs& e);
1005 
1006 
1011  virtual void onDroplistRemoved(WindowEventArgs& e);
1012 
1013 
1018  virtual void onListSelectionAccepted(WindowEventArgs& e);
1019 
1020 
1021  /*************************************************************************
1022  Overridden Event handlers
1023  *************************************************************************/
1024  virtual void onFontChanged(WindowEventArgs& e);
1025  virtual void onTextChanged(WindowEventArgs& e);
1026  virtual void onActivated(ActivationEventArgs& e);
1027 
1028 
1029  /*************************************************************************
1030  Implementation Data
1031  *************************************************************************/
1033 
1034 
1035 private:
1036  /*************************************************************************
1037  Static Properties for this class
1038  *************************************************************************/
1039  static ComboboxProperties::ReadOnly d_readOnlyProperty;
1040  static ComboboxProperties::ValidationString d_validationStringProperty;
1041  static ComboboxProperties::CaratIndex d_caratIndexProperty;
1042  static ComboboxProperties::EditSelectionStart d_selStartProperty;
1043  static ComboboxProperties::EditSelectionLength d_selLengthProperty;
1044  static ComboboxProperties::MaxEditTextLength d_maxTextLengthProperty;
1045  static ComboboxProperties::SortList d_sortProperty;
1046  static ComboboxProperties::ForceVertScrollbar d_forceVertProperty;
1047  static ComboboxProperties::ForceHorzScrollbar d_forceHorzProperty;
1048  static ComboboxProperties::SingleClickMode d_singleClickOperationProperty;
1049 
1050  /*************************************************************************
1051  Private methods
1052  *************************************************************************/
1053  void addComboboxProperties(void);
1054 };
1055 
1056 } // End of CEGUI namespace section
1057 
1058 #if defined(_MSC_VER)
1059 # pragma warning(pop)
1060 #endif
1061 
1062 #endif // end of guard _CEGUICombobox_h_