Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/ListHeaderSegment.h
1 /***********************************************************************
2  filename: CEGUIListHeaderSegment.h
3  created: 15/6/2004
4  author: Paul D Turner
5 
6  purpose: Interface to list header segment class.
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIListHeaderSegment_h_
31 #define _CEGUIListHeaderSegment_h_
32 
33 #include "../Base.h"
34 #include "../Window.h"
35 
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
50 class CEGUIEXPORT ListHeaderSegment : public Window
51 {
52 public:
53  static const String EventNamespace;
54  static const String WidgetTypeName;
55 
56 
57  /*************************************************************************
58  Constants
59  *************************************************************************/
60  // Event names
113  static const String EventSegmentSized;
120 
121  // Defaults
122  static const float DefaultSizingArea;
123  static const float SegmentMoveThreshold;
124 
125 
126  /*************************************************************************
127  Enumerated types
128  *************************************************************************/
134  {
137  Descending
138  };
139 
140 
141  /*************************************************************************
142  Accessor Methods
143  *************************************************************************/
151  bool isSizingEnabled(void) const {return d_sizingEnabled;}
152 
153 
166  SortDirection getSortDirection(void) const {return d_sortDir;}
167 
168 
176  bool isDragMovingEnabled(void) const {return d_movingEnabled;}
177 
178 
186  const Vector2f& getDragMoveOffset(void) const {return d_dragPosition;}
187 
188 
196  bool isClickable(void) const {return d_allowClicks;}
197 
198 
203  bool isSegmentHovering(void) const {return d_segmentHover;}
204 
205 
210  bool isSegmentPushed(void) const {return d_segmentPushed;}
211 
212 
217  bool isSplitterHovering(void) const {return d_splitterHover;}
218 
219 
224  bool isBeingDragMoved(void) const {return d_dragMoving;}
225 
226 
231  bool isBeingDragSized(void) const {return d_dragSizing;}
232 
233 
234  const Image* getSizingCursorImage() const;
235  const Image* getMovingCursorImage() const;
236 
237 
238  /*************************************************************************
239  Manipulator Methods
240  *************************************************************************/
251  void setSizingEnabled(bool setting);
252 
253 
269  void setSortDirection(SortDirection sort_dir);
270 
271 
282  void setDragMovingEnabled(bool setting);
283 
284 
295  void setClickable(bool setting);
296 
297 
298  void setSizingCursorImage(const Image* image);
299  void setSizingCursorImage(const String& name);
300  void setMovingCursorImage(const Image* image);
301  void setMovingCursorImage(const String& name);
302 
303 
304  /*************************************************************************
305  Construction & Destruction
306  *************************************************************************/
311  ListHeaderSegment(const String& type, const String& name);
312 
313 
318  virtual ~ListHeaderSegment(void);
319 
320 
321 protected:
322  /*************************************************************************
323  Implementation Methods
324  *************************************************************************/
335  void doDragSizing(const Vector2f& local_mouse);
336 
337 
348  void doDragMoving(const Vector2f& local_mouse);
349 
350 
355  void initDragMoving(void);
356 
357 
362  void initSizingHoverState(void);
363 
364 
369  void initSegmentHoverState(void);
370 
371 
384  bool isDragMoveThresholdExceeded(const Vector2f& local_mouse);
385 
386  /*************************************************************************
387  New Event Handlers
388  *************************************************************************/
393  virtual void onSegmentClicked(WindowEventArgs& e);
394 
395 
400  virtual void onSplitterDoubleClicked(WindowEventArgs& e);
401 
402 
407  virtual void onSizingSettingChanged(WindowEventArgs& e);
408 
409 
414  virtual void onSortDirectionChanged(WindowEventArgs& e);
415 
416 
421  virtual void onMovableSettingChanged(WindowEventArgs& e);
422 
423 
428  virtual void onSegmentDragStart(WindowEventArgs& e);
429 
430 
435  virtual void onSegmentDragStop(WindowEventArgs& e);
436 
437 
442  virtual void onSegmentDragPositionChanged(WindowEventArgs& e);
443 
444 
449  virtual void onSegmentSized(WindowEventArgs& e);
450 
451 
456  virtual void onClickableSettingChanged(WindowEventArgs& e);
457 
458 
459  /*************************************************************************
460  Overridden Event Handlers
461  *************************************************************************/
462  virtual void onMouseMove(MouseEventArgs& e);
463  virtual void onMouseButtonDown(MouseEventArgs& e);
464  virtual void onMouseButtonUp(MouseEventArgs& e);
465  virtual void onMouseDoubleClicked(MouseEventArgs& e);
466  virtual void onMouseLeaves(MouseEventArgs& e);
467  virtual void onCaptureLost(WindowEventArgs& e);
468 
469 
470  /*************************************************************************
471  Implementation Data
472  *************************************************************************/
475 
478 
481 
483 
491 
492 private:
493  /*************************************************************************
494  Private methods
495  *************************************************************************/
496  void addHeaderSegmentProperties(void);
497 };
498 
499 
500 template<>
501 class PropertyHelper<ListHeaderSegment::SortDirection>
502 {
503 public:
507  typedef String string_return_type;
508 
509  static const String& getDataTypeName()
510  {
511  static String type("SortDirection");
512 
513  return type;
514  }
515 
516  static return_type fromString(const String& str)
517  {
518  if (str == "Ascending")
519  {
521  }
522  else if (str == "Descending")
523  {
525  }
526  else
527  {
529  }
530  }
531 
532  static string_return_type toString(pass_type val)
533  {
534  if (val == ListHeaderSegment::None)
535  {
536  return "None";
537  }
538  else if (val == ListHeaderSegment::Ascending)
539  {
540  return "Ascending";
541  }
542  else if (val == ListHeaderSegment::Descending)
543  {
544  return "Descending";
545  }
546  else
547  {
548  assert(false && "Invalid Sort Direction");
549  return "Ascending";
550  }
551  }
552 };
553 
554 } // End of CEGUI namespace section
555 
556 #if defined(_MSC_VER)
557 # pragma warning(pop)
558 #endif
559 
560 #endif // end of guard _CEGUIListHeaderSegment_h_