diff --git a/include/wx/richtext/richtextformatdlg.h b/include/wx/richtext/richtextformatdlg.h index 18a91bbceb..5f65912c85 100644 --- a/include/wx/richtext/richtextformatdlg.h +++ b/include/wx/richtext/richtextformatdlg.h @@ -241,6 +241,14 @@ public: /// Find a page by class wxWindow* FindPage(wxClassInfo* info) const; + /// Whether to restore the last-selected page + static bool GetRestoreLastPage() { return sm_restoreLastPage; } + static void SetRestoreLastPage(bool b) { sm_restoreLastPage = b; } + + /// The page identifier of the last page selected (not the control id) + static int GetLastPage() { return sm_lastPage; } + static void SetLastPage(int lastPage) { sm_lastPage = lastPage; } + protected: wxRichTextAttr m_attributes; @@ -253,6 +261,9 @@ protected: static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory; static bool sm_showToolTips; + static bool sm_restoreLastPage; + static int sm_lastPage; + DECLARE_EVENT_TABLE() }; diff --git a/src/richtext/richtextformatdlg.cpp b/src/richtext/richtextformatdlg.cpp index f6b4a80c2e..a2bec8cc81 100644 --- a/src/richtext/richtextformatdlg.cpp +++ b/src/richtext/richtextformatdlg.cpp @@ -79,6 +79,8 @@ #endif bool wxRichTextFormattingDialog::sm_showToolTips = false; +bool wxRichTextFormattingDialog::sm_restoreLastPage = true; +int wxRichTextFormattingDialog::sm_lastPage = -1; IMPLEMENT_CLASS(wxRichTextDialogPage, wxPanel) @@ -104,6 +106,10 @@ void wxRichTextFormattingDialog::Init() wxRichTextFormattingDialog::~wxRichTextFormattingDialog() { + int sel = GetBookCtrl()->GetSelection(); + if (sel != -1 && sel < (int) m_pageIds.GetCount()) + sm_lastPage = m_pageIds[sel]; + delete m_styleDefinition; } @@ -128,6 +134,12 @@ bool wxRichTextFormattingDialog::Create(long flags, wxWindow* parent, const wxSt LayoutDialog(); + if (sm_restoreLastPage && sm_lastPage != -1) + { + int idx = m_pageIds.Index(sm_lastPage); + if (idx != -1) + GetBookCtrl()->SetSelection(idx); + } return true; }