with BEGIN_EVENT_TABLE_TEMPLATEn() macros
- Added double-buffering to wxVListBox and fixed a scrolling issue.
- Added wxToolbook (uses a wxToolBar to control pages).
+- Added SetSheetStyle to wxPropertySheetDialog and allowed it to
+ behave like a Mac OS X settings dialog.
wxMSW:
\section{\class{wxPropertySheetDialog}}\label{wxpropertysheetdialog}
This class represents a property sheet dialog: a tabbed dialog
-for showing settings. It is optimized to show with flat tabs
-on PocketPC devices.
+for showing settings. It is optimized to show flat tabs
+on PocketPC devices, and can be customized to use different
+controllers instead of the default notebook style.
To use this class, call \helpref{wxPropertySheetDialog::Create}{wxpropertysheetdialogcreate} from your own
Create function. Then call \helpref{CreateButtons}{wxpropertysheetdialogcreatebuttons}, and create pages, adding them to the book control.
If necessary, override CreateBookCtrl and AddBookCtrl to create and add a different
kind of book control. You would then need to use two-step construction for the dialog.
+Or, change the style of book control by calling \helpref{SetSheetStyle}{wxpropertysheetdialogsetsheetstyle}
+before calling Create.
+
+The dialogs sample shows this class being used with notebook and toolbook controllers (for
+Windows-style and Mac-style settings dialogs).
\wxheading{Derived from}
\func{virtual wxBookCtrlBase*}{CreateBookCtrl}{\void}
-Override this if you wish to create a different kind of book control; by default, a wxNotebook
-is created.
+Override this if you wish to create a different kind of book control; by default, the value
+passed to \helpref{SetSheetStyle}{wxpropertysheetdialogsetsheetstyle} is used to determine the control.
+The default behaviour is to create a notebook except on Smartphone, where a choicebook is used.
\membersection{wxPropertySheetDialog::CreateButtons}\label{wxpropertysheetdialogcreatebuttons}
Returns the inner sizer that contains the book control and button sizer.
+\membersection{wxPropertySheetDialog::GetSheetStyle}\label{wxpropertysheetdialoggetsheetstyle}
+
+\constfunc{long}{GetSheetStyle}{\void}
+
+Returns the sheet style. See \helpref{SetSheetStyle}{wxpropertysheetdialogsetsheetstyle} for
+permissable values.
+
\membersection{wxPropertySheetDialog::LayoutDialog}\label{wxpropertysheetdialoglayoutdialog}
-\func{void}{LayoutDialog}{\void}
+\func{void}{LayoutDialog}{\param{int}{ centreFlags=wxBOTH}}
Call this to lay out the dialog. On PocketPC, this does nothing, since the dialog will be shown
full-screen, and the layout will be done when the dialog receives a size event.
Sets the inner sizer that contains the book control and button sizer. You will normally not need to use this.
+\membersection{wxPropertySheetDialog::SetSheetStyle}\label{wxpropertysheetdialogsetsheetstyle}
+
+\func{void}{SetSheetStyle}{\param{long}{ style}}
+
+You can customize the look and feel of the dialog by setting the sheet style. It is
+a bit list of the following values:
+
+\twocolwidtha{5cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{wxPROPSHEET\_DEFAULT}{Uses the default look and feel for the controller window,
+normally a notebook except on Smartphone where a choice control is used.}
+\twocolitem{wxPROPSHEET\_NOTEBOOK}{Uses a notebook for the controller window.}
+\twocolitem{wxPROPSHEET\_TOOLBOOK}{Uses a toolbook for the controller window.}
+\twocolitem{wxPROPSHEET\_CHOICEBOOK}{Uses a choicebook for the controller window.}
+\twocolitem{wxPROPSHEET\_LISTBOOK}{Uses a listbook for the controller window.}
+\twocolitem{wxPROPSHEET\_SHRINKTOFIT}{Shrinks the dialog window to fit the currently selected page (common behaviour for
+property sheets on Mac OS X).}
+\end{twocollist}
+
// kind of book control.
//-----------------------------------------------------------------------------
+// Use the platform default
+#define wxPROPSHEET_DEFAULT 0x0001
+
+// Use a notebook
+#define wxPROPSHEET_NOTEBOOK 0x0002
+
+// Use a toolbook
+#define wxPROPSHEET_TOOLBOOK 0x0004
+
+// Use a choicebook
+#define wxPROPSHEET_CHOICEBOOK 0x0008
+
+// Use a listbook
+#define wxPROPSHEET_LISTBOOK 0x0010
+
+// Shrink dialog to fit current page
+#define wxPROPSHEET_SHRINKTOFIT 0x0100
+
class WXDLLIMPEXP_ADV wxPropertySheetDialog : public wxDialog
{
public:
void SetInnerSize(wxSizer* sizer) { m_innerSizer = sizer; }
wxSizer* GetInnerSizer() const { return m_innerSizer ; }
+ // Set and get the book style
+ void SetSheetStyle(long sheetStyle) { m_sheetStyle = sheetStyle; }
+ long GetSheetStyle() const { return m_sheetStyle ; }
+
/// Operations
// Creates the buttons (none on PocketPC)
virtual void CreateButtons(int flags = wxOK|wxCANCEL);
// Lay out the dialog, to be called after pages have been created
- virtual void LayoutDialog();
+ virtual void LayoutDialog(int centreFlags = wxBOTH);
/// Implementation
// Set the focus
void OnActivate(wxActivateEvent& event);
+ // Resize dialog if necessary
+ void OnIdle(wxIdleEvent& event);
+
private:
void Init();
protected:
wxBookCtrlBase* m_bookCtrl;
wxSizer* m_innerSizer; // sizer for extra space
+ long m_sheetStyle;
+ int m_selectedPage;
DECLARE_DYNAMIC_CLASS(wxPropertySheetDialog)
DECLARE_EVENT_TABLE()
#include "wx/datetime.h"
#include "wx/image.h"
#include "wx/bookctrl.h"
+#include "wx/artprov.h"
#if wxUSE_COLOURDLG
#include "wx/colordlg.h"
#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)
#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"));
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))
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);
{
DECLARE_CLASS(SettingsDialog)
public:
- SettingsDialog(wxWindow* parent);
+ SettingsDialog(wxWindow* parent, bool useToolBook = false);
+ ~SettingsDialog();
wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
ID_FONT_SIZE
};
+ wxImageList* m_imageList;
+
DECLARE_EVENT_TABLE()
};
#endif // USE_FONTDLG_GENERIC
void OnPropertySheet(wxCommandEvent& event);
+ void OnPropertySheetToolBook(wxCommandEvent& event);
void OnRequestUserAttention(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
DIALOGS_FIND,
DIALOGS_REPLACE,
DIALOGS_REQUEST,
- DIALOGS_PROPERTY_SHEET
+ DIALOGS_PROPERTY_SHEET,
+ DIALOGS_PROPERTY_SHEET_TOOLBOOK
};
#endif
#endif
#include "wx/bookctrl.h"
+
+#if wxUSE_NOTEBOOK
+#include "wx/notebook.h"
+#endif
+#if wxUSE_CHOICEBOOK
+#include "wx/choicebk.h"
+#endif
+#if wxUSE_TOOLBOOK
+#include "wx/toolbook.h"
+#endif
+#if wxUSE_LISTBOOK
+#include "wx/listbook.h"
+#endif
+
#include "wx/generic/propdlg.h"
#include "wx/sysopt.h"
BEGIN_EVENT_TABLE(wxPropertySheetDialog, wxDialog)
EVT_ACTIVATE(wxPropertySheetDialog::OnActivate)
+ EVT_IDLE(wxPropertySheetDialog::OnIdle)
END_EVENT_TABLE()
bool wxPropertySheetDialog::Create(wxWindow* parent, wxWindowID id, const wxString& title,
void wxPropertySheetDialog::Init()
{
+ m_sheetStyle = wxPROPSHEET_DEFAULT;
m_innerSizer = NULL;
m_bookCtrl = NULL;
}
// Layout the dialog, to be called after pages have been created
-void wxPropertySheetDialog::LayoutDialog()
+void wxPropertySheetDialog::LayoutDialog(int centreFlags)
{
#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
- Centre(wxBOTH);
+ if (centreFlags)
+ Centre(centreFlags);
#endif
#if defined(__SMARTPHONE__)
if (m_bookCtrl)
#else
style |= wxBK_DEFAULT;
#endif
- return new wxBookCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+
+ wxBookCtrlBase* bookCtrl = NULL;
+
+#if wxUSE_NOTEBOOK
+ if (GetSheetStyle() & wxPROPSHEET_NOTEBOOK)
+ bookCtrl = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+#endif
+#if wxUSE_CHOICEBOOK
+ if (GetSheetStyle() & wxPROPSHEET_CHOICEBOOK)
+ bookCtrl = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+#endif
+#if wxUSE_TOOLBOOK
+ if (GetSheetStyle() & wxPROPSHEET_TOOLBOOK)
+ bookCtrl = new wxToolbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+#endif
+#if wxUSE_LISTBOOK
+ if (GetSheetStyle() & wxPROPSHEET_LISTBOOK)
+ bookCtrl = new wxListbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+#endif
+ if (!bookCtrl)
+ bookCtrl = new wxBookCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+
+ if (GetSheetStyle() & wxPROPSHEET_SHRINKTOFIT)
+ bookCtrl->SetShrinkMode(true);
+
+ return bookCtrl;
}
// Adds the book control to the inner sizer.
event.Skip();
}
+// Resize dialog if necessary
+void wxPropertySheetDialog::OnIdle(wxIdleEvent& event)
+{
+ event.Skip();
+
+ if ((GetSheetStyle() & wxPROPSHEET_SHRINKTOFIT) && GetBookCtrl())
+ {
+ int sel = GetBookCtrl()->GetSelection();
+ if (sel != -1 && sel != m_selectedPage)
+ {
+ GetBookCtrl()->InvalidateBestSize();
+ InvalidateBestSize();
+ SetSizeHints(-1, -1, -1, -1);
+
+ m_selectedPage = sel;
+ LayoutDialog(0);
+ }
+ }
+}
+
#endif // wxUSE_BOOKCTRL
+