Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
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:
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_