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
00039
00040 class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
00041 {
00042 public:
00043
00044
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
00054
00055 virtual void handleEvent( EvtGeneric &rEvent );
00056
00057
00058 virtual bool mouseOver( int x, int y ) const;
00059
00060
00061 virtual void draw( OSGraphics &rImage, int xDest, int yDest );
00062
00063
00064 virtual UString getTooltipText() const { return m_tooltip; }
00065
00066
00067 virtual string getType() const { return "slider_cursor"; }
00068
00069 private:
00070
00071 FSM m_fsm;
00072
00073 VarPercent &m_rVariable;
00074
00075 const UString m_tooltip;
00076
00077 int m_width, m_height;
00078
00079 int m_xPosition, m_yPosition;
00080
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 )
00087
00088 float m_lastPercentage;
00089
00090 int m_xOffset, m_yOffset;
00091
00092 EvtGeneric *m_pEvt;
00093
00094 OSGraphics *m_pImgUp, *m_pImgOver, *m_pImgDown;
00095
00096 OSGraphics *m_pImg;
00097
00098 const Bezier &m_rCurve;
00099
00100
00101 virtual void onUpdate( Subject<VarPercent> &rVariable, void * );
00102
00103
00104 void getResizeFactors( float &rFactorX, float &rFactorY ) const;
00105
00106
00107 void refreshLayout();
00108 };
00109
00110
00111
00112 class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent>
00113 {
00114 public:
00115 CtrlSliderBg( intf_thread_t *pIntf,
00116 const Bezier &rCurve, VarPercent &rVariable,
00117 int thickness, GenericBitmap *pBackground, int nbHoriz,
00118 int nbVert, int padHoriz, int padVert, VarBool *pVisible,
00119 const UString &rHelp );
00120 virtual ~CtrlSliderBg();
00121
00122
00123 virtual bool mouseOver( int x, int y ) const;
00124
00125
00126 virtual void draw( OSGraphics &rImage, int xDest, int yDest );
00127
00128
00129 virtual void handleEvent( EvtGeneric &rEvent );
00130
00131
00132 virtual void onResize();
00133
00134
00135 virtual string getType() const { return "slider_bg"; }
00136
00137
00138 void associateCursor( CtrlSliderCursor &rCursor );
00139
00140 private:
00141
00142 CtrlSliderCursor *m_pCursor;
00143
00144 VarPercent &m_rVariable;
00145
00146 int m_thickness;
00147
00148 const Bezier &m_rCurve;
00149
00150 int m_width, m_height;
00151
00152 GenericBitmap *m_pImgSeq;
00153
00154 int m_nbHoriz, m_nbVert;
00155
00156 int m_padHoriz, m_padVert;
00157
00158 int m_bgWidth, m_bgHeight;
00159
00160 int m_position;
00161
00162
00163 virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
00164
00165
00166 void getResizeFactors( float &rFactorX, float &rFactorY ) const;
00167 };
00168
00169
00170 #endif