Crazy Eddie's GUI System  0.8.7
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 
325  void setScrollPosition(float position);
326 
328  float getUnitIntervalScrollPosition() const;
330  void setUnitIntervalScrollPosition(float position);
331 
343  PushButton* getIncreaseButton() const;
344 
356  PushButton* getDecreaseButton() const;
357 
368  Thumb* getThumb() const;
369 
404  void setConfig(const float* const document_size,
405  const float* const page_size,
406  const float* const step_size,
407  const float* const overlap_size,
408  const float* const position);
409 
424  void setEndLockEnabled(const bool enabled);
425 
441  bool isEndLockEnabled() const;
442 
444  void scrollForwardsByStep();
446  void scrollBackwardsByStep();
447 
449  void scrollForwardsByPage();
451  void scrollBackwardsByPage();
452 
453  Scrollbar(const String& type, const String& name);
454  ~Scrollbar(void);
455 
456  // overrides
457  void initialiseComponents(void);
458 
459 protected:
465  void updateThumb(void);
466 
476  float getValueFromThumb(void) const;
477 
491  float getAdjustDirectionFromPoint(const Vector2f& pt) const;
492 
496  bool setScrollPosition_impl(const float position);
497 
499  bool isAtEnd() const;
500 
502  float getMaxScrollPosition() const;
503 
505  bool handleThumbMoved(const EventArgs& e);
506 
508  bool handleIncreaseClicked(const EventArgs& e);
509 
511  bool handleDecreaseClicked(const EventArgs& e);
512 
514  bool handleThumbTrackStarted(const EventArgs& e);
515 
517  bool handleThumbTrackEnded(const EventArgs& e);
518 
520  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
521 
522  // New event handlers for slider widget
524  virtual void onScrollPositionChanged(WindowEventArgs& e);
525 
527  virtual void onThumbTrackStarted(WindowEventArgs& e);
528 
530  virtual void onThumbTrackEnded(WindowEventArgs& e);
531 
533  virtual void onScrollConfigChanged(WindowEventArgs& e);
534 
535  // Overridden event handlers
536  virtual void onMouseButtonDown(MouseEventArgs& e);
537  virtual void onMouseWheel(MouseEventArgs& e);
538 
539  // base class overrides
540  void banPropertiesForAutoWindow();
541 
542  // Implementation Data
546  float d_pageSize;
548  float d_stepSize;
552  float d_position;
555 
556 private:
558  void addScrollbarProperties(void);
559 };
560 
561 } // End of CEGUI namespace section
562 
563 #if defined(_MSC_VER)
564 # pragma warning(pop)
565 #endif
566 
567 #endif // end of guard _CEGUIScrollbar_h_
static const String EventScrollPositionChanged
Definition: widgets/Scrollbar.h:102
static const String EventThumbTrackStarted
Definition: widgets/Scrollbar.h:108
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
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:550
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:544
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:554
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:546
float d_stepSize
Step size used for increase / decrease button clicks.
Definition: widgets/Scrollbar.h:548
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:552
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