Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUIListbox.h

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIListbox.h
00003         created:        13/4/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to base class for Listbox 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 _CEGUIListbox_h_
00027 #define _CEGUIListbox_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "elements/CEGUIListboxProperties.h"
00032 #include <vector>
00033 
00034 
00035 #if defined(_MSC_VER)
00036 #       pragma warning(push)
00037 #       pragma warning(disable : 4251)
00038 #endif
00039 
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00044 
00049 class CEGUIBASE_API Listbox : public Window
00050 {
00051 public:
00052         static const String EventNamespace;                             
00053 
00054 
00055         /*************************************************************************
00056                 Constants
00057         *************************************************************************/
00058         // event names
00059         static const String EventListContentsChanged;                   
00060         static const String EventSelectionChanged;                      
00061         static const String EventSortModeChanged;                               
00062         static const String EventMultiselectModeChanged;                
00063         static const String EventVertScrollbarModeChanged;      
00064         static const String EventHorzScrollbarModeChanged;      
00065 
00066 
00067         /*************************************************************************
00068                 Accessor Methods
00069         *************************************************************************/
00077         uint    getItemCount(void) const                {return (uint)d_listItems.size();}
00078 
00079         
00087         uint    getSelectedCount(void) const;
00088 
00089 
00098         ListboxItem*    getFirstSelectedItem(void) const;
00099 
00100 
00115         ListboxItem*    getNextSelected(const ListboxItem* start_item) const;
00116 
00117 
00130         ListboxItem*    getListboxItemFromIndex(uint index) const;
00131 
00132 
00145         uint    getItemIndex(const ListboxItem* item) const;
00146 
00147 
00155         bool    isSortEnabled(void) const               {return d_sorted;}
00156 
00164         bool    isMultiselectEnabled(void) const        {return d_multiselect;}
00165 
00166 
00179         bool    isItemSelected(uint index) const;
00180 
00181 
00199         ListboxItem*    findItemWithText(const String& text, const ListboxItem* start_item);
00200 
00201 
00209         bool    isListboxItemInList(const ListboxItem* item) const;
00210 
00211 
00220         bool    isVertScrollbarAlwaysShown(void) const;
00221 
00222 
00231         bool    isHorzScrollbarAlwaysShown(void) const;
00232 
00233 
00234         /*************************************************************************
00235                 Manipulator Methods
00236         *************************************************************************/
00247         virtual void    initialise(void);
00248 
00249 
00256         void    resetList(void);
00257 
00258 
00270         void    addItem(ListboxItem* item);
00271 
00272 
00290         void    insertItem(ListboxItem* item, const ListboxItem* position);
00291 
00292 
00304         void    removeItem(const ListboxItem* item);
00305 
00306 
00314         void    clearAllSelections(void);
00315 
00316 
00327         void    setSortingEnabled(bool setting);
00328 
00329         
00341         void    setMultiselectEnabled(bool setting);
00342 
00343 
00355         void    setShowVertScrollbar(bool setting);
00356 
00357 
00369         void    setShowHorzScrollbar(bool setting);
00370 
00371 
00391         void    setItemSelectState(ListboxItem* item, bool state);
00392 
00393 
00413         void    setItemSelectState(uint item_index, bool state);
00414 
00415 
00428         void    handleUpdatedItemData(void);
00429 
00430 
00442         void    ensureItemIsVisible(uint item_index);
00443 
00444 
00457         void    ensureItemIsVisible(const ListboxItem* item);
00458 
00459 
00460         /*************************************************************************
00461                 Construction and Destruction
00462         *************************************************************************/
00467         Listbox(const String& type, const String& name);
00468 
00469 
00474         virtual ~Listbox(void);
00475 
00476 
00477 protected:
00478         /*************************************************************************
00479                 Abstract Implementation Functions (must be provided by derived class)
00480         *************************************************************************/
00490         virtual Rect    getListRenderArea(void) const           = 0;
00491 
00492 
00500         virtual Scrollbar*      createVertScrollbar(void) const         = 0;
00501  
00502 
00510         virtual Scrollbar*      createHorzScrollbar(void) const         = 0;
00511 
00512 
00520         virtual void    layoutComponentWidgets()        = 0;
00521 
00522 
00536         virtual void    renderListboxBaseImagery(float z)               = 0;
00537 
00538 
00539         /*************************************************************************
00540                 Implementation Functions
00541         *************************************************************************/
00546         void    addListboxEvents(void);
00547 
00548 
00559         virtual void    drawSelf(float z);
00560 
00561 
00566         void    configureScrollbars(void);
00567 
00573         void    selectRange(uint start, uint end);
00574 
00575 
00580         float   getTotalItemsHeight(void) const;
00581 
00582 
00587         float   getWidestItemWidth(void) const;
00588 
00589 
00597         bool    clearAllSelections_impl(void);
00598 
00599 
00608         ListboxItem*    getItemAtPoint(const Point& pt) const;
00609 
00610 
00622         bool    resetList_impl(void);
00623 
00624 
00625         /*************************************************************************
00626                 New event handlers
00627         *************************************************************************/
00632         virtual void    onListContentsChanged(WindowEventArgs& e);
00633 
00634 
00639         virtual void    onSelectionChanged(WindowEventArgs& e);
00640 
00641 
00646         virtual void    onSortModeChanged(WindowEventArgs& e);
00647 
00648 
00653         virtual void    onMultiselectModeChanged(WindowEventArgs& e);
00654 
00655 
00660         virtual void    onVertScrollbarModeChanged(WindowEventArgs& e);
00661 
00662 
00667         virtual void    onHorzScrollbarModeChanged(WindowEventArgs& e);
00668 
00669 
00670         /*************************************************************************
00671                 Overridden Event handlers
00672         *************************************************************************/
00673         virtual void    onSized(WindowEventArgs& e);
00674         virtual void    onMouseButtonDown(MouseEventArgs& e);
00675         virtual void    onMouseWheel(MouseEventArgs& e);
00676 
00677 
00678         /*************************************************************************
00679                 Implementation Data
00680         *************************************************************************/
00681         typedef std::vector<ListboxItem*>       LBItemList;
00682         bool    d_sorted;                               
00683         bool    d_multiselect;                  
00684         bool    d_forceVertScroll;              
00685         bool    d_forceHorzScroll;              
00686         Scrollbar*      d_vertScrollbar;        
00687         Scrollbar*      d_horzScrollbar;        
00688         LBItemList      d_listItems;            
00689         ListboxItem*    d_lastSelected; 
00690 
00691 
00692 private:
00693         /*************************************************************************
00694                 Static Properties for this class
00695         *************************************************************************/
00696         static ListboxProperties::Sort                                  d_sortProperty;
00697         static ListboxProperties::MultiSelect                   d_multiSelectProperty;
00698         static ListboxProperties::ForceVertScrollbar    d_forceVertProperty;
00699         static ListboxProperties::ForceHorzScrollbar    d_forceHorzProperty;
00700 
00701         /*************************************************************************
00702                 Private methods
00703         *************************************************************************/
00704         void    addListboxProperties(void);
00705 };
00706 
00707 
00713 static bool lbi_less(const ListboxItem* a, const ListboxItem* b);
00714 
00715 
00721 static bool lbi_greater(const ListboxItem* a, const ListboxItem* b);
00722 
00723 } // End of  CEGUI namespace section
00724 
00725 
00726 #if defined(_MSC_VER)
00727 #       pragma warning(pop)
00728 #endif
00729 
00730 #endif  // end of guard _CEGUIListbox_h_

Generated on Wed Feb 16 12:41:06 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1