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

Subversion Repositories openrisc

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

Go to most recent revision | 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, 2005, 2008, 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
// appsettings.cpp :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians, jld
28
// Contact(s):  julians, jld
29
// Date:        2000/09/11
30
// Version:     $Id: settingsdlg.cpp,v 1.16 2002/02/15 17:40:01 julians Exp $
31
// Purpose:
32
// Description: Implementation file for ecSettingsDialog
33
// Requires:
34
// Provides:
35
// See also:
36
// Known bugs:
37
// Usage:
38
//
39
//####DESCRIPTIONEND####
40
//
41
//===========================================================================
42
 
43
#ifdef __GNUG__
44
    #pragma implementation "settingsdlg.cpp"
45
#endif
46
 
47
#include "ecpch.h"
48
 
49
#ifdef __BORLANDC__
50
    #pragma hdrstop
51
#endif
52
 
53
#include "wx/spinctrl.h"
54
#include "wx/notebook.h"
55
#include "wx/cshelp.h"
56
#include "wx/valgen.h"
57
#include "wx/fontdlg.h"
58
#include "wx/mimetype.h"
59
 
60
#include "settingsdlg.h"
61
#include "configtool.h"
62
#include "configtooldoc.h"
63
#include "configtoolview.h"
64
 
65
// For now, we're not implementing the paths page on the settings dialog,
66
// but probably we should eventually for consistency and ease of use
67
#define ecUSE_PATHS_PAGE 0
68
 
69
#define ecUSE_RUN_PAGE 1
70
 
71
/*
72
 * Settings dialog
73
 */
74
 
75
IMPLEMENT_CLASS(ecSettingsDialog, wxDialog)
76
 
77
BEGIN_EVENT_TABLE(ecSettingsDialog, wxDialog)
78
    EVT_BUTTON(wxID_OK, ecSettingsDialog::OnOK)
79
    EVT_BUTTON(wxID_HELP, ecSettingsDialog::OnHelp)
80
    EVT_NOTEBOOK_PAGE_CHANGED(-1, ecSettingsDialog::OnPageChange)
81
END_EVENT_TABLE()
82
 
83
// GTK+ widgets seem to be chunkier than WIN32's, so give 'em more elbow-room
84
 
85
#ifdef __WXMSW__
86
#define PROPERTY_DIALOG_WIDTH   380
87
#define PROPERTY_DIALOG_HEIGHT  420
88
#else
89
#define PROPERTY_DIALOG_WIDTH   550 // 460
90
#define PROPERTY_DIALOG_HEIGHT  480
91
#endif
92
 
93
// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
94
// (209 x 162 dialog units)
95
 
96
ecSettingsDialog::ecSettingsDialog(wxWindow* parent):
97
    wxDialog()
98
{
99
    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
100
 
101
    wxDialog::Create(parent, ecID_SETTINGS_DIALOG, wxGetApp().GetSettings().GetAppName() + wxT(" Settings"), wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT));
102
 
103
    // Under MSW, we don't seem to be able to react to a click on the dialog background (no
104
    // event is generated).
105
    SetHelpText(_("The settings dialog provides the ability to change a variety of settings."));
106
 
107
    wxScreenDC dc;
108
    wxSize ppi = dc.GetPPI();
109
 
110
    //double scaleFactor = ((double) charH) / 13.0;
111
    double scaleFactor = ((double) ppi.y) / 96.0;
112
    // Fudge the scale factor to make the dialog slightly smaller,
113
    // otherwise it's a bit big. (We're assuming that most displays
114
    // are 96 or 120 ppi).
115
    if (ppi.y == 120)
116
        scaleFactor = 1.14;
117
    int dialogWidth = (int)(PROPERTY_DIALOG_WIDTH * scaleFactor);
118
    int dialogHeight = (int)(PROPERTY_DIALOG_HEIGHT * scaleFactor);
119
    SetSize(dialogWidth, dialogHeight);
120
 
121
    m_displayOptions = NULL;
122
 
123
    wxSize clientSize = GetClientSize();
124
    m_notebook = new wxNotebook(this, ecID_SETTINGS_NOTEBOOK,
125
         wxPoint(2, 2), wxSize(clientSize.GetWidth() - 4 - 10, clientSize.GetHeight() - 4 - 100));
126
 
127
    m_displayOptions = new ecDisplayOptionsDialog(m_notebook);
128
    m_notebook->AddPage(m_displayOptions, wxT("Display"));
129
    m_displayOptions->TransferDataToWindow();
130
 
131
    m_viewerOptions = new ecViewerOptionsDialog(m_notebook);
132
    m_notebook->AddPage(m_viewerOptions, wxT("Viewers"));
133
    m_viewerOptions->TransferDataToWindow();
134
 
135
#if ecUSE_PATHS_PAGE
136
    m_pathOptions = new ecPathOptionsDialog(m_notebook);
137
    m_notebook->AddPage(m_pathOptions, wxT("Paths"));
138
    m_pathOptions->TransferDataToWindow();
139
#endif
140
 
141
    m_conflictResolutionOptions = new ecConflictResolutionOptionsDialog(m_notebook);
142
    m_notebook->AddPage(m_conflictResolutionOptions, wxT("Conflict Resolution"));
143
    m_conflictResolutionOptions->TransferDataToWindow();
144
 
145
#if ecUSE_RUN_PAGE
146
    m_runOptions = new ecRunOptionsDialog(m_notebook);
147
    m_notebook->AddPage(m_runOptions, wxT("Run Tests"));
148
    m_runOptions->TransferDataToWindow();
149
#endif
150
 
151
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
152
 
153
    item0->Add( m_notebook, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
154
 
155
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
156
 
157
    wxButton *okButton = new wxButton( this, wxID_OK, "&OK", wxDefaultPosition, wxDefaultSize, 0 );
158
    item1->Add( okButton, 0, wxALIGN_CENTRE|wxALL, 5 );
159
 
160
    wxButton *cancelButton = new wxButton( this, wxID_CANCEL, "&Cancel", wxDefaultPosition, wxDefaultSize, 0 );
161
    item1->Add( cancelButton, 0, wxALIGN_CENTRE|wxALL, 5 );
162
 
163
    wxButton *helpButton = new wxButton( this, wxID_HELP, "&Help", wxDefaultPosition, wxDefaultSize, 0 );
164
    item1->Add( helpButton, 0, wxALIGN_CENTRE|wxALL, 5 );
165
 
166
#ifdef __WXGTK__
167
    // Context-sensitive help button (question mark)
168
    wxButton *contextButton = new wxContextHelpButton( this );
169
    item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
170
#endif
171
 
172
    // Necessary to add a spacer or the button highlight interferes with the notebook under wxGTK
173
    item0->Add( 4, 4, 0, wxALIGN_CENTRE|wxALL, 0 );
174
 
175
    item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
176
 
177
    this->SetAutoLayout( TRUE );
178
    this->SetSizer( item0 );
179
 
180
    okButton->SetDefault();
181
    okButton->SetFocus();
182
 
183
    Layout();
184
 
185
    m_displayOptions->Layout();
186
    m_viewerOptions->Layout();
187
#if ecUSE_PATHS_PAGE
188
    m_pathOptions->Layout();
189
#endif
190
    m_conflictResolutionOptions->Layout();
191
#if ecUSE_RUN_PAGE
192
    m_runOptions->Layout();
193
#endif
194
 
195
    okButton->SetHelpText(_("Closes the dialog and saves any changes you may have made."));
196
    cancelButton->SetHelpText(_("Closes the dialog without saving any changes you have made."));
197
    helpButton->SetHelpText(_("Invokes help for the selected dialog."));
198
 
199
    Centre(wxBOTH);
200
}
201
 
202
void ecSettingsDialog::SetSelection(int sel)
203
{
204
    m_notebook->SetSelection(sel);
205
}
206
 
207
void ecSettingsDialog::OnOK(wxCommandEvent& event)
208
{
209
    ecSettings oldSettings(wxGetApp().GetSettings());
210
 
211
    TransferDataFromWindow();
212
 
213
    if (wxGetApp().GetSettings().m_bHex != oldSettings.m_bHex)
214
    {
215
        // Refresh the values window and currently selected properties
216
        ecConfigToolHint hint(NULL, ecAllSaved);
217
        if (wxGetApp().GetConfigToolDoc())
218
            wxGetApp().GetConfigToolDoc()->UpdateAllViews (NULL, & hint);
219
    }
220
 
221
    if (wxGetApp().GetSettings().m_showMacroNames != oldSettings.m_showMacroNames)
222
    {
223
        ecConfigToolHint hint(NULL, ecNameFormatChanged);
224
        if (wxGetApp().GetConfigToolDoc())
225
            wxGetApp().GetConfigToolDoc()->UpdateAllViews (NULL, & hint);
226
    }
227
 
228
    event.Skip();
229
}
230
 
231
void ecSettingsDialog::OnHelp(wxCommandEvent& event)
232
{
233
    int sel = m_notebook->GetSelection();
234
 
235
    wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));
236
 
237
    wxWindow* page = (wxWindow*) m_notebook->GetPage(sel);
238
 
239
    wxString helpTopic;
240
    if (page == m_displayOptions)
241
    {
242
        helpTopic = wxT("Display options dialog");
243
    }
244
 
245
    if (!helpTopic.IsEmpty())
246
    {
247
        wxGetApp().GetHelpController().KeywordSearch(helpTopic);
248
    }
249
}
250
 
251
// This sets the text for the selected page, but doesn't help
252
// when trying to click on a tab: we would expect the appropriate help
253
// for that tab. We would need to look at the tabs to do this, from within OnContextHelp -
254
// probably not worth it.
255
void ecSettingsDialog::OnPageChange(wxNotebookEvent& event)
256
{
257
    event.Skip();
258
 
259
    int sel = m_notebook->GetSelection();
260
    if (sel < 0)
261
        return;
262
 
263
    wxWindow* page = m_notebook->GetPage(sel);
264
    if (page)
265
    {
266
        wxString helpText;
267
 
268
        if (page == m_displayOptions)
269
            helpText = _("The display options dialog allows you to change display-related options.");
270
        else if (page == m_viewerOptions)
271
            helpText = _("The viewer options dialog allows you to configure viewers.");
272
#if ecUSE_PATHS_PAGE
273
        else if (page == m_pathOptions)
274
            helpText = _("The path options dialog allows you to change tool paths.");
275
#endif
276
        else if (page == m_conflictResolutionOptions)
277
            helpText = _("The conflict resolution options dialog allows you to change options related to conflict resolution.");
278
#if ecUSE_RUN_PAGE
279
        else if (page == m_runOptions)
280
            helpText = _("The run options dialog allows you to change options related to running tests.");
281
#endif
282
        m_notebook->SetHelpText(helpText);
283
    }
284
}
285
 
286
bool ecSettingsDialog::TransferDataToWindow()
287
{
288
    m_displayOptions->TransferDataToWindow();
289
    m_viewerOptions->TransferDataToWindow();
290
#if ecUSE_PATHS_PAGE
291
    m_pathOptions->TransferDataToWindow();
292
#endif
293
    m_conflictResolutionOptions->TransferDataToWindow();
294
#if ecUSE_RUN_PAGE
295
    m_runOptions->TransferDataToWindow();
296
#endif
297
    return TRUE;
298
}
299
 
300
bool ecSettingsDialog::TransferDataFromWindow()
301
{
302
    m_displayOptions->TransferDataFromWindow();
303
    m_viewerOptions->TransferDataFromWindow();
304
#if ecUSE_PATHS_PAGE
305
    m_pathOptions->TransferDataFromWindow();
306
#endif
307
    m_conflictResolutionOptions->TransferDataFromWindow();
308
#if ecUSE_RUN_PAGE
309
    m_runOptions->TransferDataFromWindow();
310
#endif
311
    return TRUE;
312
}
313
 
314
/* Display options dialog
315
 */
316
 
317
// For now, disable some unnecessary features
318
#define ecUSE_FONT_SELECTION 1
319
 
320
IMPLEMENT_CLASS(ecDisplayOptionsDialog, wxPanel)
321
 
322
BEGIN_EVENT_TABLE(ecDisplayOptionsDialog, wxPanel)
323
    EVT_BUTTON(ecID_DISPLAY_OPTIONS_CHANGE_FONT, ecDisplayOptionsDialog::OnChangeFont)
324
END_EVENT_TABLE()
325
 
326
ecDisplayOptionsDialog::ecDisplayOptionsDialog(wxWindow* parent):
327
    wxPanel(parent, ecID_SETTINGS_DISPLAY)
328
{
329
    CreateControls(this);
330
 
331
    SetHelpText(_("The display options dialog allows you to change display-related options"));
332
}
333
 
334
void ecDisplayOptionsDialog::CreateControls( wxPanel *parent)
335
{
336
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
337
 
338
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Configuration Pane") );
339
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxHORIZONTAL );
340
 
341
    wxString strs3[] =
342
    {
343
        _("Use &macro names"),
344
        _("Use descriptive &names")
345
    };
346
    wxRadioBox *item3 = new wxRadioBox( parent, ecID_DISPLAY_OPTIONS_LABELS, _("Labels"), wxDefaultPosition, wxDefaultSize, 2, strs3, 1, wxRA_SPECIFY_COLS );
347
    item1->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
348
 
349
    item1->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
350
 
351
    wxString strs4[] =
352
    {
353
        _("&Decimal"),
354
        _("He&xadecimal")
355
    };
356
    wxRadioBox *item4 = new wxRadioBox( parent, ecID_DISPLAY_OPTIONS_INTEGER_ITEMS, _("Integer items"), wxDefaultPosition, wxDefaultSize, 2, strs4, 1, wxRA_SPECIFY_COLS );
357
    item1->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
358
 
359
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
360
 
361
#if ecUSE_FONT_SELECTION
362
    wxStaticBox *item6 = new wxStaticBox( parent, -1, _("Font") );
363
    wxSizer *item5 = new wxStaticBoxSizer( item6, wxHORIZONTAL );
364
 
365
    wxStaticText *item7 = new wxStaticText( parent, wxID_STATIC, _("&Window:"), wxDefaultPosition, wxDefaultSize, 0 );
366
    item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
367
 
368
    wxChoice *item8 = new wxChoice( parent, ecID_DISPLAY_OPTIONS_FONT_CHOICE, wxDefaultPosition, wxSize(120,-1), 0, NULL, 0 );
369
    item5->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 );
370
 
371
    item5->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
372
 
373
    wxButton *item9 = new wxButton( parent, ecID_DISPLAY_OPTIONS_CHANGE_FONT, _("Change &Font..."), wxDefaultPosition, wxDefaultSize, 0 );
374
    item5->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 );
375
 
376
    item0->Add( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
377
#endif
378
 
379
    wxStaticBox *item11 = new wxStaticBox( parent, -1, _("Miscellaneous") );
380
    wxSizer *item10 = new wxStaticBoxSizer( item11, wxVERTICAL );
381
 
382
    wxCheckBox *item12 = new wxCheckBox( parent, ecID_DISPLAY_OPTIONS_SHOW_SPLASH, _("Show initial &splash screen"), wxDefaultPosition, wxDefaultSize, 0 );
383
    item10->Add( item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
384
 
385
    item0->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
386
 
387
    // Add validators
388
    FindWindow(ecID_DISPLAY_OPTIONS_SHOW_SPLASH)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_showSplashScreen));
389
 
390
    // Add context-sensitive help
391
    item2->SetHelpText(_("Options relating to the configuration pane."));
392
    FindWindow(ecID_DISPLAY_OPTIONS_LABELS)->SetHelpText(_("Display macro or descriptive names in the configuration pane."));
393
    FindWindow(ecID_DISPLAY_OPTIONS_INTEGER_ITEMS)->SetHelpText(_("View integer items in the configuration pane in either decimal or hexadecimal."));
394
 
395
#if ecUSE_FONT_SELECTION
396
    FindWindow(ecID_DISPLAY_OPTIONS_FONT_CHOICE)->SetHelpText(_("Selects a window for which the font is to be changed."));
397
    FindWindow(ecID_DISPLAY_OPTIONS_CHANGE_FONT)->SetHelpText(_("Changes the font of the chosen window."));
398
    // Init the choice control
399
    unsigned int i;
400
    for (i = 0; i < wxGetApp().GetSettings().GetWindowSettings().GetCount(); i++)
401
    {
402
        ((wxChoice*) FindWindow(ecID_DISPLAY_OPTIONS_FONT_CHOICE))->Append(wxGetApp().GetSettings().GetWindowSettings().GetName(i));
403
    }
404
 
405
    ((wxChoice*) FindWindow(ecID_DISPLAY_OPTIONS_FONT_CHOICE))->SetSelection(0);
406
#endif
407
 
408
    FindWindow(ecID_DISPLAY_OPTIONS_SHOW_SPLASH)->SetHelpText(_("Selects whether a splash screen will be shown as the application starts."));
409
 
410
    parent->SetAutoLayout( TRUE );
411
    parent->SetSizer( item0 );
412
}
413
 
414
bool ecDisplayOptionsDialog::TransferDataToWindow()
415
{
416
    wxPanel::TransferDataToWindow();
417
 
418
    ((wxRadioBox*) FindWindow(ecID_DISPLAY_OPTIONS_INTEGER_ITEMS))->SetSelection( wxGetApp().GetSettings().m_bHex ? 1 : 0 ) ;
419
    ((wxRadioBox*) FindWindow(ecID_DISPLAY_OPTIONS_LABELS))->SetSelection( wxGetApp().GetSettings().m_showMacroNames ? 0 : 1 ) ;
420
    return TRUE;
421
}
422
 
423
bool ecDisplayOptionsDialog::TransferDataFromWindow()
424
{
425
    wxPanel::TransferDataFromWindow();
426
 
427
    wxGetApp().GetSettings().m_bHex = ((wxRadioBox*) FindWindow(ecID_DISPLAY_OPTIONS_INTEGER_ITEMS))->GetSelection() == 1;
428
    wxGetApp().GetSettings().m_showMacroNames = ((wxRadioBox*) FindWindow(ecID_DISPLAY_OPTIONS_LABELS))->GetSelection() == 0 ;
429
 
430
    if (!wxGetApp().GetSettings().GetWindowSettings().GetUseDefaults())
431
        wxGetApp().GetSettings().GetWindowSettings().ApplyFontsToWindows();
432
 
433
    return TRUE;
434
}
435
 
436
void ecDisplayOptionsDialog::OnChangeFont(wxCommandEvent& event)
437
{
438
    wxChoice* choice = (wxChoice*) FindWindow(ecID_DISPLAY_OPTIONS_FONT_CHOICE);
439
 
440
    wxString str = choice->GetStringSelection();
441
    if (!str.IsEmpty())
442
    {
443
        wxFontData data;
444
        data.SetInitialFont(wxGetApp().GetSettings().GetWindowSettings().GetFont(str));
445
 
446
        wxFontDialog dlg(this, & data);
447
        if (dlg.ShowModal() == wxID_OK)
448
        {
449
            wxGetApp().GetSettings().GetWindowSettings().SetFont(str, dlg.GetFontData().GetChosenFont()) ;
450
 
451
            // Changed a font, so start using specified fonts.
452
            wxGetApp().GetSettings().GetWindowSettings().SetUseDefaults(FALSE) ;
453
        }
454
    }
455
}
456
 
457
 
458
/* Viewer options dialog
459
 */
460
 
461
IMPLEMENT_CLASS(ecViewerOptionsDialog, wxPanel)
462
 
463
BEGIN_EVENT_TABLE(ecViewerOptionsDialog, wxPanel)
464
    EVT_BUTTON(ecID_VIEWER_DIALOG_BROWSE_HEADER, ecViewerOptionsDialog::OnBrowseForViewer)
465
    EVT_BUTTON(ecID_VIEWER_DIALOG_BROWSE_DOC, ecViewerOptionsDialog::OnBrowseForBrowser)
466
    EVT_BUTTON(ecID_VIEWER_DIALOG_ASSOC_INFO, ecViewerOptionsDialog::OnShowAssociatedViewerInfo)
467
 
468
    EVT_UPDATE_UI(ecID_VIEWER_DIALOG_HEADER_TEXT, ecViewerOptionsDialog::OnUpdateViewerText)
469
    EVT_UPDATE_UI(ecID_VIEWER_DIALOG_BROWSE_HEADER, ecViewerOptionsDialog::OnUpdateViewerText)
470
    EVT_UPDATE_UI(ecID_VIEWER_DIALOG_DOC_TEXT, ecViewerOptionsDialog::OnUpdateBrowserText)
471
    EVT_UPDATE_UI(ecID_VIEWER_DIALOG_BROWSE_DOC, ecViewerOptionsDialog::OnUpdateBrowserText)
472
END_EVENT_TABLE()
473
 
474
ecViewerOptionsDialog::ecViewerOptionsDialog(wxWindow* parent):
475
    wxPanel(parent, ecID_SETTINGS_VIEWER)
476
{
477
    CreateControls(this);
478
 
479
    SetHelpText(_("The viewer options dialog allows you to configure viewers."));
480
}
481
 
482
bool ecViewerOptionsDialog::TransferDataToWindow()
483
{
484
    wxPanel::TransferDataToWindow();
485
 
486
    ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_HEADER_ASSOCIATED))->SetValue(! wxGetApp().GetSettings().m_bUseCustomViewer);
487
    ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_HEADER_THIS))->SetValue(wxGetApp().GetSettings().m_bUseCustomViewer);
488
 
489
    ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_DOC_BUILTIN))->SetValue(wxGetApp().GetSettings().m_eUseCustomBrowser == ecInternal);
490
    ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_DOC_THIS))->SetValue(wxGetApp().GetSettings().m_eUseCustomBrowser == ecCustomExternal);
491
    ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_DOC_ASSOCIATED))->SetValue(wxGetApp().GetSettings().m_eUseCustomBrowser == ecAssociatedExternal);
492
 
493
    return TRUE;
494
}
495
 
496
bool ecViewerOptionsDialog::TransferDataFromWindow()
497
{
498
    wxPanel::TransferDataFromWindow();
499
 
500
    wxGetApp().GetSettings().m_bUseCustomViewer = ! ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_HEADER_ASSOCIATED))->GetValue();
501
 
502
    if (((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_DOC_BUILTIN))->GetValue())
503
        wxGetApp().GetSettings().m_eUseCustomBrowser = ecInternal;
504
    else if (((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_DOC_THIS))->GetValue())
505
        wxGetApp().GetSettings().m_eUseCustomBrowser = ecCustomExternal;
506
    else if (((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_DOC_ASSOCIATED))->GetValue())
507
        wxGetApp().GetSettings().m_eUseCustomBrowser = ecAssociatedExternal;
508
 
509
    return TRUE;
510
}
511
 
512
void ecViewerOptionsDialog::CreateControls( wxPanel *parent)
513
{
514
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
515
 
516
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("View header files using") );
517
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
518
 
519
    wxRadioButton *item3 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_HEADER_ASSOCIATED, _("Associated viewer"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
520
    item1->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
521
 
522
    wxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
523
 
524
    wxRadioButton *item5 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_HEADER_THIS, _("This &viewer:"), wxDefaultPosition, wxDefaultSize, 0 );
525
    item4->Add( item5, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
526
 
527
    item4->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
528
 
529
    wxButton *item6 = new wxButton( parent, ecID_VIEWER_DIALOG_BROWSE_HEADER, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
530
    item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
531
 
532
    item1->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 0 );
533
 
534
    wxTextCtrl *item7 = new wxTextCtrl( parent, ecID_VIEWER_DIALOG_HEADER_TEXT, _(""), wxDefaultPosition, wxSize(80,-1), 0 );
535
    item1->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
536
 
537
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
538
 
539
    item0->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
540
 
541
    wxStaticBox *item9 = new wxStaticBox( parent, -1, _("View documentation using") );
542
    wxSizer *item8 = new wxStaticBoxSizer( item9, wxVERTICAL );
543
 
544
    wxRadioButton *item10 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_DOC_BUILTIN, _("&Built-in viewer"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
545
    item8->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
546
 
547
    wxSizer *item11 = new wxBoxSizer( wxHORIZONTAL );
548
 
549
    wxRadioButton *item12 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_DOC_ASSOCIATED, _("Associated browser"), wxDefaultPosition, wxDefaultSize, 0 );
550
    item11->Add( item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
551
 
552
    item11->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
553
 
554
    wxButton *item13 = new wxButton( parent, ecID_VIEWER_DIALOG_ASSOC_INFO, _("&About..."), wxDefaultPosition, wxDefaultSize, 0 );
555
    item11->Add( item13, 0, wxALIGN_CENTRE|wxALL, 5 );
556
 
557
    item8->Add( item11, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
558
 
559
    wxSizer *item14 = new wxBoxSizer( wxHORIZONTAL );
560
 
561
    wxRadioButton *item15 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_DOC_THIS, _("This &browser:"), wxDefaultPosition, wxDefaultSize, 0 );
562
    item14->Add( item15, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
563
 
564
    item14->Add( 20, 20, 1, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
565
 
566
    wxButton *item16 = new wxButton( parent, ecID_VIEWER_DIALOG_BROWSE_DOC, _("Br&owse..."), wxDefaultPosition, wxDefaultSize, 0 );
567
    item14->Add( item16, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
568
 
569
    item8->Add( item14, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
570
 
571
    wxTextCtrl *item17 = new wxTextCtrl( parent, ecID_VIEWER_DIALOG_DOC_TEXT, _(""), wxDefaultPosition, wxSize(80,-1), 0 );
572
    item8->Add( item17, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
573
 
574
    item0->Add( item8, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
575
 
576
#if 0
577
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
578
 
579
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("View header files using") );
580
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
581
 
582
    wxRadioButton *item3 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_HEADER_ASSOCIATED, _("Associated viewer"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
583
    item1->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
584
 
585
    wxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
586
 
587
    wxRadioButton *item5 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_HEADER_THIS, _("This &viewer:"), wxDefaultPosition, wxDefaultSize, 0 );
588
    item4->Add( item5, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
589
 
590
    item4->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
591
 
592
    wxButton *item6 = new wxButton( parent, ecID_VIEWER_DIALOG_BROWSE_HEADER, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
593
    item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
594
 
595
    item1->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 0 );
596
 
597
    wxTextCtrl *item7 = new wxTextCtrl( parent, ecID_VIEWER_DIALOG_HEADER_TEXT, _(""), wxDefaultPosition, wxSize(80,-1), 0 );
598
    item1->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
599
 
600
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
601
 
602
//    item0->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
603
 
604
    wxStaticBox *item9 = new wxStaticBox( parent, -1, _("View documentation using") );
605
    wxSizer *item8 = new wxStaticBoxSizer( item9, wxVERTICAL );
606
 
607
    wxRadioButton *item10 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_DOC_BUILTIN, _("&Built-in viewer"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
608
    item8->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
609
 
610
    wxRadioButton *item11 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_DOC_ASSOCIATED, _("Associated browser"), wxDefaultPosition, wxDefaultSize, 0 );
611
    item8->Add( item11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
612
 
613
    wxSizer *item12 = new wxBoxSizer( wxHORIZONTAL );
614
 
615
    wxRadioButton *item13 = new wxRadioButton( parent, ecID_VIEWER_DIALOG_DOC_THIS, _("This &browser:"), wxDefaultPosition, wxDefaultSize, 0 );
616
    item12->Add( item13, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
617
 
618
    item12->Add( 20, 20, 1, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
619
 
620
    wxButton *item14 = new wxButton( parent, ecID_VIEWER_DIALOG_BROWSE_DOC, _("Br&owse..."), wxDefaultPosition, wxDefaultSize, 0 );
621
    item12->Add( item14, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
622
 
623
    item8->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
624
 
625
    wxTextCtrl *item15 = new wxTextCtrl( parent, ecID_VIEWER_DIALOG_DOC_TEXT, _(""), wxDefaultPosition, wxSize(80,-1), 0 );
626
    item8->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
627
 
628
    item0->Add( item8, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
629
#endif
630
 
631
    // Disable this option because we don't yet have a built-in browser
632
#if 0 // !ecUSE_EXPERIMENTAL_CODE
633
    FindWindow(ecID_VIEWER_DIALOG_DOC_BUILTIN)->Enable(FALSE);
634
#endif
635
 
636
    // Add validators
637
    FindWindow(ecID_VIEWER_DIALOG_HEADER_TEXT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_strViewer));
638
    FindWindow(ecID_VIEWER_DIALOG_DOC_TEXT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_strBrowser));
639
 
640
    // Add context-sensitive help
641
    item2->SetHelpText(_("Allows you to select a viewer to display header files."));
642
    FindWindow(ecID_VIEWER_DIALOG_HEADER_ASSOCIATED)->SetHelpText(_("Select the default viewer to display header files."));
643
    FindWindow(ecID_VIEWER_DIALOG_HEADER_THIS)->SetHelpText(_("Select a viewer of your choice to display header files."));
644
    FindWindow(ecID_VIEWER_DIALOG_BROWSE_HEADER)->SetHelpText(_("Browses for a viewer to be used to display header files."));
645
    FindWindow(ecID_VIEWER_DIALOG_HEADER_TEXT)->SetHelpText(_("Specify the viewer executable to be used to display header files."));
646
    item9->SetHelpText(_("Allows you to select a viewer to display documentation."));
647
    FindWindow(ecID_VIEWER_DIALOG_DOC_BUILTIN)->SetHelpText(_("Select the internal HTML help mechanism to display HTML-based help."));
648
    FindWindow(ecID_VIEWER_DIALOG_DOC_ASSOCIATED)->SetHelpText(_("Select the default browser to display HTML-based help."));
649
    FindWindow(ecID_VIEWER_DIALOG_DOC_THIS)->SetHelpText(_("Select a browser of your choice to display HTML-based help."));
650
    FindWindow(ecID_VIEWER_DIALOG_BROWSE_DOC)->SetHelpText(_("Browses for a browser to be used to display HTML-based help."));
651
    FindWindow(ecID_VIEWER_DIALOG_ASSOC_INFO)->SetHelpText(_("Shows information about the associated viewer."));
652
 
653
    parent->SetAutoLayout( TRUE );
654
    parent->SetSizer( item0 );
655
}
656
 
657
void ecViewerOptionsDialog::OnUpdateViewerText(wxUpdateUIEvent& event)
658
{
659
    event.Enable( FindWindow(ecID_VIEWER_DIALOG_HEADER_THIS) &&
660
                    ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_HEADER_THIS))->GetValue() );
661
}
662
 
663
void ecViewerOptionsDialog::OnUpdateBrowserText(wxUpdateUIEvent& event)
664
{
665
    event.Enable( FindWindow(ecID_VIEWER_DIALOG_DOC_THIS) &&
666
                    ((wxRadioButton*) FindWindow(ecID_VIEWER_DIALOG_DOC_THIS))->GetValue() );
667
}
668
 
669
void ecViewerOptionsDialog::OnBrowseForViewer(wxCommandEvent& event)
670
{
671
    wxString currentViewer = ((wxTextCtrl*) FindWindow(ecID_VIEWER_DIALOG_HEADER_TEXT))->GetValue();
672
 
673
    wxFileDialog dialog(this, _("Choose a viewer executable"), wxPathOnly(currentViewer),
674
        wxFileNameFromPath(currentViewer),
675
#ifdef __WXMSW__
676
        wxT("Executable files (*.exe)|*.exe"));
677
#else
678
        wxT("All files (*)|*"));
679
#endif
680
 
681
    if (dialog.ShowModal() == wxID_OK)
682
    {
683
        ((wxTextCtrl*) FindWindow(ecID_VIEWER_DIALOG_HEADER_TEXT))->SetValue(dialog.GetPath());
684
    }
685
}
686
 
687
void ecViewerOptionsDialog::OnBrowseForBrowser(wxCommandEvent& event)
688
{
689
    wxString currentViewer = ((wxTextCtrl*) FindWindow(ecID_VIEWER_DIALOG_DOC_TEXT))->GetValue();
690
 
691
    wxFileDialog dialog(this, _("Choose a browser executable"), wxPathOnly(currentViewer),
692
        wxFileNameFromPath(currentViewer),
693
#ifdef __WXMSW__
694
        wxT("Executable files (*.exe)|*.exe"));
695
#else
696
        wxT("All files (*)|*"));
697
#endif
698
 
699
    if (dialog.ShowModal() == wxID_OK)
700
    {
701
        ((wxTextCtrl*) FindWindow(ecID_VIEWER_DIALOG_DOC_TEXT))->SetValue(dialog.GetPath());
702
    }
703
}
704
 
705
void ecViewerOptionsDialog::OnShowAssociatedViewerInfo(wxCommandEvent& event)
706
{
707
    wxString msg;
708
    wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("html"));
709
    if ( !ft )
710
    {
711
        msg += wxT("It is not possible to determine the associated browser for HTML documents.\n\n");
712
    }
713
    else
714
    {
715
        msg += wxT("The associated MIME type for HTML is:\n");
716
        wxString mimeType(wxT("Unknown"));
717
        ft->GetMimeType(& mimeType);
718
        msg += mimeType;
719
        msg += wxT("\n");
720
 
721
        wxString descr;
722
        if (ft->GetDescription(& descr))
723
        {
724
            msg += descr;
725
            msg += wxT("\n");
726
        }
727
        msg += wxT("\n");
728
 
729
        wxString cmd;
730
        wxString url(wxT("http://example-url.html"));
731
        bool ok = ft->GetOpenCommand(&cmd,
732
            wxFileType::MessageParameters(url, _T("")));
733
 
734
        if (ok)
735
        {
736
            msg += wxT("The associated command is:\n");
737
            msg += cmd;
738
            msg += wxT("\n");
739
        }
740
        msg += wxT("\n");
741
    }
742
 
743
    msg += wxT("If this MIME type is not defined or looks wrong, please consult your ");
744
    msg += wxT("Configuration Tool documentation for how to set up an association.\n");
745
#if defined(__WXGTK__)
746
    msg += wxT("On Unix, this can be done by adding an entry to your ~/.mailcap file.");
747
#endif
748
 
749
    delete ft;
750
 
751
    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_INFORMATION|wxOK);
752
}
753
 
754
/* Path options dialog
755
 */
756
 
757
IMPLEMENT_CLASS(ecPathOptionsDialog, wxPanel)
758
 
759
ecPathOptionsDialog::ecPathOptionsDialog(wxWindow* parent):
760
    wxPanel(parent, ecID_SETTINGS_PATH)
761
{
762
    CreateControls(this);
763
 
764
    SetHelpText(_("The path options dialog allows you to change tool paths."));
765
}
766
 
767
bool ecPathOptionsDialog::TransferDataToWindow()
768
{
769
    wxPanel::TransferDataToWindow();
770
    return TRUE;
771
}
772
 
773
bool ecPathOptionsDialog::TransferDataFromWindow()
774
{
775
    wxPanel::TransferDataFromWindow();
776
    return TRUE;
777
}
778
 
779
void ecPathOptionsDialog::CreateControls( wxPanel *parent)
780
{
781
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
782
 
783
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Build Tools") );
784
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
785
 
786
    wxStaticText *item3 = new wxStaticText( parent, ecID_PATHS_BUILD_MSG,
787
        _("Enter the location of the arm-elf build tools "
788
          "folder, which should contain arm-elf-gcc. You can "
789
          "type in a path or use the Browse button to "
790
          "navigate to a folder."),
791
        wxDefaultPosition, wxSize(-1,70), 0 );
792
    item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
793
 
794
    wxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
795
 
796
    wxString *strs5 = (wxString*) NULL;
797
    wxComboBox *item5 = new wxComboBox( parent, ecID_PATHS_BUILD_COMBO, _(""), wxDefaultPosition, wxSize(100,-1), 0, strs5, wxCB_DROPDOWN );
798
    item4->Add( item5, 20, wxALIGN_CENTRE|wxALL, 5 );
799
 
800
    item1->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
801
 
802
    wxButton *item6 = new wxButton( parent, ecID_PATHS_BUILD_BROWSE, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
803
    item1->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
804
 
805
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
806
 
807
    wxStaticBox *item8 = new wxStaticBox( parent, -1, _("User Tools") );
808
    wxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
809
 
810
    wxStaticText *item9 = new wxStaticText( parent, ecID_PATHS_USER_MSG,
811
        _("Enter the location of the user tools folder, "
812
          "which should contain cat and ls. You can type in "
813
          "a path or use the Browse button to navigate to a "
814
          "folder."),
815
        wxDefaultPosition, wxSize(-1,60), 0 );
816
    item7->Add( item9, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
817
 
818
    wxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
819
 
820
    wxString *strs11 = (wxString*) NULL;
821
    wxComboBox *item11 = new wxComboBox( parent, ecID_PATHS_USER_COMBO, _(""), wxDefaultPosition, wxSize(100,-1), 0, strs11, wxCB_DROPDOWN );
822
    item10->Add( item11, 20, wxALIGN_CENTRE|wxALL, 5 );
823
 
824
    item7->Add( item10, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
825
 
826
    wxButton *item12 = new wxButton( parent, ecID_PATHS_USER_BROWSE, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
827
    item7->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );
828
    item0->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
829
 
830
 
831
    parent->SetAutoLayout( TRUE );
832
    parent->SetSizer( item0 );
833
 
834
    // Add context-sensitive help
835
    FindWindow( ecID_PATHS_BUILD_COMBO )->SetHelpText(_("Select the build tools folder."));
836
    FindWindow( ecID_PATHS_BUILD_BROWSE )->SetHelpText(_("Browse for the build tools folder."));
837
    FindWindow( ecID_PATHS_USER_COMBO )->SetHelpText(_("Select the user tools folder."));
838
    FindWindow( ecID_PATHS_USER_BROWSE )->SetHelpText(_("Browse for the user tools folder."));
839
}
840
 
841
/* Conflict resolution options dialog
842
 */
843
 
844
IMPLEMENT_CLASS(ecConflictResolutionOptionsDialog, wxPanel)
845
 
846
ecConflictResolutionOptionsDialog::ecConflictResolutionOptionsDialog(wxWindow* parent):
847
    wxPanel(parent, ecID_SETTINGS_CONFLICT_RESOLUTION)
848
{
849
    CreateControls(this);
850
 
851
    m_suggestFixes = ((wxGetApp().GetSettings().m_nRuleChecking & ecSettings::SuggestFixes) != 0);
852
    m_immediate = ((wxGetApp().GetSettings().m_nRuleChecking & ecSettings::Immediate) != 0);
853
    m_deferred = ((wxGetApp().GetSettings().m_nRuleChecking & ecSettings::Deferred) != 0);
854
 
855
    SetHelpText(_("The conflict resolution options dialog allows you to change options related to conflict resolution."));
856
}
857
 
858
bool ecConflictResolutionOptionsDialog::TransferDataToWindow()
859
{
860
    wxPanel::TransferDataToWindow();
861
    return TRUE;
862
}
863
 
864
bool ecConflictResolutionOptionsDialog::TransferDataFromWindow()
865
{
866
    wxPanel::TransferDataFromWindow();
867
 
868
    int& ruleChecking = wxGetApp().GetSettings().m_nRuleChecking;
869
 
870
    ruleChecking = 0;
871
    if (m_suggestFixes)
872
        ruleChecking |= ecSettings::SuggestFixes ;
873
    if (m_immediate)
874
        ruleChecking |= ecSettings::Immediate ;
875
    if (m_deferred)
876
        ruleChecking |= ecSettings::Deferred ;
877
 
878
    return TRUE;
879
}
880
 
881
void ecConflictResolutionOptionsDialog::CreateControls( wxPanel *parent)
882
{
883
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
884
 
885
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Check for conflicts:") );
886
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
887
 
888
    wxCheckBox *item3 = new wxCheckBox( parent, ecID_CONFLICT_OPTIONS_AFTER_ITEM_CHANGED, _("After any item changed"), wxDefaultPosition, wxDefaultSize, 0 );
889
    item1->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
890
 
891
    wxCheckBox *item4 = new wxCheckBox( parent, ecID_CONFLICT_OPTIONS_BEFORE_SAVING, _("Before &saving configuration"), wxDefaultPosition, wxDefaultSize, 0 );
892
    item1->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
893
 
894
    wxCheckBox *item5 = new wxCheckBox( parent, ecID_CONFLICT_OPTIONS_AUTOSUGGEST, _("&Automatically suggest fixes"), wxDefaultPosition, wxDefaultSize, 0 );
895
    item1->Add( item5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
896
 
897
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
898
 
899
    parent->SetAutoLayout( TRUE );
900
    parent->SetSizer( item0 );
901
 
902
    // Add context-sensitive help
903
    item2->SetHelpText(_("Options related to conflict resolution."));
904
    item3->SetHelpText(_("Check for configuration option conflicts after any configuration option value is changed."));
905
    item4->SetHelpText(_("Check for configuration option conflicts before saving the configuration."));
906
    item5->SetHelpText(_("When configuration conflicts are found, provide possible solutions."));
907
 
908
    // Add validators
909
    FindWindow(ecID_CONFLICT_OPTIONS_AFTER_ITEM_CHANGED)->SetValidator(wxGenericValidator(& m_immediate));
910
    FindWindow(ecID_CONFLICT_OPTIONS_BEFORE_SAVING)->SetValidator(wxGenericValidator(& m_deferred));
911
    FindWindow(ecID_CONFLICT_OPTIONS_AUTOSUGGEST)->SetValidator(wxGenericValidator(& m_suggestFixes));
912
}
913
 
914
/* Run options dialog
915
 */
916
 
917
IMPLEMENT_CLASS(ecRunOptionsDialog, wxPanel)
918
 
919
BEGIN_EVENT_TABLE(ecRunOptionsDialog, wxPanel)
920
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT, ecRunOptionsDialog::OnUpdateDownloadTimeout)
921
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT, ecRunOptionsDialog::OnUpdateRuntimeTimeout)
922
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR, ecRunOptionsDialog::OnUpdateSerial)
923
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED, ecRunOptionsDialog::OnUpdateSerial)
924
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_TCPIP_HOST, ecRunOptionsDialog::OnUpdateTCPIP)
925
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_TCPIP_PORT, ecRunOptionsDialog::OnUpdateTCPIP)
926
END_EVENT_TABLE()
927
 
928
ecRunOptionsDialog::ecRunOptionsDialog(wxWindow* parent):
929
    wxPanel(parent, ecID_SETTINGS_RUN),
930
    m_serialOn(TRUE), m_TCPIPOn(FALSE)
931
{
932
    CreateControls(this);
933
 
934
    SetHelpText(_("The run properties dialog allows you to change options related to running tests."));
935
}
936
 
937
bool ecRunOptionsDialog::TransferDataToWindow()
938
{
939
#if 0
940
    // m_strTarget now set in ecConfigToolDoc::RunTests()
941
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
942
    wxString hardware;
943
    if (doc)
944
    {
945
        hardware = doc->GetCdlConfig ()->get_hardware ().c_str();
946
    }
947
    else
948
    {
949
         hardware = _("Unknown");
950
    }
951
    wxGetApp().GetSettings().GetRunTestsSettings().m_strTarget = hardware;
952
#endif
953
 
954
    // Serial/TCPIP
955
    m_serialOn = wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial;
956
    m_TCPIPOn = !wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial;
957
 
958
    switch (wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType)
959
    {
960
    case TIMEOUT_NONE:
961
        m_downloadTimeoutString = _("None");
962
        break;
963
    case TIMEOUT_SPECIFIED:
964
        m_downloadTimeoutString = _("Specified");
965
        break;
966
    default:
967
    case TIMEOUT_AUTOMATIC:
968
        m_downloadTimeoutString = _("Calculated from file size");
969
        break;
970
    }
971
 
972
    switch (wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType)
973
    {
974
    case TIMEOUT_NONE:
975
        m_runtimeTimeoutString = _("None");
976
        break;
977
    case TIMEOUT_SPECIFIED:
978
        m_runtimeTimeoutString = _("Specified");
979
        break;
980
    default:
981
    case TIMEOUT_AUTOMATIC:
982
        m_runtimeTimeoutString = _("Default");
983
        break;
984
    }
985
 
986
    m_baudString.Printf("%d", wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud);
987
 
988
    wxPanel::TransferDataToWindow();
989
 
990
    return TRUE;
991
}
992
 
993
bool ecRunOptionsDialog::TransferDataFromWindow()
994
{
995
    wxPanel::TransferDataFromWindow();
996
 
997
    if (m_downloadTimeoutString == _("None"))
998
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_NONE;
999
    else if (m_downloadTimeoutString == _("Specified"))
1000
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_SPECIFIED;
1001
    else
1002
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_AUTOMATIC;
1003
 
1004
    if (m_runtimeTimeoutString == _("None"))
1005
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_NONE;
1006
    else if (m_runtimeTimeoutString == _("Specified"))
1007
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_SPECIFIED;
1008
    else
1009
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_AUTOMATIC;
1010
 
1011
    wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud = (int) wxAtol(m_baudString);
1012
 
1013
    // Serial/TCPIP
1014
    wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial = m_serialOn;
1015
 
1016
    return TRUE;
1017
}
1018
 
1019
void ecRunOptionsDialog::CreateControls( wxPanel *parent)
1020
{
1021
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1022
 
1023
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
1024
 
1025
    wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, _("Platform:"), wxDefaultPosition, wxDefaultSize, 0 );
1026
    item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
1027
 
1028
    wxStaticText *item3 = new wxStaticText( parent, ecID_RUN_PROPERTIES_PLATFORM, _("xxxx"), wxDefaultPosition, wxDefaultSize, 0 );
1029
    item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
1030
 
1031
    item0->Add( item1, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP, 5 );
1032
 
1033
    wxStaticBox *item5 = new wxStaticBox( parent, -1, _("Timeouts") );
1034
    wxSizer *item4 = new wxStaticBoxSizer( item5, wxVERTICAL );
1035
 
1036
    wxSizer *item6 = new wxBoxSizer( wxHORIZONTAL );
1037
 
1038
    wxStaticText *item7 = new wxStaticText( parent, wxID_STATIC, _("Download:"), wxDefaultPosition, wxSize(60,-1), 0 );
1039
    item6->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
1040
 
1041
    wxString strs8[] =
1042
    {
1043
        _("None"),
1044
        _("Specified"),
1045
        _("Calculated from file size")
1046
    };
1047
    wxChoice *item8 = new wxChoice( parent, ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE, wxDefaultPosition, wxSize(100,-1), 3, strs8, 0 );
1048
    item6->Add( item8, 1, wxALIGN_CENTRE|wxALL, 5 );
1049
 
1050
    wxSpinCtrl *item9 = new wxSpinCtrl( parent, ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT, "0", wxDefaultPosition, wxSize(50,-1), 0, 0, 10000, 0 );
1051
    item6->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 );
1052
 
1053
    item4->Add( item6, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1054
 
1055
    wxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
1056
 
1057
    wxStaticText *item11 = new wxStaticText( parent, wxID_STATIC, _("Runtime:"), wxDefaultPosition, wxSize(60,-1), 0 );
1058
    item10->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
1059
 
1060
    wxString strs12[] =
1061
    {
1062
        _("None"),
1063
        _("Specified"),
1064
        _("Default")
1065
    };
1066
    wxChoice *item12 = new wxChoice( parent, ecID_RUN_PROPERTIES_RUNTIME_CHOICE, wxDefaultPosition, wxSize(100,-1), 3, strs12, 0 );
1067
    item10->Add( item12, 1, wxALIGN_CENTRE|wxALL, 5 );
1068
 
1069
    wxSpinCtrl *item13 = new wxSpinCtrl( parent, ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT, "0", wxDefaultPosition, wxSize(50,-1), 0, 0, 10000, 0 );
1070
    item10->Add( item13, 0, wxALIGN_CENTRE|wxALL, 5 );
1071
 
1072
    item4->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1073
 
1074
    item0->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1075
 
1076
    wxStaticBox *item15 = new wxStaticBox( parent, -1, _("Connection") );
1077
    wxSizer *item14 = new wxStaticBoxSizer( item15, wxVERTICAL );
1078
 
1079
    wxSizer *item16 = new wxBoxSizer( wxHORIZONTAL );
1080
 
1081
    wxRadioButton *item17 = new wxRadioButton( parent, ecID_RUN_PROPERTIES_SERIAL, _("&Serial"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1082
    item16->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 );
1083
 
1084
    item16->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 5 );
1085
 
1086
    wxStaticText *item18 = new wxStaticText( parent, wxID_STATIC, _("&Port:"), wxDefaultPosition, wxDefaultSize, 0 );
1087
    item16->Add( item18, 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5 );
1088
 
1089
    wxString strs19[] =
1090
    {
1091
        _("/dev/ttyS0"),
1092
        _("/dev/ttyS1"),
1093
        _("/dev/ttyS2"),
1094
        _("/dev/ttyS3"),
1095
        _("/dev/ttyS4"),
1096
        _("/dev/ttyS5"),
1097
        _("/dev/ttyS6"),
1098
        _("/dev/ttyS7")
1099
    };
1100
    wxComboBox *item19 = new wxComboBox( parent, ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 8, strs19, wxCB_DROPDOWN );
1101
    item16->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 );
1102
 
1103
    wxStaticText *item20 = new wxStaticText( parent, wxID_STATIC, _("&Baud:"), wxDefaultPosition, wxDefaultSize, 0 );
1104
    item16->Add( item20, 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5 );
1105
 
1106
    wxString strs21[] =
1107
    {
1108
        _("50"),
1109
        _("75"),
1110
        _("110"),
1111
//        _("134.5"), 
1112
        _("150"),
1113
        _("200"),
1114
        _("300"),
1115
        _("600"),
1116
        _("1200"),
1117
        _("1800"),
1118
        _("2400"),
1119
        _("3600"),
1120
        _("4800"),
1121
        _("7200"),
1122
        _("9600"),
1123
        _("14400"),
1124
        _("19200"),
1125
        _("38400"),
1126
        _("57600"),
1127
        _("115200"),
1128
        _("230400"),
1129
        _("460800"),
1130
        _("921600")
1131
    };
1132
    wxChoice *item21 = new wxChoice( parent, ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED, wxDefaultPosition, wxSize(85,-1), 22, strs21, 0 );
1133
    item16->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
1134
 
1135
    item14->Add( item16, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1136
 
1137
    wxSizer *item22 = new wxBoxSizer( wxHORIZONTAL );
1138
 
1139
    wxRadioButton *item23 = new wxRadioButton( parent, ecID_RUN_PROPERTIES_TCPIP, _("&TCP/IP"), wxDefaultPosition, wxDefaultSize, 0 );
1140
    item22->Add( item23, 0, wxALIGN_CENTRE|wxALL, 5 );
1141
 
1142
    item22->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 5 );
1143
 
1144
    wxStaticText *item24 = new wxStaticText( parent, wxID_STATIC, _("&Address:"), wxDefaultPosition, wxDefaultSize, 0 );
1145
    item22->Add( item24, 0, wxALIGN_CENTRE|wxALL, 5 );
1146
 
1147
    wxTextCtrl *item25 = new wxTextCtrl( parent, ecID_RUN_PROPERTIES_TCPIP_HOST, _(""), wxDefaultPosition, wxSize(120,-1), 0 );
1148
    item22->Add( item25, 0, wxALIGN_CENTRE|wxALL, 5 );
1149
 
1150
    wxStaticText *item26 = new wxStaticText( parent, wxID_STATIC, _(":"), wxDefaultPosition, wxDefaultSize, 0 );
1151
    item22->Add( item26, 0, wxALIGN_CENTRE, 5 );
1152
 
1153
    wxTextCtrl *item27 = new wxTextCtrl( parent, ecID_RUN_PROPERTIES_TCPIP_PORT, _(""), wxDefaultPosition, wxSize(50,-1), 0 );
1154
    item22->Add( item27, 0, wxALIGN_CENTRE|wxALL, 5 );
1155
 
1156
    item14->Add( item22, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1157
 
1158
    item0->Add( item14, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1159
 
1160
    parent->SetAutoLayout( TRUE );
1161
    parent->SetSizer( item0 );
1162
 
1163
    // Add context-sensitive help
1164
    FindWindow(ecID_RUN_PROPERTIES_PLATFORM)->SetHelpText(_("Shows the hardware currently selected."));
1165
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE)->SetHelpText(_("Specifies the kind of timeout to be applied to the download phase of test execution."));
1166
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT)->SetHelpText(_("Specifies a fixed-period timeout (in seconds) to be applied to the download phase of test execution."));
1167
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_CHOICE)->SetHelpText(_("Specifies the kind of timeout to be applied to the run phase of test execution."));
1168
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT)->SetHelpText(_("Specifies a fixed-period timeout (in seconds) to be applied to the run phase of test execution."));
1169
    FindWindow(ecID_RUN_PROPERTIES_SERIAL)->SetHelpText(_("Specifies that download is local, using a serial communications port."));
1170
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR)->SetHelpText(_("Specifies the communication ports to be used for local download."));
1171
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED)->SetHelpText(_("Specifies the baud rate at which the communications port is to operate."));
1172
    FindWindow(ecID_RUN_PROPERTIES_TCPIP)->SetHelpText(_("Specifies that download is remote, using GDB remote protocol via a TCP/IP port."));
1173
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_HOST)->SetHelpText(_("Specifies the TCP/IP host to be used for remote download."));
1174
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_PORT)->SetHelpText(_("Specifies the TCP/IP port number to be used for remote download."));
1175
 
1176
    // Add validators
1177
    FindWindow(ecID_RUN_PROPERTIES_PLATFORM)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_strTarget));
1178
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE)->SetValidator(wxGenericValidator(& m_downloadTimeoutString));
1179
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeout));
1180
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_CHOICE)->SetValidator(wxGenericValidator(& m_runtimeTimeoutString));
1181
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeout));
1182
    FindWindow(ecID_RUN_PROPERTIES_SERIAL)->SetValidator(wxGenericValidator(& m_serialOn));
1183
    FindWindow(ecID_RUN_PROPERTIES_TCPIP)->SetValidator(wxGenericValidator(& m_TCPIPOn));
1184
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_strPort));
1185
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED)->SetValidator(wxGenericValidator(& m_baudString));
1186
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_HOST)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_strLocalTCPIPHost));
1187
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_PORT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_nLocalTCPIPPort));
1188
 
1189
}
1190
 
1191
void ecRunOptionsDialog::OnUpdateDownloadTimeout(wxUpdateUIEvent& event)
1192
{
1193
    wxChoice* downloadTimeoutChoice = (wxChoice*) FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE);
1194
    wxString sel = downloadTimeoutChoice->GetStringSelection();
1195
    event.Enable( sel == _("Specified") );
1196
}
1197
 
1198
void ecRunOptionsDialog::OnUpdateRuntimeTimeout(wxUpdateUIEvent& event)
1199
{
1200
    wxChoice* runTimeoutChoice = (wxChoice*) FindWindow(ecID_RUN_PROPERTIES_RUNTIME_CHOICE);
1201
    wxString sel = runTimeoutChoice->GetStringSelection();
1202
    event.Enable( sel == _("Specified") );
1203
}
1204
 
1205
void ecRunOptionsDialog::OnUpdateSerial(wxUpdateUIEvent& event)
1206
{
1207
    wxRadioButton* radio = (wxRadioButton*) FindWindow(ecID_RUN_PROPERTIES_SERIAL);
1208
    event.Enable( radio->GetValue() );
1209
}
1210
 
1211
void ecRunOptionsDialog::OnUpdateTCPIP(wxUpdateUIEvent& event)
1212
{
1213
    wxRadioButton* radio = (wxRadioButton*) FindWindow(ecID_RUN_PROPERTIES_SERIAL);
1214
    event.Enable( !radio->GetValue() );
1215
}

powered by: WebSVN 2.1.0

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