Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/Scrollbar.h
1 /***********************************************************************
2  created: 13/4/2004
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIScrollbar_h_
28 #define _CEGUIScrollbar_h_
29 
30 #include "../Base.h"
31 #include "../Window.h"
32 
33 #if defined(_MSC_VER)
34 # pragma warning(push)
35 # pragma warning(disable : 4251)
36 #endif
37 
38 // Start of CEGUI namespace section
39 namespace CEGUI
40 {
42 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer
43 {
44 public:
45  ScrollbarWindowRenderer(const String& name);
46 
52  virtual void updateThumb(void) = 0;
53 
63  virtual float getValueFromThumb(void) const = 0;
64 
78  virtual float getAdjustDirectionFromPoint(const Vector2f& pt) const = 0;
79 };
80 
89 class CEGUIEXPORT Scrollbar : public Window
90 {
91 public:
93  static const String WidgetTypeName;
94 
96  static const String EventNamespace;
121 
123  static const String ThumbName;
128 
145  float getDocumentSize(void) const
146  {
147  return d_documentSize;
148  }
149 
166  void setDocumentSize(float document_size);
167 
185  float getPageSize(void) const
186  {
187  return d_pageSize;
188  }
189 
207  void setPageSize(float page_size);
208 
226  float getStepSize(void) const
227  {
228  return d_stepSize;
229  }
230 
248  void setStepSize(float step_size);
249 
267  float getOverlapSize(void) const
268  {
269  return d_overlapSize;
270  }
271 
289  void setOverlapSize(float overlap_size);
290 
307  float getScrollPosition(void) const
308  {
309  return d_position;
310  }
311 
330  void setScrollPosition(float position);
331 
333  float getUnitIntervalScrollPosition() const;
335  void setUnitIntervalScrollPosition(float position);
336 
348  PushButton* getIncreaseButton() const;
349 
361  PushButton* getDecreaseButton() const;
362 
373  Thumb* getThumb() const;
374 
409  void setConfig(const float* const document_size,
410  const float* const page_size,
411  const float* const step_size,
412  const float* const overlap_size,
413  const float* const position);
414 
429  void setEndLockEnabled(const bool enabled);
430 
446  bool isEndLockEnabled() const;
447 
449  void scrollForwardsByStep();
451  void scrollBackwardsByStep();
452 
454  void scrollForwardsByPage();
456  void scrollBackwardsByPage();
457 
458  Scrollbar(const String& type, const String& name);
459  ~Scrollbar(void);
460 
461  // overrides
462  void initialiseComponents(void);
463 
464 protected:
470  void updateThumb(void);
471 
481  float getValueFromThumb(void) const;
482 
496  float getAdjustDirectionFromPoint(const Vector2f& pt) const;
497 
501  bool setScrollPosition_impl(const float position);
502 
504  bool isAtEnd() const;
505 
507  float getMaxScrollPosition() const;
508 
510  bool handleThumbMoved(const EventArgs& e);
511 
513  bool handleIncreaseClicked(const EventArgs& e);
514 
516  bool handleDecreaseClicked(const EventArgs& e);
517 
519  bool handleThumbTrackStarted(const EventArgs& e);
520 
522  bool handleThumbTrackEnded(const EventArgs& e);
523 
525  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
526 
527  // New event handlers for slider widget
529  virtual void onScrollPositionChanged(WindowEventArgs& e);
530 
532  virtual void onThumbTrackStarted(WindowEventArgs& e);
533 
535  virtual void onThumbTrackEnded(WindowEventArgs& e);
536 
538  virtual void onScrollConfigChanged(WindowEventArgs& e);
539 
540  // Overridden event handlers
541  virtual void onMouseButtonDown(MouseEventArgs& e);
542  virtual void onMouseWheel(MouseEventArgs& e);
543 
544  // base class overrides
545  void banPropertiesForAutoWindow();
546 
547  // Implementation Data
551  float d_pageSize;
553  float d_stepSize;
557  float d_position;
560 
561 private:
563  void addScrollbarProperties(void);
564 };
565 
566 } // End of CEGUI namespace section
567 
568 #if defined(_MSC_VER)
569 # pragma warning(pop)
570 #endif
571 
572 #endif // end of guard _CEGUIScrollbar_h_
static const String EventScrollPositionChanged
Definition: widgets/Scrollbar.h:102
static const String EventThumbTrackStarted
Definition: widgets/Scrollbar.h:108
static const String WidgetTypeName
Window factory name.
Definition: widgets/Scrollbar.h:93
static const String EventThumbTrackEnded
Definition: widgets/Scrollbar.h:114
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
Base scroll bar class.
Definition: widgets/Scrollbar.h:89
float getPageSize(void) const
Return the page size for this scroll bar.
Definition: widgets/Scrollbar.h:185
static const String EventNamespace
Namespace for global events.
Definition: widgets/Scrollbar.h:96
Base class for Thumb widget.
Definition: Thumb.h:55
float d_overlapSize
Amount of overlap when jumping by a page.
Definition: widgets/Scrollbar.h:555
float getScrollPosition(void) const
Return the current position of scroll bar within the document.
Definition: widgets/Scrollbar.h:307
static const String EventScrollConfigChanged
Definition: widgets/Scrollbar.h:120
Base-class for the assignable WindowRenderer object.
Definition: WindowRenderer.h:50
static const String ThumbName
Widget name for the thumb component.
Definition: widgets/Scrollbar.h:123
float getStepSize(void) const
Return the step size for this scroll bar.
Definition: widgets/Scrollbar.h:226
float d_documentSize
The size of the document / data being scrolled thorugh.
Definition: widgets/Scrollbar.h:549
float getDocumentSize(void) const
Return the size of the document or data.
Definition: widgets/Scrollbar.h:145
bool d_endLockPosition
whether 'end lock' mode is enabled.
Definition: widgets/Scrollbar.h:559
Base class for Scrollbar window renderer objects.
Definition: widgets/Scrollbar.h:42
static const String IncreaseButtonName
Widget name for the increase button component.
Definition: widgets/Scrollbar.h:125
Base class to provide logic for push button type widgets.
Definition: PushButton.h:47
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
float d_pageSize
The size of a single 'page' of data.
Definition: widgets/Scrollbar.h:551
float d_stepSize
Step size used for increase / decrease button clicks.
Definition: widgets/Scrollbar.h:553
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:251
static const String DecreaseButtonName
Widget name for the decrease button component.
Definition: widgets/Scrollbar.h:127
EventArgs based class that is used for objects passed to input event handlers concerning mouse input...
Definition: InputEvent.h:280
float d_position
Current scroll position.
Definition: widgets/Scrollbar.h:557
float getOverlapSize(void) const
Return the overlap size for this scroll bar.
Definition: widgets/Scrollbar.h:267
String class used within the GUI system.
Definition: String.h:62