+
+#endif // USE_MODAL_PRESENTATION
+
+// ----------------------------------------------------------------------------
+// StdButtonSizerDialog
+// ----------------------------------------------------------------------------
+
+StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent)
+ : wxDialog(parent, wxID_ANY, wxString(_T("StdButtonSizer dialog")),
+ wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
+ m_buttonsSizer(NULL)
+{
+ wxBoxSizer *const sizerTop = new wxBoxSizer(wxVERTICAL);
+
+ wxBoxSizer *const sizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *const sizerInside1 = new wxBoxSizer(wxVERTICAL);
+
+ m_chkboxAffirmativeButton = new wxCheckBox(this, wxID_ANY, _("Enable Affirmative Button"));
+
+ wxStaticBoxSizer *const sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Affirmative Button"));
+
+ m_radiobtnOk = new wxRadioButton(this, wxID_ANY, _("Ok"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+ m_radiobtnYes = new wxRadioButton(this, wxID_ANY, _("Yes"));
+
+ wxBoxSizer *const sizerInside2 = new wxBoxSizer(wxVERTICAL);
+
+ m_chkboxDismissButton = new wxCheckBox(this, wxID_ANY, _("Enable Dismiss Button"));
+
+ wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Dismiss Button"));
+
+ m_radiobtnCancel = new wxRadioButton(this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+ m_radiobtnClose = new wxRadioButton(this, wxID_ANY, _("Close"));
+
+ wxBoxSizer *const sizer3 = new wxBoxSizer(wxHORIZONTAL);
+
+ m_chkboxNo = new wxCheckBox(this, wxID_ANY, _("No"));
+ m_chkboxHelp = new wxCheckBox(this, wxID_ANY, _("Help"));
+ m_chkboxApply = new wxCheckBox(this, wxID_ANY, _("Apply"));
+
+ m_chkboxNoDefault = new wxCheckBox(this, wxID_ANY, wxT("No Default"));
+
+ sizer1->Add(m_radiobtnOk, 0, wxALL, 5);
+ sizer1->Add(m_radiobtnYes, 0, wxALL, 5);
+
+ sizer->Add(sizerInside1, 0, 0, 0);
+ sizerInside1->Add(m_chkboxAffirmativeButton, 0, wxALL, 5);
+ sizerInside1->Add(sizer1, 0, wxALL, 5);
+ sizerInside1->SetItemMinSize(sizer1, sizer1->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
+
+ sizer2->Add(m_radiobtnCancel, 0, wxALL, 5);
+ sizer2->Add(m_radiobtnClose, 0, wxALL, 5);
+
+ sizer->Add(sizerInside2, 0, 0, 0);
+ sizerInside2->Add(m_chkboxDismissButton, 0, wxALL, 5);
+ sizerInside2->Add(sizer2, 0, wxALL, 5);
+ sizerInside2->SetItemMinSize(sizer2, sizer2->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
+
+ sizerTop->Add(sizer, 0, wxALL, 5);
+
+ sizer3->Add(m_chkboxNo, 0, wxALL, 5);
+ sizer3->Add(m_chkboxHelp, 0, wxALL, 5);
+ sizer3->Add(m_chkboxApply, 0, wxALL, 5);
+
+ sizerTop->Add(sizer3, 0, wxALL, 5);
+
+ sizerTop->Add(m_chkboxNoDefault, 0, wxLEFT|wxRIGHT, 10);
+
+ EnableDisableControls();
+
+ SetSizer(sizerTop);
+
+ sizerTop->SetSizeHints(this);
+ wxCommandEvent ev;
+ OnEvent(ev);
+}
+
+void StdButtonSizerDialog::OnEvent(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_buttonsSizer)
+ {
+ m_buttonsSizer->DeleteWindows();
+ GetSizer()->Remove(m_buttonsSizer);
+ }
+
+ EnableDisableControls();
+
+ long flags = 0;
+ unsigned long numButtons = 0;
+
+ if (m_chkboxAffirmativeButton->IsChecked())
+ {
+ if (m_radiobtnOk->GetValue())
+ {
+ flags |= wxOK;
+ numButtons ++;
+ }
+ else if (m_radiobtnYes->GetValue())
+ {
+ flags |= wxYES;
+ numButtons ++;
+ }
+ }
+
+ if (m_chkboxDismissButton->IsChecked())
+ {
+ if (m_radiobtnCancel->GetValue())
+ {
+ flags |= wxCANCEL;
+ numButtons ++;
+ }
+
+ else if (m_radiobtnClose->GetValue())
+ {
+ flags |= wxCLOSE;
+ numButtons ++;
+ }
+
+ }
+
+ if (m_chkboxApply->IsChecked())
+ {
+ flags |= wxAPPLY;
+ numButtons ++;
+ }
+
+ if (m_chkboxNo->IsChecked())
+ {
+ flags |= wxNO;
+ numButtons ++;
+ }
+
+ if (m_chkboxHelp->IsChecked())
+ {
+ flags |= wxHELP;
+ numButtons ++;
+ }
+
+ if (m_chkboxNoDefault->IsChecked())
+ {
+ flags |= wxNO_DEFAULT;
+ }
+
+ m_buttonsSizer = CreateStdDialogButtonSizer(flags);
+ GetSizer()->Add(m_buttonsSizer, 0, wxGROW|wxALL, 5);
+
+ Layout();
+ GetSizer()->SetSizeHints(this);
+}
+
+void StdButtonSizerDialog::EnableDisableControls()
+{
+ const bool affButtonEnabled = m_chkboxAffirmativeButton->IsChecked();
+
+ m_radiobtnOk->Enable(affButtonEnabled);
+ m_radiobtnYes->Enable(affButtonEnabled);
+
+ const bool dismissButtonEnabled = m_chkboxDismissButton->IsChecked();
+
+ m_radiobtnCancel->Enable(dismissButtonEnabled);
+ m_radiobtnClose->Enable(dismissButtonEnabled);
+}
+
+#if USE_SETTINGS_DIALOG
+// ----------------------------------------------------------------------------
+// SettingsDialog
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog)
+
+BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog)
+END_EVENT_TABLE()
+
+SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
+{
+ SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
+
+ int tabImage1 = -1;
+ int tabImage2 = -1;
+
+ bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
+ int resizeBorder = wxRESIZE_BORDER;
+
+ if (useToolBook)
+ {
+ resizeBorder = 0;
+ tabImage1 = 0;
+ tabImage2 = 1;
+
+ int sheetStyle = wxPROPSHEET_SHRINKTOFIT;
+ if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK)
+ sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK;
+ else
+ sheetStyle |= wxPROPSHEET_TOOLBOOK;
+
+ SetSheetStyle(sheetStyle);
+ SetSheetInnerBorder(0);
+ SetSheetOuterBorder(0);
+
+ // create a dummy image list with a few icons
+ const wxSize imageSize(32, 32);
+
+ m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
+ m_imageList->
+ Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
+ m_imageList->
+ Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
+ m_imageList->
+ Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
+ m_imageList->
+ Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
+ }
+ else
+ m_imageList = NULL;
+
+ Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, resizeBorder)
+ );
+
+ // If using a toolbook, also follow Mac style and don't create buttons
+ if (!useToolBook)
+ CreateButtons(wxOK | wxCANCEL |
+ (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)
+ );
+
+ wxBookCtrlBase* notebook = GetBookCtrl();
+ notebook->SetImageList(m_imageList);
+
+ wxPanel* generalSettings = CreateGeneralSettingsPage(notebook);
+ wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook);
+
+ notebook->AddPage(generalSettings, _("General"), true, tabImage1);
+ notebook->AddPage(aestheticSettings, _("Aesthetics"), false, tabImage2);
+
+ LayoutDialog();
+}
+
+SettingsDialog::~SettingsDialog()
+{
+ delete m_imageList;
+}
+
+wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent)
+{
+ wxPanel* panel = new wxPanel(parent, wxID_ANY);
+
+ wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
+ wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
+
+ //// LOAD LAST FILE
+
+ wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL );
+ wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize);
+ itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+ item0->Add(itemSizer3, 0, wxGROW|wxALL, 0);
+
+ //// AUTOSAVE
+
+ wxString autoSaveLabel = _("&Auto-save every");
+ wxString minsLabel = _("mins");
+
+ wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL );
+ wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize);
+
+#if wxUSE_SPINCTRL
+ wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString,
+ wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1);
+#endif
+
+ itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+#if wxUSE_SPINCTRL
+ itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+#endif
+ itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+ item0->Add(itemSizer12, 0, wxGROW|wxALL, 0);
+
+ //// TOOLTIPS
+
+ wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL );
+ wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize);
+ itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+ item0->Add(itemSizer8, 0, wxGROW|wxALL, 0);
+
+ topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
+
+ panel->SetSizer(topSizer);
+ topSizer->Fit(panel);
+
+ return panel;
+}
+
+wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent)
+{
+ wxPanel* panel = new wxPanel(parent, wxID_ANY);
+
+ wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
+ wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
+
+ //// PROJECT OR GLOBAL
+ wxString globalOrProjectChoices[2];
+ globalOrProjectChoices[0] = _("&New projects");
+ globalOrProjectChoices[1] = _("&This project");
+
+ wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"),
+ wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices);
+ item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5);
+
+ projectOrGlobal->SetSelection(0);
+
+ //// BACKGROUND STYLE
+ wxArrayString backgroundStyleChoices;
+ backgroundStyleChoices.Add(wxT("Colour"));
+ backgroundStyleChoices.Add(wxT("Image"));
+ wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:"));
+
+ wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL );
+ item0->Add(styleSizer, 0, wxGROW|wxALL, 5);
+
+ wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL );
+
+ wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices);
+
+ itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+ itemSizer2->Add(5, 5, 1, wxALL, 0);
+ itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+
+ styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5);
+
+#if wxUSE_SPINCTRL
+ //// FONT SIZE SELECTION
+
+ wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:"));
+ wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL );
+
+ wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition,
+ wxSize(80, wxDefaultCoord));
+ itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+ item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5);
+#endif
+
+ topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
+ topSizer->AddSpacer(5);
+
+ panel->SetSizer(topSizer);
+ topSizer->Fit(panel);
+
+ return panel;
+}
+
+#endif // USE_SETTINGS_DIALOG