1 /*****************************************************************************
2 * open.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
29 #include <vlc_interface.h>
38 /*****************************************************************************
40 *****************************************************************************/
42 /* IDs for the controls and the menu commands */
45 Notebook_Event = 1000,
57 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
58 NetPort1_Event, NetPort2_Event, NetPort3_Event,
59 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
62 SubsFileSettings_Event,
65 /*****************************************************************************
67 *****************************************************************************/
69 /*****************************************************************************
71 *****************************************************************************/
72 OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
73 HINSTANCE h_inst, int _i_access, int _i_arg )
74 : CBaseWindow( p_intf, p_parent, h_inst )
80 for( int i = 0; i < 4; i++ )
84 net_port_label[i] = 0;
88 net_addrs_label[i] = 0;
92 CreateWindow( _T("VLC WinCE"), _T("Messages"),
93 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
94 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
95 p_parent->GetHandle(), NULL, h_inst, (void *)this );
98 /***********************************************************************
104 Processes messages sent to the main window.
106 ***********************************************************************/
107 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
110 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
117 shidi.dwMask = SHIDIM_FLAGS;
118 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
120 SHInitDialog( &shidi );
122 // Get the client area rect to put the panels in
123 GetClientRect( hwnd, &rcClient );
125 /* Create MRL combobox */
126 mrl_box = CreateWindow( _T("STATIC"),
127 _FROMMB(_("Media Resource Locator (MRL)")),
128 WS_CHILD | WS_VISIBLE | SS_LEFT,
129 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
131 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
132 WS_CHILD | WS_VISIBLE | SS_LEFT,
133 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
135 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
136 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
137 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
138 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
141 // No tooltips for ComboBox
142 label = CreateWindow( _T("STATIC"),
143 _FROMMB(_("Alternatively, you can build an MRL "
144 "using one of the following predefined "
146 WS_CHILD | WS_VISIBLE | SS_LEFT,
147 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
150 /* Create notebook */
151 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
152 iccex.dwSize = ICC_TAB_CLASSES;
153 InitCommonControlsEx (&iccex);
155 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
156 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
157 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
158 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
159 hwnd, NULL, hInst, NULL );
161 tcItem.mask = TCIF_TEXT;
162 tcItem.pszText = _T("File");
163 TabCtrl_InsertItem( notebook, 0, &tcItem );
164 tcItem.pszText = _T("Network");
165 TabCtrl_InsertItem( notebook, 1, &tcItem );
170 TabCtrl_SetCurSel( notebook, 0 );
173 TabCtrl_SetCurSel( notebook, 1 );
188 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
189 SHSipPreference( hwnd, SIP_DOWN );
193 if( LOWORD(wp) == IDOK )
199 if( HIWORD(wp) == BN_CLICKED )
201 if( (HWND)lp == net_radios[0] )
203 OnNetTypeChange( NetRadio1_Event );
204 } else if( (HWND)lp == net_radios[1] )
206 OnNetTypeChange( NetRadio2_Event );
207 } else if( (HWND)lp == net_radios[2] )
209 OnNetTypeChange( NetRadio3_Event );
210 } else if( (HWND)lp == net_radios[3] )
212 OnNetTypeChange( NetRadio4_Event );
213 } else if( (HWND)lp == subsfile_checkbox )
216 } else if( (HWND)lp == subsfile_button )
218 OnSubsFileSettings( hwnd );
219 } else if( (HWND)lp == browse_button )
225 if( HIWORD(wp) == EN_CHANGE )
227 if( (HWND)lp == net_addrs[1] )
229 OnNetPanelChange( NetAddr2_Event );
230 } else if( (HWND)lp == net_addrs[2] )
232 OnNetPanelChange( NetAddr3_Event );
233 } else if( (HWND)lp == net_addrs[3] )
235 OnNetPanelChange( NetAddr4_Event );
236 } else if( (HWND)lp == net_ports[0] )
238 OnNetPanelChange( NetPort1_Event );
239 } else if( (HWND)lp == net_ports[1] )
241 OnNetPanelChange( NetPort2_Event );
244 if( HIWORD(wp) == CBN_EDITUPDATE )
246 if ((HWND)lp == file_combo)
254 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
261 return DefWindowProc( hwnd, msg, wp, lp );
264 /*****************************************************************************
266 *****************************************************************************/
267 void OpenDialog::FilePanel( HWND hwnd )
270 GetWindowRect( notebook, &rc );
272 /* Create browse file line */
273 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
274 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
275 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
276 5*15 + 6, hwnd, NULL, hInst, NULL );
278 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
279 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
280 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
281 hwnd, NULL, hInst, NULL );
283 /* Create Subtitles File checkox */
284 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
285 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
286 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
287 hwnd, NULL, hInst, NULL );
288 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
290 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
291 WS_CHILD | WS_VISIBLE | SS_LEFT,
292 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
293 hwnd, NULL, hInst, NULL);
295 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
296 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
297 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
298 hwnd, NULL, hInst, NULL );
300 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
301 if( psz_subsfile && *psz_subsfile )
303 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
304 EnableWindow( subsfile_button, TRUE );
305 string sz_subsfile = "sub-file=";
306 sz_subsfile += psz_subsfile;
307 subsfile_mrl.push_back( sz_subsfile );
309 if( psz_subsfile ) free( psz_subsfile );
312 void OpenDialog::NetPanel( HWND hwnd )
314 INITCOMMONCONTROLSEX ic;
323 static struct net_type net_type_array[] =
325 { _T("UDP/RTP"), 82 },
326 { _T("UDP/RTP Multicast"), 140 },
327 { _T("HTTP/FTP/MMS"), 90 },
332 GetWindowRect( notebook, &rc);
335 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
336 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
337 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
339 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
340 WS_CHILD | WS_VISIBLE | SS_LEFT,
341 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
342 15, hwnd, NULL, hInst, NULL );
344 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
346 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
347 WS_CHILD | WS_VISIBLE | SS_LEFT,
348 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
349 hwnd, NULL, hInst, NULL );
351 _stprintf( psz_text, _T("%d"), i_net_ports[0] );
352 net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
353 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
354 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
355 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
357 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
358 ic.dwICC = ICC_UPDOWN_CLASS;
359 InitCommonControlsEx(&ic);
361 hUpdown[0] = CreateUpDownControl(
362 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
363 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
364 0, 0, 0, 0, hwnd, 0, hInst,
365 net_ports[0], 16000, 0, i_net_ports[0]);
367 /* UDP/RTP Multicast row */
368 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
369 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
370 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
371 hwnd, NULL, hInst, NULL);
373 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
374 WS_CHILD | WS_VISIBLE | SS_LEFT,
375 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
376 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
378 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
379 WS_CHILD | WS_VISIBLE | SS_LEFT,
380 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
381 hwnd, NULL, hInst, NULL);
383 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
384 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
385 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
386 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
387 hwnd, NULL, hInst, NULL);
389 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
390 WS_CHILD | WS_VISIBLE | SS_LEFT,
391 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
392 hwnd, NULL, hInst, NULL);
394 i_net_ports[1] = i_net_ports[0];
396 _stprintf( psz_text, _T("%d"), i_net_ports[1] );
397 net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
398 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
399 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
400 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
401 hwnd, NULL, hInst, NULL );
403 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
404 ic.dwICC = ICC_UPDOWN_CLASS;
405 InitCommonControlsEx(&ic);
407 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
408 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
409 0, 0, 0, 0, hwnd, 0, hInst,
410 net_ports[1], 16000, 0, i_net_ports[1] );
412 /* HTTP and RTSP rows */
413 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
414 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
415 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
416 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
418 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
419 WS_CHILD | WS_VISIBLE | SS_LEFT,
420 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
421 rc.top + 10, net_type_array[2].length, 15,
422 hwnd, NULL, hInst, NULL );
424 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
425 WS_CHILD | WS_VISIBLE | SS_LEFT,
426 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
427 hwnd, NULL, hInst, NULL );
429 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
430 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
431 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
432 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
433 hwnd, NULL, hInst, NULL);
435 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
436 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
437 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
438 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
440 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
441 WS_CHILD | WS_VISIBLE | SS_LEFT,
442 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
443 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
444 hwnd, NULL, hInst, NULL );
446 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
447 WS_CHILD | WS_VISIBLE | SS_LEFT,
448 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
449 hwnd, NULL, hInst, NULL );
451 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
452 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
453 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
454 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
455 hwnd, NULL, hInst, NULL );
457 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
460 void OpenDialog::UpdateMRL()
462 UpdateMRL( i_access );
465 void OpenDialog::UpdateMRL( int i_access_method )
467 string demux, mrltemp;
468 TCHAR psz_text[2048];
471 i_access = i_access_method;
473 switch( i_access_method )
476 GetWindowText( file_combo, psz_text, 2048 );
477 mrltemp = _TOMB(psz_text);
483 mrltemp = "udp" + demux + "://";
484 if( i_net_ports[0] !=
485 config_GetInt( p_intf, "server-port" ) )
487 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
493 mrltemp = "udp" + demux + "://@";
494 Edit_GetText( net_addrs[1], psz_text, 2048 );
495 mrltemp += _TOMB(psz_text);
496 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
498 sprintf( psz_tmp, ":%d", i_net_ports[1] );
505 Edit_GetText( net_addrs[2], psz_text, 2048 );
506 if( !strstr( _TOMB(psz_text), "http://" ) )
508 mrltemp = "http" + demux + "://";
510 mrltemp += _TOMB(psz_text);
515 Edit_GetText( net_addrs[3], psz_text, 2048 );
516 if( !strstr( _TOMB(psz_text), "rtsp://" ) )
518 mrltemp = "rtsp" + demux + "://";
520 mrltemp += _TOMB(psz_text);
528 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
531 void OpenDialog::OnPageChange()
533 if( TabCtrl_GetCurSel( notebook ) == 0 )
535 for( int i=0; i<4; i++ )
537 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
538 SWP_NOMOVE | SWP_NOSIZE );
539 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
540 SWP_NOMOVE | SWP_NOSIZE );
544 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
545 SWP_NOMOVE | SWP_NOSIZE );
546 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
547 SWP_NOMOVE | SWP_NOSIZE );
548 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
549 SWP_NOMOVE | SWP_NOSIZE );
550 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
551 SWP_NOMOVE | SWP_NOSIZE );
552 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
553 SWP_NOMOVE | SWP_NOSIZE );
555 i_access = FILE_ACCESS;
557 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
559 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
560 SWP_NOMOVE | SWP_NOSIZE );
561 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
562 SWP_NOMOVE | SWP_NOSIZE );
563 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
564 SWP_NOMOVE | SWP_NOSIZE );
565 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
566 SWP_NOMOVE | SWP_NOSIZE );
567 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
568 SWP_NOMOVE | SWP_NOSIZE );
570 for( int i=0; i<4; i++ )
572 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
573 SWP_NOMOVE | SWP_NOSIZE );
574 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
575 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
576 SWP_NOMOVE | SWP_NOSIZE );
578 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
579 SWP_NOMOVE | SWP_NOSIZE );
580 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
581 SWP_NOMOVE | SWP_NOSIZE );
582 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
583 SWP_NOMOVE | SWP_NOSIZE );
585 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
587 i_access = NET_ACCESS;
593 void OpenDialog::OnOk()
595 TCHAR psz_text[2048];
597 GetWindowText( mrl_combo, psz_text, 2048 );
600 char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
602 ComboBox_AddString( mrl_combo, psz_text );
603 if( ComboBox_GetCount( mrl_combo ) > 10 )
604 ComboBox_DeleteString( mrl_combo, 0 );
605 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
607 /* Update the playlist */
608 playlist_t *p_playlist =
609 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
611 if( p_playlist == NULL ) return;
613 for( int i = 0; i < i_args; i++ )
615 vlc_bool_t b_start = !i && i_open_arg;
616 playlist_item_t *p_item =
617 playlist_ItemNew( p_intf, pp_args[i], pp_args[i] );
620 while( i + 1 < i_args && pp_args[i + 1][0] == ':' )
622 playlist_ItemAddOption( p_item, pp_args[i + 1] );
626 /* Get the options from the subtitles dialog */
627 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
628 && subsfile_mrl.size() )
630 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
632 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
639 playlist_AddItem( p_playlist, p_item,
640 PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END );
644 playlist_AddItem( p_playlist, p_item,
645 PLAYLIST_APPEND, PLAYLIST_END );
649 //TogglePlayButton( PLAYING_S );
653 free( pp_args[i_args] );
654 if( !i_args ) free( pp_args );
656 vlc_object_release( p_playlist );
659 /*****************************************************************************
660 * File panel event methods.
661 *****************************************************************************/
662 void OpenDialog::OnFilePanelChange()
664 UpdateMRL( FILE_ACCESS );
667 static void OnOpenCB( intf_dialog_args_t *p_arg )
669 OpenDialog *p_this = (OpenDialog *)p_arg->p_arg;
670 char psz_tmp[PATH_MAX+2] = "\0";
672 if( p_arg->i_results && p_arg->psz_results[0] )
674 if( strchr( p_arg->psz_results[0], ' ' ) )
676 strcat( psz_tmp, "\"" );
677 strcat( psz_tmp, p_arg->psz_results[0] );
678 strcat( psz_tmp, "\"" );
680 else strcat( psz_tmp, p_arg->psz_results[0] );
682 SetWindowText( p_this->file_combo, _FROMMB(psz_tmp) );
683 ComboBox_AddString( p_this->file_combo, _FROMMB(psz_tmp) );
684 if( ComboBox_GetCount( p_this->file_combo ) > 10 )
685 ComboBox_DeleteString( p_this->file_combo, 0 );
687 p_this->UpdateMRL( FILE_ACCESS );
691 void OpenDialog::OnFileBrowse()
693 intf_dialog_args_t *p_arg =
694 (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
695 memset( p_arg, 0, sizeof(intf_dialog_args_t) );
697 p_arg->psz_title = strdup( "Open file" );
698 p_arg->psz_extensions = strdup( "All (*.*)|*.*" );
700 p_arg->pf_callback = OnOpenCB;
702 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
705 /*****************************************************************************
706 * Net panel event methods.
707 *****************************************************************************/
708 void OpenDialog::OnNetPanelChange( int event )
710 TCHAR psz_text[2048];
713 if( event >= NetPort1_Event && event <= NetPort2_Event )
715 Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
716 _stscanf( psz_text, _T("%d"), &port );
717 i_net_ports[event - NetPort1_Event] = port;
720 UpdateMRL( NET_ACCESS );
723 void OpenDialog::OnNetTypeChange( int event )
727 i_net_type = event - NetRadio1_Event;
729 if( event == NetRadio1_Event )
731 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
732 SWP_NOMOVE | SWP_NOSIZE );
733 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
734 SWP_NOMOVE | SWP_NOSIZE );
735 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
736 SWP_NOMOVE | SWP_NOSIZE );
738 else if( event == NetRadio2_Event )
740 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
741 SWP_NOMOVE | SWP_NOSIZE );
742 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
743 SWP_NOMOVE | SWP_NOSIZE );
744 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
745 SWP_NOMOVE | SWP_NOSIZE );
746 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
747 SWP_NOMOVE | SWP_NOSIZE );
748 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
749 SWP_NOMOVE | SWP_NOSIZE );
751 else if( event == NetRadio3_Event )
753 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
754 SWP_NOMOVE | SWP_NOSIZE );
755 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
756 SWP_NOMOVE | SWP_NOSIZE );
758 else if( event == NetRadio4_Event )
760 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
761 SWP_NOMOVE | SWP_NOSIZE );
762 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
763 SWP_NOMOVE | SWP_NOSIZE );
766 UpdateMRL( NET_ACCESS );
769 void OpenDialog::DisableNETCtrl()
771 for( int i=0; i<4; i++ )
773 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
774 SWP_NOMOVE | SWP_NOSIZE );
775 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
776 SWP_NOMOVE | SWP_NOSIZE );
777 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
778 SWP_NOMOVE | SWP_NOSIZE );
779 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
780 SWP_NOMOVE | SWP_NOSIZE );
781 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
782 SWP_NOMOVE | SWP_NOSIZE );
785 UpdateMRL( FILE_ACCESS );
788 /*****************************************************************************
789 * Subtitles file event methods.
790 *****************************************************************************/
791 void OpenDialog::OnSubsFileEnable()
793 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
794 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
797 void OpenDialog::OnSubsFileSettings( HWND hwnd )
800 /* Show/hide the open dialog */
801 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
802 CreateDialogBox( hwnd, subsfile_dialog );
804 subsfile_mrl.clear();
806 for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
807 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
809 delete subsfile_dialog;