]> git.sesse.net Git - vlc/commitdiff
* all: replaced remaining C callbacks by commands
authorCyril Deguet <asmax@videolan.org>
Mon, 15 Aug 2005 15:54:32 +0000 (15:54 +0000)
committerCyril Deguet <asmax@videolan.org>
Mon, 15 Aug 2005 15:54:32 +0000 (15:54 +0000)
26 files changed:
modules/gui/skins2/commands/async_queue.cpp
modules/gui/skins2/commands/async_queue.hpp
modules/gui/skins2/commands/cmd_generic.hpp
modules/gui/skins2/controls/ctrl_button.cpp
modules/gui/skins2/controls/ctrl_checkbox.cpp
modules/gui/skins2/controls/ctrl_generic.hpp
modules/gui/skins2/controls/ctrl_move.cpp
modules/gui/skins2/controls/ctrl_radialslider.cpp
modules/gui/skins2/controls/ctrl_resize.cpp
modules/gui/skins2/controls/ctrl_slider.cpp
modules/gui/skins2/controls/ctrl_text.cpp
modules/gui/skins2/controls/ctrl_text.hpp
modules/gui/skins2/src/os_factory.hpp
modules/gui/skins2/src/skin_common.hpp
modules/gui/skins2/src/tooltip.cpp
modules/gui/skins2/src/tooltip.hpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.hpp
modules/gui/skins2/win32/win32_factory.cpp
modules/gui/skins2/win32/win32_factory.hpp
modules/gui/skins2/win32/win32_timer.cpp
modules/gui/skins2/win32/win32_timer.hpp
modules/gui/skins2/x11/x11_factory.cpp
modules/gui/skins2/x11/x11_factory.hpp
modules/gui/skins2/x11/x11_timer.cpp
modules/gui/skins2/x11/x11_timer.hpp

index 30b030011ea8535b113956f7a835eae046322d74..bb670d1dc9089f758ede3a36ec775025d2b12545 100644 (file)
 #include "../src/os_timer.hpp"
 
 
-AsyncQueue::AsyncQueue( intf_thread_t *pIntf ): SkinObject( pIntf )
+AsyncQueue::AsyncQueue( intf_thread_t *pIntf ): SkinObject( pIntf ),
+    m_cmdFlush( this )
 {
     // Initialize the mutex
     vlc_mutex_init( pIntf, &m_lock );
 
     // Create a timer
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
-    m_pTimer = pOsFactory->createOSTimer( Callback( this, &doFlush ) );
+    m_pTimer = pOsFactory->createOSTimer( m_cmdFlush );
 
     // Flush the queue every 10 ms
     m_pTimer->start( 10, false );
@@ -129,9 +130,8 @@ void AsyncQueue::flush()
 }
 
 
-void AsyncQueue::doFlush( SkinObject *pObj )
+void AsyncQueue::CmdFlush::execute()
 {
-    AsyncQueue *pThis = (AsyncQueue*)pObj;
     // Flush the queue
-    pThis->flush();
+    m_pParent->flush();
 }
index c4b746be64c7c93712247637c88bb30ff7d52a88..109b1adcf2a679e0bdc6bc0118e542f1f34a78e7 100644 (file)
@@ -65,8 +65,8 @@ class AsyncQueue: public SkinObject
         AsyncQueue( intf_thread_t *pIntf );
         virtual ~AsyncQueue();
 
-        /// Callback for the timer
-        static void doFlush( SkinObject *pObj );
+        // Callback to flush the queue
+        DEFINE_CALLBACK( AsyncQueue, Flush );
 };
 
 
index f17516407caa795450dadc84ec0fad49f282c1e0..0235043c1a9017caf423bff84bc4e3e285152802 100644 (file)
@@ -44,6 +44,23 @@ class Cmd##name: public CmdGeneric \
 };
 
 
+/// Macro to define a "callback" command inside a class
+#define DEFINE_CALLBACK( parent, action ) \
+class Cmd##action: public CmdGeneric \
+{ \
+    public: \
+        Cmd##action( parent *pParent ): \
+            CmdGeneric( pParent->getIntf() ), m_pParent( pParent ) {} \
+        virtual ~Cmd##action() {} \
+        virtual void execute(); \
+        virtual string getType() const { return "Cmd" #parent #action; } \
+    private: \
+        parent *m_pParent; \
+\
+} m_cmd##action; \
+friend class Cmd##action;
+
+
 /// Base class for skins commands
 class CmdGeneric: public SkinObject
 {
index 2e2a9a2915fdffc40f8e770f868a33ca4c224d66..0cfe884cbc35bbd483436602f021e10cbfdc0fd1 100644 (file)
@@ -37,11 +37,11 @@ CtrlButton::CtrlButton( intf_thread_t *pIntf, const GenericBitmap &rBmpUp,
                         VarBool *pVisible ):
     CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
     m_rCommand( rCommand ), m_tooltip( rTooltip ),
-    m_cmdUpOverDownOver( pIntf, this ), m_cmdDownOverUpOver( pIntf, this ),
-    m_cmdDownOverDown( pIntf, this ), m_cmdDownDownOver( pIntf, this ),
-    m_cmdUpOverUp( pIntf, this ), m_cmdUpUpOver( pIntf, this ),
-    m_cmdDownUp( pIntf, this ), m_cmdUpHidden( pIntf, this ),
-    m_cmdHiddenUp( pIntf, this )
+    m_cmdUpOverDownOver( this ), m_cmdDownOverUpOver( this ),
+    m_cmdDownOverDown( this ), m_cmdDownDownOver( this ),
+    m_cmdUpOverUp( this ), m_cmdUpUpOver( this ),
+    m_cmdDownUp( this ), m_cmdUpHidden( this ),
+    m_cmdHiddenUp( this )
 {
     // Build the images of the button
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
@@ -127,74 +127,74 @@ void CtrlButton::draw( OSGraphics &rImage, int xDest, int yDest )
 
 void CtrlButton::CmdUpOverDownOver::execute()
 {
-    m_pControl->captureMouse();
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = m_pControl->m_pImgDown;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    m_pParent->captureMouse();
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = m_pParent->m_pImgDown;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
 }
 
 
 void CtrlButton::CmdDownOverUpOver::execute()
 {
-    m_pControl->releaseMouse();
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    m_pParent->releaseMouse();
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
     // Execute the command associated to this button
-    m_pControl->m_rCommand.execute();
+    m_pParent->m_rCommand.execute();
 }
 
 
 void CtrlButton::CmdDownOverDown::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
 }
 
 
 void CtrlButton::CmdDownDownOver::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = m_pControl->m_pImgDown;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = m_pParent->m_pImgDown;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
 }
 
 
 void CtrlButton::CmdUpUpOver::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = m_pControl->m_pImgOver;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = m_pParent->m_pImgOver;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
 }
 
 
 void CtrlButton::CmdUpOverUp::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
 }
 
 
 void CtrlButton::CmdDownUp::execute()
 {
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 }
 
 
 void CtrlButton::CmdUpHidden::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = NULL;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = NULL;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
 }
 
 
 void CtrlButton::CmdHiddenUp::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImg;
-    m_pControl->m_pImg = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
+    const OSGraphics *pOldImg = m_pParent->m_pImg;
+    m_pParent->m_pImg = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
 }
 
index 57992449fd40ef6c9a19003d60cad8f551b1f5ff..66398566d2ed4642c9eaad35b25b2ea62e5086c1 100644 (file)
@@ -47,11 +47,11 @@ CtrlCheckbox::CtrlCheckbox( intf_thread_t *pIntf,
     m_rVariable( rVariable ),
     m_rCommand1( rCommand1 ), m_rCommand2( rCommand2 ),
     m_tooltip1( rTooltip1 ), m_tooltip2( rTooltip2 ),
-    m_cmdUpOverDownOver( pIntf, this ), m_cmdDownOverUpOver( pIntf, this ),
-    m_cmdDownOverDown( pIntf, this ), m_cmdDownDownOver( pIntf, this ),
-    m_cmdUpOverUp( pIntf, this ), m_cmdUpUpOver( pIntf, this ),
-    m_cmdDownUp( pIntf, this ), m_cmdUpHidden( pIntf, this ),
-    m_cmdHiddenUp( pIntf, this )
+    m_cmdUpOverDownOver( this ), m_cmdDownOverUpOver( this ),
+    m_cmdDownOverDown( this ), m_cmdDownDownOver( this ),
+    m_cmdUpOverUp( this ), m_cmdUpUpOver( this ),
+    m_cmdDownUp( this ), m_cmdUpHidden( this ),
+    m_cmdHiddenUp( this )
 {
     // Build the images of the checkbox
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
@@ -171,78 +171,78 @@ void CtrlCheckbox::draw( OSGraphics &rImage, int xDest, int yDest )
 
 void CtrlCheckbox::CmdUpOverDownOver::execute()
 {
-    m_pControl->captureMouse();
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = m_pControl->m_pImgDown;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    m_pParent->captureMouse();
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = m_pParent->m_pImgDown;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 }
 
 
 void CtrlCheckbox::CmdDownOverUpOver::execute()
 {
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 
     // Invert the state variable
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 
     // Execute the command
-    m_pControl->m_pCommand->execute();
+    m_pParent->m_pCommand->execute();
 }
 
 
 void CtrlCheckbox::CmdDownOverDown::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 }
 
 
 void CtrlCheckbox::CmdDownDownOver::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = m_pControl->m_pImgDown;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = m_pParent->m_pImgDown;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 }
 
 
 void CtrlCheckbox::CmdUpUpOver::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = m_pControl->m_pImgOver;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = m_pParent->m_pImgOver;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 }
 
 
 void CtrlCheckbox::CmdUpOverUp::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 }
 
 
 void CtrlCheckbox::CmdDownUp::execute()
 {
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 }
 
 
 void CtrlCheckbox::CmdUpHidden::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = NULL;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = NULL;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 }
 
 
 void CtrlCheckbox::CmdHiddenUp::execute()
 {
-    const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
-    m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
-    m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
+    const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
+    m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
+    m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
 }
 
 
index 8b5ce46bb6b550e94088107ea31bd0ad18f4f5e6..5cddded7e64fff0da368f98c46ee0262621d9bdc 100644 (file)
@@ -134,21 +134,4 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
 typedef CountedPtr<CtrlGeneric> CtrlGenericPtr;
 
 
-// Macro to define a control action command
-#define DEFINE_CALLBACK( control, action ) \
-class Cmd##action: public CmdGeneric \
-{ \
-    public: \
-        Cmd##action( intf_thread_t *pIntf, control *pControl ): \
-            CmdGeneric( pIntf ), m_pControl( pControl) {} \
-        virtual ~Cmd##action() {} \
-        virtual void execute(); \
-        virtual string getType() const { return "Cmd" #control #action; } \
-    private: \
-        control *m_pControl; \
-\
-} m_cmd##action; \
-friend class Cmd##action;
-
-
 #endif
index 5a60360b70f5bd081b070b6171bce9b38859b203..7ea2cc693a9a0fc92064a91dde5a23fb36c9e52b 100644 (file)
@@ -37,9 +37,9 @@ CtrlMove::CtrlMove( intf_thread_t *pIntf, WindowManager &rWindowManager,
     CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
     m_rWindowManager( rWindowManager ),
     m_rCtrl( rCtrl ), m_rWindow( rWindow ),
-    m_cmdMovingMoving( pIntf, this ),
-    m_cmdStillMoving( pIntf, this ),
-    m_cmdMovingStill( pIntf, this )
+    m_cmdMovingMoving( this ),
+    m_cmdStillMoving( this ),
+    m_cmdMovingStill( this )
 {
     m_pEvt = NULL;
     m_xPos = 0;
@@ -98,33 +98,33 @@ void CtrlMove::handleEvent( EvtGeneric &rEvent )
 
 void CtrlMove::CmdStillMoving::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
-    m_pControl->m_xPos = pEvtMouse->getXPos();
-    m_pControl->m_yPos = pEvtMouse->getYPos();
+    m_pParent->m_xPos = pEvtMouse->getXPos();
+    m_pParent->m_yPos = pEvtMouse->getYPos();
 
-    m_pControl->captureMouse();
+    m_pParent->captureMouse();
 
-    m_pControl->m_rWindowManager.startMove( m_pControl->m_rWindow );
+    m_pParent->m_rWindowManager.startMove( m_pParent->m_rWindow );
 }
 
 
 void CtrlMove::CmdMovingMoving::execute()
 {
-    EvtMotion *pEvtMotion = (EvtMotion*)m_pControl->m_pEvt;
+    EvtMotion *pEvtMotion = (EvtMotion*)m_pParent->m_pEvt;
 
-    int xNewLeft = pEvtMotion->getXPos() - m_pControl->m_xPos +
-                   m_pControl->m_rWindow.getLeft();
-    int yNewTop = pEvtMotion->getYPos() - m_pControl->m_yPos +
-                  m_pControl->m_rWindow.getTop();
+    int xNewLeft = pEvtMotion->getXPos() - m_pParent->m_xPos +
+                   m_pParent->m_rWindow.getLeft();
+    int yNewTop = pEvtMotion->getYPos() - m_pParent->m_yPos +
+                  m_pParent->m_rWindow.getTop();
 
-    m_pControl->m_rWindowManager.move( m_pControl->m_rWindow, xNewLeft, yNewTop );
+    m_pParent->m_rWindowManager.move( m_pParent->m_rWindow, xNewLeft, yNewTop );
 }
 
 
 void CtrlMove::CmdMovingStill::execute()
 {
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 
-    m_pControl->m_rWindowManager.stopMove();
+    m_pParent->m_rWindowManager.stopMove();
 }
index f90d6626b4c57a0093e001213d53f95fd112d934..24df9a694135732c4da37981104d7bb72b6f7ac1 100644 (file)
@@ -40,8 +40,8 @@ CtrlRadialSlider::CtrlRadialSlider( intf_thread_t *pIntf,
                                     VarBool *pVisible ):
     CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_numImg( numImg ),
     m_rVariable( rVariable ), m_minAngle( minAngle ), m_maxAngle( maxAngle ),
-    m_cmdUpDown( pIntf, this ), m_cmdDownUp( pIntf, this ),
-    m_cmdMove( pIntf, this )
+    m_cmdUpDown( this ), m_cmdDownUp( this ),
+    m_cmdMove( this )
 {
     // Build the images of the sequence
     OSFactory *pOsFactory = OSFactory::instance( getIntf() );
@@ -107,27 +107,27 @@ void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable )
 
 void CtrlRadialSlider::CmdUpDown::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
     // Change the position of the cursor, in non-blocking mode
-    m_pControl->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), false );
+    m_pParent->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), false );
 
-    m_pControl->captureMouse();
+    m_pParent->captureMouse();
 }
 
 
 void CtrlRadialSlider::CmdDownUp::execute()
 {
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 }
 
 
 void CtrlRadialSlider::CmdMove::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
     // Change the position of the cursor, in blocking mode
-    m_pControl->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), true );
+    m_pParent->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), true );
 }
 
 
index f476b0c6c3b55d809c377a17c2d7583815725c5a..8408a01d6fe128f64a8e37d109bd7ec1d73c7d69 100644 (file)
@@ -37,12 +37,12 @@ CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl,
                         GenericLayout &rLayout, const UString &rHelp,
                         VarBool *pVisible ):
     CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_rCtrl( rCtrl ),
-    m_rLayout( rLayout ), m_cmdOutStill( pIntf, this ),
-    m_cmdStillOut( pIntf, this ),
-    m_cmdStillStill( pIntf, this ),
-    m_cmdStillResize( pIntf, this ),
-    m_cmdResizeStill( pIntf, this ),
-    m_cmdResizeResize( pIntf, this )
+    m_rLayout( rLayout ), m_cmdOutStill( this ),
+    m_cmdStillOut( this ),
+    m_cmdStillStill( this ),
+    m_cmdStillResize( this ),
+    m_cmdResizeStill( this ),
+    m_cmdResizeResize( this )
 {
     m_pEvt = NULL;
     m_xPos = 0;
@@ -105,87 +105,87 @@ void CtrlResize::handleEvent( EvtGeneric &rEvent )
 
 void CtrlResize::CmdOutStill::execute()
 {
-    OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
+    OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
     pOsFactory->changeCursor( OSFactory::kResizeNWSE );
 }
 
 
 void CtrlResize::CmdStillOut::execute()
 {
-    OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
+    OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
     pOsFactory->changeCursor( OSFactory::kDefaultArrow );
 }
 
 
 void CtrlResize::CmdStillStill::execute()
 {
-    OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
+    OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
     pOsFactory->changeCursor( OSFactory::kResizeNWSE );
 }
 
 
 void CtrlResize::CmdStillResize::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
     // Set the cursor
-    OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
+    OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
     pOsFactory->changeCursor( OSFactory::kResizeNWSE );
 
-    m_pControl->m_xPos = pEvtMouse->getXPos();
-    m_pControl->m_yPos = pEvtMouse->getYPos();
+    m_pParent->m_xPos = pEvtMouse->getXPos();
+    m_pParent->m_yPos = pEvtMouse->getYPos();
 
-    m_pControl->captureMouse();
+    m_pParent->captureMouse();
 
-    m_pControl->m_width = m_pControl->m_rLayout.getWidth();
-    m_pControl->m_height = m_pControl->m_rLayout.getHeight();
+    m_pParent->m_width = m_pParent->m_rLayout.getWidth();
+    m_pParent->m_height = m_pParent->m_rLayout.getHeight();
 }
 
 
 void CtrlResize::CmdResizeStill::execute()
 {
     // Set the cursor
-    OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
+    OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
     pOsFactory->changeCursor( OSFactory::kResizeNWSE );
 
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 }
 
 
 void CtrlResize::CmdResizeResize::execute()
 {
-    EvtMotion *pEvtMotion = (EvtMotion*)m_pControl->m_pEvt;
+    EvtMotion *pEvtMotion = (EvtMotion*)m_pParent->m_pEvt;
 
     // Set the cursor
-    OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
+    OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
     pOsFactory->changeCursor( OSFactory::kResizeNWSE );
 
-    int newWidth = pEvtMotion->getXPos() - m_pControl->m_xPos + m_pControl->m_width;
-    int newHeight = pEvtMotion->getYPos() - m_pControl->m_yPos + m_pControl->m_height;
+    int newWidth = pEvtMotion->getXPos() - m_pParent->m_xPos + m_pParent->m_width;
+    int newHeight = pEvtMotion->getYPos() - m_pParent->m_yPos + m_pParent->m_height;
 
     // Check boundaries
-    if( newWidth < m_pControl->m_rLayout.getMinWidth() )
+    if( newWidth < m_pParent->m_rLayout.getMinWidth() )
     {
-        newWidth = m_pControl->m_rLayout.getMinWidth();
+        newWidth = m_pParent->m_rLayout.getMinWidth();
     }
-    if( newWidth > m_pControl->m_rLayout.getMaxWidth() )
+    if( newWidth > m_pParent->m_rLayout.getMaxWidth() )
     {
-        newWidth = m_pControl->m_rLayout.getMaxWidth();
+        newWidth = m_pParent->m_rLayout.getMaxWidth();
     }
-    if( newHeight < m_pControl->m_rLayout.getMinHeight() )
+    if( newHeight < m_pParent->m_rLayout.getMinHeight() )
     {
-        newHeight = m_pControl->m_rLayout.getMinHeight();
+        newHeight = m_pParent->m_rLayout.getMinHeight();
     }
-    if( newHeight > m_pControl->m_rLayout.getMaxHeight() )
+    if( newHeight > m_pParent->m_rLayout.getMaxHeight() )
     {
-        newHeight = m_pControl->m_rLayout.getMaxHeight();
+        newHeight = m_pParent->m_rLayout.getMaxHeight();
     }
 
     // Create a resize command
-    CmdGeneric *pCmd = new CmdResize( m_pControl->getIntf(), m_pControl->m_rLayout,
+    CmdGeneric *pCmd = new CmdResize( m_pParent->getIntf(), m_pParent->m_rLayout,
                                       newWidth, newHeight );
     // Push the command in the asynchronous command queue
-    AsyncQueue *pQueue = AsyncQueue::instance( m_pControl->getIntf() );
+    AsyncQueue *pQueue = AsyncQueue::instance( m_pParent->getIntf() );
     pQueue->remove( "resize" );
     pQueue->push( CmdGenericPtr( pCmd ) );
 }
index ce543a22349f74067e376cd5b9907d414aa5740e..d9bb33ba9ca4d9648c3cceea285f361019f3fb32 100644 (file)
@@ -50,9 +50,9 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
     CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
     m_rVariable( rVariable ), m_tooltip( rTooltip ),
     m_width( rCurve.getWidth() ), m_height( rCurve.getHeight() ),
-    m_cmdOverDown( pIntf, this ), m_cmdDownOver( pIntf, this ),
-    m_cmdOverUp( pIntf, this ), m_cmdUpOver( pIntf, this ),
-    m_cmdMove( pIntf, this ), m_cmdScroll( pIntf, this ),
+    m_cmdOverDown( this ), m_cmdDownOver( this ),
+    m_cmdOverUp( this ), m_cmdUpOver( this ),
+    m_cmdMove( this ), m_cmdScroll( this ),
     m_lastPercentage( 0 ), m_xOffset( 0 ), m_yOffset( 0 ),
     m_pEvt( NULL ), m_rCurve( rCurve )
 {
@@ -176,128 +176,128 @@ void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable )
 
 void CtrlSliderCursor::CmdOverDown::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
     // Compute the resize factors
     float factorX, factorY;
-    m_pControl->getResizeFactors( factorX, factorY );
+    m_pParent->getResizeFactors( factorX, factorY );
 
     // Get the position of the control
-    const Position *pPos = m_pControl->getPosition();
+    const Position *pPos = m_pParent->getPosition();
 
     // Compute the offset
     int tempX, tempY;
-    m_pControl->m_rCurve.getPoint( m_pControl->m_rVariable.get(), tempX, tempY );
-    m_pControl->m_xOffset = pEvtMouse->getXPos() - pPos->getLeft()
+    m_pParent->m_rCurve.getPoint( m_pParent->m_rVariable.get(), tempX, tempY );
+    m_pParent->m_xOffset = pEvtMouse->getXPos() - pPos->getLeft()
                        - (int)(tempX * factorX);
-    m_pControl->m_yOffset = pEvtMouse->getYPos() - pPos->getTop()
+    m_pParent->m_yOffset = pEvtMouse->getYPos() - pPos->getTop()
                        - (int)(tempY * factorY);
 
-    m_pControl->captureMouse();
-    m_pControl->m_pImg = m_pControl->m_pImgDown;
-    if( m_pControl->m_pImg )
+    m_pParent->captureMouse();
+    m_pParent->m_pImg = m_pParent->m_pImgDown;
+    if( m_pParent->m_pImg )
     {
-        m_pControl->notifyLayout(
-            m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
-            m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
-            - m_pControl->m_pImg->getWidth() / 2,
-            - m_pControl->m_pImg->getHeight() / 2 );
+        m_pParent->notifyLayout(
+            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
+            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
+            - m_pParent->m_pImg->getWidth() / 2,
+            - m_pParent->m_pImg->getHeight() / 2 );
     }
     else
-        m_pControl->notifyLayout();
+        m_pParent->notifyLayout();
 }
 
 
 void CtrlSliderCursor::CmdDownOver::execute()
 {
     // Save the position
-    m_pControl->m_lastPercentage = m_pControl->m_rVariable.get();
+    m_pParent->m_lastPercentage = m_pParent->m_rVariable.get();
 
-    m_pControl->releaseMouse();
-    m_pControl->m_pImg = m_pControl->m_pImgUp;
-    if( m_pControl->m_pImg )
+    m_pParent->releaseMouse();
+    m_pParent->m_pImg = m_pParent->m_pImgUp;
+    if( m_pParent->m_pImg )
     {
-        m_pControl->notifyLayout(
-            m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
-            m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
-            - m_pControl->m_pImg->getWidth() / 2,
-            - m_pControl->m_pImg->getHeight() / 2 );
+        m_pParent->notifyLayout(
+            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
+            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
+            - m_pParent->m_pImg->getWidth() / 2,
+            - m_pParent->m_pImg->getHeight() / 2 );
     }
     else
-        m_pControl->notifyLayout();
+        m_pParent->notifyLayout();
 }
 
 
 void CtrlSliderCursor::CmdUpOver::execute()
 {
-    m_pControl->m_pImg = m_pControl->m_pImgOver;
-    if( m_pControl->m_pImg )
+    m_pParent->m_pImg = m_pParent->m_pImgOver;
+    if( m_pParent->m_pImg )
     {
-        m_pControl->notifyLayout(
-            m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
-            m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
-            - m_pControl->m_pImg->getWidth() / 2,
-            - m_pControl->m_pImg->getHeight() / 2 );
+        m_pParent->notifyLayout(
+            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
+            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
+            - m_pParent->m_pImg->getWidth() / 2,
+            - m_pParent->m_pImg->getHeight() / 2 );
     }
     else
-        m_pControl->notifyLayout();
+        m_pParent->notifyLayout();
 }
 
 
 void CtrlSliderCursor::CmdOverUp::execute()
 {
-    m_pControl->m_pImg = m_pControl->m_pImgUp;
-    if( m_pControl->m_pImg )
+    m_pParent->m_pImg = m_pParent->m_pImgUp;
+    if( m_pParent->m_pImg )
     {
-        m_pControl->notifyLayout(
-            m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
-            m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
-            - m_pControl->m_pImg->getWidth() / 2,
-            - m_pControl->m_pImg->getHeight() / 2 );
+        m_pParent->notifyLayout(
+            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
+            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
+            - m_pParent->m_pImg->getWidth() / 2,
+            - m_pParent->m_pImg->getHeight() / 2 );
     }
     else
-        m_pControl->notifyLayout();
+        m_pParent->notifyLayout();
 }
 
 
 void CtrlSliderCursor::CmdMove::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
     // Get the position of the control
-    const Position *pPos = m_pControl->getPosition();
+    const Position *pPos = m_pParent->getPosition();
 
     // Compute the resize factors
     float factorX, factorY;
-    m_pControl->getResizeFactors( factorX, factorY );
+    m_pParent->getResizeFactors( factorX, factorY );
 
     // Compute the relative position of the centre of the cursor
-    float relX = pEvtMouse->getXPos() - pPos->getLeft() - m_pControl->m_xOffset;
-    float relY = pEvtMouse->getYPos() - pPos->getTop() - m_pControl->m_yOffset;
+    float relX = pEvtMouse->getXPos() - pPos->getLeft() - m_pParent->m_xOffset;
+    float relY = pEvtMouse->getYPos() - pPos->getTop() - m_pParent->m_yOffset;
     // Ponderate with the resize factors
     int relXPond = (int)(relX / factorX);
     int relYPond = (int)(relY / factorY);
 
     // Update the position
-    if( m_pControl->m_rCurve.getMinDist( relXPond, relYPond ) < RANGE )
+    if( m_pParent->m_rCurve.getMinDist( relXPond, relYPond ) < RANGE )
     {
-        float percentage = m_pControl->m_rCurve.getNearestPercent( relXPond,
+        float percentage = m_pParent->m_rCurve.getNearestPercent( relXPond,
                                                               relYPond );
-        m_pControl->m_rVariable.set( percentage );
+        m_pParent->m_rVariable.set( percentage );
     }
     else
     {
-        m_pControl->m_rVariable.set( m_pControl->m_lastPercentage );
+        m_pParent->m_rVariable.set( m_pParent->m_lastPercentage );
     }
 }
 
 void CtrlSliderCursor::CmdScroll::execute()
 {
-    EvtScroll *pEvtScroll = (EvtScroll*)m_pControl->m_pEvt;
+    EvtScroll *pEvtScroll = (EvtScroll*)m_pParent->m_pEvt;
 
     int direction = pEvtScroll->getDirection();
 
-    float percentage = m_pControl->m_rVariable.get();
+    float percentage = m_pParent->m_rVariable.get();
     if( direction == EvtScroll::kUp )
     {
         percentage += SCROLL_STEP;
@@ -307,7 +307,7 @@ void CtrlSliderCursor::CmdScroll::execute()
         percentage -= SCROLL_STEP;
     }
 
-    m_pControl->m_rVariable.set( percentage );
+    m_pParent->m_rVariable.set( percentage );
 }
 
 
index d7561452bae6bd281a52feb414624036aa91c10a..ec76b6a5eeeb1c731617d0e79b812fdf93f89010 100644 (file)
@@ -44,14 +44,14 @@ CtrlText::CtrlText( intf_thread_t *pIntf, VarText &rVariable,
                     const GenericFont &rFont, const UString &rHelp,
                     uint32_t color, VarBool *pVisible ):
     CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
-    m_rVariable( rVariable ), m_cmdToManual( pIntf, this ),
-    m_cmdManualMoving( pIntf, this ), m_cmdManualStill( pIntf, this ),
-    m_cmdMove( pIntf, this ), m_pEvt( NULL ), m_rFont( rFont ),
+    m_rVariable( rVariable ), m_cmdToManual( this ),
+    m_cmdManualMoving( this ), m_cmdManualStill( this ),
+    m_cmdMove( this ), m_pEvt( NULL ), m_rFont( rFont ),
     m_color( color ), m_pImg( NULL ), m_pImgDouble( NULL ),
-    m_pCurrImg( NULL ), m_xPos( 0 ), m_xOffset( 0 )
+    m_pCurrImg( NULL ), m_xPos( 0 ), m_xOffset( 0 ),
+    m_cmdUpdateText( this )
 {
-    m_pTimer = OSFactory::instance( getIntf() )->createOSTimer(
-        Callback( this, &updateText ) );
+    m_pTimer = OSFactory::instance( pIntf )->createOSTimer( m_cmdUpdateText );
 
     // States
     m_fsm.addState( "still" );
@@ -254,72 +254,70 @@ void CtrlText::onChangePosition()
 
 void CtrlText::CmdToManual::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
     // Compute the offset
-    m_pControl->m_xOffset = pEvtMouse->getXPos() - m_pControl->m_xPos;
+    m_pParent->m_xOffset = pEvtMouse->getXPos() - m_pParent->m_xPos;
 
-    m_pControl->m_pTimer->stop();
-    m_pControl->captureMouse();
+    m_pParent->m_pTimer->stop();
+    m_pParent->captureMouse();
 }
 
 
 void CtrlText::CmdManualMoving::execute()
 {
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 
     // Start the automatic movement, but only if the text is wider than the
     // control
-    if( m_pControl->m_pImg &&
-        m_pControl->m_pImg->getWidth() >= m_pControl->getPosition()->getWidth() )
+    if( m_pParent->m_pImg &&
+        m_pParent->m_pImg->getWidth() >= m_pParent->getPosition()->getWidth() )
     {
         // The current image may have been set incorrectly in displayText(), so
         // set the correct value
-        m_pControl->m_pCurrImg = m_pControl->m_pImgDouble;
+        m_pParent->m_pCurrImg = m_pParent->m_pImgDouble;
 
-        m_pControl->m_pTimer->start( MOVING_TEXT_DELAY, false );
+        m_pParent->m_pTimer->start( MOVING_TEXT_DELAY, false );
     }
 }
 
 
 void CtrlText::CmdManualStill::execute()
 {
-    m_pControl->releaseMouse();
+    m_pParent->releaseMouse();
 }
 
 
 void CtrlText::CmdMove::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
+    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
 
     // Do nothing if the text fits in the control
-    if( m_pControl->m_pImg &&
-        m_pControl->m_pImg->getWidth() >= m_pControl->getPosition()->getWidth() )
+    if( m_pParent->m_pImg &&
+        m_pParent->m_pImg->getWidth() >= m_pParent->getPosition()->getWidth() )
     {
         // The current image may have been set incorrectly in displayText(), so
         // we set the correct value
-        m_pControl->m_pCurrImg = m_pControl->m_pImgDouble;
+        m_pParent->m_pCurrImg = m_pParent->m_pImgDouble;
 
         // Compute the new position of the left side, and make sure it is
         // in the correct range
-        m_pControl->m_xPos = (pEvtMouse->getXPos() - m_pControl->m_xOffset);
-        m_pControl->adjust( m_pControl->m_xPos );
+        m_pParent->m_xPos = (pEvtMouse->getXPos() - m_pParent->m_xOffset);
+        m_pParent->adjust( m_pParent->m_xPos );
 
-        m_pControl->notifyLayout( m_pControl->getPosition()->getWidth(),
-                             m_pControl->getPosition()->getHeight() );
+        m_pParent->notifyLayout( m_pParent->getPosition()->getWidth(),
+                             m_pParent->getPosition()->getHeight() );
     }
 }
 
 
-void CtrlText::updateText( SkinObject *pCtrl )
+void CtrlText::CmdUpdateText::execute()
 {
-    CtrlText *m_pControl = (CtrlText*)pCtrl;
+    m_pParent->m_xPos -= MOVING_TEXT_STEP;
+    m_pParent->adjust( m_pParent->m_xPos );
 
-    m_pControl->m_xPos -= MOVING_TEXT_STEP;
-    m_pControl->adjust( m_pControl->m_xPos );
-
-    m_pControl->notifyLayout( m_pControl->getPosition()->getWidth(),
-                         m_pControl->getPosition()->getHeight() );
+    m_pParent->notifyLayout( m_pParent->getPosition()->getWidth(),
+                         m_pParent->getPosition()->getHeight() );
 }
 
 
index da6956cf44fdffe5cb7042fe10bb7d6c7ddee30b..1de9744f263df2710398ad5a2ee2f02c1b4ef505 100644 (file)
@@ -95,7 +95,7 @@ class CtrlText: public CtrlGeneric, public Observer<VarText>
         OSTimer *m_pTimer;
 
         /// Callback for the timer
-        static void updateText( SkinObject *pCtrl );
+        DEFINE_CALLBACK( CtrlText, UpdateText );
 
         /// Method called when the observed variable is modified
         virtual void onUpdate( Subject<VarText> &rVariable );
index 9c97ba9105ae6e576114f80067069a723b87125e..73fe300e3b3eade835e98b689fef87a776b99213 100644 (file)
@@ -31,6 +31,7 @@
 #include <list>
 
 class GenericWindow;
+class CmdGeneric;
 class OSBitmap;
 class OSGraphics;
 class OSLoop;
@@ -75,8 +76,8 @@ class OSFactory: public SkinObject
         ///
         virtual void minimize() = 0;
 
-        /// Instantiate an OSTimer with the given callback
-        virtual OSTimer *createOSTimer( const Callback &rCallback ) = 0;
+        /// Instantiate an OSTimer with the given command
+        virtual OSTimer *createOSTimer( CmdGeneric &rCmd ) = 0;
 
         /// Instantiate an object OSWindow.
         virtual OSWindow *createOSWindow( GenericWindow &rWindow,
index d38ec54185f5e2b04a0a2c59b5229d042d198f6b..4f0d4725010b03f2ef4ab092ff3871914bb495ad 100644 (file)
@@ -114,28 +114,6 @@ class SkinObject
         /// interface)
         intf_thread_t *getIntf() const { return m_pIntf; }
 
-        /// Class for callbacks
-        class Callback {
-            public:
-                /// Type for callback methods
-                typedef void (*CallbackFunc_t)( SkinObject* );
-
-                /// Create a callback with the given object and function
-                Callback( SkinObject *pObj, CallbackFunc_t pFunc ):
-                    m_pObj( pObj ), m_pFunc( pFunc ) {}
-                ~Callback() {}
-
-                /// Getters
-                SkinObject *getObj() const { return m_pObj; }
-                CallbackFunc_t getFunc() const { return m_pFunc; }
-
-            private:
-                /// Pointer on the callback object
-                SkinObject *const m_pObj;
-                /// Pointer on the callback method
-                CallbackFunc_t m_pFunc;
-        };
-
     private:
         intf_thread_t *m_pIntf;
 };
index 2378f42c0d82963a3fbe9b50dec76b8563dc28ae..f8f37b2065f67c34d70da21f0248cb96512f0218 100644 (file)
 
 Tooltip::Tooltip( intf_thread_t *pIntf, const GenericFont &rFont, int delay ):
     SkinObject( pIntf ), m_rFont( rFont ), m_delay( delay ), m_pImage( NULL ),
-    m_xPos( -1 ), m_yPos( -1 )
+    m_xPos( -1 ), m_yPos( -1 ), m_cmdShow( this )
 {
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
-    m_pTimer = pOsFactory->createOSTimer( Callback( this, &doShow ) );
+    m_pTimer = pOsFactory->createOSTimer( m_cmdShow );
     m_pOsTooltip = pOsFactory->createOSTooltip();
 
     // Observe the tooltip text variable
@@ -119,22 +119,20 @@ void Tooltip::makeImage( const UString &rText )
 }
 
 
-void Tooltip::doShow( SkinObject *pObj )
+void Tooltip::CmdShow::execute()
 {
-    Tooltip *pThis = (Tooltip*)pObj;
-
-    if( pThis->m_pImage )
+    if( m_pParent->m_pImage )
     {
-        if( pThis->m_xPos == -1 )
+        if( m_pParent->m_xPos == -1 )
         {
             // Get the mouse coordinates and the image size
-            OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+            OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
             int x, y;
             pOsFactory->getMousePos( x, y );
             int scrWidth = pOsFactory->getScreenWidth();
             int scrHeight = pOsFactory->getScreenHeight();
-            int w = pThis->m_pImage->getWidth();
-            int h = pThis->m_pImage->getHeight();
+            int w = m_pParent->m_pImage->getWidth();
+            int h = m_pParent->m_pImage->getHeight();
 
             // Compute the position of the tooltip
             x -= (w / 2 + 4);
@@ -146,13 +144,13 @@ void Tooltip::doShow( SkinObject *pObj )
             if( y + h > scrHeight )
                 y -= (2 * h + 20);
 
-            pThis->m_xPos = x;
-            pThis->m_yPos = y;
+            m_pParent->m_xPos = x;
+            m_pParent->m_yPos = y;
         }
 
         // Show the tooltip window
-        pThis->m_pOsTooltip->show( pThis->m_xPos, pThis->m_yPos,
-                                   *(pThis->m_pImage) );
+        m_pParent->m_pOsTooltip->show( m_pParent->m_xPos, m_pParent->m_yPos,
+                                   *(m_pParent->m_pImage) );
     }
 }
 
index fd2a7be1edf414b7a8559e7065f86c80db8d22e7..2e6648737ec04dea66f93787fc114b1bf246d789 100644 (file)
@@ -26,6 +26,7 @@
 #define TOOLTIP_HPP
 
 #include "../utils/var_text.hpp"
+#include "../commands/cmd_generic.hpp"
 
 class GenericFont;
 class OSTooltip;
@@ -72,8 +73,8 @@ class Tooltip: public SkinObject, public Observer<VarText>
         /// Build m_pImage with the given text
         void makeImage( const UString &rText );
 
-        /// Show the tooltip window
-        static void doShow( SkinObject *pObj );
+        /// Callback to show the tooltip window
+        DEFINE_CALLBACK( Tooltip, Show );
 };
 
 
index d8134f5a6b0d41eee0b85d4d2aa1db46e17ab956..80543cbde9a5cd9e1f4f55c1e9988423da9fd860 100644 (file)
@@ -60,11 +60,12 @@ void VlcProc::destroy( intf_thread_t *pIntf )
 }
 
 
-VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_pVout( NULL )
+VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_pVout( NULL ),
+    m_cmdManage( this )
 {
     // Create a timer to poll the status of the vlc
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
-    m_pTimer = pOsFactory->createOSTimer( Callback( this, &doManage ) );
+    m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
     m_pTimer->start( 100, false );
 
     // Create and register VLC variables
@@ -272,10 +273,10 @@ void VlcProc::manage()
 }
 
 
-void VlcProc::doManage( SkinObject *pObj )
+void VlcProc::CmdManage::execute()
 {
-    VlcProc *pThis = (VlcProc*)pObj;
-    pThis->manage();
+    // Just forward to VlcProc
+    m_pParent->manage();
 }
 
 
index e8a563671af185b3e2c19ffa9bc3f6e6b1593b67..b894b9e1eec64d03c9f4f1e7eb4b08964f61441f 100644 (file)
@@ -31,6 +31,7 @@
 #include "../vars/time.hpp"
 #include "../vars/volume.hpp"
 #include "../utils/var_text.hpp"
+#include "../commands/cmd_generic.hpp"
 
 class OSTimer;
 class VarBool;
@@ -123,13 +124,12 @@ class VlcProc: public SkinObject
          */
         void manage();
 
+        /// Define the command that calls manage()
+        DEFINE_CALLBACK( VlcProc, Manage );
+
         /// Update the stream name variable
         void updateStreamName( playlist_t *p_playlist );
 
-        /// This function directly calls manage(), because it's boring to
-        /// always write "pThis->"
-        static void doManage( SkinObject *pObj );
-
         /// Callback for intf-change variable
         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
                                  vlc_value_t oldVal, vlc_value_t newVal,
index 4edbb4cb6e92462c97cac811632f5fc6ec3ea3a1..d3733eb620b0a6837735aad9663c4d9825949aa0 100644 (file)
@@ -237,9 +237,9 @@ void Win32Factory::minimize()
     ShowWindow( m_hParentWindow, SW_MINIMIZE );
 }
 
-OSTimer *Win32Factory::createOSTimer( const Callback &rCallback )
+OSTimer *Win32Factory::createOSTimer( CmdGeneric &rCmd )
 {
-    return new Win32Timer( getIntf(), rCallback, m_hParentWindow );
+    return new Win32Timer( getIntf(), rCmd, m_hParentWindow );
 }
 
 
index 665c679e07426901d8a944e77cbb82ad7e8a5671..0855acbd5cadfc3b44f45f4db94c0ce98ea6e45c 100644 (file)
@@ -56,8 +56,8 @@ class Win32Factory: public OSFactory
         ///
         virtual void minimize();
 
-        /// Instantiate an OSTimer with the given callback
-        virtual OSTimer *createOSTimer( const Callback &rCallback );
+        /// Instantiate an OSTimer with the given command
+        virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
 
         /// Instantiate an OSWindow object
         virtual OSWindow *createOSWindow( GenericWindow &rWindow,
index 3e3becba526049b52544e71adfba6dd2715c32ff..96325f1b5823b2925f60c30434ea71f1f2a7a20e 100644 (file)
@@ -25,6 +25,7 @@
 #ifdef WIN32_SKINS
 
 #include "win32_timer.hpp"
+#include "../commands/cmd_generic.hpp"
 
 
 void CALLBACK CallbackTimer( HWND hwnd, UINT uMsg,
@@ -38,9 +39,8 @@ void CALLBACK CallbackTimer( HWND hwnd, UINT uMsg,
 }
 
 
-Win32Timer::Win32Timer( intf_thread_t *pIntf, const Callback &rCallback,
-                        HWND hWnd ):
-    OSTimer( pIntf ), m_callback( rCallback ), m_hWnd( hWnd )
+Win32Timer::Win32Timer( intf_thread_t *pIntf, CmdGeneric &rCmd, HWND hWnd ):
+    OSTimer( pIntf ), m_rCommand( rCmd ), m_hWnd( hWnd )
 {
 }
 
@@ -68,7 +68,7 @@ void Win32Timer::stop()
 void Win32Timer::execute()
 {
     // Execute the callback
-    (*(m_callback.getFunc()))( m_callback.getObj() );
+    m_rCommand.execute();
 
     // Restart the timer if needed
     if( ! m_oneShot )
index f3e2e3d4cae4d474019196b6508176cf3ab37e10..463006ef24dcb8ea820eb3a9615adc12a4488539 100644 (file)
 
 #include "../src/os_timer.hpp"
 
+class CmdGeneric;
 
 // Win32 specific timer
 class Win32Timer: public OSTimer
 {
     public:
-        Win32Timer( intf_thread_t *pIntf, const Callback &rCallback,
-                    HWND hWnd );
+        Win32Timer( intf_thread_t *pIntf, CmdGeneric &rCmd, HWND hWnd );
         virtual ~Win32Timer();
 
         /// (Re)start the timer with the given delay (in ms). If oneShot is
@@ -47,8 +47,8 @@ class Win32Timer: public OSTimer
         void execute();
 
     private:
-        /// Callback to execute
-        Callback m_callback;
+        /// Command to execute
+        CmdGeneric &m_rCommand;
 
         /// Delay between two execute
         mtime_t m_interval;
index 32352e56eec820a1b8a628cf4c6edfd6423051a3..7031d1c160ba8013eb9acb94d7b4d092a1f15a6f 100644 (file)
@@ -102,9 +102,9 @@ void X11Factory::minimize()
                     DefaultScreen( m_pDisplay->getDisplay() ) );
 }
 
-OSTimer *X11Factory::createOSTimer( const Callback &rCallback )
+OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd )
 {
-    return new X11Timer( getIntf(), rCallback );
+    return new X11Timer( getIntf(), rCmd );
 }
 
 
index 1d944d67bec23a045b46d1c004fd29280120bfd0..5e5e8401776365d8e692e3e2b490c42b70082f33 100644 (file)
@@ -59,8 +59,8 @@ class X11Factory: public OSFactory
         /// Destroy the instance of OSLoop.
         virtual void destroyOSLoop();
 
-        /// Instantiate an OSTimer with the given callback
-        virtual OSTimer *createOSTimer( const Callback &rCallback );
+        /// Instantiate an OSTimer with the given command
+        virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
 
         ///
         virtual void minimize();
index 88188cd2689b6c185354ed87ea00ff80dc3579a7..2d0828e4028582c79c0b23e63590312539fd1429 100644 (file)
 
 #include "x11_timer.hpp"
 #include "x11_factory.hpp"
+#include "../commands/cmd_generic.hpp"
 
 
-X11Timer::X11Timer( intf_thread_t *pIntf, const Callback &rCallback ):
-    OSTimer( pIntf ), m_callback( rCallback )
+X11Timer::X11Timer( intf_thread_t *pIntf, CmdGeneric &rCmd ):
+    OSTimer( pIntf ), m_rCommand( rCmd )
 {
     // Get the instance of timer loop
     X11Factory *m_pOsFactory = (X11Factory*)(OSFactory::instance( pIntf ) );
@@ -71,7 +72,7 @@ bool X11Timer::execute()
 {
     m_nextDate += m_interval;
     // Execute the callback
-    (*(m_callback.getFunc()))( m_callback.getObj() );
+    m_rCommand.execute();
 
     return !m_oneShot;
 }
index 88073069ceb2ecd25a7d4ffa76fb217e5140ccf1..e22cc8f98abb5514624b589e73ad93b5d3462761 100644 (file)
 
 // Forward declaration
 class X11TimerLoop;
+class CmdGeneric;
 
 
 // X11 specific timer
 class X11Timer: public OSTimer
 {
     public:
-        X11Timer( intf_thread_t *pIntf, const Callback &rCallback );
+        X11Timer( intf_thread_t *pIntf, CmdGeneric &rCmd );
         virtual ~X11Timer();
 
         /// (Re)start the timer with the given delay (in ms). If oneShot is
@@ -54,8 +55,8 @@ class X11Timer: public OSTimer
         bool execute();
 
     private:
-        /// Callback to execute
-        Callback m_callback;
+        /// Command to execute
+        CmdGeneric m_rCommand;
         /// Timer loop
         X11TimerLoop *m_pTimerLoop;
         /// Delay between two execute