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 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_playlist.h>
43 /*****************************************************************************
45 *****************************************************************************/
47 /* IDs for the controls and the menu commands */
50 Notebook_Event = 1000,
62 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
63 NetPort1_Event, NetPort2_Event, NetPort3_Event,
64 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
67 SubsFileSettings_Event,
70 /*****************************************************************************
72 *****************************************************************************/
74 /*****************************************************************************
76 *****************************************************************************/
77 OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
78 HINSTANCE h_inst, int _i_access, int _i_arg )
79 : CBaseWindow( p_intf, p_parent, h_inst )
85 for( int i = 0; i < 4; i++ )
89 net_port_label[i] = 0;
93 net_addrs_label[i] = 0;
97 CreateWindow( _T("VLC WinCE"), _T("Messages"),
98 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
99 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
100 p_parent->GetHandle(), NULL, h_inst, (void *)this );
103 /***********************************************************************
109 Processes messages sent to the main window.
111 ***********************************************************************/
112 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
115 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
122 shidi.dwMask = SHIDIM_FLAGS;
123 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
125 SHInitDialog( &shidi );
127 // Get the client area rect to put the panels in
128 GetClientRect( hwnd, &rcClient );
130 /* Create MRL combobox */
131 mrl_box = CreateWindow( _T("STATIC"),
132 _FROMMB(_("Media Resource Locator (MRL)")),
133 WS_CHILD | WS_VISIBLE | SS_LEFT,
134 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
136 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
137 WS_CHILD | WS_VISIBLE | SS_LEFT,
138 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
140 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
141 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
142 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
143 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
146 // No tooltips for ComboBox
147 label = CreateWindow( _T("STATIC"),
148 _FROMMB(_("Alternatively, you can build an MRL "
149 "using one of the following predefined "
151 WS_CHILD | WS_VISIBLE | SS_LEFT,
152 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
155 /* Create notebook */
156 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
157 iccex.dwSize = ICC_TAB_CLASSES;
158 InitCommonControlsEx (&iccex);
160 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
161 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
162 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
163 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
164 hwnd, NULL, hInst, NULL );
166 tcItem.mask = TCIF_TEXT;
167 tcItem.pszText = _T("File");
168 TabCtrl_InsertItem( notebook, 0, &tcItem );
169 tcItem.pszText = _T("Network");
170 TabCtrl_InsertItem( notebook, 1, &tcItem );
175 TabCtrl_SetCurSel( notebook, 0 );
178 TabCtrl_SetCurSel( notebook, 1 );
193 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
194 SHSipPreference( hwnd, SIP_DOWN );
198 if( LOWORD(wp) == IDOK )
204 if( HIWORD(wp) == BN_CLICKED )
206 if( (HWND)lp == net_radios[0] )
208 OnNetTypeChange( NetRadio1_Event );
209 } else if( (HWND)lp == net_radios[1] )
211 OnNetTypeChange( NetRadio2_Event );
212 } else if( (HWND)lp == net_radios[2] )
214 OnNetTypeChange( NetRadio3_Event );
215 } else if( (HWND)lp == net_radios[3] )
217 OnNetTypeChange( NetRadio4_Event );
218 } else if( (HWND)lp == subsfile_checkbox )
221 } else if( (HWND)lp == subsfile_button )
223 OnSubsFileSettings( hwnd );
224 } else if( (HWND)lp == browse_button )
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();
266 return DefWindowProc( hwnd, msg, wp, lp );
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 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_access );
470 void OpenDialog::UpdateMRL( int i_access_method )
472 string demux, mrltemp;
473 TCHAR psz_text[2048];
476 i_access = 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_access = 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_access = NET_ACCESS;
598 void OpenDialog::OnOk()
600 TCHAR psz_text[2048];
602 GetWindowText( mrl_combo, psz_text, 2048 );
605 /*char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
607 ComboBox_AddString( mrl_combo, psz_text );
608 if( ComboBox_GetCount( mrl_combo ) > 10 )
609 ComboBox_DeleteString( mrl_combo, 0 );
610 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );*/
612 /* Update the playlist */
613 playlist_t *p_playlist = pl_Hold( p_intf );
614 if( p_playlist == NULL ) return;
616 /* for( int i = 0; i < i_args; i++ )
618 bool b_start = !i && i_open_arg;
619 playlist_item_t *p_item =
620 playlist_ItemNew( p_playlist, 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 pl_Release( p_intf );
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;