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