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_