]> git.saurik.com Git - wxWidgets.git/blob - utils/configtool/src/settingsdialog.cpp
fc0239fd7a1c72157a165cbc5b2492f0c2a32aa1
[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 #include "wx/wx.h"
13 #include "wx/cshelp.h"
14 #include "wx/statline.h"
15 #include "wx/splitter.h"
16 #include "wx/scrolwin.h"
17 #include "wx/spinctrl.h"
18 #include "wx/spinbutt.h"
19 #include "wx/valgen.h"
20 #include "wx/notebook.h"
21
22 #include "wxconfigtool.h"
23 #include "settingsdialog.h"
24
25 ////@begin XPM images
26 ////@end XPM images
27
28 /*!
29 * ctSettingsDialog type definition
30 */
31
32 IMPLEMENT_CLASS( ctSettingsDialog, wxDialog )
33
34 /*!
35 * ctSettingsDialog event table definition
36 */
37
38 BEGIN_EVENT_TABLE( ctSettingsDialog, wxDialog )
39
40 ////@begin ctSettingsDialog event table entries
41 EVT_BUTTON( wxID_OK, ctSettingsDialog::OnOk )
42
43 EVT_BUTTON( wxID_CANCEL, ctSettingsDialog::OnCancel )
44
45 EVT_BUTTON( wxID_HELP, ctSettingsDialog::OnHelp )
46
47 ////@end ctSettingsDialog event table entries
48
49 END_EVENT_TABLE()
50
51 /*!
52 * ctSettingsDialog constructor
53 */
54
55 ctSettingsDialog::ctSettingsDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
56 {
57 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
58 wxDialog::Create( parent, id, caption, pos, size, style );
59
60 CreateControls();
61 }
62
63 /*!
64 * Control creation for ctSettingsDialog
65 */
66
67 void ctSettingsDialog::CreateControls()
68 {
69 ////@begin ctSettingsDialog content construction
70
71 ctSettingsDialog* item1 = this;
72
73 wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
74 item1->SetSizer(item2);
75 item1->SetAutoLayout(TRUE);
76
77 wxNotebook* item3 = new wxNotebook(item1, ID_NOTEBOOK, wxDefaultPosition, wxSize(200, 200), wxNB_TOP);
78 wxNotebookSizer* item3Sizer = new wxNotebookSizer(item3);
79 ctGeneralSettingsDialog* item4 = new ctGeneralSettingsDialog(item3, ID_GENERAL_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
80 item3->AddPage(item4, _("General"));
81 ctLocationSettingsDialog* item9 = new ctLocationSettingsDialog(item3, ID_LOCATION_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
82 item3->AddPage(item9, _("Locations"));
83 item2->Add(item3Sizer, 0, wxGROW|wxALL, 5);
84
85 wxBoxSizer* item19 = new wxBoxSizer(wxHORIZONTAL);
86 item2->Add(item19, 0, wxGROW|wxALL, 5);
87
88 item19->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
89
90 wxButton* item21 = new wxButton(item1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0);
91 item21->SetDefault();
92 item19->Add(item21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
93
94 wxButton* item22 = new wxButton(item1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
95 item19->Add(item22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
96
97 wxButton* item23 = new wxButton(item1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0);
98 item19->Add(item23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
99
100 #if defined(__WXGTK__) || defined(__WXMAC__)
101 wxContextHelpButton* item24 = new wxContextHelpButton(item1, wxID_CONTEXT_HELP, wxDefaultPosition, wxSize(20, -1), wxBU_AUTODRAW);
102 item19->Add(item24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
103 #endif
104
105 GetSizer()->Fit(this);
106 GetSizer()->SetSizeHints(this);
107 Centre();
108 ////@end ctSettingsDialog content construction
109 }
110
111 /*!
112 * Event handler for wxID_OK
113 */
114
115 void ctSettingsDialog::OnOk( wxCommandEvent& event )
116 {
117 // Replace with custom code
118 event.Skip();
119 }
120
121 /*!
122 * Event handler for wxID_CANCEL
123 */
124
125 void ctSettingsDialog::OnCancel( wxCommandEvent& event )
126 {
127 // Replace with custom code
128 event.Skip();
129 }
130
131 /*!
132 * Event handler for wxID_HELP
133 */
134
135 void ctSettingsDialog::OnHelp( wxCommandEvent& event )
136 {
137 wxNotebook* notebook = (wxNotebook*) FindWindow(ID_NOTEBOOK);
138
139 int sel = notebook->GetSelection();
140
141 wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));
142
143 wxWindow* page = (wxWindow*) notebook->GetPage(sel);
144
145 wxString helpTopic;
146 if (page->GetId() == ID_GENERAL_SETTINGS_DIALOG)
147 {
148 helpTopic = wxT("General settings dialog");
149 }
150 else if (page->GetId() == ID_LOCATION_SETTINGS_DIALOG)
151 {
152 helpTopic = wxT("Location dialog");
153 }
154
155 if (!helpTopic.IsEmpty())
156 {
157 wxGetApp().GetHelpController().DisplaySection(helpTopic);
158 }
159 }
160
161 /*!
162 * Should we show tooltips?
163 */
164
165 bool ctSettingsDialog::ShowToolTips()
166 {
167 return TRUE;
168 }
169
170 /*!
171 * ctGeneralSettingsDialog type definition
172 */
173
174 IMPLEMENT_CLASS( ctGeneralSettingsDialog, wxPanel )
175
176 /*!
177 * ctGeneralSettingsDialog event table definition
178 */
179
180 BEGIN_EVENT_TABLE( ctGeneralSettingsDialog, wxPanel )
181
182 ////@begin ctGeneralSettingsDialog event table entries
183 ////@end ctGeneralSettingsDialog event table entries
184
185 END_EVENT_TABLE()
186
187 /*!
188 * ctGeneralSettingsDialog constructor
189 */
190
191 ctGeneralSettingsDialog::ctGeneralSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
192 {
193 wxPanel::Create( parent, id, pos, size, style );
194
195 CreateControls();
196 }
197
198 /*!
199 * Control creation for ctGeneralSettingsDialog
200 */
201
202 void ctGeneralSettingsDialog::CreateControls()
203 {
204 ////@begin ctGeneralSettingsDialog content construction
205
206 ctGeneralSettingsDialog* item4 = this;
207
208 wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL);
209 item4->SetSizer(item5);
210 item4->SetAutoLayout(TRUE);
211
212 wxStaticBox* item6Static = new wxStaticBox(item4, -1, _("General settings"));
213 wxStaticBoxSizer* item6 = new wxStaticBoxSizer(item6Static, wxVERTICAL);
214 item5->Add(item6, 1, wxGROW|wxALL, 5);
215
216 wxCheckBox* item7 = new wxCheckBox(item4, ID_LOAD_LAST_DOCUMENT, _("&Load last document"), wxDefaultPosition, wxDefaultSize, 0);
217 item7->SetValue(FALSE);
218 item6->Add(item7, 0, wxALIGN_LEFT|wxALL, 5);
219
220 wxCheckBox* item8 = new wxCheckBox(item4, ID_SHOW_TOOLTIPS, _("&Show tooltips"), wxDefaultPosition, wxDefaultSize, 0);
221 item8->SetValue(FALSE);
222 item6->Add(item8, 0, wxALIGN_LEFT|wxALL, 5);
223
224 GetSizer()->Fit(this);
225 ////@end ctGeneralSettingsDialog content construction
226
227 FindWindow(ID_LOAD_LAST_DOCUMENT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_loadLastDocument));
228 FindWindow(ID_SHOW_TOOLTIPS)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useToolTips));
229 }
230
231 /*!
232 * Should we show tooltips?
233 */
234
235 bool ctGeneralSettingsDialog::ShowToolTips()
236 {
237 return TRUE;
238 }
239
240 /*!
241 * ctLocationSettingsDialog type definition
242 */
243
244 IMPLEMENT_CLASS( ctLocationSettingsDialog, wxPanel )
245
246 /*!
247 * ctLocationSettingsDialog event table definition
248 */
249
250 BEGIN_EVENT_TABLE( ctLocationSettingsDialog, wxPanel )
251
252 ////@begin ctLocationSettingsDialog event table entries
253 EVT_UPDATE_UI( ID_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateWxwinHierarchy )
254
255 EVT_BUTTON( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnChooseWxwinHierarchy )
256 EVT_UPDATE_UI( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy )
257
258 ////@end ctLocationSettingsDialog event table entries
259
260 END_EVENT_TABLE()
261
262 /*!
263 * ctLocationSettingsDialog constructor
264 */
265
266 ctLocationSettingsDialog::ctLocationSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
267 {
268 wxPanel::Create( parent, id, pos, size, style );
269
270 CreateControls();
271 }
272
273 /*!
274 * Control creation for ctLocationSettingsDialog
275 */
276
277 void ctLocationSettingsDialog::CreateControls()
278 {
279 ////@begin ctLocationSettingsDialog content construction
280
281 ctLocationSettingsDialog* item9 = this;
282
283 wxBoxSizer* item10 = new wxBoxSizer(wxVERTICAL);
284 item9->SetSizer(item10);
285 item9->SetAutoLayout(TRUE);
286
287 wxStaticBox* item11Static = new wxStaticBox(item9, -1, _("Locations"));
288 wxStaticBoxSizer* item11 = new wxStaticBoxSizer(item11Static, wxVERTICAL);
289 item10->Add(item11, 1, wxGROW|wxALL, 5);
290
291 wxStaticText* item12 = new wxStaticText(item9, wxID_STATIC, _("&wxWindows hierarchy:"), wxDefaultPosition, wxDefaultSize, 0);
292 item11->Add(item12, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
293
294 wxBoxSizer* item13 = new wxBoxSizer(wxHORIZONTAL);
295 item11->Add(item13, 0, wxGROW, 5);
296
297 wxTextCtrl* item14 = new wxTextCtrl(item9, ID_WXWIN_HIERARCHY, _(""), wxDefaultPosition, wxSize(200, -1), 0);
298 item13->Add(item14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
299
300 wxButton* item15 = new wxButton(item9, ID_CHOOSE_WXWIN_HIERARCHY, _("&Choose..."), wxDefaultPosition, wxDefaultSize, 0);
301 item13->Add(item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
302
303 wxBoxSizer* item16 = new wxBoxSizer(wxHORIZONTAL);
304 item11->Add(item16, 0, wxGROW, 5);
305
306 item16->Add(60, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
307
308 wxCheckBox* item18 = new wxCheckBox(item9, ID_USE_WXWIN, _("&Use WXWIN environment variable"), wxDefaultPosition, wxDefaultSize, 0);
309 item18->SetValue(FALSE);
310 item16->Add(item18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
311
312 GetSizer()->Fit(this);
313 ////@end ctLocationSettingsDialog content construction
314
315 FindWindow(ID_WXWIN_HIERARCHY)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_frameworkDir));
316 FindWindow(ID_USE_WXWIN)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useEnvironmentVariable));
317 }
318
319 /*!
320 * Update event handler for ID_WXWIN_HIERARCHY
321 */
322
323 void ctLocationSettingsDialog::OnUpdateWxwinHierarchy( wxUpdateUIEvent& event )
324 {
325 wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
326 event.Enable(!checkbox->GetValue());
327 }
328
329 /*!
330 * Event handler for ID_CHOOSE_WXWIN_HIERARCHY
331 */
332
333 void ctLocationSettingsDialog::OnChooseWxwinHierarchy( wxCommandEvent& event )
334 {
335 wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow( ID_WXWIN_HIERARCHY );
336 wxASSERT( textCtrl != NULL );
337 wxString defaultPath = textCtrl->GetValue();
338
339 wxDirDialog dialog(this, _("Choose the location of the wxWindows hierarchy"),
340 defaultPath);
341 if (dialog.ShowModal() == wxID_OK)
342 {
343 textCtrl->SetValue(dialog.GetPath());
344 }
345 }
346
347 /*!
348 * Update event handler for ID_CHOOSE_WXWIN_HIERARCHY
349 */
350
351 void ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event )
352 {
353 wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
354 event.Enable(!checkbox->GetValue());
355 }
356
357 /*!
358 * Should we show tooltips?
359 */
360
361 bool ctLocationSettingsDialog::ShowToolTips()
362 {
363 return wxGetApp().GetSettings().m_useToolTips;
364 }