]> git.saurik.com Git - wxWidgets.git/blame - utils/configtool/src/settingsdialog.cpp
Fix docs for Bind
[wxWidgets.git] / utils / configtool / src / settingsdialog.cpp
CommitLineData
d7463f75
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: settingsdialog.cpp
3// Purpose:
4// Author:
5// Modified by:
6// Created:
7// RCS-ID:
8// Copyright:
9// Licence:
10/////////////////////////////////////////////////////////////////////////////
11
71ada1a5 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
f8105809
JS
13#pragma implementation "settingsdialog.h"
14#endif
15
d7463f75
JS
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
36IMPLEMENT_CLASS( ctSettingsDialog, wxDialog )
37
38/*!
39 * ctSettingsDialog event table definition
40 */
41
42BEGIN_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
53END_EVENT_TABLE()
54
55/*!
56 * ctSettingsDialog constructor
57 */
58
59ctSettingsDialog::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
71void 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"));
afc51590
JS
85 ctLocationSettingsDialog* item11 = new ctLocationSettingsDialog(item3, ID_LOCATION_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
86 item3->AddPage(item11, _("Locations"));
d7463f75
JS
87 item2->Add(item3Sizer, 0, wxGROW|wxALL, 5);
88
afc51590
JS
89 wxBoxSizer* item21 = new wxBoxSizer(wxHORIZONTAL);
90 item2->Add(item21, 0, wxGROW|wxALL, 5);
d7463f75 91
afc51590 92 item21->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 93
afc51590
JS
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);
d7463f75 97
afc51590
JS
98 wxButton* item24 = new wxButton(item1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
99 item21->Add(item24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 100
afc51590
JS
101 wxButton* item25 = new wxButton(item1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0);
102 item21->Add(item25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75
JS
103
104#if defined(__WXGTK__) || defined(__WXMAC__)
afc51590
JS
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);
d7463f75
JS
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
119void ctSettingsDialog::OnOk( wxCommandEvent& event )
120{
121 // Replace with custom code
122 event.Skip();
123}
124
125/*!
126 * Event handler for wxID_CANCEL
127 */
128
129void ctSettingsDialog::OnCancel( wxCommandEvent& event )
130{
131 // Replace with custom code
132 event.Skip();
133}
134
135/*!
136 * Event handler for wxID_HELP
137 */
138
69da0d99 139void ctSettingsDialog::OnHelp( wxCommandEvent& WXUNUSED(event) )
d7463f75
JS
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 {
e7767867 156 helpTopic = wxT("Location settings dialog");
d7463f75
JS
157 }
158
159 if (!helpTopic.IsEmpty())
160 {
161 wxGetApp().GetHelpController().DisplaySection(helpTopic);
162 }
163}
164
165/*!
166 * Should we show tooltips?
167 */
168
169bool ctSettingsDialog::ShowToolTips()
170{
171 return TRUE;
172}
173
174/*!
175 * ctGeneralSettingsDialog type definition
176 */
177
178IMPLEMENT_CLASS( ctGeneralSettingsDialog, wxPanel )
179
180/*!
181 * ctGeneralSettingsDialog event table definition
182 */
183
184BEGIN_EVENT_TABLE( ctGeneralSettingsDialog, wxPanel )
185
186////@begin ctGeneralSettingsDialog event table entries
187////@end ctGeneralSettingsDialog event table entries
188
189END_EVENT_TABLE()
190
191/*!
192 * ctGeneralSettingsDialog constructor
193 */
194
195ctGeneralSettingsDialog::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
206void 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);
afc51590 222 item7->SetHelpText(_("Check to load the last document on startup"));
3ac35b57 223#if wxUSE_TOOLTIPS
afc51590
JS
224 if (ShowToolTips())
225 item7->SetToolTip(_("Check to load the last document on startup"));
3ac35b57 226#endif
d7463f75
JS
227 item6->Add(item7, 0, wxALIGN_LEFT|wxALL, 5);
228
229 wxCheckBox* item8 = new wxCheckBox(item4, ID_SHOW_TOOLTIPS, _("&Show tooltips"), wxDefaultPosition, wxDefaultSize, 0);
230 item8->SetValue(FALSE);
afc51590 231 item8->SetHelpText(_("Check to show tooltips"));
3ac35b57 232#if wxUSE_TOOLTIPS
afc51590
JS
233 if (ShowToolTips())
234 item8->SetToolTip(_("Check to show tooltips"));
3ac35b57 235#endif
d7463f75
JS
236 item6->Add(item8, 0, wxALIGN_LEFT|wxALL, 5);
237
afc51590
JS
238 wxStaticText* item9 = new wxStaticText(item4, wxID_STATIC, _("&Default file kind to save when using the Go command:"), wxDefaultPosition, wxDefaultSize, 0);
239 item6->Add(item9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
240
241 wxString item10Strings[] = {
242 _("Setup file"),
243 _("Configure script")
244 };
245 wxChoice* item10 = new wxChoice(item4, ID_DEFAULT_FILE_KIND, wxDefaultPosition, wxSize(200, -1), 2, item10Strings, 0);
246 item10->SetStringSelection(_("Setup file"));
247 item10->SetHelpText(_("Select the default kind of file to save using Go"));
3ac35b57 248#if wxUSE_TOOLTIPS
afc51590
JS
249 if (ShowToolTips())
250 item10->SetToolTip(_("Select the default kind of file to save using Go"));
3ac35b57 251#endif
afc51590
JS
252 item6->Add(item10, 0, wxGROW|wxALL, 5);
253
d7463f75
JS
254 GetSizer()->Fit(this);
255////@end ctGeneralSettingsDialog content construction
256
257 FindWindow(ID_LOAD_LAST_DOCUMENT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_loadLastDocument));
258 FindWindow(ID_SHOW_TOOLTIPS)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useToolTips));
afc51590 259 FindWindow(ID_DEFAULT_FILE_KIND)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_defaultFileKind));
d7463f75
JS
260}
261
262/*!
263 * Should we show tooltips?
264 */
265
266bool ctGeneralSettingsDialog::ShowToolTips()
267{
268 return TRUE;
269}
270
271/*!
272 * ctLocationSettingsDialog type definition
273 */
274
275IMPLEMENT_CLASS( ctLocationSettingsDialog, wxPanel )
276
277/*!
278 * ctLocationSettingsDialog event table definition
279 */
280
281BEGIN_EVENT_TABLE( ctLocationSettingsDialog, wxPanel )
282
283////@begin ctLocationSettingsDialog event table entries
284 EVT_UPDATE_UI( ID_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateWxwinHierarchy )
285
286 EVT_BUTTON( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnChooseWxwinHierarchy )
287 EVT_UPDATE_UI( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy )
288
289////@end ctLocationSettingsDialog event table entries
290
291END_EVENT_TABLE()
292
293/*!
294 * ctLocationSettingsDialog constructor
295 */
296
297ctLocationSettingsDialog::ctLocationSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
298{
299 wxPanel::Create( parent, id, pos, size, style );
300
301 CreateControls();
302}
303
304/*!
305 * Control creation for ctLocationSettingsDialog
306 */
307
308void ctLocationSettingsDialog::CreateControls()
309{
310////@begin ctLocationSettingsDialog content construction
311
afc51590 312 ctLocationSettingsDialog* item11 = this;
d7463f75 313
afc51590
JS
314 wxBoxSizer* item12 = new wxBoxSizer(wxVERTICAL);
315 item11->SetSizer(item12);
316 item11->SetAutoLayout(TRUE);
d7463f75 317
afc51590
JS
318 wxStaticBox* item13Static = new wxStaticBox(item11, -1, _("Locations"));
319 wxStaticBoxSizer* item13 = new wxStaticBoxSizer(item13Static, wxVERTICAL);
320 item12->Add(item13, 1, wxGROW|wxALL, 5);
d7463f75 321
afc51590
JS
322 wxStaticText* item14 = new wxStaticText(item11, wxID_STATIC, _("&wxWindows hierarchy:"), wxDefaultPosition, wxDefaultSize, 0);
323 item13->Add(item14, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
d7463f75 324
afc51590
JS
325 wxBoxSizer* item15 = new wxBoxSizer(wxHORIZONTAL);
326 item13->Add(item15, 0, wxGROW, 5);
d7463f75 327
afc51590
JS
328 wxTextCtrl* item16 = new wxTextCtrl(item11, ID_WXWIN_HIERARCHY, _(""), wxDefaultPosition, wxSize(200, -1), 0);
329 item16->SetHelpText(_("Enter the root path of the wxWindows hierarchy"));
3ac35b57 330#if wxUSE_TOOLTIPS
afc51590
JS
331 if (ShowToolTips())
332 item16->SetToolTip(_("Enter the root path of the wxWindows hierarchy"));
3ac35b57 333#endif
afc51590 334 item15->Add(item16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 335
afc51590
JS
336 wxButton* item17 = new wxButton(item11, ID_CHOOSE_WXWIN_HIERARCHY, _("&Choose..."), wxDefaultPosition, wxDefaultSize, 0);
337 item17->SetHelpText(_("Click to choose the root path of the wxWindows hierarchy\\n"));
3ac35b57 338#if wxUSE_TOOLTIPS
afc51590
JS
339 if (ShowToolTips())
340 item17->SetToolTip(_("Click to choose the root path of the wxWindows hierarchy\\n"));
3ac35b57 341#endif
afc51590 342 item15->Add(item17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 343
afc51590
JS
344 wxBoxSizer* item18 = new wxBoxSizer(wxHORIZONTAL);
345 item13->Add(item18, 0, wxGROW, 5);
d7463f75 346
afc51590 347 item18->Add(60, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 348
afc51590
JS
349 wxCheckBox* item20 = new wxCheckBox(item11, ID_USE_WXWIN, _("&Use WXWIN environment variable"), wxDefaultPosition, wxDefaultSize, 0);
350 item20->SetValue(FALSE);
351 item20->SetHelpText(_("Check to use the value of WXWIN instead"));
3ac35b57 352#if wxUSE_TOOLTIPS
afc51590
JS
353 if (ShowToolTips())
354 item20->SetToolTip(_("Check to use the value of WXWIN instead"));
3ac35b57 355#endif
afc51590 356 item18->Add(item20, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75
JS
357
358 GetSizer()->Fit(this);
359////@end ctLocationSettingsDialog content construction
360
361 FindWindow(ID_WXWIN_HIERARCHY)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_frameworkDir));
362 FindWindow(ID_USE_WXWIN)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useEnvironmentVariable));
363}
364
365/*!
366 * Update event handler for ID_WXWIN_HIERARCHY
367 */
368
369void ctLocationSettingsDialog::OnUpdateWxwinHierarchy( wxUpdateUIEvent& event )
370{
371 wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
372 event.Enable(!checkbox->GetValue());
373}
374
375/*!
376 * Event handler for ID_CHOOSE_WXWIN_HIERARCHY
377 */
378
69da0d99 379void ctLocationSettingsDialog::OnChooseWxwinHierarchy( wxCommandEvent& WXUNUSED(event) )
d7463f75
JS
380{
381 wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow( ID_WXWIN_HIERARCHY );
382 wxASSERT( textCtrl != NULL );
383 wxString defaultPath = textCtrl->GetValue();
384
385 wxDirDialog dialog(this, _("Choose the location of the wxWindows hierarchy"),
386 defaultPath);
387 if (dialog.ShowModal() == wxID_OK)
388 {
389 textCtrl->SetValue(dialog.GetPath());
390 }
391}
392
393/*!
394 * Update event handler for ID_CHOOSE_WXWIN_HIERARCHY
395 */
396
397void ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event )
398{
399 wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
400 event.Enable(!checkbox->GetValue());
401}
402
403/*!
404 * Should we show tooltips?
405 */
406
407bool ctLocationSettingsDialog::ShowToolTips()
408{
409 return wxGetApp().GetSettings().m_useToolTips;
410}