Crazy Eddie's GUI System  0.8.7
widgets/ListHeaderSegment.h
1 /***********************************************************************
2  created: 15/6/2004
3  author: Paul D Turner
4 
5  purpose: Interface to list header segment class.
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 _CEGUIListHeaderSegment_h_
30 #define _CEGUIListHeaderSegment_h_
31 
32 #include "../Base.h"
33 #include "../Window.h"
34 
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 ListHeaderSegment : public Window
50 {
51 public:
52  static const String EventNamespace;
53  static const String WidgetTypeName;
54 
55 
56  /*************************************************************************
57  Constants
58  *************************************************************************/
59  // Event names
112  static const String EventSegmentSized;
119 
120  // Defaults
121  static const float DefaultSizingArea;
122  static const float SegmentMoveThreshold;
123 
124 
125  /*************************************************************************
126  Enumerated types
127  *************************************************************************/
133  {
136  Descending
137  };
138 
139 
140  /*************************************************************************
141  Accessor Methods
142  *************************************************************************/
150  bool isSizingEnabled(void) const {return d_sizingEnabled;}
151 
152 
165  SortDirection getSortDirection(void) const {return d_sortDir;}
166 
167 
175  bool isDragMovingEnabled(void) const {return d_movingEnabled;}
176 
177 
185  const Vector2f& getDragMoveOffset(void) const {return d_dragPosition;}
186 
187 
195  bool isClickable(void) const {return d_allowClicks;}
196 
197 
202  bool isSegmentHovering(void) const {return d_segmentHover;}
203 
204 
209  bool isSegmentPushed(void) const {return d_segmentPushed;}
210 
211 
216  bool isSplitterHovering(void) const {return d_splitterHover;}
217 
218 
223  bool isBeingDragMoved(void) const {return d_dragMoving;}
224 
225 
230  bool isBeingDragSized(void) const {return d_dragSizing;}
231 
232 
233  const Image* getSizingCursorImage() const;
234  const Image* getMovingCursorImage() const;
235 
236 
237  /*************************************************************************
238  Manipulator Methods
239  *************************************************************************/
250  void setSizingEnabled(bool setting);
251 
252 
269 
270 
281  void setDragMovingEnabled(bool setting);
282 
283 
294  void setClickable(bool setting);
295 
296 
297  void setSizingCursorImage(const Image* image);
298  void setSizingCursorImage(const String& name);
299  void setMovingCursorImage(const Image* image);
300  void setMovingCursorImage(const String& name);
301 
302 
303  /*************************************************************************
304  Construction & Destruction
305  *************************************************************************/
310  ListHeaderSegment(const String& type, const String& name);
311 
312 
317  virtual ~ListHeaderSegment(void);
318 
319 
320 protected:
321  /*************************************************************************
322  Implementation Methods
323  *************************************************************************/
334  void doDragSizing(const Vector2f& local_mouse);
335 
336 
347  void doDragMoving(const Vector2f& local_mouse);
348 
349 
354  void initDragMoving(void);
355 
356 
362 
363 
369 
370 
383  bool isDragMoveThresholdExceeded(const Vector2f& local_mouse);
384 
385  /*************************************************************************
386  New Event Handlers
387  *************************************************************************/
393 
394 
400 
401 
407 
408 
414 
415 
421 
422 
428 
429 
435 
436 
442 
443 
448  virtual void onSegmentSized(WindowEventArgs& e);
449 
450 
456 
457 
458  /*************************************************************************
459  Overridden Event Handlers
460  *************************************************************************/
461  virtual void onMouseMove(MouseEventArgs& e);
463  virtual void onMouseButtonUp(MouseEventArgs& e);
465  virtual void onMouseLeaves(MouseEventArgs& e);
466  virtual void onCaptureLost(WindowEventArgs& e);
467 
468 
469  /*************************************************************************
470  Implementation Data
471  *************************************************************************/
474 
477 
480 
482 
490 
491 private:
492  /*************************************************************************
493  Private methods
494  *************************************************************************/
495  void addHeaderSegmentProperties(void);
496 };
497 
498 
499 template<>
500 class PropertyHelper<ListHeaderSegment::SortDirection>
501 {
502 public:
506  typedef String string_return_type;
507 
508  static const String& getDataTypeName()
509  {
510  static String type("SortDirection");
511 
512  return type;
513  }
514 
515  static return_type fromString(const String& str)
516  {
517  if (str == "Ascending")
518  {
520  }
521  else if (str == "Descending")
522  {
524  }
525  else
526  {
528  }
529  }
530 
531  static string_return_type toString(pass_type val)
532  {
533  if (val == ListHeaderSegment::None)
534  {
535  return "None";
536  }
537  else if (val == ListHeaderSegment::Ascending)
538  {
539  return "Ascending";
540  }
541  else if (val == ListHeaderSegment::Descending)
542  {
543  return "Descending";
544  }
545  else
546  {
547  assert(false && "Invalid Sort Direction");
548  return "Ascending";
549  }
550  }
551 };
552 
553 } // End of CEGUI namespace section
554 
555 #if defined(_MSC_VER)
556 # pragma warning(pop)
557 #endif
558 
559 #endif // end of guard _CEGUIListHeaderSegment_h_
CEGUI::ListHeaderSegment::onSegmentClicked
virtual void onSegmentClicked(WindowEventArgs &e)
Handler called when segment is clicked.
CEGUI::ListHeaderSegment::onMouseDoubleClicked
virtual void onMouseDoubleClicked(MouseEventArgs &e)
Handler called when a mouse button has been double-clicked within this window's area.
CEGUI::ListHeaderSegment::d_sizingMouseCursor
const Image * d_sizingMouseCursor
Image to use for mouse when sizing (typically set by derived class).
Definition: widgets/ListHeaderSegment.h:472
CEGUI::ListHeaderSegment::initSegmentHoverState
void initSegmentHoverState(void)
Initialise the required states when we are hovering over the main segment area.
CEGUI::ListHeaderSegment::Ascending
@ Ascending
Items under this segment should be sorted in ascending order.
Definition: widgets/ListHeaderSegment.h:135
CEGUI::ListHeaderSegment::EventSortDirectionChanged
static const String EventSortDirectionChanged
Definition: widgets/ListHeaderSegment.h:82
CEGUI::ListHeaderSegment::d_segmentHover
bool d_segmentHover
true when the mouse is within the segment area (and not in sizing area).
Definition: widgets/ListHeaderSegment.h:483
CEGUI::ListHeaderSegment::d_splitterSize
float d_splitterSize
pixel width of the sizing area.
Definition: widgets/ListHeaderSegment.h:475
CEGUI::ListHeaderSegment::d_sortDir
SortDirection d_sortDir
Direction for sorting (used for deciding what icon to display).
Definition: widgets/ListHeaderSegment.h:481
CEGUI::ListHeaderSegment::initDragMoving
void initDragMoving(void)
Initialise the required states to put the widget into drag-moving mode.
CEGUI::ListHeaderSegment::EventSegmentClicked
static const String EventSegmentClicked
Definition: widgets/ListHeaderSegment.h:64
CEGUI::ListHeaderSegment::EventSegmentSized
static const String EventSegmentSized
Definition: widgets/ListHeaderSegment.h:112
CEGUI::ListHeaderSegment::EventSegmentDragStop
static const String EventSegmentDragStop
Definition: widgets/ListHeaderSegment.h:100
CEGUI::ListHeaderSegment::d_segmentPushed
bool d_segmentPushed
true when the left mouse button has been pressed within the confines of the segment.
Definition: widgets/ListHeaderSegment.h:484
CEGUI::ListHeaderSegment::onSizingSettingChanged
virtual void onSizingSettingChanged(WindowEventArgs &e)
Handler called when sizing setting changes.
CEGUI::ListHeaderSegment::SegmentMoveThreshold
static const float SegmentMoveThreshold
Amount the mouse must be dragged before drag-moving is initiated.
Definition: widgets/ListHeaderSegment.h:122
CEGUI::ListHeaderSegment::onMouseLeaves
virtual void onMouseLeaves(MouseEventArgs &e)
Handler called when the mouse cursor is no longer over this window's surface area....
CEGUI::ListHeaderSegment::onMouseButtonDown
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
CEGUI::ListHeaderSegment::onSegmentSized
virtual void onSegmentSized(WindowEventArgs &e)
Handler called when the segment is sized.
CEGUI::ListHeaderSegment::d_dragPosition
Vector2f d_dragPosition
position of dragged segment.
Definition: widgets/ListHeaderSegment.h:488
CEGUI::ListHeaderSegment::initSizingHoverState
void initSizingHoverState(void)
Initialise the required states when we are hovering over the sizing area.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::MouseEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition: InputEvent.h:281
CEGUI::ListHeaderSegment::d_dragSizing
bool d_dragSizing
true when we are being sized.
Definition: widgets/ListHeaderSegment.h:478
CEGUI::ListHeaderSegment::isSplitterHovering
bool isSplitterHovering(void) const
Return whether the splitter is currently in its hovering state.
Definition: widgets/ListHeaderSegment.h:216
CEGUI::ListHeaderSegment::onSegmentDragStop
virtual void onSegmentDragStop(WindowEventArgs &e)
Handler called when the user stops dragging the segment (releases mouse button)
CEGUI::ListHeaderSegment::isSizingEnabled
bool isSizingEnabled(void) const
Return whether this segment can be sized.
Definition: widgets/ListHeaderSegment.h:150
CEGUI::ListHeaderSegment::setDragMovingEnabled
void setDragMovingEnabled(bool setting)
Set whether drag moving is allowed for this segment.
CEGUI::Vector2< float >
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
CEGUI::ListHeaderSegment::isDragMovingEnabled
bool isDragMovingEnabled(void) const
Return whether drag moving is enabled for this segment.
Definition: widgets/ListHeaderSegment.h:175
CEGUI::ListHeaderSegment::onMouseButtonUp
virtual void onMouseButtonUp(MouseEventArgs &e)
Handler called when a mouse button has been released within this window's area.
CEGUI::ListHeaderSegment::WidgetTypeName
static const String WidgetTypeName
Window factory name.
Definition: widgets/ListHeaderSegment.h:53
CEGUI::ListHeaderSegment::onSortDirectionChanged
virtual void onSortDirectionChanged(WindowEventArgs &e)
Handler called when the sort direction value changes.
CEGUI::ListHeaderSegment::isSegmentHovering
bool isSegmentHovering(void) const
Return whether the segment is currently in its hovering state.
Definition: widgets/ListHeaderSegment.h:202
CEGUI::ListHeaderSegment::isBeingDragMoved
bool isBeingDragMoved(void) const
Return whether the segment is currently being drag-moved.
Definition: widgets/ListHeaderSegment.h:223
CEGUI::ListHeaderSegment::isClickable
bool isClickable(void) const
Return whether the segment is clickable.
Definition: widgets/ListHeaderSegment.h:195
CEGUI::ListHeaderSegment::d_dragMoving
bool d_dragMoving
true when segment is being drag moved.
Definition: widgets/ListHeaderSegment.h:487
CEGUI::ListHeaderSegment::doDragMoving
void doDragMoving(const Vector2f &local_mouse)
Update state for drag moving.
CEGUI::ListHeaderSegment::d_sizingEnabled
bool d_sizingEnabled
true when sizing is enabled for this segment.
Definition: widgets/ListHeaderSegment.h:485
CEGUI::ListHeaderSegment::d_movingMouseCursor
const Image * d_movingMouseCursor
Image to use for mouse when moving (typically set by derived class).
Definition: widgets/ListHeaderSegment.h:473
CEGUI::ListHeaderSegment::ListHeaderSegment
ListHeaderSegment(const String &type, const String &name)
Constructor for list header segment base class.
CEGUI::ListHeaderSegment::d_dragPoint
Vector2f d_dragPoint
point we are being dragged at when sizing or moving.
Definition: widgets/ListHeaderSegment.h:479
CEGUI::ListHeaderSegment::Descending
@ Descending
Items under this segment should be sorted in descending order.
Definition: widgets/ListHeaderSegment.h:136
CEGUI::ListHeaderSegment::onSegmentDragStart
virtual void onSegmentDragStart(WindowEventArgs &e)
Handler called when the user starts dragging the segment.
CEGUI::ListHeaderSegment::onMouseMove
virtual void onMouseMove(MouseEventArgs &e)
Handler called when the mouse cursor has been moved within this window's area.
CEGUI::ListHeaderSegment::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: widgets/ListHeaderSegment.h:52
CEGUI::ListHeaderSegment::onCaptureLost
virtual void onCaptureLost(WindowEventArgs &e)
Handler called when this window loses capture of mouse inputs.
CEGUI::ListHeaderSegment::EventMovableSettingChanged
static const String EventMovableSettingChanged
Definition: widgets/ListHeaderSegment.h:88
CEGUI::ListHeaderSegment::d_allowClicks
bool d_allowClicks
true if the segment can be clicked.
Definition: widgets/ListHeaderSegment.h:489
CEGUI::ListHeaderSegment::isBeingDragSized
bool isBeingDragSized(void) const
Return whether the segment is currently being drag-moved.
Definition: widgets/ListHeaderSegment.h:230
CEGUI::ListHeaderSegment::d_movingEnabled
bool d_movingEnabled
True when drag-moving is enabled for this segment;.
Definition: widgets/ListHeaderSegment.h:486
CEGUI::ListHeaderSegment::onMovableSettingChanged
virtual void onMovableSettingChanged(WindowEventArgs &e)
Handler called when the drag-movable setting is changed.
CEGUI::ListHeaderSegment::getDragMoveOffset
const Vector2f & getDragMoveOffset(void) const
Return the current drag move position offset (in pixels relative to the top-left corner of the segmen...
Definition: widgets/ListHeaderSegment.h:185
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::ListHeaderSegment::setClickable
void setClickable(bool setting)
Set whether the segment is clickable.
CEGUI::ListHeaderSegment::doDragSizing
void doDragSizing(const Vector2f &local_mouse)
Update state for drag sizing.
CEGUI::ListHeaderSegment::EventSegmentDragStart
static const String EventSegmentDragStart
Definition: widgets/ListHeaderSegment.h:94
CEGUI::ListHeaderSegment::getSortDirection
SortDirection getSortDirection(void) const
Return the current sort direction set for this segment.
Definition: widgets/ListHeaderSegment.h:165
CEGUI::ListHeaderSegment::SortDirection
SortDirection
Enumeration of possible values for sorting direction used with ListHeaderSegment classes.
Definition: widgets/ListHeaderSegment.h:133
CEGUI::ListHeaderSegment
Base class for list header segment window.
Definition: widgets/ListHeaderSegment.h:50
CEGUI::ListHeaderSegment::onSplitterDoubleClicked
virtual void onSplitterDoubleClicked(WindowEventArgs &e)
Handler called when the sizer/splitter is double-clicked.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::ListHeaderSegment::onClickableSettingChanged
virtual void onClickableSettingChanged(WindowEventArgs &e)
Handler called when the clickable setting for the segment changes.
CEGUI::ListHeaderSegment::EventSplitterDoubleClicked
static const String EventSplitterDoubleClicked
Definition: widgets/ListHeaderSegment.h:70
CEGUI::ListHeaderSegment::None
@ None
Items under this segment should not be sorted.
Definition: widgets/ListHeaderSegment.h:134
CEGUI::ListHeaderSegment::isSegmentPushed
bool isSegmentPushed(void) const
Return whether the segment is currently in its pushed state.
Definition: widgets/ListHeaderSegment.h:209
CEGUI::ListHeaderSegment::EventSegmentDragPositionChanged
static const String EventSegmentDragPositionChanged
Definition: widgets/ListHeaderSegment.h:106
CEGUI::ListHeaderSegment::~ListHeaderSegment
virtual ~ListHeaderSegment(void)
Destructor for list header segment base class.
CEGUI::Image
Interface for Image.
Definition: Image.h:161
CEGUI::PropertyHelper
Helper class used to convert various data types to and from the format expected in Property strings.
Definition: ForwardRefs.h:84
CEGUI::ListHeaderSegment::EventClickableSettingChanged
static const String EventClickableSettingChanged
Definition: widgets/ListHeaderSegment.h:118
CEGUI::ListHeaderSegment::onSegmentDragPositionChanged
virtual void onSegmentDragPositionChanged(WindowEventArgs &e)
Handler called when the drag position changes.
CEGUI::ListHeaderSegment::isDragMoveThresholdExceeded
bool isDragMoveThresholdExceeded(const Vector2f &local_mouse)
Return whether the required minimum movement threshold before initiating drag-moving has been exceede...
CEGUI::ListHeaderSegment::d_splitterHover
bool d_splitterHover
True if the mouse is over the splitter.
Definition: widgets/ListHeaderSegment.h:476
CEGUI::ListHeaderSegment::setSortDirection
void setSortDirection(SortDirection sort_dir)
Set the current sort direction set for this segment.
CEGUI::ListHeaderSegment::setSizingEnabled
void setSizingEnabled(bool setting)
Set whether this segment can be sized.
CEGUI::ListHeaderSegment::DefaultSizingArea
static const float DefaultSizingArea
Default size of the sizing area.
Definition: widgets/ListHeaderSegment.h:121
CEGUI::ListHeaderSegment::EventSizingSettingChanged
static const String EventSizingSettingChanged
Definition: widgets/ListHeaderSegment.h:76