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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [packagesdlg.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, 2003, 2005, 2009 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
// packages :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians, jld
28
// Contact(s):  julians, jld
29
// Date:        2000/09/28
30
// Version:     $Id: packagesdlg.cpp,v 1.9 2001/12/14 17:34:03 julians Exp $
31
// Purpose:
32
// Description: Implementation file for ecPackagesDialog
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 "packagesdlg.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
#include "wx/tokenzr.h"
64
 
65
#include "configtool.h"
66
#include "packagesdlg.h"
67
#include "configtooldoc.h"
68
#include "ecutils.h"
69
 
70
BEGIN_EVENT_TABLE(ecPackagesDialog, ecDialog)
71
    EVT_BUTTON(wxID_OK, ecPackagesDialog::OnOK)
72
    EVT_BUTTON(wxID_CANCEL, ecPackagesDialog::OnCancel)
73
    EVT_BUTTON(ecID_PACKAGES_DIALOG_ADD, ecPackagesDialog::OnAdd)
74
    EVT_BUTTON(ecID_PACKAGES_DIALOG_REMOVE, ecPackagesDialog::OnRemove)
75
    EVT_LISTBOX_DCLICK(ecID_PACKAGES_DIALOG_AVAILABLE_LIST, ecPackagesDialog::OnDblClickListBox1)
76
    EVT_LISTBOX_DCLICK(ecID_PACKAGES_DIALOG_USE_LIST, ecPackagesDialog::OnDblClickListBox2)
77
    EVT_LISTBOX(ecID_PACKAGES_DIALOG_AVAILABLE_LIST, ecPackagesDialog::OnClickListBox1)
78
    EVT_LISTBOX(ecID_PACKAGES_DIALOG_USE_LIST, ecPackagesDialog::OnClickListBox2)
79
    EVT_CHOICE(ecID_PACKAGES_DIALOG_VERSION, ecPackagesDialog::OnSelectVersion)
80
    EVT_INIT_DIALOG(ecPackagesDialog::OnInitDialog)
81
    EVT_BUTTON(ecID_PACKAGES_DIALOG_CLEAR, ecPackagesDialog::OnClearKeywords)
82
    EVT_CHECKBOX(ecID_PACKAGES_DIALOG_OMIT_HARDWARE, ecPackagesDialog::OnClickOmitHardwarePackages)
83
    EVT_CHECKBOX(ecID_PACKAGES_DIALOG_EXACT_MATCH, ecPackagesDialog::OnClickExactMatch)
84
    EVT_TEXT(ecID_PACKAGES_DIALOG_KEYWORDS, ecPackagesDialog::OnUpdateKeywordText)
85
    EVT_IDLE(ecPackagesDialog::OnIdle)
86
END_EVENT_TABLE()
87
 
88
// ----------------------------------------------------------------------------
89
// main frame
90
// ----------------------------------------------------------------------------
91
 
92
// Frame constructor
93
ecPackagesDialog::ecPackagesDialog(wxWindow* parent):
94
m_timer(this)
95
{
96
    m_bHardwarePackageSelected = FALSE;
97
    m_keywords = wxEmptyString;
98
    m_updateLists = FALSE;
99
    m_updateInterval = 600; // Milliseconds
100
    wxStartTimer();
101
 
102
    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
103
 
104
    ecDialog::Create(parent, ecID_PACKAGES_DIALOG, _("Packages"),
105
        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
106
 
107
    CreateControls(this);
108
 
109
    m_timer.Start(200);
110
 
111
    Centre(wxBOTH);
112
}
113
 
114
ecPackagesDialog::~ecPackagesDialog()
115
{
116
    m_timer.Stop();
117
}
118
 
119
// TODO: implement wxLB_SORT style in wxGTK.
120
void ecPackagesDialog::CreateControls(wxWindow* parent)
121
{
122
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
123
 
124
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
125
 
126
    wxSizer *item2 = new wxBoxSizer( wxVERTICAL );
127
 
128
    wxStaticText *item3 = new wxStaticText( parent, wxID_STATIC, _("Available &packages:"), wxDefaultPosition, wxDefaultSize, 0 );
129
    item2->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
130
 
131
    wxString *strs4 = (wxString*) NULL;
132
    wxListBox *item4 = new wxListBox( parent, ecID_PACKAGES_DIALOG_AVAILABLE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs4, wxLB_SORT|wxLB_HSCROLL );
133
    item2->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
134
 
135
    item1->Add( item2, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
136
 
137
    wxSizer *item5 = new wxBoxSizer( wxVERTICAL );
138
 
139
    wxButton *item6 = new wxButton( parent, ecID_PACKAGES_DIALOG_ADD, _("&Add >>"), wxDefaultPosition, wxDefaultSize, 0 );
140
    item5->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
141
 
142
    wxButton *item7 = new wxButton( parent, ecID_PACKAGES_DIALOG_REMOVE, _("<< &Remove"), wxDefaultPosition, wxDefaultSize, 0 );
143
    item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
144
 
145
    item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 0 );
146
 
147
    wxSizer *item8 = new wxBoxSizer( wxVERTICAL );
148
 
149
    wxStaticText *item9 = new wxStaticText( parent, wxID_STATIC, _("&Use these packages:"), wxDefaultPosition, wxDefaultSize, 0 );
150
    item8->Add( item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
151
 
152
    wxString *strs10 = (wxString*) NULL;
153
    wxListBox *item10 = new wxListBox( parent, ecID_PACKAGES_DIALOG_USE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs10, wxLB_SORT|wxLB_HSCROLL );
154
    item8->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
155
 
156
    item1->Add( item8, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
157
 
158
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
159
 
160
    wxStaticText *item11 = new wxStaticText( parent, wxID_STATIC, _("&Version:"), wxDefaultPosition, wxDefaultSize, 0 );
161
    item0->Add( item11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
162
 
163
    wxString *strs12 = (wxString*) NULL;
164
    wxChoice *item12 = new wxChoice( parent, ecID_PACKAGES_DIALOG_VERSION, wxDefaultPosition, wxSize(100,-1), 0, strs12, 0 );
165
    item0->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 10 );
166
 
167
    wxTextCtrl *item13 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_DESCRIPTION, _(""), wxDefaultPosition, wxSize(80,110), wxTE_MULTILINE );
168
    item0->Add( item13, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 10 );
169
 
170
    wxStaticText *item14 = new wxStaticText( parent, wxID_STATIC, _("&Keywords:"), wxDefaultPosition, wxDefaultSize, 0 );
171
    item0->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
172
 
173
    wxSizer *item15 = new wxBoxSizer( wxHORIZONTAL );
174
 
175
    wxTextCtrl *item16 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_KEYWORDS, _(""), wxDefaultPosition, wxSize(80,-1), 0 );
176
    item15->Add( item16, 1, wxALIGN_CENTRE|wxALL, 5 );
177
 
178
    wxButton *item17 = new wxButton( parent, ecID_PACKAGES_DIALOG_CLEAR, _("C&lear"), wxDefaultPosition, wxDefaultSize, 0 );
179
    item15->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 );
180
 
181
    item0->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
182
 
183
    wxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );
184
 
185
    wxCheckBox *item19 = new wxCheckBox( parent, ecID_PACKAGES_DIALOG_OMIT_HARDWARE, _("&Omit hardware packages"), wxDefaultPosition, wxDefaultSize, 0 );
186
    item18->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 );
187
 
188
    wxCheckBox *item20 = new wxCheckBox( parent, ecID_PACKAGES_DIALOG_EXACT_MATCH, _("&Match exactly"), wxDefaultPosition, wxDefaultSize, 0 );
189
    item18->Add( item20, 0, wxALIGN_CENTRE|wxALL, 5 );
190
 
191
    item18->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
192
 
193
    wxButton *item21 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
194
    item21->SetDefault();
195
    item18->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
196
 
197
    wxButton *item22 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
198
    item18->Add( item22, 0, wxALIGN_CENTRE|wxALL, 5 );
199
 
200
    item0->Add( item18, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
201
 
202
#if 0
203
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
204
 
205
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
206
 
207
    wxSizer *item2 = new wxBoxSizer( wxVERTICAL );
208
 
209
    wxStaticText *item3 = new wxStaticText( parent, wxID_STATIC, _("Available &packages:"), wxDefaultPosition, wxDefaultSize, 0 );
210
    item2->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
211
 
212
    wxString *strs4 = (wxString*) NULL;
213
    wxListBox *item4 = new wxListBox( parent, ecID_PACKAGES_DIALOG_AVAILABLE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs4, wxLB_SORT|wxLB_HSCROLL );
214
    item2->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
215
 
216
    item1->Add( item2, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
217
 
218
    wxSizer *item5 = new wxBoxSizer( wxVERTICAL );
219
 
220
    wxButton *item6 = new wxButton( parent, ecID_PACKAGES_DIALOG_ADD, _("&Add >>"), wxDefaultPosition, wxDefaultSize, 0 );
221
    item5->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
222
 
223
    wxButton *item7 = new wxButton( parent, ecID_PACKAGES_DIALOG_REMOVE, _("<< &Remove"), wxDefaultPosition, wxDefaultSize, 0 );
224
    item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
225
 
226
    item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 0 );
227
 
228
    wxSizer *item8 = new wxBoxSizer( wxVERTICAL );
229
 
230
    wxStaticText *item9 = new wxStaticText( parent, wxID_STATIC, _("&Use these packages:"), wxDefaultPosition, wxDefaultSize, 0 );
231
    item8->Add( item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
232
 
233
    wxString *strs10 = (wxString*) NULL;
234
    wxListBox *item10 = new wxListBox( parent, ecID_PACKAGES_DIALOG_USE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs10, wxLB_SORT|wxLB_HSCROLL );
235
    item8->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
236
 
237
    item1->Add( item8, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
238
 
239
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
240
 
241
    wxStaticText *item11 = new wxStaticText( parent, wxID_STATIC, _("&Version:"), wxDefaultPosition, wxDefaultSize, 0 );
242
    item0->Add( item11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
243
 
244
    wxString *strs12 = (wxString*) NULL;
245
    wxChoice *item12 = new wxChoice( parent, ecID_PACKAGES_DIALOG_VERSION, wxDefaultPosition, wxSize(100,-1), 0, strs12, 0 );
246
    item0->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 10 );
247
 
248
    wxTextCtrl *item13 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_DESCRIPTION, _(""), wxDefaultPosition, wxSize(80,110), wxTE_MULTILINE );
249
    item0->Add( item13, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 10 );
250
 
251
    wxStaticText *item14 = new wxStaticText( parent, wxID_STATIC, _("&Keywords:"), wxDefaultPosition, wxDefaultSize, 0 );
252
    item0->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
253
 
254
    wxSizer *item15 = new wxBoxSizer( wxHORIZONTAL );
255
 
256
    wxTextCtrl *item16 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_KEYWORDS, _(""), wxDefaultPosition, wxSize(80,-1), 0 );
257
    item15->Add( item16, 1, wxALIGN_CENTRE|wxALL, 5 );
258
 
259
    wxButton *item17 = new wxButton( parent, ecID_PACKAGES_DIALOG_CLEAR, _("C&lear"), wxDefaultPosition, wxDefaultSize, 0 );
260
    item15->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 );
261
 
262
    item0->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
263
 
264
    wxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );
265
 
266
    wxCheckBox *item19 = new wxCheckBox( parent, ecID_PACKAGES_DIALOG_OMIT_HARDWARE, _("Omit hardware packages"), wxDefaultPosition, wxDefaultSize, 0 );
267
    item18->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 );
268
 
269
    item18->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
270
 
271
    wxButton *item20 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
272
    item20->SetDefault();
273
    item18->Add( item20, 0, wxALIGN_CENTRE|wxALL, 5 );
274
 
275
    wxButton *item21 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
276
    item18->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
277
 
278
    item0->Add( item18, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
279
#endif
280
 
281
#ifdef __WXGTK__
282
    wxButton *contextButton = new wxContextHelpButton( parent );
283
    item18->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
284
#endif
285
 
286
    parent->FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS )->SetFocus();
287
 
288
    parent->SetAutoLayout( TRUE );
289
    parent->SetSizer( item0 );
290
    parent->Layout();
291
    item0->Fit( parent );
292
    //item0->SetSizeHints( parent );
293
 
294
    // Add context-sensitive help text
295
    parent->FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST )->SetHelpText(_("Displays the list of packages available, but not currently loaded."));
296
    parent->FindWindow( ecID_PACKAGES_DIALOG_USE_LIST )->SetHelpText(_("Displays the list of packages currently loaded."));
297
    parent->FindWindow( ecID_PACKAGES_DIALOG_ADD )->SetHelpText(_("Add one or more packages to the list to be loaded."));
298
    parent->FindWindow( ecID_PACKAGES_DIALOG_REMOVE )->SetHelpText(_("Removes one or more packages from the list to be loaded."));
299
    parent->FindWindow( ecID_PACKAGES_DIALOG_VERSION )->SetHelpText(_("Displays the version of the selected packages."));
300
    parent->FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION )->SetHelpText(_("Displays a description of the selected package (blank if more than one package is selected)."));
301
    parent->FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS )->SetHelpText(_("Enter keywords here to restrict displayed packages."));
302
    parent->FindWindow( ecID_PACKAGES_DIALOG_CLEAR )->SetHelpText(_("Clears the keyword field."));
303
    parent->FindWindow( ecID_PACKAGES_DIALOG_OMIT_HARDWARE)->SetHelpText(_("Check this to omit hardware packages, uncheck to show all packages."));
304
    parent->FindWindow( ecID_PACKAGES_DIALOG_EXACT_MATCH )->SetHelpText(_("Check this to display exact matches between keyword and aliases (case insensitive)."));
305
    parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and saves any changes you have made."));
306
    parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Closes the dialog without saving any changes you have made."));
307
 
308
#if __WXGTK__
309
    parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
310
#endif
311
 
312
    // Add validators
313
    parent->FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION )->SetValidator(wxGenericValidator(& m_packageDescription));
314
    parent->FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS )->SetValidator(wxGenericValidator(& m_keywords));
315
    parent->FindWindow( ecID_PACKAGES_DIALOG_OMIT_HARDWARE )->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_omitHardwarePackages));
316
    parent->FindWindow( ecID_PACKAGES_DIALOG_EXACT_MATCH )->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_matchPackageNamesExactly));
317
}
318
 
319
void ecPackagesDialog::OnInitDialog(wxInitDialogEvent& event)
320
{
321
    // Note: InitControls must be here, because data will be added
322
    // between construction of the dialog, and OnInitDialog.
323
    InitControls();
324
    TransferDataToWindow();
325
}
326
 
327
void ecPackagesDialog::InitControls()
328
{
329
    Fill();
330
}
331
 
332
void ecPackagesDialog::OnCancel(wxCommandEvent& event)
333
{
334
    event.Skip();
335
}
336
 
337
void ecPackagesDialog::OnOK(wxCommandEvent& event)
338
{
339
    TransferDataFromWindow();
340
    event.Skip();
341
}
342
 
343
// For each word in keywords, is it contained in 'str'?
344
bool ecPackagesDialog::MatchesKeyword(wxArrayString& keywords, const wxString& str)
345
{
346
    // _Every_ keyword must match
347
    size_t i;
348
    for (i = 0; i < keywords.GetCount(); i++)
349
    {
350
        if (str.Find(keywords[i]) == -1)
351
            return FALSE;
352
    }
353
    return TRUE;
354
}
355
 
356
void ecPackagesDialog::Fill()
357
{
358
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
359
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
360
    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();
361
 
362
    // wxGTK doesn't deselect items properly when clearing, I think
363
    int i;
364
    for (i = 0; i < availableList->GetCount(); i++)
365
        if (availableList->Selected(i))
366
            availableList->Deselect(i);
367
    for (i = 0; i < useList->GetCount(); i++)
368
        if (useList->Selected(i))
369
            useList->Deselect(i);
370
 
371
    availableList->Clear();
372
    useList->Clear();
373
    ClearDescription();
374
 
375
    wxString s2(m_keywords);
376
    s2.MakeLower();
377
 
378
    // Tokenize
379
    wxArrayString keywords;
380
    wxStringTokenizer tok(s2);
381
    while (tok.HasMoreTokens())
382
    {
383
        keywords.Add(tok.GetNextToken());
384
    }
385
 
386
    // Initialize the controls
387
    for (i = 0; i < GetCount(); i++)
388
    {
389
        const wxString& str = m_items[i];
390
        wxListBox* lb = m_arnItems[i] ? useList : availableList;
391
 
392
        wxString macroName(pDoc->GetPackageName (str));
393
 
394
        // check if the package is a hardware package
395
 
396
        if ((!wxGetApp().GetSettings().m_omitHardwarePackages) || !pDoc->GetCdlPkgData ()->is_hardware_package (ecUtils::UnicodeToStdStr (macroName)))
397
        {
398
            bool matches = TRUE;
399
 
400
            if (!m_keywords.IsEmpty())
401
            {
402
                // Descriptive name
403
                wxString s1(str);
404
                s1.MakeLower();
405
 
406
                // macro name
407
                wxString s3(macroName);
408
                s3.MakeLower();
409
 
410
                // Match all aliases
411
                const std::vector<std::string> & aliases = pDoc->GetCdlPkgData ()->get_package_aliases (ecUtils::UnicodeToStdStr (macroName));
412
 
413
                if (wxGetApp().GetSettings().m_matchPackageNamesExactly)
414
                {
415
                    int noMatches = 0;
416
 
417
                    if (s2 == s1 || s2 == s3)
418
                        noMatches ++;
419
 
420
                    size_t j;
421
                    for (j = 0; j < aliases.size(); j ++)
422
                    {
423
                        wxString alias(aliases[j].c_str());
424
                        alias.MakeLower();
425
                        if (s2 == alias)
426
                            noMatches ++;
427
                    }
428
 
429
                    matches = (noMatches > 0);
430
 
431
                }
432
                else
433
                {
434
                    // Concatenate all possible text together, and match against that
435
                    wxString toMatch;
436
 
437
                    toMatch += s1;
438
 
439
                    toMatch += s3;
440
 
441
                    size_t j;
442
                    for (j = 0; j < aliases.size(); j ++)
443
                    {
444
                        wxString alias(aliases[j].c_str());
445
                        alias.MakeLower();
446
                        toMatch += alias;
447
                    }
448
 
449
                    matches = MatchesKeyword(keywords, toMatch);
450
                }
451
            }
452
 
453
            if (matches)
454
                lb->Append(str, (void*) i);
455
        }
456
    }
457
 
458
    UpdateAddRemoveButtons();
459
 
460
    if (availableList->GetCount() == 1)
461
    {
462
        availableList->SetSelection(0);
463
        UpdatePackageDescription();
464
        UpdateVersionList ();
465
        UpdateHardwareSelectionFlag ();
466
    }
467
    else if (useList->GetCount() == 1)
468
    {
469
        useList->SetSelection(0);
470
        UpdatePackageDescription();
471
        UpdateVersionList ();
472
        UpdateHardwareSelectionFlag ();
473
    }
474
    wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS );
475
    // Necessary or TransferDataToWindow will cause insertion position to change
476
    textCtrl->SetInsertionPointEnd();
477
}
478
 
479
void ecPackagesDialog::Add(wxListBox* from, wxListBox* to)
480
{
481
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
482
 
483
    wxArrayInt selections;
484
    wxStringList selectionsStrings;
485
    int n = from -> GetSelections( selections );
486
 
487
    if (n > 0)
488
    {
489
        int i;
490
        for (i = 0; i < selections.GetCount(); i++)
491
        {
492
            wxString str = from -> GetString(selections[i]);
493
            selectionsStrings.Add(str);
494
        }
495
 
496
        // Now delete from one list and remove from t'other
497
#if wxCHECK_VERSION(2, 6, 0)
498
        for (i = 0; i < selectionsStrings.GetCount(); i++)
499
#else
500
        for (i = 0; i < selectionsStrings.Number(); i++)
501
#endif
502
        {
503
            wxString str = selectionsStrings[i];
504
 
505
            // Remove
506
            int toDelete =  from -> FindString(str);
507
            int itemIndex = -1;
508
            if (toDelete > -1)
509
            {
510
                itemIndex = (int) from -> GetClientData(toDelete);
511
                from -> Delete(toDelete);
512
            }
513
 
514
            wxASSERT (itemIndex > -1);
515
 
516
            // Add
517
            to -> Append(str, (void*) itemIndex);
518
 
519
            if (to == useList)
520
            {
521
                m_added.Add(str);
522
            }
523
            else
524
            {
525
                m_added.Remove(str);
526
            }
527
 
528
            // Select it
529
            int addedIndex = to->FindString(str);
530
            to->Select(addedIndex);
531
 
532
        }
533
        //ClearDescription();
534
        ClearSelections(* from);
535
        UpdateHardwareSelectionFlag();
536
        UpdatePackageDescription();
537
        to->SetFocus();
538
    }
539
}
540
 
541
void ecPackagesDialog::OnAdd(wxCommandEvent& event)
542
{
543
    if (m_bHardwarePackageSelected)
544
    {
545
        HardwarePackageMessageBox ();
546
        return;
547
    }
548
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
549
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
550
 
551
    Add(availableList, useList);
552
 
553
    UpdateAddRemoveButtons();
554
}
555
 
556
void ecPackagesDialog::OnRemove(wxCommandEvent& event)
557
{
558
    if (m_bHardwarePackageSelected)
559
    {
560
        HardwarePackageMessageBox ();
561
        return;
562
    }
563
 
564
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
565
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
566
 
567
    Add(useList, availableList);
568
 
569
    UpdateAddRemoveButtons();
570
}
571
 
572
void ecPackagesDialog::OnDblClickListBox1(wxCommandEvent& event)
573
{
574
    if (m_bHardwarePackageSelected)
575
    {
576
        HardwarePackageMessageBox ();
577
        return;
578
    }
579
 
580
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
581
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
582
 
583
    Add(availableList, useList);
584
 
585
    UpdateAddRemoveButtons();
586
}
587
 
588
void ecPackagesDialog::OnDblClickListBox2(wxCommandEvent& event)
589
{
590
    if (m_bHardwarePackageSelected)
591
    {
592
        HardwarePackageMessageBox ();
593
        return;
594
    }
595
 
596
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
597
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
598
 
599
    Add(useList, availableList);
600
 
601
    UpdateAddRemoveButtons();
602
}
603
 
604
void ecPackagesDialog::OnClickListBox1(wxCommandEvent& event)
605
{
606
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
607
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
608
 
609
#if 0    
610
    int sel = event.GetSelection();
611
    if (sel > -1)
612
    {
613
        // TODO: check that this works for multiple-selection listboxes
614
        DisplayDescription(availableList->GetString(sel));
615
    }
616
#endif
617
 
618
    ClearSelections(*useList);
619
    UpdatePackageDescription ();
620
    UpdateVersionList ();
621
    UpdateHardwareSelectionFlag ();
622
    UpdateAddRemoveButtons();
623
}
624
 
625
void ecPackagesDialog::OnClickListBox2(wxCommandEvent& event)
626
{
627
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
628
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
629
 
630
#if 0    
631
    int sel = event.GetSelection();
632
    if (sel > -1)
633
    {
634
        // TODO: check that this works for multiple-selection listboxes
635
        DisplayDescription(useList->GetString(sel));
636
    }
637
#endif
638
 
639
    ClearSelections(*availableList);
640
    UpdatePackageDescription ();
641
    UpdateVersionList ();
642
    UpdateHardwareSelectionFlag ();
643
    UpdateAddRemoveButtons();
644
}
645
 
646
void ecPackagesDialog::OnSelectVersion(wxCommandEvent& event)
647
{
648
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
649
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
650
    wxChoice* versionChoice = (wxChoice*) FindWindow( ecID_PACKAGES_DIALOG_VERSION );
651
 
652
    if (-1 == versionChoice->GetSelection ()) // if there is no version selection
653
        return; // do nothing
654
 
655
    wxListBox * pListBox = NULL;
656
 
657
    wxArrayInt selected1, selected2;
658
    availableList->GetSelections(selected1);
659
    useList->GetSelections(selected2);
660
 
661
    int nListSelCount = selected1.GetCount ();
662
    if (nListSelCount > 0)
663
    {
664
        pListBox = availableList;
665
    }
666
    else
667
    {
668
        nListSelCount = selected2.GetCount ();
669
        if (nListSelCount)
670
            pListBox = useList;
671
    }
672
 
673
    wxASSERT (pListBox);
674
 
675
    if (!pListBox)
676
        return;
677
 
678
    // retrieve the list box indices of the selected packages
679
 
680
    wxArrayInt* selected = (pListBox == availableList ? & selected1 : & selected2);
681
 
682
    int nIndex;
683
    for (nIndex = 0; nIndex < nListSelCount; nIndex++) // for each selected package
684
    {
685
        // set the package version to that specified in the version combo box
686
        wxString str = versionChoice->GetString(versionChoice->GetSelection());
687
 
688
        // itemIndex is the index into the list of item names. It gets stored with all the listbox items.
689
        int itemIndex = (int) pListBox->GetClientData((*selected)[nIndex]);
690
        m_currentVersions[(size_t)itemIndex] = str;
691
    }
692
}
693
 
694
void ecPackagesDialog::OnClearKeywords(wxCommandEvent& event)
695
{
696
    wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS );
697
    textCtrl->SetValue(wxT(""));
698
    TransferDataFromWindow();
699
    Fill();
700
    m_updateLists = FALSE;
701
    wxStartTimer();
702
    FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS )->SetFocus();
703
}
704
 
705
void ecPackagesDialog::OnUpdateKeywordText(wxCommandEvent& event)
706
{
707
    // Work around a bug in GTK+ that sends a text update command when
708
    // clicking on one of the listboxes.
709
    wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS );
710
    wxString value = textCtrl->GetValue();
711
    if (value == m_keywords)
712
        return;
713
 
714
    TransferDataFromWindow();
715
    m_updateLists = TRUE;
716
    wxStartTimer();
717
}
718
 
719
void ecPackagesDialog::OnClickOmitHardwarePackages(wxCommandEvent& event)
720
{
721
    TransferDataFromWindow();
722
    Fill();
723
}
724
 
725
void ecPackagesDialog::OnClickExactMatch(wxCommandEvent& event)
726
{
727
    TransferDataFromWindow();
728
    Fill();
729
}
730
 
731
void ecPackagesDialog::OnIdle(wxIdleEvent& event)
732
{
733
    long elapsed = wxGetElapsedTime(FALSE);
734
    if (m_updateLists && (elapsed > m_updateInterval))
735
    {
736
        m_updateLists = FALSE;
737
        Fill();
738
        wxStartTimer();
739
    }
740
}
741
 
742
void ecPackagesDialog::Insert(const wxString& str, bool added, const wxString& descr, const wxString& version)
743
{
744
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
745
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
746
 
747
    m_items.Add(str);
748
    m_descriptions.Add(str);
749
    m_currentVersions.Add(version);
750
    m_arnItems.Add(added);
751
 
752
    if (added)
753
        m_added.Add(str);
754
 
755
    //(added ? useList : availableList) -> Append(str);
756
}
757
 
758
bool ecPackagesDialog::IsAdded(const wxString& str)
759
{
760
    return (m_added.Index(str) != wxNOT_FOUND);
761
 
762
    //  return (((wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST ))->FindString(str) > -1) ;
763
}
764
 
765
static int ecPositionInStringList(const wxStringList& list, const wxString& item)
766
{
767
    int i;
768
    for (i = 0 ; i < list.GetCount(); i++)
769
        if (list[i] == item)
770
            return i;
771
        else
772
            i ++;
773
        return -1;
774
}
775
 
776
void ecPackagesDialog::DisplayDescription(const wxString& item)
777
{
778
    //wxTextCtrl* descrCtrl = (wxTextCtrl*) FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION ) ;
779
    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();
780
 
781
    //    int pos = ecPositionInStringList(m_items, item);
782
    //    if (pos > -1)
783
    {
784
        wxString text;
785
        //        wxString descr = m_descriptions[pos];
786
        //        text += descr;
787
        //        text += wxT("\n");
788
 
789
        wxString macroName(pDoc->GetPackageName (item));
790
 
791
        // Match all aliases
792
        const std::vector<std::string> & aliases = pDoc->GetCdlPkgData ()->get_package_aliases (ecUtils::UnicodeToStdStr (macroName));
793
 
794
        size_t j;
795
        for (j = 0; j < aliases.size(); j ++)
796
        {
797
            if (j == 1)
798
                text += wxT(".\nAliases: ");
799
            else if (j > 1)
800
                text += wxT(", ");
801
 
802
            wxString alias(aliases[j].c_str());
803
            text += alias;
804
        }
805
        text += wxT("\nMacro: ");
806
        text += macroName;
807
        text += wxT("\n\n");
808
 
809
        wxString descr = pDoc->GetCdlPkgData ()->get_package_description (ecUtils::UnicodeToStdStr (macroName)).c_str ();
810
 
811
        text += ecUtils::StripExtraWhitespace (descr);
812
 
813
        m_packageDescription = text;
814
 
815
        //descrCtrl->SetValue(text);
816
    }
817
}
818
 
819
void ecPackagesDialog::ClearDescription()
820
{
821
    wxTextCtrl* descrCtrl = (wxTextCtrl*) FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION ) ;
822
    descrCtrl->SetValue(wxEmptyString);
823
}
824
 
825
wxString ecPackagesDialog::GetVersion (const wxString& item)
826
{
827
    int nCount;
828
    for (nCount = GetCount() - 1; nCount >= 0; --nCount)
829
    {
830
        if (m_items [nCount] == item)
831
        {
832
            return m_currentVersions [nCount];
833
        }
834
    }
835
    wxASSERT (FALSE);
836
    return wxEmptyString;
837
}
838
 
839
void ecPackagesDialog::UpdateHardwareSelectionFlag()
840
{
841
    m_bHardwarePackageSelected = FALSE;
842
 
843
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
844
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
845
    wxListBox * pListBox = NULL;
846
 
847
    wxArrayInt selections1, selections2;
848
    wxArrayInt* selections = NULL;
849
    availableList->GetSelections(selections1);
850
    useList->GetSelections(selections2);
851
 
852
    int nListSelCount = selections1.GetCount ();
853
    if (nListSelCount)
854
    {
855
        pListBox = availableList;
856
        selections = & selections1;
857
    }
858
    else
859
    {
860
        nListSelCount = selections2.GetCount ();
861
        if (nListSelCount)
862
        {
863
            pListBox = useList;
864
            selections = & selections2;
865
        }
866
    }
867
 
868
    if (pListBox) // if there are packages selected
869
    {
870
        ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();
871
 
872
        // retrieve the list box indices of the selected packages
873
 
874
        //int * arnIndices = new int [nListSelCount];
875
        //pListBox->GetSelItems (nListSelCount, arnIndices);
876
 
877
        int nIndex;
878
        for (nIndex = 0; nIndex < nListSelCount; nIndex++) // for each selected package
879
        {
880
            wxString strPackageAlias = pListBox->GetString((*selections)[nIndex]);
881
 
882
            // check if the package is a hardware package
883
 
884
            //TRACE (_T("Checking '%s' for hardware status\n"), strPackageAlias);
885
            if (pDoc->GetCdlPkgData ()->is_hardware_package (ecUtils::UnicodeToStdStr (pDoc->GetPackageName (strPackageAlias))))
886
            {
887
                m_bHardwarePackageSelected = TRUE;
888
                break;
889
            }
890
        }
891
    }
892
}
893
 
894
void ecPackagesDialog::HardwarePackageMessageBox()
895
{
896
    // TODO: could give the user the choice of going to the template dialog.
897
    wxMessageBox (wxT("Add and remove hardware packages by selecting a new hardware template."),
898
        wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);
899
}
900
 
901
void ecPackagesDialog::UpdatePackageDescription ()
902
{
903
    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();
904
 
905
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
906
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
907
 
908
    wxListBox * pListBox = NULL;
909
 
910
    wxArrayInt selections1, selections2;
911
    wxArrayInt* selections = NULL;
912
    availableList->GetSelections(selections1);
913
    useList->GetSelections(selections2);
914
 
915
    if (1 == selections1.GetCount ())
916
    {
917
        pListBox = availableList;
918
        selections = & selections1;
919
    }
920
    else if (1 == selections2.GetCount ())
921
    {
922
        pListBox = useList;
923
        selections = & selections2;
924
    }
925
 
926
    if (pListBox && selections)
927
    {
928
        int nIndex = (*selections)[0];
929
        wxString strPackageAlias = pListBox->GetString(nIndex);
930
 
931
        DisplayDescription(strPackageAlias);
932
        //m_packageDescription = pDoc->GetCdlPkgData ()->get_package_description (ecUtils::UnicodeToStdStr (pDoc->GetPackageName (strPackageAlias))).c_str ();
933
        //m_packageDescription = ecUtils::StripExtraWhitespace (m_packageDescription);
934
    }
935
    else
936
    {
937
        m_packageDescription = wxEmptyString;
938
    }
939
    TransferDataToWindow ();
940
}
941
 
942
void ecPackagesDialog::UpdateVersionList ()
943
{
944
    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();
945
 
946
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
947
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
948
    wxChoice* versionChoice = (wxChoice*) FindWindow( ecID_PACKAGES_DIALOG_VERSION );
949
 
950
    versionChoice->Clear(); // clear the version combo box
951
 
952
    wxArrayInt selections1, selections2;
953
    wxArrayInt* selections = NULL;
954
    availableList->GetSelections(selections1);
955
    useList->GetSelections(selections2);
956
    wxListBox* pListBox = NULL;
957
 
958
    if (selections1.GetCount () > 0)
959
    {
960
        pListBox = availableList;
961
        selections = & selections1;
962
    }
963
    else if (selections2.GetCount () > 0)
964
    {
965
        pListBox = useList;
966
        selections = & selections2;
967
    }
968
 
969
    if (pListBox) // if there are packages selected
970
    {
971
        std::list<std::string> common_versions;
972
        bool bCommonSelectedVersion = true;
973
        int nCommonVersionIndex=-1;
974
        int nListSelCount = selections->GetCount();
975
 
976
        // retrieve the list box indices of the selected packages
977
 
978
        //int * arnIndices = new int [nListSelCount];
979
        //pListBox->GetSelItems (nListSelCount, arnIndices);
980
        int nIndex;
981
        for (nIndex = 0; nIndex < nListSelCount; nIndex++) // for each selected package
982
        {
983
            // retrieve the first package alias
984
            wxString strPackageAlias = pListBox->GetString ((*selections)[nIndex]);
985
 
986
            // retrieve the dialog item array index for use in
987
            // comparing current version strings
988
            const int nVersionIndex = (int) pListBox->GetClientData ((*selections)[nIndex]);
989
 
990
            // retrieve the installed version array
991
 
992
            //TRACE (_T("Retrieving versions for '%s'\n"), strPackageAlias);
993
            const std::vector<std::string>& versions = pDoc->GetCdlPkgData ()->get_package_versions (ecUtils::UnicodeToStdStr (pDoc->GetPackageName (strPackageAlias)));
994
 
995
            if (0 == nIndex) // if this is the first selected package
996
            {
997
                // use the version array to initialise a linked list of version
998
                // strings held in common between the selected packages
999
                unsigned int uCount;
1000
                for (uCount = 0; uCount < versions.size (); uCount++)
1001
                {
1002
                    //TRACE (_T("Adding common version '%s'\n"), wxString (versions [uCount].c_str ()));
1003
                    common_versions.push_back (versions [uCount]);
1004
                }
1005
                nCommonVersionIndex = nVersionIndex; // save the item array index
1006
            }
1007
            else // this is not the first selected package
1008
            {
1009
                std::list<std::string>::iterator i_common_versions = common_versions.begin ();
1010
                while (i_common_versions != common_versions.end ()) // iterate through the common versions
1011
                {
1012
                    if (versions.end () == std::find (versions.begin (), versions.end (), * i_common_versions)) // if the common version is not in the versions list
1013
                    {
1014
                        //TRACE (_T("Removing common version '%s'\n"), CString (i_common_versions->c_str ()));
1015
                        common_versions.erase (i_common_versions++); // remove the version from the common versions list
1016
                    }
1017
                    else
1018
                    {
1019
                        i_common_versions++;
1020
                    }
1021
                }
1022
                if (bCommonSelectedVersion) // if the selected versions of all preceding packages are identical
1023
                {
1024
                    // check if the selected version of this package matches that of the preceding ones
1025
                    bCommonSelectedVersion = (m_currentVersions [nVersionIndex] == m_currentVersions [nCommonVersionIndex]);
1026
                }
1027
            }
1028
        }
1029
 
1030
        // add the common versions to the version combo box
1031
 
1032
        std::list<std::string>::iterator i_common_versions;
1033
        for (i_common_versions = common_versions.begin (); i_common_versions != common_versions.end (); i_common_versions++)
1034
        {
1035
            //TRACE (_T("Adding version '%s'\n"), CString (i_common_versions->c_str ()));
1036
            versionChoice->Append(wxString (i_common_versions->c_str ()));
1037
        }
1038
 
1039
        // select the common current version (if any) in the version combo box
1040
 
1041
        if (bCommonSelectedVersion)
1042
        {
1043
            //TRACE (_T("Selecting version '%s'\n"), m_arstrVersions [nCommonVersionIndex]);
1044
            versionChoice->SetStringSelection (m_currentVersions [nCommonVersionIndex]);
1045
        }
1046
 
1047
        // enable the version combo box only if there are multiple common versions
1048
 
1049
        versionChoice->Enable (common_versions.size () > 1);
1050
    }
1051
    else // there are no packages selected
1052
    {
1053
        versionChoice->Enable (FALSE); // disable the version combo box
1054
    }
1055
}
1056
 
1057
void ecPackagesDialog::UpdateAddRemoveButtons()
1058
{
1059
    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );
1060
    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );
1061
 
1062
    wxArrayInt selections1, selections2;
1063
    availableList->GetSelections(selections1);
1064
    useList->GetSelections(selections2);
1065
 
1066
    FindWindow( ecID_PACKAGES_DIALOG_ADD )->Enable( selections1.GetCount() > 0 );
1067
    FindWindow( ecID_PACKAGES_DIALOG_REMOVE )->Enable( selections2.GetCount() > 0 );
1068
}
1069
 
1070
void ecPackagesDialog::ClearSelections(wxListBox& lbox)
1071
{
1072
    int i;
1073
    for (i = 0; i < lbox.GetCount(); i++)
1074
    {
1075
        lbox.Deselect(i);
1076
    }
1077
}
1078
 
1079
void ecPackagesTimer::Notify()
1080
{
1081
    static bool s_inNotify = FALSE;
1082
 
1083
    if (s_inNotify)
1084
        return;
1085
 
1086
    s_inNotify = TRUE;
1087
 
1088
    // On Windows, simply having the timer going will ping the message queue
1089
    // and cause idle processing to happen.
1090
    // On Unix, this doesn't happen so we have to do the processing explicitly.
1091
#ifdef __WXMSW__
1092
    // Nothing to do
1093
#else
1094
    if ( m_dialog )
1095
    {
1096
        wxIdleEvent event;
1097
        m_dialog->OnIdle(event);
1098
    }
1099
#endif
1100
 
1101
    s_inNotify = FALSE;
1102
}

powered by: WebSVN 2.1.0

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