ctrl_button.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * ctrl_button.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: 6e4581a8c983fbd47a8f0006a2e61df822f7ef8b $
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 along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef CTRL_BUTTON_HPP
00026 #define CTRL_BUTTON_HPP
00027 
00028 #include "ctrl_generic.hpp"
00029 #include "../utils/fsm.hpp"
00030 #include "../src/anim_bitmap.hpp"
00031 
00032 class GenericBitmap;
00033 class CmdGeneric;
00034 
00035 
00036 /// Base class for button controls
00037 class CtrlButton: public CtrlGeneric, public Observer<AnimBitmap>
00038 {
00039 public:
00040     /// Create a button with 3 images
00041     CtrlButton( intf_thread_t *pIntf, const GenericBitmap &rBmpUp,
00042                 const GenericBitmap &rBmpOver, const GenericBitmap &rBmpDown,
00043                 CmdGeneric &rCommand, const UString &rTooltip,
00044                 const UString &rHelp, VarBool *pVisible );
00045 
00046     virtual ~CtrlButton();
00047 
00048     /// Set the position and the associated layout of the control
00049     virtual void setLayout( GenericLayout *pLayout,
00050                             const Position &rPosition );
00051     virtual void unsetLayout();
00052 
00053     /// Handle an event
00054     virtual void handleEvent( EvtGeneric &rEvent );
00055 
00056     /// Check whether coordinates are inside the control
00057     virtual bool mouseOver( int x, int y ) const;
00058 
00059     /// Draw the control on the given graphics
00060     virtual void draw( OSGraphics &rImage, int xDest, int yDest );
00061 
00062     /// Get the text of the tooltip
00063     virtual UString getTooltipText() const { return m_tooltip; }
00064 
00065     /// Get the type of control (custom RTTI)
00066     virtual string getType() const { return "button"; }
00067 
00068 private:
00069     /// Finite state machine of the control
00070     FSM m_fsm;
00071     /// Command triggered by the button
00072     CmdGeneric &m_rCommand;
00073     /// Tooltip text
00074     const UString m_tooltip;
00075     /// Images of the button in the different states
00076     AnimBitmap m_imgUp, m_imgOver, m_imgDown;
00077     /// Current image
00078     AnimBitmap *m_pImg;
00079 
00080     /// Callback objects
00081     DEFINE_CALLBACK( CtrlButton, UpOverDownOver )
00082     DEFINE_CALLBACK( CtrlButton, DownOverUpOver )
00083     DEFINE_CALLBACK( CtrlButton, DownOverDown )
00084     DEFINE_CALLBACK( CtrlButton, DownDownOver )
00085     DEFINE_CALLBACK( CtrlButton, UpOverUp )
00086     DEFINE_CALLBACK( CtrlButton, UpUpOver )
00087     DEFINE_CALLBACK( CtrlButton, DownUp )
00088     DEFINE_CALLBACK( CtrlButton, UpHidden )
00089     DEFINE_CALLBACK( CtrlButton, HiddenUp )
00090 
00091     /// Change the current image
00092     void setImage( AnimBitmap *pImg );
00093 
00094     /// Method called when an animated bitmap changes
00095     virtual void onUpdate( Subject<AnimBitmap> &rBitmap, void* );
00096 
00097     /// Method called when visibility or ActiveLayout is updated
00098     virtual void onUpdate( Subject<VarBool> &rVariable , void* );
00099 
00100 };
00101 
00102 
00103 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6