1 /*****************************************************************************
2 * iteminfo.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
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 #include <wx/combobox.h>
35 #include <wx/statline.h>
39 #include "wxwindows.h"
42 # define wxRB_SINGLE 0
45 /*****************************************************************************
47 *****************************************************************************/
49 /* IDs for the controls and the menu commands */
57 BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog)
59 EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk)
60 EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel)
64 /*****************************************************************************
66 *****************************************************************************/
67 ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
68 playlist_item_t *_p_item,
69 wxWindow* _p_parent ):
70 wxDialog( _p_parent, -1, wxU(_("Playlist item info")),
71 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
77 SetIcon( *p_intf->p_sys->p_icon );
79 /* Create a panel to put everything in */
80 wxPanel *panel = new wxPanel( this, -1 );
81 panel->SetAutoLayout( TRUE );
83 /* Create the standard info panel */
84 wxPanel *info_panel = InfoPanel( panel );
87 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
89 /* Create the buttons */
90 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
91 ok_button->SetDefault();
92 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
95 /* Place everything in sizers */
96 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
97 button_sizer->Add( ok_button, 0, wxALL, 5 );
98 button_sizer->Add( cancel_button, 0, wxALL, 5 );
99 button_sizer->Layout();
100 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
101 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
102 panel_sizer->Add( info_panel, 0, wxEXPAND | wxALL, 5 );
103 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
104 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
106 panel_sizer->Layout();
107 panel->SetSizerAndFit( panel_sizer );
108 main_sizer->Add( panel, 1, wxGROW, 0 );
109 main_sizer->Layout();
110 SetSizerAndFit( main_sizer );
113 ItemInfoDialog::~ItemInfoDialog()
117 /*****************************************************************************
119 *****************************************************************************/
120 wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent )
122 wxPanel *info_panel = new wxPanel( parent, -1, wxDefaultPosition,
124 info_panel->SetAutoLayout( TRUE );
125 wxBoxSizer *info_sizer = new wxBoxSizer( wxHORIZONTAL );
127 /* Create a box to surround the controls */
128 wxStaticBox *panel_box = new wxStaticBox( info_panel, -1,
129 wxU(_("Item Info")) );
131 wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( panel_box,
134 wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20);
136 wxStaticText *uri_label =
137 new wxStaticText( info_panel, -1, wxU(_("URI")) );
139 uri_text = new wxTextCtrl( info_panel, Uri_Event,
140 wxU(p_item->input.psz_uri), wxDefaultPosition, wxSize( 300, -1 ),
141 wxTE_PROCESS_ENTER );
143 sizer->Add( uri_label, 0 , wxALIGN_LEFT |wxALL , 5 );
144 sizer->Add( uri_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
147 wxStaticText *name_label =
148 new wxStaticText( info_panel, -1, wxU(_("Name")) );
150 name_text = new wxTextCtrl( info_panel, Uri_Event,
151 wxU(p_item->input.psz_name), wxDefaultPosition, wxSize( 300, -1 ),
152 wxTE_PROCESS_ENTER );
154 sizer->Add( name_label, 0 , wxALIGN_LEFT |wxALL , 5 );
155 sizer->Add( name_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
158 info_tree = new wxTreeCtrl( info_panel, -1, wxDefaultPosition,
160 wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
164 box_sizer->Add( sizer, 0, wxEXPAND, 5 );
165 box_sizer->Add( info_tree, 0, wxEXPAND, 5 );
166 info_sizer->Add( box_sizer, 1, wxBOTTOM, 5 );
168 info_panel->SetSizer( info_sizer );
169 info_sizer->Layout();
170 info_sizer->SetSizeHints( info_panel );
177 void ItemInfoDialog::UpdateInfo()
181 info_root = info_tree->AddRoot( wxU( p_item->input.psz_name) );
184 /* Rebuild the tree */
185 for( int i = 0; i< p_item->input.i_categories ; i++)
187 wxTreeItemId cat = info_tree->AppendItem( info_root,
188 wxU( p_item->input.pp_categories[i]->psz_name) );
190 for( int j = 0 ; j < p_item->input.pp_categories[i]->i_infos ; j++ )
192 info_tree->AppendItem( cat , (wxString)
193 wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_name) +
195 wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_value) );
198 info_tree->Expand( cat );
202 /*****************************************************************************
204 *****************************************************************************/
205 void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
207 vlc_mutex_lock( &p_item->input.lock );
208 p_item->input.psz_name = strdup( name_text->GetLineText(0).mb_str() );
209 p_item->input.psz_uri = strdup( uri_text->GetLineText(0).mb_str() );
210 vlc_mutex_unlock( &p_item->input.lock );
214 void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
216 EndModal( wxID_CANCEL );