/*****************************************************************************
* open.cpp : WinCE gui plugin for VLC
*****************************************************************************
- * Copyright (C) 2000-2004 VideoLAN
+ * Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
-#include <string.h> /* strerror() */
-#include <stdio.h>
#include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_interface.h>
#include "wince.h"
-#include <winuser.h>
-#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
+#include <shlobj.h>
/*****************************************************************************
* Event Table.
/*****************************************************************************
* 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++ )
+ {
+ 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:
+FUNCTION:
WndProc
-PURPOSE:
+PURPOSE:
Processes messages sent to the main window.
-
+
***********************************************************************/
LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
SHINITDLGINFO shidi;
- SHMENUBARINFO mbi;
- INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
+ 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 );
tcItem.pszText = _T("Network");
TabCtrl_InsertItem( notebook, 1, &tcItem );
- switch( i_current_access_method )
+ switch( i_access )
{
case FILE_ACCESS:
TabCtrl_SetCurSel( notebook, 0 );
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 )
OnSubsFileSettings( hwnd );
} else if( (HWND)lp == browse_button )
{
- SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
OnFileBrowse();
- }
+ }
break;
}
if( HIWORD(wp) == EN_CHANGE )
break;
}
- return FALSE;
+ return DefWindowProc( hwnd, msg, wp, 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(""),
}
void OpenDialog::NetPanel( HWND hwnd )
-{
+{
INITCOMMONCONTROLSEX ic;
TCHAR psz_text[256];
{ _T("RTSP"), 30 }
};
- RECT rc;
+ RECT rc;
GetWindowRect( notebook, &rc);
/* UDP/RTP row */
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,
void OpenDialog::UpdateMRL()
{
- UpdateMRL( i_current_access_method );
+ UpdateMRL( i_access );
}
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 )
{
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 )
{
SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
- i_current_access_method = NET_ACCESS;
+ i_access = NET_ACCESS;
}
UpdateMRL();
char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
ComboBox_AddString( mrl_combo, psz_text );
- if( ComboBox_GetCount( mrl_combo ) > 10 )
+ if( ComboBox_GetCount( mrl_combo ) > 10 )
ComboBox_DeleteString( mrl_combo, 0 );
ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
}
}
- playlist_AddItem( p_playlist, p_item,
- PLAYLIST_APPEND, PLAYLIST_END );
if( b_start )
{
- playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
+ playlist_AddItem( p_playlist, p_item,
+ PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END );
+ }
+ else
+ {
+ playlist_AddItem( p_playlist, p_item,
+ PLAYLIST_APPEND, PLAYLIST_END );
}
}
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( GetOpenFileName((LPOPENFILENAME) &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.
*****************************************************************************/
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( 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,
SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
-
+
UpdateMRL( NET_ACCESS );
}
{
/* 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();