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 *****************************************************************************/
30 #include <vlc_interface.h>
39 /*****************************************************************************
41 *****************************************************************************/
43 /* IDs for the controls and the menu commands */
46 Notebook_Event = 1000,
58 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
59 NetPort1_Event, NetPort2_Event, NetPort3_Event,
60 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
63 SubsFileSettings_Event,
66 /*****************************************************************************
68 *****************************************************************************/
70 /*****************************************************************************
72 *****************************************************************************/
73 OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
74 HINSTANCE h_inst, int _i_access, int _i_arg )
75 : CBaseWindow( p_intf, p_parent, h_inst )
81 for( int i = 0; i < 4; i++ )
85 net_port_label[i] = 0;
89 net_addrs_label[i] = 0;
93 CreateWindow( _T("VLC WinCE"), _T("Messages"),
94 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
95 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
96 p_parent->GetHandle(), NULL, h_inst, (void *)this );
99 /***********************************************************************
105 Processes messages sent to the main window.
107 ***********************************************************************/
108 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
111 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
118 shidi.dwMask = SHIDIM_FLAGS;
119 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
121 SHInitDialog( &shidi );
123 // Get the client area rect to put the panels in
124 GetClientRect( hwnd, &rcClient );
126 /* Create MRL combobox */
127 mrl_box = CreateWindow( _T("STATIC"),
128 _FROMMB(_("Media Resource Locator (MRL)")),
129 WS_CHILD | WS_VISIBLE | SS_LEFT,
130 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
132 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
133 WS_CHILD | WS_VISIBLE | SS_LEFT,
134 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
136 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
137 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
138 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
139 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
142 // No tooltips for ComboBox
143 label = CreateWindow( _T("STATIC"),
144 _FROMMB(_("Alternatively, you can build an MRL "
145 "using one of the following predefined "
147 WS_CHILD | WS_VISIBLE | SS_LEFT,
148 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
151 /* Create notebook */
152 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
153 iccex.dwSize = ICC_TAB_CLASSES;
154 InitCommonControlsEx (&iccex);
156 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
157 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
158 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
159 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
160 hwnd, NULL, hInst, NULL );
162 tcItem.mask = TCIF_TEXT;
163 tcItem.pszText = _T("File");
164 TabCtrl_InsertItem( notebook, 0, &tcItem );
165 tcItem.pszText = _T("Network");
166 TabCtrl_InsertItem( notebook, 1, &tcItem );
171 TabCtrl_SetCurSel( notebook, 0 );
174 TabCtrl_SetCurSel( notebook, 1 );
189 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
190 SHSipPreference( hwnd, SIP_DOWN );
194 if( LOWORD(wp) == IDOK )
200 if( HIWORD(wp) == BN_CLICKED )
202 if( (HWND)lp == net_radios[0] )
204 OnNetTypeChange( NetRadio1_Event );
205 } else if( (HWND)lp == net_radios[1] )
207 OnNetTypeChange( NetRadio2_Event );
208 } else if( (HWND)lp == net_radios[2] )
210 OnNetTypeChange( NetRadio3_Event );
211 } else if( (HWND)lp == net_radios[3] )
213 OnNetTypeChange( NetRadio4_Event );
214 } else if( (HWND)lp == subsfile_checkbox )
217 } else if( (HWND)lp == subsfile_button )
219 OnSubsFileSettings( hwnd );
220 } else if( (HWND)lp == browse_button )
226 if( HIWORD(wp) == EN_CHANGE )
228 if( (HWND)lp == net_addrs[1] )
230 OnNetPanelChange( NetAddr2_Event );
231 } else if( (HWND)lp == net_addrs[2] )
233 OnNetPanelChange( NetAddr3_Event );
234 } else if( (HWND)lp == net_addrs[3] )
236 OnNetPanelChange( NetAddr4_Event );
237 } else if( (HWND)lp == net_ports[0] )
239 OnNetPanelChange( NetPort1_Event );
240 } else if( (HWND)lp == net_ports[1] )
242 OnNetPanelChange( NetPort2_Event );
245 if( HIWORD(wp) == CBN_EDITUPDATE )
247 if ((HWND)lp == file_combo)
255 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
262 return DefWindowProc( hwnd, msg, wp, lp );
265 /*****************************************************************************
267 *****************************************************************************/
268 void OpenDialog::FilePanel( HWND hwnd )
271 GetWindowRect( notebook, &rc );
273 /* Create browse file line */
274 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
275 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
276 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
277 5*15 + 6, hwnd, NULL, hInst, NULL );
279 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
280 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
281 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
282 hwnd, NULL, hInst, NULL );
284 /* Create Subtitles File checkox */
285 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
286 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
287 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
288 hwnd, NULL, hInst, NULL );
289 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
291 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
292 WS_CHILD | WS_VISIBLE | SS_LEFT,
293 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
294 hwnd, NULL, hInst, NULL);
296 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
297 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
298 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
299 hwnd, NULL, hInst, NULL );
301 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
302 if( psz_subsfile && *psz_subsfile )
304 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
305 EnableWindow( subsfile_button, TRUE );
306 string sz_subsfile = "sub-file=";
307 sz_subsfile += psz_subsfile;
308 subsfile_mrl.push_back( sz_subsfile );
310 if( psz_subsfile ) free( psz_subsfile );
313 void OpenDialog::NetPanel( HWND hwnd )
315 INITCOMMONCONTROLSEX ic;
324 static struct net_type net_type_array[] =
326 { _T("UDP/RTP"), 82 },
327 { _T("UDP/RTP Multicast"), 140 },
328 { _T("HTTP/FTP/MMS"), 90 },
333 GetWindowRect( notebook, &rc);
336 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
337 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
338 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
340 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
341 WS_CHILD | WS_VISIBLE | SS_LEFT,
342 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
343 15, hwnd, NULL, hInst, NULL );
345 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
347 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
348 WS_CHILD | WS_VISIBLE | SS_LEFT,
349 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
350 hwnd, NULL, hInst, NULL );
352 _stprintf( psz_text, _T("%d"), i_net_ports[0] );
353 net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
354 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
355 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
356 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
358 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
359 ic.dwICC = ICC_UPDOWN_CLASS;
360 InitCommonControlsEx(&ic);
362 hUpdown[0] = CreateUpDownControl(
363 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
364 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
365 0, 0, 0, 0, hwnd, 0, hInst,
366 net_ports[0], 16000, 0, i_net_ports[0]);
368 /* UDP/RTP Multicast row */
369 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
370 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
371 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
372 hwnd, NULL, hInst, NULL);
374 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
375 WS_CHILD | WS_VISIBLE | SS_LEFT,
376 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
377 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
379 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
380 WS_CHILD | WS_VISIBLE | SS_LEFT,
381 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
382 hwnd, NULL, hInst, NULL);
384 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
385 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
386 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
387 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
388 hwnd, NULL, hInst, NULL);
390 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
391 WS_CHILD | WS_VISIBLE | SS_LEFT,
392 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
393 hwnd, NULL, hInst, NULL);
395 i_net_ports[1] = i_net_ports[0];
397 _stprintf( psz_text, _T("%d"), i_net_ports[1] );
398 net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
399 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
400 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
401 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
402 hwnd, NULL, hInst, NULL );
404 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
405 ic.dwICC = ICC_UPDOWN_CLASS;
406 InitCommonControlsEx(&ic);
408 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
409 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
410 0, 0, 0, 0, hwnd, 0, hInst,
411 net_ports[1], 16000, 0, i_net_ports[1] );
413 /* HTTP and RTSP rows */
414 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
415 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
416 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
417 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
419 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
420 WS_CHILD | WS_VISIBLE | SS_LEFT,
421 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
422 rc.top + 10, net_type_array[2].length, 15,
423 hwnd, NULL, hInst, NULL );
425 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
426 WS_CHILD | WS_VISIBLE | SS_LEFT,
427 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
428 hwnd, NULL, hInst, NULL );
430 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
431 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
432 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
433 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
434 hwnd, NULL, hInst, NULL);
436 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
437 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
438 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
439 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
441 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
442 WS_CHILD | WS_VISIBLE | SS_LEFT,
443 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
444 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
445 hwnd, NULL, hInst, NULL );
447 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
448 WS_CHILD | WS_VISIBLE | SS_LEFT,
449 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
450 hwnd, NULL, hInst, NULL );
452 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
453 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
454 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
455 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
456 hwnd, NULL, hInst, NULL );
458 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
461 void OpenDialog::UpdateMRL()
463 UpdateMRL( i_access );
466 void OpenDialog::UpdateMRL( int i_access_method )
468 string demux, mrltemp;
469 TCHAR psz_text[2048];
472 i_access = i_access_method;
474 switch( i_access_method )
477 GetWindowText( file_combo, psz_text, 2048 );
478 mrltemp = _TOMB(psz_text);
484 mrltemp = "udp" + demux + "://";
485 if( i_net_ports[0] !=
486 config_GetInt( p_intf, "server-port" ) )
488 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
494 mrltemp = "udp" + demux + "://@";
495 Edit_GetText( net_addrs[1], psz_text, 2048 );
496 mrltemp += _TOMB(psz_text);
497 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
499 sprintf( psz_tmp, ":%d", i_net_ports[1] );
506 Edit_GetText( net_addrs[2], psz_text, 2048 );
507 if( !strstr( _TOMB(psz_text), "http://" ) )
509 mrltemp = "http" + demux + "://";
511 mrltemp += _TOMB(psz_text);
516 Edit_GetText( net_addrs[3], psz_text, 2048 );
517 if( !strstr( _TOMB(psz_text), "rtsp://" ) )
519 mrltemp = "rtsp" + demux + "://";
521 mrltemp += _TOMB(psz_text);
529 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
532 void OpenDialog::OnPageChange()
534 if( TabCtrl_GetCurSel( notebook ) == 0 )
536 for( int i=0; i<4; i++ )
538 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
539 SWP_NOMOVE | SWP_NOSIZE );
540 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
541 SWP_NOMOVE | SWP_NOSIZE );
545 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
546 SWP_NOMOVE | SWP_NOSIZE );
547 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
548 SWP_NOMOVE | SWP_NOSIZE );
549 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
550 SWP_NOMOVE | SWP_NOSIZE );
551 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
552 SWP_NOMOVE | SWP_NOSIZE );
553 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
554 SWP_NOMOVE | SWP_NOSIZE );
556 i_access = FILE_ACCESS;
558 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
560 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
561 SWP_NOMOVE | SWP_NOSIZE );
562 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
563 SWP_NOMOVE | SWP_NOSIZE );
564 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
565 SWP_NOMOVE | SWP_NOSIZE );
566 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
567 SWP_NOMOVE | SWP_NOSIZE );
568 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
569 SWP_NOMOVE | SWP_NOSIZE );
571 for( int i=0; i<4; i++ )
573 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
574 SWP_NOMOVE | SWP_NOSIZE );
575 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
576 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
577 SWP_NOMOVE | SWP_NOSIZE );
579 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
580 SWP_NOMOVE | SWP_NOSIZE );
581 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
582 SWP_NOMOVE | SWP_NOSIZE );
583 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
584 SWP_NOMOVE | SWP_NOSIZE );
586 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
588 i_access = NET_ACCESS;
594 void OpenDialog::OnOk()
596 TCHAR psz_text[2048];
598 GetWindowText( mrl_combo, psz_text, 2048 );
601 char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
603 ComboBox_AddString( mrl_combo, psz_text );
604 if( ComboBox_GetCount( mrl_combo ) > 10 )
605 ComboBox_DeleteString( mrl_combo, 0 );
606 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
608 /* Update the playlist */
609 playlist_t *p_playlist =
610 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
612 if( p_playlist == NULL ) return;
614 for( int i = 0; i < i_args; i++ )
616 vlc_bool_t b_start = !i && i_open_arg;
617 playlist_item_t *p_item =
618 playlist_ItemNew( p_intf, pp_args[i], pp_args[i] );
621 while( i + 1 < i_args && pp_args[i + 1][0] == ':' )
623 playlist_ItemAddOption( p_item, pp_args[i + 1] );
627 /* Get the options from the subtitles dialog */
628 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
629 && subsfile_mrl.size() )
631 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
633 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
640 playlist_AddItem( p_playlist, p_item,
641 PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END );
645 playlist_AddItem( p_playlist, p_item,
646 PLAYLIST_APPEND, PLAYLIST_END );
650 //TogglePlayButton( PLAYING_S );
654 free( pp_args[i_args] );
655 if( !i_args ) free( pp_args );
657 vlc_object_release( p_playlist );
660 /*****************************************************************************
661 * File panel event methods.
662 *****************************************************************************/
663 void OpenDialog::OnFilePanelChange()
665 UpdateMRL( FILE_ACCESS );
668 static void OnOpenCB( intf_dialog_args_t *p_arg )
670 OpenDialog *p_this = (OpenDialog *)p_arg->p_arg;
671 char psz_tmp[PATH_MAX+2] = "\0";
673 if( p_arg->i_results && p_arg->psz_results[0] )
675 if( strchr( p_arg->psz_results[0], ' ' ) )
677 strcat( psz_tmp, "\"" );
678 strcat( psz_tmp, p_arg->psz_results[0] );
679 strcat( psz_tmp, "\"" );
681 else strcat( psz_tmp, p_arg->psz_results[0] );
683 SetWindowText( p_this->file_combo, _FROMMB(psz_tmp) );
684 ComboBox_AddString( p_this->file_combo, _FROMMB(psz_tmp) );
685 if( ComboBox_GetCount( p_this->file_combo ) > 10 )
686 ComboBox_DeleteString( p_this->file_combo, 0 );
688 p_this->UpdateMRL( FILE_ACCESS );
692 void OpenDialog::OnFileBrowse()
694 intf_dialog_args_t *p_arg =
695 (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
696 memset( p_arg, 0, sizeof(intf_dialog_args_t) );
698 p_arg->psz_title = strdup( "Open file" );
699 p_arg->psz_extensions = strdup( "All (*.*)|*.*" );
701 p_arg->pf_callback = OnOpenCB;
703 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
706 /*****************************************************************************
707 * Net panel event methods.
708 *****************************************************************************/
709 void OpenDialog::OnNetPanelChange( int event )
711 TCHAR psz_text[2048];
714 if( event >= NetPort1_Event && event <= NetPort2_Event )
716 Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
717 _stscanf( psz_text, _T("%d"), &port );
718 i_net_ports[event - NetPort1_Event] = port;
721 UpdateMRL( NET_ACCESS );
724 void OpenDialog::OnNetTypeChange( int event )
728 i_net_type = event - NetRadio1_Event;
730 if( event == NetRadio1_Event )
732 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
733 SWP_NOMOVE | SWP_NOSIZE );
734 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
735 SWP_NOMOVE | SWP_NOSIZE );
736 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
737 SWP_NOMOVE | SWP_NOSIZE );
739 else if( event == NetRadio2_Event )
741 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
742 SWP_NOMOVE | SWP_NOSIZE );
743 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
744 SWP_NOMOVE | SWP_NOSIZE );
745 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
746 SWP_NOMOVE | SWP_NOSIZE );
747 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
748 SWP_NOMOVE | SWP_NOSIZE );
749 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
750 SWP_NOMOVE | SWP_NOSIZE );
752 else if( event == NetRadio3_Event )
754 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
755 SWP_NOMOVE | SWP_NOSIZE );
756 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
757 SWP_NOMOVE | SWP_NOSIZE );
759 else if( event == NetRadio4_Event )
761 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
762 SWP_NOMOVE | SWP_NOSIZE );
763 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
764 SWP_NOMOVE | SWP_NOSIZE );
767 UpdateMRL( NET_ACCESS );
770 void OpenDialog::DisableNETCtrl()
772 for( int i=0; i<4; i++ )
774 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
775 SWP_NOMOVE | SWP_NOSIZE );
776 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
777 SWP_NOMOVE | SWP_NOSIZE );
778 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
779 SWP_NOMOVE | SWP_NOSIZE );
780 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
781 SWP_NOMOVE | SWP_NOSIZE );
782 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
783 SWP_NOMOVE | SWP_NOSIZE );
786 UpdateMRL( FILE_ACCESS );
789 /*****************************************************************************
790 * Subtitles file event methods.
791 *****************************************************************************/
792 void OpenDialog::OnSubsFileEnable()
794 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
795 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
798 void OpenDialog::OnSubsFileSettings( HWND hwnd )
801 /* Show/hide the open dialog */
802 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
803 CreateDialogBox( hwnd, subsfile_dialog );
805 subsfile_mrl.clear();
807 for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
808 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
810 delete subsfile_dialog;