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

win32_timer.cpp

00001 /*****************************************************************************
00002  * win32_timer.cpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: win32_timer.cpp 12207 2005-08-15 15:54:32Z asmax $
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 #ifdef WIN32_SKINS
00026 
00027 #include "win32_timer.hpp"
00028 #include "../commands/cmd_generic.hpp"
00029 
00030 
00031 void CALLBACK CallbackTimer( HWND hwnd, UINT uMsg,
00032                              UINT_PTR idEvent, DWORD dwTime )
00033 {
00034     Win32Timer *pTimer = (Win32Timer*)idEvent;
00035     if( pTimer != NULL )
00036     {
00037         pTimer->execute();
00038     }
00039 }
00040 
00041 
00042 Win32Timer::Win32Timer( intf_thread_t *pIntf, CmdGeneric &rCmd, HWND hWnd ):
00043     OSTimer( pIntf ), m_rCommand( rCmd ), m_hWnd( hWnd )
00044 {
00045 }
00046 
00047 
00048 Win32Timer::~Win32Timer()
00049 {
00050     stop();
00051 }
00052 
00053 
00054 void Win32Timer::start( int delay, bool oneShot )
00055 {
00056     m_interval = delay;
00057     m_oneShot = oneShot;
00058     SetTimer( m_hWnd, (UINT_PTR)this, m_interval, (TIMERPROC)CallbackTimer );
00059 }
00060 
00061 
00062 void Win32Timer::stop()
00063 {
00064     KillTimer( m_hWnd, (UINT_PTR)this );
00065 }
00066 
00067 
00068 void Win32Timer::execute()
00069 {
00070     // Execute the callback
00071     m_rCommand.execute();
00072 
00073     // Restart the timer if needed
00074     if( ! m_oneShot )
00075     {
00076         start( m_interval, m_oneShot );
00077     }
00078 }
00079 
00080 #endif

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