1 /*****************************************************************************
2 * subtitles.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2001 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 /*****************************************************************************
48 *****************************************************************************/
49 SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, HINSTANCE _hInst )
56 /***********************************************************************
62 Processes messages sent to the main window.
64 ***********************************************************************/
65 LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
69 INITCOMMONCONTROLSEX ic;
73 module_config_t *p_item;
82 shidi.dwMask = SHIDIM_FLAGS;
83 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
85 SHInitDialog( &shidi );
88 memset (&mbi, 0, sizeof (SHMENUBARINFO));
89 mbi.cbSize = sizeof (SHMENUBARINFO);
90 mbi.hwndParent = hwnd;
91 mbi.nToolBarId = IDR_DUMMYMENU;
96 if (!SHCreateMenuBar(&mbi))
98 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
104 // Get the client area rect to put the panels in
105 GetClientRect(hwnd, &rcClient);
107 /* Create the subtitles file textctrl */
108 file_box = CreateWindow( _T("STATIC"), _T("Subtitles file"),
109 WS_CHILD | WS_VISIBLE | SS_LEFT,
110 5, 10, rcClient.right - 2*5, 15,
111 hwnd, NULL, hInst, NULL );
113 psz_subsfile = config_GetPsz( p_intf, "sub-file" );
114 if( !psz_subsfile ) psz_subsfile = strdup("");
116 file_combo = CreateWindow( _T("COMBOBOX"), _FROMMB(psz_subsfile),
117 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
118 10, 10 + 15 + 10 - 3, rcClient.right - 2*10, 5*15 + 6,
119 hwnd, NULL, hInst, NULL );
121 if( psz_subsfile ) free( psz_subsfile );
123 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
124 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
125 10, 10 + 2*(15 + 10) - 3, 80, 15 + 6,
126 hwnd, NULL, hInst, NULL);
128 /* Subtitles encoding */
129 encoding_combo = NULL;
130 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
133 enc_box = CreateWindow( _T("STATIC"), _T("Subtitles encoding"),
134 WS_CHILD | WS_VISIBLE | SS_LEFT,
135 5, 10 + 3*(15 + 10), rcClient.right - 2*5, 15,
136 hwnd, NULL, hInst, NULL );
138 enc_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
139 WS_CHILD | WS_VISIBLE | SS_LEFT,
140 10, 10 + 4*(15 + 10), rcClient.right - 2*10, 15,
141 hwnd, NULL, hInst, NULL );
143 encoding_combo = CreateWindow( _T("COMBOBOX"),
144 _FROMMB(p_item->psz_value),
145 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST |
146 LBS_SORT | WS_VSCROLL,
147 rcClient.right - 150 - 10, 10 + 5*(15 + 10) - 3, 150, 5*15 + 6,
148 hwnd, NULL, hInst, NULL );
150 /* build a list of available options */
151 for( int i_index = 0; p_item->ppsz_list &&
152 p_item->ppsz_list[i_index]; i_index++ )
154 ComboBox_AddString( encoding_combo,
155 _FROMMB(p_item->ppsz_list[i_index]) );
157 if( p_item->psz_value &&
158 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
159 ComboBox_SetCurSel( encoding_combo, i_index );
162 if( p_item->psz_value )
164 ComboBox_SelectString( encoding_combo, 0,
165 _FROMMB(p_item->psz_value) );
170 /* Misc Subtitles options */
171 misc_box = CreateWindow( _T("STATIC"), _T("Subtitles options"),
172 WS_CHILD | WS_VISIBLE | SS_LEFT,
173 5, 10 + 6*(15 + 10), rcClient.right - 2*5, 15,
174 hwnd, NULL, hInst, NULL );
176 delay_label = CreateWindow( _T("STATIC"),
177 _T("Delay subtitles (in 1/10s)"),
178 WS_CHILD | WS_VISIBLE | SS_LEFT,
179 10, 10 + 7*(15 + 10), rcClient.right - 70 - 2*10, 15,
180 hwnd, NULL, hInst, NULL );
182 i_delay = config_GetInt( p_intf, "sub-delay" );
183 _stprintf( psz_text, _T("%d"), i_delay );
185 delay_edit = CreateWindow( _T("EDIT"), psz_text,
186 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
187 rcClient.right - 70 - 10, 10 + 7*(15 + 10) - 3, 70, 15 + 6,
188 hwnd, NULL, hInst, NULL );
190 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
191 ic.dwICC = ICC_UPDOWN_CLASS;
192 InitCommonControlsEx(&ic);
195 CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
196 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
197 0, 0, 0, 0, hwnd, 0, hInst,
198 delay_edit, 650000, -650000, i_delay );
200 fps_label = CreateWindow( _T("STATIC"), _T("Frames per second"),
201 WS_CHILD | WS_VISIBLE | SS_LEFT,
202 10, 10 + 8*(15 + 10), rcClient.right - 70 - 2*10, 15,
203 hwnd, NULL, hInst, NULL );
205 f_fps = config_GetFloat( p_intf, "sub-fps" );
206 _stprintf( psz_text, _T("%f"), f_fps );
208 fps_edit = CreateWindow( _T("EDIT"), psz_text,
209 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
210 rcClient.right - 70 - 10, 10 + 8*(15 + 10) - 3, 70, 15 + 6,
211 hwnd, NULL, hInst, NULL);
213 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
214 ic.dwICC = ICC_UPDOWN_CLASS;
215 InitCommonControlsEx(&ic);
217 fps_spinctrl = CreateUpDownControl(
218 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
219 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
220 0, 0, 0, 0, hwnd, 0, hInst, fps_edit, 16000, 0, (int)f_fps );
225 EndDialog( hwnd, LOWORD( wp ) );
229 if ( LOWORD(wp) == IDOK )
231 subsfile_mrl.clear();
233 string szFileCombo = "sub-file=";
234 GetWindowText( file_combo, psz_text, 256 );
235 szFileCombo += _TOMB(psz_text);
236 subsfile_mrl.push_back( szFileCombo );
238 if( GetWindowTextLength( encoding_combo ) != 0 )
240 string szEncoding = "subsdec-encoding=";
241 GetWindowText( encoding_combo, psz_text, 256 );
242 szEncoding += _TOMB(psz_text);
243 subsfile_mrl.push_back( szEncoding );
246 string szDelay = "sub-delay=";
247 Edit_GetText( delay_edit, psz_text, 256 );
248 szDelay += _TOMB(psz_text);
249 subsfile_mrl.push_back( szDelay );
251 string szFps = "sub-fps=";
252 Edit_GetText( fps_edit, psz_text, 256 );
253 szFps += _TOMB(psz_text);
254 subsfile_mrl.push_back( szFps );
256 EndDialog( hwnd, LOWORD( wp ) );
259 if( HIWORD(wp) == BN_CLICKED )
261 if ((HWND)lp == browse_button)
263 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
276 /*****************************************************************************
278 *****************************************************************************/
280 /*****************************************************************************
282 *****************************************************************************/
283 void SubsFileDialog::OnFileBrowse()
286 TCHAR DateiName[80+1] = _T("\0");
287 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
289 memset(&ofn, 0, sizeof(OPENFILENAME));
290 ofn.lStructSize = sizeof (OPENFILENAME);
291 ofn.hwndOwner = NULL;
292 ofn.hInstance = hInst;
293 ofn.lpstrFilter = szFilter;
294 ofn.lpstrCustomFilter = NULL;
295 ofn.nMaxCustFilter = 0;
296 ofn.nFilterIndex = 1;
297 ofn.lpstrFile = (LPTSTR) DateiName;
299 ofn.lpstrFileTitle = NULL;
300 ofn.nMaxFileTitle = 40;
301 ofn.lpstrInitialDir = NULL;
302 ofn.lpstrTitle = _T("Open File");
305 ofn.nFileExtension = 0;
306 ofn.lpstrDefExt = NULL;
309 ofn.lpTemplateName = NULL;
310 if( GetOpenFileName((LPOPENFILENAME) &ofn) )
312 SetWindowText( file_combo, ofn.lpstrFile );
313 ComboBox_AddString( file_combo, ofn.lpstrFile );
314 if( ComboBox_GetCount( file_combo ) > 10 )
315 ComboBox_DeleteString( file_combo, 0 );