]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
cleanup - reformatting
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index d3cdcf1e15bee453103d586ec7c98ec19be1b3bb..cd8f98926249ec851d8b611890a39bb9b23e4ccd 100644 (file)
@@ -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 <wx/datetime.h>      // 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);