Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 13/4/2004 00003 author: Paul D Turner 00004 00005 purpose: Interface to base class for Combobox widget 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUICombobox_h_ 00030 #define _CEGUICombobox_h_ 00031 00032 #include "CEGUI/Base.h" 00033 #include "CEGUI/Window.h" 00034 #include "CEGUI/RegexMatcher.h" 00035 00036 #if defined(_MSC_VER) 00037 # pragma warning(push) 00038 # pragma warning(disable : 4251) 00039 #endif 00040 00041 00042 // Start of CEGUI namespace section 00043 namespace CEGUI 00044 { 00045 00050 class CEGUIEXPORT Combobox : public Window 00051 { 00052 public: 00053 typedef RegexMatcher::MatchState MatchState; 00054 00055 static const String EventNamespace; 00056 static const String WidgetTypeName; 00057 00058 /************************************************************************* 00059 Constants 00060 *************************************************************************/ 00061 // event names from edit box 00067 static const String EventReadOnlyModeChanged; 00073 static const String EventValidationStringChanged; 00079 static const String EventMaximumTextLengthChanged; 00093 static const String EventTextValidityChanged; 00099 static const String EventCaretMoved; 00105 static const String EventTextSelectionChanged; 00112 static const String EventEditboxFull; 00119 static const String EventTextAccepted; 00120 00121 // event names from list box 00127 static const String EventListContentsChanged; 00138 static const String EventListSelectionChanged; 00144 static const String EventSortModeChanged; 00151 static const String EventVertScrollbarModeChanged; 00158 static const String EventHorzScrollbarModeChanged; 00159 00160 // events we produce / generate ourselves 00166 static const String EventDropListDisplayed; 00172 static const String EventDropListRemoved; 00178 static const String EventListSelectionAccepted; 00179 00180 /************************************************************************* 00181 Child Widget name constants 00182 *************************************************************************/ 00183 static const String EditboxName; 00184 static const String DropListName; 00185 static const String ButtonName; 00186 00187 // override from Window class 00188 bool isHit(const Vector2f& position, 00189 const bool allow_disabled = false) const; 00190 00199 bool getSingleClickEnabled(void) const; 00200 00201 00209 bool isDropDownListVisible(void) const; 00210 00211 00222 Editbox* getEditbox() const; 00223 00234 PushButton* getPushButton() const; 00235 00247 ComboDropList* getDropList() const; 00248 00250 bool getAutoSizeListHeightToContent() const; 00251 00253 bool getAutoSizeListWidthToContent() const; 00254 00255 /************************************************************************* 00256 Editbox Accessors 00257 *************************************************************************/ 00265 bool hasInputFocus(void) const; 00266 00267 00276 bool isReadOnly(void) const; 00277 00278 00293 MatchState getTextMatchState() const; 00294 00295 00307 const String& getValidationString(void) const; 00308 00309 00317 size_t getCaretIndex(void) const; 00318 00319 00328 size_t getSelectionStartIndex(void) const; 00329 00330 00339 size_t getSelectionEndIndex(void) const; 00340 00341 00349 size_t getSelectionLength(void) const; 00350 00351 00363 size_t getMaxTextLength(void) const; 00364 00365 00366 /************************************************************************* 00367 List Accessors 00368 *************************************************************************/ 00376 size_t getItemCount(void) const; 00377 00378 00387 ListboxItem* getSelectedItem(void) const; 00388 00389 00402 ListboxItem* getListboxItemFromIndex(size_t index) const; 00403 00404 00417 size_t getItemIndex(const ListboxItem* item) const; 00418 00419 00427 bool isSortEnabled(void) const; 00428 00429 00442 bool isItemSelected(size_t index) const; 00443 00444 00462 ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item); 00463 00464 00472 bool isListboxItemInList(const ListboxItem* item) const; 00473 00474 00483 bool isVertScrollbarAlwaysShown(void) const; 00484 00485 00494 bool isHorzScrollbarAlwaysShown(void) const; 00495 00496 00497 /************************************************************************* 00498 Combobox Manipulators 00499 *************************************************************************/ 00510 virtual void initialiseComponents(void); 00511 00512 00520 void showDropList(void); 00521 00522 00530 void hideDropList(void); 00531 00532 00544 void setSingleClickEnabled(bool setting); 00545 00547 void selectListItemWithEditboxText(); 00548 00554 void setAutoSizeListHeightToContent(bool auto_size); 00555 00561 void setAutoSizeListWidthToContent(bool auto_size); 00562 00564 void updateAutoSizedDropList(); 00565 00566 /************************************************************************* 00567 Editbox Manipulators 00568 *************************************************************************/ 00580 void setReadOnly(bool setting); 00581 00582 00597 void setValidationString(const String& validation_string); 00598 00599 00611 void setCaretIndex(size_t caret_pos); 00612 00613 00629 void setSelection(size_t start_pos, size_t end_pos); 00641 void setSelectionStart(size_t start_pos); 00642 00653 void setSelectionLength(size_t length); 00654 00669 void setMaxTextLength(size_t max_len); 00670 00671 00679 void activateEditbox(void); 00680 00681 00682 /************************************************************************* 00683 List Manipulators 00684 *************************************************************************/ 00691 void resetList(void); 00692 00693 00705 void addItem(ListboxItem* item); 00706 00707 00725 void insertItem(ListboxItem* item, const ListboxItem* position); 00726 00727 00739 void removeItem(const ListboxItem* item); 00740 00741 00749 void clearAllSelections(void); 00750 00751 00762 void setSortingEnabled(bool setting); 00763 00764 00776 void setShowVertScrollbar(bool setting); 00777 00778 00790 void setShowHorzScrollbar(bool setting); 00791 00792 00812 void setItemSelectState(ListboxItem* item, bool state); 00813 00814 00834 void setItemSelectState(size_t item_index, bool state); 00835 00836 00849 void handleUpdatedListItemData(void); 00850 00851 00852 /************************************************************************* 00853 Construction and Destruction 00854 *************************************************************************/ 00859 Combobox(const String& type, const String& name); 00860 00861 00866 virtual ~Combobox(void); 00867 00868 00869 protected: 00870 /************************************************************************* 00871 Implementation Methods 00872 *************************************************************************/ 00877 bool button_PressHandler(const EventArgs& e); 00878 00879 00884 bool droplist_SelectionAcceptedHandler(const EventArgs& e); 00885 00886 00891 bool droplist_HiddenHandler(const EventArgs& e); 00892 00893 00898 bool editbox_MouseDownHandler(const EventArgs& e); 00899 00905 void itemSelectChangeTextUpdate(const ListboxItem* const item, 00906 bool new_state, bool old_state); 00907 00908 /************************************************************************* 00909 Handlers to relay child widget events so they appear to come from us 00910 *************************************************************************/ 00911 bool editbox_ReadOnlyChangedHandler(const EventArgs& e); 00912 bool editbox_ValidationStringChangedHandler(const EventArgs& e); 00913 bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e); 00914 bool editbox_TextValidityChangedHandler(const EventArgs& e); 00915 bool editbox_CaretMovedHandler(const EventArgs& e); 00916 bool editbox_TextSelectionChangedHandler(const EventArgs& e); 00917 bool editbox_EditboxFullEventHandler(const EventArgs& e); 00918 bool editbox_TextAcceptedEventHandler(const EventArgs& e); 00919 bool editbox_TextChangedEventHandler(const EventArgs& e); 00920 bool listbox_ListContentsChangedHandler(const EventArgs& e); 00921 bool listbox_ListSelectionChangedHandler(const EventArgs& e); 00922 bool listbox_SortModeChangedHandler(const EventArgs& e); 00923 bool listbox_VertScrollModeChangedHandler(const EventArgs& e); 00924 bool listbox_HorzScrollModeChangedHandler(const EventArgs& e); 00925 00926 00927 /************************************************************************* 00928 New Events for Combobox 00929 *************************************************************************/ 00934 virtual void onReadOnlyChanged(WindowEventArgs& e); 00935 00936 00941 virtual void onValidationStringChanged(WindowEventArgs& e); 00942 00943 00948 virtual void onMaximumTextLengthChanged(WindowEventArgs& e); 00949 00950 00956 virtual void onTextValidityChanged(RegexMatchStateEventArgs& e); 00957 00958 00963 virtual void onCaretMoved(WindowEventArgs& e); 00964 00965 00970 virtual void onTextSelectionChanged(WindowEventArgs& e); 00971 00972 00977 virtual void onEditboxFullEvent(WindowEventArgs& e); 00978 00979 00984 virtual void onTextAcceptedEvent(WindowEventArgs& e); 00985 00986 00991 virtual void onListContentsChanged(WindowEventArgs& e); 00992 00993 00999 virtual void onListSelectionChanged(WindowEventArgs& e); 01000 01001 01006 virtual void onSortModeChanged(WindowEventArgs& e); 01007 01008 01014 virtual void onVertScrollbarModeChanged(WindowEventArgs& e); 01015 01016 01022 virtual void onHorzScrollbarModeChanged(WindowEventArgs& e); 01023 01024 01029 virtual void onDropListDisplayed(WindowEventArgs& e); 01030 01031 01036 virtual void onDroplistRemoved(WindowEventArgs& e); 01037 01038 01043 virtual void onListSelectionAccepted(WindowEventArgs& e); 01044 01045 01046 /************************************************************************* 01047 Overridden Event handlers 01048 *************************************************************************/ 01049 virtual void onFontChanged(WindowEventArgs& e); 01050 virtual void onTextChanged(WindowEventArgs& e); 01051 virtual void onActivated(ActivationEventArgs& e); 01052 void onSized(ElementEventArgs& e); 01053 01054 01055 /************************************************************************* 01056 Implementation Data 01057 *************************************************************************/ 01058 bool d_singleClickOperation; 01059 bool d_autoSizeHeight; 01060 bool d_autoSizeWidth; 01061 01062 private: 01063 /************************************************************************* 01064 Private methods 01065 *************************************************************************/ 01066 void addComboboxProperties(void); 01067 }; 01068 01069 } // End of CEGUI namespace section 01070 01071 #if defined(_MSC_VER) 01072 # pragma warning(pop) 01073 #endif 01074 01075 #endif // end of guard _CEGUICombobox_h_