Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/ListHeader.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 "../Base.h"
34 #include "../Window.h"
35 #include "./ListHeaderSegment.h"
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
50 class CEGUIEXPORT HeaderSequenceEventArgs : public WindowEventArgs
51 {
52 public:
53  HeaderSequenceEventArgs(Window* wnd, uint old_idx, uint new_idx) : WindowEventArgs(wnd), d_oldIdx(old_idx), d_newIdx(new_idx) {};
54 
55  uint d_oldIdx;
56  uint d_newIdx;
57 };
58 
63 class CEGUIEXPORT ListHeaderWindowRenderer : public WindowRenderer
64 {
65 public:
70  ListHeaderWindowRenderer(const String& name);
71 
83  virtual ListHeaderSegment* createNewSegment(const String& name) const = 0;
84 
96  virtual void destroyListSegment(ListHeaderSegment* segment) const = 0;
97 };
98 
99 
104 class CEGUIEXPORT ListHeader : public Window
105 {
106 public:
107  static const String EventNamespace;
108  static const String WidgetTypeName;
109 
110 
111  /*************************************************************************
112  Constants
113  *************************************************************************/
114  // Event names
131  static const String EventSegmentSized;
156  static const String EventSegmentAdded;
190 
191  // values
192  static const float ScrollSpeed;
193  static const float MinimumSegmentPixelWidth;
194 
195  /*************************************************************************
196  Child Widget name suffix constants
197  *************************************************************************/
199  static const String SegmentNameSuffix;
200 
201 
202  /*************************************************************************
203  Accessor Methods
204  *************************************************************************/
212  uint getColumnCount(void) const;
213 
214 
227  ListHeaderSegment& getSegmentFromColumn(uint column) const;
228 
229 
243  ListHeaderSegment& getSegmentFromID(uint id) const;
244 
245 
256  ListHeaderSegment& getSortSegment(void) const;
267  uint getSortSegmentID(void) const;
268 
269 
282  uint getColumnFromSegment(const ListHeaderSegment& segment) const;
283 
284 
297  uint getColumnFromID(uint id) const;
298 
299 
310  uint getSortColumn(void) const;
311 
312 
325  uint getColumnWithText(const String& text) const;
326 
327 
340  float getPixelOffsetToSegment(const ListHeaderSegment& segment) const;
341 
342 
356  float getPixelOffsetToColumn(uint column) const;
357 
358 
366  float getTotalSegmentsPixelExtent(void) const;
367 
368 
382  UDim getColumnWidth(uint column) const;
383 
384 
392  ListHeaderSegment::SortDirection getSortDirection(void) const;
393 
394 
403  bool isSortingEnabled(void) const;
404 
405 
413  bool isColumnSizingEnabled(void) const;
414 
415 
423  bool isColumnDraggingEnabled(void) const;
424 
425 
434  float getSegmentOffset(void) const {return d_segmentOffset;}
435 
436 
437  /*************************************************************************
438  Manipulator Methods
439  *************************************************************************/
451  void setSortingEnabled(bool setting);
452 
453 
464  void setSortDirection(ListHeaderSegment::SortDirection direction);
465 
466 
479  void setSortSegment(const ListHeaderSegment& segment);
480 
481 
494  void setSortColumn(uint column);
495 
496 
509  void setSortColumnFromID(uint id);
510 
511 
523  void setColumnSizingEnabled(bool setting);
524 
525 
537  void setColumnDraggingEnabled(bool setting);
538 
539 
556  void addColumn(const String& text, uint id, const UDim& width);
557 
558 
579  void insertColumn(const String& text, uint id, const UDim& width, uint position);
580 
581 
604  void insertColumn(const String& text, uint id, const UDim& width, const ListHeaderSegment& position);
605 
606 
619  void removeColumn(uint column);
620 
621 
634  void removeSegment(const ListHeaderSegment& segment);
635 
636 
653  void moveColumn(uint column, uint position);
654 
655 
674  void moveColumn(uint column, const ListHeaderSegment& position);
675 
676 
693  void moveSegment(const ListHeaderSegment& segment, uint position);
694 
695 
713  void moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position);
714 
715 
728  void setSegmentOffset(float offset);
729 
730 
747  void setColumnWidth(uint column, const UDim& width);
748 
749 
750  /*************************************************************************
751  Construction and Destruction
752  *************************************************************************/
757  ListHeader(const String& type, const String& name);
758 
759 
764  virtual ~ListHeader(void);
765 
766 
767 protected:
768  /*************************************************************************
769  Abstract Implementation Methods
770  *************************************************************************/
782  //virtual ListHeaderSegment* createNewSegment_impl(const String& name) const = 0;
783 
784 
796  //virtual void destroyListSegment_impl(ListHeaderSegment* segment) const = 0;
797 
798 
799  /*************************************************************************
800  Implementation Methods
801  *************************************************************************/
806  ListHeaderSegment* createInitialisedSegment(const String& text, uint id, const UDim& width);
807 
808 
813  void layoutSegments(void);
814 
826  ListHeaderSegment* createNewSegment(const String& name) const;
827 
828 
840  void destroyListSegment(ListHeaderSegment* segment) const;
841 
842  // validate window renderer
843  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
844 
845  /*************************************************************************
846  New List header event handlers
847  *************************************************************************/
852  virtual void onSortColumnChanged(WindowEventArgs& e);
853 
854 
859  virtual void onSortDirectionChanged(WindowEventArgs& e);
860 
861 
866  virtual void onSegmentSized(WindowEventArgs& e);
867 
868 
873  virtual void onSegmentClicked(WindowEventArgs& e);
874 
875 
880  virtual void onSplitterDoubleClicked(WindowEventArgs& e);
881 
882 
887  virtual void onSegmentSequenceChanged(WindowEventArgs& e);
888 
889 
894  virtual void onSegmentAdded(WindowEventArgs& e);
895 
896 
901  virtual void onSegmentRemoved(WindowEventArgs& e);
902 
903 
908  virtual void onSortSettingChanged(WindowEventArgs& e);
909 
910 
915  virtual void onDragMoveSettingChanged(WindowEventArgs& e);
916 
917 
922  virtual void onDragSizeSettingChanged(WindowEventArgs& e);
923 
924 
929  virtual void onSegmentOffsetChanged(WindowEventArgs& e);
930 
931  /*************************************************************************
932  handlers for events we subscribe to from segments
933  *************************************************************************/
934  bool segmentSizedHandler(const EventArgs& e);
935  bool segmentMovedHandler(const EventArgs& e);
936  bool segmentClickedHandler(const EventArgs& e);
937  bool segmentDoubleClickHandler(const EventArgs& e);
938  bool segmentDragHandler(const EventArgs& e);
939 
940 
941  /*************************************************************************
942  Implementation Data
943  *************************************************************************/
944  typedef std::vector<ListHeaderSegment*
945  CEGUI_VECTOR_ALLOC(ListHeaderSegment*)> SegmentList;
946  SegmentList d_segments;
954 
955 
956 private:
957  /*************************************************************************
958  Private methods
959  *************************************************************************/
960  void addHeaderProperties(void);
961 };
962 
963 
964 } // End of CEGUI namespace section
965 
966 
967 #if defined(_MSC_VER)
968 # pragma warning(pop)
969 #endif
970 
971 #endif // end of guard _CEGUIListHeader_h_