From c73b439f80d84ce1a58d862835b3b8cc3fb96f5d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 26 May 2002 22:41:35 +0000 Subject: [PATCH] added wxWizard::Fit() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15679 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/wizard.tex | 23 ++++++++++++++++++----- include/wx/generic/wizard.h | 1 + include/wx/wizard.h | 9 +++++++++ src/generic/wizard.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/docs/latex/wx/wizard.tex b/docs/latex/wx/wizard.tex index f3b09b3b31..6d0866a49b 100644 --- a/docs/latex/wx/wizard.tex +++ b/docs/latex/wx/wizard.tex @@ -137,13 +137,18 @@ also \helpref{GetBitmap}{wxwizardpagegetbitmap}.} \docparam{pos}{The position of the dialog, it will be centered on the screen by default.} -\membersection{wxWizard::RunWizard}\label{wxwizardrunwizard} +\membersection{wxWizard::Fit}\label{wxwizardfit} -\func{bool}{RunWizard}{\param{wxWizardPage* }{firstPage}} +\func{void}{Fit}{\param{const wxWizardPage* }{firstPage}} -Executes the wizard starting from the given page, returns {\tt TRUE} if it was -successfully finished or {\tt FALSE} if user cancelled it. The {\it firstPage} -can not be {\tt NULL}. +Sets the page size to be big enough for all the pages accessible via the +given {\it firstPage}, i.e. this page, its next page and so on. + +This method may be called more than once and it will only change the page size +if the size required by the new page is bigger than the previously set one. +This is useful if the decision about which pages to show is taken during the +run-time as in this case, the wizard won't be able to get to all pages starting +from a single one and you should call {\it Fit} separately for the others. \membersection{wxWizard::GetCurrentPage}\label{wxwizardgetcurrentpage} @@ -158,6 +163,14 @@ Get the current page while the wizard is running. {\tt NULL} is returned if Returns the size available for the pages. +\membersection{wxWizard::RunWizard}\label{wxwizardrunwizard} + +\func{bool}{RunWizard}{\param{wxWizardPage* }{firstPage}} + +Executes the wizard starting from the given page, returns {\tt TRUE} if it was +successfully finished or {\tt FALSE} if user cancelled it. The {\it firstPage} +can not be {\tt NULL}. + \membersection{wxWizard::SetPageSize}\label{wxwizardsetpagesize} \func{void}{SetPageSize}{\param{const wxSize\& }{sizePage}} diff --git a/include/wx/generic/wizard.h b/include/wx/generic/wizard.h index f16fe894f2..b6dd5fc467 100644 --- a/include/wx/generic/wizard.h +++ b/include/wx/generic/wizard.h @@ -47,6 +47,7 @@ public: virtual wxWizardPage *GetCurrentPage() const; virtual void SetPageSize(const wxSize& size); virtual wxSize GetPageSize() const; + virtual void Fit(const wxWizardPage *firstPage); // implementation only from now on // ------------------------------- diff --git a/include/wx/wizard.h b/include/wx/wizard.h index 3fa787cc25..fd47de64a8 100644 --- a/include/wx/wizard.h +++ b/include/wx/wizard.h @@ -177,6 +177,15 @@ public: // get the size available for the page: the wizards are not resizeable, so // this size doesn't change virtual wxSize GetPageSize() const = 0; + + // set the best size for the wizard, i.e. make it big enough to contain all + // of the pages starting from the given one + // + // this function may be called several times and possible with different + // pages in which case it will only increase the page size if needed (this + // may be useful if not all pages are accessible from the first one by + // default) + virtual void Fit(const wxWizardPage *firstPage) = 0; }; // include the real class declaration diff --git a/src/generic/wizard.cpp b/src/generic/wizard.cpp index 325ff9974c..1e2e0f9fbf 100644 --- a/src/generic/wizard.cpp +++ b/src/generic/wizard.cpp @@ -280,6 +280,32 @@ void wxWizard::SetPageSize(const wxSize& size) m_sizePage = size; } +void wxWizard::Fit(const wxWizardPage *page) +{ + // otherwise it will have no effect now as it's too late... + wxASSERT_MSG( !WasCreated(), _T("should be called before RunWizard()!") ); + + wxSize sizeMax; + while ( page ) + { + wxSize size = page->GetBestSize(); + + if ( size.x > sizeMax.x ) + sizeMax.x = size.x; + + if ( size.y > sizeMax.y ) + sizeMax.y = size.y; + + page = page->GetNext(); + } + + if ( sizeMax.x > m_sizePage.x ) + m_sizePage.x = sizeMax.x; + + if ( sizeMax.y > m_sizePage.y ) + m_sizePage.y = sizeMax.y; +} + bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward) { wxASSERT_MSG( page != m_page, wxT("this is useless") ); -- 2.45.2