00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _CEGUIScrollbar_h_
00029 #define _CEGUIScrollbar_h_
00030
00031 #include "../CEGUIBase.h"
00032 #include "../CEGUIWindow.h"
00033 #include "CEGUIScrollbarProperties.h"
00034
00035 #if defined(_MSC_VER)
00036 # pragma warning(push)
00037 # pragma warning(disable : 4251)
00038 #endif
00039
00040
00041 namespace CEGUI
00042 {
00047 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer
00048 {
00049 public:
00054 ScrollbarWindowRenderer(const String& name);
00055
00061 virtual void updateThumb(void) = 0;
00062
00072 virtual float getValueFromThumb(void) const = 0;
00073
00087 virtual float getAdjustDirectionFromPoint(const Point& pt) const = 0;
00088 };
00089
00098 class CEGUIEXPORT Scrollbar : public Window
00099 {
00100 public:
00102 static const String EventNamespace;
00104 static const String WidgetTypeName;
00105
00106
00107
00108
00114 static const String EventScrollPositionChanged;
00120 static const String EventThumbTrackStarted;
00126 static const String EventThumbTrackEnded;
00132 static const String EventScrollConfigChanged;
00133
00134
00135
00136
00138 static const String ThumbNameSuffix;
00140 static const String IncreaseButtonNameSuffix;
00142 static const String DecreaseButtonNameSuffix;
00143
00144
00145
00146
00163 float getDocumentSize(void) const
00164 {
00165 return d_documentSize;
00166 }
00167
00185 float getPageSize(void) const
00186 {
00187 return d_pageSize;
00188 }
00189
00207 float getStepSize(void) const
00208 {
00209 return d_stepSize;
00210 }
00211
00229 float getOverlapSize(void) const
00230 {
00231 return d_overlapSize;
00232 }
00233
00250 float getScrollPosition(void) const
00251 {
00252 return d_position;
00253 }
00254
00266 PushButton* getIncreaseButton() const;
00267
00279 PushButton* getDecreaseButton() const;
00280
00291 Thumb* getThumb() const;
00292
00293
00294
00295
00307 virtual void initialiseComponents(void);
00308
00328 void setDocumentSize(float document_size);
00329
00350 void setPageSize(float page_size);
00351
00372 void setStepSize(float step_size);
00373
00394 void setOverlapSize(float overlap_size);
00395
00417 void setScrollPosition(float position);
00418
00453 void setConfig(const float* const document_size,
00454 const float* const page_size,
00455 const float* const step_size,
00456 const float* const overlap_size,
00457 const float* const position);
00458
00473 void setEndLockEnabled(const bool enabled);
00474
00490 bool isEndLockEnabled() const;
00491
00493 Scrollbar(const String& type, const String& name);
00494
00496 virtual ~Scrollbar(void);
00497
00498 protected:
00504 void updateThumb(void);
00505
00515 float getValueFromThumb(void) const;
00516
00530 float getAdjustDirectionFromPoint(const Point& pt) const;
00531
00535 bool setScrollPosition_impl(const float position);
00536
00538 bool isAtEnd() const;
00539
00541 float getMaxScrollPosition() const;
00542
00544 bool handleThumbMoved(const EventArgs& e);
00545
00547 bool handleIncreaseClicked(const EventArgs& e);
00548
00550 bool handleDecreaseClicked(const EventArgs& e);
00551
00553 bool handleThumbTrackStarted(const EventArgs& e);
00554
00556 bool handleThumbTrackEnded(const EventArgs& e);
00557
00569 virtual bool testClassName_impl(const String& class_name) const
00570 {
00571 if (class_name == "Scrollbar") return true;
00572
00573 return Window::testClassName_impl(class_name);
00574 }
00575
00577 virtual bool validateWindowRenderer(const String& name) const
00578 {
00579 return (name == "Scrollbar");
00580 }
00581
00582
00584 virtual void onScrollPositionChanged(WindowEventArgs& e);
00585
00587 virtual void onThumbTrackStarted(WindowEventArgs& e);
00588
00590 virtual void onThumbTrackEnded(WindowEventArgs& e);
00591
00593 virtual void onScrollConfigChanged(WindowEventArgs& e);
00594
00595
00596 virtual void onMouseButtonDown(MouseEventArgs& e);
00597 virtual void onMouseWheel(MouseEventArgs& e);
00598
00599
00601 float d_documentSize;
00603 float d_pageSize;
00605 float d_stepSize;
00607 float d_overlapSize;
00609 float d_position;
00611 bool d_endLockPosition;
00612
00613 private:
00614
00615 static ScrollbarProperties::DocumentSize d_documentSizeProperty;
00616 static ScrollbarProperties::PageSize d_pageSizeProperty;
00617 static ScrollbarProperties::StepSize d_stepSizeProperty;
00618 static ScrollbarProperties::OverlapSize d_overlapSizeProperty;
00619 static ScrollbarProperties::ScrollPosition d_scrollPositionProperty;
00620 static ScrollbarProperties::EndLockEnabled d_endLockEnabledProperty;
00621
00623 void addScrollbarProperties(void);
00624 };
00625
00626 }
00627
00628 #if defined(_MSC_VER)
00629 # pragma warning(pop)
00630 #endif
00631
00632 #endif // end of guard _CEGUIScrollbar_h_