1
// -------------------------------------------------------------------------------- //
2
// Copyright (C) 2008-2010 J.Rios
5
// This Program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2, or (at your option)
10
// This Program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; see the file LICENSE. If not, write to
17
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
// http://www.gnu.org/copyleft/gpl.html
20
// -------------------------------------------------------------------------------- //
21
#include "RadioGenreEditor.h"
23
#include "Shoutcast.h"
25
// -------------------------------------------------------------------------------- //
26
guRadioGenreEditor::guRadioGenreEditor( wxWindow * parent, guDbRadios * db ) :
27
wxDialog( parent, wxID_ANY, _("Radio Genre Editor"), wxDefaultPosition, wxSize( 280,360 ), wxDEFAULT_DIALOG_STYLE )
31
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
33
wxBoxSizer* MainSizer;
34
MainSizer = new wxBoxSizer( wxVERTICAL );
36
wxStaticBoxSizer* ListBoxSizer;
37
ListBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _(" Genres ") ), wxVERTICAL );
39
guShoutCast ShoutCast;
40
m_RadioGenres = ShoutCast.GetGenres();
42
m_CheckListBox = new wxCheckListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RadioGenres, wxLB_MULTIPLE|wxLB_NEEDED_SB|wxNO_BORDER );
43
ListBoxSizer->Add( m_CheckListBox, 1, wxALL|wxEXPAND, 5 );
45
wxBoxSizer* InputSizer;
46
InputSizer = new wxBoxSizer( wxHORIZONTAL );
48
m_InputStaticText = new wxStaticText( this, wxID_ANY, _("Other:"), wxDefaultPosition, wxDefaultSize, 0 );
49
m_InputStaticText->Wrap( -1 );
50
InputSizer->Add( m_InputStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
52
m_InputTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
53
InputSizer->Add( m_InputTextCtrl, 1, wxALL, 5 );
55
ListBoxSizer->Add( InputSizer, 0, wxEXPAND, 5 );
57
MainSizer->Add( ListBoxSizer, 1, wxEXPAND|wxALL, 5 );
59
wxStdDialogButtonSizer* TagEditorBtnSizer;
60
wxButton* TagEditorBtnSizerOK;
61
wxButton* TagEditorBtnSizerCancel;
63
TagEditorBtnSizer = new wxStdDialogButtonSizer();
64
TagEditorBtnSizerOK = new wxButton( this, wxID_OK );
65
TagEditorBtnSizer->AddButton( TagEditorBtnSizerOK );
66
TagEditorBtnSizerCancel = new wxButton( this, wxID_CANCEL );
67
TagEditorBtnSizer->AddButton( TagEditorBtnSizerCancel );
68
TagEditorBtnSizer->Realize();
69
MainSizer->Add( TagEditorBtnSizer, 0, wxRIGHT|wxBOTTOM|wxEXPAND, 5 );
71
this->SetSizer( MainSizer );
74
// By default enable already added items
75
m_Db->GetRadioGenres( guRADIO_SOURCE_GENRE, &m_AddedGenres, false );
77
int count = m_AddedGenres.Count();
79
for( index = 0; index < count; index ++ )
81
item = m_RadioGenres.Index( m_AddedGenres[ index ].m_Name );
82
if( item != wxNOT_FOUND )
83
m_CheckListBox->Check( item );
89
// -------------------------------------------------------------------------------- //
90
wxArrayString guRadioGenreEditor::GetGenres( void )
94
int count = m_CheckListBox->GetCount();
95
for( index = 0; index < count; index++ )
97
if( m_CheckListBox->IsChecked( index ) )
99
RetVal.Add( m_RadioGenres[ index ] );
102
if( !m_InputTextCtrl->IsEmpty() )
104
RetVal.Add( m_InputTextCtrl->GetValue() );
107
// we add all and then remove the existans as guListBox dont have the Index function
108
// so we check the other direction
109
count = m_AddedGenres.Count();
111
for( index = 0; index < count; index++ )
113
item = RetVal.Index( m_AddedGenres[ index ].m_Name );
114
if( item != wxNOT_FOUND )
116
RetVal.RemoveAt( item );
122
// -------------------------------------------------------------------------------- //
123
guRadioGenreEditor::~guRadioGenreEditor()
127
// -------------------------------------------------------------------------------- //