1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #include "ctrl_generic.hpp"
26 #include "../src/generic_layout.hpp"
27 #include "../src/top_window.hpp"
28 #include "../src/os_graphics.hpp"
29 #include "../utils/position.hpp"
30 #include "../utils/var_bool.hpp"
33 CtrlGeneric::CtrlGeneric( intf_thread_t *pIntf, const UString &rHelp,
35 SkinObject( pIntf ), m_pLayout( NULL ), m_pPosition( NULL ),
36 m_help( rHelp ), m_pVisible( pVisible )
38 // Observe the visibility variable
41 m_pVisible->addObserver( this );
46 CtrlGeneric::~CtrlGeneric()
54 m_pVisible->delObserver( this );
59 void CtrlGeneric::setLayout( GenericLayout *pLayout,
60 const Position &rPosition )
67 m_pPosition = new Position( rPosition );
72 void CtrlGeneric::notifyLayout( int width, int height,
73 int xOffSet, int yOffSet ) const
78 m_pLayout->onControlUpdate( *this, width, height, xOffSet, yOffSet );
83 void CtrlGeneric::notifyLayoutMaxSize( const Box *pImg1, const Box *pImg2 )
93 notifyLayout( pImg2->getWidth(), pImg2->getHeight() );
100 notifyLayout( pImg1->getWidth(), pImg1->getHeight() );
104 notifyLayout( max( pImg1->getWidth(), pImg2->getWidth() ),
105 max( pImg1->getHeight(), pImg2->getHeight() ) );
111 void CtrlGeneric::captureMouse() const
113 // Tell the layout we want to capture the mouse
116 m_pLayout->onControlCapture( *this );
121 void CtrlGeneric::releaseMouse() const
123 // Tell the layout we want to release the mouse
126 m_pLayout->onControlRelease( *this );
131 void CtrlGeneric::notifyTooltipChange() const
133 TopWindow *pWin = getWindow();
137 pWin->onTooltipChange( *this );
142 TopWindow *CtrlGeneric::getWindow() const
146 return m_pLayout->getWindow();
152 bool CtrlGeneric::isVisible() const
154 return !m_pVisible || m_pVisible->get();
158 void CtrlGeneric::onUpdate( Subject<VarBool, void*> &rVariable, void *arg )
160 // Is it the visibility variable ?
161 if( &rVariable == m_pVisible )
168 // Call the user-defined callback
169 onVarBoolUpdate( (VarBool&)rVariable );