X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fwince%2Fopen.cpp;h=b3f65e5d1f6d04b1acdab7559be8430cade138e4;hb=6ee1e193fd896ab9a4729fde14f009d9ce629815;hp=dba02a1e65e40b04dacfa854a42c99809d9a86f7;hpb=801b203b8a2f0f35717e58ef6f6403c7a22c7848;p=vlc diff --git a/modules/gui/wince/open.cpp b/modules/gui/wince/open.cpp index dba02a1e65..b3f65e5d1f 100644 --- a/modules/gui/wince/open.cpp +++ b/modules/gui/wince/open.cpp @@ -1,7 +1,7 @@ /***************************************************************************** * open.cpp : WinCE gui plugin for VLC ***************************************************************************** - * Copyright (C) 2000-2004 VideoLAN + * Copyright (C) 2000-2004 the VideoLAN team * $Id$ * * Authors: Marodon Cedric @@ -19,30 +19,21 @@ * * 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 -#include -#include +#include -#include /* malloc(), free() */ -#include -#include -using namespace std; +#include "wince.h" -#include -#include #include #include -#include - #include - -#include "wince.h" +#include /***************************************************************************** * Event Table. @@ -78,66 +69,56 @@ 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++ ) + { + 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, - PBOOL pbProcessed ) +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; - LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed ); - BOOL bWasProcessed = *pbProcessed; - *pbProcessed = TRUE; - 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.nToolBarId = IDR_DUMMYMENU; - mbi.hInstRes = hInst; - mbi.nBmpId = 0; - mbi.cBmpImages = 0; - - 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 ); @@ -158,7 +139,6 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, 0, hInst, 0 ); // No tooltips for ComboBox - label = CreateWindow( _T("STATIC"), _FROMMB(_("Alternatively, you can build an MRL " "using one of the following predefined " @@ -184,7 +164,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 ); @@ -198,48 +178,49 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, NetPanel( hwnd ); OnPageChange(); + break; + + case WM_CLOSE: + Show( FALSE ); + return TRUE; - return lResult; + case WM_SETFOCUS: + SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON ); + SHSipPreference( hwnd, SIP_DOWN ); + break; case WM_COMMAND: if( LOWORD(wp) == IDOK ) { OnOk(); - EndDialog( hwnd, LOWORD( wp ) ); - return TRUE; + Show( FALSE ); + break; } if( HIWORD(wp) == BN_CLICKED ) { if( (HWND)lp == net_radios[0] ) { OnNetTypeChange( NetRadio1_Event ); - return TRUE; } else if( (HWND)lp == net_radios[1] ) { OnNetTypeChange( NetRadio2_Event ); - return TRUE; } else if( (HWND)lp == net_radios[2] ) { OnNetTypeChange( NetRadio3_Event ); - return TRUE; } else if( (HWND)lp == net_radios[3] ) { OnNetTypeChange( NetRadio4_Event ); - return TRUE; } else if( (HWND)lp == subsfile_checkbox ) { OnSubsFileEnable(); - return TRUE; } else if( (HWND)lp == subsfile_button ) { OnSubsFileSettings( hwnd ); - return TRUE; } else if( (HWND)lp == browse_button ) { - SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON ); OnFileBrowse(); - return TRUE; - } + } + break; } if( HIWORD(wp) == EN_CHANGE ) { @@ -267,31 +248,17 @@ LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, OnFilePanelChange(); } } - - *pbProcessed = bWasProcessed; - lResult = FALSE; - return lResult; + break; case WM_NOTIFY: - if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) - { - OnPageChange(); - return TRUE; - } - - *pbProcessed = bWasProcessed; - lResult = FALSE; - return lResult; + if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange(); + break; default: - // the message was not processed - // indicate if the base class handled it - *pbProcessed = bWasProcessed; - lResult = FALSE; - return lResult; + break; } - return lResult; + return DefWindowProc( hwnd, msg, wp, lp ); } /***************************************************************************** @@ -299,8 +266,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(""), @@ -343,13 +310,13 @@ void OpenDialog::FilePanel( HWND hwnd ) } void OpenDialog::NetPanel( HWND hwnd ) -{ +{ INITCOMMONCONTROLSEX ic; - LPWSTR wUnicode; + TCHAR psz_text[256]; struct net_type { - LPWSTR szAnsi; + TCHAR *psz_text; int length; }; @@ -361,52 +328,49 @@ void OpenDialog::NetPanel( HWND hwnd ) { _T("RTSP"), 30 } }; - RECT rc; + RECT rc; GetWindowRect( notebook, &rc); /* UDP/RTP row */ - net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].szAnsi, + 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].szAnsi, + 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); + 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); - - wUnicode = new WCHAR[80]; - swprintf( wUnicode, _T("%d"), i_net_ports[0] ); - net_ports[0] = CreateWindow( _T("EDIT"), wUnicode, - 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 ); - free( wUnicode ); + 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, NULL, hInst, + 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].szAnsi, + 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].szAnsi, + 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 ); @@ -429,14 +393,12 @@ void OpenDialog::NetPanel( HWND hwnd ) i_net_ports[1] = i_net_ports[0]; - wUnicode = new WCHAR[80]; - swprintf( wUnicode, _T("%d"), i_net_ports[1] ); - net_ports[1] = CreateWindow( _T("EDIT"), wUnicode, + _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 ); - free( wUnicode ); ic.dwSize = sizeof(INITCOMMONCONTROLSEX); ic.dwICC = ICC_UPDOWN_CLASS; @@ -444,16 +406,16 @@ void OpenDialog::NetPanel( HWND hwnd ) hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS, - 0, 0, 0, 0, hwnd, NULL, hInst, + 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].szAnsi, + 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].szAnsi, + + 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, @@ -470,12 +432,12 @@ void OpenDialog::NetPanel( HWND hwnd ) rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL); - net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].szAnsi, + 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].szAnsi, + 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, @@ -497,28 +459,22 @@ void OpenDialog::NetPanel( HWND hwnd ) void OpenDialog::UpdateMRL() { - UpdateMRL( i_current_access_method ); + UpdateMRL( i_access ); } void OpenDialog::UpdateMRL( int i_access_method ) { string demux, mrltemp; + TCHAR psz_text[2048]; + char psz_tmp[256]; - int size; - BOOL bTemp; - LPSTR szAnsi; - LPWSTR wUnicode; - - i_current_access_method = i_access_method; + i_access = i_access_method; switch( i_access_method ) { case FILE_ACCESS: - //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue(); - size = GetWindowTextLength( file_combo ) + 1; - wUnicode = new WCHAR[ size ]; - GetWindowText( file_combo, wUnicode, size ); - mrltemp = _TOMB(wUnicode); + GetWindowText( file_combo, psz_text, 2048 ); + mrltemp = _TOMB(psz_text); break; case NET_ACCESS: switch( i_net_type ) @@ -528,61 +484,40 @@ void OpenDialog::UpdateMRL( int i_access_method ) if( i_net_ports[0] != config_GetInt( p_intf, "server-port" ) ) { - szAnsi = new char[50]; - sprintf( szAnsi, "@:%d", i_net_ports[0] ); - mrltemp += szAnsi; - delete [] szAnsi; + sprintf( psz_tmp, "@:%d", i_net_ports[0] ); + mrltemp += psz_tmp; } break; case 1: mrltemp = "udp" + demux + "://@"; - size = Edit_GetTextLength( net_addrs[1] ); - wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL - Edit_GetText( net_addrs[1], wUnicode, size + 1); - mrltemp += _TOMB(wUnicode); - delete [] wUnicode; + Edit_GetText( net_addrs[1], psz_text, 2048 ); + mrltemp += _TOMB(psz_text); if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) ) { - szAnsi = new char[50]; - sprintf( szAnsi, ":%d", i_net_ports[1] ); - mrltemp += szAnsi; - delete [] szAnsi; + sprintf( psz_tmp, ":%d", i_net_ports[1] ); + mrltemp += psz_tmp; } break; case 2: /* http access */ - size = Edit_GetTextLength( net_addrs[2] ); - wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL - Edit_GetText( net_addrs[2], wUnicode, size + 1); - size = WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, NULL, 0, NULL, &bTemp ); - szAnsi = new char[size]; - WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, szAnsi, size, NULL, &bTemp ); - free( wUnicode ); - if( !strstr( szAnsi, "http://" ) ) + Edit_GetText( net_addrs[2], psz_text, 2048 ); + if( !strstr( _TOMB(psz_text), "http://" ) ) { mrltemp = "http" + demux + "://"; } - mrltemp += szAnsi; - free( szAnsi ); + mrltemp += _TOMB(psz_text); break; case 3: /* RTSP access */ - size = Edit_GetTextLength( net_addrs[3] ); - wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL - Edit_GetText( net_addrs[3], wUnicode, size + 1); - size = WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, NULL, 0, NULL, &bTemp ); - szAnsi = new char[size]; - WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, szAnsi, size, NULL, &bTemp ); - free( wUnicode ); - if( !strstr( szAnsi, "rtsp://" ) ) + Edit_GetText( net_addrs[3], psz_text, 2048 ); + if( !strstr( _TOMB(psz_text), "rtsp://" ) ) { mrltemp = "rtsp" + demux + "://"; } - mrltemp += szAnsi; - free( szAnsi ); + mrltemp += _TOMB(psz_text); break; } break; @@ -617,7 +552,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 ) { @@ -649,7 +584,7 @@ void OpenDialog::OnPageChange() SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 ); - i_current_access_method = NET_ACCESS; + i_access = NET_ACCESS; } UpdateMRL(); @@ -657,18 +592,17 @@ void OpenDialog::OnPageChange() void OpenDialog::OnOk() { - int size; - LPWSTR wUnicode; - - size = GetWindowTextLength( mrl_combo ) + 1; - wUnicode = new WCHAR[ size ]; - GetWindowText( mrl_combo, wUnicode, size ); // a remplacer par ComboBox_GetText( mrl_combo, wUnicode, size ) - mrl = SeparateEntries( wUnicode ); - ComboBox_AddString( mrl_combo, wUnicode ); - if( ComboBox_GetCount( mrl_combo ) > 10 ) + 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 ); - delete [] wUnicode; /* Update the playlist */ playlist_t *p_playlist = @@ -676,18 +610,16 @@ void OpenDialog::OnOk() FIND_ANYWHERE ); if( p_playlist == NULL ) return; - for( int i = 0; i < (int)mrl.size(); i++ ) + for( int i = 0; i < i_args; i++ ) { vlc_bool_t b_start = !i && i_open_arg; playlist_item_t *p_item = - playlist_ItemNew( p_intf, (const char*)mrl[i].c_str(), - (const char *)mrl[i].c_str() ); + playlist_ItemNew( p_intf, pp_args[i], pp_args[i] ); /* Insert options */ - while( i + 1 < (int)mrl.size() && - ((const char *)mrl[i + 1].c_str())[0] == ':' ) + while( i + 1 < i_args && pp_args[i + 1][0] == ':' ) { - playlist_ItemAddOption( p_item, mrl[i + 1].c_str() ); + playlist_ItemAddOption( p_item, pp_args[i + 1] ); i++; } @@ -701,17 +633,26 @@ void OpenDialog::OnOk() } } - int i_id = 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 ); } } //TogglePlayButton( PLAYING_S ); + while( i_args-- ) + { + free( pp_args[i_args] ); + if( !i_args ) free( pp_args ); + } vlc_object_release( p_playlist ); } @@ -723,80 +664,57 @@ void OpenDialog::OnFilePanelChange() UpdateMRL( FILE_ACCESS ); } -void OpenDialog::OnFileBrowse() -{ - OPENFILENAME ofn; - TCHAR DateiName[80+1] = _T("\0"); - static TCHAR szFilter[] = _T("All (*.*)\0*.*\0"); - LPSTR psz_filename; - BOOL bTemp; - string path; - int size; - - 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 = NULL; - ofn.nFileOffset = 0; - ofn.nFileExtension = 0; - ofn.lpstrDefExt = NULL; - ofn.lCustData = 0L; - ofn.lpfnHook = NULL; - ofn.lpTemplateName = NULL; - if( GetOpenFileName((LPOPENFILENAME) &ofn) ) - { - size = WideCharToMultiByte( CP_ACP, 0, ofn.lpstrFile, -1, NULL, - 0, NULL, &bTemp ); - psz_filename = ( char * )malloc( size ); - WideCharToMultiByte( CP_ACP, 0, ofn.lpstrFile, -1, psz_filename, - size, NULL, &bTemp ); +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( strchr( psz_filename, ' ' ) ) + if( p_arg->i_results && p_arg->psz_results[0] ) + { + if( strchr( p_arg->psz_results[0], ' ' ) ) { - path = "\""; - path += psz_filename; - path += "\""; + strcat( psz_tmp, "\"" ); + strcat( psz_tmp, p_arg->psz_results[0] ); + strcat( psz_tmp, "\"" ); } - else - path = psz_filename; + else strcat( psz_tmp, p_arg->psz_results[0] ); - SetWindowText( file_combo, _FROMMB(path.c_str()) ); - ComboBox_AddString( file_combo, _FROMMB(path.c_str()) ); - 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. *****************************************************************************/ void OpenDialog::OnNetPanelChange( int event ) { + TCHAR psz_text[2048]; int port; - int size; - LPWSTR wUnicode; if( event >= NetPort1_Event && event <= NetPort2_Event ) { - size = Edit_GetTextLength( net_ports[event - NetPort1_Event] ); - wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL - Edit_GetText( net_ports[event - NetPort1_Event], wUnicode, size + 1); - swscanf( wUnicode, _T("%d"), &port ); + Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 ); + _stscanf( psz_text, _T("%d"), &port ); i_net_ports[event - NetPort1_Event] = port; - delete[] wUnicode; } UpdateMRL( NET_ACCESS ); @@ -816,7 +734,7 @@ void OpenDialog::OnNetTypeChange( int event ) 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, @@ -829,14 +747,14 @@ void OpenDialog::OnNetTypeChange( int event ) 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, @@ -844,20 +762,24 @@ void OpenDialog::OnNetTypeChange( int event ) 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++ ) + 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 ); + 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 ); @@ -876,82 +798,13 @@ void OpenDialog::OnSubsFileSettings( HWND hwnd ) { /* Show/hide the open dialog */ - SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, hInst ); - DialogBoxParam( hInst, (LPCTSTR)IDD_DUMMY, hwnd, - (DLGPROC)subsfile_dialog->BaseWndProc, - (long)subsfile_dialog ); + SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst); + CreateDialogBox( hwnd, subsfile_dialog ); subsfile_mrl.clear(); - for( int i = 0; i < subsfile_dialog->subsfile_mrl.size(); i++ ) + for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ ) subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] ); delete subsfile_dialog; } - -/***************************************************************************** - * Utility functions. - *****************************************************************************/ -vector SeparateEntries( LPWSTR entries ) -{ - int length; - vlc_bool_t b_quotes_mode = VLC_FALSE; - vector entries_array; - LPWSTR entry = new TCHAR[ wcslen(entries) + 1 ]; - - LPWSTR strToken = entries; - length = wcscspn( strToken, _T(" \t\r\n\"") ); - swprintf( entry, _T("") ); - - while( strToken - entries < wcslen(entries) ) - { - wcsncat( entry, strToken, length ); - - wcsncat( entry, strToken + length, 1 ); - - if( !b_quotes_mode && strToken[length] == _T('\"') ) - { - /* Enters quotes mode */ - entry[ wcslen(entry) - 1 ] = NULL; - b_quotes_mode = VLC_TRUE; - } - else if( b_quotes_mode && strToken[length] == _T('\"') ) - { - /* Finished the quotes mode */ - entry[ wcslen(entry) - 1 ] = NULL; - if( wcscmp( entry, _T("") ) != 0 ) - { - entries_array.push_back( _TOMB(entry) ); - } - swprintf( entry, _T("") ); - b_quotes_mode = VLC_FALSE; - } - else if( !b_quotes_mode && strToken[length] != _T('\"') ) - { - /* we found a non-quoted standalone string */ - if( strToken + length - entries < wcslen(entries) ||/*token.HasMoreTokens() ||*/ //FIX ME IF YOU CAN - strToken[length] == _T(' ') || - strToken[length] == _T('\t') || - strToken[length] == _T('\r') || - strToken[length] == _T('\n') ) - entry[ wcslen(entry) - 1 ]/*strToken[length]*/ = NULL; - if( wcscmp( entry, _T("") ) != 0 ) - { - entries_array.push_back( _TOMB(entry) ); - } - swprintf( entry, _T("") ); - } - else - {;} - - strToken += length + 1; - length = wcscspn( strToken, _T(" \t\r\n\"") ); - } - - if( wcscmp( entry, _T("") ) != 0 ) - { - entries_array.push_back( _TOMB(entry) ); - } - - return entries_array; -}