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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [wxwin/] [settingsdlg.cpp] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####COPYRIGHTBEGIN####
2
//
3
// ----------------------------------------------------------------------------
4
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5
//
6
// This program is part of the eCos host tools.
7
//
8
// This program is free software; you can redistribute it and/or modify it
9
// under the terms of the GNU General Public License as published by the Free
10
// Software Foundation; either version 2 of the License, or (at your option)
11
// any later version.
12
//
13
// This program is distributed in the hope that it will be useful, but WITHOUT
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16
// more details.
17
//
18
// You should have received a copy of the GNU General Public License along with
19
// this program; if not, write to the Free Software Foundation, Inc.,
20
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
//
22
// ----------------------------------------------------------------------------
23
//
24
//####COPYRIGHTEND####
25
// appsettings.cpp :
26
//
27
//===========================================================================
28
//#####DESCRIPTIONBEGIN####
29
//
30
// Author(s):   julians
31
// Contact(s):  julians
32
// Date:        2000/09/11
33
// Version:     $Id: settingsdlg.cpp,v 1.1.1.1 2004-02-14 13:28:54 phoenix Exp $
34
// Purpose:
35
// Description: Implementation file for ecSettingsDialog
36
// Requires:
37
// Provides:
38
// See also:
39
// Known bugs:
40
// Usage:
41
//
42
//####DESCRIPTIONEND####
43
//
44
//===========================================================================
45
 
46
#ifdef __GNUG__
47
    #pragma implementation "settingsdlg.cpp"
48
#endif
49
 
50
#include "ecpch.h"
51
 
52
#ifdef __BORLANDC__
53
    #pragma hdrstop
54
#endif
55
 
56
#include "wx/spinctrl.h"
57
#include "wx/notebook.h"
58
#include "wx/cshelp.h"
59
#include "wx/valgen.h"
60
#include "wx/fontdlg.h"
61
#include "wx/mimetype.h"
62
 
63
#include "settingsdlg.h"
64
#include "configtool.h"
65
#include "configtooldoc.h"
66
#include "configtoolview.h"
67
 
68
// For now, we're not implementing the paths page on the settings dialog,
69
// but probably we should eventually for consistency and ease of use
70
#define ecUSE_PATHS_PAGE 0
71
 
72
#define ecUSE_RUN_PAGE 1
73
 
74
/*
75
 * Settings dialog
76
 */
77
 
78
IMPLEMENT_CLASS(ecSettingsDialog, wxDialog)
79
 
80
BEGIN_EVENT_TABLE(ecSettingsDialog, wxDialog)
81
    EVT_BUTTON(wxID_OK, ecSettingsDialog::OnOK)
82
    EVT_BUTTON(wxID_HELP, ecSettingsDialog::OnHelp)
83
    EVT_NOTEBOOK_PAGE_CHANGED(-1, ecSettingsDialog::OnPageChange)
84
END_EVENT_TABLE()
85
 
86
// GTK+ widgets seem to be chunkier than WIN32's, so give 'em more elbow-room
87
 
88
#ifdef __WXMSW__
89
#define PROPERTY_DIALOG_WIDTH   380
90
#define PROPERTY_DIALOG_HEIGHT  420
91
#else
92
#define PROPERTY_DIALOG_WIDTH   550 // 460
93
#define PROPERTY_DIALOG_HEIGHT  480
94
#endif
95
 
96
// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
97
// (209 x 162 dialog units)
98
 
99
ecSettingsDialog::ecSettingsDialog(wxWindow* parent):
100
    wxDialog()
101
{
102
    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
103
 
104
    wxDialog::Create(parent, ecID_SETTINGS_DIALOG, wxGetApp().GetSettings().GetAppName() + wxT(" Settings"), wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT));
105
 
106
    // Under MSW, we don't seem to be able to react to a click on the dialog background (no
107
    // event is generated).
108
    SetHelpText(_("The settings dialog provides the ability to change a variety of settings."));
109
 
110
    wxScreenDC dc;
111
    wxSize ppi = dc.GetPPI();
112
 
113
    //double scaleFactor = ((double) charH) / 13.0;
114
    double scaleFactor = ((double) ppi.y) / 96.0;
115
    // Fudge the scale factor to make the dialog slightly smaller,
116
    // otherwise it's a bit big. (We're assuming that most displays
117
    // are 96 or 120 ppi).
118
    if (ppi.y == 120)
119
        scaleFactor = 1.14;
120
    int dialogWidth = (int)(PROPERTY_DIALOG_WIDTH * scaleFactor);
121
    int dialogHeight = (int)(PROPERTY_DIALOG_HEIGHT * scaleFactor);
122
    SetSize(dialogWidth, dialogHeight);
123
 
124
    m_displayOptions = NULL;
125
 
126
    m_notebook = new wxNotebook(this, ecID_SETTINGS_NOTEBOOK,
127
         wxPoint(2, 2), wxSize(PROPERTY_DIALOG_WIDTH - 4, PROPERTY_DIALOG_HEIGHT - 4));
128
 
129
    m_displayOptions = new ecDisplayOptionsDialog(m_notebook);
130
    m_notebook->AddPage(m_displayOptions, wxT("Display"));
131
    m_displayOptions->TransferDataToWindow();
132
 
133
    m_viewerOptions = new ecViewerOptionsDialog(m_notebook);
134
    m_notebook->AddPage(m_viewerOptions, wxT("Viewers"));
135
    m_viewerOptions->TransferDataToWindow();
136
 
137
#if ecUSE_PATHS_PAGE
138
    m_pathOptions = new ecPathOptionsDialog(m_notebook);
139
    m_notebook->AddPage(m_pathOptions, wxT("Paths"));
140
    m_pathOptions->TransferDataToWindow();
141
#endif
142
 
143
    m_conflictResolutionOptions = new ecConflictResolutionOptionsDialog(m_notebook);
144
    m_notebook->AddPage(m_conflictResolutionOptions, wxT("Conflict Resolution"));
145
    m_conflictResolutionOptions->TransferDataToWindow();
146
 
147
#if ecUSE_RUN_PAGE
148
    m_runOptions = new ecRunOptionsDialog(m_notebook);
149
    m_notebook->AddPage(m_runOptions, wxT("Run Tests"));
150
    m_runOptions->TransferDataToWindow();
151
#endif
152
 
153
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
154
 
155
    item0->Add( m_notebook, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
156
 
157
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
158
 
159
    wxButton *okButton = new wxButton( this, wxID_OK, "&OK", wxDefaultPosition, wxDefaultSize, 0 );
160
    item1->Add( okButton, 0, wxALIGN_CENTRE|wxALL, 5 );
161
 
162
    wxButton *cancelButton = new wxButton( this, wxID_CANCEL, "&Cancel", wxDefaultPosition, wxDefaultSize, 0 );
163
    item1->Add( cancelButton, 0, wxALIGN_CENTRE|wxALL, 5 );
164
 
165
    wxButton *helpButton = new wxButton( this, wxID_HELP, "&Help", wxDefaultPosition, wxDefaultSize, 0 );
166
    item1->Add( helpButton, 0, wxALIGN_CENTRE|wxALL, 5 );
167
 
168
#ifdef __WXGTK__
169
    // Context-sensitive help button (question mark)
170
    wxButton *contextButton = new wxContextHelpButton( this );
171
    item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
172
#endif
173
 
174
    // Necessary to add a spacer or the button highlight interferes with the notebook under wxGTK
175
    item0->Add( 4, 4, 0, wxALIGN_CENTRE|wxALL, 0 );
176
 
177
    item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
178
 
179
    this->SetAutoLayout( TRUE );
180
    this->SetSizer( item0 );
181
 
182
    okButton->SetDefault();
183
    okButton->SetFocus();
184
 
185
    Layout();
186
 
187
    m_displayOptions->Layout();
188
    m_viewerOptions->Layout();
189
#if ecUSE_PATHS_PAGE
190
    m_pathOptions->Layout();
191
#endif
192
    m_conflictResolutionOptions->Layout();
193
#if ecUSE_RUN_PAGE
194
    m_runOptions->Layout();
195
#endif
196
 
197
    okButton->SetHelpText(_("Closes the dialog and saves any changes you may have made."));
198
    cancelButton->SetHelpText(_("Closes the dialog without saving any changes you have made."));
199
    helpButton->SetHelpText(_("Invokes help for the selected dialog."));
200
 
201
    Centre(wxBOTH);
202
}
203
 
204
void ecSettingsDialog::SetSelection(int sel)
205
{
206
    m_notebook->SetSelection(sel);
207
}
208
 
209
void ecSettingsDialog::OnOK(wxCommandEvent& event)
210
{
211
    ecSettings oldSettings(wxGetApp().GetSettings());
212
 
213
    wxDialog::OnOK(event);
214
 
215
    if (wxGetApp().GetSettings().m_bHex != oldSettings.m_bHex)
216
    {
217
        // Refresh the values window and currently selected properties
218
        ecConfigToolHint hint(NULL, ecAllSaved);
219
        if (wxGetApp().GetConfigToolDoc())
220
            wxGetApp().GetConfigToolDoc()->UpdateAllViews (NULL, & hint);
221
    }
222
 
223
    if (wxGetApp().GetSettings().m_showMacroNames != oldSettings.m_showMacroNames)
224
    {
225
        ecConfigToolHint hint(NULL, ecNameFormatChanged);
226
        if (wxGetApp().GetConfigToolDoc())
227
            wxGetApp().GetConfigToolDoc()->UpdateAllViews (NULL, & hint);
228
    }
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), wxT("*.exe"));
675
 
676
    if (dialog.ShowModal() == wxID_OK)
677
    {
678
        ((wxTextCtrl*) FindWindow(ecID_VIEWER_DIALOG_HEADER_TEXT))->SetValue(dialog.GetPath());
679
    }
680
}
681
 
682
void ecViewerOptionsDialog::OnBrowseForBrowser(wxCommandEvent& event)
683
{
684
    wxString currentViewer = ((wxTextCtrl*) FindWindow(ecID_VIEWER_DIALOG_DOC_TEXT))->GetValue();
685
 
686
    wxFileDialog dialog(this, _("Choose a browser executable"), wxPathOnly(currentViewer),
687
        wxFileNameFromPath(currentViewer), wxT("*.exe"));
688
 
689
    if (dialog.ShowModal() == wxID_OK)
690
    {
691
        ((wxTextCtrl*) FindWindow(ecID_VIEWER_DIALOG_DOC_TEXT))->SetValue(dialog.GetPath());
692
    }
693
}
694
 
695
void ecViewerOptionsDialog::OnShowAssociatedViewerInfo(wxCommandEvent& event)
696
{
697
    wxString msg;
698
    wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("html"));
699
    if ( !ft )
700
    {
701
        msg += wxT("It is not possible to determine the associated browser for HTML documents.\n\n");
702
    }
703
    else
704
    {
705
        msg += wxT("The associated MIME type for HTML is:\n");
706
        wxString mimeType(wxT("Unknown"));
707
        ft->GetMimeType(& mimeType);
708
        msg += mimeType;
709
        msg += wxT("\n");
710
 
711
        wxString descr;
712
        if (ft->GetDescription(& descr))
713
        {
714
            msg += descr;
715
            msg += wxT("\n");
716
        }
717
        msg += wxT("\n");
718
 
719
        wxString cmd;
720
        wxString url(wxT("http://example-url.html"));
721
        bool ok = ft->GetOpenCommand(&cmd,
722
            wxFileType::MessageParameters(url, _T("")));
723
 
724
        if (ok)
725
        {
726
            msg += wxT("The associated command is:\n");
727
            msg += cmd;
728
            msg += wxT("\n");
729
        }
730
        msg += wxT("\n");
731
    }
732
 
733
    msg += wxT("If this MIME type is not defined or looks wrong, please consult your ");
734
    msg += wxT("Configuration Tool documentation for how to set up an association.\n");
735
#if defined(__WXGTK__)
736
    msg += wxT("On Unix, this can be done by adding an entry to your ~/.mailcap file.");
737
#endif
738
 
739
    delete ft;
740
 
741
    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_INFORMATION|wxOK);
742
}
743
 
744
/* Path options dialog
745
 */
746
 
747
IMPLEMENT_CLASS(ecPathOptionsDialog, wxPanel)
748
 
749
ecPathOptionsDialog::ecPathOptionsDialog(wxWindow* parent):
750
    wxPanel(parent, ecID_SETTINGS_PATH)
751
{
752
    CreateControls(this);
753
 
754
    SetHelpText(_("The path options dialog allows you to change tool paths."));
755
}
756
 
757
bool ecPathOptionsDialog::TransferDataToWindow()
758
{
759
    wxPanel::TransferDataToWindow();
760
    return TRUE;
761
}
762
 
763
bool ecPathOptionsDialog::TransferDataFromWindow()
764
{
765
    wxPanel::TransferDataFromWindow();
766
    return TRUE;
767
}
768
 
769
void ecPathOptionsDialog::CreateControls( wxPanel *parent)
770
{
771
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
772
 
773
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Build Tools") );
774
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
775
 
776
    wxStaticText *item3 = new wxStaticText( parent, ecID_PATHS_BUILD_MSG,
777
        _("Enter the location of the arm-elf build tools "
778
          "folder, which should contain arm-elf-gcc. You can "
779
          "type in a path or use the Browse button to "
780
          "navigate to a folder."),
781
        wxDefaultPosition, wxSize(-1,70), 0 );
782
    item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
783
 
784
    wxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
785
 
786
    wxString *strs5 = (wxString*) NULL;
787
    wxComboBox *item5 = new wxComboBox( parent, ecID_PATHS_BUILD_COMBO, _(""), wxDefaultPosition, wxSize(100,-1), 0, strs5, wxCB_DROPDOWN );
788
    item4->Add( item5, 20, wxALIGN_CENTRE|wxALL, 5 );
789
 
790
    item1->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
791
 
792
    wxButton *item6 = new wxButton( parent, ecID_PATHS_BUILD_BROWSE, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
793
    item1->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
794
 
795
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
796
 
797
    wxStaticBox *item8 = new wxStaticBox( parent, -1, _("User Tools") );
798
    wxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
799
 
800
    wxStaticText *item9 = new wxStaticText( parent, ecID_PATHS_USER_MSG,
801
        _("Enter the location of the user tools folder, "
802
          "which should contain cat and ls. You can type in "
803
          "a path or use the Browse button to navigate to a "
804
          "folder."),
805
        wxDefaultPosition, wxSize(-1,60), 0 );
806
    item7->Add( item9, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
807
 
808
    wxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
809
 
810
    wxString *strs11 = (wxString*) NULL;
811
    wxComboBox *item11 = new wxComboBox( parent, ecID_PATHS_USER_COMBO, _(""), wxDefaultPosition, wxSize(100,-1), 0, strs11, wxCB_DROPDOWN );
812
    item10->Add( item11, 20, wxALIGN_CENTRE|wxALL, 5 );
813
 
814
    item7->Add( item10, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
815
 
816
    wxButton *item12 = new wxButton( parent, ecID_PATHS_USER_BROWSE, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
817
    item7->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );
818
    item0->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
819
 
820
 
821
    parent->SetAutoLayout( TRUE );
822
    parent->SetSizer( item0 );
823
 
824
    // Add context-sensitive help
825
    FindWindow( ecID_PATHS_BUILD_COMBO )->SetHelpText(_("Select the build tools folder."));
826
    FindWindow( ecID_PATHS_BUILD_BROWSE )->SetHelpText(_("Browse for the build tools folder."));
827
    FindWindow( ecID_PATHS_USER_COMBO )->SetHelpText(_("Select the user tools folder."));
828
    FindWindow( ecID_PATHS_USER_BROWSE )->SetHelpText(_("Browse for the user tools folder."));
829
}
830
 
831
/* Conflict resolution options dialog
832
 */
833
 
834
IMPLEMENT_CLASS(ecConflictResolutionOptionsDialog, wxPanel)
835
 
836
ecConflictResolutionOptionsDialog::ecConflictResolutionOptionsDialog(wxWindow* parent):
837
    wxPanel(parent, ecID_SETTINGS_CONFLICT_RESOLUTION)
838
{
839
    CreateControls(this);
840
 
841
    m_suggestFixes = ((wxGetApp().GetSettings().m_nRuleChecking & ecSettings::SuggestFixes) != 0);
842
    m_immediate = ((wxGetApp().GetSettings().m_nRuleChecking & ecSettings::Immediate) != 0);
843
    m_deferred = ((wxGetApp().GetSettings().m_nRuleChecking & ecSettings::Deferred) != 0);
844
 
845
    SetHelpText(_("The conflict resolution options dialog allows you to change options related to conflict resolution."));
846
}
847
 
848
bool ecConflictResolutionOptionsDialog::TransferDataToWindow()
849
{
850
    wxPanel::TransferDataToWindow();
851
    return TRUE;
852
}
853
 
854
bool ecConflictResolutionOptionsDialog::TransferDataFromWindow()
855
{
856
    wxPanel::TransferDataFromWindow();
857
 
858
    int& ruleChecking = wxGetApp().GetSettings().m_nRuleChecking;
859
 
860
    ruleChecking = 0;
861
    if (m_suggestFixes)
862
        ruleChecking |= ecSettings::SuggestFixes ;
863
    if (m_immediate)
864
        ruleChecking |= ecSettings::Immediate ;
865
    if (m_deferred)
866
        ruleChecking |= ecSettings::Deferred ;
867
 
868
    return TRUE;
869
}
870
 
871
void ecConflictResolutionOptionsDialog::CreateControls( wxPanel *parent)
872
{
873
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
874
 
875
    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Check for conflicts:") );
876
    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
877
 
878
    wxCheckBox *item3 = new wxCheckBox( parent, ecID_CONFLICT_OPTIONS_AFTER_ITEM_CHANGED, _("After any item changed"), wxDefaultPosition, wxDefaultSize, 0 );
879
    item1->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
880
 
881
    wxCheckBox *item4 = new wxCheckBox( parent, ecID_CONFLICT_OPTIONS_BEFORE_SAVING, _("Before &saving configuration"), wxDefaultPosition, wxDefaultSize, 0 );
882
    item1->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
883
 
884
    wxCheckBox *item5 = new wxCheckBox( parent, ecID_CONFLICT_OPTIONS_AUTOSUGGEST, _("&Automatically suggest fixes"), wxDefaultPosition, wxDefaultSize, 0 );
885
    item1->Add( item5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
886
 
887
    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
888
 
889
    parent->SetAutoLayout( TRUE );
890
    parent->SetSizer( item0 );
891
 
892
    // Add context-sensitive help
893
    item2->SetHelpText(_("Options related to conflict resolution."));
894
    item3->SetHelpText(_("Check for configuration option conflicts after any configuration option value is changed."));
895
    item4->SetHelpText(_("Check for configuration option conflicts before saving the configuration."));
896
    item5->SetHelpText(_("When configuration conflicts are found, provide possible solutions."));
897
 
898
    // Add validators
899
    FindWindow(ecID_CONFLICT_OPTIONS_AFTER_ITEM_CHANGED)->SetValidator(wxGenericValidator(& m_immediate));
900
    FindWindow(ecID_CONFLICT_OPTIONS_BEFORE_SAVING)->SetValidator(wxGenericValidator(& m_deferred));
901
    FindWindow(ecID_CONFLICT_OPTIONS_AUTOSUGGEST)->SetValidator(wxGenericValidator(& m_suggestFixes));
902
}
903
 
904
/* Run options dialog
905
 */
906
 
907
IMPLEMENT_CLASS(ecRunOptionsDialog, wxPanel)
908
 
909
BEGIN_EVENT_TABLE(ecRunOptionsDialog, wxPanel)
910
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT, ecRunOptionsDialog::OnUpdateDownloadTimeout)
911
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT, ecRunOptionsDialog::OnUpdateRuntimeTimeout)
912
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR, ecRunOptionsDialog::OnUpdateSerial)
913
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED, ecRunOptionsDialog::OnUpdateSerial)
914
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_TCPIP_HOST, ecRunOptionsDialog::OnUpdateTCPIP)
915
    EVT_UPDATE_UI(ecID_RUN_PROPERTIES_TCPIP_PORT, ecRunOptionsDialog::OnUpdateTCPIP)
916
END_EVENT_TABLE()
917
 
918
ecRunOptionsDialog::ecRunOptionsDialog(wxWindow* parent):
919
    wxPanel(parent, ecID_SETTINGS_RUN),
920
    m_serialOn(TRUE), m_TCPIPOn(FALSE)
921
{
922
    CreateControls(this);
923
 
924
    SetHelpText(_("The run properties dialog allows you to change options related to running tests."));
925
}
926
 
927
bool ecRunOptionsDialog::TransferDataToWindow()
928
{
929
#if 0
930
    // m_strTarget now set in ecConfigToolDoc::RunTests()
931
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
932
    wxString hardware;
933
    if (doc)
934
    {
935
        hardware = doc->GetCdlConfig ()->get_hardware ().c_str();
936
    }
937
    else
938
    {
939
         hardware = _("Unknown");
940
    }
941
    wxGetApp().GetSettings().GetRunTestsSettings().m_strTarget = hardware;
942
#endif
943
 
944
    // Serial/TCPIP
945
    m_serialOn = wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial;
946
    m_TCPIPOn = !wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial;
947
 
948
    switch (wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType)
949
    {
950
    case TIMEOUT_NONE:
951
        m_downloadTimeoutString = _("None");
952
        break;
953
    case TIMEOUT_SPECIFIED:
954
        m_downloadTimeoutString = _("Specified");
955
        break;
956
    default:
957
    case TIMEOUT_AUTOMATIC:
958
        m_downloadTimeoutString = _("Calculated from file size");
959
        break;
960
    }
961
 
962
    switch (wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType)
963
    {
964
    case TIMEOUT_NONE:
965
        m_runtimeTimeoutString = _("None");
966
        break;
967
    case TIMEOUT_SPECIFIED:
968
        m_runtimeTimeoutString = _("Specified");
969
        break;
970
    default:
971
    case TIMEOUT_AUTOMATIC:
972
        m_runtimeTimeoutString = _("Default");
973
        break;
974
    }
975
 
976
    m_baudString.Printf("%d", wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud);
977
 
978
    wxPanel::TransferDataToWindow();
979
 
980
    return TRUE;
981
}
982
 
983
bool ecRunOptionsDialog::TransferDataFromWindow()
984
{
985
    wxPanel::TransferDataFromWindow();
986
 
987
    if (m_downloadTimeoutString == _("None"))
988
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_NONE;
989
    else if (m_downloadTimeoutString == _("Specified"))
990
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_SPECIFIED;
991
    else
992
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_AUTOMATIC;
993
 
994
    if (m_runtimeTimeoutString == _("None"))
995
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_NONE;
996
    else if (m_runtimeTimeoutString == _("Specified"))
997
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_SPECIFIED;
998
    else
999
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_AUTOMATIC;
1000
 
1001
    wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud = (int) wxAtol(m_baudString);
1002
 
1003
    // Serial/TCPIP
1004
    wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial = m_serialOn;
1005
 
1006
    return TRUE;
1007
}
1008
 
1009
void ecRunOptionsDialog::CreateControls( wxPanel *parent)
1010
{
1011
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1012
 
1013
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
1014
 
1015
    wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, _("Platform:"), wxDefaultPosition, wxDefaultSize, 0 );
1016
    item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
1017
 
1018
    wxStaticText *item3 = new wxStaticText( parent, ecID_RUN_PROPERTIES_PLATFORM, _("xxxx"), wxDefaultPosition, wxDefaultSize, 0 );
1019
    item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
1020
 
1021
    item0->Add( item1, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP, 5 );
1022
 
1023
    wxStaticBox *item5 = new wxStaticBox( parent, -1, _("Timeouts") );
1024
    wxSizer *item4 = new wxStaticBoxSizer( item5, wxVERTICAL );
1025
 
1026
    wxSizer *item6 = new wxBoxSizer( wxHORIZONTAL );
1027
 
1028
    wxStaticText *item7 = new wxStaticText( parent, wxID_STATIC, _("Download:"), wxDefaultPosition, wxSize(60,-1), 0 );
1029
    item6->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
1030
 
1031
    wxString strs8[] =
1032
    {
1033
        _("None"),
1034
        _("Specified"),
1035
        _("Calculated from file size")
1036
    };
1037
    wxChoice *item8 = new wxChoice( parent, ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE, wxDefaultPosition, wxSize(100,-1), 3, strs8, 0 );
1038
    item6->Add( item8, 1, wxALIGN_CENTRE|wxALL, 5 );
1039
 
1040
    wxSpinCtrl *item9 = new wxSpinCtrl( parent, ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT, "0", wxDefaultPosition, wxSize(50,-1), 0, 0, 10000, 0 );
1041
    item6->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 );
1042
 
1043
    item4->Add( item6, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1044
 
1045
    wxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
1046
 
1047
    wxStaticText *item11 = new wxStaticText( parent, wxID_STATIC, _("Runtime:"), wxDefaultPosition, wxSize(60,-1), 0 );
1048
    item10->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
1049
 
1050
    wxString strs12[] =
1051
    {
1052
        _("None"),
1053
        _("Specified"),
1054
        _("Default")
1055
    };
1056
    wxChoice *item12 = new wxChoice( parent, ecID_RUN_PROPERTIES_RUNTIME_CHOICE, wxDefaultPosition, wxSize(100,-1), 3, strs12, 0 );
1057
    item10->Add( item12, 1, wxALIGN_CENTRE|wxALL, 5 );
1058
 
1059
    wxSpinCtrl *item13 = new wxSpinCtrl( parent, ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT, "0", wxDefaultPosition, wxSize(50,-1), 0, 0, 10000, 0 );
1060
    item10->Add( item13, 0, wxALIGN_CENTRE|wxALL, 5 );
1061
 
1062
    item4->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1063
 
1064
    item0->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1065
 
1066
    wxStaticBox *item15 = new wxStaticBox( parent, -1, _("Connection") );
1067
    wxSizer *item14 = new wxStaticBoxSizer( item15, wxVERTICAL );
1068
 
1069
    wxSizer *item16 = new wxBoxSizer( wxHORIZONTAL );
1070
 
1071
    wxRadioButton *item17 = new wxRadioButton( parent, ecID_RUN_PROPERTIES_SERIAL, _("&Serial"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1072
    item16->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 );
1073
 
1074
    item16->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 5 );
1075
 
1076
    wxStaticText *item18 = new wxStaticText( parent, wxID_STATIC, _("&Port:"), wxDefaultPosition, wxDefaultSize, 0 );
1077
    item16->Add( item18, 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5 );
1078
 
1079
    wxString strs19[] =
1080
    {
1081
        _("COM1"),
1082
        _("COM2"),
1083
        _("COM3"),
1084
        _("COM4"),
1085
        _("COM5"),
1086
        _("COM6"),
1087
        _("COM7"),
1088
        _("COM8")
1089
    };
1090
    wxChoice *item19 = new wxChoice( parent, ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR, wxDefaultPosition, wxSize(70,-1), 8, strs19, 0 );
1091
    item16->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 );
1092
 
1093
    wxStaticText *item20 = new wxStaticText( parent, wxID_STATIC, _("&Baud:"), wxDefaultPosition, wxDefaultSize, 0 );
1094
    item16->Add( item20, 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5 );
1095
 
1096
    wxString strs21[] =
1097
    {
1098
        _("110"),
1099
        _("300"),
1100
        _("600"),
1101
        _("1200"),
1102
        _("2400"),
1103
        _("4800"),
1104
        _("9600"),
1105
        _("14400"),
1106
        _("19200"),
1107
        _("38400"),
1108
        _("56000"),
1109
        _("57600"),
1110
        _("115200"),
1111
        _("128000"),
1112
        _("256000")
1113
    };
1114
    wxChoice *item21 = new wxChoice( parent, ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED, wxDefaultPosition, wxSize(70,-1), 15, strs21, 0 );
1115
    item16->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
1116
 
1117
    item14->Add( item16, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1118
 
1119
    wxSizer *item22 = new wxBoxSizer( wxHORIZONTAL );
1120
 
1121
    wxRadioButton *item23 = new wxRadioButton( parent, ecID_RUN_PROPERTIES_TCPIP, _("&TCP/IP"), wxDefaultPosition, wxDefaultSize, 0 );
1122
    item22->Add( item23, 0, wxALIGN_CENTRE|wxALL, 5 );
1123
 
1124
    item22->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 5 );
1125
 
1126
    wxStaticText *item24 = new wxStaticText( parent, wxID_STATIC, _("&Address:"), wxDefaultPosition, wxDefaultSize, 0 );
1127
    item22->Add( item24, 0, wxALIGN_CENTRE|wxALL, 5 );
1128
 
1129
    wxTextCtrl *item25 = new wxTextCtrl( parent, ecID_RUN_PROPERTIES_TCPIP_HOST, _(""), wxDefaultPosition, wxSize(100,-1), 0 );
1130
    item22->Add( item25, 0, wxALIGN_CENTRE|wxALL, 5 );
1131
 
1132
    wxStaticText *item26 = new wxStaticText( parent, wxID_STATIC, _(":"), wxDefaultPosition, wxDefaultSize, 0 );
1133
    item22->Add( item26, 0, wxALIGN_CENTRE, 5 );
1134
 
1135
    wxTextCtrl *item27 = new wxTextCtrl( parent, ecID_RUN_PROPERTIES_TCPIP_PORT, _(""), wxDefaultPosition, wxSize(40,-1), 0 );
1136
    item22->Add( item27, 0, wxALIGN_CENTRE|wxALL, 5 );
1137
 
1138
    item14->Add( item22, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1139
 
1140
    item0->Add( item14, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1141
 
1142
    parent->SetAutoLayout( TRUE );
1143
    parent->SetSizer( item0 );
1144
 
1145
    // Add context-sensitive help
1146
    FindWindow(ecID_RUN_PROPERTIES_PLATFORM)->SetHelpText(_("Shows the hardware currently selected."));
1147
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE)->SetHelpText(_("Specifies the kind of timeout to be applied to the download phase of test execution."));
1148
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT)->SetHelpText(_("Specifies a fixed-period timeout (in seconds) to be applied to the download phase of test execution."));
1149
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_CHOICE)->SetHelpText(_("Specifies the kind of timeout to be applied to the run phase of test execution."));
1150
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT)->SetHelpText(_("Specifies a fixed-period timeout (in seconds) to be applied to the run phase of test execution."));
1151
    FindWindow(ecID_RUN_PROPERTIES_SERIAL)->SetHelpText(_("Specifies that download is local, using a serial communications port."));
1152
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR)->SetHelpText(_("Specifies the communication ports to be used for local download."));
1153
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED)->SetHelpText(_("Specifies the baud rate at which the communications port is to operate."));
1154
    FindWindow(ecID_RUN_PROPERTIES_TCPIP)->SetHelpText(_("Specifies that download is remote, using GDB remote protocol via a TCP/IP port."));
1155
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_HOST)->SetHelpText(_("Specifies the TCP/IP host to be used for remote download."));
1156
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_PORT)->SetHelpText(_("Specifies the TCP/IP port number to be used for remote download."));
1157
 
1158
    // Add validators
1159
    FindWindow(ecID_RUN_PROPERTIES_PLATFORM)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_strTarget));
1160
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE)->SetValidator(wxGenericValidator(& m_downloadTimeoutString));
1161
    FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_TIMEOUT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeout));
1162
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_CHOICE)->SetValidator(wxGenericValidator(& m_runtimeTimeoutString));
1163
    FindWindow(ecID_RUN_PROPERTIES_RUNTIME_TIMEOUT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeout));
1164
    FindWindow(ecID_RUN_PROPERTIES_SERIAL)->SetValidator(wxGenericValidator(& m_serialOn));
1165
    FindWindow(ecID_RUN_PROPERTIES_TCPIP)->SetValidator(wxGenericValidator(& m_TCPIPOn));
1166
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_ADDR)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_strPort));
1167
    FindWindow(ecID_RUN_PROPERTIES_SERIAL_PORT_SPEED)->SetValidator(wxGenericValidator(& m_baudString));
1168
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_HOST)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_strLocalTCPIPHost));
1169
    FindWindow(ecID_RUN_PROPERTIES_TCPIP_PORT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().GetRunTestsSettings().m_nLocalTCPIPPort));
1170
 
1171
}
1172
 
1173
void ecRunOptionsDialog::OnUpdateDownloadTimeout(wxUpdateUIEvent& event)
1174
{
1175
    wxChoice* downloadTimeoutChoice = (wxChoice*) FindWindow(ecID_RUN_PROPERTIES_DOWNLOAD_CHOICE);
1176
    wxString sel = downloadTimeoutChoice->GetStringSelection();
1177
    event.Enable( sel == _("Specified") );
1178
}
1179
 
1180
void ecRunOptionsDialog::OnUpdateRuntimeTimeout(wxUpdateUIEvent& event)
1181
{
1182
    wxChoice* runTimeoutChoice = (wxChoice*) FindWindow(ecID_RUN_PROPERTIES_RUNTIME_CHOICE);
1183
    wxString sel = runTimeoutChoice->GetStringSelection();
1184
    event.Enable( sel == _("Specified") );
1185
}
1186
 
1187
void ecRunOptionsDialog::OnUpdateSerial(wxUpdateUIEvent& event)
1188
{
1189
    wxRadioButton* radio = (wxRadioButton*) FindWindow(ecID_RUN_PROPERTIES_SERIAL);
1190
    event.Enable( radio->GetValue() );
1191
}
1192
 
1193
void ecRunOptionsDialog::OnUpdateTCPIP(wxUpdateUIEvent& event)
1194
{
1195
    wxRadioButton* radio = (wxRadioButton*) FindWindow(ecID_RUN_PROPERTIES_SERIAL);
1196
    event.Enable( !radio->GetValue() );
1197
}

powered by: WebSVN 2.1.0

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