Commit 2458a977 authored by Christophe Mutricy's avatar Christophe Mutricy

infopanels: Redimension the text area. implement modifiable

iteminfo: Use infopanel.
parent 06381773
...@@ -40,6 +40,7 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf, ...@@ -40,6 +40,7 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf,
bool _b_modifiable ): bool _b_modifiable ):
wxPanel( _p_parent, -1 ) wxPanel( _p_parent, -1 )
{ {
int flags= wxTE_PROCESS_ENTER;
/* Initializations */ /* Initializations */
p_intf = _p_intf; p_intf = _p_intf;
p_parent = _p_parent; p_parent = _p_parent;
...@@ -49,26 +50,29 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf, ...@@ -49,26 +50,29 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf,
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20); wxFlexGridSizer *sizer = new wxFlexGridSizer(2,8,20);
sizer->AddGrowableCol(1);
if( !b_modifiable )
flags |= wxTE_READONLY;
/* URI Textbox */ /* URI Textbox */
wxStaticText *uri_static = wxStaticText *uri_static =
new wxStaticText( this, -1, wxU(_("URI")) ); new wxStaticText( this, -1, wxU(_("URI")) );
sizer->Add( uri_static, 0 , wxALL , 5 ); sizer->Add( uri_static, 0 , wxALL , 0 );
uri_text = new wxTextCtrl( this, -1, uri_text = new wxTextCtrl( this, -1,
wxU(""), wxDefaultPosition, wxSize( 300, -1 ), wxU(""), wxDefaultPosition, wxSize( 300, -1 ), flags );
wxTE_PROCESS_ENTER ); sizer->Add( uri_text, 1 , wxALL|wxEXPAND , 0 );
sizer->Add( uri_text, 1 , wxALL , 5 );
/* Name Textbox */ /* Name Textbox */
wxStaticText *name_static = wxStaticText *name_static =
new wxStaticText( this, -1, wxU(_("Name")) ); new wxStaticText( this, -1, wxU(_("Name")) );
sizer->Add( name_static, 0 , wxALL , 5 ); sizer->Add( name_static, 0 , wxALL , 0 );
name_text = new wxTextCtrl( this, -1, name_text = new wxTextCtrl( this, -1,
wxU(""), wxDefaultPosition, wxSize( 300, -1 ), wxU(""), wxDefaultPosition, wxSize( 300, -1 ), flags );
wxTE_PROCESS_ENTER ); sizer->Add( name_text, 1 , wxALL|wxEXPAND , 0 );
sizer->Add( name_text, 1 , wxALL , 5 );
/* Treeview */ /* Treeview */
info_tree = new wxTreeCtrl( this, -1, wxDefaultPosition, info_tree = new wxTreeCtrl( this, -1, wxDefaultPosition,
...@@ -78,7 +82,7 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf, ...@@ -78,7 +82,7 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf,
info_root = info_tree->AddRoot( wxU( "" ) ); info_root = info_tree->AddRoot( wxU( "" ) );
sizer->Layout(); sizer->Layout();
panel_sizer->Add( sizer, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( sizer, 0, wxEXPAND | wxALL, 15 );
panel_sizer->Add( info_tree, 1, wxEXPAND | wxALL, 5 ); panel_sizer->Add( info_tree, 1, wxEXPAND | wxALL, 5 );
panel_sizer->Layout(); panel_sizer->Layout();
SetSizerAndFit( panel_sizer ); SetSizerAndFit( panel_sizer );
...@@ -113,6 +117,16 @@ void ItemInfoPanel::Update( input_item_t *p_item ) ...@@ -113,6 +117,16 @@ void ItemInfoPanel::Update( input_item_t *p_item )
} }
} }
char* ItemInfoPanel::GetURI( )
{
return strdup( uri_text->GetLineText(0).mb_str() );
}
char* ItemInfoPanel::GetName( )
{
return strdup( name_text->GetLineText(0).mb_str() );
}
void ItemInfoPanel::Clear() void ItemInfoPanel::Clear()
{ {
info_tree->DeleteChildren( info_root ); info_tree->DeleteChildren( info_root );
......
...@@ -40,6 +40,10 @@ public: ...@@ -40,6 +40,10 @@ public:
void Update( input_item_t *); void Update( input_item_t *);
void Clear(); void Clear();
char* GetURI();
char* GetName();
void OnOk(); void OnOk();
void OnCancel(); void OnCancel();
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*****************************************************************************/ *****************************************************************************/
#include "dialogs/iteminfo.hpp" #include "dialogs/iteminfo.hpp"
#include "dialogs/infopanels.hpp"
#include <wx/combobox.h> #include <wx/combobox.h>
#include <wx/statline.h> #include <wx/statline.h>
...@@ -68,8 +69,8 @@ ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf, ...@@ -68,8 +69,8 @@ ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
panel->SetAutoLayout( TRUE ); panel->SetAutoLayout( TRUE );
/* Create the standard info panel */ /* Create the standard info panel */
wxPanel *info_panel = InfoPanel( panel ); info_panel = new ItemInfoPanel(p_intf, panel, true );
info_panel->Update( &(p_item->input) );
/* Separation */ /* Separation */
wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK ); wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
...@@ -86,7 +87,7 @@ ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf, ...@@ -86,7 +87,7 @@ ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
button_sizer->Layout(); button_sizer->Layout();
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
panel_sizer->Add( info_panel, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( info_panel, 1, wxEXPAND | wxALL, 5 );
panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM | panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
wxALL, 5 ); wxALL, 5 );
...@@ -101,90 +102,6 @@ ItemInfoDialog::~ItemInfoDialog() ...@@ -101,90 +102,6 @@ ItemInfoDialog::~ItemInfoDialog()
{ {
} }
/*****************************************************************************
* Private methods.
*****************************************************************************/
wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent )
{
wxPanel *info_panel = new wxPanel( parent, -1, wxDefaultPosition,
wxDefaultSize );
info_panel->SetAutoLayout( TRUE );
wxBoxSizer *info_sizer = new wxBoxSizer( wxHORIZONTAL );
/* Create a box to surround the controls */
wxStaticBox *panel_box = new wxStaticBox( info_panel, -1,
wxU(_("Item Info")) );
wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( panel_box,
wxVERTICAL );
wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20);
/* URI Textbox */
wxStaticText *uri_label =
new wxStaticText( info_panel, -1, wxU(_("URI")) );
uri_text = new wxTextCtrl( info_panel, Uri_Event,
wxU(p_item->input.psz_uri), wxDefaultPosition, wxSize( 300, -1 ),
wxTE_PROCESS_ENTER );
sizer->Add( uri_label, 0 , wxALIGN_LEFT |wxALL , 5 );
sizer->Add( uri_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
/* Name Textbox */
wxStaticText *name_label =
new wxStaticText( info_panel, -1, wxU(_("Name")) );
name_text = new wxTextCtrl( info_panel, Uri_Event,
wxU(p_item->input.psz_name), wxDefaultPosition, wxSize( 300, -1 ),
wxTE_PROCESS_ENTER );
sizer->Add( name_label, 0 , wxALIGN_LEFT |wxALL , 5 );
sizer->Add( name_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
/* Treeview */
info_tree = new wxTreeCtrl( info_panel, -1, wxDefaultPosition,
wxSize(220,200),
wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
wxTR_HIDE_ROOT | wxTR_HAS_VARIABLE_ROW_HEIGHT );
sizer->Layout();
box_sizer->Add( sizer, 0, wxEXPAND, 5 );
box_sizer->Add( info_tree, 0, wxEXPAND, 5 );
info_sizer->Add( box_sizer, 1, wxBOTTOM, 5 );
info_panel->SetSizer( info_sizer );
info_sizer->Layout();
info_sizer->SetSizeHints( info_panel );
UpdateInfo();
return info_panel;
}
void ItemInfoDialog::UpdateInfo()
{
if( !info_root )
{
info_root = info_tree->AddRoot( wxU( p_item->input.psz_name) );
}
/* Rebuild the tree */
for( int i = 0; i< p_item->input.i_categories ; i++)
{
wxTreeItemId cat = info_tree->AppendItem( info_root,
wxU( p_item->input.pp_categories[i]->psz_name) );
for( int j = 0 ; j < p_item->input.pp_categories[i]->i_infos ; j++ )
{
info_tree->AppendItem( cat , (wxString)
wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_name) +
wxT(": ") +
wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_value) );
}
info_tree->Expand( cat );
}
}
/***************************************************************************** /*****************************************************************************
* Events methods. * Events methods.
...@@ -192,8 +109,8 @@ void ItemInfoDialog::UpdateInfo() ...@@ -192,8 +109,8 @@ void ItemInfoDialog::UpdateInfo()
void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{ {
vlc_mutex_lock( &p_item->input.lock ); vlc_mutex_lock( &p_item->input.lock );
p_item->input.psz_name = strdup( name_text->GetLineText(0).mb_str() ); p_item->input.psz_name = info_panel->GetName();
p_item->input.psz_uri = strdup( uri_text->GetLineText(0).mb_str() ); p_item->input.psz_uri = info_panel->GetURI();
vlc_mutex_unlock( &p_item->input.lock ); vlc_mutex_unlock( &p_item->input.lock );
EndModal( wxID_OK ); EndModal( wxID_OK );
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define _WXVLC_ITEMINFO_H_ #define _WXVLC_ITEMINFO_H_
#include "wxwidgets.hpp" #include "wxwidgets.hpp"
#include "dialogs/infopanels.hpp"
#include <wx/treectrl.h> #include <wx/treectrl.h>
namespace wxvlc namespace wxvlc
...@@ -41,7 +41,6 @@ public: ...@@ -41,7 +41,6 @@ public:
wxArrayString GetOptions(); wxArrayString GetOptions();
private: private:
wxPanel *InfoPanel( wxWindow* parent );
wxPanel *GroupPanel( wxWindow* parent ); wxPanel *GroupPanel( wxWindow* parent );
/* Event handlers (these functions should _not_ be virtual) */ /* Event handlers (these functions should _not_ be virtual) */
...@@ -58,7 +57,7 @@ private: ...@@ -58,7 +57,7 @@ private:
/* Controls for the iteminfo dialog box */ /* Controls for the iteminfo dialog box */
wxPanel *info_subpanel; wxPanel *info_subpanel;
wxPanel *info_panel; ItemInfoPanel *info_panel;
wxPanel *group_subpanel; wxPanel *group_subpanel;
wxPanel *group_panel; wxPanel *group_panel;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment