]> git.sesse.net Git - vlc/blob - modules/gui/wince/open.cpp
24d2bad2b48dc9abc1aee94a4733d33bdaaf37b7
[vlc] / modules / gui / wince / open.cpp
1 /*****************************************************************************
2  * open.cpp : WinCE gui plugin for VLC
3  *****************************************************************************
4  * Copyright (C) 2000-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8  *          Gildas Bazin <gbazin@videolan.org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_playlist.h>
35
36 #include "wince.h"
37
38 #include <windowsx.h>
39 #include <commctrl.h>
40 #include <commdlg.h>
41 #include <shlobj.h>
42
43 /*****************************************************************************
44  * Event Table.
45  *****************************************************************************/
46
47 /* IDs for the controls and the menu commands */
48 enum
49 {
50     Notebook_Event = 1000,
51     MRL_Event,
52
53     FileBrowse_Event,
54     FileName_Event,
55
56     DiscType_Event,
57     DiscDevice_Event,
58     DiscTitle_Event,
59     DiscChapter_Event,
60
61     NetType_Event,
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,
65
66     SubsFileEnable_Event,
67     SubsFileSettings_Event,
68 };
69
70 /*****************************************************************************
71  * AutoBuiltPanel.
72  *****************************************************************************/
73
74 /*****************************************************************************
75  * Constructor.
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 )
80 {
81     /* Initializations */
82     i_access = _i_access;
83     i_open_arg = _i_arg;
84
85     for( int i = 0; i < 4; i++ )
86     {
87         net_radios[i] = 0;
88         net_label[i] = 0;
89         net_port_label[i] = 0;
90         net_ports[i] = 0;
91         hUpdown[i] = 0;
92         i_net_ports[i] = 0;
93         net_addrs_label[i] = 0;
94         net_addrs[i] = 0;
95     }
96
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 );
101 }
102
103 /***********************************************************************
104
105 FUNCTION:
106   WndProc
107
108 PURPOSE:
109   Processes messages sent to the main window.
110  
111 ***********************************************************************/
112 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
113 {
114     SHINITDLGINFO shidi;
115     INITCOMMONCONTROLSEX  iccex;  // INITCOMMONCONTROLSEX structure
116     RECT rcClient;
117     TC_ITEM tcItem;
118
119     switch( msg )
120     {
121     case WM_CREATE:
122         shidi.dwMask = SHIDIM_FLAGS;
123         shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
124         shidi.hDlg = hwnd;
125         SHInitDialog( &shidi );
126
127         // Get the client area rect to put the panels in
128         GetClientRect( hwnd, &rcClient );
129
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 );
135
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 );
139
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,
144                                   0, hInst, 0 );
145
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 "
150                                        "targets:" )),
151                               WS_CHILD | WS_VISIBLE | SS_LEFT,
152                               5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
153                               hwnd, 0, hInst, 0 );
154
155         /* Create notebook */
156         iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
157         iccex.dwSize = ICC_TAB_CLASSES;
158         InitCommonControlsEx (&iccex);
159
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 );
165
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 );
171
172         switch( i_access )
173         {
174         case FILE_ACCESS:
175             TabCtrl_SetCurSel( notebook, 0 );
176             break;
177         case NET_ACCESS:
178             TabCtrl_SetCurSel( notebook, 1 );
179             break;
180         }
181
182         FilePanel( hwnd );
183         NetPanel( hwnd );
184
185         OnPageChange();
186         break;
187
188     case WM_CLOSE:
189         Show( FALSE );
190         return TRUE;
191
192     case WM_SETFOCUS:
193         SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
194         SHSipPreference( hwnd, SIP_DOWN );
195         break;
196
197     case WM_COMMAND:
198         if( LOWORD(wp) == IDOK )
199         {
200             OnOk();
201             Show( FALSE );
202             break;
203         }
204         if( HIWORD(wp) == BN_CLICKED )
205         {
206             if( (HWND)lp == net_radios[0] )
207             {
208                 OnNetTypeChange( NetRadio1_Event );
209             } else if( (HWND)lp == net_radios[1] )
210             {
211                 OnNetTypeChange( NetRadio2_Event );
212             } else if( (HWND)lp == net_radios[2] )
213             {
214                 OnNetTypeChange( NetRadio3_Event );
215             } else if( (HWND)lp == net_radios[3] )
216             {
217                 OnNetTypeChange( NetRadio4_Event );
218             } else if( (HWND)lp == subsfile_checkbox )
219             {
220                 OnSubsFileEnable();
221             } else if( (HWND)lp == subsfile_button )
222             {
223                 OnSubsFileSettings( hwnd );
224             } else if( (HWND)lp == browse_button )
225             {
226                 OnFileBrowse();
227             }
228             break;
229         }
230         if( HIWORD(wp) == EN_CHANGE )
231         {
232             if( (HWND)lp == net_addrs[1] )
233             {
234                 OnNetPanelChange( NetAddr2_Event );
235             } else if( (HWND)lp == net_addrs[2] )
236             {
237                 OnNetPanelChange( NetAddr3_Event );
238             } else if( (HWND)lp == net_addrs[3] )
239             {
240                 OnNetPanelChange( NetAddr4_Event );
241             } else if( (HWND)lp == net_ports[0] )
242             {
243                 OnNetPanelChange( NetPort1_Event );
244             } else if( (HWND)lp == net_ports[1] )
245             {
246                 OnNetPanelChange( NetPort2_Event );
247             }
248         }
249         if( HIWORD(wp) == CBN_EDITUPDATE )
250         {
251             if ((HWND)lp == file_combo)
252             {
253                 OnFilePanelChange();
254             }
255         }
256         break;
257
258     case WM_NOTIFY:
259         if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
260         break;
261
262     default:
263         break;
264     }
265
266     return DefWindowProc( hwnd, msg, wp, lp );
267 }
268
269 /*****************************************************************************
270  * Private methods.
271  *****************************************************************************/
272 void OpenDialog::FilePanel( HWND hwnd )
273 {
274     RECT rc;
275     GetWindowRect( notebook, &rc );
276
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 );
282
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 );
287
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 );
294
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);
299
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 );
304
305     char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
306     if( psz_subsfile && *psz_subsfile )
307     {
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 );
313     }
314     free( psz_subsfile );
315 }
316
317 void OpenDialog::NetPanel( HWND hwnd )
318 {
319     INITCOMMONCONTROLSEX ic;
320     TCHAR psz_text[256];
321
322     struct net_type
323     {
324         TCHAR *psz_text;
325         int length;
326     };
327
328     static struct net_type net_type_array[] =
329     {
330         { _T("UDP/RTP"), 82 },
331         { _T("UDP/RTP Multicast"), 140 },
332         { _T("HTTP/FTP/MMS"), 90 },
333         { _T("RTSP"), 30 }
334     };
335
336     RECT rc;
337     GetWindowRect( notebook, &rc);
338
339     /* UDP/RTP row */
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 );
343
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 );
348
349     i_net_ports[0] = config_GetInt( p_intf, "server-port" );
350
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 );
355
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 );
361
362     ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
363     ic.dwICC = ICC_UPDOWN_CLASS;
364     InitCommonControlsEx(&ic);
365
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]);
371
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);
377
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 );
382
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);
387
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);
393
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);
398
399     i_net_ports[1] = i_net_ports[0];
400
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 );
407
408     ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
409     ic.dwICC = ICC_UPDOWN_CLASS;
410     InitCommonControlsEx(&ic);
411
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] );
416
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 );
422  
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 );
428
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 );
433
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);
439
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 );
444
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 );
450
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 );
455
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 );
461
462     SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
463 }
464
465 void OpenDialog::UpdateMRL()
466 {
467     UpdateMRL( i_access );
468 }
469
470 void OpenDialog::UpdateMRL( int i_access_method )
471 {
472     string demux, mrltemp;
473     TCHAR psz_text[2048];
474     char psz_tmp[256];
475
476     i_access = i_access_method;
477
478     switch( i_access_method )
479     {
480     case FILE_ACCESS:
481         GetWindowText( file_combo, psz_text, 2048 );
482         mrltemp = _TOMB(psz_text);
483         break;
484     case NET_ACCESS:
485         switch( i_net_type )
486         {
487         case 0:
488             mrltemp = "udp" + demux + "://";
489             if( i_net_ports[0] !=
490                 config_GetInt( p_intf, "server-port" ) )
491             {
492                 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
493                 mrltemp += psz_tmp;
494             }
495             break;
496
497         case 1:
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" ) )
502             {
503                 sprintf( psz_tmp, ":%d", i_net_ports[1] );
504                 mrltemp += psz_tmp;
505             }
506             break;
507
508         case 2:
509             /* http access */
510             Edit_GetText( net_addrs[2], psz_text, 2048 );
511             if( !strstr( _TOMB(psz_text), "http://" ) )
512             {
513                 mrltemp = "http" + demux + "://";
514             }
515             mrltemp += _TOMB(psz_text);
516             break;
517
518         case 3:
519             /* RTSP access */
520             Edit_GetText( net_addrs[3], psz_text, 2048 );
521             if( !strstr( _TOMB(psz_text), "rtsp://" ) )
522             {
523                 mrltemp = "rtsp" + demux + "://";
524             }
525             mrltemp += _TOMB(psz_text);
526             break;
527         }
528         break;
529     default:
530         break;
531     }
532
533     SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
534 }
535
536 void OpenDialog::OnPageChange()
537 {
538     if( TabCtrl_GetCurSel( notebook ) == 0 )
539     {
540         for( int i=0; i<4; i++ )
541         {
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 );
546         }
547         DisableNETCtrl();
548
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 );
559
560         i_access = FILE_ACCESS;
561     }
562     else if ( TabCtrl_GetCurSel( notebook ) == 1 )
563     {
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 );
574
575         for( int i=0; i<4; i++ )
576         {
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 );
582         }
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 );
589
590         SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
591
592         i_access = NET_ACCESS;
593     }
594
595     UpdateMRL();
596 }
597
598 void OpenDialog::OnOk()
599 {
600     TCHAR psz_text[2048];
601
602     GetWindowText( mrl_combo, psz_text, 2048 );
603
604     int i_args;
605     /*char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
606
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 );*/
611
612     /* Update the playlist */
613     playlist_t *p_playlist = pl_Yield( p_intf );
614     if( p_playlist == NULL ) return;
615
616  /*   for( int i = 0; i < i_args; i++ )
617     {
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] );
621
622         /* Insert options */
623 /*        while( i + 1 < i_args && pp_args[i + 1][0] == ':' )
624         {
625             playlist_ItemAddOption( p_item, pp_args[i + 1] );
626             i++;
627         }*/
628
629         /* Get the options from the subtitles dialog */
630 /*        if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
631             && subsfile_mrl.size() )
632         {
633             for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
634             {
635                 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
636             }
637         }
638
639
640         if( b_start )
641         {
642             playlist_AddItem( p_playlist, p_item,
643                               PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END );
644         }
645         else
646         {
647             playlist_AddItem( p_playlist, p_item,
648                               PLAYLIST_APPEND, PLAYLIST_END );
649         }
650     }
651
652     //TogglePlayButton( PLAYING_S );
653
654     while( i_args-- )
655     {
656         free( pp_args[i_args] );
657         if( !i_args ) free( pp_args );
658     }*/
659     pl_Release( p_intf );
660 }
661
662 /*****************************************************************************
663  * File panel event methods.
664  *****************************************************************************/
665 void OpenDialog::OnFilePanelChange()
666 {
667     UpdateMRL( FILE_ACCESS );
668 }
669
670 static void OnOpenCB( intf_dialog_args_t *p_arg )
671 {
672     OpenDialog *p_this = (OpenDialog *)p_arg->p_arg;
673     char psz_tmp[PATH_MAX+2] = "\0";
674
675     if( p_arg->i_results && p_arg->psz_results[0] )
676     {
677         if( strchr( p_arg->psz_results[0], ' ' ) )
678         {
679             strcat( psz_tmp, "\"" );
680             strcat( psz_tmp, p_arg->psz_results[0] );
681             strcat( psz_tmp, "\"" );
682         }
683         else strcat( psz_tmp, p_arg->psz_results[0] );
684
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 );
689
690         p_this->UpdateMRL( FILE_ACCESS );
691     }
692 }
693
694 void OpenDialog::OnFileBrowse()
695 {
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) );
699
700     p_arg->psz_title = strdup( "Open file" );
701     p_arg->psz_extensions = strdup( "All (*.*)|*.*" );
702     p_arg->p_arg = this;
703     p_arg->pf_callback = OnOpenCB;
704
705     p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
706 }
707
708 /*****************************************************************************
709  * Net panel event methods.
710  *****************************************************************************/
711 void OpenDialog::OnNetPanelChange( int event )
712 {
713     TCHAR psz_text[2048];
714     int port;
715
716     if( event >= NetPort1_Event && event <= NetPort2_Event )
717     {
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;
721     }
722
723     UpdateMRL( NET_ACCESS );
724 }
725
726 void OpenDialog::OnNetTypeChange( int event )
727 {
728     DisableNETCtrl();
729
730     i_net_type = event - NetRadio1_Event;
731
732     if( event == NetRadio1_Event )
733     {
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 );
740     }
741     else if( event == NetRadio2_Event )
742     {
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 );
753     }
754     else if( event == NetRadio3_Event )
755     {
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 );
760     }
761     else if( event == NetRadio4_Event )
762     {
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 );
767     }
768  
769     UpdateMRL( NET_ACCESS );
770 }
771
772 void OpenDialog::DisableNETCtrl()
773 {
774     for( int i=0; i<4; i++ )
775     {
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 );
786     }
787
788     UpdateMRL( FILE_ACCESS );
789 }
790
791 /*****************************************************************************
792  * Subtitles file event methods.
793  *****************************************************************************/
794 void OpenDialog::OnSubsFileEnable()
795 {
796     EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
797                   BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
798 }
799
800 void OpenDialog::OnSubsFileSettings( HWND hwnd )
801 {
802
803     /* Show/hide the open dialog */
804     SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
805     CreateDialogBox(  hwnd, subsfile_dialog );
806
807     subsfile_mrl.clear();
808
809     for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
810         subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
811
812     delete subsfile_dialog;
813 }