Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

open.cpp

00001 /*****************************************************************************
00002  * open.cpp : WinCE gui plugin for VLC
00003  *****************************************************************************
00004  * Copyright (C) 2000-2004 the VideoLAN team
00005  * $Id: open.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Marodon Cedric <[email protected]>
00008  *          Gildas Bazin <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 /*****************************************************************************
00026  * Preamble
00027  *****************************************************************************/
00028 #include <stdlib.h>                                      /* malloc(), free() */
00029 #include <string.h>                                            /* strerror() */
00030 #include <stdio.h>
00031 #include <vlc/vlc.h>
00032 #include <vlc/intf.h>
00033 
00034 #include "wince.h"
00035 
00036 #include <windowsx.h>
00037 #include <commctrl.h>
00038 #include <commdlg.h>
00039 #include <shlobj.h>
00040 
00041 /*****************************************************************************
00042  * Event Table.
00043  *****************************************************************************/
00044 
00045 /* IDs for the controls and the menu commands */
00046 enum
00047 {
00048     Notebook_Event = 1000,
00049     MRL_Event,
00050 
00051     FileBrowse_Event,
00052     FileName_Event,
00053 
00054     DiscType_Event,
00055     DiscDevice_Event,
00056     DiscTitle_Event,
00057     DiscChapter_Event,
00058 
00059     NetType_Event,
00060     NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
00061     NetPort1_Event, NetPort2_Event, NetPort3_Event,
00062     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
00063 
00064     SubsFileEnable_Event,
00065     SubsFileSettings_Event,
00066 };
00067 
00068 /*****************************************************************************
00069  * AutoBuiltPanel.
00070  *****************************************************************************/
00071 
00072 /*****************************************************************************
00073  * Constructor.
00074  *****************************************************************************/
00075 OpenDialog::OpenDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
00076                         HINSTANCE h_inst, int _i_access, int _i_arg )
00077   :  CBaseWindow( p_intf, p_parent, h_inst )
00078 {
00079     /* Initializations */
00080     i_access = _i_access;
00081     i_open_arg = _i_arg;
00082 
00083     for( int i = 0; i < 4; i++ )
00084     {
00085         net_radios[i] = 0;
00086         net_label[i] = 0;
00087         net_port_label[i] = 0;
00088         net_ports[i] = 0;
00089         hUpdown[i] = 0;
00090         i_net_ports[i] = 0;
00091         net_addrs_label[i] = 0;
00092         net_addrs[i] = 0;
00093     }
00094 
00095     CreateWindow( _T("VLC WinCE"), _T("Messages"),
00096                   WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
00097                   0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
00098                   p_parent->GetHandle(), NULL, h_inst, (void *)this );
00099 }
00100 
00101 /***********************************************************************
00102 
00103 FUNCTION: 
00104   WndProc
00105 
00106 PURPOSE: 
00107   Processes messages sent to the main window.
00108   
00109 ***********************************************************************/
00110 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
00111 {
00112     SHINITDLGINFO shidi;
00113     INITCOMMONCONTROLSEX  iccex;  // INITCOMMONCONTROLSEX structure    
00114     RECT rcClient;
00115     TC_ITEM tcItem;
00116 
00117     switch( msg )
00118     {
00119     case WM_CREATE:
00120         shidi.dwMask = SHIDIM_FLAGS;
00121         shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR;
00122         shidi.hDlg = hwnd;
00123         SHInitDialog( &shidi );
00124 
00125         // Get the client area rect to put the panels in
00126         GetClientRect( hwnd, &rcClient );
00127 
00128         /* Create MRL combobox */
00129         mrl_box = CreateWindow( _T("STATIC"),
00130                                 _FROMMB(_("Media Resource Locator (MRL)")),
00131                                 WS_CHILD | WS_VISIBLE | SS_LEFT,
00132                                 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
00133 
00134         mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
00135                                   WS_CHILD | WS_VISIBLE | SS_LEFT,
00136                                   5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
00137 
00138         mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
00139                                   WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
00140                                   CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
00141                                   rcClient.right - 50 - 5, 5*15 + 6, hwnd,
00142                                   0, hInst, 0 );
00143 
00144         // No tooltips for ComboBox
00145         label = CreateWindow( _T("STATIC"),
00146                               _FROMMB(_("Alternatively, you can build an MRL "
00147                                        "using one of the following predefined "
00148                                        "targets:" )),
00149                               WS_CHILD | WS_VISIBLE | SS_LEFT,
00150                               5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
00151                               hwnd, 0, hInst, 0 );
00152 
00153         /* Create notebook */
00154         iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
00155         iccex.dwSize = ICC_TAB_CLASSES;
00156         InitCommonControlsEx (&iccex);
00157 
00158         notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
00159             WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
00160             5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
00161             rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
00162             hwnd, NULL, hInst, NULL );
00163 
00164         tcItem.mask = TCIF_TEXT;
00165         tcItem.pszText = _T("File");
00166         TabCtrl_InsertItem( notebook, 0, &tcItem );
00167         tcItem.pszText = _T("Network");
00168         TabCtrl_InsertItem( notebook, 1, &tcItem );
00169 
00170         switch( i_access )
00171         {
00172         case FILE_ACCESS:
00173             TabCtrl_SetCurSel( notebook, 0 );
00174             break;
00175         case NET_ACCESS:
00176             TabCtrl_SetCurSel( notebook, 1 );
00177             break;
00178         }
00179 
00180         FilePanel( hwnd );
00181         NetPanel( hwnd );
00182 
00183         OnPageChange();
00184         break;
00185 
00186     case WM_CLOSE:
00187         Show( FALSE );
00188         return TRUE;
00189 
00190     case WM_SETFOCUS:
00191         SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
00192         SHSipPreference( hwnd, SIP_DOWN ); 
00193         break;
00194 
00195     case WM_COMMAND:
00196         if( LOWORD(wp) == IDOK )
00197         {
00198             OnOk();
00199             Show( FALSE );
00200             break;
00201         }
00202         if( HIWORD(wp) == BN_CLICKED )
00203         {
00204             if( (HWND)lp == net_radios[0] )
00205             {
00206                 OnNetTypeChange( NetRadio1_Event );
00207             } else if( (HWND)lp == net_radios[1] )
00208             {
00209                 OnNetTypeChange( NetRadio2_Event );
00210             } else if( (HWND)lp == net_radios[2] )
00211             {
00212                 OnNetTypeChange( NetRadio3_Event );
00213             } else if( (HWND)lp == net_radios[3] )
00214             {
00215                 OnNetTypeChange( NetRadio4_Event );
00216             } else if( (HWND)lp == subsfile_checkbox )
00217             {
00218                 OnSubsFileEnable();
00219             } else if( (HWND)lp == subsfile_button )
00220             {
00221                 OnSubsFileSettings( hwnd );
00222             } else if( (HWND)lp == browse_button )
00223             {
00224                 OnFileBrowse();
00225             } 
00226             break;
00227         }
00228         if( HIWORD(wp) == EN_CHANGE )
00229         {
00230             if( (HWND)lp == net_addrs[1] )
00231             {
00232                 OnNetPanelChange( NetAddr2_Event );
00233             } else if( (HWND)lp == net_addrs[2] )
00234             {
00235                 OnNetPanelChange( NetAddr3_Event );
00236             } else if( (HWND)lp == net_addrs[3] )
00237             {
00238                 OnNetPanelChange( NetAddr4_Event );
00239             } else if( (HWND)lp == net_ports[0] )
00240             {
00241                 OnNetPanelChange( NetPort1_Event );
00242             } else if( (HWND)lp == net_ports[1] )
00243             {
00244                 OnNetPanelChange( NetPort2_Event );
00245             }
00246         }
00247         if( HIWORD(wp) == CBN_EDITUPDATE )
00248         {
00249             if ((HWND)lp == file_combo)
00250             {
00251                 OnFilePanelChange();
00252             }
00253         }
00254         break;
00255 
00256     case WM_NOTIFY:
00257         if( (((NMHDR *)lp)->code) == TCN_SELCHANGE ) OnPageChange();
00258         break;
00259 
00260     default:
00261         break;
00262     }
00263 
00264     return DefWindowProc( hwnd, msg, wp, lp );
00265 }
00266 
00267 /*****************************************************************************
00268  * Private methods.
00269  *****************************************************************************/
00270 void OpenDialog::FilePanel( HWND hwnd )
00271 {
00272     RECT rc;
00273     GetWindowRect( notebook, &rc );
00274 
00275     /* Create browse file line */
00276     file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
00277         WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
00278         rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
00279         5*15 + 6, hwnd, NULL, hInst, NULL );
00280 
00281     browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
00282         WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
00283         rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
00284         hwnd, NULL, hInst, NULL );
00285 
00286     /* Create Subtitles File checkox */
00287     subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
00288         WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
00289         rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
00290         hwnd, NULL, hInst, NULL );
00291     SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
00292 
00293     subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
00294                 WS_CHILD | WS_VISIBLE | SS_LEFT,
00295                 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
00296                 hwnd, NULL, hInst, NULL);
00297 
00298     subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
00299                 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
00300                 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
00301                 hwnd, NULL, hInst, NULL );
00302 
00303     char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
00304     if( psz_subsfile && *psz_subsfile )
00305     {
00306         SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
00307         EnableWindow( subsfile_button, TRUE );
00308         string sz_subsfile = "sub-file=";
00309         sz_subsfile += psz_subsfile;
00310         subsfile_mrl.push_back( sz_subsfile );
00311     }
00312     if( psz_subsfile ) free( psz_subsfile );
00313 }
00314 
00315 void OpenDialog::NetPanel( HWND hwnd )
00316 {
00317     INITCOMMONCONTROLSEX ic;
00318     TCHAR psz_text[256];
00319 
00320     struct net_type
00321     {
00322         TCHAR *psz_text;
00323         int length;
00324     };
00325 
00326     static struct net_type net_type_array[] =
00327     {
00328         { _T("UDP/RTP"), 82 },
00329         { _T("UDP/RTP Multicast"), 140 },
00330         { _T("HTTP/FTP/MMS"), 90 },
00331         { _T("RTSP"), 30 }
00332     };
00333 
00334     RECT rc;
00335     GetWindowRect( notebook, &rc);
00336 
00337     /* UDP/RTP row */
00338     net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].psz_text,
00339                 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
00340                 rc.left + 5, rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
00341 
00342     net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].psz_text,
00343                 WS_CHILD | WS_VISIBLE | SS_LEFT,
00344                 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length,
00345                 15, hwnd, NULL, hInst, NULL );
00346 
00347     i_net_ports[0] = config_GetInt( p_intf, "server-port" );
00348 
00349     net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
00350                 WS_CHILD | WS_VISIBLE | SS_LEFT,
00351                 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
00352                 hwnd, NULL, hInst, NULL );
00353 
00354     _stprintf( psz_text, _T("%d"), i_net_ports[0] );
00355     net_ports[0] = CreateWindow( _T("EDIT"), psz_text,
00356         WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
00357         rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
00358         rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
00359 
00360     ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
00361     ic.dwICC = ICC_UPDOWN_CLASS;
00362     InitCommonControlsEx(&ic);
00363 
00364     hUpdown[0] = CreateUpDownControl(
00365                 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
00366                 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
00367                 0, 0, 0, 0, hwnd, 0, hInst,
00368                 net_ports[0], 16000, 0, i_net_ports[0]);
00369 
00370     /* UDP/RTP Multicast row */
00371     net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].psz_text,
00372                 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
00373                 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
00374                 hwnd, NULL, hInst, NULL);
00375 
00376     net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].psz_text,
00377                 WS_CHILD | WS_VISIBLE | SS_LEFT,
00378                 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
00379                 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
00380 
00381     net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
00382                 WS_CHILD | WS_VISIBLE | SS_LEFT,
00383                 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
00384                 hwnd, NULL, hInst, NULL);
00385 
00386     net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
00387                 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
00388                 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
00389                 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
00390                 hwnd, NULL, hInst, NULL);
00391 
00392     net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
00393                 WS_CHILD | WS_VISIBLE | SS_LEFT,
00394                 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
00395                 hwnd, NULL, hInst, NULL);
00396 
00397     i_net_ports[1] = i_net_ports[0];
00398 
00399     _stprintf( psz_text, _T("%d"), i_net_ports[1] );
00400     net_ports[1] = CreateWindow( _T("EDIT"), psz_text,
00401                 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
00402                 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
00403                 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
00404                 hwnd, NULL, hInst, NULL );
00405 
00406     ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
00407     ic.dwICC = ICC_UPDOWN_CLASS;
00408     InitCommonControlsEx(&ic);
00409 
00410     hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
00411         UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
00412         0, 0, 0, 0, hwnd, 0, hInst,
00413         net_ports[1], 16000, 0, i_net_ports[1] );
00414 
00415     /* HTTP and RTSP rows */
00416     net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].psz_text,
00417         WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
00418         rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
00419         rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
00420         
00421     net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].psz_text,
00422         WS_CHILD | WS_VISIBLE | SS_LEFT,
00423         rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
00424         rc.top + 10, net_type_array[2].length, 15,
00425         hwnd, NULL, hInst, NULL );
00426 
00427     net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
00428         WS_CHILD | WS_VISIBLE | SS_LEFT,
00429         rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
00430         hwnd, NULL, hInst, NULL );
00431 
00432     net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
00433         WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
00434         rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
00435         rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
00436         hwnd, NULL, hInst, NULL);
00437 
00438     net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].psz_text,
00439         WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
00440         rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
00441         rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
00442 
00443     net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].psz_text,
00444         WS_CHILD | WS_VISIBLE | SS_LEFT,
00445         rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
00446         rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
00447         hwnd, NULL, hInst, NULL );
00448 
00449     net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
00450         WS_CHILD | WS_VISIBLE | SS_LEFT,
00451         rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
00452         hwnd, NULL, hInst, NULL );
00453 
00454     net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
00455         WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
00456         rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
00457         rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
00458         hwnd, NULL, hInst, NULL );
00459 
00460     SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
00461 }
00462 
00463 void OpenDialog::UpdateMRL()
00464 {
00465     UpdateMRL( i_access );
00466 }
00467 
00468 void OpenDialog::UpdateMRL( int i_access_method )
00469 {
00470     string demux, mrltemp;
00471     TCHAR psz_text[2048];
00472     char psz_tmp[256];
00473 
00474     i_access = i_access_method;
00475 
00476     switch( i_access_method )
00477     {
00478     case FILE_ACCESS:
00479         GetWindowText( file_combo, psz_text, 2048 );
00480         mrltemp = _TOMB(psz_text);
00481         break;
00482     case NET_ACCESS:
00483         switch( i_net_type )
00484         {
00485         case 0:
00486             mrltemp = "udp" + demux + "://";
00487             if( i_net_ports[0] !=
00488                 config_GetInt( p_intf, "server-port" ) )
00489             {
00490                 sprintf( psz_tmp, "@:%d", i_net_ports[0] );
00491                 mrltemp += psz_tmp;
00492             }
00493             break;
00494 
00495         case 1:
00496             mrltemp = "udp" + demux + "://@";
00497             Edit_GetText( net_addrs[1], psz_text, 2048 );
00498             mrltemp += _TOMB(psz_text);
00499             if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
00500             {
00501                 sprintf( psz_tmp, ":%d", i_net_ports[1] );
00502                 mrltemp += psz_tmp;
00503             }
00504             break;
00505 
00506         case 2:
00507             /* http access */
00508             Edit_GetText( net_addrs[2], psz_text, 2048 );
00509             if( !strstr( _TOMB(psz_text), "http://" ) )
00510             {
00511                 mrltemp = "http" + demux + "://";
00512             }
00513             mrltemp += _TOMB(psz_text);
00514             break;
00515 
00516         case 3:
00517             /* RTSP access */
00518             Edit_GetText( net_addrs[3], psz_text, 2048 );
00519             if( !strstr( _TOMB(psz_text), "rtsp://" ) )
00520             {
00521                 mrltemp = "rtsp" + demux + "://";
00522             }
00523             mrltemp += _TOMB(psz_text);
00524             break;
00525         }
00526         break;
00527     default:
00528         break;
00529     }
00530 
00531     SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
00532 }
00533 
00534 void OpenDialog::OnPageChange()
00535 {
00536     if( TabCtrl_GetCurSel( notebook ) == 0 )
00537     {
00538         for( int i=0; i<4; i++ )
00539         {
00540             SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
00541                           SWP_NOMOVE | SWP_NOSIZE );
00542             SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
00543                           SWP_NOMOVE | SWP_NOSIZE );
00544         }
00545         DisableNETCtrl();
00546 
00547         SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
00548                       SWP_NOMOVE | SWP_NOSIZE );
00549         SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
00550                       SWP_NOMOVE | SWP_NOSIZE );
00551         SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
00552                       SWP_NOMOVE | SWP_NOSIZE );
00553         SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
00554                       SWP_NOMOVE | SWP_NOSIZE );
00555         SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
00556                       SWP_NOMOVE | SWP_NOSIZE );
00557 
00558         i_access = FILE_ACCESS;
00559     }
00560     else if ( TabCtrl_GetCurSel( notebook ) == 1 )
00561     {
00562         SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
00563                       SWP_NOMOVE | SWP_NOSIZE );
00564         SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
00565                       SWP_NOMOVE | SWP_NOSIZE );
00566         SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
00567                       SWP_NOMOVE | SWP_NOSIZE );
00568         SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
00569                       SWP_NOMOVE | SWP_NOSIZE );
00570         SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
00571                       SWP_NOMOVE | SWP_NOSIZE );
00572 
00573         for( int i=0; i<4; i++ )
00574         {
00575             SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
00576                           SWP_NOMOVE | SWP_NOSIZE );
00577             SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
00578             SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
00579                           SWP_NOMOVE | SWP_NOSIZE );
00580         }
00581         SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
00582                       SWP_NOMOVE | SWP_NOSIZE );
00583         SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
00584                       SWP_NOMOVE | SWP_NOSIZE );
00585         SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
00586                       SWP_NOMOVE | SWP_NOSIZE );
00587 
00588         SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
00589 
00590         i_access = NET_ACCESS;
00591     }
00592 
00593     UpdateMRL();
00594 }
00595 
00596 void OpenDialog::OnOk()
00597 {
00598     TCHAR psz_text[2048];
00599 
00600     GetWindowText( mrl_combo, psz_text, 2048 );
00601 
00602     int i_args;
00603     char **pp_args = vlc_parse_cmdline( _TOMB(psz_text), &i_args );
00604 
00605     ComboBox_AddString( mrl_combo, psz_text );
00606     if( ComboBox_GetCount( mrl_combo ) > 10 ) 
00607         ComboBox_DeleteString( mrl_combo, 0 );
00608     ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
00609 
00610     /* Update the playlist */
00611     playlist_t *p_playlist =
00612         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00613                                        FIND_ANYWHERE );
00614     if( p_playlist == NULL ) return;
00615 
00616     for( int i = 0; i < i_args; i++ )
00617     {
00618         vlc_bool_t b_start = !i && i_open_arg;
00619         playlist_item_t *p_item =
00620             playlist_ItemNew( p_intf, pp_args[i], pp_args[i] );
00621 
00622         /* Insert options */
00623         while( i + 1 < i_args && pp_args[i + 1][0] == ':' )
00624         {
00625             playlist_ItemAddOption( p_item, pp_args[i + 1] );
00626             i++;
00627         }
00628 
00629         /* Get the options from the subtitles dialog */
00630         if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
00631             && subsfile_mrl.size() )
00632         {
00633             for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
00634             {
00635                 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
00636             }
00637         }
00638 
00639         playlist_AddItem( p_playlist, p_item,
00640                           PLAYLIST_APPEND, PLAYLIST_END );
00641 
00642         if( b_start )
00643         {
00644             playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
00645         }
00646     }
00647 
00648     //TogglePlayButton( PLAYING_S );
00649 
00650     while( i_args-- )
00651     {
00652         free( pp_args[i_args] );
00653         if( !i_args ) free( pp_args );
00654     }
00655     vlc_object_release( p_playlist );
00656 }
00657 
00658 /*****************************************************************************
00659  * File panel event methods.
00660  *****************************************************************************/
00661 void OpenDialog::OnFilePanelChange()
00662 {
00663     UpdateMRL( FILE_ACCESS );
00664 }
00665 
00666 static void OnOpenCB( intf_dialog_args_t *p_arg )
00667 {
00668     OpenDialog *p_this = (OpenDialog *)p_arg->p_arg;
00669     char psz_tmp[PATH_MAX+2] = "\0";
00670 
00671     if( p_arg->i_results && p_arg->psz_results[0] )
00672     {
00673         if( strchr( p_arg->psz_results[0], ' ' ) )
00674         {
00675             strcat( psz_tmp, "\"" );
00676             strcat( psz_tmp, p_arg->psz_results[0] );
00677             strcat( psz_tmp, "\"" );
00678         }
00679         else strcat( psz_tmp, p_arg->psz_results[0] );
00680 
00681         SetWindowText( p_this->file_combo, _FROMMB(psz_tmp) );
00682         ComboBox_AddString( p_this->file_combo, _FROMMB(psz_tmp) );
00683         if( ComboBox_GetCount( p_this->file_combo ) > 10 ) 
00684             ComboBox_DeleteString( p_this->file_combo, 0 );
00685 
00686         p_this->UpdateMRL( FILE_ACCESS );
00687     }
00688 }
00689 
00690 void OpenDialog::OnFileBrowse()
00691 {
00692     intf_dialog_args_t *p_arg =
00693         (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
00694     memset( p_arg, 0, sizeof(intf_dialog_args_t) );
00695 
00696     p_arg->psz_title = strdup( "Open file" );
00697     p_arg->psz_extensions = strdup( "All (*.*)|*.*" );
00698     p_arg->p_arg = this;
00699     p_arg->pf_callback = OnOpenCB;
00700 
00701     p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
00702 }
00703 
00704 /*****************************************************************************
00705  * Net panel event methods.
00706  *****************************************************************************/
00707 void OpenDialog::OnNetPanelChange( int event )
00708 {
00709     TCHAR psz_text[2048];
00710     int port;
00711 
00712     if( event >= NetPort1_Event && event <= NetPort2_Event )
00713     {
00714         Edit_GetText( net_ports[event - NetPort1_Event], psz_text, 2048 );
00715         _stscanf( psz_text, _T("%d"), &port );
00716         i_net_ports[event - NetPort1_Event] = port;
00717     }
00718 
00719     UpdateMRL( NET_ACCESS );
00720 }
00721 
00722 void OpenDialog::OnNetTypeChange( int event )
00723 {
00724     DisableNETCtrl();
00725 
00726     i_net_type = event - NetRadio1_Event;
00727 
00728     if( event == NetRadio1_Event )
00729     {
00730         SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
00731                       SWP_NOMOVE | SWP_NOSIZE );
00732         SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
00733                       SWP_NOMOVE | SWP_NOSIZE );
00734         SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
00735                       SWP_NOMOVE | SWP_NOSIZE );
00736     } 
00737     else if( event == NetRadio2_Event )
00738     {
00739         SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
00740                       SWP_NOMOVE | SWP_NOSIZE );
00741         SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
00742                       SWP_NOMOVE | SWP_NOSIZE );
00743         SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
00744                       SWP_NOMOVE | SWP_NOSIZE );
00745         SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
00746                       SWP_NOMOVE | SWP_NOSIZE );
00747         SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
00748                       SWP_NOMOVE | SWP_NOSIZE );
00749     } 
00750     else if( event == NetRadio3_Event )
00751     {
00752         SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
00753                       SWP_NOMOVE | SWP_NOSIZE );
00754         SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
00755                       SWP_NOMOVE | SWP_NOSIZE );
00756     } 
00757     else if( event == NetRadio4_Event )
00758     {
00759         SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
00760                       SWP_NOMOVE | SWP_NOSIZE );
00761         SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
00762                       SWP_NOMOVE | SWP_NOSIZE );
00763     }
00764         
00765     UpdateMRL( NET_ACCESS );
00766 }
00767 
00768 void OpenDialog::DisableNETCtrl()
00769 {
00770     for( int i=0; i<4; i++ )
00771     {
00772         SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0,
00773                       SWP_NOMOVE | SWP_NOSIZE );
00774         SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0,
00775                       SWP_NOMOVE | SWP_NOSIZE );
00776         SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0,
00777                       SWP_NOMOVE | SWP_NOSIZE );
00778         SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0,
00779                       SWP_NOMOVE | SWP_NOSIZE );
00780         SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0,
00781                       SWP_NOMOVE | SWP_NOSIZE );
00782     }
00783 
00784     UpdateMRL( FILE_ACCESS );
00785 }
00786 
00787 /*****************************************************************************
00788  * Subtitles file event methods.
00789  *****************************************************************************/
00790 void OpenDialog::OnSubsFileEnable()
00791 {
00792     EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
00793                   BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
00794 }
00795 
00796 void OpenDialog::OnSubsFileSettings( HWND hwnd )
00797 {
00798 
00799     /* Show/hide the open dialog */
00800     SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, this, hInst);
00801     CreateDialogBox(  hwnd, subsfile_dialog );
00802 
00803     subsfile_mrl.clear();
00804 
00805     for( int i = 0; i < (int)subsfile_dialog->subsfile_mrl.size(); i++ )
00806         subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
00807 
00808     delete subsfile_dialog;
00809 }

Generated on Tue Dec 20 10:14:45 2005 for vlc-0.8.4a by  doxygen 1.4.2