Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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
133  static const String EventSegmentSized;
158  static const String EventSegmentAdded;
192 
193  // values
194  static const float ScrollSpeed;
195  static const float MinimumSegmentPixelWidth;
196 
197  /*************************************************************************
198  Child Widget name suffix constants
199  *************************************************************************/
200  static const char SegmentNameSuffix[];
201 
202 
203  /*************************************************************************
204  Accessor Methods
205  *************************************************************************/
213  uint getColumnCount(void) const;
214 
215 
228  ListHeaderSegment& getSegmentFromColumn(uint column) const;
229 
230 
244  ListHeaderSegment& getSegmentFromID(uint id) const;
245 
246 
257  ListHeaderSegment& getSortSegment(void) const;
258 
259 
272  uint getColumnFromSegment(const ListHeaderSegment& segment) const;
273 
274 
287  uint getColumnFromID(uint id) const;
288 
289 
300  uint getSortColumn(void) const;
301 
302 
315  uint getColumnWithText(const String& text) const;
316 
317 
330  float getPixelOffsetToSegment(const ListHeaderSegment& segment) const;
331 
332 
346  float getPixelOffsetToColumn(uint column) const;
347 
348 
356  float getTotalSegmentsPixelExtent(void) const;
357 
358 
372  UDim getColumnWidth(uint column) const;
373 
374 
382  ListHeaderSegment::SortDirection getSortDirection(void) const;
383 
384 
393  bool isSortingEnabled(void) const;
394 
395 
403  bool isColumnSizingEnabled(void) const;
404 
405 
413  bool isColumnDraggingEnabled(void) const;
414 
415 
424  float getSegmentOffset(void) const {return d_segmentOffset;}
425 
426 
427  /*************************************************************************
428  Manipulator Methods
429  *************************************************************************/
441  void setSortingEnabled(bool setting);
442 
443 
454  void setSortDirection(ListHeaderSegment::SortDirection direction);
455 
456 
469  void setSortSegment(const ListHeaderSegment& segment);
470 
471 
484  void setSortColumn(uint column);
485 
486 
499  void setSortColumnFromID(uint id);
500 
501 
513  void setColumnSizingEnabled(bool setting);
514 
515 
527  void setColumnDraggingEnabled(bool setting);
528 
529 
546  void addColumn(const String& text, uint id, const UDim& width);
547 
548 
569  void insertColumn(const String& text, uint id, const UDim& width, uint position);
570 
571 
594  void insertColumn(const String& text, uint id, const UDim& width, const ListHeaderSegment& position);
595 
596 
609  void removeColumn(uint column);
610 
611 
624  void removeSegment(const ListHeaderSegment& segment);
625 
626 
643  void moveColumn(uint column, uint position);
644 
645 
664  void moveColumn(uint column, const ListHeaderSegment& position);
665 
666 
683  void moveSegment(const ListHeaderSegment& segment, uint position);
684 
685 
703  void moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position);
704 
705 
718  void setSegmentOffset(float offset);
719 
720 
737  void setColumnWidth(uint column, const UDim& width);
738 
739 
740  /*************************************************************************
741  Construction and Destruction
742  *************************************************************************/
747  ListHeader(const String& type, const String& name);
748 
749 
754  virtual ~ListHeader(void);
755 
756 
757 protected:
758  /*************************************************************************
759  Abstract Implementation Methods
760  *************************************************************************/
772  //virtual ListHeaderSegment* createNewSegment_impl(const String& name) const = 0;
773 
774 
786  //virtual void destroyListSegment_impl(ListHeaderSegment* segment) const = 0;
787 
788 
789  /*************************************************************************
790  Implementation Methods
791  *************************************************************************/
796  ListHeaderSegment* createInitialisedSegment(const String& text, uint id, const UDim& width);
797 
798 
803  void layoutSegments(void);
804 
805 
816  virtual bool testClassName_impl(const String& class_name) const
817  {
818  if (class_name=="ListHeader") return true;
819  return Window::testClassName_impl(class_name);
820  }
821 
822 
834  ListHeaderSegment* createNewSegment(const String& name) const;
835 
836 
848  void destroyListSegment(ListHeaderSegment* segment) const;
849 
850  // validate window renderer
851  virtual bool validateWindowRenderer(const String& name) const
852  {
853  return (name == "ListHeader");
854  }
855 
856  /*************************************************************************
857  New List header event handlers
858  *************************************************************************/
863  virtual void onSortColumnChanged(WindowEventArgs& e);
864 
865 
870  virtual void onSortDirectionChanged(WindowEventArgs& e);
871 
872 
877  virtual void onSegmentSized(WindowEventArgs& e);
878 
879 
884  virtual void onSegmentClicked(WindowEventArgs& e);
885 
886 
891  virtual void onSplitterDoubleClicked(WindowEventArgs& e);
892 
893 
898  virtual void onSegmentSequenceChanged(WindowEventArgs& e);
899 
900 
905  virtual void onSegmentAdded(WindowEventArgs& e);
906 
907 
912  virtual void onSegmentRemoved(WindowEventArgs& e);
913 
914 
919  virtual void onSortSettingChanged(WindowEventArgs& e);
920 
921 
926  virtual void onDragMoveSettingChanged(WindowEventArgs& e);
927 
928 
933  virtual void onDragSizeSettingChanged(WindowEventArgs& e);
934 
935 
940  virtual void onSegmentOffsetChanged(WindowEventArgs& e);
941 
942  /*************************************************************************
943  handlers for events we subscribe to from segments
944  *************************************************************************/
945  bool segmentSizedHandler(const EventArgs& e);
946  bool segmentMovedHandler(const EventArgs& e);
947  bool segmentClickedHandler(const EventArgs& e);
948  bool segmentDoubleClickHandler(const EventArgs& e);
949  bool segmentDragHandler(const EventArgs& e);
950 
951 
952  /*************************************************************************
953  Implementation Data
954  *************************************************************************/
955  typedef std::vector<ListHeaderSegment*> SegmentList;
956  SegmentList d_segments;
964 
965 
966 private:
967  /*************************************************************************
968  Static Properties for this class
969  *************************************************************************/
970  static ListHeaderProperties::SortSettingEnabled d_sortSettingProperty;
971  static ListHeaderProperties::ColumnsSizable d_sizableProperty;
972  static ListHeaderProperties::ColumnsMovable d_movableProperty;
973  static ListHeaderProperties::SortColumnID d_sortColumnIDProperty;
974  static ListHeaderProperties::SortDirection d_sortDirectionProperty;
975 
976 
977  /*************************************************************************
978  Private methods
979  *************************************************************************/
980  void addHeaderProperties(void);
981 };
982 
983 
984 } // End of CEGUI namespace section
985 
986 
987 #if defined(_MSC_VER)
988 # pragma warning(pop)
989 #endif
990 
991 #endif // end of guard _CEGUIListHeader_h_
virtual bool testClassName_impl(const String &class_name) const
Return whether this window was inherited from the given class name at some point in the inheritance h...
Definition: CEGUIListHeader.h:816
float d_segmentOffset
Base offset used to layout the segments (allows scrolling within the window area) ...
Definition: CEGUIListHeader.h:962
static const String EventSplitterDoubleClicked
Definition: CEGUIListHeader.h:144
uint d_newIdx
The new column index of the segment that has moved.
Definition: CEGUIListHeader.h:58
static const String EventSegmentRenderOffsetChanged
Definition: CEGUIListHeader.h:191
static const String EventSortDirectionChanged
Definition: CEGUIListHeader.h:128
static const String EventDragSizeSettingChanged
Definition: CEGUIListHeader.h:185
ListHeaderSegment * d_sortSegment
Pointer to the segment that is currently set as the sork-key,.
Definition: CEGUIListHeader.h:957
static const float ScrollSpeed
Speed to scroll at when dragging outside header.
Definition: CEGUIListHeader.h:194
bool d_movingEnabled
true if drag &amp; drop moving of columns / segments is enabled.
Definition: CEGUIListHeader.h:960
Base class used as the argument to all subscribers Event object.
Definition: CEGUIEventArgs.h:52
float getSegmentOffset(void) const
Return the current segment offset value. This value is used to implement scrolling of the header segm...
Definition: CEGUIListHeader.h:424
static const String EventSegmentRemoved
Definition: CEGUIListHeader.h:164
virtual bool testClassName_impl(const String &class_name) const
Return whether this window was inherited from the given class name at some point in the inheritance h...
Definition: CEGUIWindow.h:3928
bool d_sizingEnabled
true if segments can be sized by the user.
Definition: CEGUIListHeader.h:958
static const String EventSortSettingChanged
Definition: CEGUIListHeader.h:171
bool d_sortingEnabled
true if the sort criteria modifications by user are enabled (no sorting is actuall done) ...
Definition: CEGUIListHeader.h:959
Base-class for the assignable WindowRenderer object.
Definition: CEGUIWindowRenderer.h:51
static const String EventSegmentSequenceChanged
Definition: CEGUIListHeader.h:152
static const String EventSegmentClicked
Definition: CEGUIListHeader.h:138
static const String EventNamespace
Namespace for global events.
Definition: CEGUIListHeader.h:109
SegmentList d_segments
Attached segment windows in header order.
Definition: CEGUIListHeader.h:956
Property to access the current sort column (via ID code).
Definition: CEGUIListHeaderProperties.h:163
virtual bool validateWindowRenderer(const String &name) const
Function used in checking if a WindowRenderer is valid for this window.
Definition: CEGUIListHeader.h:851
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: CEGUIWindow.h:138
static const String EventSortColumnChanged
Definition: CEGUIListHeader.h:122
EventArgs class used for segment move (sequence changed) events.
Definition: CEGUIListHeader.h:52
static const String WidgetTypeName
Window factory name.
Definition: CEGUIListHeader.h:110
Property to access the sort direction setting of the list header.
Definition: CEGUIListHeaderProperties.h:138
Property to access the setting for user moving of the column headers.
Definition: CEGUIListHeaderProperties.h:85
Base class for list header segment window.
Definition: CEGUIListHeaderSegment.h:51
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: CEGUIInputEvent.h:245
Property to access the setting for user modification of the sort column &amp; direction.
Definition: CEGUIListHeaderProperties.h:111
static const String EventSegmentSized
Definition: CEGUIListHeader.h:133
SortDirection
Enumeration of possible values for sorting direction used with ListHeaderSegment classes.
Definition: CEGUIListHeaderSegment.h:134
Class representing a unified dimension; that is a dimension that has both a relative &#39;scale&#39; portion ...
Definition: CEGUIUDim.h:47
ListHeaderSegment::SortDirection d_sortDir
Brief copy of the current sort direction.
Definition: CEGUIListHeader.h:963
Base class for the multi column list header window renderer.
Definition: CEGUIListHeader.h:65
static const String EventDragMoveSettingChanged
Definition: CEGUIListHeader.h:178
Property to access the setting for user sizing of the column headers.
Definition: CEGUIListHeaderProperties.h:59
static const String EventSegmentAdded
Definition: CEGUIListHeader.h:158
Base class for the multi column list header widget.
Definition: CEGUIListHeader.h:106
String class used within the GUI system.
Definition: CEGUIString.h:57
uint d_uniqueIDNumber
field used to create unique names.
Definition: CEGUIListHeader.h:961
static const float MinimumSegmentPixelWidth
Miniumum width of a segment in pixels.
Definition: CEGUIListHeader.h:195