]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/infopanels.cpp
b6b65c32dbf7033dda5f1904c241ae305979667e
[vlc] / modules / gui / wxwidgets / dialogs / infopanels.cpp
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 $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include "dialogs/infopanels.hpp"
25 #include <wx/combobox.h>
26 #include <wx/statline.h>
27
28 #ifndef wxRB_SINGLE
29 #   define wxRB_SINGLE 0
30 #endif
31
32 /*****************************************************************************
33  * General info panel
34  *****************************************************************************/
35 BEGIN_EVENT_TABLE( ItemInfoPanel, wxPanel )
36 END_EVENT_TABLE()
37
38 ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf,
39                               wxWindow* _p_parent,
40                               bool _b_modifiable ):
41     wxPanel( _p_parent, -1 )
42 {
43     /* Initializations */
44     p_intf = _p_intf;
45     p_parent = _p_parent;
46     b_modifiable = _b_modifiable;
47
48     SetAutoLayout( TRUE );
49
50     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
51
52     wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20);
53     /* URI Textbox */
54     wxStaticText *uri_static =
55            new wxStaticText( this, -1, wxU(_("URI")) );
56     sizer->Add( uri_static, 0 , wxALL , 5 );
57
58     uri_text = new wxTextCtrl( this, -1,
59             wxU(""), wxDefaultPosition, wxSize( 300, -1 ),
60             wxTE_PROCESS_ENTER );
61     sizer->Add( uri_text, 1 ,  wxALL , 5 );
62
63     /* Name Textbox */
64     wxStaticText *name_static =
65            new wxStaticText(  this, -1, wxU(_("Name")) );
66     sizer->Add( name_static, 0 , wxALL , 5  );
67
68     name_text = new wxTextCtrl( this, -1,
69             wxU(""), wxDefaultPosition, wxSize( 300, -1 ),
70             wxTE_PROCESS_ENTER );
71     sizer->Add( name_text, 1 , wxALL , 5 );
72
73     /* Treeview */
74     info_tree = new wxTreeCtrl( this, -1, wxDefaultPosition,
75                                 wxSize(220,200),
76                                 wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
77                                 wxTR_HIDE_ROOT );
78     info_root = info_tree->AddRoot( wxU( "" ) );
79
80     sizer->Layout();
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 );
85 }
86
87 ItemInfoPanel::~ItemInfoPanel()
88 {
89 }
90
91 void ItemInfoPanel::Update( input_item_t *p_item )
92 {
93     /* Rebuild the tree */
94     Clear();
95
96     uri_text->SetValue( wxU( p_item->psz_uri ) );
97     name_text->SetValue( wxU( p_item->psz_name ) );
98
99     for( int i = 0; i< p_item->i_categories ; i++)
100     {
101         wxTreeItemId cat = info_tree->AppendItem( info_root,
102                             wxU( p_item->pp_categories[i]->psz_name) );
103
104         for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ )
105         {
106            info_tree->AppendItem( cat , (wxString)
107                wxU(p_item->pp_categories[i]->pp_infos[j]->psz_name) +
108                wxT(": ") +
109                wxU(p_item->pp_categories[i]->pp_infos[j]->psz_value) );
110         }
111
112         info_tree->Expand( cat );
113     }
114 }
115
116 void ItemInfoPanel::Clear()
117 {
118     info_tree->DeleteChildren( info_root );
119 }
120
121 void ItemInfoPanel::OnOk( )
122 {
123 }
124
125 void ItemInfoPanel::OnCancel( )
126 {
127 }
128
129 /*****************************************************************************
130  * Statistics info panel
131  *****************************************************************************/
132 BEGIN_EVENT_TABLE( InputStatsInfoPanel, wxPanel )
133 END_EVENT_TABLE()
134
135 InputStatsInfoPanel::InputStatsInfoPanel( intf_thread_t *_p_intf,
136                                           wxWindow* _p_parent ):
137     wxPanel( _p_parent, -1 )
138 {
139     /* Initializations */
140     p_intf = _p_intf;
141     p_parent = _p_parent;
142
143     SetAutoLayout( TRUE );
144
145     panel_sizer = new wxBoxSizer( wxVERTICAL );
146
147     sizer = new wxFlexGridSizer( 2,2,20 );
148
149     /* Input */
150     wxStaticBox *input_box = new wxStaticBox( this, -1,
151                                               wxU( _("Input") ) );
152     input_box->SetAutoLayout( TRUE );
153     input_bsizer = new wxStaticBoxSizer( input_box, wxVERTICAL );
154     input_sizer = new wxFlexGridSizer( 2,2, 20 );
155
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  );              \
161     }
162
163     INPUT_ADD( "Read at media", read_bytes_text, "0" );
164     INPUT_ADD( "Input bitrate", input_bitrate_text, "0" );
165
166     INPUT_ADD( "Demuxed", demux_bytes_text ,"0");
167     /* Hack to get enough size */
168     INPUT_ADD( "Stream bitrate", demux_bitrate_text, "0              " );
169
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 );
174
175    /* Vout */
176     wxStaticBox *video_box = new wxStaticBox( this, -1,
177                                               wxU( _("Video" ) ) );
178     video_box->SetAutoLayout( TRUE );
179     video_bsizer = new wxStaticBoxSizer( video_box,
180                                                           wxVERTICAL );
181     video_sizer = new wxFlexGridSizer( 2,3, 20 );
182
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 );                \
188     }
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" );
193
194
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 );
199
200    /* Aout */
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 );
206
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 );                \
212     }
213     AUDIO_ADD( "Decoded blocks", audio_decoded_text, "0" );
214     /* Hack to get enough size */
215     AUDIO_ADD( "Played buffers", played_abuffers_text,
216                                  "0                  " );
217     AUDIO_ADD( "Lost buffers", lost_abuffers_text, "0" );
218
219
220     audio_sizer->Layout();
221     audio_bsizer->Add( audio_sizer, 0, wxALL | wxGROW, 5 );
222     audio_bsizer->Layout();
223     sizer->AddSpacer( 0 );
224     sizer->Add( audio_bsizer , 0, wxALL| wxGROW, 5 );
225
226     sizer->Layout();
227     panel_sizer->Add( sizer, 0, wxEXPAND, 5 );
228     panel_sizer->Layout();
229     SetSizerAndFit( panel_sizer );
230 }
231
232 InputStatsInfoPanel::~InputStatsInfoPanel()
233 {
234 }
235
236 void InputStatsInfoPanel::Update( input_item_t *p_item )
237 {
238     vlc_mutex_lock( &p_item->p_stats->lock );
239
240     /* Input */
241 #define UPDATE( widget,format, calc... )   \
242 {                                       \
243     wxString formatted;                 \
244     formatted.Printf(  wxString( wxT(format) ), ## calc ); \
245     widget->SetLabel( formatted );                      \
246 }
247     UPDATE( read_bytes_text, "%8.0f kB",(float)(p_item->p_stats->i_read_bytes)/1000 );
248     UPDATE( input_bitrate_text, "%6.0f kB/s", (float)(p_item->p_stats->f_input_bitrate)*1000 );
249     UPDATE( demux_bytes_text, "%8.0f kB", (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
250     UPDATE( demux_bitrate_text, "%6.0f kB/s",  (float)(p_item->p_stats->f_demux_bitrate)*1000 );
251
252     /* Video */
253     UPDATE( video_decoded_text, "%5i", p_item->p_stats->i_decoded_video );
254     UPDATE( displayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
255     UPDATE( lost_frames_text, "%5i", p_item->p_stats->i_lost_pictures );
256
257     UPDATE( audio_decoded_text, "%5i", p_item->p_stats->i_decoded_audio );
258     UPDATE( played_abuffers_text, "%5i", p_item->p_stats->i_played_abuffers );
259     UPDATE( lost_abuffers_text, "%5i", p_item->p_stats->i_lost_abuffers );
260
261     vlc_mutex_unlock( &p_item->p_stats->lock );
262
263     input_sizer->Layout();
264     video_sizer->Layout();
265
266     sizer->Layout();
267     panel_sizer->Layout();
268     SetSizerAndFit( panel_sizer );
269 }
270
271 void InputStatsInfoPanel::Clear()
272 {}
273
274 void InputStatsInfoPanel::OnOk( )
275 {}
276
277 void InputStatsInfoPanel::OnCancel( )
278 {}
279