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 <stdlib.h> /* malloc(), free() */
29 #include <string.h> /* strerror() */
32 #include <vlc_interface.h>
42 /*****************************************************************************
44 *****************************************************************************/
46 /*****************************************************************************
48 *****************************************************************************/
49 SubsFileDialog::SubsFileDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
51 : CBaseWindow( p_intf, p_parent, h_inst )
55 /***********************************************************************
61 Processes messages sent to the main window.
63 ***********************************************************************/
64 LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
68 INITCOMMONCONTROLSEX ic;
72 module_config_t *p_item;
81 shidi.dwMask = SHIDIM_FLAGS;
82 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
84 SHInitDialog( &shidi );
87 memset (&mbi, 0, sizeof (SHMENUBARINFO));
88 mbi.cbSize = sizeof (SHMENUBARINFO);
89 mbi.hwndParent = hwnd;
90 mbi.dwFlags = SHCMBF_EMPTYBAR;
93 if (!SHCreateMenuBar(&mbi))
95 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
101 // Get the client area rect to put the panels in
102 GetClientRect(hwnd, &rcClient);
104 /* Create the subtitles file textctrl */
105 file_box = CreateWindow( _T("STATIC"), _T("Subtitles file"),
106 WS_CHILD | WS_VISIBLE | SS_LEFT,
107 5, 10, rcClient.right - 2*5, 15,
108 hwnd, NULL, hInst, NULL );
110 psz_subsfile = config_GetPsz( p_intf, "sub-file" );
111 if( !psz_subsfile ) psz_subsfile = strdup("");
113 file_combo = CreateWindow( _T("COMBOBOX"), _FROMMB(psz_subsfile),
114 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
115 10, 10 + 15 + 10 - 3, rcClient.right - 2*10, 5*15 + 6,
116 hwnd, NULL, hInst, NULL );
118 if( psz_subsfile ) free( psz_subsfile );
120 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
121 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
122 10, 10 + 2*(15 + 10) - 3, 80, 15 + 6,
123 hwnd, NULL, hInst, NULL);
125 /* Subtitles encoding */
126 encoding_combo = NULL;
127 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
130 enc_box = CreateWindow( _T("STATIC"), _T("Subtitles encoding"),
131 WS_CHILD | WS_VISIBLE | SS_LEFT,
132 5, 10 + 3*(15 + 10), rcClient.right - 2*5, 15,
133 hwnd, NULL, hInst, NULL );
135 enc_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
136 WS_CHILD | WS_VISIBLE | SS_LEFT,
137 10, 10 + 4*(15 + 10), rcClient.right - 2*10, 15,
138 hwnd, NULL, hInst, NULL );
140 encoding_combo = CreateWindow( _T("COMBOBOX"),
141 _FROMMB(p_item->psz_value),
142 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST |
143 LBS_SORT | WS_VSCROLL,
144 rcClient.right - 150 - 10, 10 + 5*(15 + 10) - 3, 150, 5*15 + 6,
145 hwnd, NULL, hInst, NULL );
147 /* build a list of available options */
148 for( int i_index = 0; p_item->ppsz_list &&
149 p_item->ppsz_list[i_index]; i_index++ )
151 ComboBox_AddString( encoding_combo,
152 _FROMMB(p_item->ppsz_list[i_index]) );
154 if( p_item->psz_value &&
155 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
156 ComboBox_SetCurSel( encoding_combo, i_index );
159 if( p_item->psz_value )
161 ComboBox_SelectString( encoding_combo, 0,
162 _FROMMB(p_item->psz_value) );
167 /* Misc Subtitles options */
168 misc_box = CreateWindow( _T("STATIC"), _T("Subtitles options"),
169 WS_CHILD | WS_VISIBLE | SS_LEFT,
170 5, 10 + 6*(15 + 10), rcClient.right - 2*5, 15,
171 hwnd, NULL, hInst, NULL );
173 delay_label = CreateWindow( _T("STATIC"),
174 _T("Delay subtitles (in 1/10s)"),
175 WS_CHILD | WS_VISIBLE | SS_LEFT,
176 10, 10 + 7*(15 + 10), rcClient.right - 70 - 2*10, 15,
177 hwnd, NULL, hInst, NULL );
179 i_delay = config_GetInt( p_intf, "sub-delay" );
180 _stprintf( psz_text, _T("%d"), i_delay );
182 delay_edit = CreateWindow( _T("EDIT"), psz_text,
183 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
184 rcClient.right - 70 - 10, 10 + 7*(15 + 10) - 3, 70, 15 + 6,
185 hwnd, NULL, hInst, NULL );
187 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
188 ic.dwICC = ICC_UPDOWN_CLASS;
189 InitCommonControlsEx(&ic);
192 CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
193 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
194 0, 0, 0, 0, hwnd, 0, hInst,
195 delay_edit, 650000, -650000, i_delay );
197 fps_label = CreateWindow( _T("STATIC"), _T("Frames per second"),
198 WS_CHILD | WS_VISIBLE | SS_LEFT,
199 10, 10 + 8*(15 + 10), rcClient.right - 70 - 2*10, 15,
200 hwnd, NULL, hInst, NULL );
202 f_fps = config_GetFloat( p_intf, "sub-fps" );
203 _stprintf( psz_text, _T("%f"), f_fps );
205 fps_edit = CreateWindow( _T("EDIT"), psz_text,
206 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
207 rcClient.right - 70 - 10, 10 + 8*(15 + 10) - 3, 70, 15 + 6,
208 hwnd, NULL, hInst, NULL);
210 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
211 ic.dwICC = ICC_UPDOWN_CLASS;
212 InitCommonControlsEx(&ic);
214 fps_spinctrl = CreateUpDownControl(
215 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
216 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
217 0, 0, 0, 0, hwnd, 0, hInst, fps_edit, 16000, 0, (int)f_fps );
222 EndDialog( hwnd, LOWORD( wp ) );
226 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
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 );
277 /*****************************************************************************
279 *****************************************************************************/
281 /*****************************************************************************
283 *****************************************************************************/
284 static void OnOpenCB( intf_dialog_args_t *p_arg )
286 SubsFileDialog *p_this = (SubsFileDialog *)p_arg->p_arg;
288 if( p_arg->i_results && p_arg->psz_results[0] )
290 SetWindowText( p_this->file_combo, _FROMMB(p_arg->psz_results[0]) );
291 ComboBox_AddString( p_this->file_combo,
292 _FROMMB(p_arg->psz_results[0]) );
293 if( ComboBox_GetCount( p_this->file_combo ) > 10 )
294 ComboBox_DeleteString( p_this->file_combo, 0 );
298 void SubsFileDialog::OnFileBrowse()
300 intf_dialog_args_t *p_arg =
301 (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
302 memset( p_arg, 0, sizeof(intf_dialog_args_t) );
304 p_arg->psz_title = strdup( "Open file" );
305 p_arg->psz_extensions = strdup( "All|*.*" );
307 p_arg->pf_callback = OnOpenCB;
309 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);