X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/897b24cf5ca5ca41734c79f7092104921e0c8cae..93a2619d107796afbad422363698bae4d7f06b77:/samples/dialogs/dialogs.cpp diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index d3cdcf1e15..cd8f989262 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -25,6 +25,8 @@ #include "wx/datetime.h" #include "wx/image.h" #include "wx/bookctrl.h" +#include "wx/artprov.h" +#include "wx/imaglist.h" #if wxUSE_COLOURDLG #include "wx/colordlg.h" @@ -40,7 +42,7 @@ #if wxUSE_PROGRESSDLG #if wxUSE_STOPWATCH && wxUSE_LONGLONG - #include // wxDateTime + #include "wx/datetime.h" // wxDateTime #endif #include "wx/progdlg.h" @@ -191,6 +193,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) #if USE_SETTINGS_DIALOG EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet) + EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheetToolBook) #endif EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention) @@ -358,6 +361,7 @@ bool MyApp::OnInit() #if USE_SETTINGS_DIALOG file_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Property Sheet Dialog\tCtrl-P")); + file_menu->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK, _T("Property Sheet Dialog using &ToolBook")); #endif file_menu->Append(DIALOGS_REQUEST, _T("&Request user attention\tCtrl-R")); @@ -973,6 +977,12 @@ void MyFrame::OnPropertySheet(wxCommandEvent& WXUNUSED(event)) SettingsDialog dialog(this); dialog.ShowModal(); } + +void MyFrame::OnPropertySheetToolBook(wxCommandEvent& WXUNUSED(event)) +{ + SettingsDialog dialog(this, true); + dialog.ShowModal(); +} #endif // USE_SETTINGS_DIALOG void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event)) @@ -1371,33 +1381,67 @@ IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog) BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog) END_EVENT_TABLE() -SettingsDialog::SettingsDialog(wxWindow* win) +SettingsDialog::SettingsDialog(wxWindow* win, bool useToolBook) { SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); + int tabImage1 = -1; + int tabImage2 = -1; + + if (useToolBook) + { + tabImage1 = 0; + tabImage2 = 1; + SetSheetStyle(wxPROPSHEET_TOOLBOOK|wxPROPSHEET_SHRINKTOFIT); + + // 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 #ifndef __WXWINCE__ |wxRESIZE_BORDER #endif ); - CreateButtons(wxOK|wxCANCEL + + // If using a toolbook, also follow Mac style and don't create buttons + if (!useToolBook) + CreateButtons(wxOK|wxCANCEL #ifndef __POCKETPC__ - |wxHELP + |wxHELP #endif ); wxBookCtrlBase* notebook = GetBookCtrl(); + notebook->SetImageList(m_imageList); wxPanel* generalSettings = CreateGeneralSettingsPage(notebook); wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook); - notebook->AddPage(generalSettings, _("General")); - notebook->AddPage(aestheticSettings, _("Aesthetics")); + 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);