OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [templatesdlg.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
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
// templatesdlg.cpp :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians
28
// Contact(s):  julians
29
// Date:        2000/09/27
30
// Version:     $Id: templatesdlg.cpp,v 1.10 2001/12/03 16:05:40 julians Exp $
31
// Purpose:
32
// Description: Implementation file for ecTemplatesDialog
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 "templatesdlg.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
#include "wx/cshelp.h"
62
#include "wx/valgen.h"
63
 
64
#include "configtool.h"
65
#include "configtooldoc.h"
66
#include "templatesdlg.h"
67
#include "ecutils.h"
68
 
69
BEGIN_EVENT_TABLE(ecTemplatesDialog, ecDialog)
70
    EVT_BUTTON(wxID_OK, ecTemplatesDialog::OnOK)
71
    EVT_BUTTON(wxID_CANCEL, ecTemplatesDialog::OnCancel)
72
    EVT_COMBOBOX(ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES, ecTemplatesDialog::OnSelHardwareTemplates)
73
    EVT_CHOICE(ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES, ecTemplatesDialog::OnSelPackageTemplates)
74
    EVT_CHOICE(ecID_TEMPLATES_DIALOG_VERSION, ecTemplatesDialog::OnSelPackageVersion)
75
    EVT_BUTTON(ecID_TEMPLATES_DIALOG_DETAILS, ecTemplatesDialog::OnDetails)
76
END_EVENT_TABLE()
77
 
78
// ----------------------------------------------------------------------------
79
// main frame
80
// ----------------------------------------------------------------------------
81
 
82
// Frame constructor
83
ecTemplatesDialog::ecTemplatesDialog(wxWindow* parent)
84
{
85
    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
86
 
87
    ecDialog::Create(parent, ecID_TEMPLATES_DIALOG, _("Templates"),
88
        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
89
 
90
    CreateControls(this);
91
 
92
    Centre(wxBOTH);
93
}
94
 
95
ecTemplatesDialog::~ecTemplatesDialog()
96
{
97
}
98
 
99
void ecTemplatesDialog::CreateControls(wxWindow* parent)
100
{
101
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
102
 
103
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Hardware") );
104
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
105
 
106
    wxString *strs3 = (wxString*) NULL;
107
    wxComboBox *item3 = new wxComboBox( parent, ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES, "", wxDefaultPosition, wxSize(360,-1), 0, strs3, wxCB_DROPDOWN|wxCB_READONLY|wxCB_SORT );
108
    item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
109
 
110
    wxTextCtrl *item4 = new wxTextCtrl( parent, ecID_TEMPLATES_DIALOG_HARDWARE_DESCRIPTION, _(""), wxDefaultPosition, wxSize(90,60), wxTE_MULTILINE|wxTE_READONLY );
111
    item1->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
112
 
113
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
114
 
115
    wxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
116
 
117
    wxStaticBox *item7 = new wxStaticBox( parent, -1, _("Packages") );
118
    wxSizer *item6 = new wxStaticBoxSizer( item7, wxVERTICAL );
119
 
120
    wxSizer *item8 = new wxBoxSizer( wxHORIZONTAL );
121
 
122
    wxString *strs9 = (wxString*) NULL;
123
    wxChoice *item9 = new wxChoice( parent, ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES, wxDefaultPosition, wxSize(100,-1), 0, strs9, 0 );
124
    item8->Add( item9, 20, wxALIGN_CENTRE|wxALL, 5 );
125
 
126
    wxString *strs10 = (wxString*) NULL;
127
    wxChoice *item10 = new wxChoice( parent, ecID_TEMPLATES_DIALOG_VERSION, wxDefaultPosition, wxSize(90,-1), 0, strs10, 0 );
128
    item8->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 );
129
 
130
    item6->Add( item8, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
131
 
132
    wxTextCtrl *item11 = new wxTextCtrl( parent, ecID_TEMPLATES_DIALOG_PACKAGE_DESCRIPTION, _(""), wxDefaultPosition, wxSize(110,70), wxTE_MULTILINE|wxTE_READONLY );
133
    item6->Add( item11, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
134
 
135
    item5->Add( item6, 1, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
136
 
137
    wxSizer *item12 = new wxBoxSizer( wxVERTICAL );
138
 
139
    wxButton *item13 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
140
    item12->Add( item13, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
141
 
142
    wxButton *item14 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
143
    item12->Add( item14, 0, wxALIGN_CENTRE|wxALL, 5 );
144
 
145
    item12->Add( 10, 10, 0, wxALIGN_CENTRE|wxALL, 0 );
146
 
147
    wxButton *item15 = new wxButton( parent, ecID_TEMPLATES_DIALOG_DETAILS, _("&Details >>"), wxDefaultPosition, wxDefaultSize, 0 );
148
    item12->Add( item15, 0, wxALIGN_CENTRE|wxALL, 5 );
149
 
150
    item5->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );
151
 
152
    item0->Add( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
153
 
154
    wxStaticText *item16 = new wxStaticText( parent, ecID_TEMPLATES_DIALOG_PACKAGES_MSG, _("&Packages in selected template:"), wxDefaultPosition, wxDefaultSize, 0 );
155
 
156
    wxTextCtrl *item17 = new wxTextCtrl( parent, ecID_TEMPLATES_DIALOG_PACKAGES, _(""), wxDefaultPosition, wxSize(90,100), wxTE_MULTILINE|wxTE_READONLY );
157
 
158
    // Don't add these yet (until press Details)
159
    //item0->Add( item16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
160
    //item0->Add( item17, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
161
    item16->Show(FALSE);
162
    item17->Show(FALSE);
163
 
164
#ifdef __WXGTK__
165
    wxButton *contextButton = new wxContextHelpButton( parent );
166
    item12->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
167
#endif
168
 
169
    parent->SetAutoLayout( TRUE );
170
    parent->SetSizer( item0 );
171
    parent->Layout();
172
    item0->Fit( parent );
173
    //item0->SetSizeHints( parent );
174
 
175
    // Add context-sensitive help text
176
    parent->FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES )->SetHelpText(_("Selects from the set of available hardware templates."));
177
    parent->FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_DESCRIPTION )->SetHelpText(_("Gives a brief description of the currently selected hardware template."));
178
    parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES )->SetHelpText(_("Selects from the set of available package templates."));
179
    parent->FindWindow( ecID_TEMPLATES_DIALOG_VERSION )->SetHelpText(_("Selects the version of the currently selected template."));
180
    parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_DESCRIPTION )->SetHelpText(_("Gives a brief description of the currently selected package template."));
181
    parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGES )->SetHelpText(_("Lists the packages contained in the currently selected template."));
182
    parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and saves any changes you have made."));
183
    parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Closes the dialog without saving any changes you have made."));
184
    parent->FindWindow( ecID_TEMPLATES_DIALOG_DETAILS )->SetHelpText(_("Shows or hides a portion of the dialog that provides details of the contents of the currently selected template."));
185
 
186
#if __WXGTK__
187
    parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
188
#endif
189
 
190
        // Add validators
191
        parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_DESCRIPTION )->SetValidator(wxGenericValidator(& m_strCdlTemplateDescription));
192
        parent->FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_DESCRIPTION )->SetValidator(wxGenericValidator(& m_strCdlHardwareDescription));
193
        parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGES)->SetValidator(wxGenericValidator(& m_strCdlTemplatePackages));
194
 
195
    PopulateControls();
196
}
197
 
198
// function which is called by quick sort
199
static int wxStringCompareFunction(const void *first, const void *second)
200
{
201
  wxString *strFirst = (wxString *)first;
202
  wxString *strSecond = (wxString *)second;
203
 
204
  return wxStricmp(strFirst->c_str(), strSecond->c_str());
205
}
206
 
207
void ecTemplatesDialog::PopulateControls()
208
{
209
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
210
 
211
    m_hardware = doc->GetCdlConfig ()->get_hardware ().c_str();
212
 
213
    wxComboBox* cdlHardwareCtrl = (wxComboBox*)  FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES ) ;
214
    wxChoice* cdlPackageCtrl = (wxChoice*)  FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES ) ;
215
 
216
 
217
        const std::vector<std::string> & targets = doc->GetCdlPkgData ()->get_targets ();
218
        std::vector<std::string>::const_iterator target_i;
219
 
220
    // Old code: let the combo box do the sorting. But not all platforms implement this.
221
#if 0
222
    // populate the hardware combo box
223
    int nIndex = 0;
224
        for (target_i = targets.begin (); target_i != targets.end (); target_i++)
225
        {
226
                const std::vector<std::string> & aliases = doc->GetCdlPkgData ()->get_target_aliases (* target_i);
227
 
228
                // use the first alias (if any) as the description
229
                wxString strTargetDescription = aliases.size () ? aliases [0].c_str () : target_i->c_str ();
230
                cdlHardwareCtrl->Append(strTargetDescription, (void*) &(*target_i)); // store the target iterator
231
        std::string str(* (target_i));
232
                if (m_hardware == str.c_str())            // if current target...
233
        {
234
            int sel = 0;
235
            int i;
236
            for (i = 0; i <= nIndex; i++)
237
                if (cdlHardwareCtrl->GetClientData(i) == (void*) &(*target_i))
238
                    sel = i;
239
                        cdlHardwareCtrl->SetSelection (sel); // ...select the string
240
        }
241
        nIndex ++;
242
        }
243
#else
244
    // New code: sort, then add to combobox. How do we keep track of the target iterators?
245
    // could use hash table, assuming that each string is unique
246
    wxHashTable ht(wxKEY_STRING);
247
    wxArrayString ar;
248
 
249
        for (target_i = targets.begin (); target_i != targets.end (); target_i++)
250
        {
251
                const std::vector<std::string> & aliases = doc->GetCdlPkgData ()->get_target_aliases (* target_i);
252
 
253
                // use the first alias (if any) as the description
254
                wxString strTargetDescription = aliases.size () ? aliases [0].c_str () : target_i->c_str ();
255
 
256
        ar.Add(strTargetDescription);
257
        ht.Put(strTargetDescription, (wxObject*) (void*) &(*target_i));
258
    }
259
 
260
    ar.Sort((wxArrayString::CompareFunction) & wxStringCompareFunction);
261
 
262
    int nIndex = 0;
263
 
264
    unsigned int i;
265
    for (i = 0; i < ar.GetCount(); i ++)
266
    {
267
        wxString strTargetDescription = ar[i];
268
 
269
        std::string *t_i = (std::string*) (void*) ht.Get(strTargetDescription);
270
 
271
                cdlHardwareCtrl->Append(strTargetDescription, (void*) t_i); // store the target iterator
272
        std::string str(* (t_i));
273
                if (m_hardware == str.c_str())            // if current target...
274
        {
275
            int sel = 0;
276
            int i;
277
            for (i = 0; i <= nIndex; i++)
278
                if (cdlHardwareCtrl->GetClientData(i) == (void*) &(*t_i))
279
                    sel = i;
280
                        cdlHardwareCtrl->SetSelection (sel); // ...select the string
281
        }
282
        nIndex ++;
283
        }
284
 
285
#endif
286
 
287
        if (-1 == cdlHardwareCtrl->GetSelection ()) // if no target selected...
288
                cdlHardwareCtrl->SetSelection (0);          // ...select the first one
289
 
290
        // populate the template combo box
291
        m_template = doc->GetCdlConfig ()->get_template ().c_str();
292
        const std::vector<std::string> & templates = doc->GetCdlPkgData ()->get_templates ();
293
        std::vector<std::string>::const_iterator template_i;
294
    nIndex = 0;
295
        for (template_i = templates.begin (); template_i != templates.end (); template_i++)
296
        {
297
                wxString strTemplateDescription = template_i->c_str ();
298
                cdlPackageCtrl->Append(strTemplateDescription, (void*) &(*template_i)); // store the template iterator
299
                /// m_cboCdlTemplate.SetItemData (nIndex, (DWORD) template_i); // store the template iterator
300
                std::string str(* (template_i));
301
                if (m_template == str.c_str())          // if current template...
302
                        cdlPackageCtrl->SetSelection(nIndex); // ...select the string
303
                nIndex ++;
304
        }
305
 
306
        if (-1 == cdlPackageCtrl->GetSelection()) // if no template selected...
307
                cdlPackageCtrl->SetSelection(0);          // ...select the first one
308
 
309
        // display initial target and template descriptions
310
        wxCommandEvent dummyEvent;
311
        OnSelHardwareTemplates(dummyEvent);
312
        OnSelPackageTemplates(dummyEvent);
313
 
314
        // populate the template version combo box
315
        UpdateVersionList (doc->GetTemplateVersion ());
316
}
317
 
318
void ecTemplatesDialog::OnCancel(wxCommandEvent& event)
319
{
320
    event.Skip();
321
}
322
 
323
void ecTemplatesDialog::OnOK(wxCommandEvent& event)
324
{
325
    event.Skip();
326
}
327
 
328
void ecTemplatesDialog::OnDetails(wxCommandEvent& event)
329
{
330
    wxWindow* win1 = FindWindow(ecID_TEMPLATES_DIALOG_PACKAGES);
331
 
332
    wxASSERT( win1 != NULL );
333
 
334
    bool show = !win1->IsShown();
335
 
336
    ShowDetails(show);
337
}
338
 
339
void ecTemplatesDialog::ShowDetails(bool show)
340
{
341
    wxWindow* win1 = FindWindow(ecID_TEMPLATES_DIALOG_PACKAGES);
342
    wxWindow* win2 = FindWindow(ecID_TEMPLATES_DIALOG_PACKAGES_MSG);
343
    wxButton* button = (wxButton*) FindWindow(ecID_TEMPLATES_DIALOG_DETAILS);
344
 
345
    if (show)
346
    {
347
        GetSizer()->Add( win2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
348
        GetSizer()->Add( win1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
349
        button->SetLabel("&Details <<");
350
    }
351
    else
352
    {
353
        GetSizer()->Remove(win1);
354
        GetSizer()->Remove(win2);
355
        button->SetLabel("&Details >>");
356
    }
357
    win1->Show(show);
358
    win2->Show(show);
359
 
360
    Layout();
361
    GetSizer()->Fit( this );
362
}
363
 
364
void ecTemplatesDialog::OnSelHardwareTemplates(wxCommandEvent& event)
365
{
366
    wxComboBox* cdlHardwareCtrl = (wxComboBox*)  FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES ) ;
367
    wxChoice* cdlPackageCtrl = (wxChoice*)  FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES ) ;
368
 
369
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
370
 
371
        // the target has changed so retrieve the new target description
372
        const int nIndex = cdlHardwareCtrl->GetSelection ();
373
        //std::vector<std::string>::const_iterator template_i = (std::vector<std::string>::const_iterator) cdlHardwareCtrl->GetClientData (nIndex);
374
    std::string* template_i =  (std::string*) cdlHardwareCtrl->GetClientData (nIndex);
375
        m_hardware = template_i->c_str();
376
 
377
        m_strCdlHardwareDescription = doc->GetCdlPkgData ()->get_target_description ((const wxChar*) m_hardware).c_str ();
378
        m_strCdlHardwareDescription = ecUtils::StripExtraWhitespace (m_strCdlHardwareDescription);
379
 
380
    UpdateDetails (); // display new hardware packages in details box
381
 
382
    TransferDataToWindow (); // display new target description
383
}
384
 
385
void ecTemplatesDialog::OnSelPackageTemplates(wxCommandEvent& event)
386
{
387
    wxComboBox* cdlHardwareCtrl = (wxComboBox*)  FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES ) ;
388
    wxChoice* cdlPackageCtrl = (wxChoice*)  FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES ) ;
389
 
390
        // the template has changed so update the version combo box
391
        int nIndex = cdlPackageCtrl->GetSelection ();
392
 
393
        //std::vector<std::string>::const_iterator template_i = (std::vector<std::string>::const_iterator) cdlPackageCtrl->GetClientData (nIndex);
394
    std::string *template_i = (std::string*) cdlPackageCtrl->GetClientData (nIndex);
395
        m_template = template_i->c_str();
396
 
397
        UpdateVersionList (wxT("")); // repopulate template versions combo box and select most recent version
398
}
399
 
400
void ecTemplatesDialog::OnSelPackageVersion(wxCommandEvent& event)
401
{
402
        wxString strVersion;
403
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
404
    wxChoice* cdlVersionCtrl = (wxChoice*)  FindWindow( ecID_TEMPLATES_DIALOG_VERSION ) ;
405
 
406
        strVersion = cdlVersionCtrl->GetStringSelection ();
407
 
408
        //TRACE (_T("Version '%s' selected\n"), strVersion);
409
        m_template_version = ecUtils::UnicodeToStdStr (strVersion).c_str();
410
        m_strCdlTemplateDescription = doc->GetCdlPkgData ()->get_template_description (m_template.c_str(), m_template_version.c_str()).c_str ();
411
        m_strCdlTemplateDescription = ecUtils::StripExtraWhitespace (m_strCdlTemplateDescription);
412
 
413
        UpdateDetails (); // display new template packages in details box
414
    TransferDataToWindow (); // display new template description
415
}
416
 
417
void ecTemplatesDialog::UpdateVersionList(const wxString& defaultVersion)
418
{
419
    wxComboBox* cdlHardwareCtrl = (wxComboBox*)  FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES ) ;
420
    wxChoice* cdlPackageCtrl = (wxChoice*)  FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES ) ;
421
    wxChoice* cdlVersionCtrl = (wxChoice*)  FindWindow( ecID_TEMPLATES_DIALOG_VERSION ) ;
422
 
423
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
424
 
425
        // clear the version combo box
426
        cdlVersionCtrl->Clear ();
427
 
428
        // get the template version information
429
        const std::vector<std::string>& versions = doc->GetCdlPkgData ()->get_template_versions (m_template.c_str());
430
        wxASSERT (versions.size () > 0);
431
 
432
        // add the template versions to the version combo box
433
        for (unsigned int version = 0; version < versions.size (); version++) {
434
                // TRACE (_T("Adding version '%s'\n"), CString (versions [version].c_str ()));
435
                cdlVersionCtrl->Append (versions [version].c_str ());
436
        }
437
 
438
        // select the appropriate version in the version combo box
439
        if (defaultVersion.IsEmpty()) { // if no default version specified
440
                cdlVersionCtrl->SetSelection (versions.size () - 1); // select the most recent version
441
        } else { // a default version was specified
442
                cdlVersionCtrl->SetStringSelection (defaultVersion);
443
        }
444
        wxCommandEvent dummyEvent;
445
 
446
        OnSelPackageVersion(dummyEvent);
447
 
448
        // enable the version combo box only if there are multiple versions
449
        cdlVersionCtrl->Enable (versions.size () > 1);
450
}
451
 
452
void ecTemplatesDialog::UpdateDetails()
453
{
454
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
455
 
456
        // retrieve the template and target package names
457
        const std::vector<std::string> & template_packages = doc->GetCdlPkgData ()->get_template_packages (m_template.c_str(), m_template_version.c_str());
458
        std::vector<std::string> packages = doc->GetCdlPkgData ()->get_target_packages (m_hardware.c_str());
459
        packages.insert (packages.end (), template_packages.begin (), template_packages.end ());
460
 
461
        // retrieve the zeroth (verbose) package alias for each package
462
        std::vector<std::string> aliases;
463
        unsigned int i;
464
        for (i = 0; i < packages.size (); i++)
465
        {
466
                if (doc->GetCdlPkgData ()->is_known_package (packages [i])) // if the package is installed
467
                {
468
                        aliases.push_back (doc->GetCdlPkgData ()->get_package_aliases (packages [i]) [0]);
469
                }
470
                else // package is not installed
471
                {
472
                        aliases.push_back ("Unknown package " + packages [i]);
473
                }
474
        }
475
 
476
        // sort the aliases into alphabetical order
477
        std::sort (aliases.begin (), aliases.end ());
478
 
479
        // copy the aliases into the details box
480
        m_strCdlTemplatePackages = wxT("");
481
        for (i = 0; i < aliases.size (); i++)
482
        {
483
                m_strCdlTemplatePackages += aliases [i].c_str ();
484
#ifdef __WXMSW__
485
                m_strCdlTemplatePackages += wxT("\r\n"); // add a CRLF between each alias
486
#else
487
                m_strCdlTemplatePackages += wxT("\n"); // add a LF between each alias
488
#endif
489
        }
490
        // TODO: does this work for CRLF?
491
        m_strCdlTemplatePackages.Trim (TRUE); // remove the trailing CRLF
492
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.