Crazy Eddies GUI System  0.6.0
CEGUIScrollbar.h
1 /***********************************************************************
2  filename: CEGUIScrollbar.h
3  created: 13/4/2004
4  author: Paul D Turner
5 
6  purpose: Interface to base class for Scrollbar widget
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIScrollbar_h_
31 #define _CEGUIScrollbar_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIWindow.h"
35 #include "elements/CEGUIScrollbarProperties.h"
36 
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 
44 // Start of CEGUI namespace section
45 namespace CEGUI
46 {
51 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer
52 {
53 public:
58  ScrollbarWindowRenderer(const String& name);
59 
64  virtual void updateThumb(void) = 0;
65 
73  virtual float getValueFromThumb(void) const = 0;
74 
88  virtual float getAdjustDirectionFromPoint(const Point& pt) const = 0;
89 };
90 
99 class CEGUIEXPORT Scrollbar : public Window
100 {
101 public:
102  static const String EventNamespace;
103  static const String WidgetTypeName;
104 
105  /*************************************************************************
106  Event name constants
107  *************************************************************************/
112 
113  /*************************************************************************
114  Child Widget name suffix constants
115  *************************************************************************/
116  static const String ThumbNameSuffix;
119 
120  /*************************************************************************
121  Accessor functions
122  *************************************************************************/
138  float getDocumentSize(void) const {return d_documentSize;}
139 
140 
158  float getPageSize(void) const {return d_pageSize;}
159 
160 
177  float getStepSize(void) const {return d_stepSize;}
178 
179 
197  float getOverlapSize(void) const {return d_overlapSize;}
198 
199 
216  float getScrollPosition(void) const {return d_position;}
217 
218 
230  PushButton* getIncreaseButton() const;
231 
232 
244  PushButton* getDecreaseButton() const;
245 
246 
257  Thumb* getThumb() const;
258 
259 
260  /*************************************************************************
261  Manipulator Commands
262  *************************************************************************/
273  virtual void initialiseComponents(void);
274 
275 
294  void setDocumentSize(float document_size);
295 
296 
317  void setPageSize(float page_size);
318 
319 
339  void setStepSize(float step_size);
340 
341 
362  void setOverlapSize(float overlap_size);
363 
364 
386  void setScrollPosition(float position);
387 
388 
389  /*************************************************************************
390  Construction / Destruction
391  *************************************************************************/
396  Scrollbar(const String& type, const String& name);
397 
398 
403  virtual ~Scrollbar(void);
404 
405 
406 protected:
407  /*************************************************************************
408  Implementation Methods
409  *************************************************************************/
414  void updateThumb(void);
415 
416 
424  float getValueFromThumb(void) const;
425 
426 
440  float getAdjustDirectionFromPoint(const Point& pt) const;
441 
442 
447  //virtual void updateThumb_impl(void) = 0;
448 
449 
457  //virtual float getValueFromThumb_impl(void) const = 0;
458 
459 
473  //virtual float getAdjustDirectionFromPoint_impl(const Point& pt) const = 0;
474 
475 
480  bool handleThumbMoved(const EventArgs& e);
481 
482 
487  bool handleIncreaseClicked(const EventArgs& e);
488 
489 
494  bool handleDecreaseClicked(const EventArgs& e);
495 
496 
501  bool handleThumbTrackStarted(const EventArgs& e);
502 
503 
508  bool handleThumbTrackEnded(const EventArgs& e);
509 
510 
521  virtual bool testClassName_impl(const String& class_name) const
522  {
523  if (class_name=="Scrollbar") return true;
524  return Window::testClassName_impl(class_name);
525  }
526 
527  // validate window renderer
528  virtual bool validateWindowRenderer(const String& name) const
529  {
530  return (name == "Scrollbar");
531  }
532 
533  /*************************************************************************
534  New event handlers for slider widget
535  *************************************************************************/
540  virtual void onScrollPositionChanged(WindowEventArgs& e);
541 
542 
547  virtual void onThumbTrackStarted(WindowEventArgs& e);
548 
549 
554  virtual void onThumbTrackEnded(WindowEventArgs& e);
555 
556 
561  virtual void onScrollConfigChanged(WindowEventArgs& e);
562 
563 
564  /*************************************************************************
565  Overridden event handlers
566  *************************************************************************/
567  virtual void onMouseButtonDown(MouseEventArgs& e);
568  virtual void onMouseWheel(MouseEventArgs& e);
569 
570 
571  /*************************************************************************
572  Implementation Data
573  *************************************************************************/
575  float d_pageSize;
576  float d_stepSize;
578  float d_position;
579 
580 
581 private:
582  /*************************************************************************
583  Static Properties for this class
584  *************************************************************************/
585  static ScrollbarProperties::DocumentSize d_documentSizeProperty;
586  static ScrollbarProperties::PageSize d_pageSizeProperty;
587  static ScrollbarProperties::StepSize d_stepSizeProperty;
588  static ScrollbarProperties::OverlapSize d_overlapSizeProperty;
589  static ScrollbarProperties::ScrollPosition d_scrollPositionProperty;
590 
591 
592  /*************************************************************************
593  Private methods
594  *************************************************************************/
595  void addScrollbarProperties(void);
596 };
597 
598 } // End of CEGUI namespace section
599 
600 #if defined(_MSC_VER)
601 # pragma warning(pop)
602 #endif
603 
604 #endif // end of guard _CEGUIScrollbar_h_