]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/iteminfo.cpp
Uniformize source files encoding
[vlc] / modules / gui / wxwidgets / dialogs / iteminfo.cpp
1 /*****************************************************************************
2  * iteminfo.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2004 the VideoLAN team
5  * $Id$
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/iteminfo.hpp"
25 #include "dialogs/infopanels.hpp"
26 #include <wx/combobox.h>
27 #include <wx/statline.h>
28
29 #ifndef wxRB_SINGLE
30 #   define wxRB_SINGLE 0
31 #endif
32
33 /*****************************************************************************
34  * Event Table.
35  *****************************************************************************/
36
37 /* IDs for the controls and the menu commands */
38 enum
39 {
40     Uri_Event,
41     Name_Event,
42     Enabled_Event,
43 };
44
45 BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog)
46     /* Button events */
47     EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk)
48     EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel)
49
50 END_EVENT_TABLE()
51
52 /*****************************************************************************
53  * Constructor.
54  *****************************************************************************/
55 ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
56                                 playlist_item_t *_p_item,
57                                 wxWindow* _p_parent ):
58     wxDialog( _p_parent, -1, wxU(_("Playlist item info")),
59              wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
60 {
61     /* Initializations */
62     p_intf = _p_intf;
63     p_parent = _p_parent;
64     p_item = _p_item;
65     SetIcon( *p_intf->p_sys->p_icon );
66
67     /* Create a panel to put everything in */
68     wxPanel *panel = new wxPanel( this, -1 );
69     panel->SetAutoLayout( TRUE );
70
71     /* Create the standard info panel */
72     info_panel = new ItemInfoPanel(p_intf, panel, true );
73     info_panel->Update( &(p_item->input) );
74     /* Separation */
75     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
76
77     /* Create the buttons */
78     wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
79     ok_button->SetDefault();
80     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
81                                             wxU(_("Cancel")) );
82
83     /* Place everything in sizers */
84     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
85     button_sizer->Add( ok_button, 0, wxALL, 5 );
86     button_sizer->Add( cancel_button, 0, wxALL, 5 );
87     button_sizer->Layout();
88     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
89     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
90     panel_sizer->Add( info_panel, 1, wxEXPAND | wxALL, 5 );
91     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
92     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
93                       wxALL, 5 );
94     panel_sizer->Layout();
95     panel->SetSizerAndFit( panel_sizer );
96     main_sizer->Add( panel, 1, wxGROW, 0 );
97     main_sizer->Layout();
98     SetSizerAndFit( main_sizer );
99 }
100
101 ItemInfoDialog::~ItemInfoDialog()
102 {
103 }
104
105
106 /*****************************************************************************
107  * Events methods.
108  *****************************************************************************/
109 void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
110 {
111     vlc_mutex_lock( &p_item->input.lock );
112     p_item->input.psz_name = info_panel->GetName();
113     p_item->input.psz_uri = info_panel->GetURI();
114     vlc_mutex_unlock( &p_item->input.lock );
115     EndModal( wxID_OK );
116 }
117
118 void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
119 {
120     EndModal( wxID_CANCEL );
121 }