Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
CEGUIScrollbar.h
1 /***********************************************************************
2  filename: CEGUIScrollbar.h
3  created: 13/4/2004
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIScrollbar_h_
29 #define _CEGUIScrollbar_h_
30 
31 #include "../CEGUIBase.h"
32 #include "../CEGUIWindow.h"
33 #include "CEGUIScrollbarProperties.h"
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
47 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer
48 {
49 public:
54  ScrollbarWindowRenderer(const String& name);
55 
61  virtual void updateThumb(void) = 0;
62 
72  virtual float getValueFromThumb(void) const = 0;
73 
87  virtual float getAdjustDirectionFromPoint(const Point& pt) const = 0;
88 };
89 
98 class CEGUIEXPORT Scrollbar : public Window
99 {
100 public:
102  static const String EventNamespace;
104  static const String WidgetTypeName;
105 
106  /*************************************************************************
107  Event name constants
108  *************************************************************************/
133 
134  /*************************************************************************
135  Child Widget name suffix constants
136  *************************************************************************/
138  static const String ThumbNameSuffix;
143 
144  /*************************************************************************
145  Accessor functions
146  *************************************************************************/
163  float getDocumentSize(void) const
164  {
165  return d_documentSize;
166  }
167 
185  float getPageSize(void) const
186  {
187  return d_pageSize;
188  }
189 
207  float getStepSize(void) const
208  {
209  return d_stepSize;
210  }
211 
229  float getOverlapSize(void) const
230  {
231  return d_overlapSize;
232  }
233 
250  float getScrollPosition(void) const
251  {
252  return d_position;
253  }
254 
266  PushButton* getIncreaseButton() const;
267 
279  PushButton* getDecreaseButton() const;
280 
291  Thumb* getThumb() const;
292 
293  /*************************************************************************
294  Manipulator Commands
295  *************************************************************************/
307  virtual void initialiseComponents(void);
308 
328  void setDocumentSize(float document_size);
329 
350  void setPageSize(float page_size);
351 
372  void setStepSize(float step_size);
373 
394  void setOverlapSize(float overlap_size);
395 
417  void setScrollPosition(float position);
418 
453  void setConfig(const float* const document_size,
454  const float* const page_size,
455  const float* const step_size,
456  const float* const overlap_size,
457  const float* const position);
458 
473  void setEndLockEnabled(const bool enabled);
474 
490  bool isEndLockEnabled() const;
491 
493  Scrollbar(const String& type, const String& name);
494 
496  virtual ~Scrollbar(void);
497 
498 protected:
504  void updateThumb(void);
505 
515  float getValueFromThumb(void) const;
516 
530  float getAdjustDirectionFromPoint(const Point& pt) const;
531 
535  bool setScrollPosition_impl(const float position);
536 
538  bool isAtEnd() const;
539 
541  float getMaxScrollPosition() const;
542 
544  bool handleThumbMoved(const EventArgs& e);
545 
547  bool handleIncreaseClicked(const EventArgs& e);
548 
550  bool handleDecreaseClicked(const EventArgs& e);
551 
553  bool handleThumbTrackStarted(const EventArgs& e);
554 
556  bool handleThumbTrackEnded(const EventArgs& e);
557 
569  virtual bool testClassName_impl(const String& class_name) const
570  {
571  if (class_name == "Scrollbar") return true;
572 
573  return Window::testClassName_impl(class_name);
574  }
575 
577  virtual bool validateWindowRenderer(const String& name) const
578  {
579  return (name == "Scrollbar");
580  }
581 
582  // New event handlers for slider widget
584  virtual void onScrollPositionChanged(WindowEventArgs& e);
585 
587  virtual void onThumbTrackStarted(WindowEventArgs& e);
588 
590  virtual void onThumbTrackEnded(WindowEventArgs& e);
591 
593  virtual void onScrollConfigChanged(WindowEventArgs& e);
594 
595  // Overridden event handlers
596  virtual void onMouseButtonDown(MouseEventArgs& e);
597  virtual void onMouseWheel(MouseEventArgs& e);
598 
599  // Implementation Data
603  float d_pageSize;
605  float d_stepSize;
609  float d_position;
612 
613 private:
614  // Static Properties for this class
615  static ScrollbarProperties::DocumentSize d_documentSizeProperty;
616  static ScrollbarProperties::PageSize d_pageSizeProperty;
617  static ScrollbarProperties::StepSize d_stepSizeProperty;
618  static ScrollbarProperties::OverlapSize d_overlapSizeProperty;
619  static ScrollbarProperties::ScrollPosition d_scrollPositionProperty;
620  static ScrollbarProperties::EndLockEnabled d_endLockEnabledProperty;
621 
623  void addScrollbarProperties(void);
624 };
625 
626 } // End of CEGUI namespace section
627 
628 #if defined(_MSC_VER)
629 # pragma warning(pop)
630 #endif
631 
632 #endif // end of guard _CEGUIScrollbar_h_
static const String DecreaseButtonNameSuffix
Widget name suffix for the decrease button component.
Definition: CEGUIScrollbar.h:142
Property to access the end lock mode setting for the Scrollbar.
Definition: CEGUIScrollbarProperties.h:182
Class used as a two dimensional vector (aka a Point)
Definition: CEGUIVector.h:45
Property to access the scroll position of the Scrollbar.
Definition: CEGUIScrollbarProperties.h:157
static const String EventScrollPositionChanged
Definition: CEGUIScrollbar.h:114
static const String EventThumbTrackStarted
Definition: CEGUIScrollbar.h:120
Property to access the page size for the Scrollbar.
Definition: CEGUIScrollbarProperties.h:83
virtual bool testClassName_impl(const String &class_name) const
Return whether this window was inherited from the given class name at some point in the inheritance h...
Definition: CEGUIScrollbar.h:569
static const String IncreaseButtonNameSuffix
Widget name suffix for the increase button component.
Definition: CEGUIScrollbar.h:140
static const String WidgetTypeName
Window factory name.
Definition: CEGUIScrollbar.h:104
static const String EventThumbTrackEnded
Definition: CEGUIScrollbar.h:126
Base class used as the argument to all subscribers Event object.
Definition: CEGUIEventArgs.h:52
Base scroll bar class.
Definition: CEGUIScrollbar.h:98
virtual bool testClassName_impl(const String &class_name) const
Return whether this window was inherited from the given class name at some point in the inheritance h...
Definition: CEGUIWindow.h:3928
float getPageSize(void) const
Return the page size for this scroll bar.
Definition: CEGUIScrollbar.h:185
static const String EventNamespace
Namespace for global events.
Definition: CEGUIScrollbar.h:102
Base class for Thumb widget.
Definition: CEGUIThumb.h:56
float d_overlapSize
Amount of overlap when jumping by a page.
Definition: CEGUIScrollbar.h:607
float getScrollPosition(void) const
Return the current position of scroll bar within the document.
Definition: CEGUIScrollbar.h:250
Property to access the document size for the Scrollbar.
Definition: CEGUIScrollbarProperties.h:58
static const String EventScrollConfigChanged
Definition: CEGUIScrollbar.h:132
Base-class for the assignable WindowRenderer object.
Definition: CEGUIWindowRenderer.h:51
float getStepSize(void) const
Return the step size for this scroll bar.
Definition: CEGUIScrollbar.h:207
float d_documentSize
The size of the document / data being scrolled thorugh.
Definition: CEGUIScrollbar.h:601
Property to access the step size for the Scrollbar.
Definition: CEGUIScrollbarProperties.h:108
float getDocumentSize(void) const
Return the size of the document or data.
Definition: CEGUIScrollbar.h:163
Property to access the overlap size for the Scrollbar.
Definition: CEGUIScrollbarProperties.h:133
bool d_endLockPosition
whether 'end lock' mode is enabled.
Definition: CEGUIScrollbar.h:611
Base class for Scrollbar window renderer objects.
Definition: CEGUIScrollbar.h:47
Base class to provide logic for push button type widgets.
Definition: CEGUIPushButton.h:48
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: CEGUIWindow.h:138
static const String ThumbNameSuffix
Widget name suffix for the thumb component.
Definition: CEGUIScrollbar.h:138
float d_pageSize
The size of a single 'page' of data.
Definition: CEGUIScrollbar.h:603
float d_stepSize
Step size used for increase / decrease button clicks.
Definition: CEGUIScrollbar.h:605
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: CEGUIInputEvent.h:245
EventArgs based class that is used for objects passed to input event handlers concerning mouse input...
Definition: CEGUIInputEvent.h:274
float d_position
Current scroll position.
Definition: CEGUIScrollbar.h:609
float getOverlapSize(void) const
Return the overlap size for this scroll bar.
Definition: CEGUIScrollbar.h:229
String class used within the GUI system.
Definition: CEGUIString.h:57
virtual bool validateWindowRenderer(const String &name) const
validate window renderer
Definition: CEGUIScrollbar.h:577