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"
35 CtrlGeneric::CtrlGeneric( intf_thread_t *pIntf, const UString &rHelp,
37 SkinObject( pIntf ), m_pLayout( NULL ), m_pPosition( NULL ),
38 m_help( rHelp ), m_pVisible( pVisible )
40 // Observe the visibility variable
43 m_pVisible->addObserver( this );
48 CtrlGeneric::~CtrlGeneric()
52 m_pVisible->delObserver( this );
57 void CtrlGeneric::setLayout( GenericLayout *pLayout,
58 const Position &rPosition )
60 assert( !m_pLayout && pLayout);
63 m_pPosition = new Position( rPosition );
67 void CtrlGeneric::unsetLayout()
76 void CtrlGeneric::notifyLayout( int width, int height,
77 int xOffSet, int yOffSet )
79 width = ( width > 0 ) ? width : m_pPosition->getWidth();
80 height = ( height > 0 ) ? height : m_pPosition->getHeight();
85 m_pLayout->onControlUpdate( *this, width, height, xOffSet, yOffSet );
90 void CtrlGeneric::notifyLayoutMaxSize( const Box *pImg1, const Box *pImg2 )
100 notifyLayout( pImg2->getWidth(), pImg2->getHeight() );
107 notifyLayout( pImg1->getWidth(), pImg1->getHeight() );
111 notifyLayout( max( pImg1->getWidth(), pImg2->getWidth() ),
112 max( pImg1->getHeight(), pImg2->getHeight() ) );
118 void CtrlGeneric::captureMouse() const
120 // Tell the layout we want to capture the mouse
123 m_pLayout->onControlCapture( *this );
128 void CtrlGeneric::releaseMouse() const
130 // Tell the layout we want to release the mouse
133 m_pLayout->onControlRelease( *this );
138 void CtrlGeneric::notifyTooltipChange() const
140 TopWindow *pWin = getWindow();
144 pWin->onTooltipChange( *this );
149 TopWindow *CtrlGeneric::getWindow() const
153 return m_pLayout->getWindow();
159 bool CtrlGeneric::isVisible() const
161 return !m_pVisible || m_pVisible->get();
165 void CtrlGeneric::onUpdate( Subject<VarBool> &rVariable, void *arg )
167 // Is it the visibility variable ?
168 if( &rVariable == m_pVisible )
175 // Call the user-defined callback
176 onVarBoolUpdate( (VarBool&)rVariable );