WidgetSlider.h
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 ROCKETCONTROLSWIDGETSLIDER_H
00029 #define ROCKETCONTROLSWIDGETSLIDER_H
00030
00031 #include <Rocket/Core/EventListener.h>
00032
00033 namespace Rocket {
00034 namespace Controls {
00035
00036 class ElementFormControl;
00037
00044 class WidgetSlider : public Core::EventListener
00045 {
00046 public:
00047 enum Orientation
00048 {
00049 VERTICAL,
00050 HORIZONTAL
00051 };
00052
00053 WidgetSlider(ElementFormControl* parent);
00054 virtual ~WidgetSlider();
00055
00057 bool Initialise();
00058
00060 void Update();
00061
00064 void SetBarPosition(float bar_position);
00067 float GetBarPosition();
00068
00071 void SetOrientation(Orientation orientation);
00074 Orientation GetOrientation() const;
00075
00078 void GetDimensions(Rocket::Core::Vector2f& dimensions) const;
00079
00080 protected:
00085 void FormatElements(const Rocket::Core::Vector2f& containing_block, float slider_length, float bar_length = -1);
00088 void FormatBar(float bar_length = -1);
00089
00091 Core::Element* GetParent() const;
00092
00094 virtual void ProcessEvent(Core::Event& event);
00095
00099 virtual float OnBarChange(float bar_position) = 0;
00103 virtual float OnLineIncrement() = 0;
00107 virtual float OnLineDecrement() = 0;
00112 virtual float OnPageIncrement(float click_position) = 0;
00117 virtual float OnPageDecrement(float click_position) = 0;
00118
00119 private:
00120 void PositionBar();
00121
00122 ElementFormControl* parent;
00123
00124 Orientation orientation;
00125
00126
00127 Core::Element* track;
00128
00129 Core::Element* bar;
00130
00131 Core::Element* arrows[2];
00132
00133
00134 float bar_position;
00135
00136 int bar_drag_anchor;
00137
00138
00139 float arrow_timers[2];
00140 float last_update_time;
00141 };
00142
00143 }
00144 }
00145
00146 #endif