Commit 39c68369 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wince: added dialogs provider + another massive cleanup + updates.

parent 23584f31
......@@ -6,6 +6,7 @@ SOURCES_wince = \
wince.cpp \
wince.h \
interface.cpp \
dialogs.cpp \
menus.cpp \
open.cpp \
playlist.cpp \
......
/*****************************************************************************
* dialogs.cpp : WinCE plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2005 VideoLAN
* $Id: dialogs.cpp 10101 2005-03-02 16:47:31Z robux4 $
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/aout.h>
#include <vlc/intf.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 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 */
if( p_open_dialog ) delete p_open_dialog;
if( p_playlist_dialog ) delete p_playlist_dialog;
if( p_messages_dialog ) delete p_messages_dialog;
if( p_fileinfo_dialog ) delete p_fileinfo_dialog;
if( p_prefs_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;
}
return DefWindowProc( hwnd, msg, wp, lp );
}
void DialogsProvider::OnIdle( void )
{
/* Update the log window */
if( p_messages_dialog ) p_messages_dialog->UpdateLog();
/* 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::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 );
}
if( p_arg->psz_title ) free( p_arg->psz_title );
if( p_arg->psz_extensions ) 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("All (*.*)\0*.*\0");
playlist_t *p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
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 );
}
vlc_object_release( p_playlist );
}
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 = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
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 );
}
p_malloc->Free( pidl );
}
error:
if( p_malloc) p_malloc->Release();
if( p_playlist ) vlc_object_release( p_playlist );
#ifdef UNDER_CE
FreeLibrary( ceshell_dll );
#endif
}
......@@ -42,11 +42,11 @@
/*****************************************************************************
* Constructor.
*****************************************************************************/
FileInfo::FileInfo( intf_thread_t *_p_intf, HINSTANCE _hInst )
FileInfo::FileInfo( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
p_intf = _p_intf;
hInst = _hInst;
hwnd_fileinfo = hwndTV = NULL;
}
......@@ -87,7 +87,7 @@ BOOL FileInfo::CreateTreeView(HWND hwnd)
// Be sure that the tree view actually was created.
if( !hwndTV ) return FALSE;
UpdateFileInfo( hwndTV );
UpdateFileInfo();
return TRUE;
}
......@@ -101,7 +101,7 @@ PURPOSE:
Update the TreeView with file information.
***********************************************************************/
void FileInfo::UpdateFileInfo(HWND hwnd)
void FileInfo::UpdateFileInfo()
{
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};
......@@ -130,7 +130,7 @@ void FileInfo::UpdateFileInfo(HWND hwnd)
tvins.hParent = TVI_ROOT;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
hPrevRootItem = hPrev;
......@@ -150,7 +150,7 @@ void FileInfo::UpdateFileInfo(HWND hwnd)
tvins.hParent = hPrevRootItem;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
hPrevLev2Item = hPrev;
......@@ -170,14 +170,14 @@ void FileInfo::UpdateFileInfo(HWND hwnd)
tvins.hParent = hPrevLev2Item;
// Add the item to the tree-view control.
hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
}
TreeView_Expand( hwnd, hPrevLev2Item, TVE_EXPANDPARTIAL |TVE_EXPAND );
TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND );
}
vlc_mutex_unlock( &p_input->input.p_item->lock );
TreeView_Expand( hwnd, hPrevRootItem, TVE_EXPANDPARTIAL |TVE_EXPAND );
TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND );
return;
}
......@@ -212,6 +212,11 @@ LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_COMMAND:
if ( LOWORD(wp) == IDOK )
{
......
......@@ -33,12 +33,9 @@
#include "wince.h"
#include <winuser.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shlobj.h>
#define NUMIMAGES 9 // Number of buttons in the toolbar
#define IMAGEWIDTH 17 // Width of the buttons in the toolbar
......@@ -107,9 +104,7 @@ TCHAR * szToolTips[] =
*****************************************************************************/
Interface::Interface()
: hwndMain(0), hwndCB(0), hwndTB(0), hwndSlider(0), hwndLabel(0),
hwndVol(0), hwndSB(0),
fileinfo(0), messages(0), preferences(0), playlist(0),
timer(0), open(0), video(0), b_volume_hold(0)
hwndVol(0), hwndSB(0), timer(0), video(0), b_volume_hold(0)
{
}
......@@ -127,20 +122,6 @@ BOOL Interface::InitInstance( HINSTANCE hInstance, intf_thread_t *_p_intf )
hInst = hInstance; // Store instance handle in our global variable
// Register window class
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = (WNDPROC)BaseWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = NULL;
wc.hInstance = hInstance;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = _T("VLC WinCE");
if( !RegisterClass( &wc ) ) return FALSE;
int i_style = WS_VISIBLE;
#ifndef UNDER_CE
......@@ -461,67 +442,6 @@ HWND CreateStatusBar( HWND hwnd, HINSTANCE hInst )
return hwndSB;
}
/***********************************************************************
FUNCTION:
CreateDialogBox
PURPOSE:
Creates a Dialog Box.
***********************************************************************/
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 );
}
/***********************************************************************
FUNCTION:
BaseWndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
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 );
}
/***********************************************************************
FUNCTION:
WndProc
......@@ -548,60 +468,28 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
video = CreateVideoWindow( p_intf, hwnd );
timer = new Timer( p_intf, hwnd, this );
// Hide the SIP button (WINCE only)
SetForegroundWindow( hwnd );
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
break;
case WM_COMMAND:
switch( GET_WM_COMMAND_ID(wp,lp) )
{
case ID_FILE_QUICKOPEN:
OnOpenFileSimple();
break;
case ID_FILE_OPENFILE:
open = new OpenDialog( p_intf, hInst, FILE_ACCESS,
ID_FILE_OPENFILE, OPEN_NORMAL );
CreateDialogBox( hwnd, open );
delete open;
break;
case ID_FILE_OPENDIR:
OnOpenDirectory();
break;
case ID_FILE_OPENNET:
open = new OpenDialog( p_intf, hInst, NET_ACCESS, ID_FILE_OPENNET,
OPEN_NORMAL );
CreateDialogBox( hwnd, open );
delete open;
break;
case PlayStream_Event:
OnPlayStream();
break;
case StopStream_Event:
OnStopStream();
break;
case PrevStream_Event:
OnPrevStream();
break;
case NextStream_Event:
OnNextStream();
case ID_VIEW_STREAMINFO:
case ID_VIEW_MESSAGES:
case ID_VIEW_PLAYLIST:
case ID_PREFERENCES:
OnShowDialog( GET_WM_COMMAND_ID(wp,lp) );
break;
case SlowStream_Event:
OnSlowStream();
break;
case FastStream_Event:
OnFastStream();
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:
{
......@@ -620,30 +508,6 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
SendMessage( hwnd, WM_CLOSE, 0, 0 );
break;
case ID_VIEW_STREAMINFO:
fileinfo = new FileInfo( p_intf, hInst );
CreateDialogBox( hwnd, fileinfo );
delete fileinfo;
break;
case ID_VIEW_MESSAGES:
messages = new Messages( p_intf, hInst );
CreateDialogBox( hwnd, messages );
delete messages;
break;
case ID_VIEW_PLAYLIST:
playlist = new Playlist( p_intf, hInst );
CreateDialogBox( hwnd, playlist );
delete playlist;
break;
case ID_PREFERENCES:
preferences = new PrefsDialog( p_intf, hInst );
CreateDialogBox( hwnd, preferences );
delete preferences;
break;
default:
OnMenuEvent( p_intf, GET_WM_COMMAND_ID(wp,lp) );
// we should test if it is a menu command
......@@ -685,14 +549,17 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
RefreshNavigMenu( p_intf, menu_navigation );
/* Fall through */
case WM_ENTERMENULOOP:
case WM_KILLFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
case WM_ENTERMENULOOP:
if( video && video->hWnd )
SendMessage( video->hWnd, WM_KILLFOCUS, 0, 0 );
break;
case WM_EXITMENULOOP:
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;
......@@ -737,117 +604,25 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
return DefWindowProc( hwnd, msg, wp, lp );
}
void Interface::OnOpenFileSimple( void )
void Interface::OnShowDialog( int i_dialog_event )
{
OPENFILENAME ofn;
TCHAR DateiName[80+1] = _T("\0");
static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
playlist_t *p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist == NULL ) return;
int i_id;
memset( &ofn, 0, sizeof(OPENFILENAME) );
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwndMain;
ofn.hInstance = hInst;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = (LPTSTR)DateiName;
ofn.nMaxFile = 80;
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 ) )
switch( i_dialog_event )
{
char *psz_filename = _TOMB(ofn.lpstrFile);
playlist_Add( p_playlist, psz_filename, psz_filename,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
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;
}
vlc_object_release( p_playlist );
}
void Interface::OnOpenDirectory( void )
{
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 = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist ) goto error;
memset( &bi, 0, sizeof(BROWSEINFO) );
bi.hwndOwner = hwndMain;
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 | PLAYLIST_GO, PLAYLIST_END );
}
p_malloc->Free( pidl );
}
error:
if( p_malloc) p_malloc->Release();
if( p_playlist ) vlc_object_release( p_playlist );
#ifdef UNDER_CE
FreeLibrary( ceshell_dll );
#endif
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 )
......@@ -894,7 +669,7 @@ void Interface::OnPlayStream( void )
{
/* If the playlist is empty, open a file requester instead */
vlc_object_release( p_playlist );
OnOpenFileSimple();
OnShowDialog( ID_FILE_QUICKOPEN );
}
}
......
......@@ -46,13 +46,12 @@
/*****************************************************************************
* Constructor.
*****************************************************************************/
ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
HINSTANCE _hInst,
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_intf = _p_intf;
hInst = _hInst;
p_item = _p_item;
}
......@@ -154,6 +153,11 @@ LRESULT ItemInfoDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_COMMAND:
if( LOWORD(wp) == IDOK )
{
......
......@@ -51,23 +51,25 @@
* Constructor.
*****************************************************************************/
Messages::Messages( intf_thread_t *_p_intf, HINSTANCE _hInst )
Messages::Messages( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
p_intf = _p_intf;
hInst = _hInst;
hListView = NULL;
b_verbose = VLC_FALSE;
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 );
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
Processes messages sent to the main window.
***********************************************************************/
LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
......@@ -80,37 +82,45 @@ LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
switch( msg )
{
case WM_INITDIALOG:
case WM_CREATE:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwnd;
SHInitDialog( &shidi );
RECT rect;
GetClientRect( hwnd, &rect );
hListView = CreateWindow( WC_LISTVIEW, NULL,
WS_VISIBLE | WS_CHILD | LVS_REPORT |
LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL |
WS_BORDER /*| LVS_NOCOLUMNHEADER */,
rect.left + 20, rect.top + 50,
rect.right - rect.left - ( 2 * 20 ),
rect.bottom - rect.top - 50 - 20,
WS_BORDER | LVS_NOCOLUMNHEADER, 0, 0, 0, 0,
hwnd, NULL, hInst, NULL );
ListView_SetExtendedListViewStyle( hListView, LVS_EX_FULLROWSELECT );
LVCOLUMN lv;
lv.mask = LVCF_WIDTH | LVCF_FMT | LVCF_TEXT;
lv.mask = LVCF_FMT;
lv.fmt = LVCFMT_LEFT ;
GetClientRect( hwnd, &rect );
lv.cx = rect.right - rect.left;
lv.pszText = _T("Messages");
lv.cchTextMax = 9;
ListView_InsertColumn( hListView, 0, &lv);
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;
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_TIMER:
......@@ -118,14 +128,14 @@ LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
break;
case WM_CLOSE:
EndDialog( hwnd, LOWORD( wp ) );
break;
Show( FALSE );
return TRUE;
case WM_COMMAND:
switch( LOWORD(wp) )
{
case IDOK:
EndDialog( hwnd, LOWORD( wp ) );
Show( FALSE );
break;
case IDCLEAR:
......@@ -167,8 +177,6 @@ LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
CloseHandle(fichier);
}
}
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
break;
default:
......@@ -179,7 +187,7 @@ LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
break;
}
return FALSE;
return DefWindowProc( hwnd, msg, wp, lp );
}
void Messages::UpdateLog()
......@@ -197,29 +205,31 @@ void Messages::UpdateLog()
for( i_start = p_sub->i_start; i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
if( !b_verbose && VLC_MSG_ERR != p_sub->p_msg[i_start].i_type )
continue;
/* Append all messages to log window */
debug = p_sub->p_msg[i_start].psz_module;
switch( p_sub->p_msg[i_start].i_type )
{
case VLC_MSG_INFO:
debug += ": ";
break;
case VLC_MSG_ERR:
debug += " error: ";
case VLC_MSG_INFO:
if( p_intf->p_libvlc->i_verbose < 0 ) continue;
break;
case VLC_MSG_WARN:
debug += " warning: ";
if( p_intf->p_libvlc->i_verbose < 1 ) continue;
break;
case VLC_MSG_DBG:
default:
debug += " debug: ";
if( p_intf->p_libvlc->i_verbose < 2 ) continue;
break;
}
/* Append all messages to log window */
debug = p_sub->p_msg[i_start].psz_module;
switch( p_sub->p_msg[i_start].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 += p_sub->p_msg[i_start].psz_msg;
......
......@@ -33,11 +33,10 @@
#include "wince.h"
#include <winuser.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shlobj.h>
/*****************************************************************************
* Event Table.
......@@ -73,15 +72,13 @@ enum
/*****************************************************************************
* Constructor.
*****************************************************************************/
OpenDialog::OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
int _i_access_method, int _i_arg, int _i_method )
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 */
p_intf = _p_intf;
hInst = _hInst;
i_current_access_method = _i_access_method;
i_access = _i_access;
i_open_arg = _i_arg;
i_method = _i_method;
for( int i = 0; i < 4; i++ )
{
......@@ -94,6 +91,11 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
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 );
}
/***********************************************************************
......@@ -108,36 +110,18 @@ PURPOSE:
LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
SHMENUBARINFO mbi;
INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
RECT rcClient;
TC_ITEM tcItem;
switch( msg )
{
case WM_INITDIALOG:
case WM_CREATE:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
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 );
......@@ -183,7 +167,7 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
tcItem.pszText = _T("Network");
TabCtrl_InsertItem( notebook, 1, &tcItem );
switch( i_current_access_method )
switch( i_access )
{
case FILE_ACCESS:
TabCtrl_SetCurSel( notebook, 0 );
......@@ -200,14 +184,19 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
break;
case WM_CLOSE:
EndDialog( hwnd, LOWORD( wp ) );
Show( FALSE );
return TRUE;
case WM_SETFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
SHSipPreference( hwnd, SIP_DOWN );
break;
case WM_COMMAND:
if( LOWORD(wp) == IDOK )
{
OnOk();
EndDialog( hwnd, LOWORD( wp ) );
Show( FALSE );
break;
}
if( HIWORD(wp) == BN_CLICKED )
......@@ -232,7 +221,6 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
OnSubsFileSettings( hwnd );
} else if( (HWND)lp == browse_button )
{
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
OnFileBrowse();
}
break;
......@@ -273,7 +261,7 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
break;
}
return FALSE;
return DefWindowProc( hwnd, msg, wp, lp );
}
/*****************************************************************************
......@@ -281,8 +269,8 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
*****************************************************************************/
void OpenDialog::FilePanel( HWND hwnd )
{
RECT rc;
GetWindowRect( notebook, &rc);
RECT rc;
GetWindowRect( notebook, &rc );
/* Create browse file line */
file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
......@@ -325,7 +313,7 @@ void OpenDialog::FilePanel( HWND hwnd )
}
void OpenDialog::NetPanel( HWND hwnd )
{
{
INITCOMMONCONTROLSEX ic;
TCHAR psz_text[256];
......@@ -343,7 +331,7 @@ void OpenDialog::NetPanel( HWND hwnd )
{ _T("RTSP"), 30 }
};
RECT rc;
RECT rc;
GetWindowRect( notebook, &rc);
/* UDP/RTP row */
......@@ -474,7 +462,7 @@ void OpenDialog::NetPanel( HWND hwnd )
void OpenDialog::UpdateMRL()
{
UpdateMRL( i_current_access_method );
UpdateMRL( i_access );
}
void OpenDialog::UpdateMRL( int i_access_method )
......@@ -483,7 +471,7 @@ void OpenDialog::UpdateMRL( int i_access_method )
TCHAR psz_text[2048];
char psz_tmp[256];
i_current_access_method = i_access_method;
i_access = i_access_method;
switch( i_access_method )
{
......@@ -567,7 +555,7 @@ void OpenDialog::OnPageChange()
SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
i_current_access_method = FILE_ACCESS;
i_access = FILE_ACCESS;
}
else if ( TabCtrl_GetCurSel( notebook ) == 1 )
{
......@@ -599,7 +587,7 @@ void OpenDialog::OnPageChange()
SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
i_current_access_method = NET_ACCESS;
i_access = NET_ACCESS;
}
UpdateMRL();
......@@ -675,53 +663,44 @@ void OpenDialog::OnFilePanelChange()
UpdateMRL( FILE_ACCESS );
}
void OpenDialog::OnFileBrowse()
{
OPENFILENAME ofn;
static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
TCHAR psz_file[PATH_MAX] = _T("\0");
TCHAR psz_tmp[PATH_MAX+2] = _T("\0");
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.hInstance = hInst;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = psz_file;
ofn.nMaxFile = PATH_MAX;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 40;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = _T("Open File");
ofn.Flags = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0L;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
if( GetOpenFile( &ofn ) )
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( _tcschr( ofn.lpstrFile, _T(' ') ) )
if( strchr( p_arg->psz_results[0], ' ' ) )
{
_tcscat( psz_tmp, _T("\"") );
_tcscat( psz_tmp, ofn.lpstrFile );
_tcscat( psz_tmp, _T("\"") );
strcat( psz_tmp, "\"" );
strcat( psz_tmp, p_arg->psz_results[0] );
strcat( psz_tmp, "\"" );
}
else _tcscat( psz_tmp, ofn.lpstrFile );
else strcat( psz_tmp, p_arg->psz_results[0] );
SetWindowText( file_combo, psz_tmp );
ComboBox_AddString( file_combo, psz_tmp );
if( ComboBox_GetCount( file_combo ) > 10 )
ComboBox_DeleteString( file_combo, 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 );
UpdateMRL( FILE_ACCESS );
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.
*****************************************************************************/
......@@ -818,7 +797,7 @@ void OpenDialog::OnSubsFileSettings( HWND hwnd )
{
/* Show/hide the open dialog */
SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, hInst );
SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
CreateDialogBox( hwnd, subsfile_dialog );
subsfile_mrl.clear();
......
......@@ -36,10 +36,6 @@
#include <commctrl.h>
#include <commdlg.h>
#ifndef NMAXFILE
#define NMAXFILE 512 // at least 256
#endif
#ifndef TEXTMAXBUF
#define TEXTMAXBUF 512 // at least 500
#endif
......@@ -123,13 +119,12 @@ TCHAR * szToolTips2[] =
/*****************************************************************************
* Constructor.
*****************************************************************************/
Playlist::Playlist( intf_thread_t *_p_intf, HINSTANCE _hInst )
Playlist::Playlist( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
p_intf = _p_intf;
hInst = _hInst;
hListView = NULL;
hListView = NULL;
i_title_sorted = 1;
i_author_sorted = 1;
......@@ -336,8 +331,6 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
ListView_InsertColumn( hListView, 2, &lv);
SetTimer( hwnd, 1, 500 /*milliseconds*/, NULL );
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
break;
case WM_TIMER:
......@@ -348,6 +341,11 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHSipPreference( hwnd, SIP_DOWN );
SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
break;
case WM_COMMAND:
switch( LOWORD(wp) )
{
......@@ -361,29 +359,23 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
break;
case ID_MANAGE_SAVEPL:
SHFullScreen( GetForegroundWindow(), SHFS_SHOWSIPBUTTON );
OnSave();
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
break;
case ID_MANAGE_ADDFILE:
SHFullScreen( GetForegroundWindow(), SHFS_SHOWSIPBUTTON );
OnAddFile();
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_SIMPLE,
0, 0 );
b_need_update = VLC_TRUE;
break;
case ID_MANAGE_ADDDIRECTORY:
SHFullScreen( GetForegroundWindow(), SHFS_SHOWSIPBUTTON );
OnAddFile();
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_DIRECTORY,
0, 0 );
b_need_update = VLC_TRUE;
break;
case ID_MANAGE_ADDMRL:
SHFullScreen( GetForegroundWindow(), SHFS_SHOWSIPBUTTON );
OnAddMRL();
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE, 0, 0 );
b_need_update = VLC_TRUE;
break;
......@@ -393,9 +385,7 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
break;
case Infos_Event:
SHFullScreen( GetForegroundWindow(), SHFS_SHOWSIPBUTTON );
OnPopupInfo( hwnd );
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
b_need_update = VLC_TRUE;
break;
......@@ -474,7 +464,6 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
case PopupInfo_Event:
OnPopupInfo( hwnd );
SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
b_need_update = VLC_TRUE;
break;
......@@ -579,6 +568,15 @@ void Playlist::HandlePopupMenu( HWND hwnd, POINT point )
DestroyMenu( hMenuTrackPopup );
}
/**********************************************************************
* Show the playlist
**********************************************************************/
void Playlist::ShowPlaylist( bool b_show )
{
if( b_show ) Rebuild();
Show( b_show );
}
/**********************************************************************
* Update the playlist
**********************************************************************/
......@@ -703,146 +701,81 @@ void Playlist::DeleteItem( int item )
/**********************************************************************
* I/O functions
**********************************************************************/
void Playlist::OnOpen()
static void OnOpenCB( intf_dialog_args_t *p_arg )
{
OPENFILENAME ofn;
TCHAR DateiName[80+1] = _T("\0");
static TCHAR szFilter[] = _T("All playlists (*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u)\0*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u\0");
playlist_t *p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist == NULL ) return;
intf_thread_t *p_intf = (intf_thread_t *)p_arg->p_arg;
memset( &ofn, 0, sizeof(OPENFILENAME) );
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.hInstance = hInst;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = (LPTSTR) DateiName;
ofn.nMaxFile = 80;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 40;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = _T("Open playlist");
ofn.Flags = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0L;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
if( GetOpenFileName((LPOPENFILENAME)&ofn) )
if( p_arg->i_results && p_arg->psz_results[0] )
{
playlist_Import( p_playlist, _TOMB(ofn.lpstrFile) );
}
playlist_t * p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
vlc_object_release( p_playlist );
if( p_playlist )
{
playlist_Import( p_playlist, p_arg->psz_results[0] );
}
if( p_playlist ) vlc_object_release( p_playlist );
}
}
void Playlist::OnSave()
void Playlist::OnOpen()
{
TCHAR szFile[NMAXFILE] = _T("\0");
OPENFILENAME ofn;
TCHAR psz_filters[1000];
char *psz_filters ="All playlists|*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u";
struct
{
char *psz_desc;
char *psz_filter;
char *psz_module;
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) );
} formats[] =
{ { "M3U file", "*.m3u", "export-m3u" },
{ "PLS file", "*.pls", "export-pls" }
};
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;
for( int i_len = 0, i = 0; i < sizeof(formats)/sizeof(formats[0]); i++ )
{
_tcscpy( psz_filters + i_len, _FROMMB(formats[i].psz_desc) );
i_len = i_len + _tcslen( psz_filters + i_len );
psz_filters[i_len++] = '\0';
_tcscpy( psz_filters + i_len, _FROMMB(formats[i].psz_filter) );
i_len = i_len + _tcslen( psz_filters + i_len );
psz_filters[i_len++] = '\0';
if( i == sizeof(formats)/sizeof(formats[0]) -1 )
psz_filters[i_len] = '\0';
}
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
}
memset( &(ofn), 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
ofn.nMaxFile = NMAXFILE;
ofn.lpstrFilter = psz_filters;
ofn.lpstrTitle = _T("Save playlist");
ofn.Flags = OFN_HIDEREADONLY;
static void OnSaveCB( intf_dialog_args_t *p_arg )
{
intf_thread_t *p_intf = (intf_thread_t *)p_arg->p_arg;
if( GetSaveFileName( (LPOPENFILENAME)&ofn ) )
if( p_arg->i_results && p_arg->psz_results[0] )
{
playlist_t * p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist && ofn.lpstrFile )
if( p_playlist )
{
playlist_Export( p_playlist, _TOMB(ofn.lpstrFile),
formats[ofn.nFilterIndex ?
ofn.nFilterIndex - 1 : 0].psz_module );
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], psz_export );
}
if( p_playlist ) vlc_object_release( p_playlist );
}
}
void Playlist::OnAddFile()
void Playlist::OnSave()
{
// Same code as in Interface
OPENFILENAME ofn;
TCHAR DateiName[80+1] = _T("\0");
static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
memset( &ofn, 0, sizeof(OPENFILENAME) );
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.hInstance = hInst;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = (LPTSTR)DateiName;
ofn.nMaxFile = 80;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 40;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = _T("Add 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( GetOpenFileName( (LPOPENFILENAME)&ofn ) )
{
playlist_t *p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist == NULL ) return;
char *psz_filters ="M3U file|*.m3u|PLS file|*.pls";
char *psz_filename = _TOMB(ofn.lpstrFile);
playlist_Add( p_playlist, psz_filename, psz_filename,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
vlc_object_release( p_playlist );
}
}
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) );
void Playlist::OnAddMRL()
{
p_arg->psz_title = strdup( "Save playlist" );
p_arg->psz_extensions = strdup( psz_filters );
p_arg->b_save = VLC_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 );
}
/**********************************************************************
......@@ -947,7 +880,7 @@ void Playlist::ShowInfos( HWND hwnd, int i_item )
if( p_item )
{
ItemInfoDialog *iteminfo_dialog =
new ItemInfoDialog( p_intf, hInst, p_item );
new ItemInfoDialog( p_intf, this, hInst, p_item );
CreateDialogBox( hwnd, iteminfo_dialog );
UpdateItem( i_item );
delete iteminfo_dialog;
......
......@@ -142,11 +142,11 @@ public:
/*****************************************************************************
* Constructor.
*****************************************************************************/
PrefsDialog::PrefsDialog( intf_thread_t *_p_intf, HINSTANCE _hInst )
PrefsDialog::PrefsDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
p_intf = _p_intf;
hInst = _hInst;
prefs_tree = NULL;
}
......@@ -226,6 +226,10 @@ LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
break;
case WM_COMMAND:
if( LOWORD(wp) == IDOK )
{
......
......@@ -46,11 +46,10 @@
/*****************************************************************************
* Constructor.
*****************************************************************************/
SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, HINSTANCE _hInst )
SubsFileDialog::SubsFileDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
HINSTANCE h_inst )
: CBaseWindow( p_intf, p_parent, h_inst )
{
/* Initializations */
p_intf = _p_intf;
hInst = _hInst;
}
/***********************************************************************
......@@ -223,6 +222,10 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
EndDialog( hwnd, LOWORD( wp ) );
break;
case WM_SETFOCUS:
SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
break;
case WM_COMMAND:
if ( LOWORD(wp) == IDOK )
{
......@@ -278,38 +281,30 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
/*****************************************************************************
* Events methods.
*****************************************************************************/
void SubsFileDialog::OnFileBrowse()
static void OnOpenCB( intf_dialog_args_t *p_arg )
{
OPENFILENAME ofn;
TCHAR DateiName[80+1] = _T("\0");
static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.hInstance = hInst;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = (LPTSTR) DateiName;
ofn.nMaxFile = 80;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 40;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = _T("Open File");
ofn.Flags = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0L;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
if( GetOpenFile( &ofn ) )
SubsFileDialog *p_this = (SubsFileDialog *)p_arg->p_arg;
if( p_arg->i_results && p_arg->psz_results[0] )
{
SetWindowText( file_combo, ofn.lpstrFile );
ComboBox_AddString( file_combo, ofn.lpstrFile );
if( ComboBox_GetCount( file_combo ) > 10 )
ComboBox_DeleteString( file_combo, 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);
}
......@@ -197,13 +197,11 @@ LRESULT VideoWindow::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
switch( msg )
{
case WM_KILLFOCUS:
msg_Err( p_intf, "WM_KILLFOCUS1" );
if( p_vout )
vout_Control( p_vout, VOUT_SET_FOCUS, (vlc_bool_t)VLC_FALSE );
return TRUE;
case WM_SETFOCUS:
msg_Err( p_intf, "WM_SETFOCUS1" );
if( p_vout )
vout_Control( p_vout, VOUT_SET_FOCUS, (vlc_bool_t)VLC_TRUE );
return TRUE;
......
......@@ -36,8 +36,6 @@
#include "wince.h"
#include <objbase.h>
#include <commctrl.h>
#include <commdlg.h>
/*****************************************************************************
* Local prototypes.
......@@ -46,6 +44,11 @@ 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 ( intf_thread_t * );
static void ShowDialog( intf_thread_t *, int, int, intf_dialog_args_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
......@@ -62,6 +65,11 @@ vlc_module_begin();
add_bool( "wince-embed", 1, NULL,
EMBED_TEXT, EMBED_LONGTEXT, VLC_FALSE );
add_submodule();
set_description( _("WinCE dialogs provider") );
set_capability( "dialogs provider", 10 );
set_callbacks( OpenDialogs, Close );
vlc_module_end();
HINSTANCE hInstance = 0;
......@@ -113,6 +121,7 @@ static int Open( vlc_object_t *p_this )
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;
......@@ -120,19 +129,17 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->b_slider_free = 1;
p_intf->p_sys->i_slider_pos = p_intf->p_sys->i_slider_oldpos = 0;
p_intf->p_sys->GetOpenFile = 0;
p_intf->p_sys->h_gsgetfile_dll = LoadLibrary( _T("gsgetfile") );
if( p_intf->p_sys->h_gsgetfile_dll )
{
p_intf->p_sys->GetOpenFile = (BOOL (WINAPI *)(void *))
GetProcAddress( p_intf->p_sys->h_gsgetfile_dll,
_T("gsGetOpenFileName") );
}
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 );
if( !p_intf->p_sys->GetOpenFile )
p_intf->p_sys->GetOpenFile = (BOOL (WINAPI *)(void *))GetOpenFileName;
p_intf->pf_show_dialog = ShowDialog;
return VLC_SUCCESS;
return i_ret;
}
/*****************************************************************************
......@@ -156,12 +163,19 @@ static void Close( vlc_object_t *p_this )
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 );
}
// Unsuscribe to messages bank
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
if( p_intf->p_sys->h_gsgetfile_dll )
FreeLibrary( p_intf->p_sys->h_gsgetfile_dll );
// Destroy structure
free( p_intf->p_sys );
}
......@@ -170,6 +184,27 @@ static void Close( vlc_object_t *p_this )
* 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 */
if( vlc_thread_create( p_intf, "Skins Dialogs Thread",
MainLoop, 0, VLC_TRUE ) )
{
msg_Err( p_intf, "cannot create Skins Dialogs Thread" );
p_intf->pf_show_dialog = NULL;
}
}
else
{
/* The module is used in interface mode */
MainLoop( p_intf );
}
}
static void MainLoop( intf_thread_t *p_intf )
{
MSG msg;
Interface intf;
......@@ -177,12 +212,63 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->p_main_window = &intf;
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( !intf.InitInstance( hInstance, p_intf ) ) return;
if( !p_intf->pf_show_dialog )
{
/* The module is used in interface mode */
p_intf->p_sys->p_window = &intf;
/* Create/Show the interface */
if( !intf.InitInstance( hInstance, p_intf ) )
{
#ifndef UNDER_CE
/* Uninitialize OLE/COM */
CoUninitialize();
#endif
return;
}
}
/* 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 */
vlc_thread_ready( p_intf );
/* Check if we need to start playing */
if( !p_intf->pf_show_dialog && p_intf->b_play )
{
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
}
// Main message loop
while( GetMessage( &msg, NULL, 0, 0 ) > 0 )
......@@ -196,3 +282,74 @@ static void Run( intf_thread_t *p_intf )
CoUninitialize();
#endif
}
/*****************************************************************************
* 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 );
}
}
......@@ -55,6 +55,9 @@ class VideoWindow;
*****************************************************************************/
struct intf_sys_t
{
/* the parent window */
CBaseWindow *p_window;
/* special actions */
vlc_bool_t b_playing;
......@@ -85,14 +88,8 @@ struct intf_sys_t
vector<MenuItemExt*> *p_settings_menu;
VideoWindow *p_video_window;
/* GetOpenFileName replacement */
BOOL (WINAPI *GetOpenFile)(void *);
HMODULE h_gsgetfile_dll;
};
#define GetOpenFile(a) p_intf->p_sys->GetOpenFile(a)
/*****************************************************************************
* Prototypes
*****************************************************************************/
......@@ -100,7 +97,9 @@ struct intf_sys_t
class CBaseWindow
{
public:
CBaseWindow() : hWnd(0), hInst(0) {};
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
......@@ -108,6 +107,10 @@ public:
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
......@@ -116,7 +119,8 @@ protected:
HINSTANCE GetInstance () const { return hInst; }
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM ) { return 0; };
intf_thread_t *p_intf;
CBaseWindow *p_parent;
intf_thread_t *p_intf;
};
class FileInfo;
......@@ -126,6 +130,7 @@ 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 );
......@@ -154,33 +159,28 @@ public:
HMENU hPopUpMenu;
HMENU hMenu;
FileInfo *fileinfo;
Messages *messages;
PrefsDialog *preferences;
Playlist *playlist;
Timer *timer;
OpenDialog *open;
CBaseWindow *video;
protected:
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
void OnOpenFileSimple( void );
void OnOpenDirectory( void );
void OnPlayStream( void );
void OnVideoOnTop( void );
void OnShowDialog( int );
void OnSliderUpdate( int wp );
void OnChange( int wp );
void VolumeChange( int i_volume );
void VolumeUpdate( void );
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:
......@@ -197,9 +197,11 @@ class FileInfo : public CBaseWindow
{
public:
/* Constructor */
FileInfo( intf_thread_t *_p_intf, HINSTANCE _hInst );
FileInfo( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~FileInfo(){};
void UpdateFileInfo(void);
protected:
HWND hwnd_fileinfo; // handle to fileinfo window
......@@ -209,7 +211,6 @@ protected:
TCHAR szFileInfoTitle[100]; // Main window name
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
void UpdateFileInfo( HWND );
BOOL CreateTreeView( HWND );
};
......@@ -218,16 +219,16 @@ class Messages : public CBaseWindow
{
public:
/* Constructor */
Messages( intf_thread_t *_p_intf, HINSTANCE _hInst );
Messages( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~Messages(){};
void UpdateLog(void);
protected:
virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
HWND hListView;
void UpdateLog(void);
vlc_bool_t b_verbose;
};
......@@ -236,7 +237,8 @@ class ItemInfoDialog : public CBaseWindow
{
public:
/* Constructor */
ItemInfoDialog( intf_thread_t *, HINSTANCE, playlist_item_t * );
ItemInfoDialog( intf_thread_t *, CBaseWindow *,
HINSTANCE, playlist_item_t * );
virtual ~ItemInfoDialog(){};
protected:
......@@ -271,13 +273,14 @@ class OpenDialog : public CBaseWindow
{
public:
/* Constructor */
OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
int _i_access_method, int _i_arg, int _i_method );
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 );
......@@ -289,7 +292,6 @@ protected:
HWND notebook;
HWND file_combo;
HWND browse_button;
HWND subsfile_checkbox;
HWND subsfile_label;
......@@ -306,12 +308,11 @@ protected:
HWND net_addrs_label[4];
HWND net_addrs[4];
int i_current_access_method;
int i_method; /* Normal or for the stream dialog ? */
int i_open_arg;
int i_access;
int i_net_type;
void FilePanel( HWND hwnd );
void NetPanel( HWND hwnd );
......@@ -337,16 +338,16 @@ class SubsFileDialog: public CBaseWindow
{
public:
/* Constructor */
SubsFileDialog( intf_thread_t *_p_intf, HINSTANCE _hInst );
SubsFileDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~SubsFileDialog(){};
vector<string> subsfile_mrl;
HWND file_combo;
protected:
friend class OpenDialog;
HWND file_box;
HWND file_combo;
HWND browse_button;
HWND enc_box;
......@@ -372,9 +373,12 @@ class Playlist : public CBaseWindow
{
public:
/* Constructor */
Playlist( intf_thread_t *_p_intf, HINSTANCE _hInst );
Playlist( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~Playlist(){};
void UpdatePlaylist();
void ShowPlaylist( bool );
protected:
bool b_need_update;
......@@ -387,7 +391,6 @@ protected:
HWND hwndTB; // Handle to the toolbar.
HWND hListView;
void UpdatePlaylist();
void Rebuild();
void UpdateItem( int );
LRESULT ProcessCustomDraw( LPARAM lParam );
......@@ -397,8 +400,6 @@ protected:
void OnOpen();
void OnSave();
void OnAddFile();
void OnAddMRL();
void OnDeleteSelection();
void OnInvertSelection();
......@@ -431,7 +432,7 @@ class Timer
{
public:
/* Constructor */
Timer( intf_thread_t *p_intf, HWND hwnd, Interface *_p_main_interface);
Timer( intf_thread_t *p_intf, HWND hwnd, Interface *_p_main_interface );
virtual ~Timer();
void Notify( void );
......@@ -491,7 +492,7 @@ class PrefsDialog: public CBaseWindow
{
public:
/* Constructor */
PrefsDialog( intf_thread_t *_p_intf, HINSTANCE _hInst );
PrefsDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
virtual ~PrefsDialog(){};
protected:
......@@ -547,6 +548,7 @@ protected:
*****************************************************************************/
#define _WIN32_IE 0x0500
#define SHFS_SHOWSIPBUTTON 0x0004
#define SHFS_HIDESIPBUTTON 0x0008
#define SHIDIM_FLAGS 0x0001
#define SHIDIF_DONEBUTTON 0x0001
......@@ -554,7 +556,6 @@ protected:
#define SHIDIF_FULLSCREENNOMENUBAR 0x0010
#define SHCMBF_HMENU 0x0010
#define SHCMBF_EMPTYBAR 0x0001
#define SHFS_SHOWSIPBUTTON 0x0004
#define GN_CONTEXTMENU 1000
#define SHRG_RETURNCMD 0x0001
#define SHRG_NOTIFYPARENT 0x0002
......@@ -613,6 +614,29 @@ extern "C" {
} 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 )
......@@ -620,6 +644,9 @@ extern "C" {
# 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
......
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