2
* This file is part of lib_finder plugin for Code::Blocks Studio
3
* Copyright (C) 2007 Bartlomiej Swiecki
5
* wxSmith 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 of the License, or
8
* (at your option) any later version.
10
* wxSmith 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 wxSmith; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20
* $Id: wxsmithpluginregistrants.cpp 4504 2007-10-02 21:52:30Z byo $
21
* $HeadURL: svn+ssh://byo@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/contrib/wxSmith/plugin/wxsmithpluginregistrants.cpp $
24
#include "libselectdlg.h"
26
//(*InternalHeaders(LibSelectDlg)
28
#include <wx/stattext.h>
29
#include <wx/checklst.h>
30
#include <wx/checkbox.h>
31
#include <wx/radiobut.h>
33
#include <wx/button.h>
34
#include <wx/string.h>
38
#include <configmanager.h>
40
//(*IdInit(LibSelectDlg)
41
const long LibSelectDlg::ID_STATICTEXT1 = wxNewId();
42
const long LibSelectDlg::ID_CHECKLISTBOX1 = wxNewId();
43
const long LibSelectDlg::ID_RADIOBUTTON1 = wxNewId();
44
const long LibSelectDlg::ID_RADIOBUTTON2 = wxNewId();
45
const long LibSelectDlg::ID_RADIOBUTTON3 = wxNewId();
46
const long LibSelectDlg::ID_CHECKBOX1 = wxNewId();
49
BEGIN_EVENT_TABLE(LibSelectDlg,wxDialog)
50
//(*EventTable(LibSelectDlg)
52
EVT_BUTTON(wxID_OK,LibSelectDlg::OnOk)
55
LibSelectDlg::LibSelectDlg(wxWindow* parent,const wxArrayString& Names)
57
//(*Initialize(LibSelectDlg)
58
wxBoxSizer* BoxSizer1;
59
wxStaticBoxSizer* StaticBoxSizer1;
60
wxStdDialogButtonSizer* StdDialogButtonSizer1;
62
Create(parent, wxID_ANY, _("Setting up libraries"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
63
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
64
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Select libraries You want to set up:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
65
BoxSizer1->Add(StaticText1, 0, wxTOP|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
66
m_Libraries = new wxCheckListBox(this, ID_CHECKLISTBOX1, wxDefaultPosition, wxSize(361,251), 0, 0, 0, wxDefaultValidator, _T("ID_CHECKLISTBOX1"));
67
BoxSizer1->Add(m_Libraries, 1, wxTOP|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
68
StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("Previous settings"));
69
m_DontClear = new wxRadioButton(this, ID_RADIOBUTTON1, _("Do not clear previous results (but remove duplicates)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP, wxDefaultValidator, _T("ID_RADIOBUTTON1"));
70
StaticBoxSizer1->Add(m_DontClear, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
71
m_ClearSelected = new wxRadioButton(this, ID_RADIOBUTTON2, _("Clear previous results for selected libraries"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON2"));
72
m_ClearSelected->SetValue(true);
73
StaticBoxSizer1->Add(m_ClearSelected, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
74
m_ClearAll = new wxRadioButton(this, ID_RADIOBUTTON3, _("Clear all previous libraries settings"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON3"));
75
StaticBoxSizer1->Add(m_ClearAll, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
76
BoxSizer1->Add(StaticBoxSizer1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
77
m_SetupGlobalVars = new wxCheckBox(this, ID_CHECKBOX1, _("Set up Global Variables"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
78
m_SetupGlobalVars->SetValue(true);
79
BoxSizer1->Add(m_SetupGlobalVars, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
80
StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
81
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_OK, wxEmptyString));
82
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_CANCEL, wxEmptyString));
83
StdDialogButtonSizer1->Realize();
84
BoxSizer1->Add(StdDialogButtonSizer1, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
87
BoxSizer1->SetSizeHints(this);
91
m_Libraries->Append(Names);
93
ConfigManager* Cfg = Manager::Get()->GetConfigManager(_T("lib_finder"));
94
switch ( Cfg->ReadInt(_T("libselect/previous"),1) )
96
case 0: m_DontClear->SetValue(true); break;
97
case 2: m_ClearAll->SetValue(true); break;
99
default: m_ClearSelected->SetValue(true); break;
101
m_SetupGlobalVars->SetValue(Cfg->ReadBool(_T("libselect/setup_global_vars"),true));
104
LibSelectDlg::~LibSelectDlg()
106
//(*Destroy(LibSelectDlg)
110
void LibSelectDlg::SetSelections(const wxArrayInt& Selections)
112
m_Libraries->Freeze();
115
for ( size_t i=0; i<m_Libraries->GetCount(); i++ )
117
m_Libraries->Check(i,false);
120
// Next select only those which are on the list
121
for ( size_t i=0; i<Selections.Count(); i++ )
123
m_Libraries->Check(Selections[i],true);
129
wxArrayInt LibSelectDlg::GetSelections()
132
for ( size_t i=0; i<m_Libraries->GetCount(); i++ )
134
if ( m_Libraries->IsChecked(i) )
142
bool LibSelectDlg::GetSetupGlobalVars()
144
return m_SetupGlobalVars->GetValue();
147
bool LibSelectDlg::GetDontClearPrevious()
149
return m_DontClear->GetValue();
152
bool LibSelectDlg::GetClearSelectedPrevious()
154
return m_ClearSelected->GetValue();
157
bool LibSelectDlg::GetClearAllPrevious()
159
return m_ClearAll->GetValue();
162
void LibSelectDlg::OnOk(wxCommandEvent& event)
164
ConfigManager* Cfg = Manager::Get()->GetConfigManager(_T("lib_finder"));
165
if ( m_DontClear->GetValue() ) Cfg->Write(_T("libselect/previous"),0);
166
if ( m_ClearSelected->GetValue() ) Cfg->Write(_T("libselect/previous"),1);
167
if ( m_ClearAll->GetValue() ) Cfg->Write(_T("libselect/previous"),2);
168
Cfg->Write(_T("libselect/setup_global_vars"),m_SetupGlobalVars->GetValue());