1 /*****************************************************************************
2 * iteminfo.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
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 #include "dialogs/iteminfo.hpp"
25 #include <wx/combobox.h>
26 #include <wx/statline.h>
29 # define wxRB_SINGLE 0
32 /*****************************************************************************
34 *****************************************************************************/
36 /* IDs for the controls and the menu commands */
44 BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog)
46 EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk)
47 EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel)
51 /*****************************************************************************
53 *****************************************************************************/
54 ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
55 playlist_item_t *_p_item,
56 wxWindow* _p_parent ):
57 wxDialog( _p_parent, -1, wxU(_("Playlist item info")),
58 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
64 SetIcon( *p_intf->p_sys->p_icon );
66 /* Create a panel to put everything in */
67 wxPanel *panel = new wxPanel( this, -1 );
68 panel->SetAutoLayout( TRUE );
70 /* Create the standard info panel */
71 wxPanel *info_panel = InfoPanel( panel );
74 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
76 /* Create the buttons */
77 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
78 ok_button->SetDefault();
79 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
82 /* Place everything in sizers */
83 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
84 button_sizer->Add( ok_button, 0, wxALL, 5 );
85 button_sizer->Add( cancel_button, 0, wxALL, 5 );
86 button_sizer->Layout();
87 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
88 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
89 panel_sizer->Add( info_panel, 0, wxEXPAND | wxALL, 5 );
90 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
91 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
93 panel_sizer->Layout();
94 panel->SetSizerAndFit( panel_sizer );
95 main_sizer->Add( panel, 1, wxGROW, 0 );
97 SetSizerAndFit( main_sizer );
100 ItemInfoDialog::~ItemInfoDialog()
104 /*****************************************************************************
106 *****************************************************************************/
107 wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent )
109 wxPanel *info_panel = new wxPanel( parent, -1, wxDefaultPosition,
111 info_panel->SetAutoLayout( TRUE );
112 wxBoxSizer *info_sizer = new wxBoxSizer( wxHORIZONTAL );
114 /* Create a box to surround the controls */
115 wxStaticBox *panel_box = new wxStaticBox( info_panel, -1,
116 wxU(_("Item Info")) );
118 wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( panel_box,
121 wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20);
123 wxStaticText *uri_label =
124 new wxStaticText( info_panel, -1, wxU(_("URI")) );
126 uri_text = new wxTextCtrl( info_panel, Uri_Event,
127 wxU(p_item->input.psz_uri), wxDefaultPosition, wxSize( 300, -1 ),
128 wxTE_PROCESS_ENTER );
130 sizer->Add( uri_label, 0 , wxALIGN_LEFT |wxALL , 5 );
131 sizer->Add( uri_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
134 wxStaticText *name_label =
135 new wxStaticText( info_panel, -1, wxU(_("Name")) );
137 name_text = new wxTextCtrl( info_panel, Uri_Event,
138 wxU(p_item->input.psz_name), wxDefaultPosition, wxSize( 300, -1 ),
139 wxTE_PROCESS_ENTER );
141 sizer->Add( name_label, 0 , wxALIGN_LEFT |wxALL , 5 );
142 sizer->Add( name_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
145 info_tree = new wxTreeCtrl( info_panel, -1, wxDefaultPosition,
147 wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
151 box_sizer->Add( sizer, 0, wxEXPAND, 5 );
152 box_sizer->Add( info_tree, 0, wxEXPAND, 5 );
153 info_sizer->Add( box_sizer, 1, wxBOTTOM, 5 );
155 info_panel->SetSizer( info_sizer );
156 info_sizer->Layout();
157 info_sizer->SetSizeHints( info_panel );
164 void ItemInfoDialog::UpdateInfo()
168 info_root = info_tree->AddRoot( wxU( p_item->input.psz_name) );
171 /* Rebuild the tree */
172 for( int i = 0; i< p_item->input.i_categories ; i++)
174 wxTreeItemId cat = info_tree->AppendItem( info_root,
175 wxU( p_item->input.pp_categories[i]->psz_name) );
177 for( int j = 0 ; j < p_item->input.pp_categories[i]->i_infos ; j++ )
179 info_tree->AppendItem( cat , (wxString)
180 wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_name) +
182 wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_value) );
185 info_tree->Expand( cat );
189 /*****************************************************************************
191 *****************************************************************************/
192 void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
194 vlc_mutex_lock( &p_item->input.lock );
195 p_item->input.psz_name = strdup( name_text->GetLineText(0).mb_str() );
196 p_item->input.psz_uri = strdup( uri_text->GetLineText(0).mb_str() );
197 vlc_mutex_unlock( &p_item->input.lock );
201 void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
203 EndModal( wxID_CANCEL );