Added the ability to restore the last selected page in a wxRTC formatting dialog.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75791 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2014-02-04 18:57:20 +00:00
parent 892a8b47c4
commit 179d117a35
2 changed files with 23 additions and 0 deletions

View File

@@ -241,6 +241,14 @@ public:
/// Find a page by class /// Find a page by class
wxWindow* FindPage(wxClassInfo* info) const; 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: protected:
wxRichTextAttr m_attributes; wxRichTextAttr m_attributes;
@@ -253,6 +261,9 @@ protected:
static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory; static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory;
static bool sm_showToolTips; static bool sm_showToolTips;
static bool sm_restoreLastPage;
static int sm_lastPage;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -79,6 +79,8 @@
#endif #endif
bool wxRichTextFormattingDialog::sm_showToolTips = false; bool wxRichTextFormattingDialog::sm_showToolTips = false;
bool wxRichTextFormattingDialog::sm_restoreLastPage = true;
int wxRichTextFormattingDialog::sm_lastPage = -1;
IMPLEMENT_CLASS(wxRichTextDialogPage, wxPanel) IMPLEMENT_CLASS(wxRichTextDialogPage, wxPanel)
@@ -104,6 +106,10 @@ void wxRichTextFormattingDialog::Init()
wxRichTextFormattingDialog::~wxRichTextFormattingDialog() wxRichTextFormattingDialog::~wxRichTextFormattingDialog()
{ {
int sel = GetBookCtrl()->GetSelection();
if (sel != -1 && sel < (int) m_pageIds.GetCount())
sm_lastPage = m_pageIds[sel];
delete m_styleDefinition; delete m_styleDefinition;
} }
@@ -128,6 +134,12 @@ bool wxRichTextFormattingDialog::Create(long flags, wxWindow* parent, const wxSt
LayoutDialog(); LayoutDialog();
if (sm_restoreLastPage && sm_lastPage != -1)
{
int idx = m_pageIds.Index(sm_lastPage);
if (idx != -1)
GetBookCtrl()->SetSelection(idx);
}
return true; return true;
} }