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     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 _CEGUIListHeader_h_
00027 #define _CEGUIListHeader_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "elements/CEGUIListHeaderSegment.h"
00032 #include "elements/CEGUIListHeaderProperties.h"
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 {
00048 class CEGUIEXPORT HeaderSequenceEventArgs : public WindowEventArgs
00049 {
00050 public:
00051         HeaderSequenceEventArgs(Window* wnd, uint old_idx, uint new_idx) : WindowEventArgs(wnd), d_oldIdx(old_idx), d_newIdx(new_idx) {};
00052 
00053         uint d_oldIdx;          
00054         uint d_newIdx;          
00055 };
00056 
00057 
00062 class CEGUIEXPORT ListHeader : public Window
00063 {
00064 public:
00065         static const String EventNamespace;                             
00066 
00067 
00068         /*************************************************************************
00069                 Constants
00070         *************************************************************************/
00071         // Event names
00072         static const String EventSortColumnChanged;                     
00073         static const String EventSortDirectionChanged;          
00074         static const String EventSegmentSized;                          
00075         static const String EventSegmentClicked;                                
00076         static const String EventSplitterDoubleClicked;         
00077         static const String EventSegmentSequenceChanged;                
00078         static const String EventSegmentAdded;                          
00079         static const String EventSegmentRemoved;                                
00080         static const String EventSortSettingChanged;                    
00081         static const String EventDragMoveSettingChanged;                
00082         static const String EventDragSizeSettingChanged;                
00083         static const String EventSegmentRenderOffsetChanged;    
00084 
00085         // values
00086         static const float      ScrollSpeed;                            
00087         static const float      MinimumSegmentPixelWidth;       
00088 
00089 
00090         /*************************************************************************
00091                 Accessor Methods
00092         *************************************************************************/
00100         uint    getColumnCount(void) const;
00101 
00102         
00115         ListHeaderSegment&      getSegmentFromColumn(uint column) const;
00116 
00117 
00131         ListHeaderSegment&      getSegmentFromID(uint id) const;
00132 
00133 
00144         ListHeaderSegment&      getSortSegment(void) const;
00145 
00146 
00159         uint    getColumnFromSegment(const ListHeaderSegment& segment) const;
00160 
00161 
00174         uint    getColumnFromID(uint id) const;
00175 
00176 
00187         uint    getSortColumn(void) const;
00188 
00189 
00202         uint    getColumnWithText(const String& text) const;
00203 
00204 
00217         float   getPixelOffsetToSegment(const ListHeaderSegment& segment) const;
00218 
00219 
00233         float   getPixelOffsetToColumn(uint column) const;
00234 
00235 
00243         float   getTotalSegmentsPixelExtent(void) const;
00244 
00245 
00258         float   getColumnPixelWidth(uint column) const;
00259 
00260 
00268         ListHeaderSegment::SortDirection        getSortDirection(void) const;
00269 
00270 
00279         bool    isSortingEnabled(void) const;
00280 
00281 
00289         bool    isColumnSizingEnabled(void) const;
00290 
00291 
00299         bool    isColumnDraggingEnabled(void) const;
00300 
00301 
00310         float   getSegmentOffset(void) const    {return d_segmentOffset;}
00311 
00312 
00313         /*************************************************************************
00314                 Manipulator Methods
00315         *************************************************************************/
00327         void    setSortingEnabled(bool setting);
00328 
00329 
00340         void    setSortDirection(ListHeaderSegment::SortDirection direction);
00341 
00342 
00355         void    setSortSegment(const ListHeaderSegment& segment);
00356 
00357 
00370         void    setSortColumn(uint column);
00371 
00372 
00385         void    setSortColumnFromID(uint id);
00386 
00387 
00399         void    setColumnSizingEnabled(bool setting);
00400 
00401 
00413         void    setColumnDraggingEnabled(bool setting);
00414 
00415 
00432         void    addColumn(const String& text, uint id, float width);
00433 
00434 
00455         void    insertColumn(const String& text, uint id, float width, uint position);
00456 
00457 
00480         void    insertColumn(const String& text, uint id, float width, const ListHeaderSegment& position);
00481 
00482 
00495         void    removeColumn(uint column);
00496 
00497 
00510         void    removeSegment(const ListHeaderSegment& segment);
00511 
00512 
00529         void    moveColumn(uint column, uint position);
00530 
00531 
00550         void    moveColumn(uint column, const ListHeaderSegment& position);
00551 
00552 
00569         void    moveSegment(const ListHeaderSegment& segment, uint position);
00570 
00571 
00589         void    moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position);
00590 
00591 
00604         void    setSegmentOffset(float offset);
00605 
00606 
00623         void    setColumnPixelWidth(uint column, float width);
00624 
00625 
00626         /*************************************************************************
00627                 Construction and Destruction
00628         *************************************************************************/
00633         ListHeader(const String& type, const String& name);
00634 
00635 
00640         virtual ~ListHeader(void);
00641 
00642 
00643 protected:
00644         /*************************************************************************
00645                 Abstract Implementation Methods
00646         *************************************************************************/
00658         virtual ListHeaderSegment*      createNewSegment(const String& name) const      = 0;
00659 
00660 
00672         virtual void    destroyListSegment(ListHeaderSegment* segment) const = 0;
00673 
00674 
00675         /*************************************************************************
00676                 Implementation Methods
00677         *************************************************************************/
00682         ListHeaderSegment*      createInitialisedSegment(const String& text, uint id, float width);
00683 
00684 
00689         void    layoutSegments(void);
00690 
00691 
00696         void    addListHeaderEvents(void);
00697 
00698 
00709         virtual bool    testClassName_impl(const String& class_name) const
00710         {
00711                 if (class_name==(const utf8*)"ListHeader")      return true;
00712                 return Window::testClassName_impl(class_name);
00713         }
00714 
00715 
00716         /*************************************************************************
00717                 New List header event handlers
00718         *************************************************************************/
00723         virtual void    onSortColumnChanged(WindowEventArgs& e);
00724 
00725 
00730         virtual void    onSortDirectionChanged(WindowEventArgs& e);
00731 
00732 
00737         virtual void    onSegmentSized(WindowEventArgs& e);
00738 
00739 
00744         virtual void    onSegmentClicked(WindowEventArgs& e);
00745 
00746 
00751         virtual void    onSplitterDoubleClicked(WindowEventArgs& e);
00752 
00753 
00758         virtual void    onSegmentSequenceChanged(WindowEventArgs& e);
00759 
00760 
00765         virtual void    onSegmentAdded(WindowEventArgs& e);
00766 
00767 
00772         virtual void    onSegmentRemoved(WindowEventArgs& e);
00773 
00774 
00779         virtual void    onSortSettingChanged(WindowEventArgs& e);
00780 
00781 
00786         virtual void    onDragMoveSettingChanged(WindowEventArgs& e);
00787 
00788 
00793         virtual void    onDragSizeSettingChanged(WindowEventArgs& e);
00794 
00795 
00800         virtual void    onSegmentOffsetChanged(WindowEventArgs& e);
00801 
00802 
00803         /*************************************************************************
00804                 handlers for events we subscribe to from segments
00805         *************************************************************************/
00806         bool    segmentSizedHandler(const EventArgs& e);
00807         bool    segmentMovedHandler(const EventArgs& e);
00808         bool    segmentClickedHandler(const EventArgs& e);
00809         bool    segmentDoubleClickHandler(const EventArgs& e);
00810         bool    segmentDragHandler(const EventArgs& e);
00811 
00812 
00813         /*************************************************************************
00814                 Implementation Data
00815         *************************************************************************/
00816         typedef std::vector<ListHeaderSegment*>         SegmentList;
00817         SegmentList     d_segments;                     
00818         ListHeaderSegment*      d_sortSegment;  
00819         bool    d_sizingEnabled;                
00820         bool    d_sortingEnabled;               
00821         bool    d_movingEnabled;                
00822         uint    d_uniqueIDNumber;               
00823         float   d_segmentOffset;                
00824         ListHeaderSegment::SortDirection        d_sortDir;              
00825 
00826 
00827 private:
00828         /*************************************************************************
00829                 Static Properties for this class
00830         *************************************************************************/
00831         static ListHeaderProperties::SortSettingEnabled         d_sortSettingProperty;
00832         static ListHeaderProperties::ColumnsSizable                     d_sizableProperty;
00833         static ListHeaderProperties::ColumnsMovable                     d_movableProperty;
00834         static ListHeaderProperties::SortColumnID                       d_sortColumnIDProperty;
00835         static ListHeaderProperties::SortDirection                      d_sortDirectionProperty;
00836 
00837 
00838         /*************************************************************************
00839                 Private methods
00840         *************************************************************************/
00841         void    addHeaderProperties(void);
00842 };
00843 
00844 } // End of  CEGUI namespace section
00845 
00846 
00847 #if defined(_MSC_VER)
00848 #       pragma warning(pop)
00849 #endif
00850 
00851 #endif  // end of guard _CEGUIListHeader_h_

Generated on Sat Nov 26 10:09:54 2005 for Crazy Eddies GUI System by  doxygen 1.4.5