1 /*****************************************************************************
2 * subtitles.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: subtitles.cpp,v 1.2 2003/05/20 23:17:59 gbazin Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
34 #ifdef WIN32 /* mingw32 hack */
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
42 #include <wx/wxprec.h>
44 #include <wx/textctrl.h>
45 #include <wx/combobox.h>
46 #include <wx/spinctrl.h>
47 #include <wx/statline.h>
51 #if defined MODULE_NAME_IS_skins
52 # include "../skins/src/skin_common.h"
55 #include "wxwindows.h"
58 # define wxRB_SINGLE 0
61 /*****************************************************************************
63 *****************************************************************************/
65 /* IDs for the controls and the menu commands */
68 FileBrowse_Event = wxID_HIGHEST,
71 BEGIN_EVENT_TABLE(SubsFileDialog, wxDialog)
73 EVT_BUTTON(wxID_OK, SubsFileDialog::OnOk)
74 EVT_BUTTON(wxID_CANCEL, SubsFileDialog::OnCancel)
75 EVT_BUTTON(FileBrowse_Event, SubsFileDialog::OnFileBrowse)
79 /*****************************************************************************
81 *****************************************************************************/
82 SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
83 wxDialog( _p_parent, -1, wxU(_("Open Subtitles File")),
84 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
89 SetIcon( *p_intf->p_sys->p_icon );
91 /* Create a panel to put everything in */
92 wxPanel *panel = new wxPanel( this, -1 );
93 panel->SetAutoLayout( TRUE );
95 /* Create the subtitles file textctrl */
96 wxBoxSizer *file_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
97 wxStaticBox *file_box = new wxStaticBox( panel, -1,
98 wxU(_("Subtitles file")) );
99 wxStaticBoxSizer *file_sizer = new wxStaticBoxSizer( file_box,
101 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
102 file_combo = new wxComboBox( panel, -1,
103 psz_subsfile ? wxU(psz_subsfile) : wxT(""),
104 wxPoint(20,25), wxSize(300, -1), 0, NULL );
105 if( psz_subsfile ) free( psz_subsfile );
106 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
107 wxU(_("Browse...")) );
108 file_sizer->Add( file_combo, 1, wxALL, 5 );
109 file_sizer->Add( browse_button, 0, wxALL, 5 );
110 file_sizer_sizer->Add( file_sizer, 1, wxEXPAND | wxALL, 5 );
112 /* Misc Subtitles options */
113 wxBoxSizer *misc_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
114 wxStaticBox *misc_box = new wxStaticBox( panel, -1,
115 wxU(_("Subtitles options")) );
116 wxStaticBoxSizer *misc_sizer = new wxStaticBoxSizer( misc_box,
118 wxStaticText *label =
119 new wxStaticText(panel, -1, wxU(_("Delay subtitles (in 1/10s)")));
120 int i_delay = config_GetInt( p_intf, "sub-delay" );
121 delay_spinctrl = new wxSpinCtrl( panel, -1,
122 wxString::Format(wxT("%d"), i_delay),
123 wxDefaultPosition, wxDefaultSize,
125 -650000, 650000, i_delay );
127 misc_sizer->Add( label, 0, wxALL, 5 );
128 misc_sizer->Add( delay_spinctrl, 0, wxALL, 5 );
130 label = new wxStaticText(panel, -1, wxU(_("Frames per second")));
132 float f_fps = config_GetFloat( p_intf, "sub-fps" );
133 fps_spinctrl = new wxSpinCtrl( panel, -1,
134 wxString::Format(wxT("%d"),(int)f_fps),
135 wxDefaultPosition, wxDefaultSize,
137 0, 16000, (int)f_fps );
138 fps_spinctrl->SetToolTip( wxU(_("Override frames per second. "
139 "It will only work with MicroDVD subtitles.")) );
140 misc_sizer->Add( label, 0, wxALL, 5 );
141 misc_sizer->Add( fps_spinctrl, 0, wxALL, 5 );
143 misc_sizer_sizer->Add( misc_sizer, 1, wxEXPAND | wxALL, 5 );
146 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
148 /* Create the buttons */
149 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
150 ok_button->SetDefault();
151 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
154 /* Place everything in sizers */
155 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
156 button_sizer->Add( ok_button, 0, wxALL, 5 );
157 button_sizer->Add( cancel_button, 0, wxALL, 5 );
158 button_sizer->Layout();
159 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
160 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
161 panel_sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
162 panel_sizer->Add( misc_sizer, 0, wxEXPAND | wxALL, 5 );
163 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
164 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
166 panel_sizer->Layout();
167 panel->SetSizerAndFit( panel_sizer );
168 main_sizer->Add( panel, 1, wxGROW, 0 );
169 main_sizer->Layout();
170 SetSizerAndFit( main_sizer );
173 SubsFileDialog::~SubsFileDialog()
177 /*****************************************************************************
179 *****************************************************************************/
181 /*****************************************************************************
183 *****************************************************************************/
184 void SubsFileDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
189 void SubsFileDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
191 EndModal( wxID_CANCEL );
194 void SubsFileDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
196 wxFileDialog dialog( this, wxU(_("Open file")),
197 wxT(""), wxT(""), wxT("*"), wxOPEN );
199 if( dialog.ShowModal() == wxID_OK )
201 file_combo->SetValue( dialog.GetPath() );