1 /*****************************************************************************
2 * open.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
29 #include <string.h> /* strerror() */
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, HINSTANCE _hInst,
77 int _i_access_method, int _i_arg, int _i_method )
82 i_current_access_method = _i_access_method;
87 /***********************************************************************
93 Processes messages sent to the main window.
95 ***********************************************************************/
96 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
101 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
105 LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
106 BOOL bWasProcessed = *pbProcessed;
112 shidi.dwMask = SHIDIM_FLAGS;
113 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
114 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
116 SHInitDialog( &shidi );
118 //Create the menubar.
119 memset( &mbi, 0, sizeof(SHMENUBARINFO) );
120 mbi.cbSize = sizeof(SHMENUBARINFO);
121 mbi.hwndParent = hwnd;
122 mbi.nToolBarId = IDR_DUMMYMENU;
123 mbi.hInstRes = hInst;
127 if( !SHCreateMenuBar( &mbi ) )
129 MessageBox( hwnd, _T("SHCreateMenuBar failed"),
130 _T("Error"), MB_OK );
136 // Get the client area rect to put the panels in
137 GetClientRect( hwnd, &rcClient );
139 /* Create MRL combobox */
140 mrl_box = CreateWindow( _T("STATIC"),
141 _FROMMB(_("Media Resource Locator (MRL)")),
142 WS_CHILD | WS_VISIBLE | SS_LEFT,
143 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
145 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
146 WS_CHILD | WS_VISIBLE | SS_LEFT,
147 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
149 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
150 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
151 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
152 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
155 // No tooltips for ComboBox
157 label = CreateWindow( _T("STATIC"),
158 _FROMMB(_("Alternatively, you can build an MRL "
159 "using one of the following predefined "
161 WS_CHILD | WS_VISIBLE | SS_LEFT,
162 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
165 /* Create notebook */
166 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
167 iccex.dwSize = ICC_TAB_CLASSES;
168 InitCommonControlsEx (&iccex);
170 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
171 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
172 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
173 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
174 hwnd, NULL, hInst, NULL );
176 tcItem.mask = TCIF_TEXT;
177 tcItem.pszText = _T("File");
178 TabCtrl_InsertItem( notebook, 0, &tcItem );
179 tcItem.pszText = _T("Network");
180 TabCtrl_InsertItem( notebook, 1, &tcItem );
182 switch( i_current_access_method )
185 TabCtrl_SetCurSel( notebook, 0 );
188 TabCtrl_SetCurSel( notebook, 1 );
200 if( LOWORD(wp) == IDOK )
203 EndDialog( hwnd, LOWORD( wp ) );
206 if( HIWORD(wp) == BN_CLICKED )
208 if( (HWND)lp == net_radios[0] )
210 OnNetTypeChange( NetRadio1_Event );
212 } else if( (HWND)lp == net_radios[1] )
214 OnNetTypeChange( NetRadio2_Event );
216 } else if( (HWND)lp == net_radios[2] )
218 OnNetTypeChange( NetRadio3_Event );
220 } else if( (HWND)lp == net_radios[3] )
222 OnNetTypeChange( NetRadio4_Event );
224 } else if( (HWND)lp == subsfile_checkbox )
228 } else if( (HWND)lp == subsfile_button )
230 OnSubsFileSettings( hwnd );
232 } else if( (HWND)lp == browse_button )
234 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
239 if( HIWORD(wp) == EN_CHANGE )
241 if( (HWND)lp == net_addrs[1] )
243 OnNetPanelChange( NetAddr2_Event );
244 } else if( (HWND)lp == net_addrs[2] )
246 OnNetPanelChange( NetAddr3_Event );
247 } else if( (HWND)lp == net_addrs[3] )
249 OnNetPanelChange( NetAddr4_Event );
250 } else if( (HWND)lp == net_ports[0] )
252 OnNetPanelChange( NetPort1_Event );
253 } else if( (HWND)lp == net_ports[1] )
255 OnNetPanelChange( NetPort2_Event );
258 if( HIWORD(wp) == CBN_EDITUPDATE )
260 if ((HWND)lp == file_combo)
266 *pbProcessed = bWasProcessed;
271 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE )
277 *pbProcessed = bWasProcessed;
282 // the message was not processed
283 // indicate if the base class handled it
284 *pbProcessed = bWasProcessed;
292 /*****************************************************************************
294 *****************************************************************************/
295 void OpenDialog::FilePanel( HWND hwnd )
298 GetWindowRect( notebook, &rc);
300 /* Create browse file line */
301 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
302 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
303 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
304 5*15 + 6, hwnd, NULL, hInst, NULL );
306 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
307 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
308 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
309 hwnd, NULL, hInst, NULL );
311 /* Create Subtitles File checkox */
312 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
313 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
314 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
315 hwnd, NULL, hInst, NULL );
316 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
318 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
319 WS_CHILD | WS_VISIBLE | SS_LEFT,
320 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
321 hwnd, NULL, hInst, NULL);
323 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
324 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
325 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
326 hwnd, NULL, hInst, NULL );
328 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
329 if( psz_subsfile && *psz_subsfile )
331 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
332 EnableWindow( subsfile_button, TRUE );
333 string sz_subsfile = "sub-file=";
334 sz_subsfile += psz_subsfile;
335 subsfile_mrl.push_back( sz_subsfile );
337 if( psz_subsfile ) free( psz_subsfile );
340 void OpenDialog::NetPanel( HWND hwnd )
342 INITCOMMONCONTROLSEX ic;
351 static struct net_type net_type_array[] =
353 { _T("UDP/RTP"), 82 },
354 { _T("UDP/RTP Multicast"), 140 },
355 { _T("HTTP/FTP/MMS"), 90 },
360 GetWindowRect( notebook, &rc);
363 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
364 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
365 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
367 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
368 WS_CHILD | WS_VISIBLE | SS_LEFT,
369 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
370 15, hwnd, NULL, hInst, NULL );
372 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
374 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
375 WS_CHILD | WS_VISIBLE | SS_LEFT,
376 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
377 hwnd, NULL, hInst, NULL );
379 _stprintf( psz_text, _T("%d"), i_net_ports[0] );
380 net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
381 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
382 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
383 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
385 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
386 ic.dwICC = ICC_UPDOWN_CLASS;
387 InitCommonControlsEx(&ic);
389 hUpdown[0] = CreateUpDownControl(
390 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
391 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
392 0, 0, 0, 0, hwnd, 0, hInst,
393 net_ports[0], 16000, 0, i_net_ports[0]);
395 /* UDP/RTP Multicast row */
396 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
397 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
398 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
399 hwnd, NULL, hInst, NULL);
401 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
402 WS_CHILD | WS_VISIBLE | SS_LEFT,
403 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
404 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
406 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
407 WS_CHILD | WS_VISIBLE | SS_LEFT,
408 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
409 hwnd, NULL, hInst, NULL);
411 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
412 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
413 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
414 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
415 hwnd, NULL, hInst, NULL);
417 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
418 WS_CHILD | WS_VISIBLE | SS_LEFT,
419 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
420 hwnd, NULL, hInst, NULL);
422 i_net_ports[1] = i_net_ports[0];
424 _stprintf( psz_text, _T("%d"), i_net_ports[1] );
425 net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
426 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
427 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
428 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
429 hwnd, NULL, hInst, NULL );
431 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
432 ic.dwICC = ICC_UPDOWN_CLASS;
433 InitCommonControlsEx(&ic);
435 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
436 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
437 0, 0, 0, 0, hwnd, 0, hInst,
438 net_ports[1], 16000, 0, i_net_ports[1] );
440 /* HTTP and RTSP rows */
441 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
442 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
443 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
444 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
446 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
447 WS_CHILD | WS_VISIBLE | SS_LEFT,
448 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
449 rc.top + 10, net_type_array[2].length, 15,
450 hwnd, NULL, hInst, NULL );
452 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
453 WS_CHILD | WS_VISIBLE | SS_LEFT,
454 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
455 hwnd, NULL, hInst, NULL );
457 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
458 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
459 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
460 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
461 hwnd, NULL, hInst, NULL);
463 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
464 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
465 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
466 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
468 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
469 WS_CHILD | WS_VISIBLE | SS_LEFT,
470 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
471 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
472 hwnd, NULL, hInst, NULL );
474 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
475 WS_CHILD | WS_VISIBLE | SS_LEFT,
476 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
477 hwnd, NULL, hInst, NULL );
479 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
480 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
481 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
482 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
483 hwnd, NULL, hInst, NULL );
485 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
488 void OpenDialog::UpdateMRL()
490 UpdateMRL( i_current_access_method );
493 void OpenDialog::UpdateMRL( int i_access_method )
495 string demux, mrltemp;
496 TCHAR psz_text[2048];
499 i_current_access_method = i_access_method;
501 switch( i_access_method )
504 GetWindowText( file_combo, psz_text, 2048 );
505 mrltemp = _TOMB(psz_text);
511 mrltemp = "udp" + demux + "://";
512 if( i_net_ports[0] !=
513 config_GetInt( p_intf, "server-port" ) )
515 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
521 mrltemp = "udp" + demux + "://@";
522 Edit_GetText( net_addrs[1], psz_text, 2048 );
523 mrltemp += _TOMB(psz_text);
524 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
526 sprintf( psz_tmp, ":%d", i_net_ports[1] );
533 Edit_GetText( net_addrs[2], psz_text, 2048 );
534 if( !strstr( _TOMB(psz_text), "http://" ) )
536 mrltemp = "http" + demux + "://";
538 mrltemp += _TOMB(psz_text);
543 Edit_GetText( net_addrs[3], psz_text, 2048 );
544 if( !strstr( _TOMB(psz_text), "rtsp://" ) )
546 mrltemp = "rtsp" + demux + "://";
548 mrltemp += _TOMB(psz_text);
556 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
559 void OpenDialog::OnPageChange()
561 if( TabCtrl_GetCurSel( notebook ) == 0 )
563 for( int i=0; i<4; i++ )
565 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
566 SWP_NOMOVE | SWP_NOSIZE );
567 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
568 SWP_NOMOVE | SWP_NOSIZE );
572 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
573 SWP_NOMOVE | SWP_NOSIZE );
574 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
575 SWP_NOMOVE | SWP_NOSIZE );
576 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
577 SWP_NOMOVE | SWP_NOSIZE );
578 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
579 SWP_NOMOVE | SWP_NOSIZE );
580 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
581 SWP_NOMOVE | SWP_NOSIZE );
583 i_current_access_method = FILE_ACCESS;
585 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
587 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
588 SWP_NOMOVE | SWP_NOSIZE );
589 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
590 SWP_NOMOVE | SWP_NOSIZE );
591 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
592 SWP_NOMOVE | SWP_NOSIZE );
593 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
594 SWP_NOMOVE | SWP_NOSIZE );
595 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
596 SWP_NOMOVE | SWP_NOSIZE );
598 for( int i=0; i<4; i++ )
600 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
601 SWP_NOMOVE | SWP_NOSIZE );
602 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
603 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
604 SWP_NOMOVE | SWP_NOSIZE );
606 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
607 SWP_NOMOVE | SWP_NOSIZE );
608 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
609 SWP_NOMOVE | SWP_NOSIZE );
610 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
611 SWP_NOMOVE | SWP_NOSIZE );
613 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
615 i_current_access_method = NET_ACCESS;
621 void OpenDialog::OnOk()
623 TCHAR psz_text[2048];
625 GetWindowText( mrl_combo, psz_text, 2048 ); // replace by ComboBox_GetText( mrl_combo, wUnicode, size )
626 mrl = SeparateEntries( psz_text );
627 ComboBox_AddString( mrl_combo, psz_text );
628 if( ComboBox_GetCount( mrl_combo ) > 10 )
629 ComboBox_DeleteString( mrl_combo, 0 );
630 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
632 /* Update the playlist */
633 playlist_t *p_playlist =
634 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
636 if( p_playlist == NULL ) return;
638 for( int i = 0; i < (int)mrl.size(); i++ )
640 vlc_bool_t b_start = !i && i_open_arg;
641 playlist_item_t *p_item =
642 playlist_ItemNew( p_intf, (const char*)mrl[i].c_str(),
643 (const char *)mrl[i].c_str() );
646 while( i + 1 < (int)mrl.size() &&
647 ((const char *)mrl[i + 1].c_str())[0] == ':' )
649 playlist_ItemAddOption( p_item, mrl[i + 1].c_str() );
653 /* Get the options from the subtitles dialog */
654 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
655 && subsfile_mrl.size() )
657 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
659 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
663 playlist_AddItem( p_playlist, p_item,
664 PLAYLIST_APPEND, PLAYLIST_END );
668 playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
672 //TogglePlayButton( PLAYING_S );
674 vlc_object_release( p_playlist );
677 /*****************************************************************************
678 * File panel event methods.
679 *****************************************************************************/
680 void OpenDialog::OnFilePanelChange()
682 UpdateMRL( FILE_ACCESS );
685 void OpenDialog::OnFileBrowse()
688 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
689 TCHAR psz_file[PATH_MAX] = _T("\0");
690 TCHAR psz_tmp[PATH_MAX+2] = _T("\0");
692 memset(&ofn, 0, sizeof(OPENFILENAME));
693 ofn.lStructSize = sizeof (OPENFILENAME);
694 ofn.hwndOwner = NULL;
695 ofn.hInstance = hInst;
696 ofn.lpstrFilter = szFilter;
697 ofn.lpstrCustomFilter = NULL;
698 ofn.nMaxCustFilter = 0;
699 ofn.nFilterIndex = 1;
700 ofn.lpstrFile = psz_file;
701 ofn.nMaxFile = PATH_MAX;
702 ofn.lpstrFileTitle = NULL;
703 ofn.nMaxFileTitle = 40;
704 ofn.lpstrInitialDir = NULL;
705 ofn.lpstrTitle = _T("Open File");
708 ofn.nFileExtension = 0;
709 ofn.lpstrDefExt = NULL;
712 ofn.lpTemplateName = NULL;
713 if( GetOpenFileName((LPOPENFILENAME) &ofn) )
715 if( _tcschr( ofn.lpstrFile, _T(' ') ) )
717 _tcscat( psz_tmp, _T("\"") );
718 _tcscat( psz_tmp, ofn.lpstrFile );
719 _tcscat( psz_tmp, _T("\"") );
721 else _tcscat( psz_tmp, ofn.lpstrFile );
723 SetWindowText( file_combo, psz_tmp );
724 ComboBox_AddString( file_combo, psz_tmp );
725 if( ComboBox_GetCount( file_combo ) > 10 )
726 ComboBox_DeleteString( file_combo, 0 );
728 UpdateMRL( FILE_ACCESS );
732 /*****************************************************************************
733 * Net panel event methods.
734 *****************************************************************************/
735 void OpenDialog::OnNetPanelChange( int event )
737 TCHAR psz_text[2048];
740 if( event >= NetPort1_Event && event <= NetPort2_Event )
742 Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
743 _stscanf( psz_text, _T("%d"), &port );
744 i_net_ports[event - NetPort1_Event] = port;
747 UpdateMRL( NET_ACCESS );
750 void OpenDialog::OnNetTypeChange( int event )
754 i_net_type = event - NetRadio1_Event;
756 if( event == NetRadio1_Event )
758 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
759 SWP_NOMOVE | SWP_NOSIZE );
760 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
761 SWP_NOMOVE | SWP_NOSIZE );
762 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
763 SWP_NOMOVE | SWP_NOSIZE );
765 else if( event == NetRadio2_Event )
767 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
768 SWP_NOMOVE | SWP_NOSIZE );
769 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
770 SWP_NOMOVE | SWP_NOSIZE );
771 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
772 SWP_NOMOVE | SWP_NOSIZE );
773 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
774 SWP_NOMOVE | SWP_NOSIZE );
775 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
776 SWP_NOMOVE | SWP_NOSIZE );
778 else if( event == NetRadio3_Event )
780 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
781 SWP_NOMOVE | SWP_NOSIZE );
782 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
783 SWP_NOMOVE | SWP_NOSIZE );
785 else if( event == NetRadio4_Event )
787 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
788 SWP_NOMOVE | SWP_NOSIZE );
789 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
790 SWP_NOMOVE | SWP_NOSIZE );
793 UpdateMRL( NET_ACCESS );
796 void OpenDialog::DisableNETCtrl()
798 for( int i=0; i<4; i++ )
800 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
801 SWP_NOMOVE | SWP_NOSIZE );
802 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
803 SWP_NOMOVE | SWP_NOSIZE );
804 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
805 SWP_NOMOVE | SWP_NOSIZE );
806 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
807 SWP_NOMOVE | SWP_NOSIZE );
808 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
809 SWP_NOMOVE | SWP_NOSIZE );
812 UpdateMRL( FILE_ACCESS );
815 /*****************************************************************************
816 * Subtitles file event methods.
817 *****************************************************************************/
818 void OpenDialog::OnSubsFileEnable()
820 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
821 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
824 void OpenDialog::OnSubsFileSettings( HWND hwnd )
827 /* Show/hide the open dialog */
828 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, hInst );
829 DialogBoxParam( hInst, (LPCTSTR)IDD_DUMMY, hwnd,
830 (DLGPROC)subsfile_dialog->BaseWndProc,
831 (long)subsfile_dialog );
833 subsfile_mrl.clear();
835 for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
836 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
838 delete subsfile_dialog;
841 /*****************************************************************************
843 *****************************************************************************/
844 vector<string> SeparateEntries( TCHAR *entries )
846 vlc_bool_t b_quotes_mode = VLC_FALSE;
847 vector<string> entries_array;
848 TCHAR *entry = new TCHAR[ _tcslen(entries) + 1 ];
849 TCHAR *strToken = entries;
850 int length = _tcscspn( strToken, _T(" \t\r\n\"") );
853 while( strToken - entries < _tcslen(entries) )
855 _tcsncat( entry, strToken, length );
857 _tcsncat( entry, strToken + length, 1 );
859 if( !b_quotes_mode && strToken[length] == _T('\"') )
861 /* Enters quotes mode */
862 entry[ _tcslen(entry) - 1 ] = 0;
863 b_quotes_mode = VLC_TRUE;
865 else if( b_quotes_mode && strToken[length] == _T('\"') )
867 /* Finished the quotes mode */
868 entry[ _tcslen(entry) - 1 ] = 0;
869 if( _tcscmp( entry, _T("") ) != 0 )
871 entries_array.push_back( _TOMB(entry) );
874 b_quotes_mode = VLC_FALSE;
876 else if( !b_quotes_mode && strToken[length] != _T('\"') )
878 /* we found a non-quoted standalone string */
879 if( strToken + length - entries < _tcslen(entries) ||/*token.HasMoreTokens() ||*/ //FIX ME IF YOU CAN
880 strToken[length] == _T(' ') ||
881 strToken[length] == _T('\t') ||
882 strToken[length] == _T('\r') ||
883 strToken[length] == _T('\n') )
884 entry[ _tcslen(entry) - 1 ]/*strToken[length]*/ = 0;
885 if( _tcscmp( entry, _T("") ) != 0 )
887 entries_array.push_back( _TOMB(entry) );
894 strToken += length + 1;
895 length = _tcscspn( strToken, _T(" \t\r\n\"") );
898 if( _tcscmp( entry, _T("") ) != 0 )
900 entries_array.push_back( _TOMB(entry) );
904 return entries_array;