00001 /***************************************************************************** 00002 * ctrl_radialslider.hpp 00003 ***************************************************************************** 00004 * Copyright (C) 2003 the VideoLAN team 00005 * $Id$ 00006 * 00007 * Authors: Cyril Deguet <asmax@via.ecp.fr> 00008 * Olivier Teulière <ipkiss@via.ecp.fr> 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00023 *****************************************************************************/ 00024 00025 #ifndef CTRL_RADIALSLIDER_HPP 00026 #define CTRL_RADIALSLIDER_HPP 00027 00028 #include "ctrl_generic.hpp" 00029 #include "../utils/fsm.hpp" 00030 #include "../utils/observer.hpp" 00031 00032 00033 class GenericBitmap; 00034 class OSGraphics; 00035 class VarPercent; 00036 00037 00038 /// Radial slider 00039 class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent> 00040 { 00041 public: 00042 /// Create a radial slider with the given image, which must be 00043 /// composed of numImg subimages of the same size 00044 CtrlRadialSlider( intf_thread_t *pIntf, const GenericBitmap &rBmpSeq, 00045 int numImg, VarPercent &rVariable, float minAngle, 00046 float maxAngle, const UString &rHelp, 00047 VarBool *pVisible ); 00048 00049 virtual ~CtrlRadialSlider(); 00050 00051 /// Handle an event 00052 virtual void handleEvent( EvtGeneric &rEvent ); 00053 00054 /// Check whether coordinates are inside the control 00055 virtual bool mouseOver( int x, int y ) const; 00056 00057 /// Draw the control on the given graphics 00058 virtual void draw( OSGraphics &rImage, int xDest, int yDest ); 00059 00060 /// Get the type of control (custom RTTI) 00061 virtual string getType() const { return "radial_slider"; } 00062 00063 private: 00064 /// Finite state machine of the control 00065 FSM m_fsm; 00066 /// Number of sub-images in the slider image 00067 int m_numImg; 00068 /// Variable associated to the slider 00069 VarPercent &m_rVariable; 00070 /// Min and max angles of the button 00071 float m_minAngle, m_maxAngle; 00072 /// Position of the cursor 00073 int m_position; 00074 /// Size of an image 00075 int m_width, m_height; 00076 /// The last received event 00077 EvtGeneric *m_pEvt; 00078 /// Sequence of images 00079 OSGraphics *m_pImgSeq; 00080 /// Last saved position 00081 int m_lastPos; 00082 00083 /// Callback objects 00084 DEFINE_CALLBACK( CtrlRadialSlider, UpDown ) 00085 DEFINE_CALLBACK( CtrlRadialSlider, DownUp ) 00086 DEFINE_CALLBACK( CtrlRadialSlider, Move ) 00087 00088 /// Method called when the observed variable is modified 00089 virtual void onUpdate( Subject<VarPercent> &rVariable, void* ); 00090 00091 /// Change the position of the cursor, with the given position of 00092 /// the mouse (relative to the layout). Is blocking is true, the 00093 /// the cursor cannot do more than a half turn 00094 void setCursor( int posX, int posY, bool blocking ); 00095 }; 00096 00097 00098 #endif
1.5.1