1 /*****************************************************************************
2 * subtitles.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2001 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <string.h> /* strerror() */
31 #include <vlc_interface.h>
41 /*****************************************************************************
43 *****************************************************************************/
45 /*****************************************************************************
47 *****************************************************************************/
48 SubsFileDialog::SubsFileDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
50 : CBaseWindow( p_intf, p_parent, h_inst )
54 /***********************************************************************
60 Processes messages sent to the main window.
62 ***********************************************************************/
63 LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
67 INITCOMMONCONTROLSEX ic;
71 module_config_t *p_item;
80 shidi.dwMask = SHIDIM_FLAGS;
81 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
83 SHInitDialog( &shidi );
86 memset (&mbi, 0, sizeof (SHMENUBARINFO));
87 mbi.cbSize = sizeof (SHMENUBARINFO);
88 mbi.hwndParent = hwnd;
89 mbi.dwFlags = SHCMBF_EMPTYBAR;
92 if (!SHCreateMenuBar(&mbi))
94 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
100 // Get the client area rect to put the panels in
101 GetClientRect(hwnd, &rcClient);
103 /* Create the subtitles file textctrl */
104 file_box = CreateWindow( _T("STATIC"), _T("Subtitles file"),
105 WS_CHILD | WS_VISIBLE | SS_LEFT,
106 5, 10, rcClient.right - 2*5, 15,
107 hwnd, NULL, hInst, NULL );
109 psz_subsfile = config_GetPsz( p_intf, "sub-file" );
110 if( !psz_subsfile ) psz_subsfile = strdup("");
112 file_combo = CreateWindow( _T("COMBOBOX"), _FROMMB(psz_subsfile),
113 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
114 10, 10 + 15 + 10 - 3, rcClient.right - 2*10, 5*15 + 6,
115 hwnd, NULL, hInst, NULL );
117 if( psz_subsfile ) free( psz_subsfile );
119 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
120 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
121 10, 10 + 2*(15 + 10) - 3, 80, 15 + 6,
122 hwnd, NULL, hInst, NULL);
124 /* Subtitles encoding */
125 encoding_combo = NULL;
126 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
129 enc_box = CreateWindow( _T("STATIC"), _T("Subtitles encoding"),
130 WS_CHILD | WS_VISIBLE | SS_LEFT,
131 5, 10 + 3*(15 + 10), rcClient.right - 2*5, 15,
132 hwnd, NULL, hInst, NULL );
134 enc_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
135 WS_CHILD | WS_VISIBLE | SS_LEFT,
136 10, 10 + 4*(15 + 10), rcClient.right - 2*10, 15,
137 hwnd, NULL, hInst, NULL );
139 encoding_combo = CreateWindow( _T("COMBOBOX"),
140 _FROMMB(p_item->psz_value),
141 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST |
142 LBS_SORT | WS_VSCROLL,
143 rcClient.right - 150 - 10, 10 + 5*(15 + 10) - 3, 150, 5*15 + 6,
144 hwnd, NULL, hInst, NULL );
146 /* build a list of available options */
147 for( int i_index = 0; p_item->ppsz_list &&
148 p_item->ppsz_list[i_index]; i_index++ )
150 ComboBox_AddString( encoding_combo,
151 _FROMMB(p_item->ppsz_list[i_index]) );
153 if( p_item->psz_value &&
154 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
155 ComboBox_SetCurSel( encoding_combo, i_index );
158 if( p_item->psz_value )
160 ComboBox_SelectString( encoding_combo, 0,
161 _FROMMB(p_item->psz_value) );
166 /* Misc Subtitles options */
167 misc_box = CreateWindow( _T("STATIC"), _T("Subtitles options"),
168 WS_CHILD | WS_VISIBLE | SS_LEFT,
169 5, 10 + 6*(15 + 10), rcClient.right - 2*5, 15,
170 hwnd, NULL, hInst, NULL );
172 delay_label = CreateWindow( _T("STATIC"),
173 _T("Delay subtitles (in 1/10s)"),
174 WS_CHILD | WS_VISIBLE | SS_LEFT,
175 10, 10 + 7*(15 + 10), rcClient.right - 70 - 2*10, 15,
176 hwnd, NULL, hInst, NULL );
178 i_delay = config_GetInt( p_intf, "sub-delay" );
179 _stprintf( psz_text, _T("%d"), i_delay );
181 delay_edit = CreateWindow( _T("EDIT"), psz_text,
182 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
183 rcClient.right - 70 - 10, 10 + 7*(15 + 10) - 3, 70, 15 + 6,
184 hwnd, NULL, hInst, NULL );
186 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
187 ic.dwICC = ICC_UPDOWN_CLASS;
188 InitCommonControlsEx(&ic);
191 CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
192 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
193 0, 0, 0, 0, hwnd, 0, hInst,
194 delay_edit, 650000, -650000, i_delay );
196 fps_label = CreateWindow( _T("STATIC"), _T("Frames per second"),
197 WS_CHILD | WS_VISIBLE | SS_LEFT,
198 10, 10 + 8*(15 + 10), rcClient.right - 70 - 2*10, 15,
199 hwnd, NULL, hInst, NULL );
201 f_fps = config_GetFloat( p_intf, "sub-fps" );
202 _stprintf( psz_text, _T("%f"), f_fps );
204 fps_edit = CreateWindow( _T("EDIT"), psz_text,
205 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
206 rcClient.right - 70 - 10, 10 + 8*(15 + 10) - 3, 70, 15 + 6,
207 hwnd, NULL, hInst, NULL);
209 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
210 ic.dwICC = ICC_UPDOWN_CLASS;
211 InitCommonControlsEx(&ic);
213 fps_spinctrl = CreateUpDownControl(
214 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
215 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
216 0, 0, 0, 0, hwnd, 0, hInst, fps_edit, 16000, 0, (int)f_fps );
221 EndDialog( hwnd, LOWORD( wp ) );
225 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
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 static void OnOpenCB( intf_dialog_args_t *p_arg )
285 SubsFileDialog *p_this = (SubsFileDialog *)p_arg->p_arg;
287 if( p_arg->i_results && p_arg->psz_results[0] )
289 SetWindowText( p_this->file_combo, _FROMMB(p_arg->psz_results[0]) );
290 ComboBox_AddString( p_this->file_combo,
291 _FROMMB(p_arg->psz_results[0]) );
292 if( ComboBox_GetCount( p_this->file_combo ) > 10 )
293 ComboBox_DeleteString( p_this->file_combo, 0 );
297 void SubsFileDialog::OnFileBrowse()
299 intf_dialog_args_t *p_arg =
300 (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
301 memset( p_arg, 0, sizeof(intf_dialog_args_t) );
303 p_arg->psz_title = strdup( "Open file" );
304 p_arg->psz_extensions = strdup( "All|*.*" );
306 p_arg->pf_callback = OnOpenCB;
308 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);