]> git.saurik.com Git - wxWidgets.git/blob - utils/configtool/src/settingsdialog.cpp
Doc fix
[wxWidgets.git] / utils / configtool / src / settingsdialog.cpp
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/intl.h"
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"
31 #include "wx/sizer.h"
32 #include "wx/statbox.h"
33 #include "wx/dirdlg.h"
34 #include "wx/stattext.h"
35 #include "wx/choice.h"
36
37 #endif
38
39 #include "wx/cshelp.h"
40 #include "wx/notebook.h"
41 #include "wx/valgen.h"
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
75 ctSettingsDialog::ctSettingsDialog( wxWindow* parent )
76 {
77 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
78 wxDialog::Create( parent, wxID_ANY, _("Configuration Settings"));
79 CreateControls();
80 }
81
82 /*!
83 * Control creation for ctSettingsDialog
84 */
85
86 void ctSettingsDialog::CreateControls()
87 {
88 ////@begin ctSettingsDialog content construction
89
90 ctSettingsDialog* item1 = this;
91
92 wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
93 item1->SetSizer(item2);
94
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);
101
102 wxBoxSizer* item21 = new wxBoxSizer(wxHORIZONTAL);
103 item2->Add(item21, 0, wxGROW|wxALL, 5);
104
105 item21->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
106
107 wxButton* item23 = new wxButton(item1, wxID_OK);
108 item23->SetDefault();
109 item21->Add(item23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
110
111 wxButton* item24 = new wxButton(item1, wxID_CANCEL);
112 item21->Add(item24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
113
114 wxButton* item25 = new wxButton(item1, wxID_HELP);
115 item21->Add(item25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
116
117 #if defined(__WXGTK__) || defined(__WXMAC__)
118 wxContextHelpButton* item26 = new wxContextHelpButton(item1, wxID_CONTEXT_HELP, wxDefaultPosition, wxSize(20, wxDefaultCoord), wxBU_AUTODRAW);
119 item21->Add(item26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
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
152 void ctSettingsDialog::OnHelp( wxCommandEvent& WXUNUSED(event) )
153 {
154 if(m_notebook)
155 {
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
172 if (!helpTopic.empty())
173 {
174 wxGetApp().GetHelpController().DisplaySection(helpTopic);
175 }
176 }
177 }
178
179 /*!
180 * Should we show tooltips?
181 */
182
183 bool ctSettingsDialog::ShowToolTips()
184 {
185 return true;
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()
221 {
222 ////@begin ctGeneralSettingsDialog content construction
223
224 ctGeneralSettingsDialog* item4 = this;
225
226 wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL);
227 item4->SetSizer(item5);
228
229 wxStaticBox* item6Static = new wxStaticBox(item4, wxID_ANY, _("General settings"));
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);
234 item7->SetValue(false);
235 item7->SetHelpText(_("Check to load the last document on startup"));
236 #if wxUSE_TOOLTIPS
237 if (ShowToolTips())
238 item7->SetToolTip(_("Check to load the last document on startup"));
239 #endif
240 item6->Add(item7, 0, wxALIGN_LEFT|wxALL, 5);
241
242 wxCheckBox* item8 = new wxCheckBox(item4, ID_SHOW_TOOLTIPS, _("&Show tooltips"), wxDefaultPosition, wxDefaultSize, 0);
243 item8->SetValue(false);
244 item8->SetHelpText(_("Check to show tooltips"));
245 #if wxUSE_TOOLTIPS
246 if (ShowToolTips())
247 item8->SetToolTip(_("Check to show tooltips"));
248 #endif
249 item6->Add(item8, 0, wxALIGN_LEFT|wxALL, 5);
250
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 };
258 wxChoice* item10 = new wxChoice(item4, ID_DEFAULT_FILE_KIND, wxDefaultPosition, wxSize(200, wxDefaultCoord), 2, item10Strings, 0);
259 item10->SetStringSelection(_("Setup file"));
260 item10->SetHelpText(_("Select the default kind of file to save using Go"));
261 #if wxUSE_TOOLTIPS
262 if (ShowToolTips())
263 item10->SetToolTip(_("Select the default kind of file to save using Go"));
264 #endif
265 item6->Add(item10, 0, wxGROW|wxALL, 5);
266
267 GetSizer()->Fit(this);
268 ////@end ctGeneralSettingsDialog content construction
269
270 item7->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_loadLastDocument));
271 item8->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useToolTips));
272 item10->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_defaultFileKind));
273 }
274
275 /*!
276 * Should we show tooltips?
277 */
278
279 bool ctGeneralSettingsDialog::ShowToolTips()
280 {
281 return true;
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()
322 {
323 ////@begin ctLocationSettingsDialog content construction
324
325 ctLocationSettingsDialog* item11 = this;
326
327 wxBoxSizer* item12 = new wxBoxSizer(wxVERTICAL);
328 item11->SetSizer(item12);
329
330 wxStaticBox* item13Static = new wxStaticBox(item11, wxID_ANY, _("Locations"));
331 wxStaticBoxSizer* item13 = new wxStaticBoxSizer(item13Static, wxVERTICAL);
332 item12->Add(item13, 1, wxGROW|wxALL, 5);
333
334 wxStaticText* item14 = new wxStaticText(item11, wxID_STATIC, _("&wxWidgets hierarchy:"), wxDefaultPosition, wxDefaultSize, 0);
335 item13->Add(item14, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
336
337 wxBoxSizer* item15 = new wxBoxSizer(wxHORIZONTAL);
338 item13->Add(item15, 0, wxGROW, 5);
339
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"));
342 #if wxUSE_TOOLTIPS
343 if (ShowToolTips())
344 m_wxWinHierarchy->SetToolTip(_("Enter the root path of the wxWidgets hierarchy"));
345 #endif
346 item15->Add(m_wxWinHierarchy, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
347
348 wxButton* item17 = new wxButton(item11, ID_CHOOSE_WXWIN_HIERARCHY, _("&Choose..."), wxDefaultPosition, wxDefaultSize, 0);
349 item17->SetHelpText(_("Click to choose the root path of the wxWidgets hierarchy\\n"));
350 #if wxUSE_TOOLTIPS
351 if (ShowToolTips())
352 item17->SetToolTip(_("Click to choose the root path of the wxWidgets hierarchy\\n"));
353 #endif
354 item15->Add(item17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
355
356 wxBoxSizer* item18 = new wxBoxSizer(wxHORIZONTAL);
357 item13->Add(item18, 0, wxGROW, 5);
358
359 item18->Add(60, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
360
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"));
364 #if wxUSE_TOOLTIPS
365 if (ShowToolTips())
366 m_wxWinUse->SetToolTip(_("Check to use the value of WXWIN instead"));
367 #endif
368 item18->Add(m_wxWinUse, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
369
370 GetSizer()->Fit(this);
371 ////@end ctLocationSettingsDialog content construction
372
373 m_wxWinHierarchy->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_frameworkDir));
374 m_wxWinUse->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useEnvironmentVariable));
375 }
376
377 /*!
378 * Update event handler for ID_WXWIN_HIERARCHY
379 */
380
381 void ctLocationSettingsDialog::OnUpdateWxwinHierarchy( wxUpdateUIEvent& event )
382 {
383 if(m_wxWinUse)
384 event.Enable(!m_wxWinUse->GetValue());
385 }
386
387 /*!
388 * Event handler for ID_CHOOSE_WXWIN_HIERARCHY
389 */
390
391 void ctLocationSettingsDialog::OnChooseWxwinHierarchy( wxCommandEvent& WXUNUSED(event) )
392 {
393 if (m_wxWinHierarchy)
394 {
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 }
403 }
404 }
405
406 /*!
407 * Update event handler for ID_CHOOSE_WXWIN_HIERARCHY
408 */
409
410 void ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event )
411 {
412 if (m_wxWinUse)
413 event.Enable(!m_wxWinUse->GetValue());
414 }
415
416 /*!
417 * Should we show tooltips?
418 */
419
420 bool ctLocationSettingsDialog::ShowToolTips()
421 {
422 return wxGetApp().GetSettings().m_useToolTips;
423 }