Crazy Eddie's GUI System  0.8.7
widgets/ListHeader.h
1 /***********************************************************************
2  created: 13/4/2004
3  author: Paul D Turner
4 
5  purpose: Interface to base class for ListHeader widget
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIListHeader_h_
30 #define _CEGUIListHeader_h_
31 
32 #include "../Base.h"
33 #include "../Window.h"
34 #include "./ListHeaderSegment.h"
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
49 class CEGUIEXPORT HeaderSequenceEventArgs : public WindowEventArgs
50 {
51 public:
52  HeaderSequenceEventArgs(Window* wnd, uint old_idx, uint new_idx) : WindowEventArgs(wnd), d_oldIdx(old_idx), d_newIdx(new_idx) {};
53 
54  uint d_oldIdx;
55  uint d_newIdx;
56 };
57 
62 class CEGUIEXPORT ListHeaderWindowRenderer : public WindowRenderer
63 {
64 public:
70 
82  virtual ListHeaderSegment* createNewSegment(const String& name) const = 0;
83 
95  virtual void destroyListSegment(ListHeaderSegment* segment) const = 0;
96 };
97 
98 
103 class CEGUIEXPORT ListHeader : public Window
104 {
105 public:
106  static const String EventNamespace;
107  static const String WidgetTypeName;
108 
109 
110  /*************************************************************************
111  Constants
112  *************************************************************************/
113  // Event names
130  static const String EventSegmentSized;
155  static const String EventSegmentAdded;
189 
190  // values
191  static const float ScrollSpeed;
192  static const float MinimumSegmentPixelWidth;
193 
194  /*************************************************************************
195  Child Widget name suffix constants
196  *************************************************************************/
198  static const String SegmentNameSuffix;
199 
200 
201  /*************************************************************************
202  Accessor Methods
203  *************************************************************************/
211  uint getColumnCount(void) const;
212 
213 
227 
228 
243 
244 
266  uint getSortSegmentID(void) const;
267 
268 
281  uint getColumnFromSegment(const ListHeaderSegment& segment) const;
282 
283 
296  uint getColumnFromID(uint id) const;
297 
298 
309  uint getSortColumn(void) const;
310 
311 
324  uint getColumnWithText(const String& text) const;
325 
326 
339  float getPixelOffsetToSegment(const ListHeaderSegment& segment) const;
340 
341 
355  float getPixelOffsetToColumn(uint column) const;
356 
357 
365  float getTotalSegmentsPixelExtent(void) const;
366 
367 
381  UDim getColumnWidth(uint column) const;
382 
383 
392 
393 
402  bool isSortingEnabled(void) const;
403 
404 
412  bool isColumnSizingEnabled(void) const;
413 
414 
422  bool isColumnDraggingEnabled(void) const;
423 
424 
433  float getSegmentOffset(void) const {return d_segmentOffset;}
434 
435 
436  /*************************************************************************
437  Manipulator Methods
438  *************************************************************************/
450  void setSortingEnabled(bool setting);
451 
452 
464 
465 
478  void setSortSegment(const ListHeaderSegment& segment);
479 
480 
493  void setSortColumn(uint column);
494 
495 
508  void setSortColumnFromID(uint id);
509 
510 
522  void setColumnSizingEnabled(bool setting);
523 
524 
536  void setColumnDraggingEnabled(bool setting);
537 
538 
555  void addColumn(const String& text, uint id, const UDim& width);
556 
557 
578  void insertColumn(const String& text, uint id, const UDim& width, uint position);
579 
580 
603  void insertColumn(const String& text, uint id, const UDim& width, const ListHeaderSegment& position);
604 
605 
618  void removeColumn(uint column);
619 
620 
633  void removeSegment(const ListHeaderSegment& segment);
634 
635 
652  void moveColumn(uint column, uint position);
653 
654 
673  void moveColumn(uint column, const ListHeaderSegment& position);
674 
675 
692  void moveSegment(const ListHeaderSegment& segment, uint position);
693 
694 
712  void moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position);
713 
714 
727  void setSegmentOffset(float offset);
728 
729 
746  void setColumnWidth(uint column, const UDim& width);
747 
748 
749  /*************************************************************************
750  Construction and Destruction
751  *************************************************************************/
756  ListHeader(const String& type, const String& name);
757 
758 
763  virtual ~ListHeader(void);
764 
765 
766 protected:
767  /*************************************************************************
768  Abstract Implementation Methods
769  *************************************************************************/
781  //virtual ListHeaderSegment* createNewSegment_impl(const String& name) const = 0;
782 
783 
795  //virtual void destroyListSegment_impl(ListHeaderSegment* segment) const = 0;
796 
797 
798  /*************************************************************************
799  Implementation Methods
800  *************************************************************************/
805  ListHeaderSegment* createInitialisedSegment(const String& text, uint id, const UDim& width);
806 
807 
812  void layoutSegments(void);
813 
826 
827 
839  void destroyListSegment(ListHeaderSegment* segment) const;
840 
841  // validate window renderer
842  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
843 
844  /*************************************************************************
845  New List header event handlers
846  *************************************************************************/
852 
853 
859 
860 
865  virtual void onSegmentSized(WindowEventArgs& e);
866 
867 
873 
874 
880 
881 
887 
888 
893  virtual void onSegmentAdded(WindowEventArgs& e);
894 
895 
901 
902 
908 
909 
915 
916 
922 
923 
929 
930  /*************************************************************************
931  handlers for events we subscribe to from segments
932  *************************************************************************/
933  bool segmentSizedHandler(const EventArgs& e);
934  bool segmentMovedHandler(const EventArgs& e);
935  bool segmentClickedHandler(const EventArgs& e);
936  bool segmentDoubleClickHandler(const EventArgs& e);
937  bool segmentDragHandler(const EventArgs& e);
938 
939 
940  /*************************************************************************
941  Implementation Data
942  *************************************************************************/
943  typedef std::vector<ListHeaderSegment*
944  CEGUI_VECTOR_ALLOC(ListHeaderSegment*)> SegmentList;
945  SegmentList d_segments;
953 
954 
955 private:
956  /*************************************************************************
957  Private methods
958  *************************************************************************/
959  void addHeaderProperties(void);
960 };
961 
962 
963 } // End of CEGUI namespace section
964 
965 
966 #if defined(_MSC_VER)
967 # pragma warning(pop)
968 #endif
969 
970 #endif // end of guard _CEGUIListHeader_h_
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
EventArgs class used for segment move (sequence changed) events.
Definition: widgets/ListHeader.h:50
uint d_newIdx
The new column index of the segment that has moved.
Definition: widgets/ListHeader.h:55
uint d_oldIdx
The original column index of the segment that has moved.
Definition: widgets/ListHeader.h:52
Base class for list header segment window.
Definition: widgets/ListHeaderSegment.h:50
SortDirection
Enumeration of possible values for sorting direction used with ListHeaderSegment classes.
Definition: widgets/ListHeaderSegment.h:133
Base class for the multi column list header window renderer.
Definition: widgets/ListHeader.h:63
virtual void destroyListSegment(ListHeaderSegment *segment) const =0
Cleanup and destroy the given ListHeaderSegment that was created via the createNewSegment method.
virtual ListHeaderSegment * createNewSegment(const String &name) const =0
Create and return a pointer to a new ListHeaderSegment based object.
ListHeaderWindowRenderer(const String &name)
Constructor.
Base class for the multi column list header widget.
Definition: widgets/ListHeader.h:104
void moveColumn(uint column, uint position)
Moves a column segment into a new position.
bool d_sortingEnabled
true if the sort criteria modifications by user are enabled (no sorting is actuall done)
Definition: widgets/ListHeader.h:948
void setSegmentOffset(float offset)
Set the current base segment offset. (This implements scrolling of the header segments within the hea...
UDim getColumnWidth(uint column) const
Return the width of the specified column.
static const String EventDragSizeSettingChanged
Definition: widgets/ListHeader.h:182
void moveColumn(uint column, const ListHeaderSegment &position)
Move a column segment to a new position.
static const String WidgetTypeName
Window factory name.
Definition: widgets/ListHeader.h:107
uint getColumnCount(void) const
Return the number of columns or segments attached to the header.
void removeColumn(uint column)
Removes a column segment from the ListHeader.
bool d_sizingEnabled
true if segments can be sized by the user.
Definition: widgets/ListHeader.h:947
static const String EventDragMoveSettingChanged
Definition: widgets/ListHeader.h:175
SegmentList d_segments
Attached segment windows in header order.
Definition: widgets/ListHeader.h:945
virtual void onSortColumnChanged(WindowEventArgs &e)
Handler called when the sort column is changed.
void moveSegment(const ListHeaderSegment &segment, uint position)
Moves a segment into a new position.
ListHeader(const String &type, const String &name)
Constructor for the list header base class.
void setColumnDraggingEnabled(bool setting)
Set whether columns may be reordered by the user via drag and drop.
static const String EventSegmentClicked
Definition: widgets/ListHeader.h:135
void setColumnWidth(uint column, const UDim &width)
Set the width of the specified column.
ListHeaderSegment & getSortSegment(void) const
Return the ListHeaderSegment that is marked as being the 'sort key' segment. There must be at least o...
static const String EventSortSettingChanged
Definition: widgets/ListHeader.h:168
void layoutSegments(void)
Layout the attached segments.
virtual void onDragMoveSettingChanged(WindowEventArgs &e)
Handler called when the setting that controls the users ability to drag and drop segments changes.
void removeSegment(const ListHeaderSegment &segment)
Remove the specified segment from the ListHeader.
virtual void onSegmentSequenceChanged(WindowEventArgs &e)
Handler called when the segment / column order changes.
static const String EventSegmentSized
Definition: widgets/ListHeader.h:130
void setSortColumn(uint column)
Set the column to be used as the sort column.
uint getSortSegmentID(void) const
Return the ListHeaderSegment ID that is marked as being the 'sort key' segment. There must be at leas...
bool isColumnDraggingEnabled(void) const
Return whether the user may modify the order of the segments.
virtual ~ListHeader(void)
Destructor for the list header base class.
static const float MinimumSegmentPixelWidth
Miniumum width of a segment in pixels.
Definition: widgets/ListHeader.h:192
static const String EventSegmentAdded
Definition: widgets/ListHeader.h:155
float getPixelOffsetToColumn(uint column) const
Return the pixel offset to the ListHeaderSegment at the given zero based column index.
static const String EventSortColumnChanged
Definition: widgets/ListHeader.h:119
void setSortDirection(ListHeaderSegment::SortDirection direction)
Set the current sort direction.
float getSegmentOffset(void) const
Return the current segment offset value. This value is used to implement scrolling of the header segm...
Definition: widgets/ListHeader.h:433
virtual void onSplitterDoubleClicked(WindowEventArgs &e)
Handler called when a segment splitter / sizer is double-clicked. e.window points to the segment.
bool d_movingEnabled
true if drag & drop moving of columns / segments is enabled.
Definition: widgets/ListHeader.h:949
virtual void onSortDirectionChanged(WindowEventArgs &e)
Handler called when the sort direction is changed.
ListHeaderSegment * d_sortSegment
Pointer to the segment that is currently set as the sork-key,.
Definition: widgets/ListHeader.h:946
ListHeaderSegment & getSegmentFromID(uint id) const
Return the ListHeaderSegment object with the specified ID.
ListHeaderSegment::SortDirection d_sortDir
Brief copy of the current sort direction.
Definition: widgets/ListHeader.h:952
virtual bool validateWindowRenderer(const WindowRenderer *renderer) const
Function used in checking if a WindowRenderer is valid for this window.
uint getColumnFromSegment(const ListHeaderSegment &segment) const
Return the zero based column index of the specified segment.
uint getColumnWithText(const String &text) const
Return the zero based column index of the segment with the specified text.
static const String SegmentNameSuffix
Widget name suffix for header segments.
Definition: widgets/ListHeader.h:198
void moveSegment(const ListHeaderSegment &segment, const ListHeaderSegment &position)
Move a segment to a new position.
virtual void onSegmentAdded(WindowEventArgs &e)
Handler called when a new segment is added to the header.
void setSortingEnabled(bool setting)
Set whether user manipulation of the sort column and direction is enabled.
bool isSortingEnabled(void) const
Return whether user manipulation of the sort column & direction are enabled.
void addColumn(const String &text, uint id, const UDim &width)
Add a new column segment to the end of the header.
ListHeaderSegment::SortDirection getSortDirection(void) const
Return the currently set sort direction.
float getTotalSegmentsPixelExtent(void) const
Return the total pixel width of all attached segments.
void setColumnSizingEnabled(bool setting)
Set whether columns may be sized by the user.
virtual void onSegmentSized(WindowEventArgs &e)
Handler called when a segment is sized by the user. e.window points to the segment.
float d_segmentOffset
Base offset used to layout the segments (allows scrolling within the window area)
Definition: widgets/ListHeader.h:951
ListHeaderSegment * createInitialisedSegment(const String &text, uint id, const UDim &width)
Create and return a pointer to a new ListHeaderSegment based object.
ListHeaderSegment * createNewSegment(const String &name) const
Create and return a pointer to a new ListHeaderSegment based object.
virtual void onSegmentOffsetChanged(WindowEventArgs &e)
Handler called when the base rendering offset for the segments (scroll position) changes.
ListHeaderSegment & getSegmentFromColumn(uint column) const
Return the ListHeaderSegment object for the specified column.
static const String EventSegmentRemoved
Definition: widgets/ListHeader.h:161
float getPixelOffsetToSegment(const ListHeaderSegment &segment) const
Return the pixel offset to the given ListHeaderSegment.
static const float ScrollSpeed
Speed to scroll at when dragging outside header.
Definition: widgets/ListHeader.h:191
virtual void onSortSettingChanged(WindowEventArgs &e)
Handler called then setting that controls the users ability to modify the search column & direction c...
void insertColumn(const String &text, uint id, const UDim &width, uint position)
uint d_uniqueIDNumber
field used to create unique names.
Definition: widgets/ListHeader.h:950
static const String EventSegmentSequenceChanged
Definition: widgets/ListHeader.h:149
static const String EventSegmentRenderOffsetChanged
Definition: widgets/ListHeader.h:188
void setSortSegment(const ListHeaderSegment &segment)
Set the column segment to be used as the sort column.
virtual void onDragSizeSettingChanged(WindowEventArgs &e)
Handler called when the setting that controls the users ability to size segments changes.
static const String EventNamespace
Namespace for global events.
Definition: widgets/ListHeader.h:106
virtual void onSegmentClicked(WindowEventArgs &e)
Handler called when a segment is clicked by the user. e.window points to the segment.
void insertColumn(const String &text, uint id, const UDim &width, const ListHeaderSegment &position)
void destroyListSegment(ListHeaderSegment *segment) const
Cleanup and destroy the given ListHeaderSegment that was created via the createNewSegment method.
void setSortColumnFromID(uint id)
Set the column to to be used for sorting via its ID code.
uint getSortColumn(void) const
Return the zero based index of the current sort column. There must be at least one segment/column to ...
static const String EventSortDirectionChanged
Definition: widgets/ListHeader.h:125
static const String EventSplitterDoubleClicked
Definition: widgets/ListHeader.h:141
uint getColumnFromID(uint id) const
Return the zero based column index of the segment with the specified ID.
virtual void onSegmentRemoved(WindowEventArgs &e)
Handler called when a segment is removed from the header.
bool isColumnSizingEnabled(void) const
Return whether the user may size column segments.
String class used within the GUI system.
Definition: String.h:64
Dimension that has both a relative 'scale' portion and and absolute 'offset' portion.
Definition: UDim.h:94
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
Base-class for the assignable WindowRenderer object.
Definition: WindowRenderer.h:52
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1