1 /*****************************************************************************
2 * iteminfo.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: iteminfo.cpp,v 1.1 2003/10/06 16:23:30 zorglub Exp $
7 * Authors: Clément Stenac <zorglub@videolan.org>
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/notebook.h>
45 #include <wx/textctrl.h>
46 #include <wx/combobox.h>
47 #include <wx/spinctrl.h>
48 #include <wx/statline.h>
52 #include "wxwindows.h"
55 # define wxRB_SINGLE 0
58 /*****************************************************************************
60 *****************************************************************************/
62 /* IDs for the controls and the menu commands */
71 BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog)
73 EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk)
74 EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel)
76 /* Events generated by the panels */
80 /*****************************************************************************
82 *****************************************************************************/
83 ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
84 playlist_item_t *_p_item,
85 wxWindow* _p_parent ):
86 wxDialog( _p_parent, -1, wxU(_("Playlist Item options")),
87 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
93 SetIcon( *p_intf->p_sys->p_icon );
95 /* Create a panel to put everything in */
96 wxPanel *panel = new wxPanel( this, -1 );
97 panel->SetAutoLayout( TRUE );
99 /* Create the standard info panel */
100 wxPanel *info_panel = InfoPanel( panel );
102 /* Create the group panel */
103 wxPanel *group_panel = GroupPanel( panel );
106 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
108 /* Create the buttons */
109 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
110 ok_button->SetDefault();
111 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
114 /* Place everything in sizers */
115 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
116 button_sizer->Add( ok_button, 0, wxALL, 5 );
117 button_sizer->Add( cancel_button, 0, wxALL, 5 );
118 button_sizer->Layout();
119 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
120 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
121 panel_sizer->Add( info_panel, 0, wxEXPAND | wxALL, 5 );
122 panel_sizer->Add( group_panel, 0, wxEXPAND | wxALL, 5 );
123 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
124 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
126 panel_sizer->Layout();
127 panel->SetSizerAndFit( panel_sizer );
128 main_sizer->Add( panel, 1, wxGROW, 0 );
129 main_sizer->Layout();
130 SetSizerAndFit( main_sizer );
133 ItemInfoDialog::~ItemInfoDialog()
137 /*****************************************************************************
139 *****************************************************************************/
140 wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent )
142 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
145 wxStaticBox *panel_box = new wxStaticBox( panel, -1,
146 wxU(_("Item informations")) );
147 wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
150 info_subpanel = new wxPanel( panel, -1 );
152 wxFlexGridSizer *subpanel_sizer =
153 new wxFlexGridSizer( 3, 1 , 0 , 0 );
156 wxStaticText *uri_label =
157 new wxStaticText(info_subpanel, -1, wxU(_("URI")) );
159 uri_text = new wxTextCtrl( info_subpanel, Uri_Event,
160 wxT(p_item->psz_uri),
161 wxDefaultPosition, wxSize( 300, -1 ),
164 subpanel_sizer->Add( uri_label, 0, wxALIGN_LEFT |
165 wxALIGN_CENTER_VERTICAL );
166 subpanel_sizer->Add( uri_text, 0, wxALIGN_RIGHT |
167 wxALIGN_CENTER_VERTICAL );
171 wxStaticText *name_label =
172 new wxStaticText(info_subpanel, -1, wxU(_("Name")) );
175 new wxTextCtrl( info_subpanel, Uri_Event,
176 wxT(p_item->psz_name),
177 wxDefaultPosition, wxSize( 300, -1 ),
180 subpanel_sizer->Add( name_label, 0, wxALIGN_LEFT |
181 wxALIGN_CENTER_VERTICAL );
182 subpanel_sizer->Add( name_text, 0, wxALIGN_RIGHT |
183 wxALIGN_CENTER_VERTICAL );
186 wxStaticText *author_label =
187 new wxStaticText(info_subpanel, -1, wxU(_("Author")) );
190 new wxTextCtrl( info_subpanel, Uri_Event,
191 wxT(p_item->psz_author),
192 wxDefaultPosition, wxSize( 300, -1 ),
195 subpanel_sizer->Add( author_label, 0, wxALIGN_LEFT |
196 wxALIGN_CENTER_VERTICAL );
197 subpanel_sizer->Add( author_text, 0, wxALIGN_RIGHT |
198 wxALIGN_CENTER_VERTICAL );
200 info_subpanel->SetSizerAndFit( subpanel_sizer );
202 /* Stuff everything into the main panel */
203 panel_sizer->Add( info_subpanel, 1,
204 wxEXPAND | wxALIGN_LEFT |
205 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
207 panel->SetSizerAndFit( panel_sizer );
212 wxPanel *ItemInfoDialog::GroupPanel( wxWindow* parent )
214 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
217 wxStaticBox *panel_box = new wxStaticBox( panel, -1,
218 wxU(_("Group Info")) );
220 wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
223 wxBoxSizer *subpanel_sizer;
225 group_subpanel = new wxPanel( panel, -1 );
227 subpanel_sizer = new wxBoxSizer( wxVERTICAL) ;
229 enabled_checkbox = new wxCheckBox( group_subpanel,
231 wxU(_("Item enabled")) );
233 enabled_checkbox->SetValue( p_item->b_enabled);
235 wxStaticText *group_label = new wxStaticText( group_subpanel,
236 -1, wxU(_("Group")) );
237 group_spin = new wxSpinCtrl( group_subpanel,
239 group_spin->SetValue( p_item->i_group > 0 ? p_item->i_group : 0);
241 subpanel_sizer->Add( enabled_checkbox, 0, wxALIGN_RIGHT|
242 wxALIGN_CENTER_VERTICAL );
243 subpanel_sizer->Add( group_label, 0, wxALIGN_LEFT |
244 wxALIGN_CENTER_VERTICAL );
245 subpanel_sizer->Add( group_spin, 0, wxALIGN_RIGHT );
247 group_subpanel->SetSizerAndFit( subpanel_sizer );
249 /* Stuff everything into the main panel */
250 panel_sizer->Add( group_subpanel, 0,
251 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
253 panel->SetSizerAndFit( panel_sizer );
259 /*****************************************************************************
261 *****************************************************************************/
262 void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
264 p_item->psz_name = strdup( name_text->GetLineText(0) );
265 p_item->psz_uri = strdup( uri_text->GetLineText(0) );
266 p_item->psz_author = strdup( author_text->GetLineText(0) );
267 vlc_bool_t b_old_enabled = p_item->b_enabled;
269 playlist_t * p_playlist =
270 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
272 if( p_playlist != NULL )
274 if( b_old_enabled == VLC_FALSE && enabled_checkbox->IsChecked() )
275 p_playlist->i_enabled ++;
276 else if( b_old_enabled == VLC_TRUE && !enabled_checkbox->IsChecked() )
277 p_playlist->i_enabled --;
279 vlc_object_release( p_playlist );
282 p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ;
283 p_item->i_group = group_spin->GetValue();
287 void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
289 EndModal( wxID_CANCEL );
292 /******************************************************************************
293 * Info panel event methods.
294 ******************************************************************************/