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,
70 INITCOMMONCONTROLSEX ic;
74 module_config_t *p_item;
80 LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
81 BOOL bWasProcessed = *pbProcessed;
87 shidi.dwMask = SHIDIM_FLAGS;
88 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
90 SHInitDialog( &shidi );
93 memset (&mbi, 0, sizeof (SHMENUBARINFO));
94 mbi.cbSize = sizeof (SHMENUBARINFO);
95 mbi.hwndParent = hwnd;
96 mbi.nToolBarId = IDR_DUMMYMENU;
101 if (!SHCreateMenuBar(&mbi))
103 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
109 // Get the client area rect to put the panels in
110 GetClientRect(hwnd, &rcClient);
112 /* Create the subtitles file textctrl */
113 file_box = CreateWindow( _T("STATIC"), _T("Subtitles file"),
114 WS_CHILD | WS_VISIBLE | SS_LEFT,
115 5, 10, rcClient.right - 2*5, 15,
116 hwnd, NULL, hInst, NULL );
118 psz_subsfile = config_GetPsz( p_intf, "sub-file" );
119 if( !psz_subsfile ) psz_subsfile = strdup("");
121 file_combo = CreateWindow( _T("COMBOBOX"), _FROMMB(psz_subsfile),
122 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
123 10, 10 + 15 + 10 - 3, rcClient.right - 2*10, 5*15 + 6,
124 hwnd, NULL, hInst, NULL );
126 if( psz_subsfile ) free( psz_subsfile );
128 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
129 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
130 10, 10 + 2*(15 + 10) - 3, 80, 15 + 6,
131 hwnd, NULL, hInst, NULL);
133 /* Subtitles encoding */
134 encoding_combo = NULL;
135 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
138 enc_box = CreateWindow( _T("STATIC"), _T("Subtitles encoding"),
139 WS_CHILD | WS_VISIBLE | SS_LEFT,
140 5, 10 + 3*(15 + 10), rcClient.right - 2*5, 15,
141 hwnd, NULL, hInst, NULL );
143 enc_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
144 WS_CHILD | WS_VISIBLE | SS_LEFT,
145 10, 10 + 4*(15 + 10), rcClient.right - 2*10, 15,
146 hwnd, NULL, hInst, NULL );
148 encoding_combo = CreateWindow( _T("COMBOBOX"),
149 _FROMMB(p_item->psz_value),
150 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST |
151 LBS_SORT | WS_VSCROLL,
152 rcClient.right - 150 - 10, 10 + 5*(15 + 10) - 3, 150, 5*15 + 6,
153 hwnd, NULL, hInst, NULL );
155 /* build a list of available options */
156 for( int i_index = 0; p_item->ppsz_list &&
157 p_item->ppsz_list[i_index]; i_index++ )
159 ComboBox_AddString( encoding_combo,
160 _FROMMB(p_item->ppsz_list[i_index]) );
162 if( p_item->psz_value &&
163 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
164 ComboBox_SetCurSel( encoding_combo, i_index );
167 if( p_item->psz_value )
169 ComboBox_SelectString( encoding_combo, 0,
170 _FROMMB(p_item->psz_value) );
175 /* Misc Subtitles options */
176 misc_box = CreateWindow( _T("STATIC"), _T("Subtitles options"),
177 WS_CHILD | WS_VISIBLE | SS_LEFT,
178 5, 10 + 6*(15 + 10), rcClient.right - 2*5, 15,
179 hwnd, NULL, hInst, NULL );
181 delay_label = CreateWindow( _T("STATIC"),
182 _T("Delay subtitles (in 1/10s)"),
183 WS_CHILD | WS_VISIBLE | SS_LEFT,
184 10, 10 + 7*(15 + 10), rcClient.right - 70 - 2*10, 15,
185 hwnd, NULL, hInst, NULL );
187 i_delay = config_GetInt( p_intf, "sub-delay" );
188 _stprintf( psz_text, _T("%d"), i_delay );
190 delay_edit = CreateWindow( _T("EDIT"), psz_text,
191 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
192 rcClient.right - 70 - 10, 10 + 7*(15 + 10) - 3, 70, 15 + 6,
193 hwnd, NULL, hInst, NULL );
195 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
196 ic.dwICC = ICC_UPDOWN_CLASS;
197 InitCommonControlsEx(&ic);
200 CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
201 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
202 0, 0, 0, 0, hwnd, 0, hInst,
203 delay_edit, 650000, -650000, i_delay );
205 fps_label = CreateWindow( _T("STATIC"), _T("Frames per second"),
206 WS_CHILD | WS_VISIBLE | SS_LEFT,
207 10, 10 + 8*(15 + 10), rcClient.right - 70 - 2*10, 15,
208 hwnd, NULL, hInst, NULL );
210 f_fps = config_GetFloat( p_intf, "sub-fps" );
211 _stprintf( psz_text, _T("%f"), f_fps );
213 fps_edit = CreateWindow( _T("EDIT"), psz_text,
214 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
215 rcClient.right - 70 - 10, 10 + 8*(15 + 10) - 3, 70, 15 + 6,
216 hwnd, NULL, hInst, NULL);
218 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
219 ic.dwICC = ICC_UPDOWN_CLASS;
220 InitCommonControlsEx(&ic);
222 fps_spinctrl = CreateUpDownControl(
223 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
224 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
225 0, 0, 0, 0, hwnd, 0, hInst, fps_edit, 16000, 0, (int)f_fps );
230 if ( LOWORD(wp) == IDOK )
232 subsfile_mrl.clear();
234 string szFileCombo = "sub-file=";
235 GetWindowText( file_combo, psz_text, 256 );
236 szFileCombo += _TOMB(psz_text);
237 subsfile_mrl.push_back( szFileCombo );
239 if( GetWindowTextLength( encoding_combo ) != 0 )
241 string szEncoding = "subsdec-encoding=";
242 GetWindowText( encoding_combo, psz_text, 256 );
243 szEncoding += _TOMB(psz_text);
244 subsfile_mrl.push_back( szEncoding );
247 string szDelay = "sub-delay=";
248 Edit_GetText( delay_edit, psz_text, 256 );
249 szDelay += _TOMB(psz_text);
250 subsfile_mrl.push_back( szDelay );
252 string szFps = "sub-fps=";
253 Edit_GetText( fps_edit, psz_text, 256 );
254 szFps += _TOMB(psz_text);
255 subsfile_mrl.push_back( szFps );
257 EndDialog( hwnd, LOWORD( wp ) );
260 if( HIWORD(wp) == BN_CLICKED )
262 if ((HWND)lp == browse_button)
264 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
270 *pbProcessed = bWasProcessed;
275 // the message was not processed
276 // indicate if the base class handled it
277 *pbProcessed = bWasProcessed;
285 /*****************************************************************************
287 *****************************************************************************/
289 /*****************************************************************************
291 *****************************************************************************/
292 void SubsFileDialog::OnFileBrowse()
295 TCHAR DateiName[80+1] = _T("\0");
296 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
298 memset(&ofn, 0, sizeof(OPENFILENAME));
299 ofn.lStructSize = sizeof (OPENFILENAME);
300 ofn.hwndOwner = NULL;
301 ofn.hInstance = hInst;
302 ofn.lpstrFilter = szFilter;
303 ofn.lpstrCustomFilter = NULL;
304 ofn.nMaxCustFilter = 0;
305 ofn.nFilterIndex = 1;
306 ofn.lpstrFile = (LPTSTR) DateiName;
308 ofn.lpstrFileTitle = NULL;
309 ofn.nMaxFileTitle = 40;
310 ofn.lpstrInitialDir = NULL;
311 ofn.lpstrTitle = _T("Open File");
314 ofn.nFileExtension = 0;
315 ofn.lpstrDefExt = NULL;
318 ofn.lpTemplateName = NULL;
319 if( GetOpenFileName((LPOPENFILENAME) &ofn) )
321 SetWindowText( file_combo, ofn.lpstrFile );
322 ComboBox_AddString( file_combo, ofn.lpstrFile );
323 if( ComboBox_GetCount( file_combo ) > 10 )
324 ComboBox_DeleteString( file_combo, 0 );