1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 // Copyright (C) 2003 John Dallaway
7 // This program is part of the eCos host tools.
9 // This program is free software; you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by the Free
11 // Software Foundation; either version 2 of the License, or (at your option)
14 // This program is distributed in the hope that it will be useful, but WITHOUT
15 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 // You should have received a copy of the GNU General Public License along with
20 // this program; if not, write to the Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // ----------------------------------------------------------------------------
25 //####COPYRIGHTEND####
28 //===========================================================================
29 //#####DESCRIPTIONBEGIN####
31 // Author(s): julians, jld
32 // Contact(s): julians
36 // Description: Implementation file for the ecPlatformEditorDialog
43 //####DESCRIPTIONEND####
45 //===========================================================================
47 // ============================================================================
49 // ============================================================================
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 #pragma implementation "platformeditordlg.h"
58 // Includes other headers for precompiled compilation
65 #include "wx/cshelp.h"
66 #include "wx/valgen.h"
68 #include "eCosTestPlatform.h"
69 #include "configtool.h"
70 #include "platformeditordlg.h"
73 #include "wx/msw/winundef.h"
77 //static const wxChar* g_NewLineToReplace = wxT("\r\n");
79 static const wxChar* g_NewLineToReplace = wxT("\n");
82 BEGIN_EVENT_TABLE(ecPlatformEditorDialog, ecDialog)
83 EVT_BUTTON(wxID_OK, ecPlatformEditorDialog::OnOK)
84 EVT_BUTTON(wxID_CANCEL, ecPlatformEditorDialog::OnCancel)
85 EVT_COMBOBOX(ecID_MODIFY_PLATFORM_PREFIX, ecPlatformEditorDialog::OnChangeNewPlatformPrefix)
86 EVT_TEXT(ecID_MODIFY_PLATFORM_NAME, ecPlatformEditorDialog::OnChangeNewPlatform)
87 EVT_INIT_DIALOG(ecPlatformEditorDialog::OnInitDialog)
90 // ----------------------------------------------------------------------------
92 // ----------------------------------------------------------------------------
95 ecPlatformEditorDialog::ecPlatformEditorDialog(wxWindow* parent)
97 m_bServerSideGdb = FALSE;
99 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
101 ecDialog::Create(parent, ecID_PLATFORM_EDITOR_DIALOG, _("Platforms"),
102 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
104 CreateControls(this);
109 void ecPlatformEditorDialog::OnInitDialog(wxInitDialogEvent& event)
111 m_strGDB.Replace(wxT(";"), g_NewLineToReplace);
113 wxComboBox* comboBox = (wxComboBox*) FindWindow(ecID_MODIFY_PLATFORM_PREFIX);
116 for ( i=0 ; i < CeCosTestPlatform::Count() ; i++ )
118 if (wxNOT_FOUND == comboBox->FindString(CeCosTestPlatform::Get(i)->Prefix()))
119 comboBox->Append(CeCosTestPlatform::Get(i)->Prefix());
122 wxDialog::OnInitDialog(event);
124 SetTitle(m_strCaption);
125 if( ! m_strPlatform.IsEmpty() )
127 ((wxTextCtrl*)FindWindow(ecID_MODIFY_PLATFORM_NAME))->SetValue(m_strPlatform);
129 FindWindow(ecID_MODIFY_PLATFORM_NAME)->Enable(FALSE);
132 FindWindow(wxID_OK)->Enable(!m_strPlatform.IsEmpty() && !m_strPrefix.IsEmpty());
135 void ecPlatformEditorDialog::CreateControls(wxWindow* parent)
137 wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
139 wxSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
141 wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, _("Platform &name:"), wxDefaultPosition, wxDefaultSize, 0 );
142 item1->Add( item2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
144 wxTextCtrl *item3 = new wxTextCtrl( parent, ecID_MODIFY_PLATFORM_NAME, _(""), wxDefaultPosition, wxSize(240,-1), 0 );
145 item1->Add( item3, 0, wxGROW|wxALL, 5 );
147 wxStaticText *item4 = new wxStaticText( parent, wxID_STATIC, _("Command &prefix:"), wxDefaultPosition, wxDefaultSize, 0 );
148 item1->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
150 wxString *strs5 = (wxString*) NULL;
151 wxComboBox *item5 = new wxComboBox( parent, ecID_MODIFY_PLATFORM_PREFIX, "", wxDefaultPosition, wxDefaultSize, 0, strs5, wxCB_DROPDOWN );
152 item1->Add( item5, 0, wxGROW|wxALL, 5 );
154 wxStaticText *item6 = new wxStaticText( parent, wxID_STATIC, _("Arguments for &GDB:"), wxDefaultPosition, wxDefaultSize, 0 );
155 item1->Add( item6, 0, wxALL, 5 );
157 wxTextCtrl *item7 = new wxTextCtrl( parent, ecID_MODIFY_PLATFORM_ARGS, _(""), wxDefaultPosition, wxSize(-1,140), wxTE_MULTILINE );
158 item1->Add( item7, 0, wxGROW|wxALL, 5 );
160 wxStaticText *item8 = new wxStaticText( parent, wxID_STATIC, _("Inferior:"), wxDefaultPosition, wxDefaultSize, 0 );
161 item1->Add( item8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
163 wxTextCtrl *item9 = new wxTextCtrl( parent, ecID_MODIFY_PLATFORM_INFERIOR, _(""), wxDefaultPosition, wxDefaultSize, 0 );
164 item1->Add( item9, 0, wxGROW|wxALL, 5 );
166 wxStaticText *item10 = new wxStaticText( parent, wxID_STATIC, _("Prompt:"), wxDefaultPosition, wxDefaultSize, 0 );
167 item1->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
169 wxTextCtrl *item11 = new wxTextCtrl( parent, ecID_MODIFY_PLATFORM_PROMPT, _(""), wxDefaultPosition, wxDefaultSize, 0 );
170 item1->Add( item11, 0, wxGROW|wxALL, 5 );
172 #if USE_SS_GDB_CONTROL
173 item1->Add( 20, 20, 0, wxALIGN_CENTRE|wxALL, 5 );
175 wxCheckBox *item12 = new wxCheckBox( parent, ecID_MODIFY_PLATFORM_SS_GDB, _("Server-side GDB"), wxDefaultPosition, wxDefaultSize, 0 );
176 item1->Add( item12, 0, wxGROW|wxALL, 5 );
178 item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
180 wxSizer *item13 = new wxBoxSizer( wxHORIZONTAL );
182 wxButton *item14 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
183 item14->SetDefault();
184 item13->Add( item14, 0, wxALIGN_CENTRE|wxALL, 5 );
186 wxButton *item15 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
187 item13->Add( item15, 0, wxALIGN_CENTRE|wxALL, 5 );
190 wxButton *contextButton = new wxContextHelpButton( parent );
191 item13->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
194 item0->Add( item13, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
196 // Can't do this from wxDesigner :-(
197 ((wxFlexGridSizer*)item1)->AddGrowableCol(1);
198 ((wxFlexGridSizer*)item1)->AddGrowableRow(2);
200 parent->SetAutoLayout( TRUE );
201 parent->SetSizer( item0 );
203 item0->Fit( parent );
204 item0->SetSizeHints( parent );
207 item14->SetDefault();
209 // Add context-sensitive help text
210 parent->FindWindow( ecID_MODIFY_PLATFORM_NAME )->SetHelpText(_("Specifies the name of the platform. Platform names are arbitrary strings, but must be unique for a given user."));
211 parent->FindWindow( ecID_MODIFY_PLATFORM_PREFIX )->SetHelpText(_("Specifies the prefix to be used when invoking tools (for example, 'arm-elf' is the correct prefix if the appropriate gdb executable is arm-elf-gdb)."));
212 parent->FindWindow( ecID_MODIFY_PLATFORM_ARGS )->SetHelpText(_("Specifies any additional arguments to be used when invoking gdb."));
213 parent->FindWindow( ecID_MODIFY_PLATFORM_INFERIOR )->SetHelpText(_("The gdb command to run."));
214 parent->FindWindow( ecID_MODIFY_PLATFORM_PROMPT )->SetHelpText(_("The gdb prompt."));
215 #if USE_SS_GDB_CONTROL
216 parent->FindWindow( ecID_MODIFY_PLATFORM_SS_GDB )->SetHelpText(_("TODO"));
218 parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and saves any changes you have made."));
219 parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Closes the dialog without saving any changes you have made."));
222 parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
226 parent->FindWindow( ecID_MODIFY_PLATFORM_NAME )->SetValidator(wxGenericValidator(& m_strPlatform));
227 parent->FindWindow( ecID_MODIFY_PLATFORM_PREFIX )->SetValidator(wxGenericValidator(& m_strPrefix));
228 parent->FindWindow( ecID_MODIFY_PLATFORM_ARGS )->SetValidator(wxGenericValidator(& m_strGDB));
229 parent->FindWindow( ecID_MODIFY_PLATFORM_INFERIOR )->SetValidator(wxGenericValidator(& m_strInferior));
230 parent->FindWindow( ecID_MODIFY_PLATFORM_PROMPT )->SetValidator(wxGenericValidator(& m_strPrompt));
231 #if USE_SS_GDB_CONTROL
232 parent->FindWindow( ecID_MODIFY_PLATFORM_SS_GDB )->SetValidator(wxGenericValidator(& m_bServerSideGdb));
236 void ecPlatformEditorDialog::OnChangeNewPlatformPrefix(wxCommandEvent& event)
238 FindWindow(wxID_OK)->Enable(!((wxTextCtrl*)FindWindow(ecID_MODIFY_PLATFORM_NAME))->GetValue().IsEmpty() &&
239 !((wxComboBox*)FindWindow(ecID_MODIFY_PLATFORM_PREFIX))->GetValue().IsEmpty());
242 void ecPlatformEditorDialog::OnChangeNewPlatform(wxCommandEvent& event)
244 FindWindow(wxID_OK)->Enable(!((wxTextCtrl*)FindWindow(ecID_MODIFY_PLATFORM_NAME))->GetValue().IsEmpty() &&
245 !((wxComboBox*)FindWindow(ecID_MODIFY_PLATFORM_PREFIX))->GetValue().IsEmpty());
248 void ecPlatformEditorDialog::OnCancel(wxCommandEvent& event)
253 void ecPlatformEditorDialog::OnOK(wxCommandEvent& event)
255 TransferDataFromWindow();
257 m_strGDB.Replace(g_NewLineToReplace, wxT(";"));