Crazy Eddies GUI System: CEGUIListHeader.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 "CEGUIListHeaderSegment.h"
    00036 #include "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
    00122         static const String EventSortColumnChanged;
    00128         static const String EventSortDirectionChanged;
    00133         static const String EventSegmentSized;
    00138         static const String EventSegmentClicked;
    00144         static const String EventSplitterDoubleClicked;
    00152         static const String EventSegmentSequenceChanged;
    00158         static const String EventSegmentAdded;
    00164         static const String EventSegmentRemoved;
    00171         static const String EventSortSettingChanged;
    00178         static const String EventDragMoveSettingChanged;
    00185         static const String EventDragSizeSettingChanged;
    00191         static const String EventSegmentRenderOffsetChanged;
    00192
    00193         // values
    00194         static const float      ScrollSpeed;
    00195         static const float      MinimumSegmentPixelWidth;
    00196
    00197     /*************************************************************************
    00198         Child Widget name suffix constants
    00199     *************************************************************************/
    00200     static const char SegmentNameSuffix[];
    00201
    00202
    00203         /*************************************************************************
    00204                 Accessor Methods
    00205         *************************************************************************/
    00213         uint    getColumnCount(void) const;
    00214
    00215
    00228         ListHeaderSegment&      getSegmentFromColumn(uint column) const;
    00229
    00230
    00244         ListHeaderSegment&      getSegmentFromID(uint id) const;
    00245
    00246
    00257         ListHeaderSegment&      getSortSegment(void) const;
    00258
    00259
    00272         uint    getColumnFromSegment(const ListHeaderSegment& segment) const;
    00273
    00274
    00287         uint    getColumnFromID(uint id) const;
    00288
    00289
    00300         uint    getSortColumn(void) const;
    00301
    00302
    00315         uint    getColumnWithText(const String& text) const;
    00316
    00317
    00330         float   getPixelOffsetToSegment(const ListHeaderSegment& segment) const;
    00331
    00332
    00346         float   getPixelOffsetToColumn(uint column) const;
    00347
    00348
    00356         float   getTotalSegmentsPixelExtent(void) const;
    00357
    00358
    00372         UDim getColumnWidth(uint column) const;
    00373
    00374
    00382         ListHeaderSegment::SortDirection        getSortDirection(void) const;
    00383
    00384
    00393         bool    isSortingEnabled(void) const;
    00394
    00395
    00403         bool    isColumnSizingEnabled(void) const;
    00404
    00405
    00413         bool    isColumnDraggingEnabled(void) const;
    00414
    00415
    00424         float   getSegmentOffset(void) const    {return d_segmentOffset;}
    00425
    00426
    00427         /*************************************************************************
    00428                 Manipulator Methods
    00429         *************************************************************************/
    00441         void    setSortingEnabled(bool setting);
    00442
    00443
    00454         void    setSortDirection(ListHeaderSegment::SortDirection direction);
    00455
    00456
    00469         void    setSortSegment(const ListHeaderSegment& segment);
    00470
    00471
    00484         void    setSortColumn(uint column);
    00485
    00486
    00499         void    setSortColumnFromID(uint id);
    00500
    00501
    00513         void    setColumnSizingEnabled(bool setting);
    00514
    00515
    00527         void    setColumnDraggingEnabled(bool setting);
    00528
    00529
    00546         void    addColumn(const String& text, uint id, const UDim& width);
    00547
    00548
    00569         void    insertColumn(const String& text, uint id, const UDim& width, uint position);
    00570
    00571
    00594         void    insertColumn(const String& text, uint id, const UDim& width, const ListHeaderSegment& position);
    00595
    00596
    00609         void    removeColumn(uint column);
    00610
    00611
    00624         void    removeSegment(const ListHeaderSegment& segment);
    00625
    00626
    00643         void    moveColumn(uint column, uint position);
    00644
    00645
    00664         void    moveColumn(uint column, const ListHeaderSegment& position);
    00665
    00666
    00683         void    moveSegment(const ListHeaderSegment& segment, uint position);
    00684
    00685
    00703         void    moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position);
    00704
    00705
    00718         void    setSegmentOffset(float offset);
    00719
    00720
    00737         void    setColumnWidth(uint column, const UDim& width);
    00738
    00739
    00740         /*************************************************************************
    00741                 Construction and Destruction
    00742         *************************************************************************/
    00747         ListHeader(const String& type, const String& name);
    00748
    00749
    00754         virtual ~ListHeader(void);
    00755
    00756
    00757 protected:
    00758         /*************************************************************************
    00759                 Abstract Implementation Methods
    00760         *************************************************************************/
    00772         //virtual ListHeaderSegment*    createNewSegment_impl(const String& name) const = 0;
    00773
    00774
    00786         //virtual void  destroyListSegment_impl(ListHeaderSegment* segment) const = 0;
    00787
    00788
    00789         /*************************************************************************
    00790                 Implementation Methods
    00791         *************************************************************************/
    00796         ListHeaderSegment*      createInitialisedSegment(const String& text, uint id, const UDim& width);
    00797
    00798
    00803         void    layoutSegments(void);
    00804
    00805
    00816         virtual bool    testClassName_impl(const String& class_name) const
    00817         {
    00818                 if (class_name=="ListHeader")   return true;
    00819                 return Window::testClassName_impl(class_name);
    00820         }
    00821
    00822
    00834     ListHeaderSegment*  createNewSegment(const String& name) const;
    00835
    00836
    00848     void    destroyListSegment(ListHeaderSegment* segment) const;
    00849
    00850     // validate window renderer
    00851     virtual bool validateWindowRenderer(const String& name) const
    00852     {
    00853         return (name == "ListHeader");
    00854     }
    00855
    00856         /*************************************************************************
    00857                 New List header event handlers
    00858         *************************************************************************/
    00863         virtual void    onSortColumnChanged(WindowEventArgs& e);
    00864
    00865
    00870         virtual void    onSortDirectionChanged(WindowEventArgs& e);
    00871
    00872
    00877         virtual void    onSegmentSized(WindowEventArgs& e);
    00878
    00879
    00884         virtual void    onSegmentClicked(WindowEventArgs& e);
    00885
    00886
    00891         virtual void    onSplitterDoubleClicked(WindowEventArgs& e);
    00892
    00893
    00898         virtual void    onSegmentSequenceChanged(WindowEventArgs& e);
    00899
    00900
    00905         virtual void    onSegmentAdded(WindowEventArgs& e);
    00906
    00907
    00912         virtual void    onSegmentRemoved(WindowEventArgs& e);
    00913
    00914
    00919         virtual void    onSortSettingChanged(WindowEventArgs& e);
    00920
    00921
    00926         virtual void    onDragMoveSettingChanged(WindowEventArgs& e);
    00927
    00928
    00933         virtual void    onDragSizeSettingChanged(WindowEventArgs& e);
    00934
    00935
    00940         virtual void    onSegmentOffsetChanged(WindowEventArgs& e);
    00941
    00942         /*************************************************************************
    00943                 handlers for events we subscribe to from segments
    00944         *************************************************************************/
    00945         bool    segmentSizedHandler(const EventArgs& e);
    00946         bool    segmentMovedHandler(const EventArgs& e);
    00947         bool    segmentClickedHandler(const EventArgs& e);
    00948         bool    segmentDoubleClickHandler(const EventArgs& e);
    00949         bool    segmentDragHandler(const EventArgs& e);
    00950
    00951
    00952         /*************************************************************************
    00953                 Implementation Data
    00954         *************************************************************************/
    00955         typedef std::vector<ListHeaderSegment*>         SegmentList;
    00956         SegmentList     d_segments;
    00957         ListHeaderSegment*      d_sortSegment;
    00958         bool    d_sizingEnabled;
    00959         bool    d_sortingEnabled;
    00960         bool    d_movingEnabled;
    00961         uint    d_uniqueIDNumber;
    00962         float   d_segmentOffset;
    00963         ListHeaderSegment::SortDirection        d_sortDir;
    00964
    00965
    00966 private:
    00967         /*************************************************************************
    00968                 Static Properties for this class
    00969         *************************************************************************/
    00970         static ListHeaderProperties::SortSettingEnabled         d_sortSettingProperty;
    00971         static ListHeaderProperties::ColumnsSizable                     d_sizableProperty;
    00972         static ListHeaderProperties::ColumnsMovable                     d_movableProperty;
    00973         static ListHeaderProperties::SortColumnID                       d_sortColumnIDProperty;
    00974         static ListHeaderProperties::SortDirection                      d_sortDirectionProperty;
    00975
    00976
    00977         /*************************************************************************
    00978                 Private methods
    00979         *************************************************************************/
    00980         void    addHeaderProperties(void);
    00981 };
    00982
    00983
    00984 } // End of  CEGUI namespace section
    00985
    00986
    00987 #if defined(_MSC_VER)
    00988 #       pragma warning(pop)
    00989 #endif
    00990
    00991 #endif  // end of guard _CEGUIListHeader_h_