?? interface.cpp
字號:
/***************************************************************************** * interface.cpp: WinCE gui plugin for VLC ***************************************************************************** * Copyright (C) 2003 VideoLAN * $Id: interface.cpp 10570 2005-04-06 08:27:13Z gbazin $ * * Authors: Marodon Cedric <cedric_marodon@yahoo.fr> * Gildas Bazin <gbazin@videolan.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, * USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <vlc/vlc.h>#include <vlc/aout.h>#include <vlc/vout.h>#include <vlc/intf.h>#include "wince.h"#include <windowsx.h>#include <commctrl.h>#include <commdlg.h>#define NUMIMAGES 9 // Number of buttons in the toolbar #define IMAGEWIDTH 17 // Width of the buttons in the toolbar #define IMAGEHEIGHT 16 // Height of the buttons in the toolbar #define BUTTONWIDTH 0 // Width of the button images in the toolbar#define BUTTONHEIGHT 0 // Height of the button images in the toolbar#define ID_TOOLBAR 2000 // Identifier of the main tool bar// Help strings#define HELP_SIMPLE _T("Quick file open")#define HELP_ADV _T("Advanced open")#define HELP_FILE _T("Open a file")#define HELP_DISC _T("Open Disc Media")#define HELP_NET _T("Open a network stream")#define HELP_SAT _T("Open a satellite stream")#define HELP_EJECT _T("Eject the DVD/CD")#define HELP_EXIT _T("Exit this program")#define HELP_OTHER _T("Open other types of inputs")#define HELP_PLAYLIST _T("Open the playlist")#define HELP_LOGS _T("Show the program logs")#define HELP_FILEINFO _T("Show information about the file being played")#define HELP_PREFS _T("Go to the preferences menu")#define HELP_ABOUT _T("About this program")#define HELP_STOP _T("Stop")#define HELP_PLAY _T("Play")#define HELP_PAUSE _T("Pause")#define HELP_PLO _T("Playlist")#define HELP_PLP _T("Previous playlist item")#define HELP_PLN _T("Next playlist item")#define HELP_SLOW _T("Play slower")#define HELP_FAST _T("Play faster")// The TBBUTTON structure contains information the toolbar buttons.static TBBUTTON tbButton[] = { {0, ID_FILE_QUICKOPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {1, ID_FILE_OPENNET, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP}, {2, StopStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {3, PlayStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP}, {4, ID_VIEW_PLAYLIST, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP}, {5, PrevStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {6, NextStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP}, {7, SlowStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {8, FastStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},};// Toolbar ToolTipsTCHAR * szToolTips[] = { HELP_SIMPLE, HELP_NET, HELP_STOP, HELP_PLAY, HELP_PLO, HELP_PLP, HELP_PLN, HELP_SLOW, HELP_FAST};/***************************************************************************** * Constructor. *****************************************************************************/Interface::Interface( intf_thread_t *p_intf, CBaseWindow *p_parent, HINSTANCE h_inst ) : CBaseWindow( p_intf, p_parent, h_inst ), hwndMain(0), hwndCB(0), hwndTB(0), hwndSlider(0), hwndLabel(0), hwndVol(0), hwndSB(0), timer(0), video(0), b_volume_hold(0){}Interface::~Interface(){ if( timer ) delete timer; if( video ) delete video;}BOOL Interface::InitInstance(){ /* Initializations */ i_old_playing_status = PAUSE_S; int i_style = WS_VISIBLE;#ifndef UNDER_CE i_style |= WS_OVERLAPPEDWINDOW | WS_SIZEBOX;#endif // Create main window hwndMain = CreateWindow( _T("VLC WinCE"), _T("VLC media player"), i_style, 0, MENU_HEIGHT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetInstance(), (void *)this ); if( !hwndMain ) return FALSE; ShowWindow( hwndMain, TRUE ); UpdateWindow( hwndMain ); return TRUE;}/***********************************************************************FUNCTION: CreateMenuBarPURPOSE: Creates a menu bar.***********************************************************************/HWND Interface::CreateMenuBar( HWND hwnd, HINSTANCE hInst ){ HMENU menu_file, menu_view;#ifdef UNDER_CE SHMENUBARINFO mbi; memset( &mbi, 0, sizeof(SHMENUBARINFO) ); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hwnd; mbi.hInstRes = hInst; mbi.nToolBarId = IDR_MENUBAR; if( !SHCreateMenuBar( &mbi ) ) { MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK); return 0; } TBBUTTONINFO tbbi; tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_LPARAM; SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_FILE, (LPARAM)&tbbi ); menu_file = (HMENU)tbbi.lParam; RemoveMenu( menu_file, 0, MF_BYPOSITION ); SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIEW, (LPARAM)&tbbi ); menu_view = (HMENU)tbbi.lParam; RemoveMenu( menu_view, 0, MF_BYPOSITION ); SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_SETTINGS, (LPARAM)&tbbi ); menu_settings = (HMENU)tbbi.lParam; SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIDEO, (LPARAM)&tbbi ); menu_video = (HMENU)tbbi.lParam; SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_AUDIO, (LPARAM)&tbbi ); menu_audio = (HMENU)tbbi.lParam; SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_NAVIGATION, (LPARAM)&tbbi ); menu_navigation = (HMENU)tbbi.lParam;#else menu_file = CreatePopupMenu(); menu_view = CreatePopupMenu(); menu_settings = CreatePopupMenu(); menu_audio = CreatePopupMenu(); menu_video = CreatePopupMenu(); menu_navigation = CreatePopupMenu();#endif AppendMenu( menu_file, MF_STRING, ID_FILE_QUICKOPEN, _T("Quick &Open File...") ); AppendMenu( menu_file, MF_SEPARATOR, 0, 0 ); AppendMenu( menu_file, MF_STRING, ID_FILE_OPENFILE, _T("Open &File...") ); AppendMenu( menu_file, MF_STRING, ID_FILE_OPENDIR, _T("Open &Directory...") ); AppendMenu( menu_file, MF_STRING, ID_FILE_OPENNET, _T("Open &Network Stream...") ); AppendMenu( menu_file, MF_SEPARATOR, 0, 0 ); AppendMenu( menu_file, MF_STRING, ID_FILE_ABOUT, _T("About VLC") ); AppendMenu( menu_file, MF_STRING, ID_FILE_EXIT, _T("E&xit") ); AppendMenu( menu_view, MF_STRING, ID_VIEW_PLAYLIST, _T("&Playlist...") ); AppendMenu( menu_view, MF_STRING, ID_VIEW_MESSAGES, _T("&Messages...") ); AppendMenu( menu_view, MF_STRING, ID_VIEW_STREAMINFO, _T("Stream and Media &info...") ); AppendMenu( menu_settings, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );#ifdef UNDER_CE return mbi.hwndMB;#else HMENU hmenu = CreateMenu(); AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_file, _T("File") ); AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_view, _T("View") ); AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_settings, _T("Settings") ); AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_audio, _T("Audio") ); AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_video, _T("Video") ); AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_navigation, _T("Nav") ); SetMenu( hwnd, hmenu ); return 0;#endif}/***********************************************************************FUNCTION: CreateToolBarPURPOSE: Registers the TOOLBAR control class and creates a toolbar.***********************************************************************/HWND CreateToolBar( HWND hwnd, HINSTANCE hInst ){ DWORD dwStyle; HWND hwndTB; RECT rect, rectTB; INITCOMMONCONTROLSEX iccex; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); iccex.dwICC = ICC_BAR_CLASSES; // Registers TOOLBAR control classes from the common control dll InitCommonControlsEx (&iccex); // Create the toolbar control dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | WS_EX_OVERLAPPEDWINDOW | CCS_NOPARENTALIGN; hwndTB = CreateToolbarEx( hwnd, dwStyle, 0, NUMIMAGES, hInst, IDB_BITMAP1, tbButton, sizeof(tbButton) / sizeof(TBBUTTON), BUTTONWIDTH, BUTTONHEIGHT, IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON) ); if( !hwndTB ) return NULL; // Add ToolTips to the toolbar. SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM)NUMIMAGES, (LPARAM)szToolTips ); // Reposition the toolbar. GetClientRect( hwnd, &rect ); GetWindowRect( hwndTB, &rectTB ); MoveWindow( hwndTB, rect.left, rect.bottom - rect.top - 2*MENU_HEIGHT, rect.right - rect.left, MENU_HEIGHT, TRUE ); return hwndTB;}/***********************************************************************FUNCTION: CreateSliderBarPURPOSE: Registers the TRACKBAR_CLASS control class and creates a trackbar.***********************************************************************/HWND CreateSliderBar( HWND hwnd, HINSTANCE hInst ){ HWND hwndSlider; RECT rect; INITCOMMONCONTROLSEX iccex; iccex.dwSize = sizeof( INITCOMMONCONTROLSEX ); iccex.dwICC = ICC_BAR_CLASSES; // Registers TRACKBAR_CLASS control classes from the common control dll InitCommonControlsEx( &iccex ); hwndSlider = CreateWindowEx( 0, TRACKBAR_CLASS, NULL, WS_CHILD | WS_VISIBLE | TBS_HORZ | WS_EX_OVERLAPPEDWINDOW | TBS_BOTTOM, //|WS_CLIPSIBLINGS, 0, 0, 0, 0, hwnd, NULL, hInst, NULL ); if( !hwndSlider ) return NULL; SendMessage( hwndSlider, TBM_SETRANGEMIN, 1, 0 ); SendMessage( hwndSlider, TBM_SETRANGEMAX, 1, SLIDER_MAX_POS ); SendMessage( hwndSlider, TBM_SETPOS, 1, 0 ); // Reposition the trackbar GetClientRect( hwnd, &rect ); MoveWindow( hwndSlider, rect.left, rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT, rect.right - rect.left - 40, 30, TRUE ); ShowWindow( hwndSlider, SW_HIDE ); return hwndSlider;}HWND CreateStaticText( HWND hwnd, HINSTANCE hInst ){ HWND hwndLabel; RECT rect; hwndLabel = CreateWindowEx( 0, _T("STATIC"), _T("label"), WS_CHILD | WS_VISIBLE | SS_CENTER , 0, 0, 0, 0, hwnd, (HMENU)1980, hInst, NULL ); // Reposition the trackbar GetClientRect( hwnd, &rect ); MoveWindow( hwndLabel, rect.left, rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT +30, rect.right - rect.left - 40, SLIDER_HEIGHT - 30, TRUE ); ShowWindow( hwndLabel, SW_HIDE ); return hwndLabel;}/***********************************************************************FUNCTION: CreateVolTrackBarPURPOSE: Registers the TRACKBAR_CLASS control class and creates a trackbar.***********************************************************************/HWND CreateVolTrackBar( HWND hwnd, HINSTANCE hInst ){ HWND hwndVol; RECT rect; INITCOMMONCONTROLSEX iccex; iccex.dwSize = sizeof( INITCOMMONCONTROLSEX ); iccex.dwICC = ICC_BAR_CLASSES; // Registers TRACKBAR_CLASS control classes from the common control dll InitCommonControlsEx( &iccex ); hwndVol = CreateWindowEx( 0, TRACKBAR_CLASS, NULL, WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_RIGHT | TBS_AUTOTICKS | WS_EX_OVERLAPPEDWINDOW, //|WS_CLIPSIBLINGS, 0, 0, 0, 0, hwnd, NULL, hInst, NULL ); if( !hwndVol ) return NULL; SendMessage( hwndVol, TBM_SETRANGEMIN, 1, 0 ); SendMessage( hwndVol, TBM_SETRANGEMAX, 1, 200 ); SendMessage( hwndVol, TBM_SETPOS, 1, 100 ); SendMessage( hwndVol, TBM_SETTICFREQ, 50, 0 ); // Reposition the trackbar GetClientRect( hwnd, &rect ); MoveWindow( hwndVol, rect.right - rect.left - 40, rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT, 40, SLIDER_HEIGHT, TRUE ); ShowWindow( hwndVol, SW_HIDE ); return hwndVol;}/***********************************************************************FUNCTION: CreateStatusBarPURPOSE: Registers the StatusBar control class and creates a Statusbar.***********************************************************************/HWND CreateStatusBar( HWND hwnd, HINSTANCE hInst ){ DWORD dwStyle; HWND hwndSB; RECT rect; INITCOMMONCONTROLSEX iccex; iccex.dwSize = sizeof (INITCOMMONCONTROLSEX); iccex.dwICC = ICC_BAR_CLASSES; // Registers Statusbar control classes from the common control dll InitCommonControlsEx( &iccex ); // Create the statusbar control dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | CCS_NOPARENTALIGN; hwndSB = CreateWindowEx( 0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_BOTTOM | TBS_RIGHT |WS_CLIPSIBLINGS, 0, 0, CW_USEDEFAULT, 50, hwnd, NULL, hInst, 0 ); if (!hwndSB ) return NULL; // Get the coordinates of the parent window's client area. GetClientRect( hwnd, &rect ); // allocate memory for the panes of status bar int nopanes = 2;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -