Crazy Eddies GUI System  0.7.0
CEGUIListHeader.h
1 /***********************************************************************
2  filename: CEGUIListHeader.h
3  created: 13/4/2004
4  author: Paul D Turner
5 
6  purpose: Interface to base class for ListHeader widget
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIListHeader_h_
31 #define _CEGUIListHeader_h_
32 
33 #include "../CEGUIBase.h"
34 #include "../CEGUIWindow.h"
35 #include "CEGUIListHeaderSegment.h"
36 #include "CEGUIListHeaderProperties.h"
37 
38 
39 #if defined(_MSC_VER)
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
42 #endif
43 
44 
45 // Start of CEGUI namespace section
46 namespace CEGUI
47 {
52 class CEGUIEXPORT HeaderSequenceEventArgs : public WindowEventArgs
53 {
54 public:
55  HeaderSequenceEventArgs(Window* wnd, uint old_idx, uint new_idx) : WindowEventArgs(wnd), d_oldIdx(old_idx), d_newIdx(new_idx) {};
56 
57  uint d_oldIdx;
58  uint d_newIdx;
59 };
60 
65 class CEGUIEXPORT ListHeaderWindowRenderer : public WindowRenderer
66 {
67 public:
72  ListHeaderWindowRenderer(const String& name);
73 
85  virtual ListHeaderSegment* createNewSegment(const String& name) const = 0;
86 
98  virtual void destroyListSegment(ListHeaderSegment* segment) const = 0;
99 };
100 
101 
106 class CEGUIEXPORT ListHeader : public Window
107 {
108 public:
109  static const String EventNamespace;
110  static const String WidgetTypeName;
111 
112 
113  /*************************************************************************
114  Constants
115  *************************************************************************/
116  // Event names
119  static const String EventSegmentSized;
123  static const String EventSegmentAdded;
129 
130  // values
131  static const float ScrollSpeed;
132  static const float MinimumSegmentPixelWidth;
133 
134  /*************************************************************************
135  Child Widget name suffix constants
136  *************************************************************************/
137  static const char SegmentNameSuffix[];
138 
139 
140  /*************************************************************************
141  Accessor Methods
142  *************************************************************************/
150  uint getColumnCount(void) const;
151 
152 
165  ListHeaderSegment& getSegmentFromColumn(uint column) const;
166 
167 
181  ListHeaderSegment& getSegmentFromID(uint id) const;
182 
183 
194  ListHeaderSegment& getSortSegment(void) const;
195 
196 
209  uint getColumnFromSegment(const ListHeaderSegment& segment) const;
210 
211 
224  uint getColumnFromID(uint id) const;
225 
226 
237  uint getSortColumn(void) const;
238 
239 
252  uint getColumnWithText(const String& text) const;
253 
254 
267  float getPixelOffsetToSegment(const ListHeaderSegment& segment) const;
268 
269 
283  float getPixelOffsetToColumn(uint column) const;
284 
285 
293  float getTotalSegmentsPixelExtent(void) const;
294 
295 
309  UDim getColumnWidth(uint column) const;
310 
311 
319  ListHeaderSegment::SortDirection getSortDirection(void) const;
320 
321 
330  bool isSortingEnabled(void) const;
331 
332 
340  bool isColumnSizingEnabled(void) const;
341 
342 
350  bool isColumnDraggingEnabled(void) const;
351 
352 
361  float getSegmentOffset(void) const {return d_segmentOffset;}
362 
363 
364  /*************************************************************************
365  Manipulator Methods
366  *************************************************************************/
378  void setSortingEnabled(bool setting);
379 
380 
391  void setSortDirection(ListHeaderSegment::SortDirection direction);
392 
393 
406  void setSortSegment(const ListHeaderSegment& segment);
407 
408 
421  void setSortColumn(uint column);
422 
423 
436  void setSortColumnFromID(uint id);
437 
438 
450  void setColumnSizingEnabled(bool setting);
451 
452 
464  void setColumnDraggingEnabled(bool setting);
465 
466 
483  void addColumn(const String& text, uint id, const UDim& width);
484 
485 
506  void insertColumn(const String& text, uint id, const UDim& width, uint position);
507 
508 
531  void insertColumn(const String& text, uint id, const UDim& width, const ListHeaderSegment& position);
532 
533 
546  void removeColumn(uint column);
547 
548 
561  void removeSegment(const ListHeaderSegment& segment);
562 
563 
580  void moveColumn(uint column, uint position);
581 
582 
601  void moveColumn(uint column, const ListHeaderSegment& position);
602 
603 
620  void moveSegment(const ListHeaderSegment& segment, uint position);
621 
622 
640  void moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position);
641 
642 
655  void setSegmentOffset(float offset);
656 
657 
674  void setColumnWidth(uint column, const UDim& width);
675 
676 
677  /*************************************************************************
678  Construction and Destruction
679  *************************************************************************/
684  ListHeader(const String& type, const String& name);
685 
686 
691  virtual ~ListHeader(void);
692 
693 
694 protected:
695  /*************************************************************************
696  Abstract Implementation Methods
697  *************************************************************************/
709  //virtual ListHeaderSegment* createNewSegment_impl(const String& name) const = 0;
710 
711 
723  //virtual void destroyListSegment_impl(ListHeaderSegment* segment) const = 0;
724 
725 
726  /*************************************************************************
727  Implementation Methods
728  *************************************************************************/
733  ListHeaderSegment* createInitialisedSegment(const String& text, uint id, const UDim& width);
734 
735 
740  void layoutSegments(void);
741 
742 
753  virtual bool testClassName_impl(const String& class_name) const
754  {
755  if (class_name=="ListHeader") return true;
756  return Window::testClassName_impl(class_name);
757  }
758 
759 
771  ListHeaderSegment* createNewSegment(const String& name) const;
772 
773 
785  void destroyListSegment(ListHeaderSegment* segment) const;
786 
787  // validate window renderer
788  virtual bool validateWindowRenderer(const String& name) const
789  {
790  return (name == "ListHeader");
791  }
792 
793  /*************************************************************************
794  New List header event handlers
795  *************************************************************************/
800  virtual void onSortColumnChanged(WindowEventArgs& e);
801 
802 
807  virtual void onSortDirectionChanged(WindowEventArgs& e);
808 
809 
814  virtual void onSegmentSized(WindowEventArgs& e);
815 
816 
821  virtual void onSegmentClicked(WindowEventArgs& e);
822 
823 
828  virtual void onSplitterDoubleClicked(WindowEventArgs& e);
829 
830 
835  virtual void onSegmentSequenceChanged(WindowEventArgs& e);
836 
837 
842  virtual void onSegmentAdded(WindowEventArgs& e);
843 
844 
849  virtual void onSegmentRemoved(WindowEventArgs& e);
850 
851 
856  virtual void onSortSettingChanged(WindowEventArgs& e);
857 
858 
863  virtual void onDragMoveSettingChanged(WindowEventArgs& e);
864 
865 
870  virtual void onDragSizeSettingChanged(WindowEventArgs& e);
871 
872 
877  virtual void onSegmentOffsetChanged(WindowEventArgs& e);
878 
879  /*************************************************************************
880  handlers for events we subscribe to from segments
881  *************************************************************************/
882  bool segmentSizedHandler(const EventArgs& e);
883  bool segmentMovedHandler(const EventArgs& e);
884  bool segmentClickedHandler(const EventArgs& e);
885  bool segmentDoubleClickHandler(const EventArgs& e);
886  bool segmentDragHandler(const EventArgs& e);
887 
888 
889  /*************************************************************************
890  Implementation Data
891  *************************************************************************/
892  typedef std::vector<ListHeaderSegment*> SegmentList;
893  SegmentList d_segments;
901 
902 
903 private:
904  /*************************************************************************
905  Static Properties for this class
906  *************************************************************************/
907  static ListHeaderProperties::SortSettingEnabled d_sortSettingProperty;
908  static ListHeaderProperties::ColumnsSizable d_sizableProperty;
909  static ListHeaderProperties::ColumnsMovable d_movableProperty;
910  static ListHeaderProperties::SortColumnID d_sortColumnIDProperty;
911  static ListHeaderProperties::SortDirection d_sortDirectionProperty;
912 
913 
914  /*************************************************************************
915  Private methods
916  *************************************************************************/
917  void addHeaderProperties(void);
918 };
919 
920 
921 } // End of CEGUI namespace section
922 
923 
924 #if defined(_MSC_VER)
925 # pragma warning(pop)
926 #endif
927 
928 #endif // end of guard _CEGUIListHeader_h_