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