CEGUICombobox.h

00001 /***********************************************************************
00002         filename:       CEGUICombobox.h
00003         created:        13/4/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to base class for Combobox widget
00007 *************************************************************************/
00008 /***************************************************************************
00009  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00010  *
00011  *   Permission is hereby granted, free of charge, to any person obtaining
00012  *   a copy of this software and associated documentation files (the
00013  *   "Software"), to deal in the Software without restriction, including
00014  *   without limitation the rights to use, copy, modify, merge, publish,
00015  *   distribute, sublicense, and/or sell copies of the Software, and to
00016  *   permit persons to whom the Software is furnished to do so, subject to
00017  *   the following conditions:
00018  *
00019  *   The above copyright notice and this permission notice shall be
00020  *   included in all copies or substantial portions of the Software.
00021  *
00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00028  *   OTHER DEALINGS IN THE SOFTWARE.
00029  ***************************************************************************/
00030 #ifndef _CEGUICombobox_h_
00031 #define _CEGUICombobox_h_
00032 
00033 #include "CEGUIBase.h"
00034 #include "CEGUIWindow.h"
00035 #include "elements/CEGUIComboboxProperties.h"
00036 
00037 
00038 #if defined(_MSC_VER)
00039 #       pragma warning(push)
00040 #       pragma warning(disable : 4251)
00041 #endif
00042 
00043 
00044 // Start of CEGUI namespace section
00045 namespace CEGUI
00046 {
00047 
00052 class CEGUIEXPORT Combobox : public Window
00053 {
00054 public:
00055         static const String EventNamespace;                             
00056     static const String WidgetTypeName;             
00057 
00058         /*************************************************************************
00059                 Constants
00060         *************************************************************************/
00061         // event names from edit box
00062         static const String EventReadOnlyModeChanged;                   
00063         static const String EventValidationStringChanged;               
00064         static const String EventMaximumTextLengthChanged;      
00065         static const String EventTextInvalidated;                               
00066         static const String EventInvalidEntryAttempted;         
00067         static const String EventCaratMoved;                                    
00068         static const String EventTextSelectionChanged;          
00069         static const String EventEditboxFull;                                   
00070         static const String EventTextAccepted;                          
00071 
00072         // event names from list box
00073         static const String EventListContentsChanged;                   
00074         static const String EventListSelectionChanged;          
00075         static const String EventSortModeChanged;                               
00076         static const String EventVertScrollbarModeChanged;      
00077         static const String EventHorzScrollbarModeChanged;      
00078 
00079         // events we produce / generate ourselves
00080         static const String EventDropListDisplayed;                     
00081         static const String EventDropListRemoved;                               
00082         static const String EventListSelectionAccepted;         
00083 
00084     /*************************************************************************
00085         Child Widget name suffix constants
00086     *************************************************************************/
00087     static const String EditboxNameSuffix;          
00088     static const String DropListNameSuffix;   
00089     static const String ButtonNameSuffix;           
00090 
00101         virtual bool    isHit(const Point& position) const              {return false;}
00102 
00103 
00112         bool    getSingleClickEnabled(void) const;
00113 
00114 
00122         bool    isDropDownListVisible(void) const;
00123 
00124 
00135     Editbox* getEditbox() const;
00136 
00147     PushButton* getPushButton() const;
00148 
00160     ComboDropList* getDropList() const;
00161 
00162 
00163         /*************************************************************************
00164                 Editbox Accessors
00165         *************************************************************************/
00173         bool    hasInputFocus(void) const;
00174 
00175 
00184         bool    isReadOnly(void) const;
00185 
00186 
00203         bool    isTextValid(void) const;
00204 
00205 
00217         const String&   getValidationString(void) const;
00218 
00219 
00227         size_t  getCaratIndex(void) const;
00228 
00229 
00238         size_t  getSelectionStartIndex(void) const;
00239 
00240 
00249         size_t  getSelectionEndIndex(void) const;
00250 
00251         
00259         size_t  getSelectionLength(void) const;
00260 
00261 
00273         size_t  getMaxTextLength(void) const;
00274 
00275 
00276         /*************************************************************************
00277                 List Accessors
00278         *************************************************************************/
00286         size_t  getItemCount(void) const;
00287 
00288         
00297         ListboxItem*    getSelectedItem(void) const;
00298 
00299 
00312         ListboxItem*    getListboxItemFromIndex(size_t index) const;
00313 
00314 
00327         size_t  getItemIndex(const ListboxItem* item) const;
00328 
00329 
00337         bool    isSortEnabled(void) const;
00338 
00339 
00352         bool    isItemSelected(size_t index) const;
00353 
00354 
00372         ListboxItem*    findItemWithText(const String& text, const ListboxItem* start_item);
00373 
00374 
00382         bool    isListboxItemInList(const ListboxItem* item) const;
00383 
00384 
00393         bool    isVertScrollbarAlwaysShown(void) const;
00394 
00395 
00404         bool    isHorzScrollbarAlwaysShown(void) const;
00405 
00406 
00407         /*************************************************************************
00408                 Combobox Manipulators
00409         *************************************************************************/
00420         virtual void    initialiseComponents(void);
00421 
00422 
00430         void    showDropList(void);
00431 
00432 
00440         void    hideDropList(void);
00441 
00442 
00454         void    setSingleClickEnabled(bool setting);
00455 
00456 
00457         /*************************************************************************
00458                 Editbox Manipulators
00459         *************************************************************************/
00471         void    setReadOnly(bool setting);
00472 
00473 
00488         void    setValidationString(const String& validation_string);
00489 
00490 
00502         void    setCaratIndex(size_t carat_pos);
00503 
00504 
00520         void    setSelection(size_t start_pos, size_t end_pos);
00521         
00522 
00537         void    setMaxTextLength(size_t max_len);
00538 
00539 
00547         void    activateEditbox(void);
00548 
00549 
00550         /*************************************************************************
00551                 List Manipulators
00552         *************************************************************************/
00559         void    resetList(void);
00560 
00561 
00573         void    addItem(ListboxItem* item);
00574 
00575 
00593         void    insertItem(ListboxItem* item, const ListboxItem* position);
00594 
00595 
00607         void    removeItem(const ListboxItem* item);
00608 
00609 
00617         void    clearAllSelections(void);
00618 
00619 
00630         void    setSortingEnabled(bool setting);
00631 
00632         
00644         void    setShowVertScrollbar(bool setting);
00645 
00646 
00658         void    setShowHorzScrollbar(bool setting);
00659 
00660 
00680         void    setItemSelectState(ListboxItem* item, bool state);
00681 
00682 
00702         void    setItemSelectState(size_t item_index, bool state);
00703 
00704 
00717         void    handleUpdatedListItemData(void);
00718 
00719 
00720         /*************************************************************************
00721                 Construction and Destruction
00722         *************************************************************************/
00727         Combobox(const String& type, const String& name);
00728 
00729 
00734         virtual ~Combobox(void);
00735 
00736 
00737 protected:
00738         /*************************************************************************
00739                 Implementation Methods
00740         *************************************************************************/
00745         bool    button_PressHandler(const EventArgs& e);
00746 
00747 
00752         bool    droplist_SelectionAcceptedHandler(const EventArgs& e);
00753 
00754 
00759         bool    droplist_HiddenHandler(const EventArgs& e);
00760 
00761 
00766         bool    editbox_MouseDownHandler(const EventArgs& e);
00767 
00768 
00779         virtual bool    testClassName_impl(const String& class_name) const
00780         {
00781                 if (class_name=="Combobox")     return true;
00782                 return Window::testClassName_impl(class_name);
00783         }
00784 
00785 
00786         /*************************************************************************
00787                 Handlers to relay child widget events so they appear to come from us
00788         *************************************************************************/
00789         bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
00790         bool editbox_ValidationStringChangedHandler(const EventArgs& e);
00791         bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
00792         bool editbox_TextInvalidatedEventHandler(const EventArgs& e);
00793         bool editbox_InvalidEntryAttemptedHandler(const EventArgs& e);
00794         bool editbox_CaratMovedHandler(const EventArgs& e);
00795         bool editbox_TextSelectionChangedHandler(const EventArgs& e);
00796         bool editbox_EditboxFullEventHandler(const EventArgs& e);
00797         bool editbox_TextAcceptedEventHandler(const EventArgs& e);
00798         bool editbox_TextChangedEventHandler(const EventArgs& e);
00799         bool listbox_ListContentsChangedHandler(const EventArgs& e);
00800         bool listbox_ListSelectionChangedHandler(const EventArgs& e);
00801         bool listbox_SortModeChangedHandler(const EventArgs& e);
00802         bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
00803         bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
00804 
00805         
00806         /*************************************************************************
00807                 New Events for Combobox
00808         *************************************************************************/
00813         virtual void    onReadOnlyChanged(WindowEventArgs& e);
00814 
00815 
00820         virtual void    onValidationStringChanged(WindowEventArgs& e);
00821 
00822 
00827         virtual void    onMaximumTextLengthChanged(WindowEventArgs& e);
00828 
00829 
00834         virtual void    onTextInvalidatedEvent(WindowEventArgs& e);
00835 
00836 
00841         virtual void    onInvalidEntryAttempted(WindowEventArgs& e);
00842 
00843 
00848         virtual void    onCaratMoved(WindowEventArgs& e);
00849 
00850 
00855         virtual void    onTextSelectionChanged(WindowEventArgs& e);
00856 
00857 
00862         virtual void    onEditboxFullEvent(WindowEventArgs& e);
00863 
00864 
00869         virtual void    onTextAcceptedEvent(WindowEventArgs& e);
00870 
00871 
00876         virtual void    onListContentsChanged(WindowEventArgs& e);
00877 
00878 
00884         virtual void    onListSelectionChanged(WindowEventArgs& e);
00885 
00886 
00891         virtual void    onSortModeChanged(WindowEventArgs& e);
00892 
00893 
00899         virtual void    onVertScrollbarModeChanged(WindowEventArgs& e);
00900 
00901 
00907         virtual void    onHorzScrollbarModeChanged(WindowEventArgs& e);
00908 
00909 
00914         virtual void    onDropListDisplayed(WindowEventArgs& e);
00915 
00916 
00921         virtual void    onDroplistRemoved(WindowEventArgs& e);
00922 
00923 
00928         virtual void    onListSelectionAccepted(WindowEventArgs& e);
00929 
00930 
00931         /*************************************************************************
00932                 Overridden Event handlers
00933         *************************************************************************/
00934         virtual void    onFontChanged(WindowEventArgs& e);
00935         virtual void    onTextChanged(WindowEventArgs& e);
00936         virtual void    onActivated(ActivationEventArgs& e);
00937 
00938 
00939         /*************************************************************************
00940                 Implementation Data
00941         *************************************************************************/
00942         bool                    d_singleClickOperation;         
00943 
00944 
00945 private:
00946         /*************************************************************************
00947                 Static Properties for this class
00948         *************************************************************************/
00949         static ComboboxProperties::ReadOnly                                             d_readOnlyProperty;
00950         static ComboboxProperties::ValidationString                             d_validationStringProperty;
00951         static ComboboxProperties::CaratIndex                                   d_caratIndexProperty;
00952         static ComboboxProperties::EditSelectionStart                   d_selStartProperty;
00953         static ComboboxProperties::EditSelectionLength                  d_selLengthProperty;
00954         static ComboboxProperties::MaxEditTextLength                    d_maxTextLengthProperty;
00955         static ComboboxProperties::SortList                                             d_sortProperty;
00956         static ComboboxProperties::ForceVertScrollbar                   d_forceVertProperty;
00957         static ComboboxProperties::ForceHorzScrollbar                   d_forceHorzProperty;
00958         static ComboboxProperties::SingleClickMode                              d_singleClickOperationProperty;
00959 
00960         /*************************************************************************
00961                 Private methods
00962         *************************************************************************/
00963         void    addComboboxProperties(void);
00964 };
00965 
00966 } // End of  CEGUI namespace section
00967 
00968 #if defined(_MSC_VER)
00969 #       pragma warning(pop)
00970 #endif
00971 
00972 #endif  // end of guard _CEGUICombobox_h_

Generated on Sat Jun 28 14:35:44 2008 for Crazy Eddies GUI System by  doxygen 1.5.4