# 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     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00011
    00012     This library is free software; you can redistribute it and/or
    00013     modify it under the terms of the GNU Lesser General Public
    00014     License as published by the Free Software Foundation; either
    00015     version 2.1 of the License, or (at your option) any later version.
    00016
    00017     This library is distributed in the hope that it will be useful,
    00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020     Lesser General Public License for more details.
    00021
    00022     You should have received a copy of the GNU Lesser General Public
    00023     License along with this library; if not, write to the Free Software
    00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025 *************************************************************************/
    00026 #ifndef _CEGUICombobox_h_
    00027 #define _CEGUICombobox_h_
    00028
    00029 #include "CEGUIBase.h"
    00030 #include "CEGUIWindow.h"
    00031 #include "elements/CEGUIComboboxProperties.h"
    00032
    00033
    00034 #if defined(_MSC_VER)
    00035 #       pragma warning(push)
    00036 #       pragma warning(disable : 4251)
    00037 #endif
    00038
    00039
    00040 // Start of CEGUI namespace section
    00041 namespace CEGUI
    00042 {
    00043
    00048 class CEGUIEXPORT Combobox : public Window
    00049 {
    00050 public:
    00051         static const String EventNamespace;
    00052
    00053         /*************************************************************************
    00054                 Constants
    00055         *************************************************************************/
    00056         // event names from edit box
    00057         static const String EventReadOnlyModeChanged;
    00058         static const String EventValidationStringChanged;
    00059         static const String EventMaximumTextLengthChanged;
    00060         static const String EventTextInvalidated;
    00061         static const String EventInvalidEntryAttempted;
    00062         static const String EventCaratMoved;
    00063         static const String EventTextSelectionChanged;
    00064         static const String EventEditboxFull;
    00065         static const String EventTextAccepted;
    00066
    00067         // event names from list box
    00068         static const String EventListContentsChanged;
    00069         static const String EventListSelectionChanged;
    00070         static const String EventSortModeChanged;
    00071         static const String EventVertScrollbarModeChanged;
    00072         static const String EventHorzScrollbarModeChanged;
    00073
    00074         // events we produce / generate ourselves
    00075         static const String EventDropListDisplayed;
    00076         static const String EventDropListRemoved;
    00077         static const String EventListSelectionAccepted;
    00078
    00079
    00090         virtual bool    isHit(const Point& position) const              {return false;}
    00091
    00092
    00101         bool    getSingleClickEnabled(void) const;
    00102
    00103
    00111         bool    isDropDownListVisible(void) const;
    00112
    00113
    00114         /*************************************************************************
    00115                 Editbox Accessors
    00116         *************************************************************************/
    00124         bool    hasInputFocus(void) const;
    00125
    00126
    00135         bool    isReadOnly(void) const;
    00136
    00137
    00154         bool    isTextValid(void) const;
    00155
    00156
    00168         const String&   getValidationString(void) const;
    00169
    00170
    00178         size_t  getCaratIndex(void) const;
    00179
    00180
    00189         size_t  getSelectionStartIndex(void) const;
    00190
    00191
    00200         size_t  getSelectionEndIndex(void) const;
    00201
    00202
    00210         size_t  getSelectionLength(void) const;
    00211
    00212
    00224         size_t  getMaxTextLength(void) const;
    00225
    00226
    00235         colour  getNormalTextColour(void) const;
    00236
    00237
    00246         colour  getSelectedTextColour(void) const;
    00247
    00248
    00257         colour  getNormalSelectBrushColour(void) const;
    00258
    00259
    00268         colour  getInactiveSelectBrushColour(void) const;
    00269
    00270
    00271         /*************************************************************************
    00272                 List Accessors
    00273         *************************************************************************/
    00281         size_t  getItemCount(void) const;
    00282
    00283
    00292         ListboxItem*    getSelectedItem(void) const;
    00293
    00294
    00307         ListboxItem*    getListboxItemFromIndex(size_t index) const;
    00308
    00309
    00322         size_t  getItemIndex(const ListboxItem* item) const;
    00323
    00324
    00332         bool    isSortEnabled(void) const;
    00333
    00334
    00347         bool    isItemSelected(size_t index) const;
    00348
    00349
    00367         ListboxItem*    findItemWithText(const String& text, const ListboxItem* start_item);
    00368
    00369
    00377         bool    isListboxItemInList(const ListboxItem* item) const;
    00378
    00379
    00388         bool    isVertScrollbarAlwaysShown(void) const;
    00389
    00390
    00399         bool    isHorzScrollbarAlwaysShown(void) const;
    00400
    00401
    00402         /*************************************************************************
    00403                 Combobox Manipulators
    00404         *************************************************************************/
    00415         virtual void    initialise(void);
    00416
    00417
    00425         void    showDropList(void);
    00426
    00427
    00435         void    hideDropList(void);
    00436
    00437
    00449         void    setSingleClickEnabled(bool setting);
    00450
    00451
    00452         /*************************************************************************
    00453                 Editbox Manipulators
    00454         *************************************************************************/
    00466         void    setReadOnly(bool setting);
    00467
    00468
    00483         void    setValidationString(const String& validation_string);
    00484
    00485
    00497         void    setCaratIndex(size_t carat_pos);
    00498
    00499
    00515         void    setSelection(size_t start_pos, size_t end_pos);
    00516
    00517
    00532         void    setMaxTextLength(size_t max_len);
    00533
    00534
    00545         void    setNormalTextColour(colour col);
    00546
    00547
    00556         void    setSelectedTextColour(colour col);
    00557
    00558
    00570         void    setNormalSelectBrushColour(colour col);
    00571
    00572
    00584         void    setInactiveSelectBrushColour(colour col);
    00585
    00586
    00594         void    activateEditbox(void);
    00595
    00596
    00597         /*************************************************************************
    00598                 List Manipulators
    00599         *************************************************************************/
    00606         void    resetList(void);
    00607
    00608
    00620         void    addItem(ListboxItem* item);
    00621
    00622
    00640         void    insertItem(ListboxItem* item, const ListboxItem* position);
    00641
    00642
    00654         void    removeItem(const ListboxItem* item);
    00655
    00656
    00664         void    clearAllSelections(void);
    00665
    00666
    00677         void    setSortingEnabled(bool setting);
    00678
    00679
    00691         void    setShowVertScrollbar(bool setting);
    00692
    00693
    00705         void    setShowHorzScrollbar(bool setting);
    00706
    00707
    00727         void    setItemSelectState(ListboxItem* item, bool state);
    00728
    00729
    00749         void    setItemSelectState(size_t item_index, bool state);
    00750
    00751
    00764         void    handleUpdatedListItemData(void);
    00765
    00766
    00767         /*************************************************************************
    00768                 Construction and Destruction
    00769         *************************************************************************/
    00774         Combobox(const String& type, const String& name);
    00775
    00776
    00781         virtual ~Combobox(void);
    00782
    00783
    00784 protected:
    00785         /*************************************************************************
    00786                 Implementation Methods
    00787         *************************************************************************/
    00792         void    addComboboxEvents(void);
    00793
    00794
    00803         virtual Editbox*        createEditbox(const String& name) const         = 0;
    00804
    00805
    00814         virtual PushButton*     createPushButton(const String& name) const      = 0;
    00815
    00816
    00825         virtual ComboDropList*  createDropList(const String& name) const        = 0;
    00826
    00827
    00832         bool    button_PressHandler(const EventArgs& e);
    00833
    00834
    00839         bool    droplist_SelectionAcceptedHandler(const EventArgs& e);
    00840
    00841
    00846         bool    droplist_HiddenHandler(const EventArgs& e);
    00847
    00848
    00853         bool    editbox_MouseDownHandler(const EventArgs& e);
    00854
    00855
    00866         virtual bool    testClassName_impl(const String& class_name) const
    00867         {
    00868                 if (class_name==(const utf8*)"Combobox")        return true;
    00869                 return Window::testClassName_impl(class_name);
    00870         }
    00871
    00872
    00873         /*************************************************************************
    00874                 Handlers to relay child widget events so they appear to come from us
    00875         *************************************************************************/
    00876         bool editbox_ReadOnlyChangedHandler(const EventArgs& e);
    00877         bool editbox_ValidationStringChangedHandler(const EventArgs& e);
    00878         bool editbox_MaximumTextLengthChangedHandler(const EventArgs& e);
    00879         bool editbox_TextInvalidatedEventHandler(const EventArgs& e);
    00880         bool editbox_InvalidEntryAttemptedHandler(const EventArgs& e);
    00881         bool editbox_CaratMovedHandler(const EventArgs& e);
    00882         bool editbox_TextSelectionChangedHandler(const EventArgs& e);
    00883         bool editbox_EditboxFullEventHandler(const EventArgs& e);
    00884         bool editbox_TextAcceptedEventHandler(const EventArgs& e);
    00885         bool editbox_TextChangedEventHandler(const EventArgs& e);
    00886         bool listbox_ListContentsChangedHandler(const EventArgs& e);
    00887         bool listbox_ListSelectionChangedHandler(const EventArgs& e);
    00888         bool listbox_SortModeChangedHandler(const EventArgs& e);
    00889         bool listbox_VertScrollModeChangedHandler(const EventArgs& e);
    00890         bool listbox_HorzScrollModeChangedHandler(const EventArgs& e);
    00891
    00892
    00893         /*************************************************************************
    00894                 New Events for Combobox
    00895         *************************************************************************/
    00900         virtual void    onReadOnlyChanged(WindowEventArgs& e);
    00901
    00902
    00907         virtual void    onValidationStringChanged(WindowEventArgs& e);
    00908
    00909
    00914         virtual void    onMaximumTextLengthChanged(WindowEventArgs& e);
    00915
    00916
    00921         virtual void    onTextInvalidatedEvent(WindowEventArgs& e);
    00922
    00923
    00928         virtual void    onInvalidEntryAttempted(WindowEventArgs& e);
    00929
    00930
    00935         virtual void    onCaratMoved(WindowEventArgs& e);
    00936
    00937
    00942         virtual void    onTextSelectionChanged(WindowEventArgs& e);
    00943
    00944
    00949         virtual void    onEditboxFullEvent(WindowEventArgs& e);
    00950
    00951
    00956         virtual void    onTextAcceptedEvent(WindowEventArgs& e);
    00957
    00958
    00963         virtual void    onListContentsChanged(WindowEventArgs& e);
    00964
    00965
    00971         virtual void    onListSelectionChanged(WindowEventArgs& e);
    00972
    00973
    00978         virtual void    onSortModeChanged(WindowEventArgs& e);
    00979
    00980
    00986         virtual void    onVertScrollbarModeChanged(WindowEventArgs& e);
    00987
    00988
    00994         virtual void    onHorzScrollbarModeChanged(WindowEventArgs& e);
    00995
    00996
    01001         virtual void    onDropListDisplayed(WindowEventArgs& e);
    01002
    01003
    01008         virtual void    onDroplistRemoved(WindowEventArgs& e);
    01009
    01010
    01015         virtual void    onListSelectionAccepted(WindowEventArgs& e);
    01016
    01017
    01018         /*************************************************************************
    01019                 Overridden Event handlers
    01020         *************************************************************************/
    01021         virtual void    onFontChanged(WindowEventArgs& e);
    01022         virtual void    onTextChanged(WindowEventArgs& e);
    01023         virtual void    onActivated(ActivationEventArgs& e);
    01024
    01025
    01026         /*************************************************************************
    01027                 Implementation Data
    01028         *************************************************************************/
    01029         Editbox*                d_editbox;
    01030         ComboDropList*  d_droplist;
    01031         PushButton*             d_button;
    01032         bool                    d_singleClickOperation;
    01033
    01034
    01035 private:
    01036         /*************************************************************************
    01037                 Static Properties for this class
    01038         *************************************************************************/
    01039         static ComboboxProperties::ReadOnly                                             d_readOnlyProperty;
    01040         static ComboboxProperties::ValidationString                             d_validationStringProperty;
    01041         static ComboboxProperties::CaratIndex                                   d_caratIndexProperty;
    01042         static ComboboxProperties::EditSelectionStart                   d_selStartProperty;
    01043         static ComboboxProperties::EditSelectionLength                  d_selLengthProperty;
    01044         static ComboboxProperties::MaxEditTextLength                    d_maxTextLengthProperty;
    01045         static ComboboxProperties::NormalEditTextColour                 d_normalTextColourProperty;
    01046         static ComboboxProperties::SelectedEditTextColour               d_selectedTextColourProperty;
    01047         static ComboboxProperties::ActiveEditSelectionColour    d_activeSelectionColourProperty;
    01048         static ComboboxProperties::InactiveEditSelectionColour  d_inactiveSelectionColourProperty;
    01049         static ComboboxProperties::SortList                                             d_sortProperty;
    01050         static ComboboxProperties::ForceVertScrollbar                   d_forceVertProperty;
    01051         static ComboboxProperties::ForceHorzScrollbar                   d_forceHorzProperty;
    01052         static ComboboxProperties::SingleClickMode                              d_singleClickOperationProperty;
    01053
    01054         /*************************************************************************
    01055                 Private methods
    01056         *************************************************************************/
    01057         void    addComboboxProperties(void);
    01058 };
    01059
    01060 } // End of  CEGUI namespace section
    01061
    01062 #if defined(_MSC_VER)
    01063 #       pragma warning(pop)
    01064 #endif
    01065
    01066 #endif  // end of guard _CEGUICombobox_h_