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