Crazy Eddie's GUI System  0.8.5
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 
268  void setSortDirection(SortDirection sort_dir);
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 
361  void initSizingHoverState(void);
362 
363 
368  void initSegmentHoverState(void);
369 
370 
383  bool isDragMoveThresholdExceeded(const Vector2f& local_mouse);
384 
385  /*************************************************************************
386  New Event Handlers
387  *************************************************************************/
392  virtual void onSegmentClicked(WindowEventArgs& e);
393 
394 
399  virtual void onSplitterDoubleClicked(WindowEventArgs& e);
400 
401 
406  virtual void onSizingSettingChanged(WindowEventArgs& e);
407 
408 
413  virtual void onSortDirectionChanged(WindowEventArgs& e);
414 
415 
420  virtual void onMovableSettingChanged(WindowEventArgs& e);
421 
422 
427  virtual void onSegmentDragStart(WindowEventArgs& e);
428 
429 
434  virtual void onSegmentDragStop(WindowEventArgs& e);
435 
436 
441  virtual void onSegmentDragPositionChanged(WindowEventArgs& e);
442 
443 
448  virtual void onSegmentSized(WindowEventArgs& e);
449 
450 
455  virtual void onClickableSettingChanged(WindowEventArgs& e);
456 
457 
458  /*************************************************************************
459  Overridden Event Handlers
460  *************************************************************************/
461  virtual void onMouseMove(MouseEventArgs& e);
462  virtual void onMouseButtonDown(MouseEventArgs& e);
463  virtual void onMouseButtonUp(MouseEventArgs& e);
464  virtual void onMouseDoubleClicked(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:
504  typedef return_type safe_method_return_type;
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_
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
SortDirection getSortDirection(void) const
Return the current sort direction set for this segment.
Definition: widgets/ListHeaderSegment.h:165
bool d_dragMoving
true when segment is being drag moved.
Definition: widgets/ListHeaderSegment.h:487
bool d_segmentHover
true when the mouse is within the segment area (and not in sizing area).
Definition: widgets/ListHeaderSegment.h:483
const Image * d_sizingMouseCursor
Image to use for mouse when sizing (typically set by derived class).
Definition: widgets/ListHeaderSegment.h:472
const Image * d_movingMouseCursor
Image to use for mouse when moving (typically set by derived class).
Definition: widgets/ListHeaderSegment.h:473
Interface for Image.
Definition: Image.h:158
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Vector2f d_dragPosition
position of dragged segment.
Definition: widgets/ListHeaderSegment.h:488
bool isSegmentHovering(void) const
Return whether the segment is currently in its hovering state.
Definition: widgets/ListHeaderSegment.h:202
static const String EventSegmentDragStart
Definition: widgets/ListHeaderSegment.h:94
bool isBeingDragMoved(void) const
Return whether the segment is currently being drag-moved.
Definition: widgets/ListHeaderSegment.h:223
static const String EventSegmentDragStop
Definition: widgets/ListHeaderSegment.h:100
bool d_movingEnabled
True when drag-moving is enabled for this segment;.
Definition: widgets/ListHeaderSegment.h:486
bool isClickable(void) const
Return whether the segment is clickable.
Definition: widgets/ListHeaderSegment.h:195
static const String EventSegmentClicked
Definition: widgets/ListHeaderSegment.h:64
static const String EventClickableSettingChanged
Definition: widgets/ListHeaderSegment.h:118
bool isSegmentPushed(void) const
Return whether the segment is currently in its pushed state.
Definition: widgets/ListHeaderSegment.h:209
bool d_splitterHover
True if the mouse is over the splitter.
Definition: widgets/ListHeaderSegment.h:476
float d_splitterSize
pixel width of the sizing area.
Definition: widgets/ListHeaderSegment.h:475
static const String EventSegmentSized
Definition: widgets/ListHeaderSegment.h:112
static const String EventSortDirectionChanged
Definition: widgets/ListHeaderSegment.h:82
bool d_segmentPushed
true when the left mouse button has been pressed within the confines of the segment.
Definition: widgets/ListHeaderSegment.h:484
SortDirection d_sortDir
Direction for sorting (used for deciding what icon to display).
Definition: widgets/ListHeaderSegment.h:481
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
Items under this segment should be sorted in descending order.
Definition: widgets/ListHeaderSegment.h:136
Helper class used to convert various data types to and from the format expected in Property strings...
Definition: ForwardRefs.h:84
bool isBeingDragSized(void) const
Return whether the segment is currently being drag-moved.
Definition: widgets/ListHeaderSegment.h:230
static const String EventSegmentDragPositionChanged
Definition: widgets/ListHeaderSegment.h:106
static const String EventSplitterDoubleClicked
Definition: widgets/ListHeaderSegment.h:70
bool isDragMovingEnabled(void) const
Return whether drag moving is enabled for this segment.
Definition: widgets/ListHeaderSegment.h:175
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 WidgetTypeName
Window factory name.
Definition: widgets/ListHeaderSegment.h:53
SortDirection
Enumeration of possible values for sorting direction used with ListHeaderSegment classes.
Definition: widgets/ListHeaderSegment.h:132
Vector2f d_dragPoint
point we are being dragged at when sizing or moving.
Definition: widgets/ListHeaderSegment.h:479
EventArgs based class that is used for objects passed to input event handlers concerning mouse input...
Definition: InputEvent.h:280
bool d_allowClicks
true if the segment can be clicked.
Definition: widgets/ListHeaderSegment.h:489
bool d_dragSizing
true when we are being sized.
Definition: widgets/ListHeaderSegment.h:478
bool isSizingEnabled(void) const
Return whether this segment can be sized.
Definition: widgets/ListHeaderSegment.h:150
bool isSplitterHovering(void) const
Return whether the splitter is currently in its hovering state.
Definition: widgets/ListHeaderSegment.h:216
static const String EventNamespace
Namespace for global events.
Definition: widgets/ListHeaderSegment.h:52
static const float SegmentMoveThreshold
Amount the mouse must be dragged before drag-moving is initiated.
Definition: widgets/ListHeaderSegment.h:122
Items under this segment should be sorted in ascending order.
Definition: widgets/ListHeaderSegment.h:135
Items under this segment should not be sorted.
Definition: widgets/ListHeaderSegment.h:134
String class used within the GUI system.
Definition: String.h:62
bool d_sizingEnabled
true when sizing is enabled for this segment.
Definition: widgets/ListHeaderSegment.h:485
static const String EventMovableSettingChanged
Definition: widgets/ListHeaderSegment.h:88
static const float DefaultSizingArea
Default size of the sizing area.
Definition: widgets/ListHeaderSegment.h:121
static const String EventSizingSettingChanged
Definition: widgets/ListHeaderSegment.h:76