CEGUIListHeader.h

00001 /***********************************************************************
00002         filename:       CEGUIListHeader.h
00003         created:        13/4/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to base class for ListHeader 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 _CEGUIListHeader_h_
00031 #define _CEGUIListHeader_h_
00032 
00033 #include "CEGUIBase.h"
00034 #include "CEGUIWindow.h"
00035 #include "elements/CEGUIListHeaderSegment.h"
00036 #include "elements/CEGUIListHeaderProperties.h"
00037 
00038 
00039 #if defined(_MSC_VER)
00040 #       pragma warning(push)
00041 #       pragma warning(disable : 4251)
00042 #endif
00043 
00044 
00045 // Start of CEGUI namespace section
00046 namespace CEGUI
00047 {
00052 class CEGUIEXPORT HeaderSequenceEventArgs : public WindowEventArgs
00053 {
00054 public:
00055         HeaderSequenceEventArgs(Window* wnd, uint old_idx, uint new_idx) : WindowEventArgs(wnd), d_oldIdx(old_idx), d_newIdx(new_idx) {};
00056 
00057         uint d_oldIdx;          
00058         uint d_newIdx;          
00059 };
00060 
00065 class CEGUIEXPORT ListHeaderWindowRenderer : public WindowRenderer
00066 {
00067 public:
00072     ListHeaderWindowRenderer(const String& name);
00073 
00085     virtual ListHeaderSegment*  createNewSegment(const String& name) const  = 0;
00086 
00098     virtual void    destroyListSegment(ListHeaderSegment* segment) const = 0;
00099 };
00100 
00101 
00106 class CEGUIEXPORT ListHeader : public Window
00107 {
00108 public:
00109         static const String EventNamespace;                             
00110     static const String WidgetTypeName;             
00111 
00112 
00113         /*************************************************************************
00114                 Constants
00115         *************************************************************************/
00116         // Event names
00117         static const String EventSortColumnChanged;                     
00118         static const String EventSortDirectionChanged;          
00119         static const String EventSegmentSized;                          
00120         static const String EventSegmentClicked;                                
00121         static const String EventSplitterDoubleClicked;         
00122         static const String EventSegmentSequenceChanged;                
00123         static const String EventSegmentAdded;                          
00124         static const String EventSegmentRemoved;                                
00125         static const String EventSortSettingChanged;                    
00126         static const String EventDragMoveSettingChanged;                
00127         static const String EventDragSizeSettingChanged;                
00128         static const String EventSegmentRenderOffsetChanged;    
00129 
00130         // values
00131         static const float      ScrollSpeed;                            
00132         static const float      MinimumSegmentPixelWidth;       
00133 
00134     /*************************************************************************
00135         Child Widget name suffix constants
00136     *************************************************************************/
00137     static const char SegmentNameSuffix[];          
00138 
00139 
00140         /*************************************************************************
00141                 Accessor Methods
00142         *************************************************************************/
00150         uint    getColumnCount(void) const;
00151 
00152         
00165         ListHeaderSegment&      getSegmentFromColumn(uint column) const;
00166 
00167 
00181         ListHeaderSegment&      getSegmentFromID(uint id) const;
00182 
00183 
00194         ListHeaderSegment&      getSortSegment(void) const;
00195 
00196 
00209         uint    getColumnFromSegment(const ListHeaderSegment& segment) const;
00210 
00211 
00224         uint    getColumnFromID(uint id) const;
00225 
00226 
00237         uint    getSortColumn(void) const;
00238 
00239 
00252         uint    getColumnWithText(const String& text) const;
00253 
00254 
00267         float   getPixelOffsetToSegment(const ListHeaderSegment& segment) const;
00268 
00269 
00283         float   getPixelOffsetToColumn(uint column) const;
00284 
00285 
00293         float   getTotalSegmentsPixelExtent(void) const;
00294 
00295 
00309         UDim getColumnWidth(uint column) const;
00310 
00311 
00319         ListHeaderSegment::SortDirection        getSortDirection(void) const;
00320 
00321 
00330         bool    isSortingEnabled(void) const;
00331 
00332 
00340         bool    isColumnSizingEnabled(void) const;
00341 
00342 
00350         bool    isColumnDraggingEnabled(void) const;
00351 
00352 
00361         float   getSegmentOffset(void) const    {return d_segmentOffset;}
00362 
00363 
00364         /*************************************************************************
00365                 Manipulator Methods
00366         *************************************************************************/
00378         void    setSortingEnabled(bool setting);
00379 
00380 
00391         void    setSortDirection(ListHeaderSegment::SortDirection direction);
00392 
00393 
00406         void    setSortSegment(const ListHeaderSegment& segment);
00407 
00408 
00421         void    setSortColumn(uint column);
00422 
00423 
00436         void    setSortColumnFromID(uint id);
00437 
00438 
00450         void    setColumnSizingEnabled(bool setting);
00451 
00452 
00464         void    setColumnDraggingEnabled(bool setting);
00465 
00466 
00483         void    addColumn(const String& text, uint id, const UDim& width);
00484 
00485 
00506         void    insertColumn(const String& text, uint id, const UDim& width, uint position);
00507 
00508 
00531         void    insertColumn(const String& text, uint id, const UDim& width, const ListHeaderSegment& position);
00532 
00533 
00546         void    removeColumn(uint column);
00547 
00548 
00561         void    removeSegment(const ListHeaderSegment& segment);
00562 
00563 
00580         void    moveColumn(uint column, uint position);
00581 
00582 
00601         void    moveColumn(uint column, const ListHeaderSegment& position);
00602 
00603 
00620         void    moveSegment(const ListHeaderSegment& segment, uint position);
00621 
00622 
00640         void    moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position);
00641 
00642 
00655         void    setSegmentOffset(float offset);
00656 
00657 
00674         void    setColumnWidth(uint column, const UDim& width);
00675 
00676 
00677         /*************************************************************************
00678                 Construction and Destruction
00679         *************************************************************************/
00684         ListHeader(const String& type, const String& name);
00685 
00686 
00691         virtual ~ListHeader(void);
00692 
00693 
00694 protected:
00695         /*************************************************************************
00696                 Abstract Implementation Methods
00697         *************************************************************************/
00709         //virtual ListHeaderSegment*    createNewSegment_impl(const String& name) const = 0;
00710 
00711 
00723         //virtual void  destroyListSegment_impl(ListHeaderSegment* segment) const = 0;
00724 
00725 
00726         /*************************************************************************
00727                 Implementation Methods
00728         *************************************************************************/
00733         ListHeaderSegment*      createInitialisedSegment(const String& text, uint id, const UDim& width);
00734 
00735 
00740         void    layoutSegments(void);
00741 
00742 
00753         virtual bool    testClassName_impl(const String& class_name) const
00754         {
00755                 if (class_name=="ListHeader")   return true;
00756                 return Window::testClassName_impl(class_name);
00757         }
00758 
00759 
00771     ListHeaderSegment*  createNewSegment(const String& name) const;
00772 
00773 
00785     void    destroyListSegment(ListHeaderSegment* segment) const;
00786 
00787     // validate window renderer
00788     virtual bool validateWindowRenderer(const String& name) const
00789     {
00790         return (name == "ListHeader");
00791     }
00792 
00793         /*************************************************************************
00794                 New List header event handlers
00795         *************************************************************************/
00800         virtual void    onSortColumnChanged(WindowEventArgs& e);
00801 
00802 
00807         virtual void    onSortDirectionChanged(WindowEventArgs& e);
00808 
00809 
00814         virtual void    onSegmentSized(WindowEventArgs& e);
00815 
00816 
00821         virtual void    onSegmentClicked(WindowEventArgs& e);
00822 
00823 
00828         virtual void    onSplitterDoubleClicked(WindowEventArgs& e);
00829 
00830 
00835         virtual void    onSegmentSequenceChanged(WindowEventArgs& e);
00836 
00837 
00842         virtual void    onSegmentAdded(WindowEventArgs& e);
00843 
00844 
00849         virtual void    onSegmentRemoved(WindowEventArgs& e);
00850 
00851 
00856         virtual void    onSortSettingChanged(WindowEventArgs& e);
00857 
00858 
00863         virtual void    onDragMoveSettingChanged(WindowEventArgs& e);
00864 
00865 
00870         virtual void    onDragSizeSettingChanged(WindowEventArgs& e);
00871 
00872 
00877         virtual void    onSegmentOffsetChanged(WindowEventArgs& e);
00878 
00879         /*************************************************************************
00880                 handlers for events we subscribe to from segments
00881         *************************************************************************/
00882         bool    segmentSizedHandler(const EventArgs& e);
00883         bool    segmentMovedHandler(const EventArgs& e);
00884         bool    segmentClickedHandler(const EventArgs& e);
00885         bool    segmentDoubleClickHandler(const EventArgs& e);
00886         bool    segmentDragHandler(const EventArgs& e);
00887 
00888 
00889         /*************************************************************************
00890                 Implementation Data
00891         *************************************************************************/
00892         typedef std::vector<ListHeaderSegment*>         SegmentList;
00893         SegmentList     d_segments;                     
00894         ListHeaderSegment*      d_sortSegment;  
00895         bool    d_sizingEnabled;                
00896         bool    d_sortingEnabled;               
00897         bool    d_movingEnabled;                
00898         uint    d_uniqueIDNumber;               
00899         float   d_segmentOffset;                
00900         ListHeaderSegment::SortDirection        d_sortDir;              
00901 
00902 
00903 private:
00904         /*************************************************************************
00905                 Static Properties for this class
00906         *************************************************************************/
00907         static ListHeaderProperties::SortSettingEnabled         d_sortSettingProperty;
00908         static ListHeaderProperties::ColumnsSizable                     d_sizableProperty;
00909         static ListHeaderProperties::ColumnsMovable                     d_movableProperty;
00910         static ListHeaderProperties::SortColumnID                       d_sortColumnIDProperty;
00911         static ListHeaderProperties::SortDirection                      d_sortDirectionProperty;
00912 
00913 
00914         /*************************************************************************
00915                 Private methods
00916         *************************************************************************/
00917         void    addHeaderProperties(void);
00918 };
00919 
00920 
00921 } // End of  CEGUI namespace section
00922 
00923 
00924 #if defined(_MSC_VER)
00925 #       pragma warning(pop)
00926 #endif
00927 
00928 #endif  // end of guard _CEGUIListHeader_h_

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