]> git.saurik.com Git - wxWidgets.git/blame - utils/configtool/src/settingsdialog.cpp
Removal of first part of dsw files (as requested by Jamie Gadd).
[wxWidgets.git] / utils / configtool / src / settingsdialog.cpp
CommitLineData
d7463f75 1/////////////////////////////////////////////////////////////////////////////
90c0f5a9 2// Name: utils/configtool/src/settingsdialog.cpp
d9ab621e
WS
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:
d7463f75
JS
10/////////////////////////////////////////////////////////////////////////////
11
d9ab621e
WS
12// For compilers that support precompilation, includes "wx/wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20
c5565f8c 21#include "wx/intl.h"
d7463f75
JS
22#include "wx/statline.h"
23#include "wx/splitter.h"
24#include "wx/scrolwin.h"
25#include "wx/spinctrl.h"
26#include "wx/spinbutt.h"
60c474a0
MB
27#include "wx/sizer.h"
28#include "wx/statbox.h"
29#include "wx/dirdlg.h"
c5565f8c
WS
30#include "wx/stattext.h"
31#include "wx/choice.h"
d7463f75 32
d9ab621e
WS
33#endif
34
35#include "wx/cshelp.h"
36#include "wx/notebook.h"
37#include "wx/valgen.h"
d7463f75
JS
38#include "wxconfigtool.h"
39#include "settingsdialog.h"
40
41////@begin XPM images
42////@end XPM images
43
44/*!
45 * ctSettingsDialog type definition
46 */
47
48IMPLEMENT_CLASS( ctSettingsDialog, wxDialog )
49
50/*!
51 * ctSettingsDialog event table definition
52 */
53
54BEGIN_EVENT_TABLE( ctSettingsDialog, wxDialog )
55
56////@begin ctSettingsDialog event table entries
57 EVT_BUTTON( wxID_OK, ctSettingsDialog::OnOk )
58
59 EVT_BUTTON( wxID_CANCEL, ctSettingsDialog::OnCancel )
60
61 EVT_BUTTON( wxID_HELP, ctSettingsDialog::OnHelp )
62
63////@end ctSettingsDialog event table entries
64
65END_EVENT_TABLE()
66
67/*!
68 * ctSettingsDialog constructor
69 */
70
d9ab621e 71ctSettingsDialog::ctSettingsDialog( wxWindow* parent )
d7463f75
JS
72{
73 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
d9ab621e 74 wxDialog::Create( parent, wxID_ANY, _("Configuration Settings"));
d7463f75
JS
75 CreateControls();
76}
77
78/*!
79 * Control creation for ctSettingsDialog
80 */
81
82void ctSettingsDialog::CreateControls()
dabbc6a5 83{
d7463f75
JS
84////@begin ctSettingsDialog content construction
85
86 ctSettingsDialog* item1 = this;
87
88 wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
89 item1->SetSizer(item2);
d7463f75 90
90c0f5a9 91 m_notebook = new wxNotebook(item1, wxID_ANY, wxDefaultPosition, wxSize(200, 200), wxBK_TOP);
d9ab621e
WS
92 ctGeneralSettingsDialog* item4 = new ctGeneralSettingsDialog(m_notebook, ID_GENERAL_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
93 m_notebook->AddPage(item4, _("General"));
94 ctLocationSettingsDialog* item11 = new ctLocationSettingsDialog(m_notebook, ID_LOCATION_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
95 m_notebook->AddPage(item11, _("Locations"));
96 item2->Add(m_notebook, 0, wxGROW|wxALL, 5);
d7463f75 97
afc51590
JS
98 wxBoxSizer* item21 = new wxBoxSizer(wxHORIZONTAL);
99 item2->Add(item21, 0, wxGROW|wxALL, 5);
d7463f75 100
afc51590 101 item21->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 102
677ded95 103 wxButton* item23 = new wxButton(item1, wxID_OK);
afc51590
JS
104 item23->SetDefault();
105 item21->Add(item23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 106
677ded95 107 wxButton* item24 = new wxButton(item1, wxID_CANCEL);
afc51590 108 item21->Add(item24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 109
677ded95 110 wxButton* item25 = new wxButton(item1, wxID_HELP);
afc51590 111 item21->Add(item25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75
JS
112
113#if defined(__WXGTK__) || defined(__WXMAC__)
422d0ff0 114 wxContextHelpButton* item26 = new wxContextHelpButton(item1, wxID_CONTEXT_HELP, wxDefaultPosition, wxSize(20, wxDefaultCoord), wxBU_AUTODRAW);
afc51590 115 item21->Add(item26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75
JS
116#endif
117
118 GetSizer()->Fit(this);
119 GetSizer()->SetSizeHints(this);
120 Centre();
121////@end ctSettingsDialog content construction
122}
123
124/*!
125 * Event handler for wxID_OK
126 */
127
128void ctSettingsDialog::OnOk( wxCommandEvent& event )
129{
130 // Replace with custom code
131 event.Skip();
132}
133
134/*!
135 * Event handler for wxID_CANCEL
136 */
137
138void ctSettingsDialog::OnCancel( wxCommandEvent& event )
139{
140 // Replace with custom code
141 event.Skip();
142}
143
144/*!
145 * Event handler for wxID_HELP
146 */
147
69da0d99 148void ctSettingsDialog::OnHelp( wxCommandEvent& WXUNUSED(event) )
d7463f75 149{
d9ab621e 150 if(m_notebook)
d7463f75 151 {
d9ab621e
WS
152 int sel = m_notebook->GetSelection();
153
154 wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));
155
156 wxWindow* page = (wxWindow*) m_notebook->GetPage(sel);
157
158 wxString helpTopic;
159 if (page->GetId() == ID_GENERAL_SETTINGS_DIALOG)
160 {
161 helpTopic = wxT("General settings dialog");
162 }
163 else if (page->GetId() == ID_LOCATION_SETTINGS_DIALOG)
164 {
165 helpTopic = wxT("Location settings dialog");
166 }
167
677ded95 168 if (!helpTopic.empty())
d9ab621e
WS
169 {
170 wxGetApp().GetHelpController().DisplaySection(helpTopic);
171 }
d7463f75
JS
172 }
173}
174
175/*!
176 * Should we show tooltips?
177 */
178
179bool ctSettingsDialog::ShowToolTips()
180{
4fe30bce 181 return true;
d7463f75
JS
182}
183
184/*!
185 * ctGeneralSettingsDialog type definition
186 */
187
188IMPLEMENT_CLASS( ctGeneralSettingsDialog, wxPanel )
189
190/*!
191 * ctGeneralSettingsDialog event table definition
192 */
193
194BEGIN_EVENT_TABLE( ctGeneralSettingsDialog, wxPanel )
195
196////@begin ctGeneralSettingsDialog event table entries
197////@end ctGeneralSettingsDialog event table entries
198
199END_EVENT_TABLE()
200
201/*!
202 * ctGeneralSettingsDialog constructor
203 */
204
205ctGeneralSettingsDialog::ctGeneralSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
206{
207 wxPanel::Create( parent, id, pos, size, style );
208
209 CreateControls();
210}
211
212/*!
213 * Control creation for ctGeneralSettingsDialog
214 */
215
216void ctGeneralSettingsDialog::CreateControls()
dabbc6a5 217{
d7463f75
JS
218////@begin ctGeneralSettingsDialog content construction
219
220 ctGeneralSettingsDialog* item4 = this;
221
222 wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL);
223 item4->SetSizer(item5);
d7463f75 224
4fe30bce 225 wxStaticBox* item6Static = new wxStaticBox(item4, wxID_ANY, _("General settings"));
d7463f75
JS
226 wxStaticBoxSizer* item6 = new wxStaticBoxSizer(item6Static, wxVERTICAL);
227 item5->Add(item6, 1, wxGROW|wxALL, 5);
228
229 wxCheckBox* item7 = new wxCheckBox(item4, ID_LOAD_LAST_DOCUMENT, _("&Load last document"), wxDefaultPosition, wxDefaultSize, 0);
4fe30bce 230 item7->SetValue(false);
afc51590 231 item7->SetHelpText(_("Check to load the last document on startup"));
3ac35b57 232#if wxUSE_TOOLTIPS
afc51590
JS
233 if (ShowToolTips())
234 item7->SetToolTip(_("Check to load the last document on startup"));
3ac35b57 235#endif
d7463f75
JS
236 item6->Add(item7, 0, wxALIGN_LEFT|wxALL, 5);
237
238 wxCheckBox* item8 = new wxCheckBox(item4, ID_SHOW_TOOLTIPS, _("&Show tooltips"), wxDefaultPosition, wxDefaultSize, 0);
4fe30bce 239 item8->SetValue(false);
afc51590 240 item8->SetHelpText(_("Check to show tooltips"));
3ac35b57 241#if wxUSE_TOOLTIPS
afc51590
JS
242 if (ShowToolTips())
243 item8->SetToolTip(_("Check to show tooltips"));
3ac35b57 244#endif
d7463f75
JS
245 item6->Add(item8, 0, wxALIGN_LEFT|wxALL, 5);
246
afc51590
JS
247 wxStaticText* item9 = new wxStaticText(item4, wxID_STATIC, _("&Default file kind to save when using the Go command:"), wxDefaultPosition, wxDefaultSize, 0);
248 item6->Add(item9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
249
250 wxString item10Strings[] = {
251 _("Setup file"),
252 _("Configure script")
253 };
422d0ff0 254 wxChoice* item10 = new wxChoice(item4, ID_DEFAULT_FILE_KIND, wxDefaultPosition, wxSize(200, wxDefaultCoord), 2, item10Strings, 0);
afc51590
JS
255 item10->SetStringSelection(_("Setup file"));
256 item10->SetHelpText(_("Select the default kind of file to save using Go"));
3ac35b57 257#if wxUSE_TOOLTIPS
afc51590
JS
258 if (ShowToolTips())
259 item10->SetToolTip(_("Select the default kind of file to save using Go"));
3ac35b57 260#endif
afc51590
JS
261 item6->Add(item10, 0, wxGROW|wxALL, 5);
262
d7463f75
JS
263 GetSizer()->Fit(this);
264////@end ctGeneralSettingsDialog content construction
265
d9ab621e
WS
266 item7->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_loadLastDocument));
267 item8->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useToolTips));
268 item10->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_defaultFileKind));
d7463f75
JS
269}
270
271/*!
272 * Should we show tooltips?
273 */
274
275bool ctGeneralSettingsDialog::ShowToolTips()
276{
4fe30bce 277 return true;
d7463f75
JS
278}
279
280/*!
281 * ctLocationSettingsDialog type definition
282 */
283
284IMPLEMENT_CLASS( ctLocationSettingsDialog, wxPanel )
285
286/*!
287 * ctLocationSettingsDialog event table definition
288 */
289
290BEGIN_EVENT_TABLE( ctLocationSettingsDialog, wxPanel )
291
292////@begin ctLocationSettingsDialog event table entries
293 EVT_UPDATE_UI( ID_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateWxwinHierarchy )
294
295 EVT_BUTTON( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnChooseWxwinHierarchy )
296 EVT_UPDATE_UI( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy )
297
298////@end ctLocationSettingsDialog event table entries
299
300END_EVENT_TABLE()
301
302/*!
303 * ctLocationSettingsDialog constructor
304 */
305
306ctLocationSettingsDialog::ctLocationSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
307{
308 wxPanel::Create( parent, id, pos, size, style );
309
310 CreateControls();
311}
312
313/*!
314 * Control creation for ctLocationSettingsDialog
315 */
316
317void ctLocationSettingsDialog::CreateControls()
dabbc6a5 318{
d7463f75
JS
319////@begin ctLocationSettingsDialog content construction
320
afc51590 321 ctLocationSettingsDialog* item11 = this;
d7463f75 322
afc51590
JS
323 wxBoxSizer* item12 = new wxBoxSizer(wxVERTICAL);
324 item11->SetSizer(item12);
d7463f75 325
4fe30bce 326 wxStaticBox* item13Static = new wxStaticBox(item11, wxID_ANY, _("Locations"));
afc51590
JS
327 wxStaticBoxSizer* item13 = new wxStaticBoxSizer(item13Static, wxVERTICAL);
328 item12->Add(item13, 1, wxGROW|wxALL, 5);
d7463f75 329
be5a51fb 330 wxStaticText* item14 = new wxStaticText(item11, wxID_STATIC, _("&wxWidgets hierarchy:"), wxDefaultPosition, wxDefaultSize, 0);
afc51590 331 item13->Add(item14, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
d7463f75 332
afc51590
JS
333 wxBoxSizer* item15 = new wxBoxSizer(wxHORIZONTAL);
334 item13->Add(item15, 0, wxGROW, 5);
d7463f75 335
d9ab621e
WS
336 m_wxWinHierarchy = new wxTextCtrl(item11, ID_WXWIN_HIERARCHY, wxEmptyString, wxDefaultPosition, wxSize(200, wxDefaultCoord), 0);
337 m_wxWinHierarchy->SetHelpText(_("Enter the root path of the wxWidgets hierarchy"));
3ac35b57 338#if wxUSE_TOOLTIPS
afc51590 339 if (ShowToolTips())
d9ab621e 340 m_wxWinHierarchy->SetToolTip(_("Enter the root path of the wxWidgets hierarchy"));
3ac35b57 341#endif
d9ab621e 342 item15->Add(m_wxWinHierarchy, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 343
afc51590 344 wxButton* item17 = new wxButton(item11, ID_CHOOSE_WXWIN_HIERARCHY, _("&Choose..."), wxDefaultPosition, wxDefaultSize, 0);
be5a51fb 345 item17->SetHelpText(_("Click to choose the root path of the wxWidgets hierarchy\\n"));
3ac35b57 346#if wxUSE_TOOLTIPS
afc51590 347 if (ShowToolTips())
be5a51fb 348 item17->SetToolTip(_("Click to choose the root path of the wxWidgets hierarchy\\n"));
3ac35b57 349#endif
afc51590 350 item15->Add(item17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 351
afc51590
JS
352 wxBoxSizer* item18 = new wxBoxSizer(wxHORIZONTAL);
353 item13->Add(item18, 0, wxGROW, 5);
d7463f75 354
afc51590 355 item18->Add(60, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75 356
d9ab621e
WS
357 m_wxWinUse = new wxCheckBox(item11, ID_USE_WXWIN, _("&Use WXWIN environment variable"));
358 m_wxWinUse->SetValue(false);
359 m_wxWinUse->SetHelpText(_("Check to use the value of WXWIN instead"));
3ac35b57 360#if wxUSE_TOOLTIPS
afc51590 361 if (ShowToolTips())
d9ab621e 362 m_wxWinUse->SetToolTip(_("Check to use the value of WXWIN instead"));
3ac35b57 363#endif
d9ab621e 364 item18->Add(m_wxWinUse, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
d7463f75
JS
365
366 GetSizer()->Fit(this);
367////@end ctLocationSettingsDialog content construction
368
d9ab621e
WS
369 m_wxWinHierarchy->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_frameworkDir));
370 m_wxWinUse->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useEnvironmentVariable));
d7463f75
JS
371}
372
373/*!
374 * Update event handler for ID_WXWIN_HIERARCHY
375 */
376
377void ctLocationSettingsDialog::OnUpdateWxwinHierarchy( wxUpdateUIEvent& event )
378{
d9ab621e
WS
379 if(m_wxWinUse)
380 event.Enable(!m_wxWinUse->GetValue());
d7463f75
JS
381}
382
383/*!
384 * Event handler for ID_CHOOSE_WXWIN_HIERARCHY
385 */
386
69da0d99 387void ctLocationSettingsDialog::OnChooseWxwinHierarchy( wxCommandEvent& WXUNUSED(event) )
d7463f75 388{
d9ab621e 389 if (m_wxWinHierarchy)
d7463f75 390 {
d9ab621e
WS
391 wxString defaultPath = m_wxWinHierarchy->GetValue();
392
393 wxDirDialog dialog(this, _("Choose the location of the wxWidgets hierarchy"),
394 defaultPath);
395 if (dialog.ShowModal() == wxID_OK)
396 {
397 m_wxWinHierarchy->SetValue(dialog.GetPath());
398 }
d7463f75
JS
399 }
400}
401
402/*!
403 * Update event handler for ID_CHOOSE_WXWIN_HIERARCHY
404 */
405
406void ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event )
407{
d9ab621e
WS
408 if (m_wxWinUse)
409 event.Enable(!m_wxWinUse->GetValue());
d7463f75
JS
410}
411
412/*!
413 * Should we show tooltips?
414 */
415
416bool ctLocationSettingsDialog::ShowToolTips()
417{
418 return wxGetApp().GetSettings().m_useToolTips;
419}