]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: utils/configtool/src/settingsdialog.cpp | |
3 | // Purpose: Settings dialog | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2003-06-12 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // For compilers that support precompilation, includes "wx/wx.h". | |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | ||
21 | #include "wx/intl.h" | |
22 | #include "wx/statline.h" | |
23 | #include "wx/splitter.h" | |
24 | #include "wx/scrolwin.h" | |
25 | #include "wx/spinctrl.h" | |
26 | #include "wx/spinbutt.h" | |
27 | #include "wx/sizer.h" | |
28 | #include "wx/statbox.h" | |
29 | #include "wx/dirdlg.h" | |
30 | #include "wx/stattext.h" | |
31 | #include "wx/choice.h" | |
32 | ||
33 | #endif | |
34 | ||
35 | #include "wx/cshelp.h" | |
36 | #include "wx/notebook.h" | |
37 | #include "wx/valgen.h" | |
38 | #include "wxconfigtool.h" | |
39 | #include "settingsdialog.h" | |
40 | ||
41 | ////@begin XPM images | |
42 | ////@end XPM images | |
43 | ||
44 | /*! | |
45 | * ctSettingsDialog type definition | |
46 | */ | |
47 | ||
48 | IMPLEMENT_CLASS( ctSettingsDialog, wxDialog ) | |
49 | ||
50 | /*! | |
51 | * ctSettingsDialog event table definition | |
52 | */ | |
53 | ||
54 | BEGIN_EVENT_TABLE( ctSettingsDialog, wxDialog ) | |
55 | ||
56 | ////@begin ctSettingsDialog event table entries | |
57 | EVT_BUTTON( wxID_OK, ctSettingsDialog::OnOk ) | |
58 | ||
59 | EVT_BUTTON( wxID_CANCEL, ctSettingsDialog::OnCancel ) | |
60 | ||
61 | EVT_BUTTON( wxID_HELP, ctSettingsDialog::OnHelp ) | |
62 | ||
63 | ////@end ctSettingsDialog event table entries | |
64 | ||
65 | END_EVENT_TABLE() | |
66 | ||
67 | /*! | |
68 | * ctSettingsDialog constructor | |
69 | */ | |
70 | ||
71 | ctSettingsDialog::ctSettingsDialog( wxWindow* parent ) | |
72 | { | |
73 | SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); | |
74 | wxDialog::Create( parent, wxID_ANY, _("Configuration Settings")); | |
75 | CreateControls(); | |
76 | } | |
77 | ||
78 | /*! | |
79 | * Control creation for ctSettingsDialog | |
80 | */ | |
81 | ||
82 | void ctSettingsDialog::CreateControls() | |
83 | { | |
84 | ////@begin ctSettingsDialog content construction | |
85 | ||
86 | ctSettingsDialog* item1 = this; | |
87 | ||
88 | wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL); | |
89 | item1->SetSizer(item2); | |
90 | ||
91 | m_notebook = new wxNotebook(item1, wxID_ANY, wxDefaultPosition, wxSize(200, 200), wxBK_TOP); | |
92 | ctGeneralSettingsDialog* item4 = new ctGeneralSettingsDialog(m_notebook, ID_GENERAL_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0); | |
93 | m_notebook->AddPage(item4, _("General")); | |
94 | ctLocationSettingsDialog* item11 = new ctLocationSettingsDialog(m_notebook, ID_LOCATION_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0); | |
95 | m_notebook->AddPage(item11, _("Locations")); | |
96 | item2->Add(m_notebook, 0, wxGROW|wxALL, 5); | |
97 | ||
98 | wxBoxSizer* item21 = new wxBoxSizer(wxHORIZONTAL); | |
99 | item2->Add(item21, 0, wxGROW|wxALL, 5); | |
100 | ||
101 | item21->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
102 | ||
103 | wxButton* item23 = new wxButton(item1, wxID_OK); | |
104 | item23->SetDefault(); | |
105 | item21->Add(item23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
106 | ||
107 | wxButton* item24 = new wxButton(item1, wxID_CANCEL); | |
108 | item21->Add(item24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
109 | ||
110 | wxButton* item25 = new wxButton(item1, wxID_HELP); | |
111 | item21->Add(item25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
112 | ||
113 | #if defined(__WXGTK__) || defined(__WXMAC__) | |
114 | wxContextHelpButton* item26 = new wxContextHelpButton(item1, wxID_CONTEXT_HELP, wxDefaultPosition, wxSize(20, wxDefaultCoord), wxBU_AUTODRAW); | |
115 | item21->Add(item26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
116 | #endif | |
117 | ||
118 | GetSizer()->Fit(this); | |
119 | GetSizer()->SetSizeHints(this); | |
120 | Centre(); | |
121 | ////@end ctSettingsDialog content construction | |
122 | } | |
123 | ||
124 | /*! | |
125 | * Event handler for wxID_OK | |
126 | */ | |
127 | ||
128 | void ctSettingsDialog::OnOk( wxCommandEvent& event ) | |
129 | { | |
130 | // Replace with custom code | |
131 | event.Skip(); | |
132 | } | |
133 | ||
134 | /*! | |
135 | * Event handler for wxID_CANCEL | |
136 | */ | |
137 | ||
138 | void ctSettingsDialog::OnCancel( wxCommandEvent& event ) | |
139 | { | |
140 | // Replace with custom code | |
141 | event.Skip(); | |
142 | } | |
143 | ||
144 | /*! | |
145 | * Event handler for wxID_HELP | |
146 | */ | |
147 | ||
148 | void ctSettingsDialog::OnHelp( wxCommandEvent& WXUNUSED(event) ) | |
149 | { | |
150 | if(m_notebook) | |
151 | { | |
152 | int sel = m_notebook->GetSelection(); | |
153 | ||
154 | wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected.")); | |
155 | ||
156 | wxWindow* page = (wxWindow*) m_notebook->GetPage(sel); | |
157 | ||
158 | wxString helpTopic; | |
159 | if (page->GetId() == ID_GENERAL_SETTINGS_DIALOG) | |
160 | { | |
161 | helpTopic = wxT("General settings dialog"); | |
162 | } | |
163 | else if (page->GetId() == ID_LOCATION_SETTINGS_DIALOG) | |
164 | { | |
165 | helpTopic = wxT("Location settings dialog"); | |
166 | } | |
167 | ||
168 | if (!helpTopic.empty()) | |
169 | { | |
170 | wxGetApp().GetHelpController().DisplaySection(helpTopic); | |
171 | } | |
172 | } | |
173 | } | |
174 | ||
175 | /*! | |
176 | * Should we show tooltips? | |
177 | */ | |
178 | ||
179 | bool ctSettingsDialog::ShowToolTips() | |
180 | { | |
181 | return true; | |
182 | } | |
183 | ||
184 | /*! | |
185 | * ctGeneralSettingsDialog type definition | |
186 | */ | |
187 | ||
188 | IMPLEMENT_CLASS( ctGeneralSettingsDialog, wxPanel ) | |
189 | ||
190 | /*! | |
191 | * ctGeneralSettingsDialog event table definition | |
192 | */ | |
193 | ||
194 | BEGIN_EVENT_TABLE( ctGeneralSettingsDialog, wxPanel ) | |
195 | ||
196 | ////@begin ctGeneralSettingsDialog event table entries | |
197 | ////@end ctGeneralSettingsDialog event table entries | |
198 | ||
199 | END_EVENT_TABLE() | |
200 | ||
201 | /*! | |
202 | * ctGeneralSettingsDialog constructor | |
203 | */ | |
204 | ||
205 | ctGeneralSettingsDialog::ctGeneralSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) | |
206 | { | |
207 | wxPanel::Create( parent, id, pos, size, style ); | |
208 | ||
209 | CreateControls(); | |
210 | } | |
211 | ||
212 | /*! | |
213 | * Control creation for ctGeneralSettingsDialog | |
214 | */ | |
215 | ||
216 | void ctGeneralSettingsDialog::CreateControls() | |
217 | { | |
218 | ////@begin ctGeneralSettingsDialog content construction | |
219 | ||
220 | ctGeneralSettingsDialog* item4 = this; | |
221 | ||
222 | wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL); | |
223 | item4->SetSizer(item5); | |
224 | ||
225 | wxStaticBox* item6Static = new wxStaticBox(item4, wxID_ANY, _("General settings")); | |
226 | wxStaticBoxSizer* item6 = new wxStaticBoxSizer(item6Static, wxVERTICAL); | |
227 | item5->Add(item6, 1, wxGROW|wxALL, 5); | |
228 | ||
229 | wxCheckBox* item7 = new wxCheckBox(item4, ID_LOAD_LAST_DOCUMENT, _("&Load last document"), wxDefaultPosition, wxDefaultSize, 0); | |
230 | item7->SetValue(false); | |
231 | item7->SetHelpText(_("Check to load the last document on startup")); | |
232 | #if wxUSE_TOOLTIPS | |
233 | if (ShowToolTips()) | |
234 | item7->SetToolTip(_("Check to load the last document on startup")); | |
235 | #endif | |
236 | item6->Add(item7, 0, wxALIGN_LEFT|wxALL, 5); | |
237 | ||
238 | wxCheckBox* item8 = new wxCheckBox(item4, ID_SHOW_TOOLTIPS, _("&Show tooltips"), wxDefaultPosition, wxDefaultSize, 0); | |
239 | item8->SetValue(false); | |
240 | item8->SetHelpText(_("Check to show tooltips")); | |
241 | #if wxUSE_TOOLTIPS | |
242 | if (ShowToolTips()) | |
243 | item8->SetToolTip(_("Check to show tooltips")); | |
244 | #endif | |
245 | item6->Add(item8, 0, wxALIGN_LEFT|wxALL, 5); | |
246 | ||
247 | wxStaticText* item9 = new wxStaticText(item4, wxID_STATIC, _("&Default file kind to save when using the Go command:"), wxDefaultPosition, wxDefaultSize, 0); | |
248 | item6->Add(item9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); | |
249 | ||
250 | wxString item10Strings[] = { | |
251 | _("Setup file"), | |
252 | _("Configure script") | |
253 | }; | |
254 | wxChoice* item10 = new wxChoice(item4, ID_DEFAULT_FILE_KIND, wxDefaultPosition, wxSize(200, wxDefaultCoord), 2, item10Strings, 0); | |
255 | item10->SetStringSelection(_("Setup file")); | |
256 | item10->SetHelpText(_("Select the default kind of file to save using Go")); | |
257 | #if wxUSE_TOOLTIPS | |
258 | if (ShowToolTips()) | |
259 | item10->SetToolTip(_("Select the default kind of file to save using Go")); | |
260 | #endif | |
261 | item6->Add(item10, 0, wxGROW|wxALL, 5); | |
262 | ||
263 | GetSizer()->Fit(this); | |
264 | ////@end ctGeneralSettingsDialog content construction | |
265 | ||
266 | item7->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_loadLastDocument)); | |
267 | item8->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useToolTips)); | |
268 | item10->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_defaultFileKind)); | |
269 | } | |
270 | ||
271 | /*! | |
272 | * Should we show tooltips? | |
273 | */ | |
274 | ||
275 | bool ctGeneralSettingsDialog::ShowToolTips() | |
276 | { | |
277 | return true; | |
278 | } | |
279 | ||
280 | /*! | |
281 | * ctLocationSettingsDialog type definition | |
282 | */ | |
283 | ||
284 | IMPLEMENT_CLASS( ctLocationSettingsDialog, wxPanel ) | |
285 | ||
286 | /*! | |
287 | * ctLocationSettingsDialog event table definition | |
288 | */ | |
289 | ||
290 | BEGIN_EVENT_TABLE( ctLocationSettingsDialog, wxPanel ) | |
291 | ||
292 | ////@begin ctLocationSettingsDialog event table entries | |
293 | EVT_UPDATE_UI( ID_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateWxwinHierarchy ) | |
294 | ||
295 | EVT_BUTTON( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnChooseWxwinHierarchy ) | |
296 | EVT_UPDATE_UI( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy ) | |
297 | ||
298 | ////@end ctLocationSettingsDialog event table entries | |
299 | ||
300 | END_EVENT_TABLE() | |
301 | ||
302 | /*! | |
303 | * ctLocationSettingsDialog constructor | |
304 | */ | |
305 | ||
306 | ctLocationSettingsDialog::ctLocationSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) | |
307 | { | |
308 | wxPanel::Create( parent, id, pos, size, style ); | |
309 | ||
310 | CreateControls(); | |
311 | } | |
312 | ||
313 | /*! | |
314 | * Control creation for ctLocationSettingsDialog | |
315 | */ | |
316 | ||
317 | void ctLocationSettingsDialog::CreateControls() | |
318 | { | |
319 | ////@begin ctLocationSettingsDialog content construction | |
320 | ||
321 | ctLocationSettingsDialog* item11 = this; | |
322 | ||
323 | wxBoxSizer* item12 = new wxBoxSizer(wxVERTICAL); | |
324 | item11->SetSizer(item12); | |
325 | ||
326 | wxStaticBox* item13Static = new wxStaticBox(item11, wxID_ANY, _("Locations")); | |
327 | wxStaticBoxSizer* item13 = new wxStaticBoxSizer(item13Static, wxVERTICAL); | |
328 | item12->Add(item13, 1, wxGROW|wxALL, 5); | |
329 | ||
330 | wxStaticText* item14 = new wxStaticText(item11, wxID_STATIC, _("&wxWidgets hierarchy:"), wxDefaultPosition, wxDefaultSize, 0); | |
331 | item13->Add(item14, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); | |
332 | ||
333 | wxBoxSizer* item15 = new wxBoxSizer(wxHORIZONTAL); | |
334 | item13->Add(item15, 0, wxGROW, 5); | |
335 | ||
336 | m_wxWinHierarchy = new wxTextCtrl(item11, ID_WXWIN_HIERARCHY, wxEmptyString, wxDefaultPosition, wxSize(200, wxDefaultCoord), 0); | |
337 | m_wxWinHierarchy->SetHelpText(_("Enter the root path of the wxWidgets hierarchy")); | |
338 | #if wxUSE_TOOLTIPS | |
339 | if (ShowToolTips()) | |
340 | m_wxWinHierarchy->SetToolTip(_("Enter the root path of the wxWidgets hierarchy")); | |
341 | #endif | |
342 | item15->Add(m_wxWinHierarchy, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
343 | ||
344 | wxButton* item17 = new wxButton(item11, ID_CHOOSE_WXWIN_HIERARCHY, _("&Choose..."), wxDefaultPosition, wxDefaultSize, 0); | |
345 | item17->SetHelpText(_("Click to choose the root path of the wxWidgets hierarchy\\n")); | |
346 | #if wxUSE_TOOLTIPS | |
347 | if (ShowToolTips()) | |
348 | item17->SetToolTip(_("Click to choose the root path of the wxWidgets hierarchy\\n")); | |
349 | #endif | |
350 | item15->Add(item17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
351 | ||
352 | wxBoxSizer* item18 = new wxBoxSizer(wxHORIZONTAL); | |
353 | item13->Add(item18, 0, wxGROW, 5); | |
354 | ||
355 | item18->Add(60, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
356 | ||
357 | m_wxWinUse = new wxCheckBox(item11, ID_USE_WXWIN, _("&Use WXWIN environment variable")); | |
358 | m_wxWinUse->SetValue(false); | |
359 | m_wxWinUse->SetHelpText(_("Check to use the value of WXWIN instead")); | |
360 | #if wxUSE_TOOLTIPS | |
361 | if (ShowToolTips()) | |
362 | m_wxWinUse->SetToolTip(_("Check to use the value of WXWIN instead")); | |
363 | #endif | |
364 | item18->Add(m_wxWinUse, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
365 | ||
366 | GetSizer()->Fit(this); | |
367 | ////@end ctLocationSettingsDialog content construction | |
368 | ||
369 | m_wxWinHierarchy->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_frameworkDir)); | |
370 | m_wxWinUse->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useEnvironmentVariable)); | |
371 | } | |
372 | ||
373 | /*! | |
374 | * Update event handler for ID_WXWIN_HIERARCHY | |
375 | */ | |
376 | ||
377 | void ctLocationSettingsDialog::OnUpdateWxwinHierarchy( wxUpdateUIEvent& event ) | |
378 | { | |
379 | if(m_wxWinUse) | |
380 | event.Enable(!m_wxWinUse->GetValue()); | |
381 | } | |
382 | ||
383 | /*! | |
384 | * Event handler for ID_CHOOSE_WXWIN_HIERARCHY | |
385 | */ | |
386 | ||
387 | void ctLocationSettingsDialog::OnChooseWxwinHierarchy( wxCommandEvent& WXUNUSED(event) ) | |
388 | { | |
389 | if (m_wxWinHierarchy) | |
390 | { | |
391 | wxString defaultPath = m_wxWinHierarchy->GetValue(); | |
392 | ||
393 | wxDirDialog dialog(this, _("Choose the location of the wxWidgets hierarchy"), | |
394 | defaultPath); | |
395 | if (dialog.ShowModal() == wxID_OK) | |
396 | { | |
397 | m_wxWinHierarchy->SetValue(dialog.GetPath()); | |
398 | } | |
399 | } | |
400 | } | |
401 | ||
402 | /*! | |
403 | * Update event handler for ID_CHOOSE_WXWIN_HIERARCHY | |
404 | */ | |
405 | ||
406 | void ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event ) | |
407 | { | |
408 | if (m_wxWinUse) | |
409 | event.Enable(!m_wxWinUse->GetValue()); | |
410 | } | |
411 | ||
412 | /*! | |
413 | * Should we show tooltips? | |
414 | */ | |
415 | ||
416 | bool ctLocationSettingsDialog::ShowToolTips() | |
417 | { | |
418 | return wxGetApp().GetSettings().m_useToolTips; | |
419 | } |