MyGUI  3.2.1
MyGUI_ScrollBar.h
Go to the documentation of this file.
00001 /*
00002  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
00003  * Distributed under the MIT License
00004  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
00005  */
00006 
00007 #ifndef __MYGUI_SCROLL_BAR_H__
00008 #define __MYGUI_SCROLL_BAR_H__
00009 
00010 #include "MyGUI_Prerequest.h"
00011 #include "MyGUI_Widget.h"
00012 
00013 namespace MyGUI
00014 {
00015 
00016     class ControllerItem;
00017 
00018     typedef delegates::CMultiDelegate2<ScrollBar*, size_t> EventHandle_ScrollBarPtrSizeT;
00019 
00023     class MYGUI_EXPORT ScrollBar :
00024         public Widget,
00025         public MemberObsolete<ScrollBar>
00026     {
00027         MYGUI_RTTI_DERIVED( ScrollBar )
00028 
00029     public:
00030         ScrollBar();
00031 
00033         void setVerticalAlignment(bool _value);
00035         bool getVerticalAlignment() const;
00036 
00038         void setScrollRange(size_t _value);
00040         size_t getScrollRange() const;
00041 
00043         void setScrollPosition(size_t _value);
00045         size_t getScrollPosition() const;
00046 
00050         void setScrollPage(size_t _value);
00052         size_t getScrollPage() const;
00053 
00057         void setScrollViewPage(size_t _value);
00059         size_t getScrollViewPage() const;
00060 
00064         void setScrollWheelPage(size_t _value);
00066         size_t getScrollWheelPage() const;
00067 
00069         int getLineSize() const;
00070 
00074         void setTrackSize(int _value);
00076         int getTrackSize() const;
00077 
00079         void setMinTrackSize(int _value);
00081         int getMinTrackSize() const;
00082 
00087         void setMoveToClick(bool _value);
00089         bool getMoveToClick() const;
00090 
00094         void setRepeatEnabled(bool enabled);
00098         bool getRepeatEnabled() const;
00099 
00101         void setRepeatTriggerTime(float time);
00103         float getRepeatTriggerTime(float time) const;
00104 
00106         void setRepeatStepTime(float time);
00108         float getRepeatStepTime(float time) const;
00109 
00111         virtual void setPosition(const IntPoint& _value);
00113         virtual void setSize(const IntSize& _value);
00115         virtual void setCoord(const IntCoord& _value);
00116 
00118         void setPosition(int _left, int _top);
00120         void setSize(int _width, int _height);
00122         void setCoord(int _left, int _top, int _width, int _height);
00123 
00124         /*events:*/
00130         EventHandle_ScrollBarPtrSizeT eventScrollChangePosition;
00131 
00132     protected:
00133         virtual void initialiseOverride();
00134         virtual void shutdownOverride();
00135 
00136         void updateTrack();
00137         void TrackMove(int _left, int _top);
00138 
00139         virtual void onMouseWheel(int _rel);
00140 
00141         void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
00142         void notifyMouseReleased(Widget* _sender, int _left, int _top, MouseButton _id);
00143         void notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id);
00144         void notifyMouseWheel(Widget* _sender, int _rel);
00145 
00146         virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
00147 
00148         int getTrackPlaceLength() const;
00149 
00150     private:
00151         void repeatClick(MyGUI::Widget* _widget, MyGUI::ControllerItem* _controller);
00152         void widgetStartPressed();
00153         void widgetEndPressed();
00154         void widgetFirstPartPressed();
00155         void widgetSecondPartPressed();
00156 
00157     protected:
00158         // наши кнопки
00159         Button* mWidgetStart;
00160         Button* mWidgetEnd;
00161         Button* mWidgetTrack;
00162         // куски между кнопками
00163         Widget* mWidgetFirstPart;
00164         Widget* mWidgetSecondPart;
00165 
00166         // смещение внутри окна
00167         IntPoint mPreActionOffset;
00168 
00169         // диапазон на который трек может двигаться
00170         size_t mSkinRangeStart;
00171         size_t mSkinRangeEnd;
00172 
00173         size_t mScrollRange;
00174         size_t mScrollPosition;
00175         size_t mScrollPage; // track step, when clicking buttons
00176         size_t mScrollViewPage; // track step, when clicking scroll line
00177         size_t mScrollWheelPage; // track step, when scrolling with mouse wheel
00178 
00179         bool mEnableRepeat; // Repeat clicks on the scrollbar buttons when the mouse button remains pressed down
00180         float mRepeatTriggerTime; // Time the mouse button needs to be held for repeating to start
00181         float mRepeatStepTime; // Time between repeats
00182 
00183         int mMinTrackSize;
00184         bool mMoveToClick;
00185 
00186         bool mVerticalAlignment;
00187     };
00188 
00189 } // namespace MyGUI
00190 
00191 #endif // __MYGUI_SCROLL_BAR_H__