Crazy Eddie's GUI System  0.8.5
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:
69  ListHeaderWindowRenderer(const String& name);
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 
226  ListHeaderSegment& getSegmentFromColumn(uint column) const;
227 
228 
242  ListHeaderSegment& getSegmentFromID(uint id) const;
243 
244 
255  ListHeaderSegment& getSortSegment(void) const;
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 
391  ListHeaderSegment::SortDirection getSortDirection(void) const;
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 
463  void setSortDirection(ListHeaderSegment::SortDirection direction);
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 
825  ListHeaderSegment* createNewSegment(const String& name) const;
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  *************************************************************************/
851  virtual void onSortColumnChanged(WindowEventArgs& e);
852 
853 
858  virtual void onSortDirectionChanged(WindowEventArgs& e);
859 
860 
865  virtual void onSegmentSized(WindowEventArgs& e);
866 
867 
872  virtual void onSegmentClicked(WindowEventArgs& e);
873 
874 
879  virtual void onSplitterDoubleClicked(WindowEventArgs& e);
880 
881 
886  virtual void onSegmentSequenceChanged(WindowEventArgs& e);
887 
888 
893  virtual void onSegmentAdded(WindowEventArgs& e);
894 
895 
900  virtual void onSegmentRemoved(WindowEventArgs& e);
901 
902 
907  virtual void onSortSettingChanged(WindowEventArgs& e);
908 
909 
914  virtual void onDragMoveSettingChanged(WindowEventArgs& e);
915 
916 
921  virtual void onDragSizeSettingChanged(WindowEventArgs& e);
922 
923 
928  virtual void onSegmentOffsetChanged(WindowEventArgs& e);
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_
float d_segmentOffset
Base offset used to layout the segments (allows scrolling within the window area) ...
Definition: widgets/ListHeader.h:951
static const String EventSplitterDoubleClicked
Definition: widgets/ListHeader.h:141
uint d_newIdx
The new column index of the segment that has moved.
Definition: widgets/ListHeader.h:55
static const String EventSegmentRenderOffsetChanged
Definition: widgets/ListHeader.h:188
static const String EventSortDirectionChanged
Definition: widgets/ListHeader.h:125
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
static const String EventDragSizeSettingChanged
Definition: widgets/ListHeader.h:182
ListHeaderSegment * d_sortSegment
Pointer to the segment that is currently set as the sork-key,.
Definition: widgets/ListHeader.h:946
static const float ScrollSpeed
Speed to scroll at when dragging outside header.
Definition: widgets/ListHeader.h:191
bool d_movingEnabled
true if drag & drop moving of columns / segments is enabled.
Definition: widgets/ListHeader.h:949
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
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
static const String EventSegmentRemoved
Definition: widgets/ListHeader.h:161
bool d_sizingEnabled
true if segments can be sized by the user.
Definition: widgets/ListHeader.h:947
static const String EventSortSettingChanged
Definition: widgets/ListHeader.h:168
bool d_sortingEnabled
true if the sort criteria modifications by user are enabled (no sorting is actuall done) ...
Definition: widgets/ListHeader.h:948
Base-class for the assignable WindowRenderer object.
Definition: WindowRenderer.h:50
static const String EventSegmentSequenceChanged
Definition: widgets/ListHeader.h:149
static const String EventSegmentClicked
Definition: widgets/ListHeader.h:135
static const String EventNamespace
Namespace for global events.
Definition: widgets/ListHeader.h:106
SegmentList d_segments
Attached segment windows in header order.
Definition: widgets/ListHeader.h:945
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
static const String EventSortColumnChanged
Definition: widgets/ListHeader.h:119
EventArgs class used for segment move (sequence changed) events.
Definition: widgets/ListHeader.h:49
static const String WidgetTypeName
Window factory name.
Definition: widgets/ListHeader.h:107
Base class for list header segment window.
Definition: widgets/ListHeaderSegment.h:49
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:251
static const String EventSegmentSized
Definition: widgets/ListHeader.h:130
SortDirection
Enumeration of possible values for sorting direction used with ListHeaderSegment classes.
Definition: widgets/ListHeaderSegment.h:132
Dimension that has both a relative 'scale' portion and and absolute 'offset' portion.
Definition: UDim.h:92
ListHeaderSegment::SortDirection d_sortDir
Brief copy of the current sort direction.
Definition: widgets/ListHeader.h:952
Base class for the multi column list header window renderer.
Definition: widgets/ListHeader.h:62
static const String EventDragMoveSettingChanged
Definition: widgets/ListHeader.h:175
static const String EventSegmentAdded
Definition: widgets/ListHeader.h:155
Base class for the multi column list header widget.
Definition: widgets/ListHeader.h:103
String class used within the GUI system.
Definition: String.h:62
uint d_uniqueIDNumber
field used to create unique names.
Definition: widgets/ListHeader.h:950
static const String SegmentNameSuffix
Widget name suffix for header segments.
Definition: widgets/ListHeader.h:198
static const float MinimumSegmentPixelWidth
Miniumum width of a segment in pixels.
Definition: widgets/ListHeader.h:192