Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/Scrollbar.h
1 /***********************************************************************
2  filename: CEGUIScrollbar.h
3  created: 13/4/2004
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2012 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 "../Base.h"
32 #include "../Window.h"
33 
34 #if defined(_MSC_VER)
35 # pragma warning(push)
36 # pragma warning(disable : 4251)
37 #endif
38 
39 // Start of CEGUI namespace section
40 namespace CEGUI
41 {
43 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer
44 {
45 public:
46  ScrollbarWindowRenderer(const String& name);
47 
53  virtual void updateThumb(void) = 0;
54 
64  virtual float getValueFromThumb(void) const = 0;
65 
79  virtual float getAdjustDirectionFromPoint(const Vector2f& pt) const = 0;
80 };
81 
90 class CEGUIEXPORT Scrollbar : public Window
91 {
92 public:
94  static const String WidgetTypeName;
95 
97  static const String EventNamespace;
122 
124  static const String ThumbName;
129 
146  float getDocumentSize(void) const
147  {
148  return d_documentSize;
149  }
150 
167  void setDocumentSize(float document_size);
168 
186  float getPageSize(void) const
187  {
188  return d_pageSize;
189  }
190 
208  void setPageSize(float page_size);
209 
227  float getStepSize(void) const
228  {
229  return d_stepSize;
230  }
231 
249  void setStepSize(float step_size);
250 
268  float getOverlapSize(void) const
269  {
270  return d_overlapSize;
271  }
272 
290  void setOverlapSize(float overlap_size);
291 
308  float getScrollPosition(void) const
309  {
310  return d_position;
311  }
312 
331  void setScrollPosition(float position);
332 
334  float getUnitIntervalScrollPosition() const;
336  void setUnitIntervalScrollPosition(float position);
337 
349  PushButton* getIncreaseButton() const;
350 
362  PushButton* getDecreaseButton() const;
363 
374  Thumb* getThumb() const;
375 
410  void setConfig(const float* const document_size,
411  const float* const page_size,
412  const float* const step_size,
413  const float* const overlap_size,
414  const float* const position);
415 
430  void setEndLockEnabled(const bool enabled);
431 
447  bool isEndLockEnabled() const;
448 
450  void scrollForwardsByStep();
452  void scrollBackwardsByStep();
453 
455  void scrollForwardsByPage();
457  void scrollBackwardsByPage();
458 
459  Scrollbar(const String& type, const String& name);
460  ~Scrollbar(void);
461 
462  // overrides
463  void initialiseComponents(void);
464 
465 protected:
471  void updateThumb(void);
472 
482  float getValueFromThumb(void) const;
483 
497  float getAdjustDirectionFromPoint(const Vector2f& pt) const;
498 
502  bool setScrollPosition_impl(const float position);
503 
505  bool isAtEnd() const;
506 
508  float getMaxScrollPosition() const;
509 
511  bool handleThumbMoved(const EventArgs& e);
512 
514  bool handleIncreaseClicked(const EventArgs& e);
515 
517  bool handleDecreaseClicked(const EventArgs& e);
518 
520  bool handleThumbTrackStarted(const EventArgs& e);
521 
523  bool handleThumbTrackEnded(const EventArgs& e);
524 
526  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
527 
528  // New event handlers for slider widget
530  virtual void onScrollPositionChanged(WindowEventArgs& e);
531 
533  virtual void onThumbTrackStarted(WindowEventArgs& e);
534 
536  virtual void onThumbTrackEnded(WindowEventArgs& e);
537 
539  virtual void onScrollConfigChanged(WindowEventArgs& e);
540 
541  // Overridden event handlers
542  virtual void onMouseButtonDown(MouseEventArgs& e);
543  virtual void onMouseWheel(MouseEventArgs& e);
544 
545  // base class overrides
546  void banPropertiesForAutoWindow();
547 
548  // Implementation Data
552  float d_pageSize;
554  float d_stepSize;
558  float d_position;
561 
562 private:
564  void addScrollbarProperties(void);
565 };
566 
567 } // End of CEGUI namespace section
568 
569 #if defined(_MSC_VER)
570 # pragma warning(pop)
571 #endif
572 
573 #endif // end of guard _CEGUIScrollbar_h_