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 #ifndef CTRL_SLIDER_HPP
00026 #define CTRL_SLIDER_HPP
00027
00028 #include "ctrl_generic.hpp"
00029 #include "../utils/bezier.hpp"
00030 #include "../utils/fsm.hpp"
00031 #include "../utils/observer.hpp"
00032
00033
00034 class GenericBitmap;
00035 class OSGraphics;
00036 class VarPercent;
00037
00038
00040 class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
00041 {
00042 public:
00045 CtrlSliderCursor( intf_thread_t *pIntf, const GenericBitmap &rBmpUp,
00046 const GenericBitmap &rBmpOver,
00047 const GenericBitmap &rBmpDown,
00048 const Bezier &rCurve, VarPercent &rVariable,
00049 VarBool *pVisible, const UString &rTooltip,
00050 const UString &rHelp );
00051
00052 virtual ~CtrlSliderCursor();
00053
00055 virtual void handleEvent( EvtGeneric &rEvent );
00056
00058 virtual bool mouseOver( int x, int y ) const;
00059
00061 virtual void draw( OSGraphics &rImage, int xDest, int yDest );
00062
00064 virtual UString getTooltipText() const { return m_tooltip; }
00065
00067 virtual string getType() const { return "slider_cursor"; }
00068
00069 private:
00071 FSM m_fsm;
00073 VarPercent &m_rVariable;
00075 const UString m_tooltip;
00077 int m_width, m_height;
00079 int m_xPosition, m_yPosition;
00081 DEFINE_CALLBACK( CtrlSliderCursor, OverDown )
00082 DEFINE_CALLBACK( CtrlSliderCursor, DownOver )
00083 DEFINE_CALLBACK( CtrlSliderCursor, OverUp )
00084 DEFINE_CALLBACK( CtrlSliderCursor, UpOver )
00085 DEFINE_CALLBACK( CtrlSliderCursor, Move )
00086 DEFINE_CALLBACK( CtrlSliderCursor, Scroll )
00088 float m_lastPercentage;
00090 int m_xOffset, m_yOffset;
00092 EvtGeneric *m_pEvt;
00094 OSGraphics *m_pImgUp, *m_pImgOver, *m_pImgDown;
00096 OSGraphics *m_pImg;
00098 const Bezier &m_rCurve;
00099
00101 virtual void onUpdate( Subject<VarPercent> &rVariable );
00102
00104 void getResizeFactors( float &rFactorX, float &rFactorY ) const;
00105 };
00106
00107
00109 class CtrlSliderBg: public CtrlGeneric
00110 {
00111 public:
00112 CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor,
00113 const Bezier &rCurve, VarPercent &rVariable,
00114 int thickness, VarBool *pVisible, const UString &rHelp );
00115 virtual ~CtrlSliderBg() {}
00116
00118 virtual bool mouseOver( int x, int y ) const;
00119
00121 virtual void handleEvent( EvtGeneric &rEvent );
00122
00124 virtual string getType() const { return "slider_bg"; }
00125
00126 private:
00128 CtrlSliderCursor &m_rCursor;
00130 VarPercent &m_rVariable;
00132 int m_thickness;
00134 const Bezier &m_rCurve;
00136 int m_width, m_height;
00137
00139 void getResizeFactors( float &rFactorX, float &rFactorY ) const;
00140 };
00141
00142
00143 #endif