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####
25 // choosereposdlg.cpp :
27 //===========================================================================
28 //#####DESCRIPTIONBEGIN####
31 // Contact(s): julians
33 // Version: $Id: choosereposdlg.cpp,v 1.3 2002/02/28 18:30:35 julians Exp $
35 // Description: Implementation file for ecChooseRepositoryDialog
42 //####DESCRIPTIONEND####
44 //===========================================================================
46 // ============================================================================
48 // ============================================================================
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 #pragma implementation "choosereposdlg.h"
57 // Includes other headers for precompiled compilation
64 #include "wx/cshelp.h"
65 #include "wx/dirdlg.h"
66 #include "wx/valgen.h"
68 #include "configtool.h"
69 #include "configtooldoc.h"
70 #include "choosereposdlg.h"
72 BEGIN_EVENT_TABLE(ecChooseRepositoryDialog, ecDialog)
73 EVT_BUTTON(ecID_CHOOSE_REPOSITORY_BROWSE, ecChooseRepositoryDialog::OnBrowse)
74 EVT_BUTTON(wxID_OK, ecChooseRepositoryDialog::OnOK)
75 EVT_BUTTON(wxID_CANCEL, ecChooseRepositoryDialog::OnCancel)
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
83 ecChooseRepositoryDialog::ecChooseRepositoryDialog(wxWindow* parent)
85 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
87 ecDialog::Create(parent, ecID_CHOOSE_REPOSITORY_DIALOG, _("Choose folder for eCos repository"),
88 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
95 void ecChooseRepositoryDialog::CreateControls(wxWindow* parent)
97 wxSizer *item0 = new wxBoxSizer( wxHORIZONTAL );
99 wxSizer *item1 = new wxBoxSizer( wxVERTICAL );
101 wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, _("Please specify the root of the eCos repository tree."), wxDefaultPosition, wxDefaultSize, 0 );
102 item1->Add( item2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
104 item1->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
106 wxTextCtrl *item3 = new wxTextCtrl( parent, ecID_CHOOSE_REPOSITORY_TEXT, _(""), wxDefaultPosition, wxSize(320,-1), 0 );
107 item1->Add( item3, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
109 item0->Add( item1, 1, wxALIGN_CENTRE|wxALL, 5 );
111 wxSizer *item4 = new wxBoxSizer( wxVERTICAL );
113 wxButton *item5 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
114 item4->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
116 wxButton *item6 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
117 item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
119 wxButton *item7 = new wxButton( parent, ecID_CHOOSE_REPOSITORY_BROWSE, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
120 item4->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
122 item0->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
125 wxSizer *item0 = new wxBoxSizer( wxHORIZONTAL );
127 wxSizer *item1 = new wxBoxSizer( wxVERTICAL );
129 wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, "Please specify the root of the eCos repository tree.", wxDefaultPosition, wxDefaultSize, 0 );
130 item1->Add( item2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
132 item1->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );
134 wxTextCtrl *item3 = new wxTextCtrl( parent, ecID_CHOOSE_REPOSITORY_TEXT, "", wxDefaultPosition, wxSize(320,-1), 0 );
135 item1->Add( item3, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
137 item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
139 wxSizer *item4 = new wxBoxSizer( wxVERTICAL );
141 wxButton *item5 = new wxButton( parent, wxID_OK, "&OK", wxDefaultPosition, wxDefaultSize, 0 );
142 item4->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
145 wxButton *item6 = new wxButton( parent, wxID_CANCEL, "&Cancel", wxDefaultPosition, wxDefaultSize, 0 );
146 item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
148 wxButton *item7 = new wxButton( parent, ecID_CHOOSE_REPOSITORY_BROWSE, "&Browse...", wxDefaultPosition, wxDefaultSize, 0 );
149 item4->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
152 wxButton *contextButton = new wxContextHelpButton( parent );
153 item4->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
156 item0->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
160 wxButton *contextButton = new wxContextHelpButton( parent );
161 item4->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
164 parent->SetAutoLayout( TRUE );
165 parent->SetSizer( item0 );
167 item0->Fit( parent );
168 item0->SetSizeHints( parent );
170 parent->FindWindow( ecID_CHOOSE_REPOSITORY_TEXT)->SetFocus();
172 // Add context-sensitive help text
173 parent->FindWindow( ecID_CHOOSE_REPOSITORY_TEXT)->SetHelpText(_("Selects the repository folder."));
174 parent->FindWindow( ecID_CHOOSE_REPOSITORY_BROWSE)->SetHelpText(_("Browse for the folder."));
175 parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and loads the selected repository."));
176 parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Closes the dialog without loading a repository."));
179 parent->FindWindow( ecID_CHOOSE_REPOSITORY_TEXT)->SetValidator(wxGenericValidator(& wxGetApp().GetConfigToolDoc()->m_strRepository));
182 parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
186 void ecChooseRepositoryDialog::OnBrowse(wxCommandEvent& event)
188 wxDirDialog dialog(this, wxT("Repository path"));
189 if (wxID_OK == dialog.ShowModal())
191 wxString path = dialog.GetPath();
192 ((wxTextCtrl*) FindWindow( ecID_CHOOSE_REPOSITORY_TEXT))->SetValue(path);
196 void ecChooseRepositoryDialog::OnCancel(wxCommandEvent& event)
201 void ecChooseRepositoryDialog::OnOK(wxCommandEvent& event)
203 wxString folder(GetFolder());
204 if (!wxDirExists(folder))
206 wxMessageBox(_("This is not a valid folder."));
207 return; // Don't Skip so we don't dismiss the dialog
211 wxMessageBox(_("This does not like a valid eCos repository."));
212 return; // Don't Skip so we don't dismiss the dialog
217 wxString ecChooseRepositoryDialog::GetFolder()
219 return ((wxTextCtrl*) FindWindow( ecID_CHOOSE_REPOSITORY_TEXT))->GetValue();