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