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 
330  void setUnitIntervalScrollPosition(float position);
331 
344 
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 
447 
452 
453  Scrollbar(const String& type, const String& name);
454  ~Scrollbar(void);
455 
456  // overrides
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 
509 
512 
515 
518 
520  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
521 
522  // New event handlers for slider widget
525 
528 
531 
534 
535  // Overridden event handlers
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_
CEGUI::Scrollbar
Base scroll bar class.
Definition: widgets/Scrollbar.h:90
CEGUI::Scrollbar::setEndLockEnabled
void setEndLockEnabled(const bool enabled)
Enable or disable the 'end lock' mode for the scrollbar.
CEGUI::Scrollbar::setStepSize
void setStepSize(float step_size)
Set the step size for this scroll bar.
CEGUI::Scrollbar::handleThumbTrackStarted
bool handleThumbTrackStarted(const EventArgs &e)
handler function for when thumb tracking begins
CEGUI::Scrollbar::setConfig
void setConfig(const float *const document_size, const float *const page_size, const float *const step_size, const float *const overlap_size, const float *const position)
Sets multiple scrollbar configuration parameters simultaneously.
CEGUI::Scrollbar::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: widgets/Scrollbar.h:96
CEGUI::Scrollbar::getScrollPosition
float getScrollPosition(void) const
Return the current position of scroll bar within the document.
Definition: widgets/Scrollbar.h:307
CEGUI::Scrollbar::d_position
float d_position
Current scroll position.
Definition: widgets/Scrollbar.h:552
CEGUI::Scrollbar::ThumbName
static const String ThumbName
Widget name for the thumb component.
Definition: widgets/Scrollbar.h:123
CEGUI::Scrollbar::scrollBackwardsByStep
void scrollBackwardsByStep()
move scroll position backwards by the current step size
CEGUI::ScrollbarWindowRenderer
Base class for Scrollbar window renderer objects.
Definition: widgets/Scrollbar.h:43
CEGUI::Scrollbar::handleDecreaseClicked
bool handleDecreaseClicked(const EventArgs &e)
handler function for when the decrease button is clicked.
CEGUI::Scrollbar::isAtEnd
bool isAtEnd() const
return whether the current scroll position is at the end of the range.
CEGUI::Scrollbar::getUnitIntervalScrollPosition
float getUnitIntervalScrollPosition() const
return the current scroll position as a value in the interval [0, 1]
CEGUI::Scrollbar::scrollForwardsByPage
void scrollForwardsByPage()
move scroll position forwards by a page (uses appropriate overlap)
CEGUI::Scrollbar::getStepSize
float getStepSize(void) const
Return the step size for this scroll bar.
Definition: widgets/Scrollbar.h:226
CEGUI::Scrollbar::getAdjustDirectionFromPoint
float getAdjustDirectionFromPoint(const Vector2f &pt) const
Given window location pt, return a value indicating what change should be made to the scroll bar.
CEGUI::Scrollbar::setScrollPosition_impl
bool setScrollPosition_impl(const float position)
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Scrollbar::onThumbTrackEnded
virtual void onThumbTrackEnded(WindowEventArgs &e)
Handler triggered when the scroll bar thumb is released.
CEGUI::MouseEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition: InputEvent.h:281
CEGUI::Scrollbar::setOverlapSize
void setOverlapSize(float overlap_size)
Set the overlap size for this scroll bar.
CEGUI::Scrollbar::WidgetTypeName
static const String WidgetTypeName
Window factory name.
Definition: widgets/Scrollbar.h:93
CEGUI::Scrollbar::onScrollConfigChanged
virtual void onScrollConfigChanged(WindowEventArgs &e)
Handler triggered when the scroll bar data configuration changes.
CEGUI::Vector2< float >
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
CEGUI::Scrollbar::setScrollPosition
void setScrollPosition(float position)
Set the current position of scroll bar within the document.
CEGUI::Scrollbar::getPageSize
float getPageSize(void) const
Return the page size for this scroll bar.
Definition: widgets/Scrollbar.h:185
CEGUI::Scrollbar::handleThumbMoved
bool handleThumbMoved(const EventArgs &e)
handler function for when thumb moves.
CEGUI::Thumb
Base class for Thumb widget.
Definition: Thumb.h:56
CEGUI::Scrollbar::getThumb
Thumb * getThumb() const
Return a pointer to the Thumb component widget for this Scrollbar.
CEGUI::Scrollbar::getOverlapSize
float getOverlapSize(void) const
Return the overlap size for this scroll bar.
Definition: widgets/Scrollbar.h:267
CEGUI::Scrollbar::onMouseWheel
virtual void onMouseWheel(MouseEventArgs &e)
Handler called when the mouse wheel (z-axis) position changes within this window's area.
CEGUI::Scrollbar::scrollForwardsByStep
void scrollForwardsByStep()
move scroll position forwards by the current step size
CEGUI::Scrollbar::getValueFromThumb
float getValueFromThumb(void) const
return value that best represents current scroll bar position given the current location of the thumb...
CEGUI::Scrollbar::updateThumb
void updateThumb(void)
update the size and location of the thumb to properly represent the current state of the scroll bar
CEGUI::Scrollbar::DecreaseButtonName
static const String DecreaseButtonName
Widget name for the decrease button component.
Definition: widgets/Scrollbar.h:127
CEGUI::Scrollbar::getIncreaseButton
PushButton * getIncreaseButton() const
Return a pointer to the 'increase' PushButtoncomponent widget for this Scrollbar.
CEGUI::Scrollbar::handleThumbTrackEnded
bool handleThumbTrackEnded(const EventArgs &e)
handler function for when thumb tracking begins
CEGUI::Scrollbar::d_documentSize
float d_documentSize
The size of the document / data being scrolled thorugh.
Definition: widgets/Scrollbar.h:544
CEGUI::Scrollbar::d_endLockPosition
bool d_endLockPosition
whether 'end lock' mode is enabled.
Definition: widgets/Scrollbar.h:554
CEGUI::Scrollbar::EventThumbTrackStarted
static const String EventThumbTrackStarted
Definition: widgets/Scrollbar.h:108
CEGUI::Scrollbar::setDocumentSize
void setDocumentSize(float document_size)
Set the size of the document or data.
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::Scrollbar::d_overlapSize
float d_overlapSize
Amount of overlap when jumping by a page.
Definition: widgets/Scrollbar.h:550
CEGUI::Scrollbar::onMouseButtonDown
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
CEGUI::Scrollbar::onThumbTrackStarted
virtual void onThumbTrackStarted(WindowEventArgs &e)
Handler triggered when the user begins to drag the scroll bar thumb.
CEGUI::Scrollbar::initialiseComponents
void initialiseComponents(void)
Initialises the Window based object ready for use.
CEGUI::WindowRenderer
Base-class for the assignable WindowRenderer object.
Definition: WindowRenderer.h:52
CEGUI::Scrollbar::EventScrollPositionChanged
static const String EventScrollPositionChanged
Definition: widgets/Scrollbar.h:102
CEGUI::Scrollbar::onScrollPositionChanged
virtual void onScrollPositionChanged(WindowEventArgs &e)
Handler triggered when the scroll position changes.
CEGUI::Scrollbar::d_stepSize
float d_stepSize
Step size used for increase / decrease button clicks.
Definition: widgets/Scrollbar.h:548
CEGUI::Scrollbar::handleIncreaseClicked
bool handleIncreaseClicked(const EventArgs &e)
handler function for when the increase button is clicked.
CEGUI::Scrollbar::getDecreaseButton
PushButton * getDecreaseButton() const
Return a pointer to the 'decrease' PushButton component widget for this Scrollbar.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Scrollbar::d_pageSize
float d_pageSize
The size of a single 'page' of data.
Definition: widgets/Scrollbar.h:546
CEGUI::Scrollbar::setPageSize
void setPageSize(float page_size)
Set the page size for this scroll bar.
CEGUI::ScrollbarWindowRenderer::getValueFromThumb
virtual float getValueFromThumb(void) const =0
return value that best represents current scroll bar position given the current location of the thumb...
CEGUI::Scrollbar::scrollBackwardsByPage
void scrollBackwardsByPage()
move scroll position backwards by a page (uses appropriate overlap)
CEGUI::Scrollbar::EventScrollConfigChanged
static const String EventScrollConfigChanged
Definition: widgets/Scrollbar.h:120
CEGUI::Scrollbar::isEndLockEnabled
bool isEndLockEnabled() const
Returns whether the 'end lock'mode for the scrollbar is enabled.
CEGUI::Scrollbar::validateWindowRenderer
virtual bool validateWindowRenderer(const WindowRenderer *renderer) const
validate window renderer
CEGUI::Scrollbar::EventThumbTrackEnded
static const String EventThumbTrackEnded
Definition: widgets/Scrollbar.h:114
CEGUI::Scrollbar::IncreaseButtonName
static const String IncreaseButtonName
Widget name for the increase button component.
Definition: widgets/Scrollbar.h:125
CEGUI::PushButton
Base class to provide logic for push button type widgets.
Definition: PushButton.h:48
CEGUI::ScrollbarWindowRenderer::getAdjustDirectionFromPoint
virtual float getAdjustDirectionFromPoint(const Vector2f &pt) const =0
Given window location pt, return a value indicating what change should be made to the scroll bar.
CEGUI::Scrollbar::getMaxScrollPosition
float getMaxScrollPosition() const
return the max allowable scroll position value
CEGUI::EventArgs
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
CEGUI::ScrollbarWindowRenderer::updateThumb
virtual void updateThumb(void)=0
update the size and location of the thumb to properly represent the current state of the scroll bar
CEGUI::Scrollbar::getDocumentSize
float getDocumentSize(void) const
Return the size of the document or data.
Definition: widgets/Scrollbar.h:145
CEGUI::Scrollbar::setUnitIntervalScrollPosition
void setUnitIntervalScrollPosition(float position)
set the current scroll position as a value in the interval [0, 1]