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