Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

generic_window.cpp

00001 /*****************************************************************************
00002  * generic_window.cpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: generic_window.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Cyril Deguet     <[email protected]>
00008  *          Olivier Teulière <[email protected]>
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 #include "generic_window.hpp"
00026 #include "os_window.hpp"
00027 #include "os_factory.hpp"
00028 #include "../events/evt_refresh.hpp"
00029 
00030 
00031 GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
00032                               bool dragDrop, bool playOnDrop,
00033                               GenericWindow *pParent ):
00034     SkinObject( pIntf ), m_left( left ), m_top( top ), m_width( 0 ),
00035     m_height( 0 ), m_varVisible( pIntf )
00036 {
00037    // Get the OSFactory
00038     OSFactory *pOsFactory = OSFactory::instance( getIntf() );
00039 
00040     // Get the parent OSWindow, if any
00041     OSWindow *pOSParent = NULL;
00042     if( pParent )
00043     {
00044         pOSParent = pParent->m_pOsWindow;
00045     }
00046 
00047     // Create an OSWindow to handle OS specific processing
00048     m_pOsWindow = pOsFactory->createOSWindow( *this, dragDrop, playOnDrop,
00049                                               pOSParent );
00050 
00051     // Observe the visibility variable
00052     m_varVisible.addObserver( this );
00053 }
00054 
00055 
00056 GenericWindow::~GenericWindow()
00057 {
00058     m_varVisible.delObserver( this );
00059 
00060     if( m_pOsWindow )
00061     {
00062         delete m_pOsWindow;
00063     }
00064 }
00065 
00066 
00067 void GenericWindow::processEvent( EvtRefresh &rEvtRefresh )
00068 {
00069     // Refresh the given area
00070     refresh( rEvtRefresh.getXStart(), rEvtRefresh.getYStart(),
00071              rEvtRefresh.getWidth(), rEvtRefresh.getHeight() );
00072 }
00073 
00074 
00075 void GenericWindow::show() const
00076 {
00077     m_varVisible.set( true );
00078 }
00079 
00080 
00081 void GenericWindow::hide() const
00082 {
00083     m_varVisible.set( false );
00084 }
00085 
00086 
00087 void GenericWindow::move( int left, int top )
00088 {
00089     // Update the window coordinates
00090     m_left = left;
00091     m_top = top;
00092 
00093     m_pOsWindow->moveResize( left, top, m_width, m_height );
00094 }
00095 
00096 
00097 void GenericWindow::resize( int width, int height )
00098 {
00099     // Update the window size
00100     m_width = width;
00101     m_height = height;
00102 
00103     m_pOsWindow->moveResize( m_left, m_top, width, height );
00104 }
00105 
00106 
00107 void GenericWindow::raise() const
00108 {
00109     m_pOsWindow->raise();
00110 }
00111 
00112 
00113 void GenericWindow::setOpacity( uint8_t value )
00114 {
00115     m_pOsWindow->setOpacity( value );
00116 }
00117 
00118 
00119 void GenericWindow::toggleOnTop( bool onTop ) const
00120 {
00121     m_pOsWindow->toggleOnTop( onTop );
00122 }
00123 
00124 
00125 void GenericWindow::onUpdate( Subject<VarBool> &rVariable )
00126 {
00127     if( m_varVisible.get() )
00128     {
00129         innerShow();
00130     }
00131     else
00132     {
00133         innerHide();
00134     }
00135 }
00136 
00137 
00138 void GenericWindow::innerShow()
00139 {
00140     if( m_pOsWindow )
00141     {
00142         m_pOsWindow->show( m_left, m_top );
00143     }
00144 }
00145 
00146 
00147 void GenericWindow::innerHide()
00148 {
00149     if( m_pOsWindow )
00150     {
00151         m_pOsWindow->hide();
00152     }
00153 }
00154 

Generated on Tue Dec 20 10:14:42 2005 for vlc-0.8.4a by  doxygen 1.4.2