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

interface.cpp

00001 /*****************************************************************************
00002  * interface.cpp: WinCE gui plugin for VLC
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: interface.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Marodon Cedric <[email protected]>
00008  *          Gildas Bazin <[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,
00023  * USA.
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027  * Preamble
00028  *****************************************************************************/
00029 #include <vlc/vlc.h>
00030 #include <vlc/aout.h>
00031 #include <vlc/vout.h>
00032 #include <vlc/intf.h>
00033 
00034 #include "wince.h"
00035 
00036 #include <windowsx.h>
00037 #include <commctrl.h>
00038 #include <commdlg.h>
00039 
00040 #define NUMIMAGES     9   // Number of buttons in the toolbar           
00041 #define IMAGEWIDTH    17   // Width of the buttons in the toolbar  
00042 #define IMAGEHEIGHT   16   // Height of the buttons in the toolbar  
00043 #define BUTTONWIDTH   0    // Width of the button images in the toolbar
00044 #define BUTTONHEIGHT  0    // Height of the button images in the toolbar
00045 #define ID_TOOLBAR    2000 // Identifier of the main tool bar
00046 
00047 // Help strings
00048 #define HELP_SIMPLE _T("Quick file open")
00049 #define HELP_ADV    _T("Advanced open")
00050 #define HELP_FILE   _T("Open a file")
00051 #define HELP_DISC   _T("Open Disc Media")
00052 #define HELP_NET    _T("Open a network stream")
00053 #define HELP_SAT    _T("Open a satellite stream")
00054 #define HELP_EJECT  _T("Eject the DVD/CD")
00055 #define HELP_EXIT   _T("Exit this program")
00056 
00057 #define HELP_OTHER _T("Open other types of inputs")
00058 
00059 #define HELP_PLAYLIST   _T("Open the playlist")
00060 #define HELP_LOGS       _T("Show the program logs")
00061 #define HELP_FILEINFO   _T("Show information about the file being played")
00062 
00063 #define HELP_PREFS _T("Go to the preferences menu")
00064 
00065 #define HELP_ABOUT _T("About this program")
00066 
00067 #define HELP_STOP _T("Stop")
00068 
00069 #define HELP_PLAY _T("Play")
00070 #define HELP_PAUSE _T("Pause")
00071 #define HELP_PLO _T("Playlist")
00072 #define HELP_PLP _T("Previous playlist item")
00073 #define HELP_PLN _T("Next playlist item")
00074 #define HELP_SLOW _T("Play slower")
00075 #define HELP_FAST _T("Play faster")
00076 
00077 // The TBBUTTON structure contains information the toolbar buttons.
00078 static TBBUTTON tbButton[] =      
00079 {
00080   {0, ID_FILE_QUICKOPEN,        TBSTATE_ENABLED, TBSTYLE_BUTTON},
00081   {1, ID_FILE_OPENNET,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
00082   {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
00083   {2, StopStream_Event,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
00084   {3, PlayStream_Event,        TBSTATE_ENABLED, TBSTYLE_BUTTON},
00085   {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
00086   {4, ID_VIEW_PLAYLIST,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
00087   {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
00088   {5, PrevStream_Event,      TBSTATE_ENABLED, TBSTYLE_BUTTON},
00089   {6, NextStream_Event,      TBSTATE_ENABLED, TBSTYLE_BUTTON},
00090   {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
00091   {7, SlowStream_Event,      TBSTATE_ENABLED, TBSTYLE_BUTTON},
00092   {8, FastStream_Event,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
00093 };
00094 
00095 // Toolbar ToolTips
00096 TCHAR * szToolTips[] = 
00097 {
00098     HELP_SIMPLE, HELP_NET, HELP_STOP, HELP_PLAY, HELP_PLO, HELP_PLP,
00099     HELP_PLN, HELP_SLOW, HELP_FAST
00100 };
00101 
00102 /*****************************************************************************
00103  * Constructor.
00104  *****************************************************************************/
00105 Interface::Interface( intf_thread_t *p_intf, CBaseWindow *p_parent,
00106                       HINSTANCE h_inst )
00107   : CBaseWindow( p_intf, p_parent, h_inst ),
00108     hwndMain(0), hwndCB(0), hwndTB(0), hwndSlider(0), hwndLabel(0),
00109     hwndVol(0), hwndSB(0), timer(0), video(0), b_volume_hold(0)
00110 {
00111 }
00112 
00113 Interface::~Interface()
00114 {
00115     if( timer ) delete timer;
00116     if( video ) delete video;
00117 }
00118 
00119 BOOL Interface::InitInstance()
00120 {
00121     /* Initializations */
00122     i_old_playing_status = PAUSE_S;
00123 
00124     int i_style = WS_VISIBLE;
00125 
00126 #ifndef UNDER_CE
00127     i_style |= WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
00128 #endif
00129 
00130     // Create main window
00131     hwndMain =
00132         CreateWindow( _T("VLC WinCE"), _T("VLC media player"), i_style,
00133                       0, MENU_HEIGHT, CW_USEDEFAULT, CW_USEDEFAULT,
00134                       NULL, NULL, GetInstance(), (void *)this );
00135 
00136     if( !hwndMain ) return FALSE;
00137 
00138     ShowWindow( hwndMain, TRUE );
00139     UpdateWindow( hwndMain );
00140 
00141     return TRUE;
00142 }
00143 
00144 /***********************************************************************
00145 FUNCTION: 
00146   CreateMenuBar
00147 
00148 PURPOSE: 
00149   Creates a menu bar.
00150 ***********************************************************************/
00151 HWND Interface::CreateMenuBar( HWND hwnd, HINSTANCE hInst )
00152 {
00153     HMENU menu_file, menu_view;
00154 
00155 #ifdef UNDER_CE
00156     SHMENUBARINFO mbi;
00157     memset( &mbi, 0, sizeof(SHMENUBARINFO) );
00158     mbi.cbSize     = sizeof(SHMENUBARINFO);
00159     mbi.hwndParent = hwnd;
00160     mbi.hInstRes   = hInst;
00161     mbi.nToolBarId = IDR_MENUBAR;
00162 
00163     if( !SHCreateMenuBar( &mbi ) )
00164     {
00165         MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
00166         return 0;
00167     }
00168 
00169     TBBUTTONINFO tbbi;
00170     tbbi.cbSize = sizeof(tbbi);
00171     tbbi.dwMask = TBIF_LPARAM;
00172 
00173     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_FILE, (LPARAM)&tbbi );
00174     menu_file = (HMENU)tbbi.lParam;
00175     RemoveMenu( menu_file, 0, MF_BYPOSITION );
00176     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIEW, (LPARAM)&tbbi );
00177     menu_view = (HMENU)tbbi.lParam;
00178     RemoveMenu( menu_view, 0, MF_BYPOSITION );
00179     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_SETTINGS, (LPARAM)&tbbi );
00180     menu_settings = (HMENU)tbbi.lParam;
00181     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIDEO, (LPARAM)&tbbi );
00182     menu_video = (HMENU)tbbi.lParam;
00183     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_AUDIO, (LPARAM)&tbbi );
00184     menu_audio = (HMENU)tbbi.lParam;
00185     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_NAVIGATION, (LPARAM)&tbbi );
00186     menu_navigation = (HMENU)tbbi.lParam;
00187 
00188 #else
00189     menu_file = CreatePopupMenu();
00190     menu_view = CreatePopupMenu();
00191     menu_settings = CreatePopupMenu();
00192     menu_audio = CreatePopupMenu();
00193     menu_video = CreatePopupMenu();
00194     menu_navigation = CreatePopupMenu();
00195 #endif
00196 
00197     AppendMenu( menu_file, MF_STRING, ID_FILE_QUICKOPEN,
00198                 _T("Quick &Open File...") );
00199     AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
00200     AppendMenu( menu_file, MF_STRING, ID_FILE_OPENFILE,
00201                 _T("Open &File...") );
00202     AppendMenu( menu_file, MF_STRING, ID_FILE_OPENDIR,
00203                 _T("Open &Directory...") );
00204     AppendMenu( menu_file, MF_STRING, ID_FILE_OPENNET,
00205                 _T("Open &Network Stream...") );
00206     AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
00207     AppendMenu( menu_file, MF_STRING, ID_FILE_ABOUT,
00208                 _T("About VLC") );
00209     AppendMenu( menu_file, MF_STRING, ID_FILE_EXIT,
00210                 _T("E&xit") );
00211 
00212     AppendMenu( menu_view, MF_STRING, ID_VIEW_PLAYLIST,
00213                 _T("&Playlist...") );
00214     AppendMenu( menu_view, MF_STRING, ID_VIEW_MESSAGES,
00215                 _T("&Messages...") );
00216     AppendMenu( menu_view, MF_STRING, ID_VIEW_STREAMINFO,
00217                 _T("Stream and Media &info...") );
00218 
00219     AppendMenu( menu_settings, MF_STRING, ID_PREFERENCES,
00220                 _T("&Preferences...") );
00221 
00222 
00223 #ifdef UNDER_CE
00224     return mbi.hwndMB;
00225 
00226 #else
00227     HMENU hmenu = CreateMenu();
00228 
00229     AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_file, _T("File") );
00230     AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_view, _T("View") );
00231     AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_settings,
00232                 _T("Settings") );
00233     AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_audio, _T("Audio") );
00234     AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_video, _T("Video") );
00235     AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_navigation, _T("Nav") );
00236 
00237     SetMenu( hwnd, hmenu );
00238     return 0;
00239 
00240 #endif
00241 }
00242 
00243 /***********************************************************************
00244 FUNCTION: 
00245   CreateToolBar
00246 
00247 PURPOSE: 
00248   Registers the TOOLBAR control class and creates a toolbar.
00249 ***********************************************************************/
00250 HWND CreateToolBar( HWND hwnd, HINSTANCE hInst )
00251 {
00252     DWORD dwStyle;
00253     HWND hwndTB;
00254     RECT rect, rectTB;
00255 
00256     INITCOMMONCONTROLSEX iccex;
00257     iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
00258     iccex.dwICC = ICC_BAR_CLASSES;
00259 
00260     // Registers TOOLBAR control classes from the common control dll
00261     InitCommonControlsEx (&iccex);
00262 
00263     //  Create the toolbar control
00264     dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS |
00265         WS_EX_OVERLAPPEDWINDOW | CCS_NOPARENTALIGN;
00266 
00267     hwndTB = CreateToolbarEx( hwnd, dwStyle, 0, NUMIMAGES,
00268         hInst, IDB_BITMAP1, tbButton, sizeof(tbButton) / sizeof(TBBUTTON),
00269         BUTTONWIDTH, BUTTONHEIGHT, IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON) );
00270 
00271     if( !hwndTB ) return NULL;
00272   
00273     // Add ToolTips to the toolbar.
00274     SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM)NUMIMAGES, 
00275                  (LPARAM)szToolTips );
00276 
00277     // Reposition the toolbar.
00278     GetClientRect( hwnd, &rect );
00279     GetWindowRect( hwndTB, &rectTB );
00280     MoveWindow( hwndTB, rect.left, rect.bottom - rect.top - 2*MENU_HEIGHT, 
00281                 rect.right - rect.left, MENU_HEIGHT, TRUE );
00282 
00283     return hwndTB;
00284 }
00285 
00286 /***********************************************************************
00287 
00288 FUNCTION: 
00289   CreateSliderBar
00290 
00291 PURPOSE: 
00292   Registers the TRACKBAR_CLASS control class and creates a trackbar.
00293 
00294 ***********************************************************************/
00295 HWND CreateSliderBar( HWND hwnd, HINSTANCE hInst )
00296 {
00297     HWND hwndSlider;
00298     RECT rect;
00299 
00300     INITCOMMONCONTROLSEX iccex;
00301     iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
00302     iccex.dwICC = ICC_BAR_CLASSES;
00303 
00304     // Registers TRACKBAR_CLASS control classes from the common control dll
00305     InitCommonControlsEx( &iccex );
00306 
00307     hwndSlider = CreateWindowEx( 0, TRACKBAR_CLASS, NULL,
00308                 WS_CHILD | WS_VISIBLE | TBS_HORZ | WS_EX_OVERLAPPEDWINDOW |
00309                 TBS_BOTTOM,  //|WS_CLIPSIBLINGS,
00310                 0, 0, 0, 0, hwnd, NULL, hInst, NULL );
00311 
00312     if( !hwndSlider ) return NULL;
00313 
00314     SendMessage( hwndSlider, TBM_SETRANGEMIN, 1, 0 );
00315     SendMessage( hwndSlider, TBM_SETRANGEMAX, 1, SLIDER_MAX_POS );
00316     SendMessage( hwndSlider, TBM_SETPOS, 1, 0 );
00317 
00318     // Reposition the trackbar
00319     GetClientRect( hwnd, &rect );
00320     MoveWindow( hwndSlider, rect.left, 
00321                 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT, 
00322                 rect.right - rect.left - 40, 30, TRUE );
00323 
00324     ShowWindow( hwndSlider, SW_HIDE );
00325 
00326     return hwndSlider;
00327 }
00328 
00329 HWND CreateStaticText( HWND hwnd, HINSTANCE hInst )
00330 {
00331     HWND hwndLabel;
00332     RECT rect;
00333 
00334     hwndLabel = CreateWindowEx( 0, _T("STATIC"), _T("label"),
00335                                 WS_CHILD | WS_VISIBLE | SS_CENTER ,
00336                                 0, 0, 0, 0, hwnd, (HMENU)1980, hInst, NULL );
00337 
00338     // Reposition the trackbar
00339     GetClientRect( hwnd, &rect );
00340 
00341     MoveWindow( hwndLabel, rect.left,
00342                 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT +30,
00343                 rect.right - rect.left - 40,
00344                 SLIDER_HEIGHT - 30, TRUE );
00345 
00346     ShowWindow( hwndLabel, SW_HIDE );
00347 
00348     return hwndLabel;
00349 }
00350 
00351 /***********************************************************************
00352 
00353 FUNCTION: 
00354   CreateVolTrackBar
00355 
00356 PURPOSE: 
00357   Registers the TRACKBAR_CLASS control class and creates a trackbar.
00358 
00359 ***********************************************************************/
00360 HWND CreateVolTrackBar( HWND hwnd, HINSTANCE hInst )
00361 {
00362     HWND hwndVol;
00363     RECT rect;
00364 
00365     INITCOMMONCONTROLSEX iccex;
00366     iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
00367     iccex.dwICC = ICC_BAR_CLASSES;
00368 
00369     // Registers TRACKBAR_CLASS control classes from the common control dll
00370     InitCommonControlsEx( &iccex );
00371 
00372     hwndVol = CreateWindowEx( 0, TRACKBAR_CLASS, NULL,
00373                 WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_RIGHT | TBS_AUTOTICKS |
00374                 WS_EX_OVERLAPPEDWINDOW, //|WS_CLIPSIBLINGS,
00375                 0, 0, 0, 0, hwnd, NULL, hInst, NULL );
00376 
00377     if( !hwndVol ) return NULL;
00378 
00379     SendMessage( hwndVol, TBM_SETRANGEMIN, 1, 0 );
00380     SendMessage( hwndVol, TBM_SETRANGEMAX, 1, 200 );
00381     SendMessage( hwndVol, TBM_SETPOS, 1, 100 );
00382     SendMessage( hwndVol, TBM_SETTICFREQ, 50, 0 );  
00383 
00384     // Reposition the trackbar
00385     GetClientRect( hwnd, &rect );
00386     MoveWindow( hwndVol, rect.right - rect.left - 40, 
00387                 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT, 
00388                 40, SLIDER_HEIGHT, TRUE );
00389 
00390     ShowWindow( hwndVol, SW_HIDE );
00391 
00392     return hwndVol;
00393 }
00394 
00395 /***********************************************************************
00396 
00397 FUNCTION: 
00398   CreateStatusBar
00399 
00400 PURPOSE: 
00401   Registers the StatusBar control class and creates a Statusbar.
00402 
00403 ***********************************************************************/
00404 HWND CreateStatusBar( HWND hwnd, HINSTANCE hInst )
00405 {
00406     DWORD dwStyle;
00407     HWND hwndSB;
00408     RECT rect;
00409 
00410     INITCOMMONCONTROLSEX iccex;
00411     iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
00412     iccex.dwICC = ICC_BAR_CLASSES;
00413 
00414     // Registers Statusbar control classes from the common control dll
00415     InitCommonControlsEx( &iccex );
00416 
00417     // Create the statusbar control
00418     dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | CCS_NOPARENTALIGN;
00419 
00420     hwndSB = CreateWindowEx( 0, STATUSCLASSNAME, NULL,
00421                              WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_BOTTOM |
00422                              TBS_RIGHT  |WS_CLIPSIBLINGS,
00423                              0, 0, CW_USEDEFAULT, 50, hwnd, NULL, hInst, 0 );
00424 
00425     if (!hwndSB ) return NULL;
00426 
00427     // Get the coordinates of the parent window's client area. 
00428     GetClientRect( hwnd, &rect );
00429 
00430     // allocate memory for the panes of status bar
00431     int nopanes = 2;
00432     int *indicators = new int[nopanes];
00433 
00434     // set width for the panes
00435     indicators[0] = 3 * ( rect.right - rect.left ) / 4;
00436     indicators[1] = rect.right - rect.left;
00437 
00438     // call functions to set style
00439     SendMessage( hwndSB, SB_SETPARTS, (WPARAM)nopanes, (LPARAM)indicators );
00440 
00441     return hwndSB;
00442 }
00443 
00444 /***********************************************************************
00445 FUNCTION: 
00446   WndProc
00447 
00448 PURPOSE: 
00449   Processes messages sent to the main window.
00450 ***********************************************************************/
00451 LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
00452 {
00453     switch( msg )
00454     {
00455     case WM_CREATE:
00456         hwndCB = CreateMenuBar( hwnd, hInst );
00457         hwndTB = CreateToolBar( hwnd, hInst );
00458         hwndSlider = CreateSliderBar( hwnd, hInst );
00459         hwndLabel = CreateStaticText( hwnd, hInst );
00460         hwndVol = CreateVolTrackBar( hwnd, hInst );
00461 #ifdef UNDER_CE
00462         hwndSB = CreateStatusBar( hwnd, hInst );
00463 #endif
00464 
00465         /* Video window */
00466         if( config_GetInt( p_intf, "wince-embed" ) )
00467             video = CreateVideoWindow( p_intf, hwnd );
00468 
00469         timer = new Timer( p_intf, hwnd, this );
00470         break;
00471 
00472     case WM_COMMAND:
00473         switch( GET_WM_COMMAND_ID(wp,lp) )
00474         {
00475         case ID_FILE_QUICKOPEN: 
00476         case ID_FILE_OPENFILE: 
00477         case ID_FILE_OPENDIR:
00478         case ID_FILE_OPENNET:
00479         case ID_VIEW_STREAMINFO:
00480         case ID_VIEW_MESSAGES:
00481         case ID_VIEW_PLAYLIST:
00482         case ID_PREFERENCES:
00483             OnShowDialog( GET_WM_COMMAND_ID(wp,lp) );
00484             break;
00485 
00486         case PlayStream_Event: OnPlayStream(); break;
00487         case StopStream_Event: OnStopStream(); break;
00488         case PrevStream_Event: OnPrevStream(); break;
00489         case NextStream_Event: OnNextStream(); break;
00490         case SlowStream_Event: OnSlowStream(); break;
00491         case FastStream_Event: OnFastStream(); break;
00492 
00493         case ID_FILE_ABOUT: 
00494         {
00495             string about = (string)"VLC media player " PACKAGE_VERSION +
00496                 _("\n(WinCE interface)\n\n") +
00497                 _("(c) 1996-2005 - the VideoLAN Team\n\n") +
00498                 _("The VideoLAN team <[email protected]>\n"
00499                   "http://www.videolan.org/\n\n");
00500 
00501             MessageBox( hwnd, _FROMMB(about.c_str()),
00502                         _T("About VLC media player"), MB_OK );
00503             break;
00504         }
00505 
00506         case ID_FILE_EXIT:
00507             SendMessage( hwnd, WM_CLOSE, 0, 0 );
00508             break;
00509 
00510         default:
00511             OnMenuEvent( p_intf, GET_WM_COMMAND_ID(wp,lp) );
00512             // we should test if it is a menu command
00513         }
00514         break;
00515   
00516     case WM_TIMER:
00517         timer->Notify();
00518         break;
00519 
00520     case WM_CTLCOLORSTATIC: 
00521         if( ( (HWND)lp == hwndSlider ) || ( (HWND)lp == hwndVol ) )
00522         { 
00523             return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) ); 
00524         }
00525         if( (HWND)lp == hwndLabel )
00526         {
00527             SetBkColor( (HDC)wp, RGB (192, 192, 192) ); 
00528             return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) ); 
00529         }
00530         break;
00531 
00532     case WM_HSCROLL:
00533         if( (HWND)lp == hwndSlider ) OnSliderUpdate( wp );
00534         break;
00535 
00536     case WM_VSCROLL:
00537         if( (HWND)lp == hwndVol ) OnChange( wp );
00538         break;
00539 
00540     case WM_INITMENUPOPUP:
00541         if( (HMENU)wp == menu_settings )
00542             RefreshSettingsMenu( p_intf, menu_settings );
00543         if( (HMENU)wp == menu_audio )
00544             RefreshAudioMenu( p_intf, menu_audio );
00545         if( (HMENU)wp == menu_video )
00546             RefreshVideoMenu( p_intf, menu_video );
00547         if( (HMENU)wp == menu_navigation )
00548             RefreshNavigMenu( p_intf, menu_navigation );
00549         /* Fall through */
00550 
00551     case WM_KILLFOCUS:
00552         SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
00553     case WM_ENTERMENULOOP:
00554         if( video && video->hWnd )
00555             SendMessage( video->hWnd, WM_KILLFOCUS, 0, 0 );
00556         break;
00557 
00558     case WM_SETFOCUS:
00559         SHSipPreference( hwnd, SIP_DOWN ); 
00560         SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
00561     case WM_EXITMENULOOP:
00562         if( video && video->hWnd )
00563             SendMessage( video->hWnd, WM_SETFOCUS, 0, 0 );
00564         break;
00565 
00566     case WM_LBUTTONDOWN:
00567         {
00568             SHRGINFO shrg;
00569             shrg.cbSize = sizeof( shrg );
00570             shrg.hwndClient = hwnd;
00571             shrg.ptDown.x = LOWORD(lp);
00572             shrg.ptDown.y = HIWORD(lp);
00573             shrg.dwFlags = SHRG_RETURNCMD ;
00574 
00575             if( SHRecognizeGesture( &shrg ) == GN_CONTEXTMENU )
00576                 PopupMenu( p_intf, hwnd, shrg.ptDown );
00577         }
00578         break;
00579 
00580    case WM_RBUTTONUP:
00581         {
00582             POINT point;
00583             point.x = LOWORD(lp);
00584             point.y = HIWORD(lp);
00585             PopupMenu( p_intf, hwnd, point );
00586         }
00587         break;
00588 
00589     case WM_HELP:
00590         MessageBox (hwnd, _T("Help"), _T("Help"), MB_OK);
00591         break;
00592 
00593     case WM_CLOSE:
00594         if( hwndCB ) DestroyWindow( hwndCB );
00595         DestroyWindow( hwnd );
00596         break;
00597 
00598     case WM_DESTROY:
00599         PostQuitMessage( 0 );
00600         break;
00601     }
00602 
00603     return DefWindowProc( hwnd, msg, wp, lp );
00604 }
00605 
00606 void Interface::OnShowDialog( int i_dialog_event )
00607 {
00608     int i_id;
00609 
00610     switch( i_dialog_event )
00611     {
00612     case ID_FILE_QUICKOPEN: i_id = INTF_DIALOG_FILE_SIMPLE; break;
00613     case ID_FILE_OPENFILE: i_id = INTF_DIALOG_FILE; break;
00614     case ID_FILE_OPENDIR: i_id = INTF_DIALOG_DIRECTORY; break;
00615     case ID_FILE_OPENNET: i_id = INTF_DIALOG_NET; break;
00616     case ID_VIEW_PLAYLIST: i_id = INTF_DIALOG_PLAYLIST; break;
00617     case ID_VIEW_MESSAGES: i_id = INTF_DIALOG_MESSAGES; break;
00618     case ID_VIEW_STREAMINFO: i_id = INTF_DIALOG_FILEINFO; break;
00619     case ID_PREFERENCES: i_id = INTF_DIALOG_PREFS; break;
00620     default: i_id = INTF_DIALOG_FILE; break;
00621     }
00622 
00623     if( p_intf->p_sys->pf_show_dialog )
00624         p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
00625 }
00626 
00627 void Interface::OnPlayStream( void )
00628 {
00629     playlist_t *p_playlist = (playlist_t *)
00630         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
00631     if( p_playlist == NULL ) return;
00632 
00633     if( p_playlist->i_size && p_playlist->i_enabled )
00634     {
00635         vlc_value_t state;
00636 
00637         input_thread_t *p_input = (input_thread_t *)
00638             vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
00639 
00640         if( p_input == NULL )
00641         {
00642             /* No stream was playing, start one */
00643             playlist_Play( p_playlist );
00644             TogglePlayButton( PLAYING_S );
00645             vlc_object_release( p_playlist );
00646             return;
00647         }
00648 
00649         var_Get( p_input, "state", &state );
00650 
00651         if( state.i_int != PAUSE_S )
00652         {
00653             /* A stream is being played, pause it */
00654             state.i_int = PAUSE_S;
00655         }
00656         else
00657         {
00658             /* Stream is paused, resume it */
00659             state.i_int = PLAYING_S;
00660         }
00661         var_Set( p_input, "state", state );
00662 
00663         TogglePlayButton( state.i_int );
00664         vlc_object_release( p_input );
00665         vlc_object_release( p_playlist );
00666     }
00667     else
00668     {
00669         /* If the playlist is empty, open a file requester instead */
00670         vlc_object_release( p_playlist );
00671         OnShowDialog( ID_FILE_QUICKOPEN );
00672     }
00673 }
00674 
00675 void Interface::TogglePlayButton( int i_playing_status )
00676 {
00677     TBREPLACEBITMAP tbrb;
00678     tbrb.hInstOld = tbrb.hInstNew = (HINSTANCE) hInst;
00679     tbrb.nButtons = NUMIMAGES;
00680 
00681     if( i_playing_status == i_old_playing_status ) return;
00682 
00683     if( i_playing_status == PLAYING_S )
00684     {
00685         tbrb.nIDOld = IDB_BITMAP2;
00686         tbrb.nIDNew = IDB_BITMAP1;
00687 
00688         SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
00689                      (LPARAM)(LPTBREPLACEBITMAP)&tbrb );
00690     }
00691     else
00692     {
00693         tbrb.nIDOld = IDB_BITMAP1;
00694         tbrb.nIDNew = IDB_BITMAP2;
00695 
00696         SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
00697                      (LPARAM)(LPTBREPLACEBITMAP)&tbrb );
00698     }
00699 
00700     UpdateWindow( hwndTB );
00701 
00702     i_old_playing_status = i_playing_status;
00703 }
00704 
00705 void Interface::OnVideoOnTop( void )
00706 {
00707     vlc_value_t val;
00708 
00709     vout_thread_t *p_vout = (vout_thread_t *)
00710         vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
00711 
00712     if( p_vout == NULL ) return;
00713 
00714     if( var_Get( (vlc_object_t *)p_vout, "video-on-top", &val ) < 0 )
00715         return;
00716 
00717     val.b_bool = !val.b_bool;
00718     var_Set( (vlc_object_t *)p_vout, "video-on-top", val );
00719 
00720     vlc_object_release( (vlc_object_t *)p_vout );
00721 }
00722 
00723 void Interface::OnSliderUpdate( int wp )
00724 {
00725     vlc_mutex_lock( &p_intf->change_lock );
00726     input_thread_t *p_input = p_intf->p_sys->p_input;
00727 
00728     int dwPos = SendMessage( hwndSlider, TBM_GETPOS, 0, 0 ); 
00729 
00730     if( (int)LOWORD(wp) == SB_THUMBPOSITION ||
00731         (int)LOWORD(wp) == SB_ENDSCROLL )
00732     {
00733         if( p_intf->p_sys->i_slider_pos != dwPos && p_input )
00734         {
00735             vlc_value_t pos;
00736             pos.f_float = (float)dwPos / (float)SLIDER_MAX_POS;
00737             var_Set( p_input, "position", pos );
00738         }
00739 
00740         p_intf->p_sys->b_slider_free = VLC_TRUE;
00741     }
00742     else
00743     {
00744         p_intf->p_sys->b_slider_free = VLC_FALSE;
00745 
00746         if( p_input )
00747         {
00748             /* Update stream date */
00749             char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
00750             mtime_t i_seconds;
00751 
00752             i_seconds = var_GetTime( p_input, "length" ) / I64C(1000000 );
00753             secstotimestr( psz_total, i_seconds );
00754 
00755             i_seconds = var_GetTime( p_input, "time" ) / I64C(1000000 );
00756             secstotimestr( psz_time, i_seconds );
00757 
00758             SendMessage( hwndLabel, WM_SETTEXT, (WPARAM)1,
00759                          (LPARAM)_FROMMB(psz_time) );
00760         }
00761     }
00762 
00763     vlc_mutex_unlock( &p_intf->change_lock );
00764 }
00765 
00766 void Interface::OnChange( int wp )
00767 {
00768     DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
00769 
00770     if( LOWORD(wp) == SB_THUMBPOSITION || LOWORD(wp) == SB_ENDSCROLL )
00771     {
00772         VolumeChange( 200 - (int)dwPos );
00773         b_volume_hold = VLC_FALSE;
00774     }
00775     else
00776     {
00777         b_volume_hold = VLC_TRUE;
00778     }
00779 }
00780 
00781 void Interface::VolumeChange( int i_volume )
00782 {
00783     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
00784 }
00785 
00786 void Interface::VolumeUpdate()
00787 {
00788     audio_volume_t i_volume;
00789 
00790     if( b_volume_hold ) return;
00791 
00792     aout_VolumeGet( p_intf, &i_volume );
00793 
00794     int i_volume_ctrl = 200 - i_volume * 200 * 2 / AOUT_VOLUME_MAX;
00795 
00796     DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
00797     if( i_volume_ctrl == (int)dwPos ) return;
00798 
00799     SendMessage( hwndVol, TBM_SETPOS, 1, i_volume_ctrl );
00800 }
00801 
00802 void Interface::OnStopStream( void )
00803 {
00804     playlist_t * p_playlist = (playlist_t *)
00805         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
00806     if( p_playlist == NULL ) return;
00807 
00808     playlist_Stop( p_playlist );
00809     TogglePlayButton( PAUSE_S );
00810     vlc_object_release( p_playlist );
00811 }
00812 
00813 void Interface::OnPrevStream( void )
00814 {
00815     playlist_t * p_playlist = (playlist_t *)
00816         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
00817     if( p_playlist == NULL ) return;
00818 
00819     playlist_Prev( p_playlist );
00820     vlc_object_release( p_playlist );
00821 }
00822 
00823 void Interface::OnNextStream( void )
00824 {
00825     playlist_t * p_playlist = (playlist_t *)
00826         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
00827     if( p_playlist == NULL ) return;
00828 
00829     playlist_Next( p_playlist );
00830     vlc_object_release( p_playlist );
00831 }
00832 
00833 void Interface::OnSlowStream( void )
00834 {
00835     input_thread_t *p_input = (input_thread_t *)
00836         vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
00837 
00838     if( p_input == NULL ) return;
00839 
00840     vlc_value_t val; val.b_bool = VLC_TRUE;
00841     var_Set( p_input, "rate-slower", val );
00842     vlc_object_release( p_input );
00843 }
00844 
00845 void Interface::OnFastStream( void )
00846 {
00847     input_thread_t *p_input = (input_thread_t *)
00848         vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
00849 
00850     if( p_input == NULL ) return;
00851 
00852     vlc_value_t val; val.b_bool = VLC_TRUE;
00853     var_Set( p_input, "rate-faster", val );
00854     vlc_object_release( p_input );
00855 }
00856 
00857 void Interface::Update()
00858 {
00859     /* Misc updates */
00860     VolumeUpdate();
00861 }

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