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 <stdlib.h> /* malloc(), free() */
29 #include <string.h> /* strerror() */
41 /*****************************************************************************
43 *****************************************************************************/
45 /* IDs for the controls and the menu commands */
48 Notebook_Event = 1000,
60 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
61 NetPort1_Event, NetPort2_Event, NetPort3_Event,
62 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
65 SubsFileSettings_Event,
68 /*****************************************************************************
70 *****************************************************************************/
72 /*****************************************************************************
74 *****************************************************************************/
75 OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
76 HINSTANCE h_inst, int _i_access, int _i_arg )
77 : CBaseWindow( p_intf, p_parent, h_inst )
83 for( int i = 0; i < 4; i++ )
87 net_port_label[i] = 0;
91 net_addrs_label[i] = 0;
95 CreateWindow( _T("VLC WinCE"), _T("Messages"),
96 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
97 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
98 p_parent->GetHandle(), NULL, h_inst, (void *)this );
101 /***********************************************************************
107 Processes messages sent to the main window.
109 ***********************************************************************/
110 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
113 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
120 shidi.dwMask = SHIDIM_FLAGS;
121 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
123 SHInitDialog( &shidi );
125 // Get the client area rect to put the panels in
126 GetClientRect( hwnd, &rcClient );
128 /* Create MRL combobox */
129 mrl_box = CreateWindow( _T("STATIC"),
130 _FROMMB(_("Media Resource Locator (MRL)")),
131 WS_CHILD | WS_VISIBLE | SS_LEFT,
132 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
134 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
135 WS_CHILD | WS_VISIBLE | SS_LEFT,
136 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
138 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
139 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
140 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
141 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
144 // No tooltips for ComboBox
145 label = CreateWindow( _T("STATIC"),
146 _FROMMB(_("Alternatively, you can build an MRL "
147 "using one of the following predefined "
149 WS_CHILD | WS_VISIBLE | SS_LEFT,
150 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
153 /* Create notebook */
154 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
155 iccex.dwSize = ICC_TAB_CLASSES;
156 InitCommonControlsEx (&iccex);
158 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
159 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
160 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
161 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
162 hwnd, NULL, hInst, NULL );
164 tcItem.mask = TCIF_TEXT;
165 tcItem.pszText = _T("File");
166 TabCtrl_InsertItem( notebook, 0, &tcItem );
167 tcItem.pszText = _T("Network");
168 TabCtrl_InsertItem( notebook, 1, &tcItem );
173 TabCtrl_SetCurSel( notebook, 0 );
176 TabCtrl_SetCurSel( notebook, 1 );
191 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
192 SHSipPreference( hwnd, SIP_DOWN );
196 if( LOWORD(wp) == IDOK )
202 if( HIWORD(wp) == BN_CLICKED )
204 if( (HWND)lp == net_radios[0] )
206 OnNetTypeChange( NetRadio1_Event );
207 } else if( (HWND)lp == net_radios[1] )
209 OnNetTypeChange( NetRadio2_Event );
210 } else if( (HWND)lp == net_radios[2] )
212 OnNetTypeChange( NetRadio3_Event );
213 } else if( (HWND)lp == net_radios[3] )
215 OnNetTypeChange( NetRadio4_Event );
216 } else if( (HWND)lp == subsfile_checkbox )
219 } else if( (HWND)lp == subsfile_button )
221 OnSubsFileSettings( hwnd );
222 } else if( (HWND)lp == browse_button )
228 if( HIWORD(wp) == EN_CHANGE )
230 if( (HWND)lp == net_addrs[1] )
232 OnNetPanelChange( NetAddr2_Event );
233 } else if( (HWND)lp == net_addrs[2] )
235 OnNetPanelChange( NetAddr3_Event );
236 } else if( (HWND)lp == net_addrs[3] )
238 OnNetPanelChange( NetAddr4_Event );
239 } else if( (HWND)lp == net_ports[0] )
241 OnNetPanelChange( NetPort1_Event );
242 } else if( (HWND)lp == net_ports[1] )
244 OnNetPanelChange( NetPort2_Event );
247 if( HIWORD(wp) == CBN_EDITUPDATE )
249 if ((HWND)lp == file_combo)
257 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
264 return DefWindowProc( hwnd, msg, wp, lp );
267 /*****************************************************************************
269 *****************************************************************************/
270 void OpenDialog::FilePanel( HWND hwnd )
273 GetWindowRect( notebook, &rc );
275 /* Create browse file line */
276 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
277 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
278 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
279 5*15 + 6, hwnd, NULL, hInst, NULL );
281 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
282 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
283 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
284 hwnd, NULL, hInst, NULL );
286 /* Create Subtitles File checkox */
287 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
288 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
289 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
290 hwnd, NULL, hInst, NULL );
291 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
293 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
294 WS_CHILD | WS_VISIBLE | SS_LEFT,
295 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
296 hwnd, NULL, hInst, NULL);
298 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
299 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
300 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
301 hwnd, NULL, hInst, NULL );
303 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
304 if( psz_subsfile && *psz_subsfile )
306 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
307 EnableWindow( subsfile_button, TRUE );
308 string sz_subsfile = "sub-file=";
309 sz_subsfile += psz_subsfile;
310 subsfile_mrl.push_back( sz_subsfile );
312 if( psz_subsfile ) free( psz_subsfile );
315 void OpenDialog::NetPanel( HWND hwnd )
317 INITCOMMONCONTROLSEX ic;
326 static struct net_type net_type_array[] =
328 { _T("UDP/RTP"), 82 },
329 { _T("UDP/RTP Multicast"), 140 },
330 { _T("HTTP/FTP/MMS"), 90 },
335 GetWindowRect( notebook, &rc);
338 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
339 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
340 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
342 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
343 WS_CHILD | WS_VISIBLE | SS_LEFT,
344 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
345 15, hwnd, NULL, hInst, NULL );
347 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
349 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
350 WS_CHILD | WS_VISIBLE | SS_LEFT,
351 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
352 hwnd, NULL, hInst, NULL );
354 _stprintf( psz_text, _T("%d"), i_net_ports[0] );
355 net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
356 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
357 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
358 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
360 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
361 ic.dwICC = ICC_UPDOWN_CLASS;
362 InitCommonControlsEx(&ic);
364 hUpdown[0] = CreateUpDownControl(
365 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
366 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
367 0, 0, 0, 0, hwnd, 0, hInst,
368 net_ports[0], 16000, 0, i_net_ports[0]);
370 /* UDP/RTP Multicast row */
371 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
372 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
373 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
374 hwnd, NULL, hInst, NULL);
376 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
377 WS_CHILD | WS_VISIBLE | SS_LEFT,
378 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
379 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
381 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
382 WS_CHILD | WS_VISIBLE | SS_LEFT,
383 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
384 hwnd, NULL, hInst, NULL);
386 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
387 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
388 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
389 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
390 hwnd, NULL, hInst, NULL);
392 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
393 WS_CHILD | WS_VISIBLE | SS_LEFT,
394 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
395 hwnd, NULL, hInst, NULL);
397 i_net_ports[1] = i_net_ports[0];
399 _stprintf( psz_text, _T("%d"), i_net_ports[1] );
400 net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
401 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
402 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
403 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
404 hwnd, NULL, hInst, NULL );
406 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
407 ic.dwICC = ICC_UPDOWN_CLASS;
408 InitCommonControlsEx(&ic);
410 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
411 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
412 0, 0, 0, 0, hwnd, 0, hInst,
413 net_ports[1], 16000, 0, i_net_ports[1] );
415 /* HTTP and RTSP rows */
416 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
417 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
418 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
419 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
421 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
422 WS_CHILD | WS_VISIBLE | SS_LEFT,
423 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
424 rc.top + 10, net_type_array[2].length, 15,
425 hwnd, NULL, hInst, NULL );
427 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
428 WS_CHILD | WS_VISIBLE | SS_LEFT,
429 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
430 hwnd, NULL, hInst, NULL );
432 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
433 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
434 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
435 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
436 hwnd, NULL, hInst, NULL);
438 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
439 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
440 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
441 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
443 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
444 WS_CHILD | WS_VISIBLE | SS_LEFT,
445 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
446 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
447 hwnd, NULL, hInst, NULL );
449 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
450 WS_CHILD | WS_VISIBLE | SS_LEFT,
451 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
452 hwnd, NULL, hInst, NULL );
454 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
455 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
456 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
457 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
458 hwnd, NULL, hInst, NULL );
460 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
463 void OpenDialog::UpdateMRL()
465 UpdateMRL( i_access );
468 void OpenDialog::UpdateMRL( int i_access_method )
470 string demux, mrltemp;
471 TCHAR psz_text[2048];
474 i_access = i_access_method;
476 switch( i_access_method )
479 GetWindowText( file_combo, psz_text, 2048 );
480 mrltemp = _TOMB(psz_text);
486 mrltemp = "udp" + demux + "://";
487 if( i_net_ports[0] !=
488 config_GetInt( p_intf, "server-port" ) )
490 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
496 mrltemp = "udp" + demux + "://@";
497 Edit_GetText( net_addrs[1], psz_text, 2048 );
498 mrltemp += _TOMB(psz_text);
499 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
501 sprintf( psz_tmp, ":%d", i_net_ports[1] );
508 Edit_GetText( net_addrs[2], psz_text, 2048 );
509 if( !strstr( _TOMB(psz_text), "http://" ) )
511 mrltemp = "http" + demux + "://";
513 mrltemp += _TOMB(psz_text);
518 Edit_GetText( net_addrs[3], psz_text, 2048 );
519 if( !strstr( _TOMB(psz_text), "rtsp://" ) )
521 mrltemp = "rtsp" + demux + "://";
523 mrltemp += _TOMB(psz_text);
531 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
534 void OpenDialog::OnPageChange()
536 if( TabCtrl_GetCurSel( notebook ) == 0 )
538 for( int i=0; i<4; i++ )
540 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
541 SWP_NOMOVE | SWP_NOSIZE );
542 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
543 SWP_NOMOVE | SWP_NOSIZE );
547 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
548 SWP_NOMOVE | SWP_NOSIZE );
549 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
550 SWP_NOMOVE | SWP_NOSIZE );
551 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
552 SWP_NOMOVE | SWP_NOSIZE );
553 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
554 SWP_NOMOVE | SWP_NOSIZE );
555 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
556 SWP_NOMOVE | SWP_NOSIZE );
558 i_access = FILE_ACCESS;
560 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
562 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
563 SWP_NOMOVE | SWP_NOSIZE );
564 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
565 SWP_NOMOVE | SWP_NOSIZE );
566 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
567 SWP_NOMOVE | SWP_NOSIZE );
568 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
569 SWP_NOMOVE | SWP_NOSIZE );
570 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
571 SWP_NOMOVE | SWP_NOSIZE );
573 for( int i=0; i<4; i++ )
575 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
576 SWP_NOMOVE | SWP_NOSIZE );
577 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
578 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
579 SWP_NOMOVE | SWP_NOSIZE );
581 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
582 SWP_NOMOVE | SWP_NOSIZE );
583 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
584 SWP_NOMOVE | SWP_NOSIZE );
585 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
586 SWP_NOMOVE | SWP_NOSIZE );
588 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
590 i_access = NET_ACCESS;
596 void OpenDialog::OnOk()
598 TCHAR psz_text[2048];
600 GetWindowText( mrl_combo, psz_text, 2048 );
603 char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
605 ComboBox_AddString( mrl_combo, psz_text );
606 if( ComboBox_GetCount( mrl_combo ) > 10 )
607 ComboBox_DeleteString( mrl_combo, 0 );
608 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
610 /* Update the playlist */
611 playlist_t *p_playlist =
612 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
614 if( p_playlist == NULL ) return;
616 for( int i = 0; i < i_args; i++ )
618 vlc_bool_t b_start = !i && i_open_arg;
619 playlist_item_t *p_item =
620 playlist_ItemNew( p_intf, pp_args[i], pp_args[i] );
623 while( i + 1 < i_args && pp_args[i + 1][0] == ':' )
625 playlist_ItemAddOption( p_item, pp_args[i + 1] );
629 /* Get the options from the subtitles dialog */
630 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
631 && subsfile_mrl.size() )
633 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
635 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
642 playlist_AddItem( p_playlist, p_item,
643 PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END );
647 playlist_AddItem( p_playlist, p_item,
648 PLAYLIST_APPEND, PLAYLIST_END );
652 //TogglePlayButton( PLAYING_S );
656 free( pp_args[i_args] );
657 if( !i_args ) free( pp_args );
659 vlc_object_release( p_playlist );
662 /*****************************************************************************
663 * File panel event methods.
664 *****************************************************************************/
665 void OpenDialog::OnFilePanelChange()
667 UpdateMRL( FILE_ACCESS );
670 static void OnOpenCB( intf_dialog_args_t *p_arg )
672 OpenDialog *p_this = (OpenDialog *)p_arg->p_arg;
673 char psz_tmp[PATH_MAX+2] = "\0";
675 if( p_arg->i_results && p_arg->psz_results[0] )
677 if( strchr( p_arg->psz_results[0], ' ' ) )
679 strcat( psz_tmp, "\"" );
680 strcat( psz_tmp, p_arg->psz_results[0] );
681 strcat( psz_tmp, "\"" );
683 else strcat( psz_tmp, p_arg->psz_results[0] );
685 SetWindowText( p_this->file_combo, _FROMMB(psz_tmp) );
686 ComboBox_AddString( p_this->file_combo, _FROMMB(psz_tmp) );
687 if( ComboBox_GetCount( p_this->file_combo ) > 10 )
688 ComboBox_DeleteString( p_this->file_combo, 0 );
690 p_this->UpdateMRL( FILE_ACCESS );
694 void OpenDialog::OnFileBrowse()
696 intf_dialog_args_t *p_arg =
697 (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
698 memset( p_arg, 0, sizeof(intf_dialog_args_t) );
700 p_arg->psz_title = strdup( "Open file" );
701 p_arg->psz_extensions = strdup( "All (*.*)|*.*" );
703 p_arg->pf_callback = OnOpenCB;
705 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
708 /*****************************************************************************
709 * Net panel event methods.
710 *****************************************************************************/
711 void OpenDialog::OnNetPanelChange( int event )
713 TCHAR psz_text[2048];
716 if( event >= NetPort1_Event && event <= NetPort2_Event )
718 Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
719 _stscanf( psz_text, _T("%d"), &port );
720 i_net_ports[event - NetPort1_Event] = port;
723 UpdateMRL( NET_ACCESS );
726 void OpenDialog::OnNetTypeChange( int event )
730 i_net_type = event - NetRadio1_Event;
732 if( event == NetRadio1_Event )
734 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
735 SWP_NOMOVE | SWP_NOSIZE );
736 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
737 SWP_NOMOVE | SWP_NOSIZE );
738 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
739 SWP_NOMOVE | SWP_NOSIZE );
741 else if( event == NetRadio2_Event )
743 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
744 SWP_NOMOVE | SWP_NOSIZE );
745 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
746 SWP_NOMOVE | SWP_NOSIZE );
747 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
748 SWP_NOMOVE | SWP_NOSIZE );
749 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
750 SWP_NOMOVE | SWP_NOSIZE );
751 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
752 SWP_NOMOVE | SWP_NOSIZE );
754 else if( event == NetRadio3_Event )
756 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
757 SWP_NOMOVE | SWP_NOSIZE );
758 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
759 SWP_NOMOVE | SWP_NOSIZE );
761 else if( event == NetRadio4_Event )
763 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
764 SWP_NOMOVE | SWP_NOSIZE );
765 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
766 SWP_NOMOVE | SWP_NOSIZE );
769 UpdateMRL( NET_ACCESS );
772 void OpenDialog::DisableNETCtrl()
774 for( int i=0; i<4; i++ )
776 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
777 SWP_NOMOVE | SWP_NOSIZE );
778 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
779 SWP_NOMOVE | SWP_NOSIZE );
780 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
781 SWP_NOMOVE | SWP_NOSIZE );
782 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
783 SWP_NOMOVE | SWP_NOSIZE );
784 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
785 SWP_NOMOVE | SWP_NOSIZE );
788 UpdateMRL( FILE_ACCESS );
791 /*****************************************************************************
792 * Subtitles file event methods.
793 *****************************************************************************/
794 void OpenDialog::OnSubsFileEnable()
796 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
797 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
800 void OpenDialog::OnSubsFileSettings( HWND hwnd )
803 /* Show/hide the open dialog */
804 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
805 CreateDialogBox( hwnd, subsfile_dialog );
807 subsfile_mrl.clear();
809 for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
810 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
812 delete subsfile_dialog;