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