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