1 #include "librariesdlg.h"
2 
3 //(*InternalHeaders(LibrariesDlg)
4 #include <wx/checkbox.h>
5 #include <wx/sizer.h>
6 #include <wx/button.h>
7 #include <wx/panel.h>
8 #include <wx/string.h>
9 #include <wx/intl.h>
10 #include <wx/wxFlatNotebook/renderer.h>
11 #include <wx/stattext.h>
12 #include <wx/textctrl.h>
13 #include <wx/wxFlatNotebook/wxFlatNotebook.h>
14 #include <wx/listbox.h>
15 //*)
16 
17 #include <algorithm>
18 #include <sdk.h>
19 #include <manager.h>
20 #include <configmanager.h>
21 #include <globals.h>
22 #include <wx/tokenzr.h>
23 
24 #include "dirlistdlg.h"
25 #include "processingdlg.h"
26 #include "librarydetectionmanager.h"
27 #include "libselectdlg.h"
28 #include "defsdownloaddlg.h"
29 
30 //(*IdInit(LibrariesDlg)
31 const long LibrariesDlg::ID_LISTBOX1 = wxNewId();
32 const long LibrariesDlg::ID_CHECKBOX1 = wxNewId();
33 const long LibrariesDlg::ID_CHECKBOX2 = wxNewId();
34 const long LibrariesDlg::ID_BUTTON1 = wxNewId();
35 const long LibrariesDlg::ID_BUTTON2 = wxNewId();
36 const long LibrariesDlg::ID_BUTTON11 = wxNewId();
37 const long LibrariesDlg::ID_BUTTON8 = wxNewId();
38 const long LibrariesDlg::ID_LISTBOX2 = wxNewId();
39 const long LibrariesDlg::ID_BUTTON9 = wxNewId();
40 const long LibrariesDlg::ID_BUTTON10 = wxNewId();
41 const long LibrariesDlg::ID_BUTTON3 = wxNewId();
42 const long LibrariesDlg::ID_BUTTON4 = wxNewId();
43 const long LibrariesDlg::ID_STATICTEXT10 = wxNewId();
44 const long LibrariesDlg::ID_STATICTEXT1 = wxNewId();
45 const long LibrariesDlg::ID_STATICTEXT9 = wxNewId();
46 const long LibrariesDlg::ID_STATICTEXT2 = wxNewId();
47 const long LibrariesDlg::ID_TEXTCTRL1 = wxNewId();
48 const long LibrariesDlg::ID_STATICTEXT5 = wxNewId();
49 const long LibrariesDlg::ID_TEXTCTRL4 = wxNewId();
50 const long LibrariesDlg::ID_STATICTEXT4 = wxNewId();
51 const long LibrariesDlg::ID_TEXTCTRL3 = wxNewId();
52 const long LibrariesDlg::ID_STATICTEXT3 = wxNewId();
53 const long LibrariesDlg::ID_TEXTCTRL2 = wxNewId();
54 const long LibrariesDlg::ID_PANEL1 = wxNewId();
55 const long LibrariesDlg::ID_TEXTCTRL13 = wxNewId();
56 const long LibrariesDlg::ID_PANEL8 = wxNewId();
57 const long LibrariesDlg::ID_TEXTCTRL5 = wxNewId();
58 const long LibrariesDlg::ID_PANEL6 = wxNewId();
59 const long LibrariesDlg::ID_TEXTCTRL8 = wxNewId();
60 const long LibrariesDlg::ID_PANEL3 = wxNewId();
61 const long LibrariesDlg::ID_TEXTCTRL12 = wxNewId();
62 const long LibrariesDlg::ID_PANEL5 = wxNewId();
63 const long LibrariesDlg::ID_STATICTEXT6 = wxNewId();
64 const long LibrariesDlg::ID_TEXTCTRL9 = wxNewId();
65 const long LibrariesDlg::ID_BUTTON5 = wxNewId();
66 const long LibrariesDlg::ID_STATICTEXT7 = wxNewId();
67 const long LibrariesDlg::ID_TEXTCTRL10 = wxNewId();
68 const long LibrariesDlg::ID_BUTTON6 = wxNewId();
69 const long LibrariesDlg::ID_STATICTEXT8 = wxNewId();
70 const long LibrariesDlg::ID_TEXTCTRL11 = wxNewId();
71 const long LibrariesDlg::ID_BUTTON7 = wxNewId();
72 const long LibrariesDlg::ID_PANEL4 = wxNewId();
73 const long LibrariesDlg::ID_TEXTCTRL6 = wxNewId();
74 const long LibrariesDlg::ID_PANEL7 = wxNewId();
75 const long LibrariesDlg::ID_TEXTCTRL7 = wxNewId();
76 const long LibrariesDlg::ID_PANEL2 = wxNewId();
77 const long LibrariesDlg::ID_STATICTEXT11 = wxNewId();
78 const long LibrariesDlg::ID_TEXTCTRL14 = wxNewId();
79 const long LibrariesDlg::ID_PANEL9 = wxNewId();
80 const long LibrariesDlg::ID_STATICTEXT12 = wxNewId();
81 const long LibrariesDlg::ID_TEXTCTRL15 = wxNewId();
82 const long LibrariesDlg::ID_PANEL10 = wxNewId();
83 const long LibrariesDlg::ID_FLATNOTEBOOK1 = wxNewId();
84 //*)
85 
BEGIN_EVENT_TABLE(LibrariesDlg,wxScrollingDialog)86 BEGIN_EVENT_TABLE(LibrariesDlg,wxScrollingDialog)
87     //(*EventTable(LibrariesDlg)
88     //*)
89     EVT_BUTTON(wxID_OK,LibrariesDlg::OnWrite)
90 END_EVENT_TABLE()
91 
92 LibrariesDlg::LibrariesDlg(wxWindow* parent, TypedResults& knownLibraries)
93     : m_KnownLibraries(knownLibraries)
94     , m_SelectedConfig(0)
95     , m_WhileUpdating(false)
96 {
97     //(*Initialize(LibrariesDlg)
98     wxBoxSizer* BoxSizer15;
99     wxStaticBoxSizer* StaticBoxSizer2;
100     wxFlexGridSizer* FlexGridSizer1;
101     wxFlexGridSizer* FlexGridSizer2;
102     wxBoxSizer* BoxSizer3;
103     wxBoxSizer* BoxSizer16;
104     wxBoxSizer* BoxSizer10;
105     wxBoxSizer* BoxSizer7;
106     wxBoxSizer* BoxSizer11;
107     wxBoxSizer* BoxSizer13;
108     wxBoxSizer* BoxSizer2;
109     wxStaticBoxSizer* StaticBoxSizer3;
110     wxBoxSizer* BoxSizer17;
111     wxBoxSizer* BoxSizer9;
112     wxBoxSizer* BoxSizer18;
113     wxFlexGridSizer* FlexGridSizer3;
114     wxBoxSizer* BoxSizer19;
115     wxBoxSizer* BoxSizer4;
116     wxStaticBoxSizer* StaticBoxSizer4;
117     wxBoxSizer* BoxSizer8;
118     wxBoxSizer* BoxSizer20;
119     wxBoxSizer* BoxSizer1;
120     wxBoxSizer* BoxSizer12;
121     wxBoxSizer* BoxSizer14;
122     wxBoxSizer* BoxSizer6;
123     wxStdDialogButtonSizer* StdDialogButtonSizer1;
124     wxBoxSizer* BoxSizer5;
125     wxStaticBoxSizer* StaticBoxSizer1;
126 
127     Create(parent, wxID_ANY, _("Registered libraries"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, _T("wxID_ANY"));
128     BoxSizer1 = new wxBoxSizer(wxVERTICAL);
129     BoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
130     BoxSizer14 = new wxBoxSizer(wxVERTICAL);
131     StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("Registered libraries"));
132     m_Libraries = new wxListBox(this, ID_LISTBOX1, wxDefaultPosition, wxSize(180,250), 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX1"));
133     StaticBoxSizer1->Add(m_Libraries, 1, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 5);
134     m_ShowPredefined = new wxCheckBox(this, ID_CHECKBOX1, _("Show Predefined libraries"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
135     m_ShowPredefined->SetValue(true);
136     StaticBoxSizer1->Add(m_ShowPredefined, 0, wxEXPAND, 5);
137     m_ShowPkgConfig = new wxCheckBox(this, ID_CHECKBOX2, _("Show Pkg-Config entries"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
138     m_ShowPkgConfig->SetValue(false);
139     StaticBoxSizer1->Add(m_ShowPkgConfig, 0, wxBOTTOM|wxEXPAND, 5);
140     BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
141     Button1 = new wxButton(this, ID_BUTTON1, _("Add"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
142     BoxSizer2->Add(Button1, 1, wxEXPAND, 5);
143     Button2 = new wxButton(this, ID_BUTTON2, _("Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
144     BoxSizer2->Add(Button2, 1, wxLEFT|wxEXPAND, 5);
145     StaticBoxSizer1->Add(BoxSizer2, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
146     Button3 = new wxButton(this, ID_BUTTON11, _("Download definitions"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON11"));
147     StaticBoxSizer1->Add(Button3, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
148     BoxSizer14->Add(StaticBoxSizer1, 1, wxALL|wxEXPAND, 5);
149     StaticBoxSizer4 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Autodetection of libraries"));
150     Button8 = new wxButton(this, ID_BUTTON8, _("Scan"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON8"));
151     StaticBoxSizer4->Add(Button8, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5);
152     BoxSizer14->Add(StaticBoxSizer4, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
153     BoxSizer16->Add(BoxSizer14, 1, wxEXPAND, 5);
154     BoxSizer3 = new wxBoxSizer(wxVERTICAL);
155     StaticBoxSizer2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Available configurations"));
156     BoxSizer18 = new wxBoxSizer(wxHORIZONTAL);
157     m_Configurations = new wxListBox(this, ID_LISTBOX2, wxDefaultPosition, wxSize(201,44), 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX2"));
158     BoxSizer18->Add(m_Configurations, 1, wxTOP|wxBOTTOM|wxLEFT|wxEXPAND, 5);
159     BoxSizer17 = new wxBoxSizer(wxVERTICAL);
160     m_ConfigUp = new wxButton(this, ID_BUTTON9, _("^"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON9"));
161     BoxSizer17->Add(m_ConfigUp, 1, wxTOP|wxEXPAND, 5);
162     m_ConfigDown = new wxButton(this, ID_BUTTON10, _("v"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON10"));
163     BoxSizer17->Add(m_ConfigDown, 1, wxBOTTOM|wxEXPAND, 5);
164     BoxSizer18->Add(BoxSizer17, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5);
165     BoxSizer4 = new wxBoxSizer(wxVERTICAL);
166     m_ConfDuplicate = new wxButton(this, ID_BUTTON3, _("Duplicate"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
167     BoxSizer4->Add(m_ConfDuplicate, 1, wxTOP|wxALIGN_CENTER_HORIZONTAL, 5);
168     m_ConfDelete = new wxButton(this, ID_BUTTON4, _("Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON4"));
169     BoxSizer4->Add(m_ConfDelete, 1, wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5);
170     BoxSizer18->Add(BoxSizer4, 0, wxALIGN_CENTER_VERTICAL, 5);
171     StaticBoxSizer2->Add(BoxSizer18, 1, wxEXPAND, 5);
172     StaticText9 = new wxStaticText(this, ID_STATICTEXT10, _("Note: Order on this list set priorities of configurations."), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE, _T("ID_STATICTEXT10"));
173     StaticBoxSizer2->Add(StaticText9, 0, wxEXPAND, 5);
174     BoxSizer3->Add(StaticBoxSizer2, 1, wxEXPAND, 5);
175     StaticBoxSizer3 = new wxStaticBoxSizer(wxVERTICAL, this, _("Configuration options"));
176     FlexGridSizer1 = new wxFlexGridSizer(0, 2, 5, 5);
177     FlexGridSizer1->AddGrowableCol(1);
178     StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Type:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
179     FlexGridSizer1->Add(StaticText1, 1, wxALIGN_CENTER_VERTICAL, 5);
180     m_Type = new wxStaticText(this, ID_STATICTEXT9, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT9"));
181     FlexGridSizer1->Add(m_Type, 1, wxEXPAND, 5);
182     StaticBoxSizer3->Add(FlexGridSizer1, 0, wxALL|wxEXPAND, 5);
183     FlatNotebook1 = new wxFlatNotebook(this, ID_FLATNOTEBOOK1, wxDefaultPosition, wxDefaultSize, wxFNB_DEFAULT_STYLE|wxFNB_NO_X_BUTTON|wxFNB_NODRAG|wxFNB_FF2|wxCLIP_CHILDREN);
184     Panel1 = new wxPanel(FlatNotebook1, ID_PANEL1, wxPoint(53,10), wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL, _T("ID_PANEL1"));
185     FlexGridSizer2 = new wxFlexGridSizer(0, 2, 5, 0);
186     FlexGridSizer2->AddGrowableCol(0);
187     FlexGridSizer2->AddGrowableRow(0);
188     FlexGridSizer3 = new wxFlexGridSizer(0, 2, 5, 5);
189     FlexGridSizer3->AddGrowableCol(1);
190     StaticText2 = new wxStaticText(Panel1, ID_STATICTEXT2, _("Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
191     FlexGridSizer3->Add(StaticText2, 1, wxALIGN_CENTER_VERTICAL, 5);
192     m_Name = new wxTextCtrl(Panel1, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
193     m_Name->SetToolTip(_("Full name of the library"));
194     FlexGridSizer3->Add(m_Name, 1, wxEXPAND, 5);
195     StaticText5 = new wxStaticText(Panel1, ID_STATICTEXT5, _("Base path:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5"));
196     FlexGridSizer3->Add(StaticText5, 1, wxALIGN_CENTER_VERTICAL, 5);
197     m_BasePath = new wxTextCtrl(Panel1, ID_TEXTCTRL4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL4"));
198     FlexGridSizer3->Add(m_BasePath, 1, wxEXPAND, 5);
199     StaticText4 = new wxStaticText(Panel1, ID_STATICTEXT4, _("Pkg-Config name:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
200     FlexGridSizer3->Add(StaticText4, 1, wxALIGN_CENTER_VERTICAL, 5);
201     m_PkgConfigName = new wxTextCtrl(Panel1, ID_TEXTCTRL3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL3"));
202     FlexGridSizer3->Add(m_PkgConfigName, 1, wxEXPAND, 5);
203     StaticText3 = new wxStaticText(Panel1, ID_STATICTEXT3, _("Description:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
204     FlexGridSizer3->Add(StaticText3, 1, wxALIGN_CENTER_VERTICAL, 5);
205     m_Description = new wxTextCtrl(Panel1, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(103,116), wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL2"));
206     FlexGridSizer3->Add(m_Description, 1, wxEXPAND, 5);
207     FlexGridSizer2->Add(FlexGridSizer3, 1, wxALL|wxEXPAND, 5);
208     Panel1->SetSizer(FlexGridSizer2);
209     FlexGridSizer2->Fit(Panel1);
210     FlexGridSizer2->SetSizeHints(Panel1);
211     Panel8 = new wxPanel(FlatNotebook1, ID_PANEL8, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL8"));
212     BoxSizer15 = new wxBoxSizer(wxHORIZONTAL);
213     m_Categories = new wxTextCtrl(Panel8, ID_TEXTCTRL13, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL13"));
214     BoxSizer15->Add(m_Categories, 1, wxALL|wxEXPAND, 5);
215     Panel8->SetSizer(BoxSizer15);
216     BoxSizer15->Fit(Panel8);
217     BoxSizer15->SetSizeHints(Panel8);
218     Panel2 = new wxPanel(FlatNotebook1, ID_PANEL6, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL6"));
219     BoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
220     m_Compilers = new wxTextCtrl(Panel2, ID_TEXTCTRL5, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL5"));
221     BoxSizer5->Add(m_Compilers, 1, wxALL|wxEXPAND, 5);
222     Panel2->SetSizer(BoxSizer5);
223     BoxSizer5->Fit(Panel2);
224     BoxSizer5->SetSizeHints(Panel2);
225     Panel4 = new wxPanel(FlatNotebook1, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
226     BoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
227     m_Defines = new wxTextCtrl(Panel4, ID_TEXTCTRL8, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL8"));
228     BoxSizer8->Add(m_Defines, 1, wxALL|wxEXPAND, 5);
229     Panel4->SetSizer(BoxSizer8);
230     BoxSizer8->Fit(Panel4);
231     BoxSizer8->SetSizeHints(Panel4);
232     Panel6 = new wxPanel(FlatNotebook1, ID_PANEL5, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL5"));
233     BoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
234     m_Libs = new wxTextCtrl(Panel6, ID_TEXTCTRL12, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL12"));
235     BoxSizer13->Add(m_Libs, 1, wxALL|wxEXPAND, 5);
236     Panel6->SetSizer(BoxSizer13);
237     BoxSizer13->Fit(Panel6);
238     BoxSizer13->SetSizeHints(Panel6);
239     Panel5 = new wxPanel(FlatNotebook1, ID_PANEL4, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL4"));
240     BoxSizer9 = new wxBoxSizer(wxVERTICAL);
241     StaticText6 = new wxStaticText(Panel5, ID_STATICTEXT6, _("Compiler:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
242     BoxSizer9->Add(StaticText6, 0, wxTOP|wxALIGN_LEFT, 5);
243     BoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
244     m_CompilerDirs = new wxTextCtrl(Panel5, ID_TEXTCTRL9, wxEmptyString, wxDefaultPosition, wxSize(25,12), wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL9"));
245     BoxSizer10->Add(m_CompilerDirs, 1, wxEXPAND, 5);
246     Button5 = new wxButton(Panel5, ID_BUTTON5, _("+"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON5"));
247     BoxSizer10->Add(Button5, 0, wxALIGN_TOP, 5);
248     BoxSizer9->Add(BoxSizer10, 1, wxEXPAND, 5);
249     StaticText7 = new wxStaticText(Panel5, ID_STATICTEXT7, _("Linker:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7"));
250     BoxSizer9->Add(StaticText7, 0, wxTOP|wxALIGN_LEFT, 5);
251     BoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
252     m_LinkerDir = new wxTextCtrl(Panel5, ID_TEXTCTRL10, wxEmptyString, wxDefaultPosition, wxSize(48,8), wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL10"));
253     BoxSizer11->Add(m_LinkerDir, 1, wxEXPAND, 5);
254     Button6 = new wxButton(Panel5, ID_BUTTON6, _("+"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON6"));
255     BoxSizer11->Add(Button6, 0, wxALIGN_TOP, 5);
256     BoxSizer9->Add(BoxSizer11, 1, wxEXPAND, 5);
257     StaticText8 = new wxStaticText(Panel5, ID_STATICTEXT8, _("Extra objects (like resources):"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
258     BoxSizer9->Add(StaticText8, 0, wxTOP|wxALIGN_LEFT, 5);
259     BoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
260     m_ObjectsDir = new wxTextCtrl(Panel5, ID_TEXTCTRL11, wxEmptyString, wxDefaultPosition, wxSize(78,12), wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL11"));
261     BoxSizer12->Add(m_ObjectsDir, 1, wxEXPAND, 5);
262     Button7 = new wxButton(Panel5, ID_BUTTON7, _("+"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON7"));
263     BoxSizer12->Add(Button7, 0, wxALIGN_TOP, 5);
264     BoxSizer9->Add(BoxSizer12, 1, wxEXPAND, 5);
265     Panel5->SetSizer(BoxSizer9);
266     BoxSizer9->Fit(Panel5);
267     BoxSizer9->SetSizeHints(Panel5);
268     Panel7 = new wxPanel(FlatNotebook1, ID_PANEL7, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL7"));
269     BoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
270     m_CFlags = new wxTextCtrl(Panel7, ID_TEXTCTRL6, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL6"));
271     BoxSizer6->Add(m_CFlags, 1, wxALL|wxEXPAND, 5);
272     Panel7->SetSizer(BoxSizer6);
273     BoxSizer6->Fit(Panel7);
274     BoxSizer6->SetSizeHints(Panel7);
275     Panel3 = new wxPanel(FlatNotebook1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL2"));
276     BoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
277     m_LFlags = new wxTextCtrl(Panel3, ID_TEXTCTRL7, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL7"));
278     BoxSizer7->Add(m_LFlags, 1, wxALL|wxEXPAND, 5);
279     Panel3->SetSizer(BoxSizer7);
280     BoxSizer7->Fit(Panel3);
281     BoxSizer7->SetSizeHints(Panel3);
282     Panel9 = new wxPanel(FlatNotebook1, ID_PANEL9, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL9"));
283     BoxSizer19 = new wxBoxSizer(wxVERTICAL);
284     StaticText10 = new wxStaticText(Panel9, ID_STATICTEXT11, _("Header files used by this library:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT11"));
285     BoxSizer19->Add(StaticText10, 0, wxALL|wxEXPAND, 5);
286     m_Headers = new wxTextCtrl(Panel9, ID_TEXTCTRL14, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL14"));
287     BoxSizer19->Add(m_Headers, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
288     Panel9->SetSizer(BoxSizer19);
289     BoxSizer19->Fit(Panel9);
290     BoxSizer19->SetSizeHints(Panel9);
291     Panel10 = new wxPanel(FlatNotebook1, ID_PANEL10, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL10"));
292     BoxSizer20 = new wxBoxSizer(wxVERTICAL);
293     StaticText11 = new wxStaticText(Panel10, ID_STATICTEXT12, _("List of required libraries:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT12"));
294     BoxSizer20->Add(StaticText11, 0, wxALL|wxEXPAND, 5);
295     m_Required = new wxTextCtrl(Panel10, ID_TEXTCTRL15, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL15"));
296     BoxSizer20->Add(m_Required, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
297     Panel10->SetSizer(BoxSizer20);
298     BoxSizer20->Fit(Panel10);
299     BoxSizer20->SetSizeHints(Panel10);
300     FlatNotebook1->AddPage(Panel1, _("Base options"), false);
301     FlatNotebook1->AddPage(Panel8, _("Categories"), false);
302     FlatNotebook1->AddPage(Panel2, _("Compilers"), false);
303     FlatNotebook1->AddPage(Panel4, _("Defines"), false);
304     FlatNotebook1->AddPage(Panel6, _("Libs"), false);
305     FlatNotebook1->AddPage(Panel5, _("Directories"), false);
306     FlatNotebook1->AddPage(Panel7, _("CFlags"), false);
307     FlatNotebook1->AddPage(Panel3, _("LFlags"), false);
308     FlatNotebook1->AddPage(Panel9, _("Headers"), false);
309     FlatNotebook1->AddPage(Panel10, _("Requirements"), false);
310     StaticBoxSizer3->Add(FlatNotebook1, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
311     BoxSizer3->Add(StaticBoxSizer3, 0, wxTOP|wxEXPAND, 5);
312     BoxSizer16->Add(BoxSizer3, 2, wxALL|wxEXPAND, 5);
313     BoxSizer1->Add(BoxSizer16, 1, wxEXPAND, 5);
314     StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
315     StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_OK, wxEmptyString));
316     StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_CANCEL, wxEmptyString));
317     StdDialogButtonSizer1->Realize();
318     BoxSizer1->Add(StdDialogButtonSizer1, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
319     SetSizer(BoxSizer1);
320     BoxSizer1->Fit(this);
321     BoxSizer1->SetSizeHints(this);
322 
323     Connect(ID_LISTBOX1,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&LibrariesDlg::Onm_LibrariesSelect);
324     Connect(ID_CHECKBOX1,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&LibrariesDlg::Onm_ShowPredefinedClick);
325     Connect(ID_CHECKBOX2,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&LibrariesDlg::Onm_ShowPkgConfigClick);
326     Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::OnButton1Click);
327     Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::OnButton2Click);
328     Connect(ID_BUTTON11,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::OnButton3Click);
329     Connect(ID_BUTTON8,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::OnButton8Click);
330     Connect(ID_LISTBOX2,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&LibrariesDlg::Onm_ConfigurationsSelect);
331     Connect(ID_BUTTON9,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::Onm_ConfigPosChangeUp);
332     Connect(ID_BUTTON10,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::Onm_ConfigPosChangeDown);
333     Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::Onm_ConfDuplicateClick);
334     Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&LibrariesDlg::Onm_ConfDeleteClick);
335     Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&LibrariesDlg::Onm_NameText);
336     Connect(wxID_ANY,wxEVT_INIT_DIALOG,(wxObjectEventFunction)&LibrariesDlg::OnInit);
337     //*)
338 
339     RecreateLibrariesList(_T(""));
340 }
341 
~LibrariesDlg()342 LibrariesDlg::~LibrariesDlg()
343 {
344     //(*Destroy(LibrariesDlg)
345     //*)
346 }
347 
348 
OnInit(wxInitDialogEvent & event)349 void LibrariesDlg::OnInit(wxInitDialogEvent& event)
350 {
351     event.Skip();
352 }
353 
OnButton8Click(wxCommandEvent &)354 void LibrariesDlg::OnButton8Click(wxCommandEvent& /*event*/)
355 {
356     LibraryDetectionManager m_Manager(m_WorkingCopy);
357 
358     // Loading library search filters
359     if ( !m_Manager.LoadSearchFilters() )
360     {
361         cbMessageBox(
362             _("Didn't found any search filters used to detect libraries.\n"
363               "Please check if lib_finder plugin is installed properly."));
364         return;
365     }
366 
367     // Getting list of directories to process
368     DirListDlg Dlg(this);
369     if ( Dlg.ShowModal() == wxID_CANCEL ) return;
370 
371     // Do the processing
372     FileNamesMap FNMap;
373     ProcessingDlg PDlg(Manager::Get()->GetAppWindow(),m_Manager,m_WorkingCopy);
374     PDlg.ShowModal();
375 
376     bool apply = PDlg.ReadDirs(Dlg.Dirs) && PDlg.ProcessLibs();
377 
378     PDlg.Hide();
379 
380     if ( apply )
381     {
382         PDlg.ApplyResults( false );
383     }
384 
385     RecreateLibrariesListForceRefresh();
386 }
387 
388 
RecreateLibrariesList(const wxString & Selection)389 void LibrariesDlg::RecreateLibrariesList(const wxString& Selection)
390 {
391     m_Libraries->Clear();
392 
393     wxArrayString AllResults;
394     bool ShowPredefined = m_ShowPredefined->GetValue();
395     bool ShowPkgConfig  = m_ShowPkgConfig->GetValue();
396 
397     for ( int i=0; i<rtCount; i++ )
398     {
399         bool Include = true;
400         switch ( i )
401         {
402             case rtPredefined: Include = ShowPredefined; break;
403             case rtPkgConfig:  Include = ShowPkgConfig; break;
404             default: break;
405         }
406 
407         if ( Include )
408         {
409             m_WorkingCopy[i].GetShortCodes(AllResults);
410         }
411     }
412 
413     AllResults.Sort();
414 
415     wxString Prev = wxEmptyString;
416     int Index = wxNOT_FOUND;
417     for ( size_t i=0; i<AllResults.Count(); i++ )
418     {
419         if ( Prev != AllResults[i] )
420         {
421             Prev = AllResults[i];
422             int ThisIndex = m_Libraries->Append( Prev );
423             if ( Prev == Selection )
424             {
425                 Index = ThisIndex;
426             }
427         }
428     }
429 
430     if ( Index == wxNOT_FOUND )
431     {
432         if ( !m_Libraries->IsEmpty() )
433         {
434             Index = 0;
435         }
436     }
437 
438     m_Libraries->SetSelection(Index);
439     if ( Index != wxNOT_FOUND )
440     {
441         SelectLibrary( m_Libraries->GetString(Index) );
442     }
443     else
444     {
445         SelectLibrary( wxEmptyString );
446     }
447 }
448 
RecreateLibrariesListForceRefresh()449 void LibrariesDlg::RecreateLibrariesListForceRefresh()
450 {
451     // We clear current selection before to force reloading of all
452     // configurations of library
453     wxString Sel = m_SelectedShortcut;
454     m_SelectedShortcut.Clear();
455 
456     // Rebuilding the list
457     RecreateLibrariesList(Sel);
458 }
459 
Onm_ShowPredefinedClick(wxCommandEvent &)460 void LibrariesDlg::Onm_ShowPredefinedClick(wxCommandEvent& /*event*/)
461 {
462     RecreateLibrariesListForceRefresh();
463 }
464 
Onm_ShowPkgConfigClick(wxCommandEvent &)465 void LibrariesDlg::Onm_ShowPkgConfigClick(wxCommandEvent& /*event*/)
466 {
467     RecreateLibrariesListForceRefresh();
468 }
469 
Onm_LibrariesSelect(wxCommandEvent &)470 void LibrariesDlg::Onm_LibrariesSelect(wxCommandEvent& /*event*/)
471 {
472     SelectLibrary( m_Libraries->GetStringSelection() );
473 }
474 
SelectLibrary(const wxString & Shortcut)475 void LibrariesDlg::SelectLibrary(const wxString& Shortcut)
476 {
477     if ( Shortcut == m_SelectedShortcut )
478     {
479         return;
480     }
481 
482     StoreConfiguration();
483     m_SelectedShortcut = Shortcut;
484     m_Configurations->Clear();
485 
486     int Index = wxNOT_FOUND;
487     for ( int i=0; i<rtCount; i++ )
488     {
489         ResultArray& arr = m_WorkingCopy[i].GetShortCode( Shortcut );
490         for ( size_t j=0; j<arr.Count(); j++ )
491         {
492             LibraryResult* result = arr[j];
493             int ThisIndex = m_Configurations->Append( GetDesc(result), (void*)result );
494             if ( result == m_SelectedConfig )
495             {
496                 Index = ThisIndex;
497             }
498         }
499     }
500 
501     if ( Index == wxNOT_FOUND )
502     {
503         if ( !m_Configurations->IsEmpty() )
504         {
505             Index = 0;
506         }
507     }
508 
509     m_Configurations->SetSelection(Index);
510 
511     SelectConfiguration( (Index==wxNOT_FOUND) ? 0 : (LibraryResult*)m_Configurations->GetClientData(Index) );
512 }
513 
SelectConfiguration(LibraryResult * Configuration)514 void LibrariesDlg::SelectConfiguration(LibraryResult* Configuration)
515 {
516     if ( Configuration == m_SelectedConfig )
517     {
518         return;
519     }
520     m_SelectedConfig = Configuration;
521 
522     m_WhileUpdating = true;
523     if ( !Configuration )
524     {
525         m_Type->SetLabel( wxEmptyString );
526         m_Name->Disable();
527         m_Name->Clear();
528         m_BasePath->Disable();
529         m_BasePath->Clear();
530         m_PkgConfigName->Disable();
531         m_PkgConfigName->Clear();
532         m_Description->Disable();
533         m_Description->Clear();
534         m_Categories->Disable();
535         m_Categories->Clear();
536         m_Compilers->Clear();
537         m_Compilers->Disable();
538         m_Defines->Clear();
539         m_Defines->Disable();
540         m_Libs->Clear();
541         m_Libs->Disable();
542         m_CompilerDirs->Clear();
543         m_CompilerDirs->Disable();
544         m_LinkerDir->Clear();
545         m_LinkerDir->Disable();
546         m_ObjectsDir->Clear();
547         m_ObjectsDir->Disable();
548         m_CFlags->Clear();
549         m_CFlags->Disable();
550         m_LFlags->Clear();
551         m_LFlags->Disable();
552         m_ConfDelete->Disable();
553         m_ConfDuplicate->Disable();
554         m_ConfigDown->Disable();
555         m_ConfigUp->Disable();
556         m_Headers->Disable();
557         m_Required->Clear();
558         m_Required->Disable();
559 
560         m_WhileUpdating = false;
561         return;
562     }
563 
564     bool DisableAll = true;
565     switch ( Configuration->Type )
566     {
567         case rtDetected:
568             m_Type->SetLabel(_("Custom"));
569             DisableAll = false;
570             break;
571 
572         case rtPredefined:
573             m_Type->SetLabel(_("Predefined"));
574             break;
575 
576         case rtPkgConfig:
577             m_Type->SetLabel(_("Pkg-Config"));
578             break;
579 
580         case rtCount:
581         case rtUnknown:
582         default:
583             break;
584     }
585 
586     m_Name->SetValue(Configuration->LibraryName);
587     m_Name->Enable( !DisableAll );
588     m_BasePath->SetValue(Configuration->BasePath);
589     m_BasePath->Enable( !DisableAll );
590     m_PkgConfigName->SetValue(Configuration->PkgConfigVar);
591     m_PkgConfigName->Enable( !DisableAll );
592     m_Description->SetValue(Configuration->Description);
593     m_Description->Enable( !DisableAll );
594     m_Categories->SetValue(GetStringFromArray(Configuration->Categories,_T("\n")));
595     m_Categories->Enable( !DisableAll );
596     m_Compilers->SetValue(GetStringFromArray(Configuration->Compilers,_T("\n")));
597     m_Compilers->Enable( !DisableAll );
598     m_Defines->SetValue(GetStringFromArray(Configuration->Defines,_T("\n")));
599     m_Defines->Enable( !DisableAll );
600     m_Libs->SetValue(GetStringFromArray(Configuration->Libs,_T("\n")));
601     m_Libs->Enable( !DisableAll );
602     m_CompilerDirs->SetValue(GetStringFromArray(Configuration->IncludePath,_T("\n")));
603     m_CompilerDirs->Enable( !DisableAll );
604     m_LinkerDir->SetValue(GetStringFromArray(Configuration->LibPath,_T("\n")));
605     m_LinkerDir->Enable( !DisableAll );
606     m_ObjectsDir->SetValue(GetStringFromArray(Configuration->ObjPath,_T("\n")));
607     m_ObjectsDir->Enable( !DisableAll );
608     m_CFlags->SetValue(GetStringFromArray(Configuration->CFlags,_T("\n")));
609     m_CFlags->Enable( !DisableAll );
610     m_LFlags->SetValue(GetStringFromArray(Configuration->LFlags,_T("\n")));
611     m_LFlags->Enable( !DisableAll );
612     m_Headers->SetValue(GetStringFromArray(Configuration->Headers,_T("\n")));
613     m_Headers->Enable( !DisableAll );
614     m_ConfDelete->Enable( !DisableAll && ( m_Configurations->GetCount() > 1 ) );
615     m_ConfDuplicate->Enable( true );
616     m_Required->Enable( !DisableAll );
617     m_Required->SetValue( GetStringFromArray(Configuration->Require,_T("\n")));
618 
619     m_ConfigUp->Disable();
620     m_ConfigDown->Disable();
621 
622     if ( !DisableAll )
623     {
624         int Selection = m_Configurations->GetSelection();
625         if ( Selection>0 )
626         {
627             m_ConfigUp->Enable();
628         }
629 
630 
631         if ( Selection < (int)m_Configurations->GetCount()-1 )
632         {
633             LibraryResult* NextResult = (LibraryResult*)m_Configurations->GetClientData( Selection+1 );
634             if ( NextResult && NextResult->Type == rtDetected )
635             {
636                 m_ConfigDown->Enable();
637             }
638         }
639     }
640 
641     m_WhileUpdating = false;
642 }
643 
GetDesc(LibraryResult * Configuration)644 wxString LibrariesDlg::GetDesc(LibraryResult* Configuration)
645 {
646     wxString ret;
647     switch ( Configuration->Type )
648     {
649         case rtPkgConfig:  ret += _("Pkg-Config: "); break;
650         case rtPredefined: ret += _("Predefined: "); break;
651         case rtDetected:
652         case rtCount:
653         case rtUnknown:
654         default: break;
655     }
656 
657     if ( Configuration->LibraryName.IsEmpty() )
658     {
659         ret += Configuration->ShortCode;
660     }
661     else
662     {
663         ret += Configuration->LibraryName;
664     }
665 
666     if ( !Configuration->Compilers.IsEmpty() )
667     {
668         ret += _T(" (");
669         ret += _("Compilers");
670 
671         for ( size_t i=0; i<Configuration->Compilers.Count(); i++ )
672         {
673             ret += (i==0) ? _T(": ") : _T(", ");
674             ret += Configuration->Compilers[i];
675         }
676 
677         ret += _T(")");
678     }
679 
680     return ret;
681 }
682 
OnWrite(wxCommandEvent & event)683 void LibrariesDlg::OnWrite(wxCommandEvent& event)
684 {
685     StoreConfiguration();
686     //m_WorkingCopy[rtDetected].DebugDump( _T("LibrariesDlg::OnWrite - original") );
687     m_KnownLibraries[rtDetected] = m_WorkingCopy[rtDetected];
688     //m_KnownLibraries[rtDetected].DebugDump( _T("LibrariesDlg::OnWrite - after copy") );
689     m_KnownLibraries[rtDetected].WriteDetectedResults();
690     event.Skip();
691 }
692 
Onm_ConfDeleteClick(wxCommandEvent &)693 void LibrariesDlg::Onm_ConfDeleteClick(wxCommandEvent& /*event*/)
694 {
695     if ( m_SelectedShortcut.IsEmpty() || !m_SelectedConfig || m_SelectedConfig->Type!=rtDetected )
696     {
697         return;
698     }
699 
700     if ( cbMessageBox( _("Do you really want to delete this entry?"), _("Deleting library settings"), wxYES_NO, this ) != wxID_YES )
701     {
702         return;
703     }
704 
705     m_WhileUpdating = true;
706     m_Configurations->Delete( m_Configurations->GetSelection() );
707     m_WhileUpdating = false;
708     ResultArray& arr = m_WorkingCopy[rtDetected].GetShortCode( m_SelectedShortcut );
709     for ( size_t i=0; i<arr.Count(); i++ )
710     {
711         if ( arr[i] == m_SelectedConfig )
712         {
713             arr.RemoveAt(i);
714             delete m_SelectedConfig;
715             m_SelectedConfig = 0;
716             if ( i >= arr.Count() )
717             {
718                 if ( i>0 )
719                 {
720                     i--;
721                 }
722                 else
723                 {
724                     m_Configurations->SetSelection( wxNOT_FOUND );
725                     SelectConfiguration( 0 );
726                     return;
727                 }
728             }
729 
730             m_Configurations->SetSelection( i );
731             SelectConfiguration( (LibraryResult*) m_Configurations->GetClientData(i) );
732         }
733     }
734 }
735 
Onm_ConfigurationsSelect(wxCommandEvent &)736 void LibrariesDlg::Onm_ConfigurationsSelect(wxCommandEvent& /*event*/)
737 {
738     if ( m_WhileUpdating ) return;
739     StoreConfiguration();
740     int Index = m_Configurations->GetSelection();
741     if ( Index == wxNOT_FOUND )
742     {
743         SelectConfiguration( 0 );
744         return;
745     }
746     SelectConfiguration( (LibraryResult*) m_Configurations->GetClientData(Index) );
747 }
748 
Onm_ConfDuplicateClick(wxCommandEvent &)749 void LibrariesDlg::Onm_ConfDuplicateClick(wxCommandEvent& /*event*/)
750 {
751     if ( m_SelectedShortcut.IsEmpty() || !m_SelectedConfig )
752     {
753         return;
754     }
755 
756     StoreConfiguration();
757     ResultArray& arr = m_WorkingCopy[rtDetected].GetShortCode( m_SelectedShortcut );
758 
759     // Duplicating entry
760     LibraryResult* newResult = new LibraryResult( *m_SelectedConfig );
761     newResult->Type = rtDetected;
762     arr.Add( newResult );
763 
764     // Searching for good place to put new result into the list
765     int Index;
766     for ( Index = m_Configurations->GetCount(); Index-->0; )
767     {
768         LibraryResult* conf = (LibraryResult*)m_Configurations->GetClientData( Index );
769         if ( !conf ) continue;
770         if ( conf->Type == rtDetected )
771         {
772             break;
773         }
774     }
775 
776     m_Configurations->Insert( GetDesc( newResult ), ++Index, (void*)newResult );
777     m_Configurations->SetSelection(Index);
778     SelectConfiguration( newResult );
779 }
780 
StoreConfiguration()781 void LibrariesDlg::StoreConfiguration()
782 {
783     if ( !m_SelectedConfig ) return;
784     if ( m_SelectedConfig->Type != rtDetected ) return;
785 
786     m_SelectedConfig->LibraryName  = m_Name->GetValue();
787     m_SelectedConfig->BasePath     = m_BasePath->GetValue();
788     m_SelectedConfig->PkgConfigVar = m_PkgConfigName->GetValue();
789     m_SelectedConfig->Description  = m_Description->GetValue();
790     m_SelectedConfig->Categories   = wxStringTokenize( m_Categories->GetValue(),   _T("\n\r"), wxTOKEN_STRTOK );
791     m_SelectedConfig->Compilers    = wxStringTokenize( m_Compilers->GetValue(),    _T("\n\r"), wxTOKEN_STRTOK );
792     m_SelectedConfig->Defines      = wxStringTokenize( m_Defines->GetValue(),      _T("\n\r"), wxTOKEN_STRTOK );
793     m_SelectedConfig->Libs         = wxStringTokenize( m_Libs->GetValue(),         _T("\n\r"), wxTOKEN_STRTOK );
794     m_SelectedConfig->IncludePath  = wxStringTokenize( m_CompilerDirs->GetValue(), _T("\n\r"), wxTOKEN_STRTOK );
795     m_SelectedConfig->LibPath      = wxStringTokenize( m_LinkerDir->GetValue(),    _T("\n\r"), wxTOKEN_STRTOK );
796     m_SelectedConfig->ObjPath      = wxStringTokenize( m_ObjectsDir->GetValue(),   _T("\n\r"), wxTOKEN_STRTOK );
797     m_SelectedConfig->CFlags       = wxStringTokenize( m_CFlags->GetValue(),       _T("\n\r"), wxTOKEN_STRTOK );
798     m_SelectedConfig->LFlags       = wxStringTokenize( m_LFlags->GetValue(),       _T("\n\r"), wxTOKEN_STRTOK );
799     m_SelectedConfig->Headers      = wxStringTokenize( m_Headers->GetValue(),      _T("\n\r"), wxTOKEN_STRTOK );
800     m_SelectedConfig->Require      = wxStringTokenize( m_Required->GetValue(),     _T("\n\r"), wxTOKEN_STRTOK );
801 }
802 
Onm_NameText(wxCommandEvent &)803 void LibrariesDlg::Onm_NameText(wxCommandEvent& /*event*/)
804 {
805     if ( m_WhileUpdating ) return;
806     RefreshConfigurationName();
807 }
808 
RefreshConfigurationName()809 void LibrariesDlg::RefreshConfigurationName()
810 {
811     if ( !m_SelectedConfig ) return;
812     StoreConfiguration();
813     m_Configurations->SetString( m_Configurations->GetSelection(), GetDesc( m_SelectedConfig ) );
814 }
815 
Onm_CompilersText(wxCommandEvent &)816 void LibrariesDlg::Onm_CompilersText(wxCommandEvent& /*event*/)
817 {
818     if ( m_WhileUpdating ) return;
819     RefreshConfigurationName();
820 }
821 
OnButton1Click(wxCommandEvent &)822 void LibrariesDlg::OnButton1Click(wxCommandEvent& /*event*/)
823 {
824     StoreConfiguration();
825 
826     wxString ShortCode = cbGetTextFromUser( _("Enter Shortcode for new library"), _("New library"), wxEmptyString, this );
827     if ( ShortCode.IsEmpty() ) return;
828 
829     // Detect whether such shortcode is used
830     for ( int i=0; i<rtCount; i++ )
831     {
832         if ( m_WorkingCopy[i].IsShortCode( ShortCode ) )
833         {
834             cbMessageBox(
835                 _("Library with such shortcode already exists.\n"
836                   "If you don't see it, make sure that all known\n"
837                   "libraries (including those from pkg-config\n"
838                   "and predefined ones) are shown."), _("Error"), wxOK | wxICON_ERROR );
839             return;
840         }
841     }
842 
843     // Adding new result
844     ResultArray& arr = m_WorkingCopy[rtDetected].GetShortCode(ShortCode);
845     LibraryResult* res = new LibraryResult;
846     res->Type = rtDetected;
847     res->LibraryName = ShortCode;
848     res->ShortCode = ShortCode;
849     arr.Add(res);
850 
851     m_SelectedShortcut = ShortCode;
852     RecreateLibrariesListForceRefresh();
853 
854     //m_WorkingCopy[rtDetected].DebugDump(_T("After add"));
855 }
856 
OnButton2Click(wxCommandEvent &)857 void LibrariesDlg::OnButton2Click(wxCommandEvent& /*event*/)
858 {
859     if ( m_SelectedShortcut.IsEmpty() ) return;
860 
861     if ( cbMessageBox( _("Do you really want to clear settings of this library?"), _("Removing library settings"), wxYES_NO, this ) != wxID_YES )
862     {
863         return;
864     }
865 
866     for ( int i=0; i<rtCount; i++ )
867     {
868         if ( i == rtDetected )
869         {
870             break;
871         }
872 
873         if ( m_WorkingCopy[i].IsShortCode( m_SelectedShortcut ) )
874         {
875             wxString Msg;
876             wxString Cpt;
877             switch ( i )
878             {
879                 case rtPkgConfig:
880                     Msg = _( "This library has configuration in pkg-config database\n"
881                              "which can not be cleared.\n"
882                              "Do you want to delete custom resuls only ?" );
883                     Cpt = _("Pkg-config settings available");
884                     break;
885 
886                 case rtPredefined:
887                     Msg = _( "This library has predefined configuration\n"
888                              "which can not be cleared.\n"
889                              "Do you want to delete custom resuls only ?" );
890                     Cpt = _("Predefined settings available");
891                     break;
892 
893                 default:
894                     Msg = _( "This library has static configuration\n"
895                              "which can not be cleared.\n"
896                              "Do you want to delete custom resuls only ?" );
897                     Cpt = _("Static settings available");
898             }
899 
900             if ( cbMessageBox( Msg, Cpt, wxYES_NO, this ) != wxID_YES )
901             {
902                 return;
903             }
904             break;
905         }
906     }
907 
908     m_SelectedConfig = 0;
909     ResultArray& arr = m_WorkingCopy[rtDetected].GetShortCode( m_SelectedShortcut );
910     for ( size_t i=0; i<arr.Count(); i++ )
911     {
912         delete arr[i];
913     }
914     arr.Clear();
915     RecreateLibrariesListForceRefresh();
916 }
917 
Onm_ConfigPosChangeDown(wxCommandEvent &)918 void LibrariesDlg::Onm_ConfigPosChangeDown(wxCommandEvent& /*event*/)
919 {
920     if ( m_WhileUpdating ) return;
921     m_WhileUpdating = true;
922 
923     StoreConfiguration();
924 
925     int Index = m_Configurations->GetSelection();
926     if ( Index!=wxNOT_FOUND )
927     {
928         m_Configurations->Insert(
929             m_Configurations->GetStringSelection(),
930             Index + 2,
931             m_Configurations->GetClientData( Index ) );
932         m_Configurations->Delete( Index );
933         m_Configurations->SetSelection( Index+1 );
934 
935         LibraryResult* tmp = m_SelectedConfig;
936         m_SelectedConfig = 0;
937         SelectConfiguration( tmp );
938     }
939 
940     m_WhileUpdating = false;
941 }
942 
Onm_ConfigPosChangeUp(wxCommandEvent &)943 void LibrariesDlg::Onm_ConfigPosChangeUp(wxCommandEvent& /*event*/)
944 {
945     if ( m_WhileUpdating ) return;
946     m_WhileUpdating = true;
947 
948     StoreConfiguration();
949 
950     int Index = m_Configurations->GetSelection();
951     if ( Index!=wxNOT_FOUND )
952     {
953         m_Configurations->Insert(
954             m_Configurations->GetStringSelection(),
955             Index - 1,
956             m_Configurations->GetClientData( Index ) );
957         m_Configurations->Delete( Index+1 );
958         m_Configurations->SetSelection( Index-1 );
959 
960         LibraryResult* tmp = m_SelectedConfig;
961         m_SelectedConfig = 0;
962         SelectConfiguration( tmp );
963     }
964     m_WhileUpdating = false;
965 }
966 
OnButton3Click(wxCommandEvent &)967 void LibrariesDlg::OnButton3Click(wxCommandEvent& /*event*/)
968 {
969     DefsDownloadDlg(this).ShowModal();
970 }
971