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 *****************************************************************************/
28 #include <string.h> /* strerror() */
31 #include <vlc_interface.h>
40 /*****************************************************************************
42 *****************************************************************************/
44 /* IDs for the controls and the menu commands */
47 Notebook_Event = 1000,
59 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
60 NetPort1_Event, NetPort2_Event, NetPort3_Event,
61 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
64 SubsFileSettings_Event,
67 /*****************************************************************************
69 *****************************************************************************/
71 /*****************************************************************************
73 *****************************************************************************/
74 OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
75 HINSTANCE h_inst, int _i_access, int _i_arg )
76 : CBaseWindow( p_intf, p_parent, h_inst )
82 for( int i = 0; i < 4; i++ )
86 net_port_label[i] = 0;
90 net_addrs_label[i] = 0;
94 CreateWindow( _T("VLC WinCE"), _T("Messages"),
95 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
96 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
97 p_parent->GetHandle(), NULL, h_inst, (void *)this );
100 /***********************************************************************
106 Processes messages sent to the main window.
108 ***********************************************************************/
109 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
112 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
119 shidi.dwMask = SHIDIM_FLAGS;
120 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
122 SHInitDialog( &shidi );
124 // Get the client area rect to put the panels in
125 GetClientRect( hwnd, &rcClient );
127 /* Create MRL combobox */
128 mrl_box = CreateWindow( _T("STATIC"),
129 _FROMMB(_("Media Resource Locator (MRL)")),
130 WS_CHILD | WS_VISIBLE | SS_LEFT,
131 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
133 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
134 WS_CHILD | WS_VISIBLE | SS_LEFT,
135 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
137 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
138 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
139 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
140 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
143 // No tooltips for ComboBox
144 label = CreateWindow( _T("STATIC"),
145 _FROMMB(_("Alternatively, you can build an MRL "
146 "using one of the following predefined "
148 WS_CHILD | WS_VISIBLE | SS_LEFT,
149 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
152 /* Create notebook */
153 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
154 iccex.dwSize = ICC_TAB_CLASSES;
155 InitCommonControlsEx (&iccex);
157 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
158 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
159 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
160 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
161 hwnd, NULL, hInst, NULL );
163 tcItem.mask = TCIF_TEXT;
164 tcItem.pszText = _T("File");
165 TabCtrl_InsertItem( notebook, 0, &tcItem );
166 tcItem.pszText = _T("Network");
167 TabCtrl_InsertItem( notebook, 1, &tcItem );
172 TabCtrl_SetCurSel( notebook, 0 );
175 TabCtrl_SetCurSel( notebook, 1 );
190 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
191 SHSipPreference( hwnd, SIP_DOWN );
195 if( LOWORD(wp) == IDOK )
201 if( HIWORD(wp) == BN_CLICKED )
203 if( (HWND)lp == net_radios[0] )
205 OnNetTypeChange( NetRadio1_Event );
206 } else if( (HWND)lp == net_radios[1] )
208 OnNetTypeChange( NetRadio2_Event );
209 } else if( (HWND)lp == net_radios[2] )
211 OnNetTypeChange( NetRadio3_Event );
212 } else if( (HWND)lp == net_radios[3] )
214 OnNetTypeChange( NetRadio4_Event );
215 } else if( (HWND)lp == subsfile_checkbox )
218 } else if( (HWND)lp == subsfile_button )
220 OnSubsFileSettings( hwnd );
221 } else if( (HWND)lp == browse_button )
227 if( HIWORD(wp) == EN_CHANGE )
229 if( (HWND)lp == net_addrs[1] )
231 OnNetPanelChange( NetAddr2_Event );
232 } else if( (HWND)lp == net_addrs[2] )
234 OnNetPanelChange( NetAddr3_Event );
235 } else if( (HWND)lp == net_addrs[3] )
237 OnNetPanelChange( NetAddr4_Event );
238 } else if( (HWND)lp == net_ports[0] )
240 OnNetPanelChange( NetPort1_Event );
241 } else if( (HWND)lp == net_ports[1] )
243 OnNetPanelChange( NetPort2_Event );
246 if( HIWORD(wp) == CBN_EDITUPDATE )
248 if ((HWND)lp == file_combo)
256 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
263 return DefWindowProc( hwnd, msg, wp, lp );
266 /*****************************************************************************
268 *****************************************************************************/
269 void OpenDialog::FilePanel( HWND hwnd )
272 GetWindowRect( notebook, &rc );
274 /* Create browse file line */
275 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
276 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
277 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
278 5*15 + 6, hwnd, NULL, hInst, NULL );
280 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
281 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
282 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
283 hwnd, NULL, hInst, NULL );
285 /* Create Subtitles File checkox */
286 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
287 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
288 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
289 hwnd, NULL, hInst, NULL );
290 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
292 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
293 WS_CHILD | WS_VISIBLE | SS_LEFT,
294 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
295 hwnd, NULL, hInst, NULL);
297 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
298 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
299 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
300 hwnd, NULL, hInst, NULL );
302 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
303 if( psz_subsfile && *psz_subsfile )
305 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
306 EnableWindow( subsfile_button, TRUE );
307 string sz_subsfile = "sub-file=";
308 sz_subsfile += psz_subsfile;
309 subsfile_mrl.push_back( sz_subsfile );
311 if( psz_subsfile ) free( psz_subsfile );
314 void OpenDialog::NetPanel( HWND hwnd )
316 INITCOMMONCONTROLSEX ic;
325 static struct net_type net_type_array[] =
327 { _T("UDP/RTP"), 82 },
328 { _T("UDP/RTP Multicast"), 140 },
329 { _T("HTTP/FTP/MMS"), 90 },
334 GetWindowRect( notebook, &rc);
337 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
338 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
339 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
341 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
342 WS_CHILD | WS_VISIBLE | SS_LEFT,
343 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
344 15, hwnd, NULL, hInst, NULL );
346 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
348 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
349 WS_CHILD | WS_VISIBLE | SS_LEFT,
350 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
351 hwnd, NULL, hInst, NULL );
353 _stprintf( psz_text, _T("%d"), i_net_ports[0] );
354 net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
355 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
356 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
357 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
359 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
360 ic.dwICC = ICC_UPDOWN_CLASS;
361 InitCommonControlsEx(&ic);
363 hUpdown[0] = CreateUpDownControl(
364 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
365 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
366 0, 0, 0, 0, hwnd, 0, hInst,
367 net_ports[0], 16000, 0, i_net_ports[0]);
369 /* UDP/RTP Multicast row */
370 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
371 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
372 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
373 hwnd, NULL, hInst, NULL);
375 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
376 WS_CHILD | WS_VISIBLE | SS_LEFT,
377 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
378 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
380 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
381 WS_CHILD | WS_VISIBLE | SS_LEFT,
382 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
383 hwnd, NULL, hInst, NULL);
385 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
386 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
387 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
388 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
389 hwnd, NULL, hInst, NULL);
391 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
392 WS_CHILD | WS_VISIBLE | SS_LEFT,
393 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
394 hwnd, NULL, hInst, NULL);
396 i_net_ports[1] = i_net_ports[0];
398 _stprintf( psz_text, _T("%d"), i_net_ports[1] );
399 net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
400 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
401 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
402 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
403 hwnd, NULL, hInst, NULL );
405 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
406 ic.dwICC = ICC_UPDOWN_CLASS;
407 InitCommonControlsEx(&ic);
409 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
410 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
411 0, 0, 0, 0, hwnd, 0, hInst,
412 net_ports[1], 16000, 0, i_net_ports[1] );
414 /* HTTP and RTSP rows */
415 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
416 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
417 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
418 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
420 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
421 WS_CHILD | WS_VISIBLE | SS_LEFT,
422 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
423 rc.top + 10, net_type_array[2].length, 15,
424 hwnd, NULL, hInst, NULL );
426 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
427 WS_CHILD | WS_VISIBLE | SS_LEFT,
428 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
429 hwnd, NULL, hInst, NULL );
431 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
432 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
433 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
434 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
435 hwnd, NULL, hInst, NULL);
437 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
438 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
439 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
440 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
442 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
443 WS_CHILD | WS_VISIBLE | SS_LEFT,
444 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
445 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
446 hwnd, NULL, hInst, NULL );
448 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
449 WS_CHILD | WS_VISIBLE | SS_LEFT,
450 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
451 hwnd, NULL, hInst, NULL );
453 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
454 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
455 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
456 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
457 hwnd, NULL, hInst, NULL );
459 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
462 void OpenDialog::UpdateMRL()
464 UpdateMRL( i_access );
467 void OpenDialog::UpdateMRL( int i_access_method )
469 string demux, mrltemp;
470 TCHAR psz_text[2048];
473 i_access = i_access_method;
475 switch( i_access_method )
478 GetWindowText( file_combo, psz_text, 2048 );
479 mrltemp = _TOMB(psz_text);
485 mrltemp = "udp" + demux + "://";
486 if( i_net_ports[0] !=
487 config_GetInt( p_intf, "server-port" ) )
489 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
495 mrltemp = "udp" + demux + "://@";
496 Edit_GetText( net_addrs[1], psz_text, 2048 );
497 mrltemp += _TOMB(psz_text);
498 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
500 sprintf( psz_tmp, ":%d", i_net_ports[1] );
507 Edit_GetText( net_addrs[2], psz_text, 2048 );
508 if( !strstr( _TOMB(psz_text), "http://" ) )
510 mrltemp = "http" + demux + "://";
512 mrltemp += _TOMB(psz_text);
517 Edit_GetText( net_addrs[3], psz_text, 2048 );
518 if( !strstr( _TOMB(psz_text), "rtsp://" ) )
520 mrltemp = "rtsp" + demux + "://";
522 mrltemp += _TOMB(psz_text);
530 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
533 void OpenDialog::OnPageChange()
535 if( TabCtrl_GetCurSel( notebook ) == 0 )
537 for( int i=0; i<4; i++ )
539 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
540 SWP_NOMOVE | SWP_NOSIZE );
541 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
542 SWP_NOMOVE | SWP_NOSIZE );
546 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
547 SWP_NOMOVE | SWP_NOSIZE );
548 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
549 SWP_NOMOVE | SWP_NOSIZE );
550 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
551 SWP_NOMOVE | SWP_NOSIZE );
552 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
553 SWP_NOMOVE | SWP_NOSIZE );
554 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
555 SWP_NOMOVE | SWP_NOSIZE );
557 i_access = FILE_ACCESS;
559 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
561 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
562 SWP_NOMOVE | SWP_NOSIZE );
563 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
564 SWP_NOMOVE | SWP_NOSIZE );
565 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
566 SWP_NOMOVE | SWP_NOSIZE );
567 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
568 SWP_NOMOVE | SWP_NOSIZE );
569 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
570 SWP_NOMOVE | SWP_NOSIZE );
572 for( int i=0; i<4; i++ )
574 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
575 SWP_NOMOVE | SWP_NOSIZE );
576 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
577 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
578 SWP_NOMOVE | SWP_NOSIZE );
580 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
581 SWP_NOMOVE | SWP_NOSIZE );
582 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
583 SWP_NOMOVE | SWP_NOSIZE );
584 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
585 SWP_NOMOVE | SWP_NOSIZE );
587 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
589 i_access = NET_ACCESS;
595 void OpenDialog::OnOk()
597 TCHAR psz_text[2048];
599 GetWindowText( mrl_combo, psz_text, 2048 );
602 char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
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 < i_args; i++ )
617 vlc_bool_t b_start = !i && i_open_arg;
618 playlist_item_t *p_item =
619 playlist_ItemNew( p_intf, pp_args[i], pp_args[i] );
622 while( i + 1 < i_args && pp_args[i + 1][0] == ':' )
624 playlist_ItemAddOption( p_item, pp_args[i + 1] );
628 /* Get the options from the subtitles dialog */
629 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
630 && subsfile_mrl.size() )
632 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
634 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
641 playlist_AddItem( p_playlist, p_item,
642 PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END );
646 playlist_AddItem( p_playlist, p_item,
647 PLAYLIST_APPEND, PLAYLIST_END );
651 //TogglePlayButton( PLAYING_S );
655 free( pp_args[i_args] );
656 if( !i_args ) free( pp_args );
658 vlc_object_release( p_playlist );
661 /*****************************************************************************
662 * File panel event methods.
663 *****************************************************************************/
664 void OpenDialog::OnFilePanelChange()
666 UpdateMRL( FILE_ACCESS );
669 static void OnOpenCB( intf_dialog_args_t *p_arg )
671 OpenDialog *p_this = (OpenDialog *)p_arg->p_arg;
672 char psz_tmp[PATH_MAX+2] = "\0";
674 if( p_arg->i_results && p_arg->psz_results[0] )
676 if( strchr( p_arg->psz_results[0], ' ' ) )
678 strcat( psz_tmp, "\"" );
679 strcat( psz_tmp, p_arg->psz_results[0] );
680 strcat( psz_tmp, "\"" );
682 else strcat( psz_tmp, p_arg->psz_results[0] );
684 SetWindowText( p_this->file_combo, _FROMMB(psz_tmp) );
685 ComboBox_AddString( p_this->file_combo, _FROMMB(psz_tmp) );
686 if( ComboBox_GetCount( p_this->file_combo ) > 10 )
687 ComboBox_DeleteString( p_this->file_combo, 0 );
689 p_this->UpdateMRL( FILE_ACCESS );
693 void OpenDialog::OnFileBrowse()
695 intf_dialog_args_t *p_arg =
696 (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
697 memset( p_arg, 0, sizeof(intf_dialog_args_t) );
699 p_arg->psz_title = strdup( "Open file" );
700 p_arg->psz_extensions = strdup( "All (*.*)|*.*" );
702 p_arg->pf_callback = OnOpenCB;
704 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
707 /*****************************************************************************
708 * Net panel event methods.
709 *****************************************************************************/
710 void OpenDialog::OnNetPanelChange( int event )
712 TCHAR psz_text[2048];
715 if( event >= NetPort1_Event && event <= NetPort2_Event )
717 Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
718 _stscanf( psz_text, _T("%d"), &port );
719 i_net_ports[event - NetPort1_Event] = port;
722 UpdateMRL( NET_ACCESS );
725 void OpenDialog::OnNetTypeChange( int event )
729 i_net_type = event - NetRadio1_Event;
731 if( event == NetRadio1_Event )
733 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
734 SWP_NOMOVE | SWP_NOSIZE );
735 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
736 SWP_NOMOVE | SWP_NOSIZE );
737 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
738 SWP_NOMOVE | SWP_NOSIZE );
740 else if( event == NetRadio2_Event )
742 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
743 SWP_NOMOVE | SWP_NOSIZE );
744 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
745 SWP_NOMOVE | SWP_NOSIZE );
746 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
747 SWP_NOMOVE | SWP_NOSIZE );
748 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
749 SWP_NOMOVE | SWP_NOSIZE );
750 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
751 SWP_NOMOVE | SWP_NOSIZE );
753 else if( event == NetRadio3_Event )
755 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
756 SWP_NOMOVE | SWP_NOSIZE );
757 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
758 SWP_NOMOVE | SWP_NOSIZE );
760 else if( event == NetRadio4_Event )
762 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
763 SWP_NOMOVE | SWP_NOSIZE );
764 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
765 SWP_NOMOVE | SWP_NOSIZE );
768 UpdateMRL( NET_ACCESS );
771 void OpenDialog::DisableNETCtrl()
773 for( int i=0; i<4; i++ )
775 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
776 SWP_NOMOVE | SWP_NOSIZE );
777 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
778 SWP_NOMOVE | SWP_NOSIZE );
779 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
780 SWP_NOMOVE | SWP_NOSIZE );
781 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
782 SWP_NOMOVE | SWP_NOSIZE );
783 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
784 SWP_NOMOVE | SWP_NOSIZE );
787 UpdateMRL( FILE_ACCESS );
790 /*****************************************************************************
791 * Subtitles file event methods.
792 *****************************************************************************/
793 void OpenDialog::OnSubsFileEnable()
795 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
796 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
799 void OpenDialog::OnSubsFileSettings( HWND hwnd )
802 /* Show/hide the open dialog */
803 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
804 CreateDialogBox( hwnd, subsfile_dialog );
806 subsfile_mrl.clear();
808 for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
809 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
811 delete subsfile_dialog;