1 /*****************************************************************************
2 * open.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
29 #include <string.h> /* strerror() */
42 /*****************************************************************************
44 *****************************************************************************/
46 /* IDs for the controls and the menu commands */
49 Notebook_Event = 1000,
61 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
62 NetPort1_Event, NetPort2_Event, NetPort3_Event,
63 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
66 SubsFileSettings_Event,
69 /*****************************************************************************
71 *****************************************************************************/
73 /*****************************************************************************
75 *****************************************************************************/
76 OpenDialog::OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
77 int _i_access_method, int _i_arg, int _i_method )
82 i_current_access_method = _i_access_method;
87 /***********************************************************************
93 Processes messages sent to the main window.
95 ***********************************************************************/
96 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
100 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
107 shidi.dwMask = SHIDIM_FLAGS;
108 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
109 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
111 SHInitDialog( &shidi );
113 //Create the menubar.
114 memset( &mbi, 0, sizeof(SHMENUBARINFO) );
115 mbi.cbSize = sizeof(SHMENUBARINFO);
116 mbi.hwndParent = hwnd;
117 mbi.nToolBarId = IDR_DUMMYMENU;
118 mbi.hInstRes = hInst;
122 if( !SHCreateMenuBar( &mbi ) )
124 MessageBox( hwnd, _T("SHCreateMenuBar failed"),
125 _T("Error"), MB_OK );
131 // Get the client area rect to put the panels in
132 GetClientRect( hwnd, &rcClient );
134 /* Create MRL combobox */
135 mrl_box = CreateWindow( _T("STATIC"),
136 _FROMMB(_("Media Resource Locator (MRL)")),
137 WS_CHILD | WS_VISIBLE | SS_LEFT,
138 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
140 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
141 WS_CHILD | WS_VISIBLE | SS_LEFT,
142 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
144 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
145 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
146 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
147 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
150 // No tooltips for ComboBox
151 label = CreateWindow( _T("STATIC"),
152 _FROMMB(_("Alternatively, you can build an MRL "
153 "using one of the following predefined "
155 WS_CHILD | WS_VISIBLE | SS_LEFT,
156 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
159 /* Create notebook */
160 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
161 iccex.dwSize = ICC_TAB_CLASSES;
162 InitCommonControlsEx (&iccex);
164 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
165 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
166 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
167 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
168 hwnd, NULL, hInst, NULL );
170 tcItem.mask = TCIF_TEXT;
171 tcItem.pszText = _T("File");
172 TabCtrl_InsertItem( notebook, 0, &tcItem );
173 tcItem.pszText = _T("Network");
174 TabCtrl_InsertItem( notebook, 1, &tcItem );
176 switch( i_current_access_method )
179 TabCtrl_SetCurSel( notebook, 0 );
182 TabCtrl_SetCurSel( notebook, 1 );
193 EndDialog( hwnd, LOWORD( wp ) );
197 if( LOWORD(wp) == IDOK )
200 EndDialog( hwnd, LOWORD( wp ) );
203 if( HIWORD(wp) == BN_CLICKED )
205 if( (HWND)lp == net_radios[0] )
207 OnNetTypeChange( NetRadio1_Event );
208 } else if( (HWND)lp == net_radios[1] )
210 OnNetTypeChange( NetRadio2_Event );
211 } else if( (HWND)lp == net_radios[2] )
213 OnNetTypeChange( NetRadio3_Event );
214 } else if( (HWND)lp == net_radios[3] )
216 OnNetTypeChange( NetRadio4_Event );
217 } else if( (HWND)lp == subsfile_checkbox )
220 } else if( (HWND)lp == subsfile_button )
222 OnSubsFileSettings( hwnd );
223 } else if( (HWND)lp == browse_button )
225 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
230 if( HIWORD(wp) == EN_CHANGE )
232 if( (HWND)lp == net_addrs[1] )
234 OnNetPanelChange( NetAddr2_Event );
235 } else if( (HWND)lp == net_addrs[2] )
237 OnNetPanelChange( NetAddr3_Event );
238 } else if( (HWND)lp == net_addrs[3] )
240 OnNetPanelChange( NetAddr4_Event );
241 } else if( (HWND)lp == net_ports[0] )
243 OnNetPanelChange( NetPort1_Event );
244 } else if( (HWND)lp == net_ports[1] )
246 OnNetPanelChange( NetPort2_Event );
249 if( HIWORD(wp) == CBN_EDITUPDATE )
251 if ((HWND)lp == file_combo)
259 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
269 /*****************************************************************************
271 *****************************************************************************/
272 void OpenDialog::FilePanel( HWND hwnd )
275 GetWindowRect( notebook, &rc);
277 /* Create browse file line */
278 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
279 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
280 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
281 5*15 + 6, hwnd, NULL, hInst, NULL );
283 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
284 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
285 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
286 hwnd, NULL, hInst, NULL );
288 /* Create Subtitles File checkox */
289 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
290 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
291 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
292 hwnd, NULL, hInst, NULL );
293 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
295 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
296 WS_CHILD | WS_VISIBLE | SS_LEFT,
297 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
298 hwnd, NULL, hInst, NULL);
300 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
301 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
302 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
303 hwnd, NULL, hInst, NULL );
305 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
306 if( psz_subsfile && *psz_subsfile )
308 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
309 EnableWindow( subsfile_button, TRUE );
310 string sz_subsfile = "sub-file=";
311 sz_subsfile += psz_subsfile;
312 subsfile_mrl.push_back( sz_subsfile );
314 if( psz_subsfile ) free( psz_subsfile );
317 void OpenDialog::NetPanel( HWND hwnd )
319 INITCOMMONCONTROLSEX ic;
328 static struct net_type net_type_array[] =
330 { _T("UDP/RTP"), 82 },
331 { _T("UDP/RTP Multicast"), 140 },
332 { _T("HTTP/FTP/MMS"), 90 },
337 GetWindowRect( notebook, &rc);
340 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
341 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
342 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
344 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
345 WS_CHILD | WS_VISIBLE | SS_LEFT,
346 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
347 15, hwnd, NULL, hInst, NULL );
349 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
351 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
352 WS_CHILD | WS_VISIBLE | SS_LEFT,
353 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
354 hwnd, NULL, hInst, NULL );
356 _stprintf( psz_text, _T("%d"), i_net_ports[0] );
357 net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
358 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
359 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
360 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
362 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
363 ic.dwICC = ICC_UPDOWN_CLASS;
364 InitCommonControlsEx(&ic);
366 hUpdown[0] = CreateUpDownControl(
367 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
368 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
369 0, 0, 0, 0, hwnd, 0, hInst,
370 net_ports[0], 16000, 0, i_net_ports[0]);
372 /* UDP/RTP Multicast row */
373 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
374 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
375 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
376 hwnd, NULL, hInst, NULL);
378 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
379 WS_CHILD | WS_VISIBLE | SS_LEFT,
380 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
381 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
383 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
384 WS_CHILD | WS_VISIBLE | SS_LEFT,
385 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
386 hwnd, NULL, hInst, NULL);
388 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
389 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
390 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
391 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
392 hwnd, NULL, hInst, NULL);
394 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
395 WS_CHILD | WS_VISIBLE | SS_LEFT,
396 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
397 hwnd, NULL, hInst, NULL);
399 i_net_ports[1] = i_net_ports[0];
401 _stprintf( psz_text, _T("%d"), i_net_ports[1] );
402 net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
403 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
404 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
405 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
406 hwnd, NULL, hInst, NULL );
408 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
409 ic.dwICC = ICC_UPDOWN_CLASS;
410 InitCommonControlsEx(&ic);
412 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
413 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
414 0, 0, 0, 0, hwnd, 0, hInst,
415 net_ports[1], 16000, 0, i_net_ports[1] );
417 /* HTTP and RTSP rows */
418 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
419 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
420 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
421 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
423 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
424 WS_CHILD | WS_VISIBLE | SS_LEFT,
425 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
426 rc.top + 10, net_type_array[2].length, 15,
427 hwnd, NULL, hInst, NULL );
429 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
430 WS_CHILD | WS_VISIBLE | SS_LEFT,
431 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
432 hwnd, NULL, hInst, NULL );
434 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
435 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
436 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
437 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
438 hwnd, NULL, hInst, NULL);
440 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
441 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
442 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
443 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
445 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
446 WS_CHILD | WS_VISIBLE | SS_LEFT,
447 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
448 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
449 hwnd, NULL, hInst, NULL );
451 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
452 WS_CHILD | WS_VISIBLE | SS_LEFT,
453 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
454 hwnd, NULL, hInst, NULL );
456 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
457 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
458 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
459 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
460 hwnd, NULL, hInst, NULL );
462 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
465 void OpenDialog::UpdateMRL()
467 UpdateMRL( i_current_access_method );
470 void OpenDialog::UpdateMRL( int i_access_method )
472 string demux, mrltemp;
473 TCHAR psz_text[2048];
476 i_current_access_method = i_access_method;
478 switch( i_access_method )
481 GetWindowText( file_combo, psz_text, 2048 );
482 mrltemp = _TOMB(psz_text);
488 mrltemp = "udp" + demux + "://";
489 if( i_net_ports[0] !=
490 config_GetInt( p_intf, "server-port" ) )
492 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
498 mrltemp = "udp" + demux + "://@";
499 Edit_GetText( net_addrs[1], psz_text, 2048 );
500 mrltemp += _TOMB(psz_text);
501 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
503 sprintf( psz_tmp, ":%d", i_net_ports[1] );
510 Edit_GetText( net_addrs[2], psz_text, 2048 );
511 if( !strstr( _TOMB(psz_text), "http://" ) )
513 mrltemp = "http" + demux + "://";
515 mrltemp += _TOMB(psz_text);
520 Edit_GetText( net_addrs[3], psz_text, 2048 );
521 if( !strstr( _TOMB(psz_text), "rtsp://" ) )
523 mrltemp = "rtsp" + demux + "://";
525 mrltemp += _TOMB(psz_text);
533 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
536 void OpenDialog::OnPageChange()
538 if( TabCtrl_GetCurSel( notebook ) == 0 )
540 for( int i=0; i<4; i++ )
542 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
543 SWP_NOMOVE | SWP_NOSIZE );
544 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
545 SWP_NOMOVE | SWP_NOSIZE );
549 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
550 SWP_NOMOVE | SWP_NOSIZE );
551 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
552 SWP_NOMOVE | SWP_NOSIZE );
553 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
554 SWP_NOMOVE | SWP_NOSIZE );
555 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
556 SWP_NOMOVE | SWP_NOSIZE );
557 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
558 SWP_NOMOVE | SWP_NOSIZE );
560 i_current_access_method = FILE_ACCESS;
562 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
564 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
565 SWP_NOMOVE | SWP_NOSIZE );
566 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
567 SWP_NOMOVE | SWP_NOSIZE );
568 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
569 SWP_NOMOVE | SWP_NOSIZE );
570 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
571 SWP_NOMOVE | SWP_NOSIZE );
572 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
573 SWP_NOMOVE | SWP_NOSIZE );
575 for( int i=0; i<4; i++ )
577 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
578 SWP_NOMOVE | SWP_NOSIZE );
579 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
580 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
581 SWP_NOMOVE | SWP_NOSIZE );
583 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
584 SWP_NOMOVE | SWP_NOSIZE );
585 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
586 SWP_NOMOVE | SWP_NOSIZE );
587 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
588 SWP_NOMOVE | SWP_NOSIZE );
590 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
592 i_current_access_method = NET_ACCESS;
598 void OpenDialog::OnOk()
600 TCHAR psz_text[2048];
602 GetWindowText( mrl_combo, psz_text, 2048 ); // replace by ComboBox_GetText( mrl_combo, wUnicode, size )
603 mrl = SeparateEntries( psz_text );
604 ComboBox_AddString( mrl_combo, psz_text );
605 if( ComboBox_GetCount( mrl_combo ) > 10 )
606 ComboBox_DeleteString( mrl_combo, 0 );
607 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
609 /* Update the playlist */
610 playlist_t *p_playlist =
611 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
613 if( p_playlist == NULL ) return;
615 for( int i = 0; i < (int)mrl.size(); i++ )
617 vlc_bool_t b_start = !i && i_open_arg;
618 playlist_item_t *p_item =
619 playlist_ItemNew( p_intf, (const char*)mrl[i].c_str(),
620 (const char *)mrl[i].c_str() );
623 while( i + 1 < (int)mrl.size() &&
624 ((const char *)mrl[i + 1].c_str())[0] == ':' )
626 playlist_ItemAddOption( p_item, mrl[i + 1].c_str() );
630 /* Get the options from the subtitles dialog */
631 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
632 && subsfile_mrl.size() )
634 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
636 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
640 playlist_AddItem( p_playlist, p_item,
641 PLAYLIST_APPEND, PLAYLIST_END );
645 playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
649 //TogglePlayButton( PLAYING_S );
651 vlc_object_release( p_playlist );
654 /*****************************************************************************
655 * File panel event methods.
656 *****************************************************************************/
657 void OpenDialog::OnFilePanelChange()
659 UpdateMRL( FILE_ACCESS );
662 void OpenDialog::OnFileBrowse()
665 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
666 TCHAR psz_file[PATH_MAX] = _T("\0");
667 TCHAR psz_tmp[PATH_MAX+2] = _T("\0");
669 memset(&ofn, 0, sizeof(OPENFILENAME));
670 ofn.lStructSize = sizeof (OPENFILENAME);
671 ofn.hwndOwner = NULL;
672 ofn.hInstance = hInst;
673 ofn.lpstrFilter = szFilter;
674 ofn.lpstrCustomFilter = NULL;
675 ofn.nMaxCustFilter = 0;
676 ofn.nFilterIndex = 1;
677 ofn.lpstrFile = psz_file;
678 ofn.nMaxFile = PATH_MAX;
679 ofn.lpstrFileTitle = NULL;
680 ofn.nMaxFileTitle = 40;
681 ofn.lpstrInitialDir = NULL;
682 ofn.lpstrTitle = _T("Open File");
685 ofn.nFileExtension = 0;
686 ofn.lpstrDefExt = NULL;
689 ofn.lpTemplateName = NULL;
690 if( GetOpenFileName((LPOPENFILENAME) &ofn) )
692 if( _tcschr( ofn.lpstrFile, _T(' ') ) )
694 _tcscat( psz_tmp, _T("\"") );
695 _tcscat( psz_tmp, ofn.lpstrFile );
696 _tcscat( psz_tmp, _T("\"") );
698 else _tcscat( psz_tmp, ofn.lpstrFile );
700 SetWindowText( file_combo, psz_tmp );
701 ComboBox_AddString( file_combo, psz_tmp );
702 if( ComboBox_GetCount( file_combo ) > 10 )
703 ComboBox_DeleteString( file_combo, 0 );
705 UpdateMRL( FILE_ACCESS );
709 /*****************************************************************************
710 * Net panel event methods.
711 *****************************************************************************/
712 void OpenDialog::OnNetPanelChange( int event )
714 TCHAR psz_text[2048];
717 if( event >= NetPort1_Event && event <= NetPort2_Event )
719 Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
720 _stscanf( psz_text, _T("%d"), &port );
721 i_net_ports[event - NetPort1_Event] = port;
724 UpdateMRL( NET_ACCESS );
727 void OpenDialog::OnNetTypeChange( int event )
731 i_net_type = event - NetRadio1_Event;
733 if( event == NetRadio1_Event )
735 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
736 SWP_NOMOVE | SWP_NOSIZE );
737 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
738 SWP_NOMOVE | SWP_NOSIZE );
739 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
740 SWP_NOMOVE | SWP_NOSIZE );
742 else if( event == NetRadio2_Event )
744 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
745 SWP_NOMOVE | SWP_NOSIZE );
746 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
747 SWP_NOMOVE | SWP_NOSIZE );
748 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
749 SWP_NOMOVE | SWP_NOSIZE );
750 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
751 SWP_NOMOVE | SWP_NOSIZE );
752 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
753 SWP_NOMOVE | SWP_NOSIZE );
755 else if( event == NetRadio3_Event )
757 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
758 SWP_NOMOVE | SWP_NOSIZE );
759 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
760 SWP_NOMOVE | SWP_NOSIZE );
762 else if( event == NetRadio4_Event )
764 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
765 SWP_NOMOVE | SWP_NOSIZE );
766 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
767 SWP_NOMOVE | SWP_NOSIZE );
770 UpdateMRL( NET_ACCESS );
773 void OpenDialog::DisableNETCtrl()
775 for( int i=0; i<4; i++ )
777 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
778 SWP_NOMOVE | SWP_NOSIZE );
779 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
780 SWP_NOMOVE | SWP_NOSIZE );
781 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
782 SWP_NOMOVE | SWP_NOSIZE );
783 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
784 SWP_NOMOVE | SWP_NOSIZE );
785 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
786 SWP_NOMOVE | SWP_NOSIZE );
789 UpdateMRL( FILE_ACCESS );
792 /*****************************************************************************
793 * Subtitles file event methods.
794 *****************************************************************************/
795 void OpenDialog::OnSubsFileEnable()
797 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
798 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
801 void OpenDialog::OnSubsFileSettings( HWND hwnd )
804 /* Show/hide the open dialog */
805 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, hInst );
806 CreateDialogBox( hwnd, subsfile_dialog );
808 subsfile_mrl.clear();
810 for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
811 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
813 delete subsfile_dialog;
816 /*****************************************************************************
818 *****************************************************************************/
819 vector<string> SeparateEntries( TCHAR *entries )
821 vlc_bool_t b_quotes_mode = VLC_FALSE;
822 vector<string> entries_array;
823 TCHAR *entry = new TCHAR[ _tcslen(entries) + 1 ];
824 TCHAR *strToken = entries;
825 int length = _tcscspn( strToken, _T(" \t\r\n\"") );
828 while( strToken - entries < _tcslen(entries) )
830 _tcsncat( entry, strToken, length );
832 _tcsncat( entry, strToken + length, 1 );
834 if( !b_quotes_mode && strToken[length] == _T('\"') )
836 /* Enters quotes mode */
837 entry[ _tcslen(entry) - 1 ] = 0;
838 b_quotes_mode = VLC_TRUE;
840 else if( b_quotes_mode && strToken[length] == _T('\"') )
842 /* Finished the quotes mode */
843 entry[ _tcslen(entry) - 1 ] = 0;
844 if( _tcscmp( entry, _T("") ) != 0 )
846 entries_array.push_back( _TOMB(entry) );
849 b_quotes_mode = VLC_FALSE;
851 else if( !b_quotes_mode && strToken[length] != _T('\"') )
853 /* we found a non-quoted standalone string */
854 if( strToken + length - entries < _tcslen(entries) ||/*token.HasMoreTokens() ||*/ //FIX ME IF YOU CAN
855 strToken[length] == _T(' ') ||
856 strToken[length] == _T('\t') ||
857 strToken[length] == _T('\r') ||
858 strToken[length] == _T('\n') )
859 entry[ _tcslen(entry) - 1 ]/*strToken[length]*/ = 0;
860 if( _tcscmp( entry, _T("") ) != 0 )
862 entries_array.push_back( _TOMB(entry) );
869 strToken += length + 1;
870 length = _tcscspn( strToken, _T(" \t\r\n\"") );
873 if( _tcscmp( entry, _T("") ) != 0 )
875 entries_array.push_back( _TOMB(entry) );
879 return entries_array;