1 /*****************************************************************************
2 * infopanels.cpp : Information panels (general info, stats, ...)
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
5 * $Id: iteminfo.cpp 13905 2006-01-12 23:10:04Z dionoea $
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "dialogs/infopanels.hpp"
25 #include <wx/combobox.h>
26 #include <wx/statline.h>
29 # define wxRB_SINGLE 0
32 /*****************************************************************************
34 *****************************************************************************/
35 BEGIN_EVENT_TABLE( ItemInfoPanel, wxPanel )
38 ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf,
41 wxPanel( _p_parent, -1 )
46 b_modifiable = _b_modifiable;
48 SetAutoLayout( TRUE );
50 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
52 wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20);
54 wxStaticText *uri_static =
55 new wxStaticText( this, -1, wxU(_("URI")) );
56 sizer->Add( uri_static, 0 , wxALL , 5 );
58 uri_text = new wxTextCtrl( this, -1,
59 wxU(""), wxDefaultPosition, wxSize( 300, -1 ),
61 sizer->Add( uri_text, 1 , wxALL , 5 );
64 wxStaticText *name_static =
65 new wxStaticText( this, -1, wxU(_("Name")) );
66 sizer->Add( name_static, 0 , wxALL , 5 );
68 name_text = new wxTextCtrl( this, -1,
69 wxU(""), wxDefaultPosition, wxSize( 300, -1 ),
71 sizer->Add( name_text, 1 , wxALL , 5 );
74 info_tree = new wxTreeCtrl( this, -1, wxDefaultPosition,
76 wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
78 info_root = info_tree->AddRoot( wxU( "" ) );
81 panel_sizer->Add( sizer, 0, wxEXPAND | wxALL, 5 );
82 panel_sizer->Add( info_tree, 1, wxEXPAND | wxALL, 5 );
83 panel_sizer->Layout();
84 SetSizerAndFit( panel_sizer );
87 ItemInfoPanel::~ItemInfoPanel()
91 void ItemInfoPanel::Update( input_item_t *p_item )
93 /* Rebuild the tree */
96 uri_text->SetValue( wxU( p_item->psz_uri ) );
97 name_text->SetValue( wxU( p_item->psz_name ) );
99 for( int i = 0; i< p_item->i_categories ; i++)
101 wxTreeItemId cat = info_tree->AppendItem( info_root,
102 wxU( p_item->pp_categories[i]->psz_name) );
104 for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ )
106 info_tree->AppendItem( cat , (wxString)
107 wxU(p_item->pp_categories[i]->pp_infos[j]->psz_name) +
109 wxU(p_item->pp_categories[i]->pp_infos[j]->psz_value) );
112 info_tree->Expand( cat );
116 void ItemInfoPanel::Clear()
118 info_tree->DeleteChildren( info_root );
121 void ItemInfoPanel::OnOk( )
125 void ItemInfoPanel::OnCancel( )
129 /*****************************************************************************
130 * Statistics info panel
131 *****************************************************************************/
132 BEGIN_EVENT_TABLE( InputStatsInfoPanel, wxPanel )
135 InputStatsInfoPanel::InputStatsInfoPanel( intf_thread_t *_p_intf,
136 wxWindow* _p_parent ):
137 wxPanel( _p_parent, -1 )
139 /* Initializations */
141 p_parent = _p_parent;
143 SetAutoLayout( TRUE );
145 panel_sizer = new wxBoxSizer( wxVERTICAL );
147 sizer = new wxFlexGridSizer( 2,2,20 );
150 wxStaticBox *input_box = new wxStaticBox( this, -1,
152 input_box->SetAutoLayout( TRUE );
153 input_bsizer = new wxStaticBoxSizer( input_box, wxVERTICAL );
154 input_sizer = new wxFlexGridSizer( 2,2, 20 );
156 #define INPUT_ADD(txt,widget,dflt) \
157 { input_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ), \
158 0, wxEXPAND| wxRIGHT, 5 ); \
159 widget = new wxStaticText( this, -1, wxU( dflt ) ); \
160 input_sizer->Add( widget, 0, wxEXPAND| wxLEFT, 5 ); \
163 INPUT_ADD( "Read at media", read_bytes_text, "0" );
164 INPUT_ADD( "Input bitrate", input_bitrate_text, "0" );
166 INPUT_ADD( "Demuxed", demux_bytes_text ,"0");
167 /* Hack to get enough size */
168 INPUT_ADD( "Stream bitrate", demux_bitrate_text, "0 " );
170 input_sizer->Layout();
171 input_bsizer->Add( input_sizer, 0, wxALL | wxGROW, 5 );
172 input_bsizer->Layout();
173 sizer->Add( input_bsizer, 0, wxALL|wxGROW, 5 );
176 wxStaticBox *video_box = new wxStaticBox( this, -1,
177 wxU( _("Video" ) ) );
178 video_box->SetAutoLayout( TRUE );
179 video_bsizer = new wxStaticBoxSizer( video_box,
181 video_sizer = new wxFlexGridSizer( 2,3, 20 );
183 #define VIDEO_ADD(txt,widget,dflt) \
184 { video_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ), \
185 0, wxEXPAND|wxLEFT , 5 ); \
186 widget = new wxStaticText( this, -1, wxU( dflt ) ); \
187 video_sizer->Add( widget, 0, wxEXPAND|wxRIGHT, 5 ); \
189 VIDEO_ADD( "Decoded blocks", video_decoded_text, "0" );
190 /* Hack to get enough size */
191 VIDEO_ADD( "Displayed frames", displayed_text, "0 " );
192 VIDEO_ADD( "Lost frames", lost_frames_text, "0" );
195 video_sizer->Layout();
196 video_bsizer->Add( video_sizer, 0, wxALL | wxGROW, 5 );
197 video_bsizer->Layout();
198 sizer->Add( video_bsizer , 0, wxALL| wxGROW, 5 );
201 wxStaticBox *audio_box = new wxStaticBox( this, -1,
202 wxU( _("Audio" ) ) );
203 audio_box->SetAutoLayout( TRUE );
204 audio_bsizer = new wxStaticBoxSizer( audio_box, wxVERTICAL );
205 audio_sizer = new wxFlexGridSizer( 2,3, 20 );
207 #define AUDIO_ADD(txt,widget,dflt) \
208 { audio_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ), \
209 0, wxEXPAND|wxLEFT , 5 ); \
210 widget = new wxStaticText( this, -1, wxU( dflt ) ); \
211 audio_sizer->Add( widget, 0, wxEXPAND|wxRIGHT, 5 ); \
213 AUDIO_ADD( "Decoded blocks", audio_decoded_text, "0" );
214 /* Hack to get enough size */
215 AUDIO_ADD( "Played buffers", played_abuffers_text,
217 AUDIO_ADD( "Lost buffers", lost_abuffers_text, "0" );
220 audio_sizer->Layout();
221 audio_bsizer->Add( audio_sizer, 0, wxALL | wxGROW, 5 );
222 audio_bsizer->Layout();
223 sizer->Add( audio_bsizer , 0, wxALL| wxGROW, 5 );
226 panel_sizer->Add( sizer, 0, wxEXPAND, 5 );
227 panel_sizer->Layout();
228 SetSizerAndFit( panel_sizer );
231 InputStatsInfoPanel::~InputStatsInfoPanel()
235 void InputStatsInfoPanel::Update( input_item_t *p_item )
237 vlc_mutex_lock( &p_item->p_stats->lock );
240 #define UPDATE( widget,format, calc... ) \
242 wxString formatted; \
243 formatted.Printf( wxString( wxT(format) ), ## calc ); \
244 widget->SetLabel( formatted ); \
246 UPDATE( read_bytes_text, "%8.0f kB",(float)(p_item->p_stats->i_read_bytes)/1000 );
247 UPDATE( input_bitrate_text, "%6.0f kB/s", (float)(p_item->p_stats->f_input_bitrate)*1000 );
248 UPDATE( demux_bytes_text, "%8.0f kB", (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
249 UPDATE( demux_bitrate_text, "%6.0f kB/s", (float)(p_item->p_stats->f_demux_bitrate)*1000 );
252 UPDATE( video_decoded_text, "%5i", p_item->p_stats->i_decoded_video );
253 UPDATE( displayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
254 UPDATE( lost_frames_text, "%5i", p_item->p_stats->i_lost_pictures );
256 UPDATE( audio_decoded_text, "%5i", p_item->p_stats->i_decoded_audio );
257 UPDATE( played_abuffers_text, "%5i", p_item->p_stats->i_played_abuffers );
258 UPDATE( lost_abuffers_text, "%5i", p_item->p_stats->i_lost_abuffers );
260 vlc_mutex_unlock( &p_item->p_stats->lock );
262 input_sizer->Layout();
263 video_sizer->Layout();
266 panel_sizer->Layout();
267 SetSizerAndFit( panel_sizer );
270 void InputStatsInfoPanel::Clear()
273 void InputStatsInfoPanel::OnOk( )
276 void InputStatsInfoPanel::OnCancel( )