]> git.saurik.com Git - wxWidgets.git/blob - utils/configtool/src/settingsdialog.cpp
7bcb2fb02204fa9b8794897dbad56b7feae2bb28
[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* item9 = new ctLocationSettingsDialog(item3, ID_LOCATION_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
86 item3->AddPage(item9, _("Locations"));
87 item2->Add(item3Sizer, 0, wxGROW|wxALL, 5);
88
89 wxBoxSizer* item19 = new wxBoxSizer(wxHORIZONTAL);
90 item2->Add(item19, 0, wxGROW|wxALL, 5);
91
92 item19->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
93
94 wxButton* item21 = new wxButton(item1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0);
95 item21->SetDefault();
96 item19->Add(item21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97
98 wxButton* item22 = new wxButton(item1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
99 item19->Add(item22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
100
101 wxButton* item23 = new wxButton(item1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0);
102 item19->Add(item23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
103
104 #if defined(__WXGTK__) || defined(__WXMAC__)
105 wxContextHelpButton* item24 = new wxContextHelpButton(item1, wxID_CONTEXT_HELP, wxDefaultPosition, wxSize(20, -1), wxBU_AUTODRAW);
106 item19->Add(item24, 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 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 item6->Add(item7, 0, wxALIGN_LEFT|wxALL, 5);
223
224 wxCheckBox* item8 = new wxCheckBox(item4, ID_SHOW_TOOLTIPS, _("&Show tooltips"), wxDefaultPosition, wxDefaultSize, 0);
225 item8->SetValue(FALSE);
226 item6->Add(item8, 0, wxALIGN_LEFT|wxALL, 5);
227
228 GetSizer()->Fit(this);
229 ////@end ctGeneralSettingsDialog content construction
230
231 FindWindow(ID_LOAD_LAST_DOCUMENT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_loadLastDocument));
232 FindWindow(ID_SHOW_TOOLTIPS)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useToolTips));
233 }
234
235 /*!
236 * Should we show tooltips?
237 */
238
239 bool ctGeneralSettingsDialog::ShowToolTips()
240 {
241 return TRUE;
242 }
243
244 /*!
245 * ctLocationSettingsDialog type definition
246 */
247
248 IMPLEMENT_CLASS( ctLocationSettingsDialog, wxPanel )
249
250 /*!
251 * ctLocationSettingsDialog event table definition
252 */
253
254 BEGIN_EVENT_TABLE( ctLocationSettingsDialog, wxPanel )
255
256 ////@begin ctLocationSettingsDialog event table entries
257 EVT_UPDATE_UI( ID_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateWxwinHierarchy )
258
259 EVT_BUTTON( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnChooseWxwinHierarchy )
260 EVT_UPDATE_UI( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy )
261
262 ////@end ctLocationSettingsDialog event table entries
263
264 END_EVENT_TABLE()
265
266 /*!
267 * ctLocationSettingsDialog constructor
268 */
269
270 ctLocationSettingsDialog::ctLocationSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
271 {
272 wxPanel::Create( parent, id, pos, size, style );
273
274 CreateControls();
275 }
276
277 /*!
278 * Control creation for ctLocationSettingsDialog
279 */
280
281 void ctLocationSettingsDialog::CreateControls()
282 {
283 ////@begin ctLocationSettingsDialog content construction
284
285 ctLocationSettingsDialog* item9 = this;
286
287 wxBoxSizer* item10 = new wxBoxSizer(wxVERTICAL);
288 item9->SetSizer(item10);
289 item9->SetAutoLayout(TRUE);
290
291 wxStaticBox* item11Static = new wxStaticBox(item9, -1, _("Locations"));
292 wxStaticBoxSizer* item11 = new wxStaticBoxSizer(item11Static, wxVERTICAL);
293 item10->Add(item11, 1, wxGROW|wxALL, 5);
294
295 wxStaticText* item12 = new wxStaticText(item9, wxID_STATIC, _("&wxWindows hierarchy:"), wxDefaultPosition, wxDefaultSize, 0);
296 item11->Add(item12, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
297
298 wxBoxSizer* item13 = new wxBoxSizer(wxHORIZONTAL);
299 item11->Add(item13, 0, wxGROW, 5);
300
301 wxTextCtrl* item14 = new wxTextCtrl(item9, ID_WXWIN_HIERARCHY, _(""), wxDefaultPosition, wxSize(200, -1), 0);
302 item13->Add(item14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
303
304 wxButton* item15 = new wxButton(item9, ID_CHOOSE_WXWIN_HIERARCHY, _("&Choose..."), wxDefaultPosition, wxDefaultSize, 0);
305 item13->Add(item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
306
307 wxBoxSizer* item16 = new wxBoxSizer(wxHORIZONTAL);
308 item11->Add(item16, 0, wxGROW, 5);
309
310 item16->Add(60, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
311
312 wxCheckBox* item18 = new wxCheckBox(item9, ID_USE_WXWIN, _("&Use WXWIN environment variable"), wxDefaultPosition, wxDefaultSize, 0);
313 item18->SetValue(FALSE);
314 item16->Add(item18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
315
316 GetSizer()->Fit(this);
317 ////@end ctLocationSettingsDialog content construction
318
319 FindWindow(ID_WXWIN_HIERARCHY)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_frameworkDir));
320 FindWindow(ID_USE_WXWIN)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useEnvironmentVariable));
321 }
322
323 /*!
324 * Update event handler for ID_WXWIN_HIERARCHY
325 */
326
327 void ctLocationSettingsDialog::OnUpdateWxwinHierarchy( wxUpdateUIEvent& event )
328 {
329 wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
330 event.Enable(!checkbox->GetValue());
331 }
332
333 /*!
334 * Event handler for ID_CHOOSE_WXWIN_HIERARCHY
335 */
336
337 void ctLocationSettingsDialog::OnChooseWxwinHierarchy( wxCommandEvent& event )
338 {
339 wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow( ID_WXWIN_HIERARCHY );
340 wxASSERT( textCtrl != NULL );
341 wxString defaultPath = textCtrl->GetValue();
342
343 wxDirDialog dialog(this, _("Choose the location of the wxWindows hierarchy"),
344 defaultPath);
345 if (dialog.ShowModal() == wxID_OK)
346 {
347 textCtrl->SetValue(dialog.GetPath());
348 }
349 }
350
351 /*!
352 * Update event handler for ID_CHOOSE_WXWIN_HIERARCHY
353 */
354
355 void ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event )
356 {
357 wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
358 event.Enable(!checkbox->GetValue());
359 }
360
361 /*!
362 * Should we show tooltips?
363 */
364
365 bool ctLocationSettingsDialog::ShowToolTips()
366 {
367 return wxGetApp().GetSettings().m_useToolTips;
368 }