1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
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)
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
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.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
27 //===========================================================================
28 //#####DESCRIPTIONBEGIN####
31 // Contact(s): julians
35 // Description: Implementation file for ecSectionDialog
42 //####DESCRIPTIONEND####
44 //===========================================================================
47 #pragma implementation "sectiondlg.cpp"
56 #include "wx/notebook.h"
57 #include "wx/cshelp.h"
59 #include "sectiondlg.h"
60 #include "configtool.h"
66 IMPLEMENT_CLASS(ecSectionDialog, wxDialog)
68 BEGIN_EVENT_TABLE(ecSectionDialog, wxDialog)
69 EVT_BUTTON(wxID_OK, ecSectionDialog::OnOK)
70 EVT_BUTTON(wxID_CANCEL, ecSectionDialog::OnCancel)
71 EVT_BUTTON(wxID_HELP, ecSectionDialog::OnHelp)
72 EVT_BUTTON(wxID_APPLY, ecSectionDialog::OnApply)
73 EVT_NOTEBOOK_PAGE_CHANGED(-1, ecSectionDialog::OnPageChange)
76 #define PROPERTY_DIALOG_WIDTH 400
77 #define PROPERTY_DIALOG_HEIGHT 380
79 // For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
80 // (209 x 162 dialog units)
82 ecSectionDialog::ecSectionDialog(wxWindow* parent):
85 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
87 wxDialog::Create(parent, ecID_SECTION_DIALOG, _("Section Properties"), wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT));
89 // Under MSW, we don't seem to be able to react to a click on the dialog background (no
90 // event is generated).
91 SetHelpText(_("TODO"));
94 wxSize ppi = dc.GetPPI();
96 //double scaleFactor = ((double) charH) / 13.0;
97 double scaleFactor = ((double) ppi.y) / 96.0;
98 // Fudge the scale factor to make the dialog slightly smaller,
99 // otherwise it's a bit big. (We're assuming that most displays
100 // are 96 or 120 ppi).
103 int dialogWidth = (int)(PROPERTY_DIALOG_WIDTH * scaleFactor);
104 int dialogHeight = (int)(PROPERTY_DIALOG_HEIGHT * scaleFactor);
105 SetSize(dialogWidth, dialogHeight);
107 m_notebook = new wxNotebook(this, ecID_SETTINGS_NOTEBOOK,
108 wxPoint(2, 2), wxSize(PROPERTY_DIALOG_WIDTH - 4, PROPERTY_DIALOG_HEIGHT - 4));
110 m_general = new ecSectionGeneralDialog(m_notebook);
111 m_notebook->AddPage(m_general, wxT("General"));
112 m_general->TransferDataToWindow();
114 m_relocation = new ecSectionRelocationDialog(m_notebook);
115 m_notebook->AddPage(m_relocation, wxT("Relocation"));
116 m_relocation->TransferDataToWindow();
118 m_note = new ecSectionNoteDialog(m_notebook);
119 m_notebook->AddPage(m_note, wxT("Note"));
120 m_note->TransferDataToWindow();
122 wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
124 item0->Add( m_notebook, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
126 wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
128 wxButton *okButton = new wxButton( this, wxID_OK, "&OK", wxDefaultPosition, wxDefaultSize, 0 );
129 item1->Add( okButton, 0, wxALIGN_CENTRE|wxALL, 5 );
131 wxButton *cancelButton = new wxButton( this, wxID_CANCEL, "&Cancel", wxDefaultPosition, wxDefaultSize, 0 );
132 item1->Add( cancelButton, 0, wxALIGN_CENTRE|wxALL, 5 );
134 wxButton *applyButton = new wxButton( this, wxID_APPLY, "&Apply", wxDefaultPosition, wxDefaultSize, 0 );
135 item1->Add( applyButton, 0, wxALIGN_CENTRE|wxALL, 5 );
137 wxButton *helpButton = new wxButton( this, wxID_HELP, "&Help", wxDefaultPosition, wxDefaultSize, 0 );
138 item1->Add( helpButton, 0, wxALIGN_CENTRE|wxALL, 5 );
141 // Context-sensitive help button (question mark)
142 wxButton *contextButton = new wxContextHelpButton( this );
143 item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
146 // Necessary to add a spacer or the button highlight interferes with the notebook under wxGTK
147 item0->Add( 4, 4, 0, wxALIGN_CENTRE|wxALL, 0 );
149 item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
151 this->SetAutoLayout( TRUE );
152 this->SetSizer( item0 );
154 okButton->SetDefault();
155 okButton->SetFocus();
160 m_relocation->Layout();
163 okButton->SetHelpText(_("Closes the dialog and saves any changes you may have made."));
164 cancelButton->SetHelpText(_("Closes the dialog without saving any changes you have made."));
165 helpButton->SetHelpText(_("Invokes help for the selected dialog."));
166 applyButton->SetHelpText(_("Immediately applies any changes you may have made."));
171 void ecSectionDialog::OnOK(wxCommandEvent& event)
173 wxDialog::OnOK(event);
176 void ecSectionDialog::OnCancel(wxCommandEvent& event)
178 wxDialog::OnCancel(event);
181 void ecSectionDialog::OnApply(wxCommandEvent& event)
185 void ecSectionDialog::OnHelp(wxCommandEvent& event)
187 int sel = m_notebook->GetSelection();
189 wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));
191 wxWindow* page = (wxWindow*) m_notebook->GetPage(sel);
194 if (page == m_general)
196 helpTopic = wxT("General section dialog");
199 if (!helpTopic.IsEmpty())
201 wxGetApp().GetHelpController().KeywordSearch(helpTopic);
205 // This sets the text for the selected page, but doesn't help
206 // when trying to click on a tab: we would expect the appropriate help
207 // for that tab. We would need to look at the tabs to do this, from within OnContextHelp -
208 // probably not worth it.
209 void ecSectionDialog::OnPageChange(wxNotebookEvent& event)
213 int sel = m_notebook->GetSelection();
217 wxWindow* page = m_notebook->GetPage(sel);
222 if (page == m_displayOptions)
223 helpText = _("The display options dialog allows you to change display-related options.");
224 else if (page == m_viewerOptions)
225 helpText = _("The viewer options dialog allows you to configure viewers.");
226 else if (page == m_pathOptions)
227 helpText = _("The path options dialog allows you to change tool paths.");
228 else if (page == m_conflictResolutionOptions)
229 helpText = _("The conflict resolution options dialog allows you to change options related to conflict resolution.");
230 m_notebook->SetHelpText(helpText);
235 bool ecSectionDialog::TransferDataToWindow()
237 m_general->TransferDataToWindow();
238 m_relocation->TransferDataToWindow();
239 m_note->TransferDataToWindow();
243 bool ecSectionDialog::TransferDataFromWindow()
245 m_general->TransferDataFromWindow();
246 m_relocation->TransferDataFromWindow();
247 m_note->TransferDataFromWindow();
254 IMPLEMENT_CLASS(ecSectionGeneralDialog, wxPanel)
256 ecSectionGeneralDialog::ecSectionGeneralDialog(wxWindow* parent):
257 wxPanel(parent, ecID_SECTION_GENERAL)
259 CreateControls(this);
261 SetHelpText(_("TODO"));
264 void ecSectionGeneralDialog::CreateControls( wxPanel *parent)
266 wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
268 wxStaticBox *item2 = new wxStaticBox( parent, -1, "Name" );
269 wxSizer *item1 = new wxStaticBoxSizer( item2, wxHORIZONTAL );
271 wxSizer *item3 = new wxBoxSizer( wxVERTICAL );
273 wxRadioButton *item4 = new wxRadioButton( parent, ecID_SECTION_GENERAL_LINKER, "&Linker-defined:", wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
274 item3->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
276 wxRadioButton *item5 = new wxRadioButton( parent, ecID_SECTION_GENERAL_USER, "&User-defined:", wxDefaultPosition, wxDefaultSize, 0 );
277 item3->Add( item5, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
279 item1->Add( item3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
281 item1->Add( 5, 5, 1, wxALIGN_CENTRE|wxALL, 5 );
283 wxSizer *item6 = new wxBoxSizer( wxVERTICAL );
285 wxTextCtrl *item7 = new wxTextCtrl( parent, ecID_SECTION_GENERAL_LINKER_TEXT, "", wxDefaultPosition, wxSize(200,-1), 0 );
286 item6->Add( item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
292 wxChoice *item8 = new wxChoice( parent, ecID_SECTION_GENERAL_USER_TEXT, wxDefaultPosition, wxSize(100,-1), 1, strs8, 0 );
293 item6->Add( item8, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
295 wxSizer *item9 = new wxBoxSizer( wxHORIZONTAL );
297 wxCheckBox *item10 = new wxCheckBox( parent, ecID_SECTION_GENERAL_KNOWN_SIZE, "&Known size:", wxDefaultPosition, wxDefaultSize, 0 );
298 item9->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 );
304 wxChoice *item11 = new wxChoice( parent, ecID_SECTION_GENERAL_KNOWN_SIZE_CHOICE, wxDefaultPosition, wxSize(100,-1), 1, strs11, 0 );
305 item9->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
307 item6->Add( item9, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
309 item1->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
311 item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
313 //item0->Add( 20, 20, 0, wxALIGN_CENTRE|wxALL, 5 );
314 item0->Add( 1, 1, 20, wxALIGN_CENTRE|wxALL, 0 );
316 wxStaticBox *item13 = new wxStaticBox( parent, -1, "Find Location (VMA)" );
317 wxSizer *item12 = new wxStaticBoxSizer( item13, wxHORIZONTAL );
319 wxSizer *item14 = new wxBoxSizer( wxVERTICAL );
321 wxRadioButton *item15 = new wxRadioButton( parent, ecID_SECTION_GENERAL_ABSOLUTE, "A&bsolute:", wxDefaultPosition, wxDefaultSize, 0 );
322 item14->Add( item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
324 wxRadioButton *item16 = new wxRadioButton( parent, ecID_SECTION_GENERAL_FOLLOWING, "&Following:", wxDefaultPosition, wxDefaultSize, 0 );
325 item14->Add( item16, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
327 item12->Add( item14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
329 item12->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
331 wxSizer *item17 = new wxBoxSizer( wxVERTICAL );
333 wxTextCtrl *item18 = new wxTextCtrl( parent, ecID_SECTION_GENERAL_ABSOLUTE_TEXT, "", wxDefaultPosition, wxSize(200,-1), 0 );
334 item17->Add( item18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
340 wxChoice *item19 = new wxChoice( parent, ecID_SECTION_GENERAL_FOLLOWING_TEXT, wxDefaultPosition, wxSize(100,-1), 1, strs19, 0 );
341 item17->Add( item19, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
343 wxSizer *item20 = new wxBoxSizer( wxHORIZONTAL );
345 wxStaticText *item21 = new wxStaticText( parent, wxID_STATIC, "&Alignment:", wxDefaultPosition, wxDefaultSize, 0 );
346 item20->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
352 wxChoice *item22 = new wxChoice( parent, ecID_SECTION_GENERAL_ALIGNMENT, wxDefaultPosition, wxSize(100,-1), 1, strs22, 0 );
353 item20->Add( item22, 0, wxALIGN_CENTRE|wxALL, 5 );
355 item17->Add( item20, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
357 item12->Add( item17, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
359 item0->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
362 // Add context-sensitive help
363 //item2->SetHelpText(_(""));
365 parent->SetAutoLayout( TRUE );
366 parent->SetSizer( item0 );
369 bool ecSectionGeneralDialog::TransferDataToWindow()
371 wxPanel::TransferDataToWindow();
375 bool ecSectionGeneralDialog::TransferDataFromWindow()
377 wxPanel::TransferDataFromWindow();
384 IMPLEMENT_CLASS(ecSectionRelocationDialog, wxPanel)
386 ecSectionRelocationDialog::ecSectionRelocationDialog(wxWindow* parent):
387 wxPanel(parent, ecID_SECTION_RELOCATION)
389 CreateControls(this);
391 SetHelpText(_("TODO"));
394 void ecSectionRelocationDialog::CreateControls( wxPanel *parent)
396 wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
398 item0->Add( 20, 20, 5, wxALIGN_CENTRE|wxALL, 5 );
400 wxCheckBox *item1 = new wxCheckBox( parent, ecID_SECTION_RELOCATION_RELOCATE, "&Relocate section", wxDefaultPosition, wxDefaultSize, 0 );
401 item0->Add( item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 );
403 item0->Add( 20, 20, 20, wxALIGN_CENTRE|wxALL, 0 );
405 wxStaticBox *item3 = new wxStaticBox( parent, -1, "Initial Location (LMA)" );
406 wxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
408 wxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
410 wxRadioButton *item5 = new wxRadioButton( parent, ecID_SECTION_RELOCATION_ABSOLUTE, "A&bsolute:", wxDefaultPosition, wxDefaultSize, 0 );
411 item4->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
413 item4->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
415 wxTextCtrl *item6 = new wxTextCtrl( parent, ecID_SECTION_RELOCATION_ABSOLUTE_TEXT, "", wxDefaultPosition, wxSize(80,-1), 0 );
416 item4->Add( item6, 20, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
418 item2->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
420 wxSizer *item7 = new wxBoxSizer( wxHORIZONTAL );
422 wxRadioButton *item8 = new wxRadioButton( parent, ecID_SECTION_RELOCATION_FOLLOWING, "&Following:", wxDefaultPosition, wxDefaultSize, 0 );
423 item7->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 );
425 item7->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
431 wxChoice *item9 = new wxChoice( parent, ecID_SECTION_RELOCATION_FOLLOWING_CHOICE, wxDefaultPosition, wxSize(100,-1), 1, strs9, 0 );
432 item7->Add( item9, 20, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
434 item2->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
436 item0->Add( item2, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
438 item0->Add( 20, 20, 20, wxALIGN_CENTRE|wxALL, 5 );
440 // Add context-sensitive help
441 //item2->SetHelpText(_(""));
443 parent->SetAutoLayout( TRUE );
444 parent->SetSizer( item0 );
447 bool ecSectionRelocationDialog::TransferDataToWindow()
449 wxPanel::TransferDataToWindow();
453 bool ecSectionRelocationDialog::TransferDataFromWindow()
455 wxPanel::TransferDataFromWindow();
462 IMPLEMENT_CLASS(ecSectionNoteDialog, wxPanel)
464 ecSectionNoteDialog::ecSectionNoteDialog(wxWindow* parent):
465 wxPanel(parent, ecID_SECTION_NOTE)
467 CreateControls(this);
469 SetHelpText(_("TODO"));
472 void ecSectionNoteDialog::CreateControls( wxPanel *parent)
474 wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
476 wxTextCtrl *item1 = new wxTextCtrl( parent, ecID_SECTION_NOTE_TEXT, "", wxDefaultPosition, wxSize(80,40), wxTE_MULTILINE );
477 item0->Add( item1, 20, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
480 // Add context-sensitive help
481 //item2->SetHelpText(_(""));
483 parent->SetAutoLayout( TRUE );
484 parent->SetSizer( item0 );
487 bool ecSectionNoteDialog::TransferDataToWindow()
489 wxPanel::TransferDataToWindow();
493 bool ecSectionNoteDialog::TransferDataFromWindow()
495 wxPanel::TransferDataFromWindow();