Commit ba2736f4 authored by Pierre Ynard's avatar Pierre Ynard

Remove the WinCE GUI

It is unmaintained, broken, and hasn't even been building for the
last 6 months.
parent 85686977
......@@ -4390,26 +4390,6 @@ AS_IF([test "${enable_qt4}" != "no"], [
])
AM_CONDITIONAL(ENABLE_QT4, [test "x$enable_qt4" != "xno"])
dnl
dnl WinCE GUI module
dnl
AC_ARG_ENABLE(wince,
[ --enable-wince Windows CE interface (default enabled with MinGW)])
if test "${enable_wince}" != "no"; then
if test "${SYS}" = "mingwce"; then
VLC_ADD_PLUGIN([wince])
VLC_ADD_CXXFLAGS([wince],[])
VLC_ADD_LIBS([wince],[-lcommctrl -lcommdlg -laygshell])
dnl Gross hack
VLC_ADD_LIBS([wince],[\\\${top_builddir}modules/gui/wince/wince_rc.o])
elif test "${SYS}" = "mingw32"; then
VLC_ADD_CXXFLAGS([wince],[])
VLC_ADD_LIBS([wince],[-lcomctl32 -lcomdlg32 -lgdi32 -lole32])
dnl Gross hack
VLC_ADD_LIBS([wince],[\\\${top_builddir}modules/gui/wince/wince_rc.o])
fi
fi
dnl
dnl Simple test for skins2 dependency
dnl
......@@ -5287,7 +5267,6 @@ AC_CONFIG_FILES([
modules/gui/qnx/Makefile
modules/gui/qt4/Makefile
modules/gui/skins2/Makefile
modules/gui/wince/Makefile
modules/meta_engine/Makefile
modules/misc/Makefile
modules/misc/dummy/Makefile
......
DIST_SUBDIRS = beos macosx hildon minimal_macosx qnx qt4 skins2 wince
DIST_SUBDIRS = beos macosx hildon minimal_macosx qnx qt4 skins2
SUBDIRS =
if HAVE_BEOS
......@@ -17,9 +17,6 @@ endif
if BUILD_SKINS
SUBDIRS += skins2
endif
if HAVE_WINCE
SUBDIRS += wince
endif
SOURCES_ncurses = ncurses.c
SOURCES_fbosd = fbosd.c
SUFFIXES += .rc
wince_rc.o: $(top_srcdir)/modules/gui/wince/wince_rc.rc
$(WINDRES) --include-dir $(top_srcdir)/modules/gui/wince/ -i $< -o $@
SOURCES_wince = \
wince.cpp \
wince.h \
interface.cpp \
dialogs.cpp \
menus.cpp \
open.cpp \
playlist.cpp \
fileinfo.cpp \
iteminfo.cpp \
messages.cpp \
preferences.cpp \
preferences_widgets.cpp \
preferences_widgets.h \
subtitles.cpp \
timer.cpp \
video.cpp \
$(NULL)
EXTRA_DIST += \
wince_rc.rc \
bitmaps/vlc16x16.ico \
bitmaps/toolbar1.bmp \
bitmaps/toolbar2.bmp \
bitmaps/toolbar3.bmp
BUILT_SOURCES += wince_rc.o
/*****************************************************************************
* dialogs.cpp : WinCE plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id$
*
* Authors: 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include "wince.h"
#include <commctrl.h>
#include <commdlg.h>
#include <shlobj.h>
/* Dialogs Provider */
class DialogsProvider: public CBaseWindow
{
public:
/* Constructor */
DialogsProvider( intf_thread_t *, CBaseWindow *, HINSTANCE = 0 );
virtual ~DialogsProvider();
protected:
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
private:
void OnExit( void );
void OnIdle( void );
void OnPlaylist( void );
void OnMessages( void );
void OnFileInfo( void );
void OnPreferences( void );
void OnPopupMenu( void );
void OnOpen( int, int );
void OnOpenFileSimple( int );
void OnOpenDirectory( int );
void OnOpenFileGeneric( intf_dialog_args_t * );
/* GetOpenFileName replacement */
BOOL (WINAPI *GetOpenFile)(void *);
HMODULE h_gsgetfile_dll;
public:
/* Secondary windows */
OpenDialog *p_open_dialog;
Playlist *p_playlist_dialog;
Messages *p_messages_dialog;
PrefsDialog *p_prefs_dialog;
FileInfo *p_fileinfo_dialog;
};
CBaseWindow *CreateDialogsProvider( intf_thread_t *p_intf,
CBaseWindow *p_parent, HINSTANCE h_inst )
{
return new DialogsProvider( p_intf, p_parent, h_inst );
}
/*****************************************************************************
* Constructor.
*****************************************************************************/
DialogsProvider::DialogsProvider( intf_thread_t *p_intf,
CBaseWindow *p_parent, HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
p_open_dialog = NULL;
p_playlist_dialog = NULL;
p_messages_dialog = NULL;
p_fileinfo_dialog = NULL;
p_prefs_dialog = NULL;
/* Create dummy window */
hWnd = CreateWindow( _T("VLC WinCE"), _T("DialogsProvider"), 0,
0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
p_parent->GetHandle(), NULL, h_inst, (void *)this );
GetOpenFile = 0;
h_gsgetfile_dll = LoadLibrary( _T("gsgetfile") );
if( h_gsgetfile_dll )
{
GetOpenFile = (BOOL (WINAPI *)(void *))
GetProcAddress( h_gsgetfile_dll, _T("gsGetOpenFileName") );
}
if( !GetOpenFile )
GetOpenFile = (BOOL (WINAPI *)(void *))::GetOpenFileName;
}
DialogsProvider::~DialogsProvider()
{
/* Clean up */
delete p_open_dialog;
delete p_playlist_dialog;
delete p_messages_dialog;
delete p_fileinfo_dialog;
delete p_prefs_dialog;
if( h_gsgetfile_dll ) FreeLibrary( h_gsgetfile_dll );
}
LRESULT DialogsProvider::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
switch( msg )
{
case WM_APP + INTF_DIALOG_FILE: OnOpen( FILE_ACCESS, wp ); return TRUE;
case WM_APP + INTF_DIALOG_NET: OnOpen( NET_ACCESS, wp ); return TRUE;
case WM_APP + INTF_DIALOG_FILE_SIMPLE: OnOpenFileSimple( wp ); return TRUE;
case WM_APP + INTF_DIALOG_DIRECTORY: OnOpenDirectory( wp ); return TRUE;
case WM_APP + INTF_DIALOG_FILE_GENERIC:
OnOpenFileGeneric( (intf_dialog_args_t*)lp ); return TRUE;
case WM_APP + INTF_DIALOG_PLAYLIST: OnPlaylist(); return TRUE;
case WM_APP + INTF_DIALOG_MESSAGES: OnMessages(); return TRUE;
case WM_APP + INTF_DIALOG_FILEINFO: OnFileInfo(); return TRUE;
case WM_APP + INTF_DIALOG_PREFS: OnPreferences(); return TRUE;
case WM_APP + INTF_DIALOG_POPUPMENU: OnPopupMenu(); return TRUE;
}
return DefWindowProc( hwnd, msg, wp, lp );
}
void DialogsProvider::OnIdle( void )
{
/* Update the playlist */
if( p_playlist_dialog ) p_playlist_dialog->UpdatePlaylist();
/* Update the fileinfo windows */
if( p_fileinfo_dialog ) p_fileinfo_dialog->UpdateFileInfo();
}
void DialogsProvider::OnPopupMenu( void )
{
POINT point = {0};
PopupMenu( p_intf, hWnd, point );
}
void DialogsProvider::OnPlaylist( void )
{
#if 1
Playlist *playlist = new Playlist( p_intf, this, hInst );
CreateDialogBox( hWnd, playlist );
delete playlist;
#else
/* Show/hide the playlist window */
if( !p_playlist_dialog )
p_playlist_dialog = new Playlist( p_intf, this, hInst );
if( p_playlist_dialog )
{
p_playlist_dialog->ShowPlaylist( !p_playlist_dialog->IsShown() );
}
#endif
}
void DialogsProvider::OnMessages( void )
{
/* Show/hide the log window */
if( !p_messages_dialog )
p_messages_dialog = new Messages( p_intf, this, hInst );
if( p_messages_dialog )
{
p_messages_dialog->Show( !p_messages_dialog->IsShown() );
}
}
void DialogsProvider::OnFileInfo( void )
{
#if 1
FileInfo *fileinfo = new FileInfo( p_intf, this, hInst );
CreateDialogBox( hWnd, fileinfo );
delete fileinfo;
#else
/* Show/hide the file info window */
if( !p_fileinfo_dialog )
p_fileinfo_dialog = new FileInfo( p_intf, this, hInst );
if( p_fileinfo_dialog )
{
p_fileinfo_dialog->Show( !p_fileinfo_dialog->IsShown() );
}
#endif
}
void DialogsProvider::OnPreferences( void )
{
#if 1
PrefsDialog *preferences = new PrefsDialog( p_intf, this, hInst );
CreateDialogBox( hWnd, preferences );
delete preferences;
#else
/* Show/hide the open dialog */
if( !p_prefs_dialog )
p_prefs_dialog = new PrefsDialog( p_intf, this, hInst );
if( p_prefs_dialog )
{
p_prefs_dialog->Show( !p_prefs_dialog->IsShown() );
}
#endif
}
void DialogsProvider::OnOpen( int i_access, int i_arg )
{
/* Show/hide the open dialog */
if( !p_open_dialog )
p_open_dialog = new OpenDialog( p_intf, this, hInst, i_access, i_arg );
if( p_open_dialog )
{
p_open_dialog->Show( !p_open_dialog->IsShown() );
}
}
void DialogsProvider::OnOpenFileGeneric( intf_dialog_args_t *p_arg )
{
if( p_arg == NULL )
{
msg_Dbg( p_intf, "OnOpenFileGeneric() called with NULL arg" );
return;
}
/* Convert the filter string */
TCHAR *psz_filters = (TCHAR *)
malloc( (strlen(p_arg->psz_extensions) + 2) * sizeof(TCHAR) );
_tcscpy( psz_filters, _FROMMB(p_arg->psz_extensions) );
int i;
for( i = 0; psz_filters[i]; i++ )
{
if( psz_filters[i] == '|' ) psz_filters[i] = 0;
}
psz_filters[++i] = 0;
OPENFILENAME ofn;
TCHAR szFile[MAX_PATH] = _T("\0");
memset( &ofn, 0, sizeof(OPENFILENAME) );
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = hInst;
ofn.lpstrFilter = psz_filters;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = (LPTSTR)szFile;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 40;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = _FROMMB(p_arg->psz_title);
ofn.Flags = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0L;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
if( p_arg->b_save && GetSaveFileName( &ofn ) )
{
p_arg->i_results = 1;
p_arg->psz_results = (char **)malloc( p_arg->i_results *
sizeof(char *) );
p_arg->psz_results[0] = strdup( _TOMB(ofn.lpstrFile) );
}
if( !p_arg->b_save && GetOpenFile( &ofn ) )
{
p_arg->i_results = 1;
p_arg->psz_results = (char **)malloc( p_arg->i_results *
sizeof(char *) );
p_arg->psz_results[0] = strdup( _TOMB(ofn.lpstrFile) );
}
/* Callback */
if( p_arg->pf_callback )
{
p_arg->pf_callback( p_arg );
}
if( p_arg->psz_results )
{
for( int i = 0; i < p_arg->i_results; i++ )
{
free( p_arg->psz_results[i] );
}
free( p_arg->psz_results );
}
free( p_arg->psz_title );
free( p_arg->psz_extensions );
free( p_arg );
}
void DialogsProvider::OnOpenFileSimple( int i_arg )
{
OPENFILENAME ofn;
TCHAR szFile[MAX_PATH] = _T("\0");
static TCHAR szFilter[] = _T("wav (*.wav)\0*.wav\0mp3 (*.mp3 *.mpga)\0*.mp3;*.mpga\0All (*.*)\0*.*\0");
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
memset( &ofn, 0, sizeof(OPENFILENAME) );
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = hInst;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = (LPTSTR)szFile;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 40;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = _T("Quick Open File");
ofn.Flags = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0L;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
if( GetOpenFile( &ofn ) )
{
char *psz_filename = _TOMB(ofn.lpstrFile);
playlist_Add( p_playlist, psz_filename, psz_filename,
PLAYLIST_APPEND | (i_arg?PLAYLIST_GO:0), PLAYLIST_END,
TRUE, FALSE );
}
pl_Release( p_intf );
}
void DialogsProvider::OnOpenDirectory( int i_arg )
{
TCHAR psz_result[MAX_PATH];
LPMALLOC p_malloc = 0;
LPITEMIDLIST pidl;
BROWSEINFO bi;
playlist_t *p_playlist = 0;
#ifdef UNDER_CE
# define SHGetMalloc MySHGetMalloc
# define SHBrowseForFolder MySHBrowseForFolder
# define SHGetPathFromIDList MySHGetPathFromIDList
HMODULE ceshell_dll = LoadLibrary( _T("ceshell") );
if( !ceshell_dll ) return;
HRESULT (WINAPI *SHGetMalloc)(LPMALLOC *) =
(HRESULT (WINAPI *)(LPMALLOC *))
GetProcAddress( ceshell_dll, _T("SHGetMalloc") );
LPITEMIDLIST (WINAPI *SHBrowseForFolder)(LPBROWSEINFO) =
(LPITEMIDLIST (WINAPI *)(LPBROWSEINFO))
GetProcAddress( ceshell_dll, _T("SHBrowseForFolder") );
BOOL (WINAPI *SHGetPathFromIDList)(LPCITEMIDLIST, LPTSTR) =
(BOOL (WINAPI *)(LPCITEMIDLIST, LPTSTR))
GetProcAddress( ceshell_dll, _T("SHGetPathFromIDList") );
if( !SHGetMalloc || !SHBrowseForFolder || !SHGetPathFromIDList )
{
msg_Err( p_intf, "couldn't load SHBrowseForFolder API" );
FreeLibrary( ceshell_dll );
return;
}
#endif
if( !SUCCEEDED( SHGetMalloc(&p_malloc) ) ) goto error;
p_playlist = pl_Hold( p_intf );
if( !p_playlist ) goto error;
memset( &bi, 0, sizeof(BROWSEINFO) );
bi.hwndOwner = hWnd;
bi.pszDisplayName = psz_result;
bi.ulFlags = BIF_EDITBOX;
#ifndef UNDER_CE
bi.ulFlags |= BIF_USENEWUI;
#endif
if( (pidl = SHBrowseForFolder( &bi ) ) )
{
if( SHGetPathFromIDList( pidl, psz_result ) )
{
char *psz_filename = _TOMB(psz_result);
playlist_Add( p_playlist, psz_filename, psz_filename,
PLAYLIST_APPEND | (i_arg ? PLAYLIST_GO : 0),
PLAYLIST_END, TRUE, FALSE );
}
p_malloc->Free( pidl );
}
error:
if( p_malloc) p_malloc->Release();
if( p_playlist ) pl_Release( p_intf );
#ifdef UNDER_CE
FreeLibrary( ceshell_dll );
#endif
}
/*****************************************************************************
* fileinfo.cpp : WinCE gui plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_input.h>
#include "wince.h"
#include <winuser.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
/*****************************************************************************
* Constructor.
*****************************************************************************/
FileInfo::FileInfo( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
hwnd_fileinfo = hwndTV = NULL;
}
/***********************************************************************
FUNCTION:
CreateTreeView
PURPOSE:
Registers the TreeView control class and creates a TreeView.
***********************************************************************/
BOOL FileInfo::CreateTreeView(HWND hwnd)
{
DWORD dwStyle;
RECT rect;
INITCOMMONCONTROLSEX iccex;
iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
iccex.dwICC = ICC_TREEVIEW_CLASSES;
// Registers Statusbar control classes from the common control dll
InitCommonControlsEx( &iccex );
// Get the coordinates of the parent window's client area
GetClientRect( hwnd, &rect );
// Assign the window styles for the tree view.
dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT |
TVS_HASBUTTONS;
// Create the tree-view control.
hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
rect.right-rect.left,
rect.bottom-rect.top-MENU_HEIGHT,
hwnd, NULL, hInst, NULL );
// Be sure that the tree view actually was created.
if( !hwndTV ) return FALSE;
UpdateFileInfo();
return TRUE;
}
/***********************************************************************
FUNCTION:
UpdateFileInfo
PURPOSE:
Update the TreeView with file information.
***********************************************************************/
void FileInfo::UpdateFileInfo()
{
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};
HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
HTREEITEM hPrevRootItem = NULL;
HTREEITEM hPrevLev2Item = NULL;
p_intf->p_sys->p_input = (input_thread_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
input_thread_t *p_input = p_intf->p_sys->p_input;
if( !p_input ) return;
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
input_item_t * inp_item = input_GetItem(p_input);
tvi.pszText = _FROMMB( input_item_GetName( inp_item ) );
tvi.cchTextMax = _tcslen( tvi.pszText );
// Save the heading level in the item's application-defined data area
tvi.lParam = (LPARAM)1;
tvins.item = tvi;
//tvins.hInsertAfter = TVI_LAST;
tvins.hInsertAfter = hPrev;
tvins.hParent = TVI_ROOT;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
hPrevRootItem = hPrev;
vlc_mutex_lock( &inp_item->lock );
for( int i = 0; i < inp_item->i_categories; i++ )
{
info_category_t *p_cat = inp_item->pp_categories[i];
// Set the text of the item.
tvi.pszText = _FROMMB( inp_item->psz_name );
tvi.cchTextMax = _tcslen( tvi.pszText );
// Save the heading level in the item's application-defined data area
tvi.lParam = (LPARAM)2; // level 2
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
tvins.hParent = hPrevRootItem;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
hPrevLev2Item = hPrev;
for( int j = 0; j < p_cat->i_infos; j++ )
{
info_t *p_info = p_cat->pp_infos[j];
// Set the text of the item.
string szAnsi = (string)p_info->psz_name;
szAnsi += ": ";
szAnsi += p_info->psz_value;
tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
tvi.cchTextMax = _tcslen( tvi.pszText );
tvi.lParam = (LPARAM)3; // level 3
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
tvins.hParent = hPrevLev2Item;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
}
TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND );
}
vlc_mutex_unlock( &inp_item->lock );
TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND );
return;
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
switch( msg )
{
case WM_INITDIALOG:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
CreateTreeView( hwnd );
UpdateWindow( hwnd );
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
break;
case WM_CLOSE:
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_COMMAND:
if ( LOWORD(wp) == IDOK )
{
EndDialog( hwnd, LOWORD( wp ) );
}
break;
default:
break;
}
return FALSE;
}
/*****************************************************************************
* interface.cpp: WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2003 the VideoLAN team
* $Id$
*
* 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
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#define __STDC_CONSTANT_MACROS 1
#include <inttypes.h>
#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_vout.h>
#include <vlc_interface.h>
#include <vlc_input.h>
#include <vlc_playlist.h>
#include "wince.h"
#define INT64_C(val) val##LL
#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 ToolTips
TCHAR * 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()
{
delete timer;
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:
CreateMenuBar
PURPOSE:
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:
CreateToolBar
PURPOSE:
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:
CreateSliderBar
PURPOSE:
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:
CreateVolTrackBar
PURPOSE:
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:
CreateStatusBar
PURPOSE:
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;
int *indicators = new int[nopanes];
// set width for the panes
indicators[0] = 3 * ( rect.right - rect.left ) / 4;
indicators[1] = rect.right - rect.left;
// call functions to set style
SendMessage( hwndSB, SB_SETPARTS, (WPARAM)nopanes, (LPARAM)indicators );
return hwndSB;
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
switch( msg )
{
case WM_CREATE:
hwndCB = CreateMenuBar( hwnd, hInst );
hwndTB = CreateToolBar( hwnd, hInst );
hwndSlider = CreateSliderBar( hwnd, hInst );
hwndLabel = CreateStaticText( hwnd, hInst );
hwndVol = CreateVolTrackBar( hwnd, hInst );
#ifdef UNDER_CE
hwndSB = CreateStatusBar( hwnd, hInst );
#endif
/* Video window */
if( config_GetInt( p_intf, "wince-embed" ) )
video = CreateVideoWindow( p_intf, hwnd );
timer = new Timer( p_intf, hwnd, this );
break;
case WM_COMMAND:
switch( GET_WM_COMMAND_ID(wp,lp) )
{
case ID_FILE_QUICKOPEN:
case ID_FILE_OPENFILE:
case ID_FILE_OPENDIR:
case ID_FILE_OPENNET:
case ID_VIEW_STREAMINFO:
case ID_VIEW_MESSAGES:
case ID_VIEW_PLAYLIST:
case ID_PREFERENCES:
OnShowDialog( GET_WM_COMMAND_ID(wp,lp) );
break;
case PlayStream_Event: OnPlayStream(); break;
case StopStream_Event: OnStopStream(); break;
case PrevStream_Event: OnPrevStream(); break;
case NextStream_Event: OnNextStream(); break;
case SlowStream_Event: OnSlowStream(); break;
case FastStream_Event: OnFastStream(); break;
case ID_FILE_ABOUT:
{
string about = (string)"VLC media player " PACKAGE_VERSION +
_("\n(WinCE interface)\n\n") +
_("(c) 1996-2008 - the VideoLAN Team\n\n") +
_("Compiled by ") + VLC_CompileBy() + "@" +
VLC_CompileHost() + "." + VLC_CompileDomain() + ".\n" +
_("Compiler: ") + VLC_Compiler() + ".\n\n" +
_("The VideoLAN team <videolan@videolan.org>\n"
"http://www.videolan.org/");
MessageBox( hwnd, _FROMMB(about.c_str()),
_T("About VLC media player"), MB_OK );
break;
}
case ID_FILE_EXIT:
SendMessage( hwnd, WM_CLOSE, 0, 0 );
break;
default:
OnMenuEvent( p_intf, GET_WM_COMMAND_ID(wp,lp) );
// we should test if it is a menu command
}
break;
case WM_TIMER:
timer->Notify();
break;
case WM_CTLCOLORSTATIC:
if( ( (HWND)lp == hwndSlider ) || ( (HWND)lp == hwndVol ) )
{
return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
}
if( (HWND)lp == hwndLabel )
{
SetBkColor( (HDC)wp, RGB (192, 192, 192) );
return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
}
break;
case WM_HSCROLL:
if( (HWND)lp == hwndSlider ) OnSliderUpdate( wp );
break;
case WM_VSCROLL:
if( (HWND)lp == hwndVol ) OnChange( wp );
break;
case WM_INITMENUPOPUP:
if( (HMENU)wp == menu_settings )
RefreshSettingsMenu( p_intf, menu_settings );
if( (HMENU)wp == menu_audio )
RefreshAudioMenu( p_intf, menu_audio );
if( (HMENU)wp == menu_video )
RefreshVideoMenu( p_intf, menu_video );
if( (HMENU)wp == menu_navigation )
RefreshNavigMenu( p_intf, menu_navigation );
/* Fall through */
case WM_KILLFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
case WM_ENTERMENULOOP:
if( video && video->hWnd )
SendMessage( video->hWnd, WM_KILLFOCUS, 0, 0 );
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
case WM_EXITMENULOOP:
if( video && video->hWnd )
SendMessage( video->hWnd, WM_SETFOCUS, 0, 0 );
break;
case WM_LBUTTONDOWN:
{
SHRGINFO shrg;
shrg.cbSize = sizeof( shrg );
shrg.hwndClient = hwnd;
shrg.ptDown.x = LOWORD(lp);
shrg.ptDown.y = HIWORD(lp);
shrg.dwFlags = SHRG_RETURNCMD ;
if( SHRecognizeGesture( &shrg ) == GN_CONTEXTMENU )
PopupMenu( p_intf, hwnd, shrg.ptDown );
}
break;
case WM_RBUTTONUP:
{
POINT point;
point.x = LOWORD(lp);
point.y = HIWORD(lp);
PopupMenu( p_intf, hwnd, point );
}
break;
case WM_HELP:
MessageBox (hwnd, _T("Help"), _T("Help"), MB_OK);
break;
case WM_CLOSE:
if( hwndCB ) DestroyWindow( hwndCB );
DestroyWindow( hwnd );
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
}
return DefWindowProc( hwnd, msg, wp, lp );
}
void Interface::OnShowDialog( int i_dialog_event )
{
int i_id;
switch( i_dialog_event )
{
case ID_FILE_QUICKOPEN: i_id = INTF_DIALOG_FILE_SIMPLE; break;
case ID_FILE_OPENFILE: i_id = INTF_DIALOG_FILE; break;
case ID_FILE_OPENDIR: i_id = INTF_DIALOG_DIRECTORY; break;
case ID_FILE_OPENNET: i_id = INTF_DIALOG_NET; break;
case ID_VIEW_PLAYLIST: i_id = INTF_DIALOG_PLAYLIST; break;
case ID_VIEW_MESSAGES: i_id = INTF_DIALOG_MESSAGES; break;
case ID_VIEW_STREAMINFO: i_id = INTF_DIALOG_FILEINFO; break;
case ID_PREFERENCES: i_id = INTF_DIALOG_PREFS; break;
default: i_id = INTF_DIALOG_FILE; break;
}
if( p_intf->p_sys->pf_show_dialog )
p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
}
void Interface::OnPlayStream( void )
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
if( !playlist_IsEmpty(p_playlist) )
{
vlc_value_t state;
input_thread_t *p_input = (input_thread_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input == NULL )
{
/* No stream was playing, start one */
playlist_Play( p_playlist );
TogglePlayButton( PLAYING_S );
pl_Release( p_intf );
return;
}
var_Get( p_input, "state", &state );
if( state.i_int != PAUSE_S )
{
/* A stream is being played, pause it */
state.i_int = PAUSE_S;
}
else
{
/* Stream is paused, resume it */
state.i_int = PLAYING_S;
}
var_Set( p_input, "state", state );
TogglePlayButton( state.i_int );
vlc_object_release( p_input );
}
else
{
/* If the playlist is empty, open a file requester instead */
OnShowDialog( ID_FILE_QUICKOPEN );
}
pl_Release( p_intf );
}
void Interface::TogglePlayButton( int i_playing_status )
{
TBREPLACEBITMAP tbrb;
tbrb.hInstOld = tbrb.hInstNew = (HINSTANCE) hInst;
tbrb.nButtons = NUMIMAGES;
if( i_playing_status == i_old_playing_status ) return;
if( i_playing_status == PLAYING_S )
{
tbrb.nIDOld = IDB_BITMAP2;
tbrb.nIDNew = IDB_BITMAP1;
SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
(LPARAM)(LPTBREPLACEBITMAP)&tbrb );
}
else
{
tbrb.nIDOld = IDB_BITMAP1;
tbrb.nIDNew = IDB_BITMAP2;
SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
(LPARAM)(LPTBREPLACEBITMAP)&tbrb );
}
UpdateWindow( hwndTB );
i_old_playing_status = i_playing_status;
}
void Interface::OnVideoOnTop( void )
{
vlc_value_t val;
vout_thread_t *p_vout = (vout_thread_t *)
vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout == NULL ) return;
if( var_Get( (vlc_object_t *)p_vout, "video-on-top", &val ) < 0 )
return;
val.b_bool = !val.b_bool;
var_Set( (vlc_object_t *)p_vout, "video-on-top", val );
vlc_object_release( (vlc_object_t *)p_vout );
}
void Interface::OnSliderUpdate( int wp )
{
input_thread_t *p_input = p_intf->p_sys->p_input;
int dwPos = SendMessage( hwndSlider, TBM_GETPOS, 0, 0 );
if( (int)LOWORD(wp) == SB_THUMBPOSITION ||
(int)LOWORD(wp) == SB_ENDSCROLL )
{
if( p_intf->p_sys->i_slider_pos != dwPos && p_input )
{
vlc_value_t pos;
pos.f_float = (float)dwPos / (float)SLIDER_MAX_POS;
var_Set( p_input, "position", pos );
}
p_intf->p_sys->b_slider_free = true;
}
else
{
p_intf->p_sys->b_slider_free = false;
if( p_input )
{
/* Update stream date */
char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
mtime_t i_seconds;
i_seconds = var_GetTime( p_input, "length" ) / INT64_C(1000000 );
secstotimestr( psz_total, i_seconds );
i_seconds = var_GetTime( p_input, "time" ) / INT64_C(1000000 );
secstotimestr( psz_time, i_seconds );
SendMessage( hwndLabel, WM_SETTEXT, (WPARAM)1,
(LPARAM)_FROMMB(psz_time) );
}
}
}
void Interface::OnChange( int wp )
{
DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
if( LOWORD(wp) == SB_THUMBPOSITION || LOWORD(wp) == SB_ENDSCROLL )
{
VolumeChange( 200 - (int)dwPos );
b_volume_hold = false;
}
else
{
b_volume_hold = true;
}
}
void Interface::VolumeChange( int i_volume )
{
playlist_t * p_playlist = pl_Hold( p_intf );
aout_VolumeSet( p_playlist, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
pl_Release( p_intf );
}
void Interface::VolumeUpdate()
{
audio_volume_t i_volume;
if( b_volume_hold ) return;
playlist_t * p_playlist = pl_Hold( p_intf );
aout_VolumeGet( p_intf, &i_volume );
pl_Release( p_intf );
int i_volume_ctrl = 200 - i_volume * 200 * 2 / AOUT_VOLUME_MAX;
DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
if( i_volume_ctrl == (int)dwPos ) return;
SendMessage( hwndVol, TBM_SETPOS, 1, i_volume_ctrl );
}
void Interface::OnStopStream( void )
{
playlist_t * p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
playlist_Stop( p_playlist );
TogglePlayButton( PAUSE_S );
pl_Release( p_intf );
}
void Interface::OnPrevStream( void )
{
playlist_t * p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
playlist_Prev( p_playlist );
pl_Release( p_intf );
}
void Interface::OnNextStream( void )
{
playlist_t * p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
playlist_Next( p_playlist );
pl_Release( p_intf );
}
void Interface::OnSlowStream( void )
{
input_thread_t *p_input = (input_thread_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input == NULL ) return;
vlc_value_t val; val.b_bool = true;
var_TriggerCallback( p_input, "rate-slower" );
vlc_object_release( p_input );
}
void Interface::OnFastStream( void )
{
input_thread_t *p_input = (input_thread_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input == NULL ) return;
var_TriggerCallback( p_input, "rate-faster" );
vlc_object_release( p_input );
}
void Interface::Update()
{
/* Misc updates */
VolumeUpdate();
}
/*****************************************************************************
* iteminfo.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include "wince.h"
#include <winuser.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
/*****************************************************************************
* Event Table.
*****************************************************************************/
/*****************************************************************************
* Constructor.
*****************************************************************************/
ItemInfoDialog::ItemInfoDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst,
playlist_item_t *_p_item )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
p_item = _p_item;
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT ItemInfoDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
SHMENUBARINFO mbi;
INITCOMMONCONTROLSEX iccex;
RECT rcClient;
char *psz_uri;
switch( msg )
{
case WM_INITDIALOG:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
//Create the menubar.
memset( &mbi, 0, sizeof (SHMENUBARINFO) );
mbi.cbSize = sizeof (SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.dwFlags = SHCMBF_EMPTYBAR;
mbi.hInstRes = hInst;
if( !SHCreateMenuBar(&mbi) )
{
MessageBox( hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK );
//return -1;
}
hwndCB = mbi.hwndMB;
// Get the client area rect to put the panels in
GetClientRect( hwnd, &rcClient );
/* URI Textbox */
uri_label = CreateWindow( _T("STATIC"), _T("URI:"),
WS_CHILD | WS_VISIBLE | SS_RIGHT,
0, 10, 60, 15, hwnd, NULL, hInst, NULL);
psz_uri = input_item_GetURI( p_item->p_input );
uri_text = CreateWindow( _T("EDIT"), _FROMMB(psz_uri),
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
70, 10 - 3, rcClient.right - 70 - 10, 15 + 6, hwnd, 0, hInst, 0 );
free( psz_uri );
/* Name Textbox */
name_label = CreateWindow( _T("STATIC"), _T("Name:"),
WS_CHILD | WS_VISIBLE | SS_RIGHT ,
0, 10 + 15 + 10, 60, 15,
hwnd, NULL, hInst, NULL);
name_text = CreateWindow( _T("EDIT"),
_FROMMB(p_item->p_input->psz_name),
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
70, 10 + 15 + 10 - 3, rcClient.right - 70 - 10, 15 + 6,
hwnd, NULL, hInst, NULL);
/* CheckBox */
checkbox_label = CreateWindow( _T("STATIC"), _T("Item Enabled:"),
WS_CHILD | WS_VISIBLE | SS_RIGHT ,
rcClient.right - 15 - 10 - 90 - 10, 10 + 4*( 15 + 10 ) + 5, 90, 15,
hwnd, NULL, hInst, NULL );
enabled_checkbox = CreateWindow( _T("BUTTON"), _T("Item Enabled"),
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
rcClient.right - 15 - 10, 10 + 4*( 15 + 10 ) + 5, 15, 15,
hwnd, NULL, hInst, NULL );
SendMessage( enabled_checkbox, BM_SETCHECK,
(p_item->i_flags & PLAYLIST_DBL_FLAG) ?
BST_UNCHECKED : BST_CHECKED, 0 );
/* Treeview */
iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
iccex.dwICC = ICC_TREEVIEW_CLASSES;
InitCommonControlsEx( &iccex );
// Create the tree-view control.
info_tree = CreateWindowEx( 0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
TVS_LINESATROOT | TVS_HASBUTTONS,
0, rcClient.bottom/2, rcClient.right,
rcClient.bottom - rcClient.bottom/2 - MENU_HEIGHT + 2, // +2 to fix
hwnd, NULL, hInst, NULL );
UpdateInfo();
break;
case WM_CLOSE:
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_COMMAND:
if( LOWORD(wp) == IDOK )
{
OnOk();
EndDialog( hwnd, LOWORD( wp ) );
}
break;
default:
break;
}
return FALSE;
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
void ItemInfoDialog::UpdateInfo()
{
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};
HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
HTREEITEM hPrevRootItem = NULL;
HTREEITEM hPrevLev2Item = NULL;
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
// Set the text of the item.
tvi.pszText = _FROMMB(p_item->p_input->psz_name);
tvi.cchTextMax = _tcslen(tvi.pszText);
// Save the heading level in the item's application-defined data area
tvi.lParam = (LPARAM)1; // root level
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
tvins.hParent = TVI_ROOT;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
hPrevRootItem = hPrev;
/* Rebuild the tree */
vlc_mutex_lock( &p_item->p_input->lock );
for( int i = 0; i < p_item->p_input->i_categories; i++ )
{
info_category_t *p_cat = p_item->p_input->pp_categories[i];
// Set the text of the item.
tvi.pszText = _FROMMB( p_item->p_input->psz_name );
tvi.cchTextMax = _tcslen( tvi.pszText );
// Save the heading level in the item's application-defined data area
tvi.lParam = (LPARAM)2; // level 2
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
tvins.hParent = hPrevRootItem;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
hPrevLev2Item = hPrev;
for( int j = 0; j < p_cat->i_infos; j++ )
{
info_t *p_info = p_cat->pp_infos[j];
// Set the text of the item.
string szAnsi = (string)p_info->psz_name;
szAnsi += ": ";
szAnsi += p_info->psz_value;
tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
tvi.cchTextMax = _tcslen( tvi.pszText );
tvi.lParam = (LPARAM)3; // level 3
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
tvins.hParent = hPrevLev2Item;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
}
TreeView_Expand( info_tree, hPrevLev2Item,
TVE_EXPANDPARTIAL |TVE_EXPAND );
}
vlc_mutex_unlock( &p_item->p_input->lock );
TreeView_Expand( info_tree, hPrevRootItem, TVE_EXPANDPARTIAL |TVE_EXPAND );
}
/*****************************************************************************
* Events methods.
*****************************************************************************/
void ItemInfoDialog::OnOk()
{
int b_state = false;
TCHAR psz_name[MAX_PATH];
Edit_GetText( name_text, psz_name, MAX_PATH );
input_item_SetName( p_item->p_input, _TOMB( psz_name ) );
TCHAR psz_uri[MAX_PATH];
Edit_GetText( uri_text, psz_uri, MAX_PATH );
input_item_SetURI( p_item->p_input, _TOMB(psz_uri) );
vlc_mutex_lock( &p_item->p_input->lock );
bool b_old_enabled = !(p_item->i_flags & PLAYLIST_DBL_FLAG);
playlist_t * p_playlist = pl_Hold( p_intf );
if( p_playlist != NULL )
{
b_state = SendMessage( enabled_checkbox, BM_GETCHECK, 0, 0 );
pl_Release( p_intf );
}
p_item->i_flags |= (b_state & BST_CHECKED) ? false : PLAYLIST_DBL_FLAG ;
vlc_mutex_unlock( &p_item->p_input->lock );
}
/*****************************************************************************
* menus.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include "wince.h"
/*****************************************************************************
* Event Table.
*****************************************************************************/
/* IDs for the controls and the menu commands */
enum
{
/* menu items */
MenuDummy_Event = 1000,
OpenFileSimple_Event = 1100,
OpenFile_Event,
OpenDisc_Event,
OpenNet_Event,
FirstAutoGenerated_Event = 1999,
SettingsMenu_Events = 2000,
AudioMenu_Events = 3000,
VideoMenu_Events = 4000,
NavigMenu_Events = 5000,
PopupMenu_Events = 6000
};
HMENU OpenStreamMenu( intf_thread_t *p_intf )
{
HMENU hmenu = CreatePopupMenu();
AppendMenu( hmenu, MF_STRING, ID_FILE_QUICKOPEN,
_T("Quick &Open File...") );
AppendMenu( hmenu, MF_STRING, ID_FILE_OPENFILE,
_T("Open &File...") );
AppendMenu( hmenu, MF_STRING, ID_FILE_OPENNET,
_T("Open &Network Stream...") );
return hmenu;
}
HMENU MiscMenu( intf_thread_t *p_intf )
{
HMENU hmenu = CreatePopupMenu();
AppendMenu( hmenu, MF_STRING, ID_VIEW_STREAMINFO, _T("Media &Info...") );
AppendMenu( hmenu, MF_STRING, ID_VIEW_MESSAGES, _T("&Messages...") );
AppendMenu( hmenu, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );
return hmenu;
}
void PopupMenu( intf_thread_t *p_intf, HWND p_parent, POINT point )
{
#define MAX_POPUP_ITEMS 45
vlc_object_t *p_object, *p_input;
char *ppsz_varnames[MAX_POPUP_ITEMS];
vlc_object_t * pi_objects[MAX_POPUP_ITEMS];
int i = 0, i_last_separator = 0;
/* Initializations */
memset( pi_objects, 0, MAX_POPUP_ITEMS * sizeof(vlc_object_t *) );
ppsz_varnames[i] = "VLC media player";
pi_objects[i++] = 0;
ppsz_varnames[i++] = NULL; /* Separator */
i_last_separator = i;
/* Input menu */
p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "bookmark";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "title";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "chapter";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "program";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "navigation";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "dvd_menus";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "video-es";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "audio-es";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "spu-es";
pi_objects[i++] = p_object;
}
p_input = p_object;
if( !p_input ) goto interfacemenu;
/* Video menu */
if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
i_last_separator = i;
p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_object != NULL )
{
vlc_object_t *p_dec_obj;
ppsz_varnames[i] = "fullscreen";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "zoom";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "deinterlace-mode";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "aspect-ratio";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "crop";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "video-on-top";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "directx-wallpaper";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "video-snapshot";
pi_objects[i++] = p_object;
p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
VLC_OBJECT_DECODER,
FIND_PARENT );
if( p_dec_obj != NULL )
{
ppsz_varnames[i] = "ffmpeg-pp-q";
pi_objects[i++] = p_dec_obj;
vlc_object_release( p_dec_obj );
}
vlc_object_release( p_object );
}
/* Audio menu */
if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
i_last_separator = i;
p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "audio-device";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "audio-channels";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "visual";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "equalizer";
pi_objects[i++] = p_object;
vlc_object_release( p_object );
}
interfacemenu:
/* Interface menu */
if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
i_last_separator = i;
/* Build menu */
vector<MenuItemExt*> popup_menu;
HMENU hmenu = CreatePopupMenu();
RefreshMenu( p_intf, &popup_menu, hmenu, i,
ppsz_varnames, pi_objects, PopupMenu_Events );
MenuItemExt::ClearList( &popup_menu );
/* Add static entries */
if( p_input != NULL )
{
vlc_value_t val;
AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
AppendMenu( hmenu, MF_STRING, StopStream_Event, _T("Stop") );
AppendMenu( hmenu, MF_STRING, PrevStream_Event, _T("Previous") );
AppendMenu( hmenu, MF_STRING, NextStream_Event, _T("Next") );
var_Get( p_input, "state", &val );
if( val.i_int == PAUSE_S )
AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
else
AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Pause") );
vlc_object_release( p_input );
}
else
{
playlist_t * p_playlist = pl_Hold( p_intf );
if( p_playlist && !playlist_IsEmpty( p_playlist ) )
{
AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
}
if( p_playlist ) pl_Release( p_intf );
}
AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)MiscMenu( p_intf ),
_T("Miscellaneous") );
AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)OpenStreamMenu( p_intf ),
_T("Open") );
TrackPopupMenu( hmenu, 0, point.x, point.y, 0, p_parent, 0 );
PostMessage( p_parent, WM_NULL, 0, 0 );
DestroyMenu( hmenu );
}
void RefreshAudioMenu( intf_thread_t *p_intf, HMENU hMenu )
{
#define MAX_AUDIO_ITEMS 10
vlc_object_t *p_object;
char *ppsz_varnames[MAX_AUDIO_ITEMS];
vlc_object_t * pi_objects[MAX_AUDIO_ITEMS];
int i;
/* Delete old menu */
int count = wce_GetMenuItemCount( hMenu );
for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
if( p_intf->p_sys->p_audio_menu )
MenuItemExt::ClearList( p_intf->p_sys->p_audio_menu );
else p_intf->p_sys->p_audio_menu = new vector<MenuItemExt*>;
/* Initializations */
memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(vlc_object_t *) );
i = 0;
p_object = (vlc_object_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "audio-es";
pi_objects[i++] = p_object;
vlc_object_release( p_object );
}
p_object = (vlc_object_t *)
vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "audio-device";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "audio-channels";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "visual";
pi_objects[i++] = p_object;
vlc_object_release( p_object );
}
/* Build menu */
RefreshMenu( p_intf, p_intf->p_sys->p_audio_menu,
hMenu, i, ppsz_varnames, pi_objects, AudioMenu_Events );
}
void RefreshVideoMenu( intf_thread_t *p_intf, HMENU hMenu )
{
#define MAX_VIDEO_ITEMS 15
vlc_object_t *p_object;
char *ppsz_varnames[MAX_VIDEO_ITEMS];
vlc_object_t * pi_objects[MAX_VIDEO_ITEMS];
int i;
/* Delete old menu */
int count = wce_GetMenuItemCount( hMenu );
for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
if( p_intf->p_sys->p_video_menu )
MenuItemExt::ClearList( p_intf->p_sys->p_video_menu );
else p_intf->p_sys->p_video_menu = new vector<MenuItemExt*>;
/* Initializations */
memset( pi_objects, 0, MAX_VIDEO_ITEMS * sizeof(vlc_object_t *) );
i = 0;
p_object = (vlc_object_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "video-es";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "spu-es";
pi_objects[i++] = p_object;
vlc_object_release( p_object );
}
p_object = (vlc_object_t *)
vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_object != NULL )
{
vlc_object_t *p_dec_obj;
ppsz_varnames[i] = "fullscreen";
pi_objects[i++] = p_object;
#ifdef WINCE
ppsz_varnames[i] = "transform";
pi_objects[i++] = p_object;
#endif
ppsz_varnames[i] = "zoom";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "deinterlace-mode";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "aspect-ratio";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "crop";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "directx-on-top";
pi_objects[i++] = p_object;
p_dec_obj = (vlc_object_t *)
vlc_object_find( p_object, VLC_OBJECT_DECODER, FIND_PARENT );
if( p_dec_obj != NULL )
{
ppsz_varnames[i] = "ffmpeg-pp-q";
pi_objects[i++] = p_dec_obj;
vlc_object_release( p_dec_obj );
}
vlc_object_release( p_object );
}
/* Build menu */
RefreshMenu( p_intf, p_intf->p_sys->p_video_menu, hMenu, i,
ppsz_varnames, pi_objects, VideoMenu_Events );
}
void RefreshNavigMenu( intf_thread_t *p_intf, HMENU hMenu )
{
#define MAX_NAVIG_ITEMS 10
vlc_object_t *p_object;
char *ppsz_varnames[MAX_NAVIG_ITEMS];
vlc_object_t * pi_objects[MAX_NAVIG_ITEMS];
int i;
/* Delete old menu */
int count = wce_GetMenuItemCount( hMenu );
for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
if( p_intf->p_sys->p_navig_menu )
MenuItemExt::ClearList( p_intf->p_sys->p_navig_menu );
else p_intf->p_sys->p_navig_menu = new vector<MenuItemExt*>;
/* Initializations */
memset( pi_objects, 0, MAX_NAVIG_ITEMS * sizeof(vlc_object_t *) );
i = 0;
p_object = (vlc_object_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "title";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "chapter";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "program";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "navigation";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "dvd_menus";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "prev-title";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "next-title";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "prev-chapter";
pi_objects[i++] = p_object;
ppsz_varnames[i] = "next-chapter";
pi_objects[i++] = p_object;
vlc_object_release( p_object );
}
/* Build menu */
RefreshMenu( p_intf, p_intf->p_sys->p_navig_menu, hMenu, i,
ppsz_varnames, pi_objects, NavigMenu_Events );
}
void RefreshSettingsMenu( intf_thread_t *p_intf, HMENU hMenu )
{
#define MAX_SETTINGS_ITEMS 10
vlc_object_t *p_object;
char *ppsz_varnames[MAX_SETTINGS_ITEMS];
vlc_object_t * pi_objects[MAX_SETTINGS_ITEMS];
int i;
/* Delete old menu */
int count = wce_GetMenuItemCount( hMenu );
for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
if( p_intf->p_sys->p_settings_menu )
MenuItemExt::ClearList( p_intf->p_sys->p_settings_menu );
else p_intf->p_sys->p_settings_menu = new vector<MenuItemExt*>;
/* Initializations */
memset( pi_objects, 0, MAX_SETTINGS_ITEMS * sizeof(vlc_object_t *) );
i = 0;
AppendMenu( hMenu, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );
/* Other interfaces */
/*FIXME: copy the Qt way of mapping menus and objects */
/*p_object = (vlc_object_t *) NULL;
//vlc_object_find_name( p_intf, "wince", FIND_PARENT );
if( p_object != NULL )
{
ppsz_varnames[i] = "intf-add";
pi_objects[i++] = p_object;
vlc_object_release( p_object );
}*/
/* Build menu */
RefreshMenu( p_intf, p_intf->p_sys->p_settings_menu, hMenu, i,
ppsz_varnames, pi_objects, SettingsMenu_Events );
}
/*****************************************************************************
* Refresh the menu.
*****************************************************************************/
void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
HMENU hMenu , int i_count, char **ppsz_varnames,
vlc_object_t **pi_objects, int i_start_id )
{
vlc_object_t *p_object;
bool b_section_empty = false;
int i;
/* Initializations */
int i_item_id = i_start_id;
for( i = 0; i < i_count; i++ )
{
if( !ppsz_varnames[i] )
{
if( b_section_empty )
{
AppendMenu( hMenu, MF_GRAYED | MF_STRING,
MenuDummy_Event + i, _T("Empty") );
}
AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") );
b_section_empty = true;
continue;
}
if( !pi_objects[i] )
{
AppendMenu( hMenu, MF_GRAYED | MF_STRING,
MenuDummy_Event, _FROMMB(ppsz_varnames[i]) );
b_section_empty = false;
continue;
}
p_object = pi_objects[i];
if( p_object == NULL ) continue;
b_section_empty = false;
CreateMenuItem( p_intf, p_menu_list, hMenu, ppsz_varnames[i],
p_object, &i_item_id );
vlc_object_release( p_object );
}
/* Special case for empty menus */
if( wce_GetMenuItemCount(hMenu) == 0 || b_section_empty )
{
AppendMenu( hMenu, MF_GRAYED | MF_STRING,
MenuDummy_Event + i, _T("Empty") );
}
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
HMENU hMenu, char *psz_var, vlc_object_t *p_object,
int *pi_item_id )
{
MenuItemExt *pMenuItemExt;
HMENU hMenuItem;
vlc_value_t val, text;
int i_type;
/* Check the type of the object variable */
i_type = var_Type( p_object, psz_var );
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
case VLC_VAR_BOOL:
case VLC_VAR_VARIABLE:
case VLC_VAR_STRING:
case VLC_VAR_INTEGER:
case VLC_VAR_FLOAT:
break;
default:
/* Variable doesn't exist or isn't handled */
return;
}
/* Make sure we want to display the variable */
if( i_type & VLC_VAR_HASCHOICE )
{
var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
if( val.i_int == 0 ) return;
if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
return;
}
/* Get the descriptive name of the variable */
var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
var_Get( p_object, psz_var, &val );
if( i_type & VLC_VAR_HASCHOICE )
{
hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, psz_var,
p_object, pi_item_id );
AppendMenu( hMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
_FROMMB(text.psz_string ? text.psz_string : psz_var) );
if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
free( text.psz_string );
return;
}
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
AppendMenu( hMenu, MF_STRING , ++(*pi_item_id),
_FROMMB(text.psz_string ? text.psz_string : psz_var) );
pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
p_object, val, i_type );
p_menu_list->push_back( pMenuItemExt );
break;
case VLC_VAR_BOOL:
val.b_bool = !val.b_bool;
AppendMenu( hMenu, MF_STRING | MF_CHECKED, ++(*pi_item_id),
_FROMMB(text.psz_string ? text.psz_string : psz_var) );
pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
p_object, val, i_type );
p_menu_list->push_back( pMenuItemExt );
CheckMenuItem( hMenu, *pi_item_id ,
( val.b_bool ? MF_UNCHECKED : MF_CHECKED ) |
MF_BYCOMMAND );
break;
default:
free( text.psz_string );
return;
}
if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
free( text.psz_string );
}
HMENU CreateChoicesMenu( intf_thread_t *p_intf,
vector<MenuItemExt*> *p_menu_list, char *psz_var,
vlc_object_t *p_object, int *pi_item_id )
{
MenuItemExt *pMenuItemExt;
vlc_value_t val, val_list, text_list;
int i_type, i;
HMENU hSubMenu = CreatePopupMenu();
/* Check the type of the object variable */
i_type = var_Type( p_object, psz_var );
/* Make sure we want to display the variable */
if( i_type & VLC_VAR_HASCHOICE )
{
var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
if( val.i_int == 0 ) return NULL;
if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
return NULL;
}
else
{
return NULL;
}
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
case VLC_VAR_BOOL:
case VLC_VAR_VARIABLE:
case VLC_VAR_STRING:
case VLC_VAR_INTEGER:
break;
default:
/* Variable doesn't exist or isn't handled */
return NULL;
}
if( var_Get( p_object, psz_var, &val ) < 0 ) return NULL;
if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
&val_list, &text_list ) < 0 )
{
if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
return NULL;
}
for( i = 0; i < val_list.p_list->i_count; i++ )
{
vlc_value_t another_val;
HMENU hMenuItem;
char *psz_tmp;
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VARIABLE:
hMenuItem = CreateChoicesMenu( p_intf, p_menu_list,
val_list.p_list->p_values[i].psz_string, p_object, pi_item_id );
AppendMenu( hSubMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
_FROMMB(text_list.p_list->p_values[i].psz_string ?
text_list.p_list->p_values[i].psz_string :
val_list.p_list->p_values[i].psz_string) );
break;
case VLC_VAR_STRING:
another_val.psz_string =
strdup(val_list.p_list->p_values[i].psz_string);
AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
_FROMMB(text_list.p_list->p_values[i].psz_string ?
text_list.p_list->p_values[i].psz_string :
val_list.p_list->p_values[i].psz_string) );
pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
p_object, another_val, i_type );
p_menu_list->push_back( pMenuItemExt );
if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string &&
!strcmp( val.psz_string,
val_list.p_list->p_values[i].psz_string ) )
CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
break;
case VLC_VAR_INTEGER:
asprintf( &psz_tmp, "%d", val_list.p_list->p_values[i].i_int );
AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
_FROMMB(text_list.p_list->p_values[i].psz_string ?
text_list.p_list->p_values[i].psz_string : psz_tmp));
free( psz_tmp );
pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
p_object, val_list.p_list->p_values[i], i_type );
p_menu_list->push_back( pMenuItemExt );
if( val_list.p_list->p_values[i].i_int == val.i_int )
CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
break;
default:
break;
}
}
/* Clean up everything */
if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
var_FreeList( &val_list, &text_list );
return hSubMenu;
}
int wce_GetMenuItemCount(HMENU hMenu)
{
const int MAX_NUM_ITEMS = 256;
int iPos, iCount;
MENUITEMINFO mii;
memset( (char *)&mii, 0, sizeof(MENUITEMINFO) );
mii.cbSize = sizeof(MENUITEMINFO);
iCount = 0;
for( iPos = 0; iPos < MAX_NUM_ITEMS; iPos++ )
{
if( !GetMenuItemInfo(hMenu, (UINT)iPos, TRUE, &mii) ) break;
iCount++;
}
return iCount;
}
void OnMenuEvent( intf_thread_t *p_intf, int id )
{
MenuItemExt *p_menuitemext = NULL;
vector<MenuItemExt*>::iterator iter;
if( p_intf->p_sys->p_settings_menu )
for( iter = p_intf->p_sys->p_settings_menu->begin();
iter != p_intf->p_sys->p_settings_menu->end(); iter++ )
if( (*iter)->id == id )
{
p_menuitemext = *iter;
break;
}
if( p_intf->p_sys->p_audio_menu && !p_menuitemext )
for( iter = p_intf->p_sys->p_audio_menu->begin();
iter != p_intf->p_sys->p_audio_menu->end(); iter++ )
if( (*iter)->id == id )
{
p_menuitemext = *iter;
break;
}
if( p_intf->p_sys->p_video_menu && !p_menuitemext )
for( iter = p_intf->p_sys->p_video_menu->begin();
iter != p_intf->p_sys->p_video_menu->end(); iter++ )
if( (*iter)->id == id )
{
p_menuitemext = *iter;
break;
}
if( p_intf->p_sys->p_navig_menu && !p_menuitemext )
for( iter = p_intf->p_sys->p_navig_menu->begin();
iter != p_intf->p_sys->p_navig_menu->end(); iter++ )
if( (*iter)->id == id )
{
p_menuitemext = *iter;
break;
}
if( p_menuitemext )
{
vlc_object_t *p_object = p_menuitemext->p_object;
if( p_object == NULL ) return;
var_Set( p_object, p_menuitemext->psz_var, p_menuitemext->val );
int i_type = var_Type( p_object, p_menuitemext->psz_var );
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_VOID:
case VLC_VAR_BOOL:
case VLC_VAR_VARIABLE:
case VLC_VAR_STRING:
case VLC_VAR_INTEGER:
break;
default:
/* Variable doesn't exist or isn't handled */
return;
}
vlc_object_release( p_object );
}
}
/*****************************************************************************
* A small helper class which encapsulate wxMenuitem with some other useful
* things.
*****************************************************************************/
MenuItemExt::MenuItemExt( intf_thread_t *p_intf, int _id, char *_psz_var,
vlc_object_t * _p_object, vlc_value_t _val, int _i_val_type )
{
/* Initializations */
id = _id;
p_intf = p_intf;
psz_var = strdup( _psz_var );
i_val_type = _i_val_type;
p_object = _p_object;
val = _val;
};
MenuItemExt::~MenuItemExt()
{
free( psz_var );
if( ( i_val_type & VLC_VAR_TYPE ) == VLC_VAR_STRING )
free( val.psz_string );
};
void MenuItemExt::ClearList( vector<MenuItemExt*> *p_menu_list )
{
vector<MenuItemExt*>::iterator iter;
if( !p_menu_list ) return;
for( iter = p_menu_list->begin(); iter != p_menu_list->end(); iter++ )
{
delete *iter;
}
p_menu_list->clear();
}
/*****************************************************************************
* messages.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include "wince.h"
#include <winuser.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#ifndef NMAXFILE
#define NMAXFILE 512 // at least 256
#endif
#ifndef TEXTMAXBUF
#define TEXTMAXBUF 512 // at least 500
#endif
/*****************************************************************************
* Constructor.
*****************************************************************************/
Messages::Messages( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
hListView = NULL;
hWnd = CreateWindow( _T("VLC WinCE"), _T("Messages"),
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
p_parent->GetHandle(), NULL, h_inst, (void *)this );
// Suscribe to messages bank
cb_data = new msg_cb_data_t;
cb_data->self = this;
sub = msg_Subscribe( p_intf->p_libvlc, sinkMessage, cb_data );
}
Messages::~Messages()
{
msg_Unsubscribe(sub);
delete cb_data;
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
TCHAR psz_text[TEXTMAXBUF];
OPENFILENAME ofn;
int i_dummy;
HANDLE fichier;
switch( msg )
{
case WM_CREATE:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
hListView = CreateWindow( WC_LISTVIEW, NULL,
WS_VISIBLE | WS_CHILD | LVS_REPORT |
LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL |
WS_BORDER | LVS_NOCOLUMNHEADER, 0, 0, 0, 0,
hwnd, NULL, hInst, NULL );
ListView_SetExtendedListViewStyle( hListView, LVS_EX_FULLROWSELECT );
LVCOLUMN lv;
lv.mask = LVCF_FMT;
lv.fmt = LVCFMT_LEFT ;
ListView_InsertColumn( hListView, 0, &lv );
SetTimer( hwnd, 1, 500 /*milliseconds*/, NULL );
break;
case WM_WINDOWPOSCHANGED:
{
RECT rect;
if( !GetClientRect( hwnd, &rect ) ) break;
SetWindowPos( hListView, 0, 0, 0,
rect.right - rect.left, rect.bottom - rect.top, 0 );
LVCOLUMN lv;
lv.cx = rect.right - rect.left;
lv.mask = LVCF_WIDTH;
ListView_SetColumn( hListView, 0, &lv );
}
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_CLOSE:
Show( FALSE );
return TRUE;
case WM_COMMAND:
switch( LOWORD(wp) )
{
case IDOK:
Show( FALSE );
break;
case IDCLEAR:
ListView_DeleteAllItems( hListView );
break;
case IDSAVEAS:
memset( &(ofn), 0, sizeof(ofn) );
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = _T("");
ofn.nMaxFile = NMAXFILE;
ofn.lpstrFilter = _T("Text (*.txt)\0*.txt\0");
ofn.lpstrTitle = _T("Save File As");
ofn.Flags = OFN_HIDEREADONLY;
ofn.lpstrDefExt = _T("txt");
if( GetSaveFileName( (LPOPENFILENAME)&ofn ) )
{
fichier = CreateFile( ofn.lpstrFile, GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL );
if( fichier != INVALID_HANDLE_VALUE )
{
int n;
//SetFilePointer( fichier, 0, NULL, FILE_END );
for( n = 0; n < ListView_GetItemCount( hListView ); n++ )
{
ListView_GetItemText( hListView, n, 0, psz_text,
TEXTMAXBUF );
string text_out = (string)_TOMB(psz_text) + "\n";
WriteFile( fichier, text_out.c_str(), text_out.size(),
(LPDWORD)&i_dummy, NULL );
}
FlushFileBuffers( fichier );
CloseHandle(fichier);
}
}
break;
default:
break;
}
default:
break;
}
return DefWindowProc( hwnd, msg, wp, lp );
}
void Messages::sinkMessage (msg_cb_data_t *data, msg_item_t *item,
unsigned overruns)
{
Messages *self = data->self;
self->sinkMessage (item, overruns);
}
void Messages::sinkMessage (msg_item_t *item, unsigned overruns)
{
vlc_value_t val;
var_Get( p_intf->p_libvlc, "verbose", &val );
/* Append all messages to log window */
string debug = item->psz_module;
switch( item->i_type )
{
case VLC_MSG_INFO: debug += ": "; break;
case VLC_MSG_ERR: debug += " error: "; break;
case VLC_MSG_WARN: debug += " warning: "; break;
default: debug += " debug: "; break;
}
/* Add message */
debug += item->psz_msg;
LVITEM lv;
lv.mask = LVIF_TEXT;
lv.pszText = TEXT("");
lv.cchTextMax = 1;
lv.iSubItem = 0;
lv.iItem = ListView_GetItemCount( hListView );
ListView_InsertItem( hListView, &lv );
ListView_SetItemText( hListView, lv.iItem, 0,
(TCHAR *)_FROMMB(debug.c_str()) );
}
/*****************************************************************************
* open.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include "wince.h"
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shlobj.h>
/*****************************************************************************
* Event Table.
*****************************************************************************/
/* IDs for the controls and the menu commands */
enum
{
Notebook_Event = 1000,
MRL_Event,
FileBrowse_Event,
FileName_Event,
DiscType_Event,
DiscDevice_Event,
DiscTitle_Event,
DiscChapter_Event,
NetType_Event,
NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
NetPort1_Event, NetPort2_Event, NetPort3_Event,
NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
SubsFileEnable_Event,
SubsFileSettings_Event,
};
/*****************************************************************************
* AutoBuiltPanel.
*****************************************************************************/
/*****************************************************************************
* Constructor.
*****************************************************************************/
OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst, int _i_access, int _i_arg )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
i_access = _i_access;
i_open_arg = _i_arg;
for( int i = 0; i < 4; i++ )
{
net_radios[i] = 0;
net_label[i] = 0;
net_port_label[i] = 0;
net_ports[i] = 0;
hUpdown[i] = 0;
i_net_ports[i] = 0;
net_addrs_label[i] = 0;
net_addrs[i] = 0;
}
CreateWindow( _T("VLC WinCE"), _T("Messages"),
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
p_parent->GetHandle(), NULL, h_inst, (void *)this );
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
RECT rcClient;
TC_ITEM tcItem;
switch( msg )
{
case WM_CREATE:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
// Get the client area rect to put the panels in
GetClientRect( hwnd, &rcClient );
/* Create MRL combobox */
mrl_box = CreateWindow( _T("STATIC"),
_FROMMB(_("Media Resource Locator (MRL)")),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
rcClient.right - 50 - 5, 5*15 + 6, hwnd,
0, hInst, 0 );
// No tooltips for ComboBox
label = CreateWindow( _T("STATIC"),
_FROMMB(_("Alternatively, you can build an MRL "
"using one of the following predefined "
"targets:" )),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
hwnd, 0, hInst, 0 );
/* Create notebook */
iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
iccex.dwSize = ICC_TAB_CLASSES;
InitCommonControlsEx (&iccex);
notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
hwnd, NULL, hInst, NULL );
tcItem.mask = TCIF_TEXT;
tcItem.pszText = _T("File");
TabCtrl_InsertItem( notebook, 0, &tcItem );
tcItem.pszText = _T("Network");
TabCtrl_InsertItem( notebook, 1, &tcItem );
switch( i_access )
{
case FILE_ACCESS:
TabCtrl_SetCurSel( notebook, 0 );
break;
case NET_ACCESS:
TabCtrl_SetCurSel( notebook, 1 );
break;
}
FilePanel( hwnd );
NetPanel( hwnd );
OnPageChange();
break;
case WM_CLOSE:
Show( FALSE );
return TRUE;
case WM_SETFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
SHSipPreference( hwnd, SIP_DOWN );
break;
case WM_COMMAND:
if( LOWORD(wp) == IDOK )
{
OnOk();
Show( FALSE );
break;
}
if( HIWORD(wp) == BN_CLICKED )
{
if( (HWND)lp == net_radios[0] )
{
OnNetTypeChange( NetRadio1_Event );
} else if( (HWND)lp == net_radios[1] )
{
OnNetTypeChange( NetRadio2_Event );
} else if( (HWND)lp == net_radios[2] )
{
OnNetTypeChange( NetRadio3_Event );
} else if( (HWND)lp == net_radios[3] )
{
OnNetTypeChange( NetRadio4_Event );
} else if( (HWND)lp == subsfile_checkbox )
{
OnSubsFileEnable();
} else if( (HWND)lp == subsfile_button )
{
OnSubsFileSettings( hwnd );
} else if( (HWND)lp == browse_button )
{
OnFileBrowse();
}
break;
}
if( HIWORD(wp) == EN_CHANGE )
{
if( (HWND)lp == net_addrs[1] )
{
OnNetPanelChange( NetAddr2_Event );
} else if( (HWND)lp == net_addrs[2] )
{
OnNetPanelChange( NetAddr3_Event );
} else if( (HWND)lp == net_addrs[3] )
{
OnNetPanelChange( NetAddr4_Event );
} else if( (HWND)lp == net_ports[0] )
{
OnNetPanelChange( NetPort1_Event );
} else if( (HWND)lp == net_ports[1] )
{
OnNetPanelChange( NetPort2_Event );
}
}
if( HIWORD(wp) == CBN_EDITUPDATE )
{
if ((HWND)lp == file_combo)
{
OnFilePanelChange();
}
}
break;
case WM_NOTIFY:
if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
break;
default:
break;
}
return DefWindowProc( hwnd, msg, wp, lp );
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
void OpenDialog::FilePanel( HWND hwnd )
{
RECT rc;
GetWindowRect( notebook, &rc );
/* Create browse file line */
file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
5*15 + 6, hwnd, NULL, hInst, NULL );
browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
hwnd, NULL, hInst, NULL );
/* Create Subtitles File checkox */
subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
hwnd, NULL, hInst, NULL );
SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
hwnd, NULL, hInst, NULL);
subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
hwnd, NULL, hInst, NULL );
char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
if( psz_subsfile && *psz_subsfile )
{
SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
EnableWindow( subsfile_button, TRUE );
string sz_subsfile = "sub-file=";
sz_subsfile += psz_subsfile;
subsfile_mrl.push_back( sz_subsfile );
}
free( psz_subsfile );
}
void OpenDialog::NetPanel( HWND hwnd )
{
INITCOMMONCONTROLSEX ic;
TCHAR psz_text[256];
struct net_type
{
TCHAR *psz_text;
int length;
};
static struct net_type net_type_array[] =
{
{ _T("UDP/RTP"), 82 },
{ _T("UDP/RTP Multicast"), 140 },
{ _T("HTTP/FTP/MMS"), 90 },
{ _T("RTSP"), 30 }
};
RECT rc;
GetWindowRect( notebook, &rc);
/* UDP/RTP row */
net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
15, hwnd, NULL, hInst, NULL );
i_net_ports[0] = config_GetInt( p_intf, "server-port" );
net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
hwnd, NULL, hInst, NULL );
_stprintf( psz_text, _T("%d"), i_net_ports[0] );
net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
ic.dwICC = ICC_UPDOWN_CLASS;
InitCommonControlsEx(&ic);
hUpdown[0] = CreateUpDownControl(
WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
0, 0, 0, 0, hwnd, 0, hInst,
net_ports[0], 16000, 0, i_net_ports[0]);
/* UDP/RTP Multicast row */
net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
hwnd, NULL, hInst, NULL);
net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
hwnd, NULL, hInst, NULL);
net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
hwnd, NULL, hInst, NULL);
net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
hwnd, NULL, hInst, NULL);
i_net_ports[1] = i_net_ports[0];
_stprintf( psz_text, _T("%d"), i_net_ports[1] );
net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
hwnd, NULL, hInst, NULL );
ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
ic.dwICC = ICC_UPDOWN_CLASS;
InitCommonControlsEx(&ic);
hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
0, 0, 0, 0, hwnd, 0, hInst,
net_ports[1], 16000, 0, i_net_ports[1] );
/* HTTP and RTSP rows */
net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
rc.top + 10, net_type_array[2].length, 15,
hwnd, NULL, hInst, NULL );
net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
hwnd, NULL, hInst, NULL );
net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
hwnd, NULL, hInst, NULL);
net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
hwnd, NULL, hInst, NULL );
net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
hwnd, NULL, hInst, NULL );
net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
hwnd, NULL, hInst, NULL );
SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
}
void OpenDialog::UpdateMRL()
{
UpdateMRL( i_access );
}
void OpenDialog::UpdateMRL( int i_access_method )
{
string demux, mrltemp;
TCHAR psz_text[2048];
char psz_tmp[256];
i_access = i_access_method;
switch( i_access_method )
{
case FILE_ACCESS:
GetWindowText( file_combo, psz_text, 2048 );
mrltemp = _TOMB(psz_text);
break;
case NET_ACCESS:
switch( i_net_type )
{
case 0:
mrltemp = "udp" + demux + "://";
if( i_net_ports[0] !=
config_GetInt( p_intf, "server-port" ) )
{
sprintf( psz_tmp, "@:%d", i_net_ports[0] );
mrltemp += psz_tmp;
}
break;
case 1:
mrltemp = "udp" + demux + "://@";
Edit_GetText( net_addrs[1], psz_text, 2048 );
mrltemp += _TOMB(psz_text);
if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
{
sprintf( psz_tmp, ":%d", i_net_ports[1] );
mrltemp += psz_tmp;
}
break;
case 2:
/* http access */
Edit_GetText( net_addrs[2], psz_text, 2048 );
if( !strstr( _TOMB(psz_text), "http://" ) )
{
mrltemp = "http" + demux + "://";
}
mrltemp += _TOMB(psz_text);
break;
case 3:
/* RTSP access */
Edit_GetText( net_addrs[3], psz_text, 2048 );
if( !strstr( _TOMB(psz_text), "rtsp://" ) )
{
mrltemp = "rtsp" + demux + "://";
}
mrltemp += _TOMB(psz_text);
break;
}
break;
default:
break;
}
SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
}
void OpenDialog::OnPageChange()
{
if( TabCtrl_GetCurSel( notebook ) == 0 )
{
for( int i=0; i<4; i++ )
{
SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
DisableNETCtrl();
SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
i_access = FILE_ACCESS;
}
else if ( TabCtrl_GetCurSel( notebook ) == 1 )
{
SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
for( int i=0; i<4; i++ )
{
SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
i_access = NET_ACCESS;
}
UpdateMRL();
}
void OpenDialog::OnOk()
{
TCHAR psz_text[2048];
GetWindowText( mrl_combo, psz_text, 2048 );
int i_args;
/*char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
ComboBox_AddString( mrl_combo, psz_text );
if( ComboBox_GetCount( mrl_combo ) > 10 )
ComboBox_DeleteString( mrl_combo, 0 );
ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );*/
/* Update the playlist */
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
/* for( int i = 0; i < i_args; i++ )
{
bool b_start = !i && i_open_arg;
playlist_item_t *p_item =
playlist_ItemNew( p_playlist, pp_args[i], pp_args[i] );
/* Insert options */
/* while( i + 1 < i_args && pp_args[i + 1][0] == ':' )
{
playlist_ItemAddOption( p_item, pp_args[i + 1] );
i++;
}*/
/* Get the options from the subtitles dialog */
/* if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
&& subsfile_mrl.size() )
{
for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
{
playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
}
}
if( b_start )
{
playlist_AddItem( p_playlist, p_item,
PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END );
}
else
{
playlist_AddItem( p_playlist, p_item,
PLAYLIST_APPEND, PLAYLIST_END );
}
}
//TogglePlayButton( PLAYING_S );
while( i_args-- )
{
free( pp_args[i_args] );
if( !i_args ) free( pp_args );
}*/
pl_Release( p_intf );
}
/*****************************************************************************
* File panel event methods.
*****************************************************************************/
void OpenDialog::OnFilePanelChange()
{
UpdateMRL( FILE_ACCESS );
}
static void OnOpenCB( intf_dialog_args_t *p_arg )
{
OpenDialog *p_this = (OpenDialog *)p_arg->p_arg;
char psz_tmp[PATH_MAX+2] = "\0";
if( p_arg->i_results && p_arg->psz_results[0] )
{
if( strchr( p_arg->psz_results[0], ' ' ) )
{
strcat( psz_tmp, "\"" );
strcat( psz_tmp, p_arg->psz_results[0] );
strcat( psz_tmp, "\"" );
}
else strcat( psz_tmp, p_arg->psz_results[0] );
SetWindowText( p_this->file_combo, _FROMMB(psz_tmp) );
ComboBox_AddString( p_this->file_combo, _FROMMB(psz_tmp) );
if( ComboBox_GetCount( p_this->file_combo ) > 10 )
ComboBox_DeleteString( p_this->file_combo, 0 );
p_this->UpdateMRL( FILE_ACCESS );
}
}
void OpenDialog::OnFileBrowse()
{
intf_dialog_args_t *p_arg =
(intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
memset( p_arg, 0, sizeof(intf_dialog_args_t) );
p_arg->psz_title = strdup( "Open file" );
p_arg->psz_extensions = strdup( "All (*.*)|*.*" );
p_arg->p_arg = this;
p_arg->pf_callback = OnOpenCB;
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
}
/*****************************************************************************
* Net panel event methods.
*****************************************************************************/
void OpenDialog::OnNetPanelChange( int event )
{
TCHAR psz_text[2048];
int port;
if( event >= NetPort1_Event && event <= NetPort2_Event )
{
Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
_stscanf( psz_text, _T("%d"), &port );
i_net_ports[event - NetPort1_Event] = port;
}
UpdateMRL( NET_ACCESS );
}
void OpenDialog::OnNetTypeChange( int event )
{
DisableNETCtrl();
i_net_type = event - NetRadio1_Event;
if( event == NetRadio1_Event )
{
SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
else if( event == NetRadio2_Event )
{
SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
else if( event == NetRadio3_Event )
{
SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
else if( event == NetRadio4_Event )
{
SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
UpdateMRL( NET_ACCESS );
}
void OpenDialog::DisableNETCtrl()
{
for( int i=0; i<4; i++ )
{
SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
UpdateMRL( FILE_ACCESS );
}
/*****************************************************************************
* Subtitles file event methods.
*****************************************************************************/
void OpenDialog::OnSubsFileEnable()
{
EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
}
void OpenDialog::OnSubsFileSettings( HWND hwnd )
{
/* Show/hide the open dialog */
SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
CreateDialogBox( hwnd, subsfile_dialog );
subsfile_mrl.clear();
for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
delete subsfile_dialog;
}
/*****************************************************************************
* playlist.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include "wince.h"
#include <commctrl.h>
#include <commdlg.h>
#ifndef TEXTMAXBUF
#define TEXTMAXBUF 512 // at least 500
#endif
#define LONG2POINT(l, pt) ((pt).x = (SHORT)LOWORD(l), (pt).y = (SHORT)HIWORD(l))
#define NUMIMAGES 11 // Number of buttons in the toolbar
#define IMAGEWIDTH 16 // 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
enum
{
Infos_Event = 1000,
Up_Event,
Down_Event,
Random_Event,
Loop_Event,
Repeat_Event,
PopupPlay_Event,
PopupDel_Event,
PopupEna_Event,
PopupInfo_Event
};
// Help strings
#define HELP_OPENPL _T("Open playlist")
#define HELP_SAVEPL _T("Save playlist")
#define HELP_ADDFILE _T("Add File")
#define HELP_ADDMRL _T("Add MRL")
#define HELP_DELETE _T("Delete selection")
#define HELP_INFOS _T("Item info")
#define HELP_UP _T("Up")
#define HELP_DOWN _T("Down")
#define HELP_RANDOM _T("Random")
#define HELP_LOOP _T("Repeat all")
#define HELP_REPEAT _T("Repeat one")
// The TBBUTTON structure contains information the toolbar buttons.
static TBBUTTON tbButton2[] =
{
{0, ID_MANAGE_OPENPL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{1, ID_MANAGE_SAVEPL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP },
{2, ID_MANAGE_ADDFILE, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{3, ID_MANAGE_ADDMRL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{4, ID_SEL_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP },
{5, Infos_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP },
{6, Up_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{7, Down_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP },
{8, Random_Event, TBSTATE_ENABLED, TBSTYLE_CHECK },
{9, Loop_Event, TBSTATE_ENABLED, TBSTYLE_CHECK },
{10, Repeat_Event, TBSTATE_ENABLED, TBSTYLE_CHECK }
};
// Toolbar ToolTips
TCHAR * szToolTips2[] =
{
HELP_OPENPL,
HELP_SAVEPL,
HELP_ADDFILE,
HELP_ADDMRL,
HELP_DELETE,
HELP_INFOS,
HELP_UP,
HELP_DOWN,
HELP_RANDOM,
HELP_LOOP,
HELP_REPEAT
};
/*****************************************************************************
* Event Table.
*****************************************************************************/
/*****************************************************************************
* Constructor.
*****************************************************************************/
Playlist::Playlist( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
hListView = NULL;
i_title_sorted = 1;
i_author_sorted = 1;
b_need_update = true;
}
/***********************************************************************
FUNCTION:
CreateMenuBar
PURPOSE:
Creates a menu bar.
***********************************************************************/
static HWND CreateMenuBar( HWND hwnd, HINSTANCE hInst )
{
#ifdef UNDER_CE
SHMENUBARINFO mbi;
memset( &mbi, 0, sizeof(SHMENUBARINFO) );
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.hInstRes = hInst;
mbi.nToolBarId = IDR_MENUBAR2;
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_MANAGE, (LPARAM)&tbbi );
HMENU hmenu_file = (HMENU)tbbi.lParam;
RemoveMenu( hmenu_file, 0, MF_BYPOSITION );
SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_SORT, (LPARAM)&tbbi );
HMENU hmenu_sort = (HMENU)tbbi.lParam;
RemoveMenu( hmenu_sort, 0, MF_BYPOSITION );
SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_SEL, (LPARAM)&tbbi );
HMENU hmenu_sel = (HMENU)tbbi.lParam;
RemoveMenu( hmenu_sel, 0, MF_BYPOSITION );
#else
HMENU hmenu_file = CreatePopupMenu();
HMENU hmenu_sort = CreatePopupMenu();
HMENU hmenu_sel = CreatePopupMenu();
#endif
AppendMenu( hmenu_file, MF_STRING, ID_MANAGE_ADDFILE,
_T("&Add File...") );
AppendMenu( hmenu_file, MF_STRING, ID_MANAGE_ADDDIRECTORY,
_T("Add Directory...") );
AppendMenu( hmenu_file, MF_STRING, ID_MANAGE_ADDMRL,
_T("Add MRL...") );
AppendMenu( hmenu_file, MF_SEPARATOR, 0, 0 );
AppendMenu( hmenu_file, MF_STRING, ID_MANAGE_OPENPL,
_T("Open &Playlist") );
AppendMenu( hmenu_file, MF_STRING, ID_MANAGE_SAVEPL,
_T("Save Playlist") );
AppendMenu( hmenu_sort, MF_STRING, ID_SORT_TITLE,
_T("Sort by &title") );
AppendMenu( hmenu_sort, MF_STRING, ID_SORT_RTITLE,
_T("&Reverse sort by title") );
AppendMenu( hmenu_sort, MF_SEPARATOR, 0, 0 );
AppendMenu( hmenu_sort, MF_STRING, ID_SORT_AUTHOR,
_T("Sort by &author") );
AppendMenu( hmenu_sort, MF_STRING, ID_SORT_RAUTHOR,
_T("Reverse sort by &author") );
AppendMenu( hmenu_sort, MF_SEPARATOR, 0, 0 );
AppendMenu( hmenu_sort, MF_STRING, ID_SORT_SHUFFLE,
_T("&Shuffle Playlist") );
AppendMenu( hmenu_sel, MF_STRING, ID_SEL_ENABLE,
_T("&Enable") );
AppendMenu( hmenu_sel, MF_STRING, ID_SEL_DISABLE,
_T("&Disable") );
AppendMenu( hmenu_sel, MF_SEPARATOR, 0, 0 );
AppendMenu( hmenu_sel, MF_STRING, ID_SEL_INVERT,
_T("&Invert") );
AppendMenu( hmenu_sel, MF_STRING, ID_SEL_DELETE,
_T("D&elete") );
AppendMenu( hmenu_sel, MF_SEPARATOR, 0, 0 );
AppendMenu( hmenu_sel, MF_STRING, ID_SEL_SELECTALL,
_T("&Select All") );
#ifdef UNDER_CE
return mbi.hwndMB;
#else
HMENU hmenu = CreateMenu();
AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_file, _T("Manage") );
AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_sort, _T("Sort") );
AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_sel, _T("Selection") );
SetMenu( hwnd, hmenu );
return hwnd;
#endif
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
SHMENUBARINFO mbi;
INITCOMMONCONTROLSEX iccex;
RECT rect, rectTB;
DWORD dwStyle;
int bState;
playlist_t *p_playlist;
switch( msg )
{
case WM_INITDIALOG:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
hwndCB = CreateMenuBar( hwnd, hInst );
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_BITMAP3, tbButton2,
sizeof (tbButton2) / sizeof (TBBUTTON),
BUTTONWIDTH, BUTTONHEIGHT,
IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON) );
if( !hwndTB ) break;
// Add ToolTips to the toolbar.
SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM) NUMIMAGES,
(LPARAM)szToolTips2 );
// Reposition the toolbar.
GetClientRect( hwnd, &rect );
GetWindowRect( hwndTB, &rectTB );
MoveWindow( hwndTB, rect.left, rect.top - 2, rect.right - rect.left,
MENU_HEIGHT /*rectTB.bottom - rectTB.top */, TRUE);
// random, loop, repeat buttons states
vlc_value_t val;
p_playlist = pl_Hold( p_intf );
if( !p_playlist ) break;
var_Get( p_playlist , "random", &val );
bState = val.b_bool ? TBSTATE_CHECKED : 0;
SendMessage( hwndTB, TB_SETSTATE, Random_Event,
MAKELONG(bState | TBSTATE_ENABLED, 0) );
var_Get( p_playlist , "loop", &val );
bState = val.b_bool ? TBSTATE_CHECKED : 0;
SendMessage( hwndTB, TB_SETSTATE, Loop_Event,
MAKELONG(bState | TBSTATE_ENABLED, 0) );
var_Get( p_playlist , "repeat", &val );
bState = val.b_bool ? TBSTATE_CHECKED : 0;
SendMessage( hwndTB, TB_SETSTATE, Repeat_Event,
MAKELONG(bState | TBSTATE_ENABLED, 0) );
pl_Release( p_intf );
GetClientRect( hwnd, &rect );
hListView = CreateWindow( WC_LISTVIEW, NULL, WS_VISIBLE | WS_CHILD |
LVS_REPORT | LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL,
rect.left, rect.top + 2*(MENU_HEIGHT+1), rect.right - rect.left,
rect.bottom - ( rect.top + 2*MENU_HEIGHT) - MENU_HEIGHT,
hwnd, NULL, hInst, NULL );
ListView_SetExtendedListViewStyle( hListView, LVS_EX_FULLROWSELECT );
LVCOLUMN lv;
lv.mask = LVCF_WIDTH | LVCF_FMT | LVCF_TEXT;
lv.fmt = LVCFMT_LEFT ;
GetClientRect( hwnd, &rect );
lv.cx = 120;
lv.pszText = _T("Name");
lv.cchTextMax = 9;
ListView_InsertColumn( hListView, 0, &lv);
lv.cx = 55;
lv.pszText = _T("Author");
lv.cchTextMax = 9;
ListView_InsertColumn( hListView, 1, &lv);
lv.cx = rect.right - rect.left - 180;
lv.pszText = _T("Duration");
lv.cchTextMax = 9;
ListView_InsertColumn( hListView, 2, &lv);
SetTimer( hwnd, 1, 500 /*milliseconds*/, NULL );
break;
case WM_TIMER:
UpdatePlaylist();
break;
case WM_CLOSE:
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_COMMAND:
switch( LOWORD(wp) )
{
case IDOK:
EndDialog( hwnd, LOWORD( wp ) );
break;
case ID_MANAGE_OPENPL:
OnOpen();
b_need_update = true;
break;
case ID_MANAGE_SAVEPL:
OnSave();
break;
case ID_MANAGE_ADDFILE:
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_SIMPLE,
0, 0 );
b_need_update = true;
break;
case ID_MANAGE_ADDDIRECTORY:
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_DIRECTORY,
0, 0 );
b_need_update = true;
break;
case ID_MANAGE_ADDMRL:
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE, 0, 0 );
b_need_update = true;
break;
case ID_SEL_DELETE:
OnDeleteSelection();
b_need_update = true;
break;
case Infos_Event:
OnPopupInfo( hwnd );
b_need_update = true;
break;
case Up_Event:
OnUp();
b_need_update = true;
break;
case Down_Event:
OnDown();
b_need_update = true;
break;
case Random_Event:
OnRandom();
break;
case Loop_Event:
OnLoop();
break;
case Repeat_Event:
OnRepeat();
break;
case ID_SORT_TITLE:
OnSort( ID_SORT_TITLE );
break;
case ID_SORT_RTITLE:
OnSort( ID_SORT_RTITLE );
break;
case ID_SORT_AUTHOR:
OnSort( ID_SORT_AUTHOR );
break;
case ID_SORT_RAUTHOR:
OnSort( ID_SORT_RAUTHOR );
break;
case ID_SORT_SHUFFLE:
OnSort( ID_SORT_SHUFFLE );
break;
case ID_SEL_ENABLE:
OnEnableSelection();
break;
case ID_SEL_DISABLE:
OnDisableSelection();
break;
case ID_SEL_INVERT:
OnInvertSelection();
break;
case ID_SEL_SELECTALL:
OnSelectAll();
break;
case PopupPlay_Event:
OnPopupPlay();
b_need_update = true;
break;
case PopupDel_Event:
OnPopupDel();
b_need_update = true;
break;
case PopupEna_Event:
OnPopupEna();
b_need_update = true;
break;
case PopupInfo_Event:
OnPopupInfo( hwnd );
b_need_update = true;
break;
default:
break;
}
break;
case WM_NOTIFY:
if( ( ((LPNMHDR)lp)->hwndFrom == hListView ) &&
( ((LPNMHDR)lp)->code == NM_CUSTOMDRAW ) )
{
SetWindowLong( hwnd, DWL_MSGRESULT,
(LONG)ProcessCustomDraw(lp) );
}
else if( ( ((LPNMHDR)lp)->hwndFrom == hListView ) &&
( ((LPNMHDR)lp)->code == GN_CONTEXTMENU ) )
{
HandlePopupMenu( hwnd, ((PNMRGINFO)lp)->ptAction );
}
else if( ( ((LPNMHDR)lp)->hwndFrom == hListView ) &&
( ((LPNMHDR)lp)->code == LVN_COLUMNCLICK ) )
{
OnColSelect( ((LPNMLISTVIEW)lp)->iSubItem );
}
else if( ( ((LPNMHDR)lp)->hwndFrom == hListView ) &&
( ((LPNMHDR)lp)->code == LVN_ITEMACTIVATE ) )
{
OnActivateItem( ((LPNMLISTVIEW)lp)->iSubItem );
}
break;
default:
// the message was not processed
// indicate if the base class handled it
break;
}
return FALSE;
}
LRESULT Playlist::ProcessCustomDraw( LPARAM lParam )
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
switch( lplvcd->nmcd.dwDrawStage )
{
case CDDS_PREPAINT : //Before the paint cycle begins
//request notifications for individual listview items
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT: //Before an item is drawn
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return CDRF_DODEFAULT;
if( (int)lplvcd->nmcd.dwItemSpec == p_playlist->i_current_index )
{
lplvcd->clrText = RGB(255,0,0);
pl_Release( p_intf );
return CDRF_NEWFONT;
}
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
(int)lplvcd->nmcd.dwItemSpec );
if( !p_item )
{
PL_UNLOCK;
pl_Release( p_intf );
return CDRF_DODEFAULT;
}
if( p_item->i_flags & PLAYLIST_DBL_FLAG )
{
lplvcd->clrText = RGB(192,192,192);
PL_UNLOCK;
pl_Release( p_intf );
return CDRF_NEWFONT;
}
PL_UNLOCK;
pl_Release( p_intf );
}
return CDRF_DODEFAULT;
}
/**********************************************************************
* Handles the display of the "floating" popup
**********************************************************************/
void Playlist::HandlePopupMenu( HWND hwnd, POINT point )
{
HMENU hMenuTrackPopup;
// Create the popup menu.
hMenuTrackPopup = CreatePopupMenu();
// Append some items.
AppendMenu( hMenuTrackPopup, MF_STRING, PopupPlay_Event, _T("Play") );
AppendMenu( hMenuTrackPopup, MF_STRING, PopupDel_Event, _T("Delete") );
AppendMenu( hMenuTrackPopup, MF_STRING, PopupEna_Event,
_T("Toggle enabled") );
AppendMenu( hMenuTrackPopup, MF_STRING, PopupInfo_Event, _T("Info") );
/* Draw and track the "floating" popup */
TrackPopupMenu( hMenuTrackPopup, 0, point.x, point.y, 0, hwnd, NULL );
/* Destroy the menu since were are done with it. */
DestroyMenu( hMenuTrackPopup );
}
/**********************************************************************
* Show the playlist
**********************************************************************/
void Playlist::ShowPlaylist( bool b_show )
{
if( b_show ) Rebuild();
Show( b_show );
}
/**********************************************************************
* Update the playlist
**********************************************************************/
void Playlist::UpdatePlaylist()
{
if( b_need_update )
{
Rebuild();
b_need_update = false;
}
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
/* Update the colour of items */
PL_LOCK;
if( p_intf->p_sys->i_playing != playlist_CurrentSize( p_playlist ) )
{
// p_playlist->i_index in RED
Rebuild();
// if exists, p_intf->p_sys->i_playing in BLACK
p_intf->p_sys->i_playing = p_playlist->i_current_index;
}
PL_UNLOCK;
pl_Release( p_intf );
}
/**********************************************************************
* Rebuild the playlist
**********************************************************************/
void Playlist::Rebuild()
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
int i_focused =
ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
/* Clear the list... */
ListView_DeleteAllItems( hListView );
/* ...and rebuild it */
PL_LOCK;
playlist_item_t * p_root = p_playlist->p_local_onelevel;
playlist_item_t * p_child = NULL;
int iItem = 0;
while( ( p_child = playlist_GetNextLeaf( p_playlist, p_root, p_child, FALSE, FALSE ) ) )
{
LVITEM lv;
lv.mask = LVIF_TEXT;
lv.pszText = _T("");
lv.cchTextMax = 1;
lv.iSubItem = 0;
lv.iItem = iItem;
ListView_InsertItem( hListView, &lv );
ListView_SetItemText( hListView, lv.iItem, 0,
_FROMMB(p_child->p_input->psz_name) );
UpdateItem( p_child->i_id );
iItem++;
}
PL_UNLOCK;
if ( i_focused )
ListView_SetItemState( hListView, i_focused, LVIS_FOCUSED |
LVIS_SELECTED, LVIS_STATEIMAGEMASK )
else
ListView_SetItemState( hListView, i_focused, LVIS_FOCUSED,
LVIS_STATEIMAGEMASK );
pl_Release( p_intf );
}
/**********************************************************************
* Update one playlist item
**********************************************************************/
void Playlist::UpdateItem( int i )
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i );
if( !p_item )
{
PL_UNLOCK;
pl_Release( p_intf );
return;
}
ListView_SetItemText( hListView, i, 0, _FROMMB(p_item->p_input->psz_name) );
ListView_SetItemText( hListView, i, 1,
_FROMMB( input_item_GetInfo( p_item->p_input,
_("General") , _("Author") ) ) );
char psz_duration[MSTRTIME_MAX_SIZE];
mtime_t dur = input_item_GetDuration( p_item->p_input );
PL_UNLOCK;
if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
ListView_SetItemText( hListView, i, 2, _FROMMB(psz_duration) );
pl_Release( p_intf );
}
/**********************************************************************
* Private functions
**********************************************************************/
void Playlist::DeleteItem( input_item_t *item )
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
playlist_DeleteFromInput( p_playlist, item, FALSE );
ListView_DeleteItem( hListView, item );
pl_Release( p_intf );
}
/**********************************************************************
* I/O functions
**********************************************************************/
static void OnOpenCB( intf_dialog_args_t *p_arg )
{
intf_thread_t *p_intf = (intf_thread_t *)p_arg->p_arg;
if( p_arg->i_results && p_arg->psz_results[0] )
{
playlist_t * p_playlist = pl_Hold( p_intf );
if( p_playlist )
{
playlist_Import( p_playlist, p_arg->psz_results[0] );
pl_Release( p_intf );
}
}
}
void Playlist::OnOpen()
{
char *psz_filters ="All playlists|*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u";
intf_dialog_args_t *p_arg =
(intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
memset( p_arg, 0, sizeof(intf_dialog_args_t) );
p_arg->psz_title = strdup( "Open playlist" );
p_arg->psz_extensions = strdup( psz_filters );
p_arg->p_arg = p_intf;
p_arg->pf_callback = OnOpenCB;
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
}
static void OnSaveCB( intf_dialog_args_t *p_arg )
{
intf_thread_t *p_intf = (intf_thread_t *)p_arg->p_arg;
if( p_arg->i_results && p_arg->psz_results[0] )
{
playlist_t * p_playlist = pl_Hold( p_intf );
if( p_playlist )
{
char *psz_export;
char *psz_ext = strrchr( p_arg->psz_results[0], '.' );
if( psz_ext && !strcmp( psz_ext, ".pls") )
psz_export = "export-pls";
else psz_export = "export-m3u";
playlist_Export( p_playlist, p_arg->psz_results[0], p_playlist->p_local_onelevel, psz_export );
pl_Release( p_intf );
}
}
}
void Playlist::OnSave()
{
char *psz_filters ="M3U file|*.m3u|PLS file|*.pls";
intf_dialog_args_t *p_arg =
(intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
memset( p_arg, 0, sizeof(intf_dialog_args_t) );
p_arg->psz_title = strdup( "Save playlist" );
p_arg->psz_extensions = strdup( psz_filters );
p_arg->b_save = true;
p_arg->p_arg = p_intf;
p_arg->pf_callback = OnSaveCB;
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC,
0, p_arg );
}
/**********************************************************************
* Selection functions
**********************************************************************/
void Playlist::OnDeleteSelection()
{
/* Delete from the end to the beginning, to avoid a shift of indices */
for( long item = ((int) ListView_GetItemCount( hListView ) - 1);
item >= 0; item-- )
{
if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) )
{
DeleteItem( item );
}
}
}
void Playlist::OnInvertSelection()
{
UINT iState;
for( long item = 0; item < ListView_GetItemCount( hListView ); item++ )
{
iState = ListView_GetItemState( hListView, item, LVIS_STATEIMAGEMASK );
ListView_SetItemState( hListView, item, iState ^ LVIS_SELECTED,
LVIS_STATEIMAGEMASK );
}
}
void Playlist::OnEnableSelection()
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
for( long item = ListView_GetItemCount( hListView ) - 1;
item >= 0; item-- )
{
if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) )
{
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item );
p_item->i_flags ^= PLAYLIST_DBL_FLAG;
PL_UNLOCK;
UpdateItem( item );
}
}
pl_Release( p_intf );
}
void Playlist::OnDisableSelection()
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
for( long item = ListView_GetItemCount( hListView ) - 1;
item >= 0; item-- )
{
if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) )
{
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item );
p_item->i_flags |= PLAYLIST_DBL_FLAG;
PL_UNLOCK;
UpdateItem( item );
}
}
pl_Release( p_intf );
}
void Playlist::OnSelectAll()
{
for( long item = 0; item < ListView_GetItemCount( hListView ); item++ )
{
ListView_SetItemState( hListView, item, LVIS_FOCUSED | LVIS_SELECTED,
LVIS_STATEIMAGEMASK );
}
}
void Playlist::OnActivateItem( int i_item )
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
playlist_Skip( p_playlist, i_item - p_playlist->i_current_index );
pl_Release( p_intf );
}
void Playlist::ShowInfos( HWND hwnd, int i_item )
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_item );
if( p_item )
{
ItemInfoDialog *iteminfo_dialog =
new ItemInfoDialog( p_intf, this, hInst, p_item );
PL_UNLOCK;
CreateDialogBox( hwnd, iteminfo_dialog );
UpdateItem( i_item );
delete iteminfo_dialog;
}
pl_Release( p_intf );
}
/********************************************************************
* Move functions
********************************************************************/
void Playlist::OnUp()
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
/* We use the first selected item, so find it */
long i_item =
ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
if( i_item > 0 && i_item < playlist_CurrentSize( p_playlist ) )
{
playlist_Prev( p_playlist );
if( i_item > 1 )
{
ListView_SetItemState( hListView, i_item - 1, LVIS_FOCUSED,
LVIS_STATEIMAGEMASK );
}
else
{
ListView_SetItemState( hListView, 0, LVIS_FOCUSED,
LVIS_STATEIMAGEMASK );
}
}
pl_Release( p_intf );
return;
}
void Playlist::OnDown()
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
/* We use the first selected item, so find it */
long i_item =
ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
if( i_item >= 0 && i_item < playlist_CurrentSize( p_playlist ) - 1 )
{
playlist_Next( p_playlist );
ListView_SetItemState( hListView, i_item + 1, LVIS_FOCUSED,
LVIS_STATEIMAGEMASK );
}
pl_Release( p_intf );
return;
}
/**********************************************************************
* Playlist mode functions
**********************************************************************/
void Playlist::OnRandom()
{
vlc_value_t val;
int bState = SendMessage( hwndTB, TB_GETSTATE, Random_Event, 0 );
val.b_bool = (bState & TBSTATE_CHECKED) ? true : false;
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
var_Set( p_playlist , "random", val );
pl_Release( p_intf );
}
void Playlist::OnLoop ()
{
vlc_value_t val;
int bState = SendMessage( hwndTB, TB_GETSTATE, Loop_Event, 0 );
val.b_bool = (bState & TBSTATE_CHECKED) ? true : false;
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
var_Set( p_playlist , "loop", val );
pl_Release( p_intf );
}
void Playlist::OnRepeat ()
{
vlc_value_t val;
int bState = SendMessage( hwndTB, TB_GETSTATE, Repeat_Event, 0 );
val.b_bool = (bState & TBSTATE_CHECKED) ? true : false;
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
var_Set( p_playlist , "repeat", val );
pl_Release( p_intf );
}
/********************************************************************
* Sorting functions
********************************************************************/
void Playlist::OnSort( UINT event )
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
switch( event )
{
case ID_SORT_TITLE:
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_TITLE, ORDER_NORMAL);
break;
case ID_SORT_RTITLE:
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_TITLE, ORDER_REVERSE );
break;
case ID_SORT_AUTHOR:
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_ARTIST, ORDER_NORMAL);
break;
case ID_SORT_RAUTHOR:
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_ARTIST, ORDER_REVERSE);
break;
case ID_SORT_SHUFFLE:
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_RANDOM, ORDER_NORMAL);
break;
}
pl_Release( p_intf );
b_need_update = true;
return;
}
void Playlist::OnColSelect( int iSubItem )
{
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
switch( iSubItem )
{
case 0:
if( i_title_sorted != 1 )
{
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_TITLE, ORDER_NORMAL);
i_title_sorted = 1;
}
else
{
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_TITLE, ORDER_REVERSE );
i_title_sorted = -1;
}
break;
case 1:
if( i_author_sorted != 1 )
{
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_ARTIST, ORDER_NORMAL);
i_author_sorted = 1;
}
else
{
playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
SORT_ARTIST, ORDER_REVERSE);
i_author_sorted = -1;
}
break;
default:
break;
}
pl_Release( p_intf );
b_need_update = true;
return;
}
/*****************************************************************************
* Popup management functions
*****************************************************************************/
void Playlist::OnPopupPlay()
{
int i_popup_item =
ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
if( i_popup_item != -1 )
{
playlist_Skip( p_playlist, i_popup_item - p_playlist->i_current_index );
}
pl_Release( p_intf );
}
void Playlist::OnPopupDel()
{
int i_popup_item =
ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
DeleteItem( i_popup_item );
}
void Playlist::OnPopupEna()
{
int i_popup_item =
ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return;
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_popup_item );
if( !(p_playlist->items.p_elems[i_popup_item]->i_flags & PLAYLIST_DBL_FLAG) )
//playlist_IsEnabled( p_playlist, i_popup_item ) )
{
p_item->i_flags |= PLAYLIST_DBL_FLAG;
}
else
{
p_item->i_flags ^= PLAYLIST_DBL_FLAG;
}
PL_UNLOCK;
pl_Release( p_intf );
UpdateItem( i_popup_item );
}
void Playlist::OnPopupInfo( HWND hwnd )
{
int i_popup_item =
ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
ShowInfos( hwnd, i_popup_item );
}
/*****************************************************************************
* preferences.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include "wince.h"
#include <winuser.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#include <vlc_config_cat.h>
#include "preferences_widgets.h"
#define TYPE_CATEGORY 0
#define TYPE_CATSUBCAT 1 /* Category with embedded subcategory */
#define TYPE_SUBCATEGORY 2
#define TYPE_MODULE 3
/*****************************************************************************
* Event Table.
*****************************************************************************/
/* IDs for the controls and the menu commands */
enum
{
Notebook_Event,
MRL_Event,
ResetAll_Event,
Advanced_Event
};
/*****************************************************************************
* Classes declarations.
*****************************************************************************/
class ConfigTreeData;
class PrefsTreeCtrl
{
public:
PrefsTreeCtrl() { }
PrefsTreeCtrl( intf_thread_t *_p_intf, PrefsDialog *p_prefs_dialog,
HWND hwnd, HINSTANCE _hInst );
virtual ~PrefsTreeCtrl();
void ApplyChanges();
/*void CleanChanges();*/
void OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent, HINSTANCE hInst );
ConfigTreeData *FindModuleConfig( ConfigTreeData *config_data );
HWND hwndTV;
private:
intf_thread_t *p_intf;
PrefsDialog *p_prefs_dialog;
bool b_advanced;
HTREEITEM general_item;
HTREEITEM plugins_item;
};
class PrefsPanel
{
public:
PrefsPanel() { }
PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
PrefsDialog *, module_t *p_module, char *, char *, ConfigTreeData * );
virtual ~PrefsPanel() {}
void Hide();
void Show();
HWND config_window;
int oldvalue;
int maxvalue;
void ApplyChanges();
private:
intf_thread_t *p_intf;
PrefsDialog *p_prefs_dialog;
bool b_advanced;
HWND label;
vector<ConfigControl *> config_array;
};
class ConfigTreeData
{
public:
ConfigTreeData() { b_submodule = 0; panel = NULL; psz_name = NULL;
psz_help = NULL; }
virtual ~ConfigTreeData() { delete panel;
free( psz_name );
free( psz_help ); }
bool b_submodule;
PrefsPanel *panel;
module_t *p_module;
int i_object_id;
int i_subcat_id;
int i_type;
char *psz_name;
char *psz_help;
};
/*****************************************************************************
* Constructor.
*****************************************************************************/
PrefsDialog::PrefsDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
prefs_tree = NULL;
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
SHMENUBARINFO mbi;
RECT rcClient;
switch( msg )
{
case WM_INITDIALOG:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
//Create the menubar
memset( &mbi, 0, sizeof (SHMENUBARINFO) );
mbi.cbSize = sizeof (SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.dwFlags = SHCMBF_EMPTYBAR;
mbi.hInstRes = hInst;
if( !SHCreateMenuBar(&mbi) )
{
MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
//return -1;
}
hwndCB = mbi.hwndMB;
// Get the client area rect to put the panels in
GetClientRect(hwnd, &rcClient);
/* Create the buttons */
advanced_checkbox =
CreateWindow( _T("BUTTON"), _T("Advanced options"),
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
5, 10, 15, 15, hwnd, NULL, hInst, NULL );
SendMessage( advanced_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
advanced_label = CreateWindow( _T("STATIC"), _T("Advanced options"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5 + 15 + 5, 10, 110, 15,
hwnd, NULL, hInst, NULL);
if( config_GetInt( p_intf, "advanced" ) )
{
SendMessage( advanced_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
/*dummy_event.SetInt(TRUE);
OnAdvanced( dummy_event );*/
}
reset_button = CreateWindow( _T("BUTTON"), _T("Reset All"),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
rcClient.right - 5 - 80, 10 - 3, 80, 15 + 6,
hwnd, NULL, hInst, NULL );
/* Create the preferences tree control */
prefs_tree = new PrefsTreeCtrl( p_intf, this, hwnd, hInst );
UpdateWindow( hwnd );
break;
case WM_CLOSE:
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
break;
case WM_COMMAND:
if( LOWORD(wp) == IDOK )
{
OnOk();
EndDialog( hwnd, LOWORD( wp ) );
}
break;
case WM_NOTIFY:
if( lp && prefs_tree &&
((LPNMHDR)lp)->hwndFrom == prefs_tree->hwndTV &&
((LPNMHDR)lp)->code == TVN_SELCHANGED )
{
prefs_tree->OnSelectTreeItem( (NM_TREEVIEW FAR *)(LPNMHDR)lp,
hwnd, hInst );
}
break;
case WM_VSCROLL:
{
TVITEM tvi = {0};
tvi.mask = TVIF_PARAM;
tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );
if( !tvi.hItem ) break;
if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;
ConfigTreeData *config_data =
prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );
if( config_data && hwnd == config_data->panel->config_window )
{
int dy;
RECT rc;
GetWindowRect( hwnd, &rc);
int newvalue = config_data->panel->oldvalue;
switch ( GET_WM_VSCROLL_CODE(wp,lp) )
{
case SB_BOTTOM : newvalue = 0; break;
case SB_TOP : newvalue = config_data->panel->maxvalue; break;
case SB_LINEDOWN : newvalue += 10; break;
case SB_PAGEDOWN : newvalue += rc.bottom - rc.top - 25; break; // wrong! one page is notebook actual length
case SB_LINEUP : newvalue -= 10; break;
case SB_PAGEUP : newvalue -= rc.bottom - rc.top - 25; break;
case SB_THUMBPOSITION:
case SB_THUMBTRACK : newvalue = GET_WM_VSCROLL_POS(wp,lp); break;
}
newvalue = max(0,min(config_data->panel->maxvalue,newvalue));
SetScrollPos( hwnd,SB_VERT,newvalue,TRUE);//SB_CTL si hwnd=hwndScrollBar, SB_VERT si window
dy = config_data->panel->oldvalue - newvalue;
ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN );
UpdateWindow ( hwnd);
config_data->panel->oldvalue = newvalue;
}
break;
}
default:
break;
}
return FALSE;
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
/*****************************************************************************
* Events methods.
*****************************************************************************/
void PrefsDialog::OnOk( void )
{
prefs_tree->ApplyChanges();
config_SaveConfigFile( p_intf, NULL );
}
/*****************************************************************************
* PrefsTreeCtrl class definition.
*****************************************************************************/
PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
PrefsDialog *_p_prefs_dialog, HWND hwnd,
HINSTANCE hInst )
{
module_t *p_module = NULL;
module_config_t *p_item;
INITCOMMONCONTROLSEX iccex;
RECT rcClient;
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};
HTREEITEM hPrev;
size_t i_capability_count = 0;
size_t i_child_index;
HTREEITEM category_item, subcategory_item;
/* Initializations */
p_intf = _p_intf;
p_prefs_dialog = _p_prefs_dialog;
b_advanced = false;
/* Create a tree view */
// Initialize the INITCOMMONCONTROLSEX structure.
iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
iccex.dwICC = ICC_TREEVIEW_CLASSES;
// Registers Statusbar control classes from the common control dll
InitCommonControlsEx( &iccex );
// Get the client area rect to put the tv in
GetClientRect(hwnd, &rcClient);
// Create the tree-view control.
hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
TVS_LINESATROOT | TVS_HASBUTTONS,
5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
hwnd, NULL, hInst, NULL );
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
/*
* Build a tree of the main options
*/
ConfigTreeData *config_data = new ConfigTreeData;
config_data->i_object_id = TYPE_CATEGORY;
config_data->psz_help = strdup(MAIN_HELP);
config_data->psz_name = strdup( "General" );
tvi.pszText = _T("General settings");
tvi.cchTextMax = lstrlen(_T("General settings"));
tvi.lParam = (long)config_data;
tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
tvins.hParent = TVI_ROOT;
// Add the item to the tree-view control.
hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
general_item = hPrev;
/* Build the categories list */
p_module = module_get_main();
unsigned int confsize;
const char *psz_help;
module_config_t * p_config;
/* Enumerate config categories and store a reference so we can
* generate their config panel when it is asked by the user. */
p_config = module_config_get (p_module, &confsize);
for( size_t i = 0; i < confsize; i++ )
{
/* Work on a new item */
module_config_t *p_item = p_config + i;
switch( p_item->i_type )
{
case CONFIG_CATEGORY:
if( p_item->value.i == -1 ) break; // Don't display it
config_data = new ConfigTreeData;
config_data->psz_name = strdup( config_CategoryNameGet(p_item->value.i ) );
psz_help = config_CategoryHelpGet( p_item->value.i );
if( psz_help )
{
config_data->psz_help = strdup( psz_help );
}
else
{
config_data->psz_help = NULL;
}
config_data->i_type = TYPE_CATEGORY;
config_data->i_object_id = p_item->value.i;
config_data->p_module = p_module;
tvi.pszText = _FROMMB(config_data->psz_name);
tvi.cchTextMax = _tcslen(tvi.pszText);
/* Add the category to the tree */
tvi.lParam = (long)config_data;
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
tvins.hParent = general_item; //level 3
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
break;
case CONFIG_SUBCATEGORY:
if( p_item->value.i == -1 ) break; // Don't display it
/* Special case: move the "general" subcategories to their parent category */
if(config_data && p_item->value.i == SUBCAT_VIDEO_GENERAL ||
p_item->value.i == SUBCAT_ADVANCED_MISC ||
p_item->value.i == SUBCAT_INPUT_GENERAL ||
p_item->value.i == SUBCAT_INTERFACE_GENERAL ||
p_item->value.i == SUBCAT_SOUT_GENERAL||
p_item->value.i == SUBCAT_PLAYLIST_GENERAL||
p_item->value.i == SUBCAT_AUDIO_GENERAL )
{
config_data->i_type = TYPE_CATSUBCAT;
config_data->i_subcat_id = p_item->value.i;
free( config_data->psz_name );
config_data->psz_name = strdup( config_CategoryNameGet( p_item->value.i ) );
free( config_data->psz_help );
const char *psz_help = config_CategoryHelpGet( p_item->value.i );
if( psz_help )
{
config_data->psz_help = strdup( psz_help );
}
else
{
config_data->psz_help = NULL;
}
continue;
}
config_data = new ConfigTreeData;
config_data->psz_name = strdup( config_CategoryNameGet( p_item->value.i ) );
psz_help = config_CategoryHelpGet( p_item->value.i );
if( psz_help )
{
config_data->psz_help = strdup( psz_help );
}
else
{
config_data->psz_help = NULL;
}
config_data->i_type = TYPE_SUBCATEGORY;
config_data->i_object_id = p_item->value.i;
tvi.pszText = _FROMMB(config_data->psz_name);
tvi.cchTextMax = _tcslen(tvi.pszText);
tvi.lParam = (long)config_data;
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
tvins.hParent = hPrev;
// Add the item to the tree-view control.
TreeView_InsertItem( hwndTV, &tvins );
break;
}
}
TreeView_SortChildren( hwndTV, general_item, 0 );
module_config_free( p_config );
/* List the plugins */
module_t **p_list = module_list_get( NULL );
/*
* Build a tree of all the plugins
*/
for( size_t i_index = 0; p_list[i_index]; i_index++ )
{
/* Take every module */
p_module = p_list[i_index];
/* Exclude the main module */
if( module_is_main( p_module ) )
continue;
/* Exclude empty plugins (submodules don't have config options, they
* are stored in the parent module) */
unsigned int confsize;
i_child_index = 0;
int i_category = 0, i_subcategory = 0, i_options = 0;
bool b_options = false;
p_config = module_config_get( (module_t *) p_module,&confsize);
/* Loop through the configurations items */
for( size_t i = 0; i < confsize; i++ )
{
module_config_t *p_item = p_config + i;
if( p_item->i_type == CONFIG_CATEGORY )
i_category = p_item->value.i;
else if( p_item->i_type == CONFIG_SUBCATEGORY )
i_subcategory = p_item->value.i;
if( p_item->i_type & CONFIG_ITEM )
b_options = true;
if( b_options && i_category && i_subcategory )
break;
}
module_config_free (p_config);
/* Dummy item, please proceed */
if( !b_options || i_category == 0 || i_subcategory == 0 ) continue;
category_item = TreeView_GetChild( hwndTV, general_item );
while(category_item != 0)
{
TVITEM category_tvi = {0};
category_tvi.mask = TVIF_PARAM;
category_tvi.lParam = NULL;
category_tvi.hItem = category_item;
TreeView_GetItem( hwndTV, &category_tvi );
ConfigTreeData * data = (ConfigTreeData *)category_tvi.lParam;
if( data->i_object_id == i_category )
{
subcategory_item = TreeView_GetChild( hwndTV, category_item );
while(subcategory_item != 0)
{
TVITEM subcategory_tvi = {0};
subcategory_tvi.mask = TVIF_PARAM;
subcategory_tvi.lParam = NULL;
subcategory_tvi.hItem = subcategory_item;
TreeView_GetItem( hwndTV, &subcategory_tvi );
ConfigTreeData * subdata = (ConfigTreeData *)subcategory_tvi.lParam;
if( subdata->i_object_id == i_subcategory )
{
config_data = new ConfigTreeData;
config_data->psz_name = strdup( module_get_object( p_module ) );
config_data->psz_help = NULL;
config_data->i_type = TYPE_MODULE;
config_data->i_object_id = p_item->value.i;
config_data->p_module = p_module;
tvi.pszText = _FROMMB(module_get_name( p_module, false ));
tvi.cchTextMax = _tcslen(tvi.pszText);
tvi.lParam = (long)config_data;
tvins.item = tvi;
tvins.hInsertAfter = subcategory_item;
tvins.hParent = subcategory_item;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
break;
}
subcategory_item = TreeView_GetNextSibling( hwndTV, subcategory_item );
}
break;
}
category_item = TreeView_GetNextSibling( hwndTV, category_item );
}
}
/* Sort all this mess */
TreeView_SortChildren( hwndTV, general_item, 0 );
category_item = TreeView_GetChild( hwndTV, general_item );
while( category_item != 0 )
{
TreeView_SortChildren( hwndTV, category_item, 0 );
category_item = TreeView_GetNextSibling( hwndTV, category_item );
}
/* Clean-up everything */
module_list_free( p_list );
TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
}
PrefsTreeCtrl::~PrefsTreeCtrl()
{
}
void PrefsTreeCtrl::ApplyChanges()
{
ConfigTreeData *config_data;
/* Apply changes to the main module */
HTREEITEM item = TreeView_GetChild( hwndTV, general_item );
while( item != 0 )
{
TVITEM tvi = {0};
tvi.mask = TVIF_PARAM;
tvi.hItem = item;
TreeView_GetItem( hwndTV, &tvi );
config_data = (ConfigTreeData *)tvi.lParam;
if( config_data && config_data->panel )
{
config_data->panel->ApplyChanges();
}
item = TreeView_GetNextSibling( hwndTV, item );
}
/* Apply changes to the plugins */
item = TreeView_GetChild( hwndTV, general_item );
while( item != 0 )
{
HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
while( item2 != 0 )
{
HTREEITEM item3 = TreeView_GetChild( hwndTV, item2 );
while(item3 !=0)
{
TVITEM tvi = {0};
tvi.mask = TVIF_PARAM;
tvi.hItem = item3;
TreeView_GetItem( hwndTV, &tvi );
config_data = (ConfigTreeData *)tvi.lParam;
if( config_data && config_data->panel )
{
config_data->panel->ApplyChanges();
}
item3 = TreeView_GetNextSibling( hwndTV, item3 );
}
item2 = TreeView_GetNextSibling( hwndTV, item2 );
}
item = TreeView_GetNextSibling( hwndTV, item );
}
}
ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
{
if( !config_data || !config_data->p_module )
{
return config_data;
}
ConfigTreeData *config_new;
HTREEITEM item = TreeView_GetChild( hwndTV, general_item );
while( item != 0 )
{
HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
while( item2 != 0 )
{
HTREEITEM item3 = TreeView_GetChild( hwndTV, item2 );
while( item3 != 0 )
{
TVITEM tvi = {0};
tvi.mask = TVIF_PARAM;
tvi.hItem = item3;
TreeView_GetItem( hwndTV, &tvi );
config_new = (ConfigTreeData *)tvi.lParam;
if( config_new && config_new->p_module == config_data->p_module )
{
return config_new;
}
item3 = TreeView_GetNextSibling( hwndTV, item3 );
}
item2 = TreeView_GetNextSibling( hwndTV, item2 );
}
item = TreeView_GetNextSibling( hwndTV, item );
}
/* Found nothing */
return NULL;
}
void PrefsTreeCtrl::OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent,
HINSTANCE hInst )
{
ConfigTreeData *config_data = NULL;
if( pnmtv->itemOld.hItem )
config_data = FindModuleConfig( (ConfigTreeData *)pnmtv->itemOld.lParam );
if( config_data && config_data->panel )
{
config_data->panel->Hide();
}
/* Don't use event.GetItem() because we also send fake events */
TVITEM tvi = {0};
tvi.mask = TVIF_PARAM;
tvi.hItem = TreeView_GetSelection( hwndTV );
TreeView_GetItem( hwndTV, &tvi );
config_data = FindModuleConfig( (ConfigTreeData *)tvi.lParam );
if( config_data )
{
if( !config_data->panel )
{
/* The panel hasn't been created yet. Let's do it. */
config_data->panel =
new PrefsPanel( parent, hInst, p_intf, p_prefs_dialog,
config_data->p_module,
config_data->psz_name,
config_data->psz_help, config_data );
}
else
{
config_data->panel->Show();
}
}
}
/*****************************************************************************
* PrefsPanel class definition.
*****************************************************************************/
PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
PrefsDialog *_p_prefs_dialog,
module_t *p_module, char *psz_name, char *psz_help, ConfigTreeData * config_data )
{
module_config_t *p_item, *p_config, *p_end;
/* Initializations */
p_intf = _p_intf;
p_prefs_dialog = _p_prefs_dialog;
module_t **p_list;
b_advanced = true;
if( config_data->i_type == TYPE_CATEGORY )
{
label = CreateWindow( _T("STATIC"), _FROMMB(psz_name),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10 + (15 + 10), 200, 15,
parent, NULL, hInst, NULL );
config_window = NULL;
}
else
{
/* Get a pointer to the module */
if( config_data->i_type == TYPE_MODULE )
{
p_module = config_data->p_module;
}
else
{
/* List the plugins */
size_t i_index;
bool b_found = false;
p_list = module_list_get( NULL );
for( i_index = 0; p_list[i_index]; i_index++ )
{
p_module = p_list[i_index];
if( !strcmp( module_get_object(p_module), "main" ) )
{
b_found = true;
break;
}
}
if( !p_module && !b_found )
{
msg_Warn( p_intf, "unable to create preferences "
"(main module not found)" );
return;
}
}
/* Enumerate config options and add corresponding config boxes
* (submodules don't have config options, they are stored in the
* parent module) */
unsigned confsize;
p_config = module_config_get( (module_t *) p_module,&confsize);
p_item = p_config;
p_end = p_config + confsize;
/* Find the category if it has been specified */
if( config_data->i_type == TYPE_SUBCATEGORY ||
config_data->i_type == TYPE_CATSUBCAT )
{
for( ; p_item && p_item < p_end ; p_item++ )
{
if( p_item->i_type == CONFIG_SUBCATEGORY &&
( config_data->i_type == TYPE_SUBCATEGORY &&
p_item->value.i == config_data->i_object_id ) ||
( config_data->i_type == TYPE_CATSUBCAT &&
p_item->value.i == config_data->i_subcat_id ) )
{
break;
}
}
}
/* Add a head title to the panel */
const char *psz_head;
if( config_data->i_type == TYPE_SUBCATEGORY ||
config_data->i_type == TYPE_CATSUBCAT )
{
psz_head = config_data->psz_name;
p_item++;
}
else
{
psz_head = module_GetLongName(p_module);
}
label = CreateWindow( _T("STATIC"), _FROMMB(psz_head ?
psz_head : _("Unknown")),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10 + (15 + 10), 250, 15,
parent, NULL, hInst, NULL );
WNDCLASS wc;
memset( &wc, 0, sizeof(wc) );
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) _p_prefs_dialog->BaseWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = _T("PrefsPanelClass");
RegisterClass(&wc);
RECT rc;
GetWindowRect( parent, &rc);
config_window = CreateWindow( _T("PrefsPanelClass"),
_T("config_window"),
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER,
5, 10 + 2*(15 + 10), rc.right - 5 - 7, 105,
parent, NULL, hInst, (void *) _p_prefs_dialog );
int y_pos = 5;
for( ; p_item && p_item < p_end ; p_item++ )
{
/* If a category has been specified, check we finished the job */
if( ( ( config_data->i_type == TYPE_SUBCATEGORY &&
p_item->value.i != config_data->i_object_id ) ||
( config_data->i_type == TYPE_CATSUBCAT &&
p_item->value.i != config_data->i_subcat_id ) ) &&
(p_item->i_type == CONFIG_CATEGORY ||
p_item->i_type == CONFIG_SUBCATEGORY ) )
break;
ConfigControl *control = NULL;
control = CreateConfigControl( VLC_OBJECT(p_intf),
p_item, config_window,
hInst, &y_pos );
/* Don't add items that were not recognized */
if( control == NULL ) continue;
/* Add the config data to our array so we can keep a trace of it */
config_array.push_back( control );
}
GetWindowRect( config_window, &rc);
maxvalue = y_pos - (rc.bottom - rc.top) + 5;
oldvalue = 0;
SetScrollRange( config_window, SB_VERT, 0, maxvalue, TRUE );
}
}
void PrefsPanel::Hide()
{
ShowWindow( label, SW_HIDE );
if( config_window ) ShowWindow( config_window, SW_HIDE );
}
void PrefsPanel::Show()
{
ShowWindow( label, SW_SHOW );
if( config_window ) ShowWindow( config_window, SW_SHOW );
}
void PrefsPanel::ApplyChanges()
{
vlc_value_t val;
for( size_t i = 0; i < config_array.size(); i++ )
{
ConfigControl *control = config_array[i];
switch( control->GetType() )
{
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_MODULE:
config_PutPsz( p_intf, control->GetName(),
control->GetPszValue() );
break;
case CONFIG_ITEM_KEY:
/* So you don't need to restart to have the changes take effect */
val.i_int = control->GetIntValue();
var_Set( p_intf->p_libvlc, control->GetName(), val );
case CONFIG_ITEM_INTEGER:
case CONFIG_ITEM_BOOL:
config_PutInt( p_intf, control->GetName(),
control->GetIntValue() );
break;
case CONFIG_ITEM_FLOAT:
config_PutFloat( p_intf, control->GetName(),
control->GetFloatValue() );
break;
}
}
}
/*****************************************************************************
* preferences_widgets.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include "wince.h"
#include <windows.h>
#include <windowsx.h>
#include <winuser.h>
#include <commctrl.h>
#include "preferences_widgets.h"
/*****************************************************************************
* CreateConfigControl wrapper
*****************************************************************************/
ConfigControl *CreateConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int *py_pos )
{
ConfigControl *p_control = NULL;
switch( p_item->i_type )
{
case CONFIG_ITEM_MODULE:
p_control = new ModuleConfigControl( p_this, p_item, parent, hInst, py_pos );
break;
case CONFIG_ITEM_STRING:
if( !p_item->i_list )
{
p_control = new StringConfigControl( p_this, p_item, parent, hInst, py_pos );
}
/*else
{
p_control = new StringListConfigControl( p_this, p_item, parent, hInst, py_pos );
}*/
break;
/*
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
p_control = new FileConfigControl( p_this, p_item, parent, hInst, py_pos );
break;
case CONFIG_ITEM_INTEGER:
if( p_item->i_list )
{
p_control = new IntegerListConfigControl( p_this, p_item, parent, hInst, py_pos );
}
else if( p_item->i_min != 0 || p_item->i_max != 0 )
{
p_control = new RangedIntConfigControl( p_this, p_item, parent, hInst, py_pos );
}
else
{
p_control = new IntegerConfigControl( p_this, p_item, parent, hInst, py_pos );
}
break;
*/
case CONFIG_ITEM_KEY:
p_control = new KeyConfigControl( p_this, p_item, parent, hInst, py_pos );
break;
case CONFIG_ITEM_FLOAT:
p_control = new FloatConfigControl( p_this, p_item, parent, hInst, py_pos );
break;
case CONFIG_ITEM_BOOL:
p_control = new BoolConfigControl( p_this, p_item, parent, hInst, py_pos );
break;
default:
break;
}
return p_control;
}
/*****************************************************************************
* ConfigControl implementation
*****************************************************************************/
ConfigControl::ConfigControl( vlc_object_t *_p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst )
: p_this( _p_this ), pf_update_callback( NULL ), p_update_data( NULL ),
parent( parent ), name( p_item->psz_name ), i_type( p_item->i_type ),
b_advanced( p_item->b_advanced )
{
/*sizer = new wxBoxSizer( wxHORIZONTAL );*/
}
ConfigControl::~ConfigControl()
{
}
/*wxSizer *ConfigControl::Sizer()
{
return sizer;
}*/
char *ConfigControl::GetName()
{
return name;
}
int ConfigControl::GetType()
{
return i_type;
}
bool ConfigControl::IsAdvanced()
{
return b_advanced;
}
void ConfigControl::SetUpdateCallback( void (*p_callback)( void * ),
void *p_data )
{
pf_update_callback = p_callback;
p_update_data = p_data;
}
void ConfigControl::OnUpdate( UINT event )
{
if( pf_update_callback )
{
pf_update_callback( p_update_data );
}
}
/*****************************************************************************
* KeyConfigControl implementation
*****************************************************************************/
string *KeyConfigControl::m_keysList = NULL;
KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
// Init the keys decriptions array
if( m_keysList == NULL )
{
m_keysList = new string[vlc_num_keys];
for( size_t i = 0; i < vlc_num_keys; ++i )
{
m_keysList[i] = vlc_keys[i].psz_key_string;
}
}
label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
alt = CreateWindow( _T("BUTTON"), _T("Alt"),
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
20, *py_pos, 15, 15, parent, NULL, hInst, NULL );
Button_SetCheck( alt, p_item->i_type & KEY_MODIFIER_ALT ? BST_CHECKED :
BST_UNCHECKED );
alt_label = CreateWindow( _T("STATIC"), _T("Alt"),
WS_CHILD | WS_VISIBLE | SS_LEFT, 20 + 15 + 5, *py_pos, 30, 15,
parent, NULL, hInst, NULL );
ctrl = CreateWindow( _T("BUTTON"), _T("Ctrl"),
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
20 + 15 + 5 + 30 + 5, *py_pos, 15, 15,
parent, NULL, hInst, NULL );
Button_SetCheck( ctrl, p_item->i_type & KEY_MODIFIER_CTRL ? BST_CHECKED :
BST_UNCHECKED );
ctrl_label = CreateWindow( _T("STATIC"), _T("Ctrl"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
20 + 15 + 5 + 30 + 5 + 15 + 5, *py_pos, 30, 15,
parent, NULL, hInst, NULL );
shift = CreateWindow( _T("BUTTON"), _T("Shift"),
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
20 + 15 + 5 + 2*(30 + 5) + 15 + 5, *py_pos, 15, 15,
parent, NULL, hInst, NULL );
Button_SetCheck( shift, p_item->i_type & KEY_MODIFIER_SHIFT ?
BST_CHECKED : BST_UNCHECKED );
shift_label = CreateWindow( _T("STATIC"), _T("Shift"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
20 + 15 + 5 + 2*(30 + 5) + 2*(15 + 5), *py_pos, 30, 15,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
combo = CreateWindow( _T("COMBOBOX"), _T(""),
WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL, 20, *py_pos, 130, 5*15 + 6,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
for( size_t i = 0; i < vlc_num_keys ; ++i )
{
ComboBox_AddString( combo, _FROMMB(m_keysList[i].c_str()) );
ComboBox_SetItemData( combo, i, (void*)vlc_keys[i].i_key_code );
if( (unsigned int)vlc_keys[i].i_key_code ==
( ((unsigned int)p_item->i_type) & ~KEY_MODIFIER ) )
{
ComboBox_SetCurSel( combo, i );
ComboBox_SetText( combo, _FROMMB(m_keysList[i].c_str()) );
}
}
}
KeyConfigControl::~KeyConfigControl()
{
if( m_keysList )
{
delete[] m_keysList;
m_keysList = NULL;
}
}
int KeyConfigControl::GetIntValue()
{
int result = 0;
if( Button_GetCheck( alt ) )
{
result |= KEY_MODIFIER_ALT;
}
if( Button_GetCheck( ctrl ) )
{
result |= KEY_MODIFIER_CTRL;
}
if( Button_GetCheck( shift ) )
{
result |= KEY_MODIFIER_SHIFT;
}
int selected = ComboBox_GetCurSel( combo );
if( selected != -1 )
{
result |= (int)ComboBox_GetItemData( combo, selected );
}
return result;
}
/*****************************************************************************
* ModuleConfigControl implementation
*****************************************************************************/
ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
module_t **p_list;
module_t *p_parser;
label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, *py_pos, 200, 15,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
combo = CreateWindow( _T("COMBOBOX"), _T(""),
WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL,
20, *py_pos, 180, 5*15 + 6,
parent, NULL, hInst, NULL);
*py_pos += 15 + 10;
/* build a list of available modules */
p_list = module_list_get( NULL );
ComboBox_AddString( combo, _T("Default") );
ComboBox_SetItemData( combo, 0, (void *)NULL );
ComboBox_SetCurSel( combo, 0 );
//ComboBox_SetText( combo, _T("Default") );
for( size_t i_index = 0; p_list[i_index]; i_index++ )
{
p_parser = p_list[i_index];
if( module_provides( p_parser, p_item->psz_type ) )
{
ComboBox_AddString( combo, _FROMMB(module_GetLongName( p_parser ) ));
ComboBox_SetItemData( combo, i_index,
(void *) module_get_object( p_parser ) );
if( p_item->value.psz && !strcmp( p_item->value.psz,
module_get_object( p_parser )) )
{
ComboBox_SetCurSel( combo, i_index );
//ComboBox_SetText( combo, _FROMMB( module_GetLongName(p_parser)) );
}
}
}
module_list_free( p_list );
}
ModuleConfigControl::~ModuleConfigControl()
{
;
}
char *ModuleConfigControl::GetPszValue()
{
int selected = ComboBox_GetCurSel( combo );
if( selected != -1 )
return (char *)ComboBox_GetItemData( combo, selected );
else return NULL;
}
/*****************************************************************************
* StringConfigControl implementation
*****************************************************************************/
StringConfigControl::StringConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, *py_pos, 200, 15,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
textctrl = CreateWindow( _T("EDIT"), p_item->psz_type ?
_FROMMB(p_item->psz_type) : _T(""),
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT |
ES_AUTOHSCROLL, 20, *py_pos - 3, 180, 15 + 3,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
}
StringConfigControl::~StringConfigControl()
{
;
}
char *StringConfigControl::GetPszValue()
{
int i_size;
char *psz_result;
TCHAR *psz_string;
i_size = Edit_GetTextLength( textctrl );
psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) );
Edit_GetText( textctrl, psz_string, i_size + 1 );
psz_result = strdup( _TOMB(psz_string) );
free( psz_string );
return psz_result;
}
#if 0
/*****************************************************************************
* StringListConfigControl implementation
*****************************************************************************/
StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
combo = new wxComboBox( this, -1, wxT(""),
wxDefaultPosition, wxDefaultSize,
0, NULL, wxCB_READONLY );
UpdateCombo( p_item );
combo->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
for( int i = 0; i < p_item->i_action; i++ )
{
wxButton *button =
new wxButton( this, wxID_HIGHEST+i,
wxU(p_item->ppsz_action_text[i]) );
sizer->Add( button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
}
sizer->Layout();
this->SetSizerAndFit( sizer );
}
StringListConfigControl::~StringListConfigControl()
{
}
void StringListConfigControl::UpdateCombo( module_config_t *p_item )
{
/* build a list of available options */
for( int i_index = 0; i_index < p_item->i_list; i_index++ )
{
combo->Append( ( p_item->ppsz_list_text &&
p_item->ppsz_list_text[i_index] ) ?
wxU(p_item->ppsz_list_text[i_index]) :
wxL2U(p_item->ppsz_list[i_index]) );
combo->SetClientData( i_index, (void *)p_item->ppsz_list[i_index] );
if( ( p_item->psz_value &&
!strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) ||
( !p_item->psz_value && !*p_item->ppsz_list[i_index] ) )
{
combo->SetSelection( i_index );
combo->SetValue( ( p_item->ppsz_list_text &&
p_item->ppsz_list_text[i_index] ) ?
wxU(p_item->ppsz_list_text[i_index]) :
wxL2U(p_item->ppsz_list[i_index]) );
}
}
}
BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
/* Button events */
EVT_BUTTON(-1, StringListConfigControl::OnAction)
/* Text events */
EVT__T(-1, StringListConfigControl::OnUpdate)
END_EVENT_TABLE()
void StringListConfigControl::OnAction( wxCommandEvent& event )
{
int i_action = event.GetId() - wxID_HIGHEST;
module_config_t *p_item = config_FindConfig( p_this, GetName().mb_str() );
if( !p_item ) return;
if( i_action < 0 || i_action >= p_item->i_action ) return;
vlc_value_t val;
wxString value = GetPszValue();
(const char *)val.psz_string = value.mb_str();
p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
if( p_item->b_dirty )
{
combo->Clear();
UpdateCombo( p_item );
p_item->b_dirty = false;
}
}
wxString StringListConfigControl::GetPszValue()
{
int selected = combo->GetSelection();
if( selected != -1 )
{
return wxL2U((char *)combo->GetClientData( selected ));
}
return wxString();
}
/*****************************************************************************
* FileConfigControl implementation
*****************************************************************************/
FileConfigControl::FileConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
textctrl = new wxTextCtrl( this, -1,
wxL2U(p_item->psz_value),
wxDefaultPosition,
wxDefaultSize,
wxTE_PROCESS_ENTER);
textctrl->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( textctrl, 1, wxALL, 5 );
browse = new wxButton( this, wxID_HIGHEST, wxU(_("Browse...")) );
sizer->Add( browse, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
sizer->Layout();
this->SetSizerAndFit( sizer );
}
BEGIN_EVENT_TABLE(FileConfigControl, wxPanel)
/* Button events */
EVT_BUTTON(wxID_HIGHEST, FileConfigControl::OnBrowse)
END_EVENT_TABLE()
void FileConfigControl::OnBrowse( wxCommandEvent& event )
{
if( directory )
{
wxDirDialog dialog( this, wxU(_("Choose directory")) );
if( dialog.ShowModal() == wxID_OK )
{
textctrl->SetValue( dialog.GetPath() );
}
}
else
{
wxFileDialog dialog( this, wxU(_("Choose file")),
wxT(""), wxT(""), wxT("*.*"),
#if defined( __WXMSW__ )
wxOPEN
#else
wxOPEN | wxSAVE
#endif
);
if( dialog.ShowModal() == wxID_OK )
{
textctrl->SetValue( dialog.GetPath() );
}
}
}
FileConfigControl::~FileConfigControl()
{
;
}
wxString FileConfigControl::GetPszValue()
{
return textctrl->GetValue();
}
/*****************************************************************************
* IntegerConfigControl implementation
*****************************************************************************/
IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
spin = new wxSpinCtrl( this, -1,
wxString::Format(wxT("%d"),
p_item->i_value),
wxDefaultPosition, wxDefaultSize,
wxSP_ARROW_KEYS,
-10000000, 10000000, p_item->i_value);
spin->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
sizer->Add( spin, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
sizer->Layout();
this->SetSizerAndFit( sizer );
}
IntegerConfigControl::~IntegerConfigControl()
{
;
}
int IntegerConfigControl::GetIntValue()
{
return spin->GetValue();
}
/*****************************************************************************
* IntegerListConfigControl implementation
*****************************************************************************/
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent,
HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
combo = new wxComboBox( this, -1, wxT(""),
wxDefaultPosition, wxDefaultSize,
0, NULL, wxCB_READONLY );
UpdateCombo( p_item );
combo->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
sizer->Layout();
this->SetSizerAndFit( sizer );
}
IntegerListConfigControl::~IntegerListConfigControl()
{
}
void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
{
/* build a list of available options */
for( int i_index = 0; i_index < p_item->i_list; i_index++ )
{
if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
{
combo->Append( wxU(p_item->ppsz_list_text[i_index]) );
}
else
{
combo->Append( wxString::Format(wxT("%i"),
p_item->pi_list[i_index]) );
}
combo->SetClientData( i_index, (void *)p_item->pi_list[i_index] );
if( p_item->i_value == p_item->pi_list[i_index] )
{
combo->SetSelection( i_index );
if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
{
combo->SetValue( wxU(p_item->ppsz_list_text[i_index]) );
}
else
{
combo->SetValue( wxString::Format(wxT("%i"),
p_item->pi_list[i_index]) );
}
}
}
}
BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
/* Button events */
EVT_BUTTON(-1, IntegerListConfigControl::OnAction)
END_EVENT_TABLE()
void IntegerListConfigControl::OnAction( wxCommandEvent& event )
{
int i_action = event.GetId() - wxID_HIGHEST;
module_config_t *p_item;
p_item = config_FindConfig( p_this, GetName().mb_str() );
if( !p_item ) return;
if( i_action < 0 || i_action >= p_item->i_action ) return;
vlc_value_t val;
val.i_int = GetIntValue();
p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
if( p_item->b_dirty )
{
combo->Clear();
UpdateCombo( p_item );
p_item->b_dirty = false;
}
}
int IntegerListConfigControl::GetIntValue()
{
int selected = combo->GetSelection();
if( selected != -1 )
{
return (int)combo->GetClientData( selected );
}
return -1;
}
/*****************************************************************************
* RangedIntConfigControl implementation
*****************************************************************************/
RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
p_item->i_max, wxDefaultPosition, wxDefaultSize,
wxSL_LABELS | wxSL_HORIZONTAL );
slider->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
sizer->Layout();
this->SetSizerAndFit( sizer );
}
RangedIntConfigControl::~RangedIntConfigControl()
{
;
}
int RangedIntConfigControl::GetIntValue()
{
return slider->GetValue();
}
#endif
/*****************************************************************************
* FloatConfigControl implementation
*****************************************************************************/
FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
HWND parent, HINSTANCE hInst,
int *py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, *py_pos, 200, 15,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
TCHAR psz_string[100];
_stprintf( psz_string, _T("%d"), p_item->i_type );
textctrl = CreateWindow( _T("EDIT"), psz_string,
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_RIGHT | ES_AUTOHSCROLL,
20, *py_pos - 3, 70, 15 + 3, parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
}
FloatConfigControl::~FloatConfigControl()
{
;
}
float FloatConfigControl::GetFloatValue()
{
float f_value;
int i_size = Edit_GetTextLength( textctrl );
TCHAR *psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) );
Edit_GetText( textctrl, psz_string, i_size + 1 );
if( _tscanf( psz_string, _T("%f"), &f_value ) == 1 )
{
free( psz_string );
return f_value;
}
free( psz_string );
return 0.0;
}
/*****************************************************************************
* BoolConfigControl implementation
*****************************************************************************/
BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
module_config_t *p_item, HWND parent,
HINSTANCE hInst, int * py_pos )
: ConfigControl( p_this, p_item, parent, hInst )
{
checkbox = CreateWindow( _T("BUTTON"), _T(""),
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
5, *py_pos, 15, 15,
parent, NULL, hInst, NULL );
Button_SetCheck( checkbox, config_GetInt(p_this, p_item->psz_name) ? BST_CHECKED : BST_UNCHECKED );
checkbox_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5 + 15 + 5, *py_pos, 180, 15,
parent, NULL, hInst, NULL );
*py_pos += 15 + 10;
}
BoolConfigControl::~BoolConfigControl()
{
;
}
int BoolConfigControl::GetIntValue()
{
if( Button_GetCheck( checkbox ) ) return 1;
else return 0;
}
/*****************************************************************************
* preferences_widgets.h : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2003 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
class ConfigControl
{
public:
ConfigControl( vlc_object_t *, module_config_t *, HWND, HINSTANCE );
virtual ~ConfigControl();
virtual int GetIntValue() {return 0;}
virtual float GetFloatValue() {return 0;}
virtual char *GetPszValue() {return GetName();}
// FIXME returns name corresponding to parent
// put the panel name corresponding to HWND into the constructor and make it private
char *GetName();
int GetType();
bool IsAdvanced();
void SetUpdateCallback( void (*)( void * ), void * );
protected:
/*wxBoxSizer *sizer;*/
HWND label;
vlc_object_t *p_this;
void (*pf_update_callback)( void * );
void *p_update_data;
void OnUpdate( UINT );
private:
HWND parent;
char *name;
int i_type;
bool b_advanced;
};
ConfigControl *CreateConfigControl( vlc_object_t *,
module_config_t *, HWND, HINSTANCE,
int * );
class KeyConfigControl: public ConfigControl
{
public:
KeyConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~KeyConfigControl();
virtual int GetIntValue();
private:
HWND alt;
HWND alt_label;
HWND ctrl;
HWND ctrl_label;
HWND shift;
HWND shift_label;
HWND combo;
// Array of key descriptions, for the ComboBox
static string *m_keysList;
};
class ModuleConfigControl: public ConfigControl
{
public:
ModuleConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~ModuleConfigControl();
virtual char *GetPszValue();
private:
HWND combo;
};
class StringConfigControl: public ConfigControl
{
public:
StringConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~StringConfigControl();
virtual char *GetPszValue();
private:
HWND textctrl;
};
class StringListConfigControl: public ConfigControl
{
public:
StringListConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~StringListConfigControl();
virtual char *GetPszValue();
private:
};
class FileConfigControl: public ConfigControl
{
public:
FileConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~FileConfigControl();
void OnBrowse( UINT );
virtual char *GetPszValue();
private:
};
class IntegerConfigControl: public ConfigControl
{
public:
IntegerConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~IntegerConfigControl();
virtual int GetIntValue();
private:
};
class IntegerListConfigControl: public ConfigControl
{
public:
IntegerListConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~IntegerListConfigControl();
virtual int GetIntValue();
private:
};
class RangedIntConfigControl: public ConfigControl
{
public:
RangedIntConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~RangedIntConfigControl();
virtual int GetIntValue();
private:
};
class FloatConfigControl: public ConfigControl
{
public:
FloatConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~FloatConfigControl();
virtual float GetFloatValue();
private:
HWND textctrl;
};
class BoolConfigControl: public ConfigControl
{
public:
BoolConfigControl( vlc_object_t *, module_config_t *, HWND,
HINSTANCE, int * );
~BoolConfigControl();
virtual int GetIntValue();
private:
HWND checkbox;
HWND checkbox_label;
};
/*****************************************************************************
* subtitles.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2001 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include "wince.h"
#include <winuser.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
/*****************************************************************************
* Event Table.
*****************************************************************************/
/*****************************************************************************
* Constructor.
*****************************************************************************/
SubsFileDialog::SubsFileDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
SHMENUBARINFO mbi;
INITCOMMONCONTROLSEX ic;
RECT rcClient;
char *psz_subsfile;
module_config_t *p_item;
float f_fps;
int i_delay;
TCHAR psz_text[256];
switch( msg )
{
case WM_INITDIALOG:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
//Create the menubar.
memset (&mbi, 0, sizeof (SHMENUBARINFO));
mbi.cbSize = sizeof (SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.dwFlags = SHCMBF_EMPTYBAR;
mbi.hInstRes = hInst;
if (!SHCreateMenuBar(&mbi))
{
MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
//return -1;
}
hwndCB = mbi.hwndMB;
// Get the client area rect to put the panels in
GetClientRect(hwnd, &rcClient);
/* Create the subtitles file textctrl */
file_box = CreateWindow( _T("STATIC"), _T("Subtitles file"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10, rcClient.right - 2*5, 15,
hwnd, NULL, hInst, NULL );
psz_subsfile = config_GetPsz( p_intf, "sub-file" );
if( !psz_subsfile ) psz_subsfile = strdup("");
file_combo = CreateWindow( _T("COMBOBOX"), _FROMMB(psz_subsfile),
WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
10, 10 + 15 + 10 - 3, rcClient.right - 2*10, 5*15 + 6,
hwnd, NULL, hInst, NULL );
free( psz_subsfile );
browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
10, 10 + 2*(15 + 10) - 3, 80, 15 + 6,
hwnd, NULL, hInst, NULL);
/* Subtitles encoding */
encoding_combo = NULL;
p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
if( p_item )
{
enc_box = CreateWindow( _T("STATIC"), _T("Subtitles encoding"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10 + 3*(15 + 10), rcClient.right - 2*5, 15,
hwnd, NULL, hInst, NULL );
enc_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
WS_CHILD | WS_VISIBLE | SS_LEFT,
10, 10 + 4*(15 + 10), rcClient.right - 2*10, 15,
hwnd, NULL, hInst, NULL );
encoding_combo = CreateWindow( _T("COMBOBOX"),
_FROMMB(p_item->value.psz),
WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST |
LBS_SORT | WS_VSCROLL,
rcClient.right - 150 - 10, 10 + 5*(15 + 10) - 3, 150, 5*15 + 6,
hwnd, NULL, hInst, NULL );
/* build a list of available options */
for( int i_index = 0; p_item->ppsz_list &&
p_item->ppsz_list[i_index]; i_index++ )
{
ComboBox_AddString( encoding_combo,
_FROMMB(p_item->ppsz_list[i_index]) );
if( p_item->value.psz &&
!strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
ComboBox_SetCurSel( encoding_combo, i_index );
}
if( p_item->value.psz )
{
ComboBox_SelectString( encoding_combo, 0,
_FROMMB(p_item->value.psz) );
}
}
/* Misc Subtitles options */
misc_box = CreateWindow( _T("STATIC"), _T("Subtitles options"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 10 + 6*(15 + 10), rcClient.right - 2*5, 15,
hwnd, NULL, hInst, NULL );
delay_label = CreateWindow( _T("STATIC"),
_T("Delay subtitles (in 1/10s)"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
10, 10 + 7*(15 + 10), rcClient.right - 70 - 2*10, 15,
hwnd, NULL, hInst, NULL );
i_delay = config_GetInt( p_intf, "sub-delay" );
_stprintf( psz_text, _T("%d"), i_delay );
delay_edit = CreateWindow( _T("EDIT"), psz_text,
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
rcClient.right - 70 - 10, 10 + 7*(15 + 10) - 3, 70, 15 + 6,
hwnd, NULL, hInst, NULL );
ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
ic.dwICC = ICC_UPDOWN_CLASS;
InitCommonControlsEx(&ic);
delay_spinctrl =
CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
0, 0, 0, 0, hwnd, 0, hInst,
delay_edit, 650000, -650000, i_delay );
fps_label = CreateWindow( _T("STATIC"), _T("Frames per second"),
WS_CHILD | WS_VISIBLE | SS_LEFT,
10, 10 + 8*(15 + 10), rcClient.right - 70 - 2*10, 15,
hwnd, NULL, hInst, NULL );
f_fps = config_GetFloat( p_intf, "sub-fps" );
_stprintf( psz_text, _T("%f"), f_fps );
fps_edit = CreateWindow( _T("EDIT"), psz_text,
WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
rcClient.right - 70 - 10, 10 + 8*(15 + 10) - 3, 70, 15 + 6,
hwnd, NULL, hInst, NULL);
ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
ic.dwICC = ICC_UPDOWN_CLASS;
InitCommonControlsEx(&ic);
fps_spinctrl = CreateUpDownControl(
WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
0, 0, 0, 0, hwnd, 0, hInst, fps_edit, 16000, 0, (int)f_fps );
break;
case WM_CLOSE:
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
break;
case WM_COMMAND:
if ( LOWORD(wp) == IDOK )
{
subsfile_mrl.clear();
string szFileCombo = "sub-file=";
GetWindowText( file_combo, psz_text, 256 );
szFileCombo += _TOMB(psz_text);
subsfile_mrl.push_back( szFileCombo );
if( GetWindowTextLength( encoding_combo ) != 0 )
{
string szEncoding = "subsdec-encoding=";
GetWindowText( encoding_combo, psz_text, 256 );
szEncoding += _TOMB(psz_text);
subsfile_mrl.push_back( szEncoding );
}
string szDelay = "sub-delay=";
Edit_GetText( delay_edit, psz_text, 256 );
szDelay += _TOMB(psz_text);
subsfile_mrl.push_back( szDelay );
string szFps = "sub-fps=";
Edit_GetText( fps_edit, psz_text, 256 );
szFps += _TOMB(psz_text);
subsfile_mrl.push_back( szFps );
EndDialog( hwnd, LOWORD( wp ) );
break;
}
if( HIWORD(wp) == BN_CLICKED )
{
if ((HWND)lp == browse_button)
{
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
OnFileBrowse();
}
}
break;
default:
break;
}
return FALSE;
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
/*****************************************************************************
* Events methods.
*****************************************************************************/
static void OnOpenCB( intf_dialog_args_t *p_arg )
{
SubsFileDialog *p_this = (SubsFileDialog *)p_arg->p_arg;
if( p_arg->i_results && p_arg->psz_results[0] )
{
SetWindowText( p_this->file_combo, _FROMMB(p_arg->psz_results[0]) );
ComboBox_AddString( p_this->file_combo,
_FROMMB(p_arg->psz_results[0]) );
if( ComboBox_GetCount( p_this->file_combo ) > 10 )
ComboBox_DeleteString( p_this->file_combo, 0 );
}
}
void SubsFileDialog::OnFileBrowse()
{
intf_dialog_args_t *p_arg =
(intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
memset( p_arg, 0, sizeof(intf_dialog_args_t) );
p_arg->psz_title = strdup( "Open file" );
p_arg->psz_extensions = strdup( "All|*.*" );
p_arg->p_arg = this;
p_arg->pf_callback = OnOpenCB;
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
}
/*****************************************************************************
* timer.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2003 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_interface.h>
#include <vlc_input.h>
#include <vlc_playlist.h>
#include "wince.h"
#include <commctrl.h>
/* Callback prototype */
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void * );
/*****************************************************************************
* Constructor.
*****************************************************************************/
Timer::Timer( intf_thread_t *_p_intf, HWND hwnd, Interface *_p_main_interface)
{
p_intf = _p_intf;
p_main_interface = _p_main_interface;
i_old_playing_status = PAUSE_S;
i_old_rate = INPUT_RATE_DEFAULT;
/* Register callback for the intf-popupmenu variable */
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist != NULL )
{
var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
pl_Release( p_intf );
}
SetTimer( hwnd, 1, 200 /*milliseconds*/, NULL );
}
Timer::~Timer()
{
/* Unregister callback */
playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist != NULL )
{
var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
pl_Release( p_intf );
}
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
/*****************************************************************************
* Manage: manage main thread messages
*****************************************************************************
* In this function, called approx. 10 times a second, we check what the
* main program wanted to tell us.
*****************************************************************************/
void Timer::Notify( void )
{
vlc_value_t val;
char *shortname;
/* Update the input */
if( p_intf->p_sys->p_input == NULL )
{
p_intf->p_sys->p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
/* Show slider */
if( p_intf->p_sys->p_input )
{
ShowWindow( p_main_interface->hwndSlider, SW_SHOW );
ShowWindow( p_main_interface->hwndLabel, SW_SHOW );
ShowWindow( p_main_interface->hwndVol, SW_SHOW );
// only for local file, check if works well with net url
input_item_t *p_item =input_GetItem(p_intf->p_sys->p_input);
shortname = strrchr( input_item_GetURL(p_item), '\\' );
if (! shortname)
shortname = input_item_GetURL(p_item);
else shortname++;
SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
(WPARAM) 0, (LPARAM)_FROMMB(shortname) );
p_main_interface->TogglePlayButton( PLAYING_S );
i_old_playing_status = PLAYING_S;
}
}
else if( p_intf->p_sys->p_input->b_dead )
{
/* Hide slider */
ShowWindow( p_main_interface->hwndSlider, SW_HIDE);
ShowWindow( p_main_interface->hwndLabel, SW_HIDE);
ShowWindow( p_main_interface->hwndVol, SW_HIDE);
p_main_interface->TogglePlayButton( PAUSE_S );
i_old_playing_status = PAUSE_S;
SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
(WPARAM) 0, (LPARAM)(LPCTSTR) TEXT(""));
vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL;
}
if( p_intf->p_sys->p_input )
{
input_thread_t *p_input = p_intf->p_sys->p_input;
if( vlc_object_alive (p_input) )
{
/* New input or stream map change */
p_intf->p_sys->b_playing = 1;
/* Manage the slider */
if( /*p_input->stream.b_seekable &&*/ p_intf->p_sys->b_playing )
{
/* Update the slider if the user isn't dragging it. */
if( p_intf->p_sys->b_slider_free )
{
vlc_value_t pos;
char psz_time[ MSTRTIME_MAX_SIZE ];
vlc_value_t time;
mtime_t i_seconds;
/* Update the value */
var_Get( p_input, "position", &pos );
if( pos.f_float >= 0.0 )
{
p_intf->p_sys->i_slider_pos =
(int)(SLIDER_MAX_POS * pos.f_float);
SendMessage( p_main_interface->hwndSlider, TBM_SETPOS,
1, p_intf->p_sys->i_slider_pos );
var_Get( p_intf->p_sys->p_input, "time", &time );
i_seconds = time.i_time / 1000000;
secstotimestr ( psz_time, i_seconds );
SendMessage( p_main_interface->hwndLabel, WM_SETTEXT,
(WPARAM)1, (LPARAM)_FROMMB(psz_time) );
}
}
}
/* Take care of the volume, etc... */
p_main_interface->Update();
/* Manage Playing status */
var_Get( p_input, "state", &val );
if( i_old_playing_status != val.i_int )
{
if( val.i_int == PAUSE_S )
{
p_main_interface->TogglePlayButton( PAUSE_S );
}
else
{
p_main_interface->TogglePlayButton( PLAYING_S );
}
i_old_playing_status = val.i_int;
}
/* Manage Speed status */
var_Get( p_input, "rate", &val );
if( i_old_rate != (int)((float)INPUT_RATE_DEFAULT / val.f_float) )
{
TCHAR psz_text[15];
_stprintf( psz_text + 2, _T("x%.2f"), 1000.0 / val.i_int );
psz_text[0] = psz_text[1] = _T('\t');
SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
(WPARAM) 1, (LPARAM)(LPCTSTR) psz_text );
i_old_rate = val.i_int;
}
}
}
else if( p_intf->p_sys->b_playing && vlc_object_alive( p_intf ) )
{
p_intf->p_sys->b_playing = 0;
p_main_interface->TogglePlayButton( PAUSE_S );
i_old_playing_status = PAUSE_S;
}
if( !vlc_object_alive( p_intf ) )
{
/* Prepare to die, young Skywalker */
/* p_main_interface->Close(TRUE);*/
return;
}
}
/*****************************************************************************
* PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
* We don't show the menu directly here because we don't want the
* caller to block for a too long time.
*****************************************************************************/
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param )
{
intf_thread_t *p_intf = (intf_thread_t *)param;
if( p_intf->p_sys->pf_show_dialog )
{
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
new_val.b_bool, 0 );
}
return VLC_SUCCESS;
}
/*****************************************************************************
* video.cpp : WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2000-2004, 2003 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_vout.h>
#include <vlc_interface.h>
#include "wince.h"
static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *,
int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint,
unsigned int *pi_height_hint );
static void ReleaseWindow( intf_thread_t *p_intf, void *p_window );
static int ControlWindow( intf_thread_t *p_intf, void *p_window,
int i_query, va_list args );
/* IDs for the controls and the menu commands */
enum
{
UpdateSize_Event = 1000 + 1,
UpdateHide_Event
};
/* Video Window */
class VideoWindow : public CBaseWindow
{
public:
/* Constructor */
VideoWindow( intf_thread_t *_p_intf, HWND _p_parent );
virtual ~VideoWindow();
void *GetWindow( vout_thread_t *, int *, int *, unsigned int *,
unsigned int * );
void ReleaseWindow( void * );
int ControlWindow( void *, int, va_list );
HWND p_child_window; // public because of menu
private:
intf_thread_t *p_intf;
vout_thread_t *p_vout;
HWND p_parent;
vlc_mutex_t lock;
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
};
/*****************************************************************************
* Public methods.
*****************************************************************************/
CBaseWindow *CreateVideoWindow( intf_thread_t *p_intf, HWND p_parent )
{
return new VideoWindow( p_intf, p_parent );
}
/*****************************************************************************
* Constructor.
*****************************************************************************/
VideoWindow::VideoWindow( intf_thread_t *_p_intf, HWND _p_parent )
{
RECT rect;
WNDCLASS wc;
/* Initializations */
p_intf = _p_intf;
p_parent = _p_parent;
p_child_window = NULL;
vlc_mutex_init( &lock );
p_vout = NULL;
// Changeset 138da19...
//p_intf->pf_request_window = ::GetWindow;
//p_intf->pf_release_window = ::ReleaseWindow;
//p_intf->pf_control_window = ::ControlWindow;
p_intf->p_sys->p_video_window = this;
GetClientRect( p_parent, &rect );
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = (WNDPROC)BaseWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = NULL;
wc.hInstance = GetModuleHandle(0);
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = _T("VIDEOWINDOW");
RegisterClass( &wc );
p_child_window = CreateWindow (
_T("VIDEOWINDOW"), _T(""),
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_BORDER,
0, 20, rect.right - rect.left,
rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT - 20,
p_parent, NULL, GetModuleHandle(0), (void *)this );
ShowWindow( p_child_window, SW_SHOW );
UpdateWindow( p_child_window );
ReleaseWindow( (void*)p_child_window );
}
VideoWindow::~VideoWindow()
{
vlc_mutex_destroy( &lock );
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *p_vout,
int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint,
unsigned int *pi_height_hint )
{
return p_intf->p_sys->p_video_window->GetWindow( p_vout, pi_x_hint,
pi_y_hint, pi_width_hint, pi_height_hint );
}
void *VideoWindow::GetWindow( vout_thread_t *_p_vout,
int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint,
unsigned int *pi_height_hint )
{
vlc_mutex_lock( &lock );
if( p_vout )
{
vlc_mutex_unlock( &lock );
msg_Dbg( p_intf, "Video window already in use" );
return NULL;
}
p_vout = _p_vout;
vlc_mutex_unlock( &lock );
ShowWindow( (HWND)p_child_window, SW_SHOW );
return p_child_window;
}
static void ReleaseWindow( intf_thread_t *p_intf, void *p_window )
{
p_intf->p_sys->p_video_window->ReleaseWindow( p_window );
}
void VideoWindow::ReleaseWindow( void *p_window )
{
vlc_mutex_lock( &lock );
p_vout = NULL;
vlc_mutex_unlock( &lock );
ShowWindow( (HWND)p_window, SW_HIDE );
SetForegroundWindow( p_parent );
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT VideoWindow::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
switch( msg )
{
case WM_KILLFOCUS:
return TRUE;
case WM_SETFOCUS:
return TRUE;
default:
return DefWindowProc( hwnd, msg, wp, lp );
}
}
static int ControlWindow( intf_thread_t *p_intf, void *p_window,
int i_query, va_list args )
{
return p_intf->p_sys->p_video_window->ControlWindow( p_window, i_query,
args );
}
int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
{
int i_ret = VLC_EGENERIC;
vlc_mutex_lock( &lock );
switch( i_query )
{
case VOUT_SET_STAY_ON_TOP:
break;
default:
msg_Dbg( p_intf, "control query not supported" );
break;
}
vlc_mutex_unlock( &lock );
return i_ret;
}
/*****************************************************************************
* wince.cpp: WinCE gui plugin for VLC
*****************************************************************************
* Copyright (C) 2003 the VideoLAN team
* $Id$
*
* Author: 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
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_interface.h>
#include <vlc_input.h>
#if defined( UNDER_CE ) && defined(__MINGW32__)
/* This is a gross hack for the wince gcc cross-compiler */
#define _off_t long
#endif
#include "wince.h"
#include <objbase.h>
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * );
static int OpenDialogs( vlc_object_t * );
static void* MainLoop ( vlc_object_t * );
static void ShowDialog( intf_thread_t *, int, int, intf_dialog_args_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define EMBED_TEXT N_("Embed video in interface")
#define EMBED_LONGTEXT N_("Embed the video inside the interface instead " \
"of having it in a separate window.")
vlc_module_begin ()
set_shortname( "WinCE" )
set_description( (char *) _("WinCE interface") )
set_capability( "interface", 100 )
set_callbacks( Open, Close )
add_shortcut( "wince" )
set_category( CAT_INTERFACE )
set_subcategory( SUBCAT_INTERFACE_MAIN )
add_bool( "wince-embed", true, NULL,
EMBED_TEXT, EMBED_LONGTEXT, false )
add_submodule ()
set_description( N_("WinCE dialogs provider") )
set_capability( "dialogs provider", 10 )
set_callbacks( OpenDialogs, Close )
vlc_module_end ()
HINSTANCE hInstance = 0;
#if !defined(__BUILTIN__)
extern "C" BOOL WINAPI
DllMain( HANDLE hModule, DWORD fdwReason, LPVOID lpReserved )
{
hInstance = (HINSTANCE)hModule;
return TRUE;
}
#endif
/* Global variables used by _TOMB() / _FROMB() */
wchar_t pwsz_mbtow_wince[2048];
char psz_wtomb_wince[2048];
/*****************************************************************************
* Open: initialize interface
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
// Check if the application is running.
// If it's running then focus its window and bail out.
HWND hwndMain = FindWindow( _T("VLC WinCE"), _T("VLC media player") );
if( hwndMain )
{
SetForegroundWindow( hwndMain );
return VLC_EGENERIC;
}
// Allocate instance and initialize some members
p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
return VLC_ENOMEM;
// Misc init
p_intf->p_sys->p_audio_menu = NULL;
p_intf->p_sys->p_video_menu = NULL;
p_intf->p_sys->p_navig_menu = NULL;
p_intf->p_sys->p_settings_menu = NULL;
p_intf->pf_run = Run;
p_intf->pf_show_dialog = NULL;
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->b_playing = 0;
p_intf->p_sys->i_playing = -1;
p_intf->p_sys->b_slider_free = 1;
p_intf->p_sys->i_slider_pos = p_intf->p_sys->i_slider_oldpos = 0;
return VLC_SUCCESS;
}
static int OpenDialogs( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
int i_ret = Open( p_this );
p_intf->pf_show_dialog = ShowDialog;
return i_ret;
}
/*****************************************************************************
* Close: destroy interface
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
intf_sys_t *p_sys = p_intf->p_sys;
if( p_sys->p_input )
{
vlc_object_release( p_sys->p_input );
}
MenuItemExt::ClearList( p_intf->p_sys->p_video_menu );
delete p_intf->p_sys->p_video_menu;
MenuItemExt::ClearList( p_intf->p_sys->p_audio_menu );
delete p_intf->p_sys->p_audio_menu;
MenuItemExt::ClearList( p_intf->p_sys->p_settings_menu );
delete p_intf->p_sys->p_settings_menu;
MenuItemExt::ClearList( p_intf->p_sys->p_navig_menu );
delete p_intf->p_sys->p_navig_menu;
if( p_intf->pf_show_dialog )
{
/* We must destroy the dialogs thread */
#if 0
wxCommandEvent event( wxEVT_DIALOG, INTF_DIALOG_EXIT );
p_intf->p_sys->p_wxwindow->AddPendingEvent( event );
#endif
vlc_thread_join( p_intf );
}
// Destroy structure
free( p_intf->p_sys );
}
/*****************************************************************************
* Run: main loop
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
if( p_intf->pf_show_dialog )
{
/* The module is used in dialog provider mode */
/* Create a new thread for the dialogs provider */
p_intf->p_sys->thread_ready = CreateEvent (NULL, TRUE, FALSE, NULL);
if( vlc_thread_create( p_intf, "WinCE Dialogs Thread", MainLoop, 0 ) )
{
msg_Err( p_intf, "cannot create WinCE Dialogs Thread" );
p_intf->pf_show_dialog = NULL;
}
else
WaitForSingleObject (p_intf->p_sys->thread_ready, INFINITE);
CloseHandle (p_intf->p_sys->thread_ready);
}
else
{
int canc = vlc_savecancel();
/* The module is used in interface mode */
MainLoop( VLC_OBJECT(p_intf) );
vlc_restorecancel( canc );
}
}
static void* MainLoop( vlc_object_t * p_this )
{
intf_thread_t *p_intf = (intf_thread_t*)p_this;
MSG msg;
Interface *intf = 0;
int canc = vlc_savecancel ();
if( !hInstance ) hInstance = GetModuleHandle(NULL);
// Register window class
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = (WNDPROC)CBaseWindow::BaseWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = NULL;
wc.hInstance = hInstance;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)(COLOR_MENU+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = _T("VLC WinCE");
RegisterClass( &wc );
#ifndef UNDER_CE
/* Initialize OLE/COM */
CoInitialize( 0 );
#endif
if( !p_intf->pf_show_dialog )
{
/* The module is used in interface mode */
p_intf->p_sys->p_window = intf = new Interface( p_intf, 0, hInstance );
/* Create/Show the interface */
if( !intf->InitInstance() ) goto end;
}
/* Creates the dialogs provider */
p_intf->p_sys->p_window =
CreateDialogsProvider( p_intf, p_intf->pf_show_dialog ?
NULL : p_intf->p_sys->p_window, hInstance );
p_intf->p_sys->pf_show_dialog = ShowDialog;
/* OK, initialization is over */
SetEvent( p_intf->p_sys->thread_ready );
// Main message loop
while( GetMessage( &msg, NULL, 0, 0 ) > 0 )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
end:
delete intf;
#ifndef UNDER_CE
/* Uninitialize OLE/COM */
CoUninitialize();
#endif
vlc_restorecancel (canc);
return NULL;
}
/*****************************************************************************
* CBaseWindow Implementation
*****************************************************************************/
LRESULT CALLBACK CBaseWindow::BaseWndProc( HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam )
{
CBaseWindow *p_obj;
// check to see if a copy of the 'this' pointer needs to be saved
if( msg == WM_CREATE )
{
p_obj = (CBaseWindow *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
SetWindowLong( hwnd, GWL_USERDATA,
(LONG)((LPCREATESTRUCT)lParam)->lpCreateParams );
p_obj->hWnd = hwnd;
}
if( msg == WM_INITDIALOG )
{
p_obj = (CBaseWindow *)lParam;
SetWindowLong( hwnd, GWL_USERDATA, lParam );
p_obj->hWnd = hwnd;
}
// Retrieve the pointer
p_obj = (CBaseWindow *)GetWindowLong( hwnd, GWL_USERDATA );
if( !p_obj ) return DefWindowProc( hwnd, msg, wParam, lParam );
// Filter message through child classes
return p_obj->WndProc( hwnd, msg, wParam, lParam );
}
int CBaseWindow::CreateDialogBox( HWND hwnd, CBaseWindow *p_obj )
{
uint8_t p_buffer[sizeof(DLGTEMPLATE) + sizeof(WORD) * 4];
DLGTEMPLATE *p_dlg_template = (DLGTEMPLATE *)p_buffer;
memset( p_dlg_template, 0, sizeof(DLGTEMPLATE) + sizeof(WORD) * 4 );
// these values are arbitrary, they won't be used normally anyhow
p_dlg_template->x = 0; p_dlg_template->y = 0;
p_dlg_template->cx = 300; p_dlg_template->cy = 300;
p_dlg_template->style =
DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX;
return DialogBoxIndirectParam( GetModuleHandle(0), p_dlg_template, hwnd,
(DLGPROC)p_obj->BaseWndProc, (LPARAM)p_obj);
}
/*****************************************************************************
* ShowDialog
*****************************************************************************/
static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg,
intf_dialog_args_t *p_arg )
{
SendMessage( p_intf->p_sys->p_window->GetHandle(), WM_CANCELMODE, 0, 0 );
if( i_dialog_event == INTF_DIALOG_POPUPMENU && i_arg == 0 ) return;
/* Hack to prevent popup events to be enqueued when
* one is already active */
#if 0
if( i_dialog_event != INTF_DIALOG_POPUPMENU ||
!p_intf->p_sys->p_popup_menu )
#endif
{
SendMessage( p_intf->p_sys->p_window->GetHandle(),
WM_APP + i_dialog_event, (WPARAM)i_arg, (LPARAM)p_arg );
}
}
/*****************************************************************************
* wince.h: private WinCE interface descriptor
*****************************************************************************
* Copyright (C) 1999-2004 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Marodon Cedric <cedric_marodon@yahoo.fr>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef WINCE_RESOURCE
#define SLIDER_HEIGHT 50
#define SLIDER_MAX_POS 10000
#define MENU_HEIGHT 26
#define FILE_ACCESS 1
#define NET_ACCESS 2
#define OPEN_NORMAL 0
#define OPEN_STREAM 1
#if defined( UNDER_CE ) && defined(__MINGW32__)
/* This is a gross hack for the wince gcc cross-compiler */
# define _off_t long
#endif
#include <vlc_keys.h>
#include <vlc_messages.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
class CBaseWindow;
class MenuItemExt;
class VideoWindow;
/*****************************************************************************
* intf_sys_t: description and status of wxwindows interface
*****************************************************************************/
struct intf_sys_t
{
/* the parent window */
CBaseWindow *p_window;
/* special actions */
bool b_playing;
/* The input thread */
input_thread_t * p_input;
/* The slider */
int i_slider_pos; /* slider position */
int i_slider_oldpos; /* previous position */
bool b_slider_free; /* slider status */
/* Playlist management */
int i_playing; /* playlist selected item */
/* Send an event to show a dialog */
void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
intf_dialog_args_t *p_arg );
/* Dynamic Menu management */
vector<MenuItemExt*> *p_audio_menu;
vector<MenuItemExt*> *p_video_menu;
vector<MenuItemExt*> *p_navig_menu;
vector<MenuItemExt*> *p_settings_menu;
VideoWindow *p_video_window;
HANDLE thread_ready;
};
/*****************************************************************************
* Prototypes
*****************************************************************************/
class CBaseWindow
{
public:
CBaseWindow( intf_thread_t *_p_intf = 0, CBaseWindow *_p_parent = 0,
HINSTANCE _hInst = 0 )
: hWnd(0), hInst(_hInst), p_parent(_p_parent), p_intf(_p_intf) {};
virtual ~CBaseWindow() {};
HWND hWnd; // The main window handle
static LRESULT CALLBACK BaseWndProc( HWND, UINT, WPARAM, LPARAM );
static int CreateDialogBox( HWND, CBaseWindow * );
HWND GetHandle() { return hWnd; }
BOOL Show( BOOL b_show ) { return (hWnd && ShowWindow(hWnd, b_show)); }
BOOL IsShown( void ) { return (hWnd && IsWindowVisible(hWnd)); }
protected:
HINSTANCE hInst; // The current instance
HWND hwndCB; // The command bar handle
HINSTANCE GetInstance () const { return hInst; }
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM ) { return 0; };
CBaseWindow *p_parent;
intf_thread_t *p_intf;
};
class FileInfo;
class Messages;
class Playlist;
class Timer;
class OpenDialog;
class PrefsDialog;
CBaseWindow *CreateDialogsProvider( intf_thread_t *, CBaseWindow *, HINSTANCE);
CBaseWindow *CreateVideoWindow( intf_thread_t *, HWND );
void PopupMenu( intf_thread_t *, HWND, POINT );
/* Main Interface */
class Interface : public CBaseWindow
{
public:
/* Constructor */
Interface( intf_thread_t *, CBaseWindow *, HINSTANCE );
~Interface();
BOOL InitInstance();
HWND CreateMenuBar( HWND, HINSTANCE );
void TogglePlayButton( int i_playing_status );
void Update();
HWND hwndMain; // Handle to the main window.
HWND hwndCB; // Handle to the command bar (contains menu)
HWND hwndTB; // Handle to the toolbar.
HWND hwndSlider; // Handle to the Sliderbar.
HWND hwndLabel;
HWND hwndVol; // Handle to the volume trackbar.
HWND hwndSB; // Handle to the status bar.
HMENU hPopUpMenu;
HMENU hMenu;
Timer *timer;
CBaseWindow *video;
protected:
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
void OnShowDialog( int );
void OnPlayStream( void );
void OnStopStream( void );
void OnPrevStream( void );
void OnNextStream( void );
void OnSlowStream( void );
void OnFastStream( void );
void OnVideoOnTop( void );
void OnSliderUpdate( int wp );
void OnChange( int wp );
void VolumeChange( int i_volume );
void VolumeUpdate( void );
int i_old_playing_status;
private:
HMENU menu_settings;
HMENU menu_video;
HMENU menu_audio;
HMENU menu_navigation;
bool b_volume_hold;
};
/* File Info */
class FileInfo : public CBaseWindow
{
public:
/* Constructor */
FileInfo( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~FileInfo(){};
void UpdateFileInfo(void);
protected:
HWND hwnd_fileinfo; // handle to fileinfo window
HWND hwndTV; // handle to tree-view control
TCHAR szFileInfoClassName[100]; // Main window class name
TCHAR szFileInfoTitle[100]; // Main window name
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
BOOL CreateTreeView( HWND );
};
struct msg_cb_data_t
{
Messages *self;
};
/* Messages */
class Messages : public CBaseWindow
{
public:
/* Constructor */
Messages( intf_thread_t *, CBaseWindow *, HINSTANCE );
~Messages();
static void sinkMessage (msg_cb_data_t *, msg_item_t *, unsigned);
void sinkMessage (msg_item_t *item, unsigned);
protected:
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
/* The messages window */
msg_subscription_t* sub; /* message bank subscription */
msg_cb_data_t *cb_data;
HWND hListView;
bool b_verbose;
};
/* ItemInfo Dialog */
class ItemInfoDialog : public CBaseWindow
{
public:
/* Constructor */
ItemInfoDialog( intf_thread_t *, CBaseWindow *,
HINSTANCE, playlist_item_t * );
virtual ~ItemInfoDialog(){};
protected:
intf_thread_t *p_intf;
HWND hwndCB; // Handle to the command bar (but no menu)
playlist_item_t *p_item;
/* Event handlers (these functions should _not_ be virtual) */
void OnOk();
void UpdateInfo();
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
/* Controls for the iteminfo dialog box */
HWND uri_label;
HWND uri_text;
HWND name_label;
HWND name_text;
HWND checkbox_label;
HWND enabled_checkbox;
HWND info_tree;
};
/* Open Dialog */
class SubsFileDialog;
class OpenDialog : public CBaseWindow
{
public:
/* Constructor */
OpenDialog( intf_thread_t *, CBaseWindow *, HINSTANCE, int, int );
virtual ~OpenDialog(){};
void UpdateMRL();
void UpdateMRL( int i_access_method );
HWND file_combo;
protected:
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
HWND mrl_box;
HWND mrl_label;
HWND mrl_combo;
HWND label;
HWND notebook;
HWND browse_button;
HWND subsfile_checkbox;
HWND subsfile_label;
HWND subsfile_button;
SubsFileDialog *subsfile_dialog;
HWND net_radios[4];
HWND net_label[4];
HWND net_port_label[4];
HWND net_ports[4];
HWND hUpdown[4];
int i_net_ports[4];
HWND net_addrs_label[4];
HWND net_addrs[4];
int i_open_arg;
int i_access;
int i_net_type;
void FilePanel( HWND hwnd );
void NetPanel( HWND hwnd );
void OnSubsFileEnable();
void OnSubsFileSettings( HWND hwnd );
void OnPageChange();
void OnFilePanelChange();
void OnFileBrowse();
void OnNetPanelChange( int event );
void OnNetTypeChange( int event );
void DisableNETCtrl();
void OnOk();
vector<string> mrl;
vector<string> subsfile_mrl;
};
/* Subtitles File Dialog */
class SubsFileDialog: public CBaseWindow
{
public:
/* Constructor */
SubsFileDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~SubsFileDialog(){};
vector<string> subsfile_mrl;
HWND file_combo;
protected:
friend class OpenDialog;
HWND file_box;
HWND browse_button;
HWND enc_box;
HWND enc_label;
HWND encoding_combo;
HWND misc_box;
HWND delay_label;
HWND delay_edit;
HWND delay_spinctrl;
HWND fps_label;
HWND fps_edit;
HWND fps_spinctrl;
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
/* Event handlers (these functions should _not_ be virtual) */
void OnFileBrowse();
};
/* Playlist */
class Playlist : public CBaseWindow
{
public:
/* Constructor */
Playlist( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~Playlist(){};
void UpdatePlaylist();
void ShowPlaylist( bool );
protected:
bool b_need_update;
vlc_mutex_t lock;
int i_title_sorted;
int i_author_sorted;
HWND hwndCB; // Handle to the command bar (contains menu)
HWND hwndTB; // Handle to the toolbar.
HWND hListView;
void Rebuild();
void UpdateItem( int );
LRESULT ProcessCustomDraw( LPARAM lParam );
void HandlePopupMenu( HWND hwnd, POINT point);
void DeleteItem( input_item_t * item );
void OnOpen();
void OnSave();
void OnDeleteSelection();
void OnInvertSelection();
void OnEnableSelection();
void OnDisableSelection();
void OnSelectAll();
void OnActivateItem( int i_item );
void ShowInfos( HWND hwnd, int i_item );
void OnUp();
void OnDown();
void OnRandom();
void OnLoop();
void OnRepeat();
void OnSort( UINT event );
void OnColSelect( int iSubItem );
void OnPopupPlay();
void OnPopupDel();
void OnPopupEna();
void OnPopupInfo( HWND hwnd );
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
};
/* Timer */
class Timer
{
public:
/* Constructor */
Timer( intf_thread_t *p_intf, HWND hwnd, Interface *_p_main_interface );
virtual ~Timer();
void Notify( void );
private:
intf_thread_t *p_intf;
Interface *p_main_interface;
//Interface *p_main_interface;
int i_old_playing_status;
int i_old_rate;
};
/* Menus */
void RefreshSettingsMenu( intf_thread_t *_p_intf, HMENU hMenu );
void RefreshAudioMenu( intf_thread_t *_p_intf, HMENU hMenu );
void RefreshVideoMenu( intf_thread_t *_p_intf, HMENU hMenu );
void RefreshNavigMenu( intf_thread_t *_p_intf, HMENU hMenu );
void RefreshMenu( intf_thread_t *, vector<MenuItemExt*> *, HMENU, int,
char **, vlc_object_t **, int );
int wce_GetMenuItemCount( HMENU );
void CreateMenuItem( intf_thread_t *, vector<MenuItemExt*> *, HMENU, char *,
vlc_object_t *, int * );
HMENU CreateChoicesMenu( intf_thread_t *, vector<MenuItemExt*> *, char *,
vlc_object_t *, int * );
void OnMenuEvent( intf_thread_t *, int );
/*****************************************************************************
* A small helper class which encapsulate wxMenuitem with some other useful
* things.
*****************************************************************************/
class MenuItemExt
{
public:
/* Constructor */
MenuItemExt( intf_thread_t *_p_intf, int _id, char *_psz_var,
vlc_object_t * p_object, vlc_value_t _val, int _i_val_type );
virtual ~MenuItemExt();
static void ClearList( vector<MenuItemExt*> * );
int id;
intf_thread_t *p_intf;
char *psz_var;
int i_val_type;
vlc_object_t * p_object;
vlc_value_t val;
private:
};
/* Preferences Dialog */
/* Preferences Dialog */
class PrefsTreeCtrl;
class PrefsDialog: public CBaseWindow
{
public:
/* Constructor */
PrefsDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~PrefsDialog(){};
protected:
/* Event handlers (these functions should _not_ be virtual) */
void OnOk( void );
/*void OnCancel( UINT event );
void OnSave( UINT event );
void OnResetAll( UINT event );
void OnAdvanced( UINT event );*/
HWND save_button;
HWND reset_button;
HWND advanced_checkbox;
HWND advanced_label;
PrefsTreeCtrl *prefs_tree;
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
};
/*****************************************************************************
* A small helper function for utf8 <-> unicode conversions
*****************************************************************************/
#ifdef UNICODE
extern wchar_t pwsz_mbtow_wince[2048];
extern char psz_wtomb_wince[2048];
static inline wchar_t *_FROMMB( const char *psz_in )
{
mbstowcs( pwsz_mbtow_wince, psz_in, 2048 );
pwsz_mbtow_wince[2048-1] = 0;
return pwsz_mbtow_wince;
}
static inline char *_TOMB( const wchar_t *pwsz_in )
{
wcstombs( psz_wtomb_wince, pwsz_in, 2048 );
psz_wtomb_wince[2048-1] = 0;
return psz_wtomb_wince;
}
#else
# define _FROMMB(a) a
# define _TOMB(a) a
#endif
/*****************************************************************************
* Misc definitions (mainly from aygshell.h)
*****************************************************************************/
#define _WIN32_IE 0x0500
#define SHFS_SHOWSIPBUTTON 0x0004
#define SHFS_HIDESIPBUTTON 0x0008
#define SHIDIM_FLAGS 0x0001
#define SHIDIF_DONEBUTTON 0x0001
#define SHIDIF_SIPDOWN 0x0008
#define SHIDIF_FULLSCREENNOMENUBAR 0x0010
#define SHCMBF_HMENU 0x0010
#define SHCMBF_EMPTYBAR 0x0001
#define GN_CONTEXTMENU 1000
#define SHRG_RETURNCMD 0x0001
#define SHRG_NOTIFYPARENT 0x0002
#define SHCMBM_GETSUBMENU (WM_USER + 401)
#define SHCMBM_GETMENU (WM_USER + 402)
#ifndef TBSTYLE_NO_DROPDOWN_ARROW
#define TBSTYLE_NO_DROPDOWN_ARROW 0x0080
#endif
#define lstrlenW wcslen
#define SHGetMenu(hwnd) \
(HMENU)SendMessage((hwnd), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0)
#define TrackPopupMenu(hm,u,x,y,r,hw,p) \
TrackPopupMenuEx((hm),(u),(x),(y),(hw),0)
extern "C" {
typedef struct tagSHMENUBARINFO
{
DWORD cbSize;
HWND hwndParent;
DWORD dwFlags;
UINT nToolBarId;
HINSTANCE hInstRes;
int nBmpId;
int cBmpImages;
HWND hwndMB;
COLORREF clrBk;
} SHMENUBARINFO, *PSHMENUBARINFO;
BOOL SHCreateMenuBar( SHMENUBARINFO *pmbi );
BOOL SHFullScreen(HWND hwndRequester, DWORD dwState);
typedef struct tagSHINITDLGINFO
{
DWORD dwMask;
HWND hDlg;
DWORD dwFlags;
} SHINITDLGINFO, *PSHINITDLGINFO;
BOOL SHInitDialog(PSHINITDLGINFO pshidi);
typedef struct tagNMRGINFO
{
NMHDR hdr;
POINT ptAction;
DWORD dwItemSpec;
} NMRGINFO, *PNMRGINFO;
BOOL WINAPI CommandBar_InsertMenubarEx(HWND, HINSTANCE, LPTSTR, WORD);
typedef struct tagSHRGI
{
DWORD cbSize;
HWND hwndClient;
POINT ptDown;
DWORD dwFlags;
} SHRGINFO, *PSHRGINFO;
DWORD SHRecognizeGesture(SHRGINFO *shrg);
typedef enum tagSIPSTATE
{
SIP_UP = 0,
SIP_DOWN,
SIP_FORCEDOWN,
SIP_UNCHANGED,
SIP_INPUTDIALOG,
} SIPSTATE;
BOOL SHSipPreference(HWND, SIPSTATE);
BOOL SHSipInfo(UINT, UINT, PVOID, UINT);
typedef struct
{
DWORD cbSize;
DWORD fdwFlags;
RECT rcVisibleDesktop;
RECT rcSipRect;
DWORD dwImDataSize;
VOID *pvImData;
} SIPINFO;
}
#if defined( WIN32 ) && !defined( UNDER_CE )
# define SHFullScreen(a,b)
# define SHInitDialog(a)
# define SHCreateMenuBar(a) 1
# define SHRecognizeGesture(a) 0
# define SHSipPreference(a,b)
# define SHSipInfo(a,b,c,d) 0
#endif
#endif //WINCE_RESOURCE
#define IDD_ABOUT 101
#define IDI_ICON1 102
#define IDB_BITMAP1 103
#define IDB_BITMAP2 111
#define IDR_MENUBAR1 113
#define IDD_FILEINFO 118
#define IDD_DUMMY 118
#define IDD_MESSAGES 119
#define IDR_MENUBAR 120
#define IDR_MENUBAR2 121
#define IDD_PLAYLIST 122
#define IDB_BITMAP3 123
#define IDD_ITEMINFO 124
#define IDCLEAR 1001
#define IDSAVEAS 1002
#define ID_FILE 40028
#define ID_VIEW 40030
#define ID_SETTINGS 40032
#define ID_AUDIO 40034
#define ID_EMPTY 40034
#define ID_VIDEO 40036
#define ID_NAVIGATION 40038
#define IDM_FILE 40042
#define IDM_VIEW 40044
#define IDM_SETTINGS 40046
#define IDM_AUDIO 40048
#define IDM_VIDEO 40050
#define IDM_NAVIGATION 40053
#define ID_FILE_QUICKOPEN 40057
#define ID_FILE_OPENFILE 40058
#define ID_FILE_OPENDIR 40059
#define ID_FILE_OPENNET 40060
#define ID_FILE_EXIT 40061
#define ID_VIEW_PLAYLIST 40063
#define ID_VIEW_MESSAGES 40064
#define ID_VIEW_MEDIAINFO 40065
#define ID_VIEW_STREAMINFO 40066
#define ID_PREFERENCES 40071
#define ID_FILE_ABOUT 40069
#define IDM_MANAGE 40087
#define IDM_SORT 40088
#define IDM_SEL 40089
#define ID_SORT_AUTHOR 40091
#define ID_SORT_RAUTHOR 40092
#define ID_SORT_SHUFFLE 40095
#define ID_SEL_INVERT 40096
#define ID_SEL_DELETE 40097
#define ID_SEL_SELECTALL 40098
#define ID_SEL_ENABLE 40100
#define ID_SEL_DISABLE 40101
#define ID_SORT_TITLE 40102
#define ID_SORT_RTITLE 40103
#define ID_MANAGE_ADDFILE 40104
#define ID_MANAGE_ADDDIRECTORY 40105
#define ID_MANAGE_ADDMRL 40106
#define ID_MANAGE_OPENPL 40107
#define ID_MANAGE_SAVEPL 40108
#define StopStream_Event 57601
#define PlayStream_Event 57602
#define PrevStream_Event 57603
#define NextStream_Event 57604
#define SlowStream_Event 57605
#define FastStream_Event 57606
//Microsoft Developer Studio generated resource script.
//
#define WINCE_RESOURCE
#include "wince.h"
#if !defined(UNDER_CE)
#define UNDER_CE _WIN32_WCE
#endif
#if !defined(_WIN32_WCE)
#define _WIN32_WCE UNDER_CE
#endif
#define _WIN32_IE 0x0501
#include <commctrl.h>
#ifdef RC_INVOKED
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
#include "winuser.h" // extract from windows header
#endif
#endif
/////////////////////////////////////////////////////////////////////////////
//
// Menubar
//
#if defined(UNDER_CE) // Menus are dynamically built on Win32
IDR_MENUBAR MENU DISCARDABLE
BEGIN
POPUP "File"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
POPUP "View"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
POPUP "Settings"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
POPUP "Audio"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
POPUP "Video"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
POPUP "Nav"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
END
IDR_MENUBAR2 MENU DISCARDABLE
BEGIN
POPUP "Manage"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
POPUP "Sort"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
POPUP "Selection"
BEGIN
MENUITEM "Empty", ID_EMPTY, GRAYED
END
END
#endif
/////////////////////////////////////////////////////////////////////////////
//
// Data
//
IDR_MENUBAR RCDATA DISCARDABLE
BEGIN
IDR_MENUBAR, 6,
I_IMAGENONE, IDM_FILE, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_FILE, IDM_FILE, 0,
I_IMAGENONE, IDM_VIEW, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_VIEW, IDM_VIEW, 1,
I_IMAGENONE, IDM_SETTINGS, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_SETTINGS, IDM_SETTINGS, 2,
I_IMAGENONE, IDM_AUDIO, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_AUDIO, IDM_AUDIO, 3,
I_IMAGENONE, IDM_VIDEO, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_VIDEO, IDM_VIDEO, 4,
I_IMAGENONE, IDM_NAVIGATION, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_NAVIGATION, IDM_NAVIGATION, 5
END
IDR_MENUBAR2 RCDATA DISCARDABLE
BEGIN
IDR_MENUBAR2, 3,
I_IMAGENONE, IDM_MANAGE, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_MANAGE, IDM_MANAGE, 0,
I_IMAGENONE, IDM_SORT, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_SORT, IDM_SORT, 1,
I_IMAGENONE, IDM_SEL, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDM_SEL, IDM_SEL, 2
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDM_FILE "File"
IDM_VIEW "View"
IDM_SETTINGS "Settings"
IDM_AUDIO "Audio"
IDM_VIDEO "Video"
IDM_NAVIGATION "Navigation"
END
STRINGTABLE DISCARDABLE
BEGIN
IDM_MANAGE "Manage"
IDM_SORT "Sort"
IDM_SEL "Selection"
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
#ifdef UNDER_CE
IDI_ICON1 ICON DISCARDABLE "bitmaps/vlc16x16.ico"
#else
IDI_ICON1 ICON DISCARDABLE "bitmaps\\vlc16x16.ico"
#endif
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
#ifdef UNDER_CE
IDB_BITMAP1 BITMAP DISCARDABLE "bitmaps/toolbar1.bmp"
IDB_BITMAP2 BITMAP DISCARDABLE "bitmaps/toolbar2.bmp"
IDB_BITMAP3 BITMAP DISCARDABLE "bitmaps/toolbar3.bmp"
#else
IDB_BITMAP1 BITMAP DISCARDABLE "bitmaps\\toolbar1.bmp"
IDB_BITMAP2 BITMAP DISCARDABLE "bitmaps\\toolbar2.bmp"
IDB_BITMAP3 BITMAP DISCARDABLE "bitmaps\\toolbar3.bmp"
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment