1 |
786 |
skrzyp |
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####
|
2 |
|
|
// -------------------------------------------
|
3 |
|
|
// This file is part of the eCos host tools.
|
4 |
|
|
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
5 |
|
|
//
|
6 |
|
|
// This program is free software; you can redistribute it and/or modify
|
7 |
|
|
// it under the terms of the GNU General Public License as published by
|
8 |
|
|
// the Free Software Foundation; either version 2 or (at your option) any
|
9 |
|
|
// later version.
|
10 |
|
|
//
|
11 |
|
|
// This program is distributed in the hope that it will be useful, but
|
12 |
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public License
|
17 |
|
|
// along with this program; if not, write to the
|
18 |
|
|
// Free Software Foundation, Inc., 51 Franklin Street,
|
19 |
|
|
// Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
|
|
// -------------------------------------------
|
21 |
|
|
// ####ECOSHOSTGPLCOPYRIGHTEND####
|
22 |
|
|
// buildoptionsdlg.cpp :
|
23 |
|
|
//
|
24 |
|
|
//===========================================================================
|
25 |
|
|
//#####DESCRIPTIONBEGIN####
|
26 |
|
|
//
|
27 |
|
|
// Author(s): julians
|
28 |
|
|
// Contact(s): julians
|
29 |
|
|
// Date: 2000/09/27
|
30 |
|
|
// Version: $Id: buildoptionsdlg.cpp,v 1.2 2001/03/23 13:38:04 julians Exp $
|
31 |
|
|
// Purpose:
|
32 |
|
|
// Description: Implementation file for ecBuildOptionsDialog
|
33 |
|
|
// Requires:
|
34 |
|
|
// Provides:
|
35 |
|
|
// See also:
|
36 |
|
|
// Known bugs:
|
37 |
|
|
// Usage:
|
38 |
|
|
//
|
39 |
|
|
//####DESCRIPTIONEND####
|
40 |
|
|
//
|
41 |
|
|
//===========================================================================
|
42 |
|
|
|
43 |
|
|
// ============================================================================
|
44 |
|
|
// declarations
|
45 |
|
|
// ============================================================================
|
46 |
|
|
|
47 |
|
|
// ----------------------------------------------------------------------------
|
48 |
|
|
// headers
|
49 |
|
|
// ----------------------------------------------------------------------------
|
50 |
|
|
#ifdef __GNUG__
|
51 |
|
|
#pragma implementation "buildoptionsdlg.h"
|
52 |
|
|
#endif
|
53 |
|
|
|
54 |
|
|
// Includes other headers for precompiled compilation
|
55 |
|
|
#include "ecpch.h"
|
56 |
|
|
|
57 |
|
|
#ifdef __BORLANDC__
|
58 |
|
|
#pragma hdrstop
|
59 |
|
|
#endif
|
60 |
|
|
|
61 |
|
|
#ifdef __WXGTK__
|
62 |
|
|
#include "bitmaps/package_open.xpm"
|
63 |
|
|
#include "bitmaps/package_version.xpm"
|
64 |
|
|
#endif
|
65 |
|
|
|
66 |
|
|
#include "wx/cshelp.h"
|
67 |
|
|
|
68 |
|
|
#include "configtool.h"
|
69 |
|
|
#include "configtooldoc.h"
|
70 |
|
|
#include "buildoptionsdlg.h"
|
71 |
|
|
#include "flags.hxx"
|
72 |
|
|
|
73 |
|
|
BEGIN_EVENT_TABLE(ecBuildOptionsDialog, ecDialog)
|
74 |
|
|
EVT_BUTTON(wxID_OK, ecBuildOptionsDialog::OnOK)
|
75 |
|
|
EVT_BUTTON(wxID_CANCEL, ecBuildOptionsDialog::OnCancel)
|
76 |
|
|
EVT_CHOICE(ecID_BUILD_OPTIONS_CATEGORY, ecBuildOptionsDialog::OnSelCategory)
|
77 |
|
|
EVT_TREE_SEL_CHANGED(ecID_BUILD_OPTIONS_PACKAGES_TREE, ecBuildOptionsDialog::OnSelTree)
|
78 |
|
|
EVT_INIT_DIALOG(ecBuildOptionsDialog::OnInitDialog)
|
79 |
|
|
END_EVENT_TABLE()
|
80 |
|
|
|
81 |
|
|
// ----------------------------------------------------------------------------
|
82 |
|
|
// main frame
|
83 |
|
|
// ----------------------------------------------------------------------------
|
84 |
|
|
|
85 |
|
|
// Frame constructor
|
86 |
|
|
ecBuildOptionsDialog::ecBuildOptionsDialog(wxWindow* parent):
|
87 |
|
|
m_imageList(16, 16, 1),
|
88 |
|
|
m_arEntries(wxGetApp().GetConfigToolDoc()->GetBuildInfo().entries)
|
89 |
|
|
|
90 |
|
|
{
|
91 |
|
|
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
|
92 |
|
|
|
93 |
|
|
ecDialog::Create(parent, ecID_BUILD_OPTIONS_DIALOG, _("Build Options"),
|
94 |
|
|
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
|
95 |
|
|
|
96 |
|
|
CreateControls(this);
|
97 |
|
|
|
98 |
|
|
m_imageList.Add(wxICON(package_open));
|
99 |
|
|
m_imageList.Add(wxICON(package_version));
|
100 |
|
|
m_treeCtrl->SetImageList(& m_imageList);
|
101 |
|
|
|
102 |
|
|
#if 0
|
103 |
|
|
// Add some dummy items
|
104 |
|
|
wxTreeItemId rootId = m_treeCtrl->AddRoot(_("Configuration"), 0, -1);
|
105 |
|
|
m_treeCtrl->AppendItem(rootId, _("eCos HAL"), 0, -1);
|
106 |
|
|
m_treeCtrl->AppendItem(rootId, _("I/O sub-system"), 0, -1);
|
107 |
|
|
m_treeCtrl->AppendItem(rootId, _("Serial device drivers"), 0, -1);
|
108 |
|
|
m_treeCtrl->AppendItem(rootId, _("Infrastructure"), 0, -1);
|
109 |
|
|
m_treeCtrl->AppendItem(rootId, _("eCos kernel"), 0, -1);
|
110 |
|
|
m_treeCtrl->AppendItem(rootId, _("C library"), 0, -1);
|
111 |
|
|
|
112 |
|
|
m_treeCtrl->Expand(rootId);
|
113 |
|
|
#endif
|
114 |
|
|
|
115 |
|
|
Centre(wxBOTH);
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
ecBuildOptionsDialog::~ecBuildOptionsDialog()
|
119 |
|
|
{
|
120 |
|
|
m_treeCtrl->SetImageList(NULL);
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
void ecBuildOptionsDialog::OnInitDialog(wxInitDialogEvent& event)
|
124 |
|
|
{
|
125 |
|
|
m_treeCtrl->DeleteAllItems();
|
126 |
|
|
//wxTreeItemId rootId = m_treeCtrl->AddRoot(_("Configuration"), 0, -1);
|
127 |
|
|
CreateItems(wxGetApp().GetConfigToolDoc()->GetFirstItem(), wxTreeItemId());
|
128 |
|
|
|
129 |
|
|
m_treeCtrl->Expand(m_treeCtrl->GetRootItem());
|
130 |
|
|
((wxChoice*) FindWindow(ecID_BUILD_OPTIONS_CATEGORY))->SetSelection(0);
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
void ecBuildOptionsDialog::CreateControls(wxWindow* parent)
|
134 |
|
|
{
|
135 |
|
|
m_treeCtrl = new wxTreeCtrl(parent, ecID_BUILD_OPTIONS_PACKAGES_TREE,
|
136 |
|
|
wxDefaultPosition, wxSize(280, 220), wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
|
137 |
|
|
|
138 |
|
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
139 |
|
|
|
140 |
|
|
wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
|
141 |
|
|
|
142 |
|
|
wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, _("&Category:"), wxDefaultPosition, wxDefaultSize, 0 );
|
143 |
|
|
item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
|
144 |
|
|
|
145 |
|
|
wxString strs3[] =
|
146 |
|
|
{
|
147 |
|
|
_("CFLAGS"),
|
148 |
|
|
_("LDFLAGS")
|
149 |
|
|
};
|
150 |
|
|
wxChoice *item3 = new wxChoice( parent, ecID_BUILD_OPTIONS_CATEGORY, wxDefaultPosition, wxSize(90,-1), 2, strs3, 0 );
|
151 |
|
|
item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
|
152 |
|
|
|
153 |
|
|
item1->Add( 20, 20, 20, wxALIGN_CENTRE|wxALL, 5 );
|
154 |
|
|
|
155 |
|
|
wxButton *item4 = new wxButton( parent, wxID_OK, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
|
156 |
|
|
item4->SetDefault();
|
157 |
|
|
item1->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
|
158 |
|
|
|
159 |
|
|
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
160 |
|
|
|
161 |
|
|
wxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
|
162 |
|
|
|
163 |
|
|
wxSizer *item6 = new wxBoxSizer( wxVERTICAL );
|
164 |
|
|
|
165 |
|
|
wxStaticText *item7 = new wxStaticText( parent, wxID_STATIC, _("&Packages:"), wxDefaultPosition, wxDefaultSize, 0 );
|
166 |
|
|
item6->Add( item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
167 |
|
|
|
168 |
|
|
wxWindow *item8 = parent->FindWindow( ecID_BUILD_OPTIONS_PACKAGES_TREE );
|
169 |
|
|
wxASSERT( item8 );
|
170 |
|
|
item6->Add( item8, 10, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
171 |
|
|
|
172 |
|
|
item5->Add( item6, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
|
173 |
|
|
|
174 |
|
|
wxSizer *item9 = new wxBoxSizer( wxVERTICAL );
|
175 |
|
|
|
176 |
|
|
wxStaticText *item10 = new wxStaticText( parent, wxID_STATIC, _("&Flags:"), wxDefaultPosition, wxDefaultSize, 0 );
|
177 |
|
|
item9->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
178 |
|
|
|
179 |
|
|
wxString *strs11 = (wxString*) NULL;
|
180 |
|
|
wxListBox *item11 = new wxListBox( parent, ecID_BUILD_OPTIONS_FLAGS, wxDefaultPosition, wxSize(170,240), 0, strs11, 0 );
|
181 |
|
|
item9->Add( item11, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
182 |
|
|
|
183 |
|
|
item5->Add( item9, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
|
184 |
|
|
|
185 |
|
|
item0->Add( item5, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
186 |
|
|
|
187 |
|
|
#if 0
|
188 |
|
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
189 |
|
|
|
190 |
|
|
wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
|
191 |
|
|
|
192 |
|
|
wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, _("&Category:"), wxDefaultPosition, wxDefaultSize, 0 );
|
193 |
|
|
item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
|
194 |
|
|
|
195 |
|
|
wxString strs3[] =
|
196 |
|
|
{
|
197 |
|
|
_("CFLAGS"),
|
198 |
|
|
_("LDFLAGS")
|
199 |
|
|
};
|
200 |
|
|
wxChoice *item3 = new wxChoice( parent, ecID_BUILD_OPTIONS_CATEGORY, wxDefaultPosition, wxSize(90,-1), 2, strs3, 0 );
|
201 |
|
|
item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
|
202 |
|
|
|
203 |
|
|
item1->Add( 20, 20, 20, wxALIGN_CENTRE|wxALL, 5 );
|
204 |
|
|
|
205 |
|
|
wxButton *item4 = new wxButton( parent, wxID_OK, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
|
206 |
|
|
item4->SetDefault();
|
207 |
|
|
item1->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
|
208 |
|
|
|
209 |
|
|
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
210 |
|
|
|
211 |
|
|
wxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
|
212 |
|
|
|
213 |
|
|
wxSizer *item6 = new wxBoxSizer( wxVERTICAL );
|
214 |
|
|
|
215 |
|
|
wxStaticText *item7 = new wxStaticText( parent, wxID_STATIC, _("&Packages:"), wxDefaultPosition, wxDefaultSize, 0 );
|
216 |
|
|
item6->Add( item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
217 |
|
|
|
218 |
|
|
wxWindow *item8 = parent->FindWindow( ecID_BUILD_OPTIONS_PACKAGES_TREE );
|
219 |
|
|
wxASSERT( item8 );
|
220 |
|
|
item6->Add( item8, 10, wxALIGN_CENTRE|wxALL, 5 );
|
221 |
|
|
|
222 |
|
|
item5->Add( item6, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
|
223 |
|
|
|
224 |
|
|
wxSizer *item9 = new wxBoxSizer( wxVERTICAL );
|
225 |
|
|
|
226 |
|
|
wxStaticText *item10 = new wxStaticText( parent, wxID_STATIC, _("&Flags:"), wxDefaultPosition, wxDefaultSize, 0 );
|
227 |
|
|
item9->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
228 |
|
|
|
229 |
|
|
wxString *strs11 = (wxString*) NULL;
|
230 |
|
|
wxListBox *item11 = new wxListBox( parent, ecID_BUILD_OPTIONS_FLAGS, wxDefaultPosition, wxSize(170,240), 0, strs11, 0 );
|
231 |
|
|
item9->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
|
232 |
|
|
|
233 |
|
|
item5->Add( item9, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
|
234 |
|
|
|
235 |
|
|
item0->Add( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
236 |
|
|
#endif
|
237 |
|
|
|
238 |
|
|
#ifdef __WXGTK__
|
239 |
|
|
wxButton *contextButton = new wxContextHelpButton( parent );
|
240 |
|
|
item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
|
241 |
|
|
#endif
|
242 |
|
|
|
243 |
|
|
parent->SetAutoLayout( TRUE );
|
244 |
|
|
parent->SetSizer( item0 );
|
245 |
|
|
parent->Layout();
|
246 |
|
|
item0->Fit( parent );
|
247 |
|
|
item0->SetSizeHints( parent );
|
248 |
|
|
|
249 |
|
|
// Add context-sensitive help text
|
250 |
|
|
parent->FindWindow( ecID_BUILD_OPTIONS_CATEGORY )->SetHelpText(_("Selects the categorty of build flags for which options are to be displayed."));
|
251 |
|
|
parent->FindWindow( ecID_BUILD_OPTIONS_PACKAGES_TREE )->SetHelpText(_("Displays a view of the packages currently included in the configuration."));
|
252 |
|
|
parent->FindWindow( ecID_BUILD_OPTIONS_FLAGS )->SetHelpText(_("Lists the flags defined for the packages selected in the adjacent Packages window."));
|
253 |
|
|
parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and saves any changes you have made."));
|
254 |
|
|
parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Closes the dialog without saving any changes you have made."));
|
255 |
|
|
|
256 |
|
|
#if __WXGTK__
|
257 |
|
|
parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
|
258 |
|
|
#endif
|
259 |
|
|
|
260 |
|
|
}
|
261 |
|
|
|
262 |
|
|
void ecBuildOptionsDialog::OnCancel(wxCommandEvent& event)
|
263 |
|
|
{
|
264 |
|
|
event.Skip();
|
265 |
|
|
}
|
266 |
|
|
|
267 |
|
|
void ecBuildOptionsDialog::OnOK(wxCommandEvent& event)
|
268 |
|
|
{
|
269 |
|
|
event.Skip();
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
void ecBuildOptionsDialog::CreateItems(ecConfigItem *pti, wxTreeItemId hParent)
|
273 |
|
|
{
|
274 |
|
|
if (pti->IsPackage() || !hParent.IsOk())
|
275 |
|
|
{
|
276 |
|
|
wxTreeItemId h;
|
277 |
|
|
|
278 |
|
|
if (!hParent.IsOk()) // pti->GetItemNameOrMacro() == _("Configuration"))
|
279 |
|
|
h = m_treeCtrl->AddRoot(pti->GetItemNameOrMacro(), 0, -1);
|
280 |
|
|
else
|
281 |
|
|
h = m_treeCtrl->AppendItem(hParent, pti->GetItemNameOrMacro(), 0, -1);
|
282 |
|
|
|
283 |
|
|
m_treeCtrl->SetItemData(h, new ecBuildOptionsData(pti));
|
284 |
|
|
// m_Tree.SetItemImage(h,18,18);
|
285 |
|
|
for(ecConfigItem *pChild=pti->FirstChild();pChild;pChild=pChild->NextSibling()){
|
286 |
|
|
CreateItems(pChild,h);
|
287 |
|
|
}
|
288 |
|
|
}
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
void ecBuildOptionsDialog::Redisplay (wxTreeItemId item)
|
292 |
|
|
{
|
293 |
|
|
ecConfigItem *pti= ((ecBuildOptionsData*) m_treeCtrl->GetItemData(item))->GetConfigItem();
|
294 |
|
|
|
295 |
|
|
const CdlValuable valuable = pti->GetCdlValuable();
|
296 |
|
|
std::string name;
|
297 |
|
|
const CdlBuildInfo_Loadable *pe=NULL;
|
298 |
|
|
if(valuable){
|
299 |
|
|
const char *pszname=valuable->get_name().c_str();
|
300 |
|
|
for(EntriesArray::size_type j=0;j<m_arEntries.size();j++){
|
301 |
|
|
if(0==strcmp(m_arEntries[j].name.c_str(),pszname)){
|
302 |
|
|
pe=&m_arEntries[j];
|
303 |
|
|
break;
|
304 |
|
|
}
|
305 |
|
|
}
|
306 |
|
|
}
|
307 |
|
|
|
308 |
|
|
wxString strCat = ((wxChoice*) FindWindow(ecID_BUILD_OPTIONS_CATEGORY))->GetStringSelection();
|
309 |
|
|
|
310 |
|
|
const wxString strFlags=get_flags(wxGetApp().GetConfigToolDoc()->GetCdlConfig(), pe, ecUtils::UnicodeToStdStr(strCat)).c_str();
|
311 |
|
|
|
312 |
|
|
wxArrayString ar;
|
313 |
|
|
ecUtils::Chop(strFlags,ar, wxT(' '), FALSE, FALSE);
|
314 |
|
|
|
315 |
|
|
wxListBox* listBox = (wxListBox*) FindWindow( ecID_BUILD_OPTIONS_FLAGS );
|
316 |
|
|
|
317 |
|
|
wxString strEdit;
|
318 |
|
|
bool bRedraw=(listBox->GetCount() != ar.GetCount());
|
319 |
|
|
if(!bRedraw)
|
320 |
|
|
{
|
321 |
|
|
for(int i=0;i<ar.GetCount();i++){
|
322 |
|
|
wxString strOld = listBox->GetString(i);
|
323 |
|
|
|
324 |
|
|
if(strOld!=ar[i])
|
325 |
|
|
{
|
326 |
|
|
bRedraw = TRUE;
|
327 |
|
|
break;
|
328 |
|
|
}
|
329 |
|
|
}
|
330 |
|
|
}
|
331 |
|
|
if(bRedraw){
|
332 |
|
|
listBox->Clear();
|
333 |
|
|
for(int i=0;i<ar.GetCount();i++){
|
334 |
|
|
listBox->Append(ar[i]);
|
335 |
|
|
}
|
336 |
|
|
}
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
void ecBuildOptionsDialog::OnSelCategory(wxCommandEvent& event)
|
340 |
|
|
{
|
341 |
|
|
wxTreeItemId item = m_treeCtrl->GetSelection();
|
342 |
|
|
if (item.IsOk())
|
343 |
|
|
{
|
344 |
|
|
Redisplay(item);
|
345 |
|
|
}
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
void ecBuildOptionsDialog::OnSelTree(wxTreeEvent& event)
|
349 |
|
|
{
|
350 |
|
|
wxTreeItemId item = m_treeCtrl->GetSelection();
|
351 |
|
|
if (item.IsOk())
|
352 |
|
|
{
|
353 |
|
|
Redisplay(item);
|
354 |
|
|
}
|
355 |
|
|
}
|