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>
42 /*****************************************************************************
44 *****************************************************************************/
46 /* IDs for the controls and the menu commands */
49 Notebook_Event = 1000,
61 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
62 NetPort1_Event, NetPort2_Event, NetPort3_Event,
63 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
66 SubsFileSettings_Event,
69 /*****************************************************************************
71 *****************************************************************************/
73 /*****************************************************************************
75 *****************************************************************************/
76 OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
77 HINSTANCE h_inst, int _i_access, int _i_arg )
78 : CBaseWindow( p_intf, p_parent, h_inst )
84 for( int i = 0; i < 4; i++ )
88 net_port_label[i] = 0;
92 net_addrs_label[i] = 0;
96 CreateWindow( _T("VLC WinCE"), _T("Messages"),
97 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
98 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
99 p_parent->GetHandle(), NULL, h_inst, (void *)this );
102 /***********************************************************************
108 Processes messages sent to the main window.
110 ***********************************************************************/
111 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
114 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
121 shidi.dwMask = SHIDIM_FLAGS;
122 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
124 SHInitDialog( &shidi );
126 // Get the client area rect to put the panels in
127 GetClientRect( hwnd, &rcClient );
129 /* Create MRL combobox */
130 mrl_box = CreateWindow( _T("STATIC"),
131 _FROMMB(_("Media Resource Locator (MRL)")),
132 WS_CHILD | WS_VISIBLE | SS_LEFT,
133 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
135 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
136 WS_CHILD | WS_VISIBLE | SS_LEFT,
137 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
139 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
140 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
141 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
142 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
145 // No tooltips for ComboBox
146 label = CreateWindow( _T("STATIC"),
147 _FROMMB(_("Alternatively, you can build an MRL "
148 "using one of the following predefined "
150 WS_CHILD | WS_VISIBLE | SS_LEFT,
151 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
154 /* Create notebook */
155 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
156 iccex.dwSize = ICC_TAB_CLASSES;
157 InitCommonControlsEx (&iccex);
159 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
160 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
161 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
162 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
163 hwnd, NULL, hInst, NULL );
165 tcItem.mask = TCIF_TEXT;
166 tcItem.pszText = _T("File");
167 TabCtrl_InsertItem( notebook, 0, &tcItem );
168 tcItem.pszText = _T("Network");
169 TabCtrl_InsertItem( notebook, 1, &tcItem );
174 TabCtrl_SetCurSel( notebook, 0 );
177 TabCtrl_SetCurSel( notebook, 1 );
192 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
193 SHSipPreference( hwnd, SIP_DOWN );
197 if( LOWORD(wp) == IDOK )
203 if( HIWORD(wp) == BN_CLICKED )
205 if( (HWND)lp == net_radios[0] )
207 OnNetTypeChange( NetRadio1_Event );
208 } else if( (HWND)lp == net_radios[1] )
210 OnNetTypeChange( NetRadio2_Event );
211 } else if( (HWND)lp == net_radios[2] )
213 OnNetTypeChange( NetRadio3_Event );
214 } else if( (HWND)lp == net_radios[3] )
216 OnNetTypeChange( NetRadio4_Event );
217 } else if( (HWND)lp == subsfile_checkbox )
220 } else if( (HWND)lp == subsfile_button )
222 OnSubsFileSettings( hwnd );
223 } else if( (HWND)lp == browse_button )
229 if( HIWORD(wp) == EN_CHANGE )
231 if( (HWND)lp == net_addrs[1] )
233 OnNetPanelChange( NetAddr2_Event );
234 } else if( (HWND)lp == net_addrs[2] )
236 OnNetPanelChange( NetAddr3_Event );
237 } else if( (HWND)lp == net_addrs[3] )
239 OnNetPanelChange( NetAddr4_Event );
240 } else if( (HWND)lp == net_ports[0] )
242 OnNetPanelChange( NetPort1_Event );
243 } else if( (HWND)lp == net_ports[1] )
245 OnNetPanelChange( NetPort2_Event );
248 if( HIWORD(wp) == CBN_EDITUPDATE )
250 if ((HWND)lp == file_combo)
258 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
265 return DefWindowProc( hwnd, msg, wp, lp );
268 /*****************************************************************************
270 *****************************************************************************/
271 void OpenDialog::FilePanel( HWND hwnd )
274 GetWindowRect( notebook, &rc );
276 /* Create browse file line */
277 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
278 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
279 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
280 5*15 + 6, hwnd, NULL, hInst, NULL );
282 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
283 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
284 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
285 hwnd, NULL, hInst, NULL );
287 /* Create Subtitles File checkox */
288 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
289 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
290 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
291 hwnd, NULL, hInst, NULL );
292 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
294 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
295 WS_CHILD | WS_VISIBLE | SS_LEFT,
296 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
297 hwnd, NULL, hInst, NULL);
299 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
300 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
301 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
302 hwnd, NULL, hInst, NULL );
304 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
305 if( psz_subsfile && *psz_subsfile )
307 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
308 EnableWindow( subsfile_button, TRUE );
309 string sz_subsfile = "sub-file=";
310 sz_subsfile += psz_subsfile;
311 subsfile_mrl.push_back( sz_subsfile );
313 free( psz_subsfile );
316 void OpenDialog::NetPanel( HWND hwnd )
318 INITCOMMONCONTROLSEX ic;
327 static struct net_type net_type_array[] =
329 { _T("UDP/RTP"), 82 },
330 { _T("UDP/RTP Multicast"), 140 },
331 { _T("HTTP/FTP/MMS"), 90 },
336 GetWindowRect( notebook, &rc);
339 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
340 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
341 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
343 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
344 WS_CHILD | WS_VISIBLE | SS_LEFT,
345 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
346 15, hwnd, NULL, hInst, NULL );
348 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
350 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
351 WS_CHILD | WS_VISIBLE | SS_LEFT,
352 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
353 hwnd, NULL, hInst, NULL );
355 _stprintf( psz_text, _T("%d"), i_net_ports[0] );
356 net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
357 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
358 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
359 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
361 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
362 ic.dwICC = ICC_UPDOWN_CLASS;
363 InitCommonControlsEx(&ic);
365 hUpdown[0] = CreateUpDownControl(
366 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
367 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
368 0, 0, 0, 0, hwnd, 0, hInst,
369 net_ports[0], 16000, 0, i_net_ports[0]);
371 /* UDP/RTP Multicast row */
372 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
373 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
374 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
375 hwnd, NULL, hInst, NULL);
377 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
378 WS_CHILD | WS_VISIBLE | SS_LEFT,
379 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
380 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
382 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
383 WS_CHILD | WS_VISIBLE | SS_LEFT,
384 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
385 hwnd, NULL, hInst, NULL);
387 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
388 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
389 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
390 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
391 hwnd, NULL, hInst, NULL);
393 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
394 WS_CHILD | WS_VISIBLE | SS_LEFT,
395 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
396 hwnd, NULL, hInst, NULL);
398 i_net_ports[1] = i_net_ports[0];
400 _stprintf( psz_text, _T("%d"), i_net_ports[1] );
401 net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
402 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
403 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
404 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
405 hwnd, NULL, hInst, NULL );
407 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
408 ic.dwICC = ICC_UPDOWN_CLASS;
409 InitCommonControlsEx(&ic);
411 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
412 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
413 0, 0, 0, 0, hwnd, 0, hInst,
414 net_ports[1], 16000, 0, i_net_ports[1] );
416 /* HTTP and RTSP rows */
417 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
418 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
419 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
420 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
422 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
423 WS_CHILD | WS_VISIBLE | SS_LEFT,
424 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
425 rc.top + 10, net_type_array[2].length, 15,
426 hwnd, NULL, hInst, NULL );
428 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
429 WS_CHILD | WS_VISIBLE | SS_LEFT,
430 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
431 hwnd, NULL, hInst, NULL );
433 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
434 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
435 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
436 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
437 hwnd, NULL, hInst, NULL);
439 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
440 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
441 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
442 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
444 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
445 WS_CHILD | WS_VISIBLE | SS_LEFT,
446 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
447 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
448 hwnd, NULL, hInst, NULL );
450 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
451 WS_CHILD | WS_VISIBLE | SS_LEFT,
452 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
453 hwnd, NULL, hInst, NULL );
455 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
456 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
457 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
458 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
459 hwnd, NULL, hInst, NULL );
461 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
464 void OpenDialog::UpdateMRL()
466 UpdateMRL( i_access );
469 void OpenDialog::UpdateMRL( int i_access_method )
471 string demux, mrltemp;
472 TCHAR psz_text[2048];
475 i_access = i_access_method;
477 switch( i_access_method )
480 GetWindowText( file_combo, psz_text, 2048 );
481 mrltemp = _TOMB(psz_text);
487 mrltemp = "udp" + demux + "://";
488 if( i_net_ports[0] !=
489 config_GetInt( p_intf, "server-port" ) )
491 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
497 mrltemp = "udp" + demux + "://@";
498 Edit_GetText( net_addrs[1], psz_text, 2048 );
499 mrltemp += _TOMB(psz_text);
500 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
502 sprintf( psz_tmp, ":%d", i_net_ports[1] );
509 Edit_GetText( net_addrs[2], psz_text, 2048 );
510 if( !strstr( _TOMB(psz_text), "http://" ) )
512 mrltemp = "http" + demux + "://";
514 mrltemp += _TOMB(psz_text);
519 Edit_GetText( net_addrs[3], psz_text, 2048 );
520 if( !strstr( _TOMB(psz_text), "rtsp://" ) )
522 mrltemp = "rtsp" + demux + "://";
524 mrltemp += _TOMB(psz_text);
532 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
535 void OpenDialog::OnPageChange()
537 if( TabCtrl_GetCurSel( notebook ) == 0 )
539 for( int i=0; i<4; i++ )
541 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
542 SWP_NOMOVE | SWP_NOSIZE );
543 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
544 SWP_NOMOVE | SWP_NOSIZE );
548 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
549 SWP_NOMOVE | SWP_NOSIZE );
550 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
551 SWP_NOMOVE | SWP_NOSIZE );
552 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
553 SWP_NOMOVE | SWP_NOSIZE );
554 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
555 SWP_NOMOVE | SWP_NOSIZE );
556 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
557 SWP_NOMOVE | SWP_NOSIZE );
559 i_access = FILE_ACCESS;
561 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
563 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
564 SWP_NOMOVE | SWP_NOSIZE );
565 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
566 SWP_NOMOVE | SWP_NOSIZE );
567 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
568 SWP_NOMOVE | SWP_NOSIZE );
569 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
570 SWP_NOMOVE | SWP_NOSIZE );
571 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
572 SWP_NOMOVE | SWP_NOSIZE );
574 for( int i=0; i<4; i++ )
576 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
577 SWP_NOMOVE | SWP_NOSIZE );
578 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
579 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
580 SWP_NOMOVE | SWP_NOSIZE );
582 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
583 SWP_NOMOVE | SWP_NOSIZE );
584 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
585 SWP_NOMOVE | SWP_NOSIZE );
586 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
587 SWP_NOMOVE | SWP_NOSIZE );
589 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
591 i_access = NET_ACCESS;
597 void OpenDialog::OnOk()
599 TCHAR psz_text[2048];
601 GetWindowText( mrl_combo, psz_text, 2048 );
604 char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
606 ComboBox_AddString( mrl_combo, psz_text );
607 if( ComboBox_GetCount( mrl_combo ) > 10 )
608 ComboBox_DeleteString( mrl_combo, 0 );
609 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
611 /* Update the playlist */
612 playlist_t *p_playlist = pl_Yield( p_intf );
613 if( p_playlist == NULL ) return;
615 for( int i = 0; i < i_args; i++ )
617 bool b_start = !i && i_open_arg;
618 playlist_item_t *p_item =
619 playlist_ItemNew( p_playlist, 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 pl_Release( p_intf );
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;