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 "projectconfigurationpanel.h"
26
//(*InternalHeaders(ProjectConfigurationPanel)
27
#include <wx/treectrl.h>
29
#include <wx/stattext.h>
30
#include <wx/textctrl.h>
31
#include <wx/checkbox.h>
32
#include <wx/listbox.h>
34
#include <wx/button.h>
35
#include <wx/string.h>
38
#include <wx/tokenzr.h>
40
#include "lib_finder.h"
42
//(*IdInit(ProjectConfigurationPanel)
43
const long ProjectConfigurationPanel::ID_LISTBOX1 = wxNewId();
44
const long ProjectConfigurationPanel::ID_CHECKBOX2 = wxNewId();
45
const long ProjectConfigurationPanel::ID_BUTTON4 = wxNewId();
46
const long ProjectConfigurationPanel::ID_BUTTON1 = wxNewId();
47
const long ProjectConfigurationPanel::ID_BUTTON2 = wxNewId();
48
const long ProjectConfigurationPanel::ID_TREECTRL1 = wxNewId();
49
const long ProjectConfigurationPanel::ID_STATICTEXT1 = wxNewId();
50
const long ProjectConfigurationPanel::ID_TEXTCTRL2 = wxNewId();
51
const long ProjectConfigurationPanel::ID_CHECKBOX1 = wxNewId();
52
const long ProjectConfigurationPanel::ID_TEXTCTRL1 = wxNewId();
53
const long ProjectConfigurationPanel::ID_BUTTON3 = wxNewId();
54
const long ProjectConfigurationPanel::ID_STATICTEXT2 = wxNewId();
55
const long ProjectConfigurationPanel::ID_TIMER1 = wxNewId();
58
BEGIN_EVENT_TABLE(ProjectConfigurationPanel,cbConfigurationPanel)
59
//(*EventTable(ProjectConfigurationPanel)
65
class TreeItemData: public wxTreeItemData
67
// Warning: since we use reference to string instead of string itself,
68
// the base string must exist as long as this item data exists
70
TreeItemData(const wxString& ShortCode): m_ShortCode(ShortCode) {}
73
const wxString& m_ShortCode;
76
class ListItemData: public wxClientData
78
// We don't use string's reference here since project's libraries set
79
// should be much smaller than list of known libraries
81
ListItemData(const wxString& ShortCode): m_ShortCode(ShortCode) {}
84
const wxString m_ShortCode;
88
ProjectConfigurationPanel::ProjectConfigurationPanel(wxWindow* parent,ProjectConfiguration* Configuration,cbProject* Project,TypedResults& KnownLibs):
89
m_Configuration(Configuration),
91
m_KnownLibs(KnownLibs)
93
//(*Initialize(ProjectConfigurationPanel)
94
wxBoxSizer* BoxSizer4;
95
wxStaticBoxSizer* StaticBoxSizer2;
96
wxBoxSizer* BoxSizer6;
97
wxBoxSizer* BoxSizer5;
98
wxBoxSizer* BoxSizer2;
99
wxStaticBoxSizer* StaticBoxSizer3;
100
wxBoxSizer* BoxSizer1;
101
wxStaticBoxSizer* StaticBoxSizer1;
102
wxBoxSizer* BoxSizer3;
103
wxStaticBoxSizer* m_DisableAuto;
105
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
106
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
107
BoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
108
BoxSizer5 = new wxBoxSizer(wxVERTICAL);
109
StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("Libraries used in project"));
110
m_UsedLibraries = new wxListBox(this, ID_LISTBOX1, wxDefaultPosition, wxSize(147,123), 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX1"));
111
StaticBoxSizer1->Add(m_UsedLibraries, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
112
BoxSizer5->Add(StaticBoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
113
m_DisableAuto = new wxStaticBoxSizer(wxVERTICAL, this, _("Extra settings"));
114
m_NoAuto = new wxCheckBox(this, ID_CHECKBOX2, _("Don\'t setup automatically"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
115
m_NoAuto->SetValue(false);
116
m_NoAuto->SetToolTip(_("If you check this option, lib_finder won\'t add settings of libraries automatically.\nNote that automatic setup is available only after applying extra patch to code::blocks available at forums."));
117
m_DisableAuto->Add(m_NoAuto, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
118
m_AddScript = new wxButton(this, ID_BUTTON4, _("Add manual build script"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON4"));
119
m_AddScript->SetToolTip(_("When you use this option, extra script will be added to the project.\nThis script does invoke lib_finder and will add settings of libraries\njust as in case of automatic setup.\nIt may be usefull when no extra-event patch has been applied."));
120
m_DisableAuto->Add(m_AddScript, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
121
BoxSizer5->Add(m_DisableAuto, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
122
BoxSizer6->Add(BoxSizer5, 3, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
123
BoxSizer2 = new wxBoxSizer(wxVERTICAL);
124
m_Add = new wxButton(this, ID_BUTTON1, _("<"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON1"));
126
m_Add->SetToolTip(_("Add selected library to project"));
127
BoxSizer2->Add(m_Add, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
128
m_Remove = new wxButton(this, ID_BUTTON2, _(">"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON2"));
130
m_Remove->SetToolTip(_("Remove selected library from project"));
131
BoxSizer2->Add(m_Remove, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
132
BoxSizer6->Add(BoxSizer2, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
133
BoxSizer3 = new wxBoxSizer(wxVERTICAL);
134
StaticBoxSizer2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Known libraries"));
135
m_KnownLibrariesTree = new wxTreeCtrl(this, ID_TREECTRL1, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT|wxTR_SINGLE|wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER, wxDefaultValidator, _T("ID_TREECTRL1"));
136
StaticBoxSizer2->Add(m_KnownLibrariesTree, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
137
BoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
138
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Filter:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
139
BoxSizer4->Add(StaticText1, 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
140
m_Filter = new wxTextCtrl(this, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
141
BoxSizer4->Add(m_Filter, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
142
StaticBoxSizer2->Add(BoxSizer4, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
143
m_Tree = new wxCheckBox(this, ID_CHECKBOX1, _("Show as tree"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
144
m_Tree->SetValue(true);
145
StaticBoxSizer2->Add(m_Tree, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
146
BoxSizer3->Add(StaticBoxSizer2, 1, wxBOTTOM|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
147
StaticBoxSizer3 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Unknown library"));
148
m_UnknownLibrary = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
149
StaticBoxSizer3->Add(m_UnknownLibrary, 1, wxTOP|wxBOTTOM|wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
150
m_AddUnknown = new wxButton(this, ID_BUTTON3, _("Add"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON3"));
151
m_AddUnknown->Disable();
152
StaticBoxSizer3->Add(m_AddUnknown, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
153
BoxSizer3->Add(StaticBoxSizer3, 0, wxTOP|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
154
BoxSizer6->Add(BoxSizer3, 4, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
155
BoxSizer1->Add(BoxSizer6, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
156
m_EventText = new wxStaticText(this, ID_STATICTEXT2, _("Note: Because there\'s not yet ability to update project\'s build options\nfrom plugin, the only way to automatically add library configurations\nis to use build script"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE, _T("ID_STATICTEXT2"));
158
BoxSizer1->Add(m_EventText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
160
Timer1.SetOwner(this, ID_TIMER1);
161
BoxSizer1->Fit(this);
162
BoxSizer1->SetSizeHints(this);
164
Connect(ID_LISTBOX1,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_UsedLibrariesSelect);
165
Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_AddScriptClick);
166
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_AddClick);
167
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_RemoveClick);
168
Connect(ID_TREECTRL1,wxEVT_COMMAND_TREE_SEL_CHANGED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_KnownLibrariesTreeSelectionChanged);
169
Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_FilterText);
170
Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_ENTER,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_FilterTextEnter);
171
Connect(ID_CHECKBOX1,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_TreeClick);
172
Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_UnknownLibraryText);
173
Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_AddUnknownClick);
174
Connect(ID_TIMER1,wxEVT_TIMER,(wxObjectEventFunction)&ProjectConfigurationPanel::OnTimer1Trigger);
177
m_EventText->Show(!lib_finder::IsExtraEvent());
179
if ( m_Project->GetBuildScripts().Index(_T("lib_finder.script")) != wxNOT_FOUND )
181
// There's a build script yet
182
m_AddScript->Disable();
185
m_ConfCopy = *m_Configuration;
186
FillKnownLibraries();
190
ProjectConfigurationPanel::~ProjectConfigurationPanel()
192
//(*Destroy(ProjectConfigurationPanel)
196
wxString ProjectConfigurationPanel::GetTitle() const
198
return _T("Libraries");
201
wxString ProjectConfigurationPanel::GetBitmapBaseName() const
206
void ProjectConfigurationPanel::OnApply()
209
*m_Configuration = m_ConfCopy;
212
void ProjectConfigurationPanel::OnCancel()
216
void ProjectConfigurationPanel::LoadData()
218
m_UsedLibraries->Freeze();
219
for ( size_t i=0; i<m_ConfCopy.m_GlobalUsedLibs.Count(); i++ )
221
wxString Name = m_ConfCopy.m_GlobalUsedLibs[i];
222
m_UsedLibraries->Append(GetUserListName(Name),new ListItemData(Name));
224
m_UsedLibraries->Thaw();
225
m_NoAuto->SetValue(m_ConfCopy.m_DisableAuto);
228
wxString ProjectConfigurationPanel::GetUserListName(const wxString& Name)
230
for ( int i=0; i<rtCount; i++ )
232
if ( m_KnownLibs[i].IsShortCode(Name) )
237
return Name + _T(" (pkg-config)");
240
return Name + _T(": ") + m_KnownLibs[i].GetShortCode(Name)[0]->LibraryName;
245
return Name + _T(" (Unknown library)");
248
void ProjectConfigurationPanel::StoreData()
250
m_ConfCopy.m_DisableAuto = m_NoAuto->GetValue();
253
void ProjectConfigurationPanel::FillKnownLibraries()
256
m_KnownLibrariesTree->Freeze();
257
m_KnownLibrariesTree->DeleteAllItems();
258
m_KnownLibrariesTree->AddRoot(_("Known libraries"));
260
m_CategoryMap.clear();
261
m_IsOtherCategory = false;
262
m_IsPkgConfig = false;
264
wxString Filter = m_Filter->GetValue().Upper();
265
bool Tree = m_Tree->GetValue();
267
// Collecting list of all global variable names,
268
// currently without pkg-config entries (will be used later)
270
for ( int i=0; i<rtCount; i++ )
272
if ( i==rtPkgConfig ) continue;
273
m_KnownLibs[i].GetShortCodes(Vars);
276
for ( size_t i=0; i<Vars.Count(); i++ )
278
ResultArray* Array = 0;
279
for ( int j=0; j<rtCount; j++ )
281
if ( j!=rtPkgConfig )
283
if ( m_KnownLibs[j].IsShortCode(Vars[i]) )
285
Array = &m_KnownLibs[j].GetShortCode(Vars[i]);
290
if ( !Array || Array->IsEmpty() ) continue;
292
if ( !Filter.IsEmpty() )
294
if ( (*Array)[0]->LibraryName.Upper().Find(Filter) == wxNOT_FOUND &&
295
(*Array)[0]->ShortCode.Upper().Find(Filter) == wxNOT_FOUND )
297
// This result has been filtered
304
wxArrayString& Categories = (*Array)[0]->Categories;
305
if ( Categories.IsEmpty() )
307
BuildEntry(OtherCategoryId(),*Array);
311
for ( size_t i=0; i<Categories.Count(); i++ )
313
BuildEntry(CategoryId(Categories[i]),*Array);
319
BuildEntry(m_KnownLibrariesTree->GetRootItem(),*Array);
323
// Now add pkg-config entries in separate category at the end
325
m_KnownLibs[rtPkgConfig].GetShortCodes(Vars);
327
if ( !Vars.IsEmpty() )
329
for ( size_t i=0; i<Vars.Count(); i++ )
331
ResultArray& Array = m_KnownLibs[rtPkgConfig].GetShortCode(Vars[i]);
332
if ( Array.IsEmpty() ) continue;
334
if ( !Filter.IsEmpty() )
336
if ( Array[0]->LibraryName.Upper().Find(Filter) == wxNOT_FOUND &&
337
Array[0]->ShortCode.Upper().Find(Filter) == wxNOT_FOUND )
339
// This result has been filtered
344
BuildEntry(Tree ? PkgConfigId() : m_KnownLibrariesTree->GetRootItem(),Array);
348
// Ok, let's present all results
349
m_KnownLibrariesTree->ExpandAll();
350
m_KnownLibrariesTree->Thaw();
353
void ProjectConfigurationPanel::BuildEntry(const wxTreeItemId& Id,ResultArray& Array)
355
wxString Name = Array[0]->ShortCode;
356
if ( !Array[0]->LibraryName.IsEmpty() )
358
Name = Name + _T(": ") + Array[0]->LibraryName;
360
m_KnownLibrariesTree->AppendItem(Id,Name,0,0,new TreeItemData(Array[0]->ShortCode));
363
wxTreeItemId ProjectConfigurationPanel::OtherCategoryId()
365
if ( m_IsOtherCategory )
367
return m_CategoryMap[_T(".other")];
370
m_IsOtherCategory = true;
371
return m_CategoryMap[_T(".other")] = m_KnownLibrariesTree->AppendItem(m_KnownLibrariesTree->GetRootItem(),_("Other"));
374
wxTreeItemId ProjectConfigurationPanel::PkgConfigId()
378
return m_CategoryMap[_T(".pkg-config")];
380
m_IsPkgConfig = true;
381
return m_CategoryMap[_T(".pkg-config")] = m_KnownLibrariesTree->AppendItem(m_KnownLibrariesTree->GetRootItem(),_("Available in pkg-config"));
384
wxTreeItemId ProjectConfigurationPanel::CategoryId(const wxString& Category)
386
if ( m_CategoryMap.find(Category.Lower()) != m_CategoryMap.end() )
388
return m_CategoryMap[Category.Lower()];
391
wxStringTokenizer Tokens(Category,_T("."),wxTOKEN_STRTOK);
392
wxString PathSoFar = _T("");
393
wxTreeItemId IdSoFar = m_KnownLibrariesTree->GetRootItem();
394
bool FirstElem = true;
395
while ( Tokens.HasMoreTokens() )
397
// Iterate through items already added to map
398
wxString Part = Tokens.GetNextToken();
399
PathSoFar += Part.Lower();
400
if ( m_CategoryMap.find(PathSoFar) == m_CategoryMap.end() )
402
// Ok, found first node which is not yet added, this mean
403
// that all subnodes are also not yet added
404
int SkipLast = FirstElem ? (m_IsOtherCategory?1:0) + (m_IsPkgConfig?1:0) : 0;
406
// First elem of the path must take into consideration
407
// that some categoies must remain at the end
410
IdSoFar = m_CategoryMap[PathSoFar] =
411
m_KnownLibrariesTree->InsertItem(
413
m_KnownLibrariesTree->GetChildrenCount(IdSoFar,false)-SkipLast,
419
IdSoFar = m_CategoryMap[PathSoFar] =
420
m_KnownLibrariesTree->AppendItem(IdSoFar,Part);
423
// Next items are always added at the end
424
while ( Tokens.HasMoreTokens() )
426
Part = Tokens.GetNextToken();
427
PathSoFar += _T(".");
428
PathSoFar = Part.Lower();
429
IdSoFar = m_CategoryMap[PathSoFar] =
430
m_KnownLibrariesTree->AppendItem(IdSoFar,Part);
433
// If we're here, all remaining path has been added, so we
438
PathSoFar += _T(".");
440
// Just for sure if there are multiple dots
441
m_CategoryMap[Category.Lower()] = IdSoFar;
445
void ProjectConfigurationPanel::Onm_TreeClick(wxCommandEvent& event)
447
FillKnownLibraries();
450
void ProjectConfigurationPanel::OnTimer1Trigger(wxTimerEvent& event)
452
FillKnownLibraries();
455
void ProjectConfigurationPanel::Onm_FilterText(wxCommandEvent& event)
457
Timer1.Start(500,true);
460
void ProjectConfigurationPanel::Onm_FilterTextEnter(wxCommandEvent& event)
462
FillKnownLibraries();
465
void ProjectConfigurationPanel::Onm_KnownLibrariesTreeSelectionChanged(wxTreeEvent& event)
467
if ( m_KnownLibrariesTree->GetSelection().IsOk() )
469
TreeItemData* Data = (TreeItemData*)m_KnownLibrariesTree->GetItemData(m_KnownLibrariesTree->GetSelection());
472
wxString Library = Data->m_ShortCode;
473
if ( m_ConfCopy.m_GlobalUsedLibs.Index(Library) == wxNOT_FOUND )
483
void ProjectConfigurationPanel::Onm_UsedLibrariesSelect(wxCommandEvent& event)
485
m_Remove->Enable( m_UsedLibraries->GetSelection() != wxNOT_FOUND );
488
void ProjectConfigurationPanel::Onm_RemoveClick(wxCommandEvent& event)
490
if ( m_UsedLibraries->GetSelection() != wxNOT_FOUND )
493
((ListItemData*)m_UsedLibraries->GetClientObject(
494
m_UsedLibraries->GetSelection()))->m_ShortCode;
495
m_ConfCopy.m_GlobalUsedLibs.Remove(Library);
496
m_UsedLibraries->Delete(m_UsedLibraries->GetSelection());
499
Onm_KnownLibrariesTreeSelectionChanged(ev);
503
void ProjectConfigurationPanel::Onm_AddClick(wxCommandEvent& event)
505
if ( m_KnownLibrariesTree->GetSelection().IsOk() )
507
TreeItemData* Data = (TreeItemData*)m_KnownLibrariesTree->GetItemData(m_KnownLibrariesTree->GetSelection());
510
wxString Library = Data->m_ShortCode;
511
if ( m_ConfCopy.m_GlobalUsedLibs.Index(Library) == wxNOT_FOUND )
513
m_ConfCopy.m_GlobalUsedLibs.Add(Library);
514
m_UsedLibraries->Append(GetUserListName(Library),new ListItemData(Library));
522
void ProjectConfigurationPanel::Onm_UnknownLibraryText(wxCommandEvent& event)
524
m_AddUnknown->Enable(m_UnknownLibrary->GetLastPosition()!=0);
527
void ProjectConfigurationPanel::Onm_AddUnknownClick(wxCommandEvent& event)
529
wxString Library = m_UnknownLibrary->GetValue();
530
if ( !Library.IsEmpty() )
532
if ( m_ConfCopy.m_GlobalUsedLibs.Index(Library) == wxNOT_FOUND )
534
m_ConfCopy.m_GlobalUsedLibs.Add(Library);
535
m_UsedLibraries->Append(GetUserListName(Library),new ListItemData(Library));
537
Onm_KnownLibrariesTreeSelectionChanged(ev);
542
void ProjectConfigurationPanel::Onm_AddScriptClick(wxCommandEvent& event)
544
wxFile Fl(m_Project->GetBasePath() + wxFileName::GetPathSeparator() + _T("lib_finder.script"),wxFile::write);
545
if ( !Fl.IsOpened() )
547
wxMessageBox(_("Couldn't create file \"lib_finder.script\" in project's base path"),_("lib_finder.script error"),wxOK|wxICON_ERROR,this);
552
_T("function SetBuildOptions(base)\n")
554
_T("\tif ( \"LibFinder\" in getroottable() )\n")
556
_T("\t\tLibFinder.SetupTarget(base);\n")
561
wxMessageBox(_("Couldn't write script file \"lib_finder.script\"."),_("lib_finder.script error"),wxOK|wxICON_ERROR,this);
566
m_Project->AddBuildScript(_T("lib_finder.script"));
567
m_AddScript->Disable();
568
m_NoAuto->SetValue(true);
570
wxMessageBox(_("Script \"lib_finder.script\" successfully added."),_("lib_finder.script Success"),wxOK|wxICON_INFORMATION,this);