X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fwince%2Fopen.cpp;h=cd0b304392a44c393181d7b292c9db0baab21c55;hb=905e5d8ae88a2d56f346fc33590dbe69bb07a5eb;hp=4c9e7fa8fa339aac733375e994ac8cdddfa70ee5;hpb=9abc1276b17955d403fea3ca171da08d2d0dad60;p=vlc diff --git a/modules/gui/wince/open.cpp b/modules/gui/wince/open.cpp index 4c9e7fa8fa..cd0b304392 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,7 +19,7 @@ * * 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. *****************************************************************************/ /***************************************************************************** @@ -29,15 +29,14 @@ #include /* strerror() */ #include #include -#include +#include #include "wince.h" -#include -#include #include #include #include +#include /***************************************************************************** * Event Table. @@ -73,15 +72,30 @@ 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 ); } /*********************************************************************** @@ -93,46 +107,21 @@ 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 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 ); @@ -153,7 +142,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 " @@ -179,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 ); @@ -193,48 +181,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 ) { @@ -262,31 +251,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 ); } /***************************************************************************** @@ -294,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(""), @@ -338,7 +313,7 @@ void OpenDialog::FilePanel( HWND hwnd ) } void OpenDialog::NetPanel( HWND hwnd ) -{ +{ INITCOMMONCONTROLSEX ic; TCHAR psz_text[256]; @@ -356,7 +331,7 @@ void OpenDialog::NetPanel( HWND hwnd ) { _T("RTSP"), 30 } }; - RECT rc; + RECT rc; GetWindowRect( notebook, &rc); /* UDP/RTP row */ @@ -487,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 ) @@ -496,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 ) { @@ -580,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 ) { @@ -612,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(); @@ -622,8 +597,11 @@ void OpenDialog::OnOk() { TCHAR psz_text[2048]; - GetWindowText( mrl_combo, psz_text, 2048 ); // replace by ComboBox_GetText( mrl_combo, wUnicode, size ) - mrl = SeparateEntries( psz_text ); + 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 ); @@ -635,18 +613,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++; } @@ -660,17 +636,26 @@ void OpenDialog::OnOk() } } - 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 ); } @@ -682,53 +667,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( 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. *****************************************************************************/ @@ -825,10 +801,8 @@ 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(); @@ -837,69 +811,3 @@ void OpenDialog::OnSubsFileSettings( HWND hwnd ) delete subsfile_dialog; } - -/***************************************************************************** - * Utility functions. - *****************************************************************************/ -vector SeparateEntries( TCHAR *entries ) -{ - vlc_bool_t b_quotes_mode = VLC_FALSE; - vector entries_array; - TCHAR *entry = new TCHAR[ _tcslen(entries) + 1 ]; - TCHAR *strToken = entries; - int length = _tcscspn( strToken, _T(" \t\r\n\"") ); - *entry = 0; - - while( strToken - entries < _tcslen(entries) ) - { - _tcsncat( entry, strToken, length ); - - _tcsncat( entry, strToken + length, 1 ); - - if( !b_quotes_mode && strToken[length] == _T('\"') ) - { - /* Enters quotes mode */ - entry[ _tcslen(entry) - 1 ] = 0; - b_quotes_mode = VLC_TRUE; - } - else if( b_quotes_mode && strToken[length] == _T('\"') ) - { - /* Finished the quotes mode */ - entry[ _tcslen(entry) - 1 ] = 0; - if( _tcscmp( entry, _T("") ) != 0 ) - { - entries_array.push_back( _TOMB(entry) ); - } - *entry = 0; - b_quotes_mode = VLC_FALSE; - } - else if( !b_quotes_mode && strToken[length] != _T('\"') ) - { - /* we found a non-quoted standalone string */ - if( strToken + length - entries < _tcslen(entries) ||/*token.HasMoreTokens() ||*/ //FIX ME IF YOU CAN - strToken[length] == _T(' ') || - strToken[length] == _T('\t') || - strToken[length] == _T('\r') || - strToken[length] == _T('\n') ) - entry[ _tcslen(entry) - 1 ]/*strToken[length]*/ = 0; - if( _tcscmp( entry, _T("") ) != 0 ) - { - entries_array.push_back( _TOMB(entry) ); - } - *entry = 0; - } - else - {;} - - strToken += length + 1; - length = _tcscspn( strToken, _T(" \t\r\n\"") ); - } - - if( _tcscmp( entry, _T("") ) != 0 ) - { - entries_array.push_back( _TOMB(entry) ); - } - - delete [] entry; - return entries_array; -}