1 |
786 |
skrzyp |
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####
|
2 |
|
|
// -------------------------------------------
|
3 |
|
|
// This file is part of the eCos host tools.
|
4 |
|
|
// Copyright (C) 1998, 1999, 2000 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 |
|
|
// folderdlg.cpp :
|
23 |
|
|
//
|
24 |
|
|
//===========================================================================
|
25 |
|
|
//#####DESCRIPTIONBEGIN####
|
26 |
|
|
//
|
27 |
|
|
// Author(s): julians
|
28 |
|
|
// Contact(s): julians
|
29 |
|
|
// Date: 2000/12/20
|
30 |
|
|
// Version: $Id: folderdlg.cpp,v 1.2 2001/03/23 13:38:04 julians Exp $
|
31 |
|
|
// Purpose:
|
32 |
|
|
// Description: Implementation of ecFolderDialog
|
33 |
|
|
// Requires:
|
34 |
|
|
// Provides:
|
35 |
|
|
// See also:
|
36 |
|
|
// Known bugs:
|
37 |
|
|
// Usage:
|
38 |
|
|
//
|
39 |
|
|
//####DESCRIPTIONEND####
|
40 |
|
|
//
|
41 |
|
|
//===========================================================================
|
42 |
|
|
|
43 |
|
|
#ifdef __GNUG__
|
44 |
|
|
#pragma implementation "folderdlg.cpp"
|
45 |
|
|
#endif
|
46 |
|
|
|
47 |
|
|
#include "ecpch.h"
|
48 |
|
|
|
49 |
|
|
#ifdef __BORLANDC__
|
50 |
|
|
#pragma hdrstop
|
51 |
|
|
#endif
|
52 |
|
|
|
53 |
|
|
#include "configtool.h"
|
54 |
|
|
#include "folderdlg.h"
|
55 |
|
|
|
56 |
|
|
//----------------------------------------------------------------------------
|
57 |
|
|
// ecFolderDialog
|
58 |
|
|
//----------------------------------------------------------------------------
|
59 |
|
|
|
60 |
|
|
BEGIN_EVENT_TABLE(ecFolderDialog, ecDialog)
|
61 |
|
|
EVT_BUTTON( wxID_OK, ecFolderDialog::OnOK )
|
62 |
|
|
EVT_BUTTON( wxID_CANCEL, ecFolderDialog::OnCancel )
|
63 |
|
|
EVT_BUTTON( ecID_FOLDER_DIALOG_BROWSE, ecFolderDialog::OnBrowse )
|
64 |
|
|
EVT_INIT_DIALOG(ecFolderDialog::OnInitDialog)
|
65 |
|
|
END_EVENT_TABLE()
|
66 |
|
|
|
67 |
|
|
ecFolderDialog::ecFolderDialog( const wxString& defaultPath, const wxArrayString& paths,
|
68 |
|
|
const wxString& msg, wxWindow *parent, wxWindowID id, const wxString &title,
|
69 |
|
|
const wxPoint &position, const wxSize& size, long style )
|
70 |
|
|
{
|
71 |
|
|
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
|
72 |
|
|
|
73 |
|
|
m_defaultPath = defaultPath;
|
74 |
|
|
m_paths = paths;
|
75 |
|
|
m_message = msg;
|
76 |
|
|
|
77 |
|
|
wxDialog::Create( parent, id, title, position, size, style );
|
78 |
|
|
|
79 |
|
|
CreateControls();
|
80 |
|
|
|
81 |
|
|
Centre(wxBOTH);
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
void ecFolderDialog::OnInitDialog(wxInitDialogEvent& event)
|
85 |
|
|
{
|
86 |
|
|
wxComboBox* comboBox = (wxComboBox*) FindWindow(ecID_FOLDER_DIALOG_PATHS);
|
87 |
|
|
|
88 |
|
|
wxASSERT (comboBox != NULL) ;
|
89 |
|
|
|
90 |
|
|
size_t i;
|
91 |
|
|
for (i = (size_t) 0; i < m_paths.GetCount(); i++)
|
92 |
|
|
{
|
93 |
|
|
comboBox->Append(m_paths[i]);
|
94 |
|
|
if (m_paths[i] == m_defaultPath)
|
95 |
|
|
comboBox->SetSelection(i);
|
96 |
|
|
}
|
97 |
|
|
if (comboBox->FindString(m_defaultPath) == -1)
|
98 |
|
|
comboBox->Append(m_defaultPath);
|
99 |
|
|
|
100 |
|
|
#if wxCHECK_VERSION(2, 6, 0)
|
101 |
|
|
if (comboBox->GetSelection() == -1)
|
102 |
|
|
#else
|
103 |
|
|
if (comboBox->GetSelection() == -1 && comboBox->Number() > 0)
|
104 |
|
|
#endif
|
105 |
|
|
comboBox->SetSelection(0);
|
106 |
|
|
|
107 |
|
|
comboBox->SetFocus();
|
108 |
|
|
|
109 |
|
|
wxStaticText* staticText = (wxStaticText*) FindWindow(ecID_FOLDER_DIALOG_MSG);
|
110 |
|
|
|
111 |
|
|
wxASSERT ( staticText != NULL );
|
112 |
|
|
|
113 |
|
|
staticText->SetLabel(m_message);
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
void ecFolderDialog::OnOK(wxCommandEvent &event)
|
117 |
|
|
{
|
118 |
|
|
wxComboBox* comboBox = (wxComboBox*) FindWindow(ecID_FOLDER_DIALOG_PATHS);
|
119 |
|
|
m_defaultPath = comboBox->GetValue();
|
120 |
|
|
|
121 |
|
|
event.Skip();
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
void ecFolderDialog::OnCancel(wxCommandEvent &event)
|
125 |
|
|
{
|
126 |
|
|
event.Skip();
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
void ecFolderDialog::OnBrowse(wxCommandEvent &event)
|
130 |
|
|
{
|
131 |
|
|
wxComboBox* comboBox = (wxComboBox*) FindWindow(ecID_FOLDER_DIALOG_PATHS);
|
132 |
|
|
|
133 |
|
|
wxString value = comboBox->GetValue();
|
134 |
|
|
|
135 |
|
|
wxDirDialog dirDialog(this, wxT("Choose a directory"), value);
|
136 |
|
|
if (dirDialog.ShowModal() == wxID_OK)
|
137 |
|
|
{
|
138 |
|
|
comboBox->SetValue(dirDialog.GetPath());
|
139 |
|
|
}
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
void ecFolderDialog::CreateControls()
|
143 |
|
|
{
|
144 |
|
|
wxWindow* parent = this;
|
145 |
|
|
|
146 |
|
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
147 |
|
|
|
148 |
|
|
wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
|
149 |
|
|
|
150 |
|
|
wxStaticText *item2 = new wxStaticText( parent, ecID_FOLDER_DIALOG_MSG, _("text"), wxDefaultPosition, wxSize(-1,70), wxST_NO_AUTORESIZE );
|
151 |
|
|
item1->Add( item2, 10, wxALIGN_CENTER_HORIZONTAL|wxALL, 10 );
|
152 |
|
|
|
153 |
|
|
wxSizer *item3 = new wxBoxSizer( wxVERTICAL );
|
154 |
|
|
|
155 |
|
|
wxButton *item4 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
156 |
|
|
item4->SetDefault();
|
157 |
|
|
item3->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
|
158 |
|
|
|
159 |
|
|
wxButton *item5 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
160 |
|
|
item3->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
|
161 |
|
|
|
162 |
|
|
wxButton *item6 = new wxButton( parent, ecID_FOLDER_DIALOG_BROWSE, _("&Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
|
163 |
|
|
item3->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
|
164 |
|
|
|
165 |
|
|
item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
|
166 |
|
|
|
167 |
|
|
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
168 |
|
|
|
169 |
|
|
wxString *strs7 = (wxString*) NULL;
|
170 |
|
|
wxComboBox *item7 = new wxComboBox( parent, ecID_FOLDER_DIALOG_PATHS, "", wxDefaultPosition, wxSize(470,-1), 0, strs7, wxCB_DROPDOWN );
|
171 |
|
|
item0->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
172 |
|
|
|
173 |
|
|
parent->SetAutoLayout( TRUE );
|
174 |
|
|
parent->SetSizer( item0 );
|
175 |
|
|
parent->Layout();
|
176 |
|
|
item0->Fit( parent );
|
177 |
|
|
item0->SetSizeHints( parent );
|
178 |
|
|
|
179 |
|
|
// Add validators
|
180 |
|
|
//parent->FindWindow( ecID_LICENSE_TEXT )->SetValidator(wxGenericValidator(& m_licenseText));
|
181 |
|
|
|
182 |
|
|
// Add context-sensitive help text
|
183 |
|
|
parent->FindWindow( wxID_OK )->SetHelpText(_("Confirms your folder selection."));
|
184 |
|
|
parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Cancels the operation."));
|
185 |
|
|
|
186 |
|
|
#if __WXGTK__
|
187 |
|
|
//parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
|
188 |
|
|
#endif
|
189 |
|
|
}
|