summaryrefslogtreecommitdiff
path: root/include/vcl/roadmapwizard.hxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-09-14 18:40:21 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-09-15 16:25:57 +0200
commit04f326cee7678be86db3bb826f6f83918d7a239a (patch)
tree1f5093dab1883203594800325b01c694792395f3 /include/vcl/roadmapwizard.hxx
parentbcaeebd98a697d6bcf891990c3b13de5da1790e7 (diff)
merge RoadmapWizard and OWizardMachine
Change-Id: Ib8c68cb5e96f8bfa9b2398946b87f3b451b3a37e Reviewed-on: https://gerrit.libreoffice.org/78912 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/vcl/roadmapwizard.hxx')
-rw-r--r--include/vcl/roadmapwizard.hxx319
1 files changed, 288 insertions, 31 deletions
diff --git a/include/vcl/roadmapwizard.hxx b/include/vcl/roadmapwizard.hxx
index 9670c84dd13d..bae94ee05c1a 100644
--- a/include/vcl/roadmapwizard.hxx
+++ b/include/vcl/roadmapwizard.hxx
@@ -58,18 +58,118 @@ namespace vcl
<code>n2</code>, which share at least the first <code>k</code> states (where <code>k</code>
is at least 1), and an arbitrary number of other states.
*/
- class VCL_DLLPUBLIC RoadmapWizard : public vcl::OWizardMachine
+ class VCL_DLLPUBLIC RoadmapWizard : public ModalDialog
{
private:
- std::unique_ptr<RoadmapWizardImpl> m_pImpl;
+ Idle maWizardLayoutIdle;
+ Size maPageSize;
+ ImplWizPageData* mpFirstPage;
+ ImplWizButtonData* mpFirstBtn;
+ VclPtr<TabPage> mpCurTabPage;
+ VclPtr<PushButton> mpPrevBtn;
+ VclPtr<PushButton> mpNextBtn;
+ VclPtr<vcl::Window> mpViewWindow;
+ sal_uInt16 mnCurLevel;
+ WindowAlign meViewAlign;
+ Link<RoadmapWizard*,void> maActivateHdl;
+ sal_Int16 mnLeftAlignCount;
+ bool mbEmptyViewMargin;
+
+ DECL_DLLPRIVATE_LINK( ImplHandleWizardLayoutTimerHdl, Timer*, void );
+
+ // IMPORTANT:
+ // traveling pages should not be done by calling these base class member, some mechanisms of this class
+ // here (e.g. committing page data) depend on having full control over page traveling.
+ // So use the travelXXX methods if you need to travel
+
+ protected:
+ long LogicalCoordinateToPixel(int iCoordinate);
+ /**sets the number of buttons which should be left-aligned. Normally, buttons are right-aligned.
+
+ only to be used during construction, before any layouting happened
+ */
+ void SetLeftAlignedButtonCount( sal_Int16 _nCount );
+ /** declares the view area to have an empty margin
+
+ Normally, the view area has a certain margin to the top/left/bottom/right of the
+ dialog. By calling this method, you can reduce this margin to 0.
+ */
+ void SetEmptyViewMargin();
+
+ void CalcAndSetSize();
public:
- RoadmapWizard(
- vcl::Window* _pParent
- );
+ VclPtr<OKButton> m_pFinish;
+ VclPtr<CancelButton> m_pCancel;
+ VclPtr<PushButton> m_pNextPage;
+ VclPtr<PushButton> m_pPrevPage;
+ VclPtr<HelpButton> m_pHelp;
+
+ private:
+ std::unique_ptr<WizardMachineImplData> m_xWizardImpl;
+ // hold members in this structure to allow keeping compatible when members are added
+ std::unique_ptr<RoadmapWizardImpl> m_xRoadmapImpl;
+
+ public:
+ RoadmapWizard(vcl::Window* pParent);
virtual ~RoadmapWizard( ) override;
virtual void dispose() override;
+ virtual void Resize() override;
+ virtual void StateChanged( StateChangedType nStateChange ) override;
+ virtual bool EventNotify( NotifyEvent& rNEvt ) override;
+
+ virtual void ActivatePage();
+ virtual bool DeactivatePage();
+
+ virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
+
+ bool ShowPrevPage();
+ bool ShowNextPage();
+ bool ShowPage( sal_uInt16 nLevel );
+ bool Finish( long nResult = 0 );
+ sal_uInt16 GetCurLevel() const { return mnCurLevel; }
+
+ void AddPage( TabPage* pPage );
+ void RemovePage( TabPage* pPage );
+ void SetPage( sal_uInt16 nLevel, TabPage* pPage );
+ TabPage* GetPage( sal_uInt16 nLevel ) const;
+
+ void AddButton( Button* pButton, long nOffset = 0 );
+ void RemoveButton( Button* pButton );
+
+ void SetPrevButton( PushButton* pButton ) { mpPrevBtn = pButton; }
+ void SetNextButton( PushButton* pButton ) { mpNextBtn = pButton; }
+
+ void SetViewWindow( vcl::Window* pWindow ) { mpViewWindow = pWindow; }
+ void SetViewAlign( WindowAlign eAlign ) { meViewAlign = eAlign; }
+
+ void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
+ const Size& GetPageSizePixel() const { return maPageSize; }
+
+ void SetActivatePageHdl( const Link<RoadmapWizard*,void>& rLink ) { maActivateHdl = rLink; }
+
+ /// enable (or disable) buttons
+ void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable);
+ /// set the default style for a button
+ void defaultButton(WizardButtonFlags _nWizardButtonFlags);
+ /// set the default style for a button
+ void defaultButton(PushButton* _pNewDefButton);
+
+ /// set the base of the title to use - the title of the current page is appended
+ void setTitleBase(const OUString& _rTitleBase);
+
+ /// determines whether there is a next state to which we can advance
+ virtual bool canAdvance() const;
+
+ /** updates the user interface which deals with traveling in the wizard
+
+ The default implementation simply checks whether both the current page and the wizard
+ itself allow to advance to the next state (<code>canAdvance</code>), and enables the "Next"
+ button if and only if this is the case.
+ */
+ virtual void updateTravelUI();
+
void SetRoadmapHelpId( const OString& _rId );
void SetRoadmapInteractive( bool _bInteractive );
@@ -84,11 +184,136 @@ namespace vcl
// returns whether a given state is enabled
bool isStateEnabled( WizardTypes::WizardState _nState ) const;
- // WizardDialog overridables
- virtual bool canAdvance() const override;
- virtual void updateTravelUI() override;
-
protected:
+
+ /// to override to create new pages
+ virtual VclPtr<TabPage> createPage(WizardTypes::WizardState nState);
+
+ /// will be called when a new page is about to be displayed
+ virtual void enterState(WizardTypes::WizardState _nState);
+
+ /** will be called when the current state is about to be left for the given reason
+
+ The base implementation in this class will simply call <member>OWizardPage::commitPage</member>
+ for the current page, and return whatever this call returns.
+
+ @param _eReason
+ The reason why the state is to be left.
+ @return
+ <TRUE/> if and only if the page is allowed to be left
+ */
+ virtual bool prepareLeaveCurrentState( WizardTypes::CommitPageReason eReason );
+
+ /** will be called when the given state is left
+
+ This is the very last possibility for derived classes to veto the deactivation
+ of a page.
+
+ @todo Normally, we would not need the return value here - derived classes now have
+ the possibility to veto page deactivations in <member>prepareLeaveCurrentState</member>. However,
+ changing this return type is too incompatible at the moment ...
+
+ @return
+ <TRUE/> if and only if the page is allowed to be left
+ */
+ virtual bool leaveState(WizardTypes::WizardState _nState);
+
+ /** determine the next state to travel from the given one
+
+ This method ensures that traveling happens along the active path.
+
+ Return WZS_INVALID_STATE to prevent traveling.
+
+ @see activatePath
+ */
+ virtual WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const;
+
+ /** called when the finish button is pressed
+ <p>By default, only the base class' Finish method (which is not virtual) is called</p>
+ */
+ virtual bool onFinish();
+
+ /// travel to the next state
+ bool travelNext();
+
+ /// travel to the previous state
+ bool travelPrevious();
+
+ /** enables the automatic enabled/disabled state of the "Next" button
+
+ If this is <TRUE/>, then upon entering a new state, the "Next" button will automatically be
+ enabled if and only if determineNextState does not return WZS_INVALID_STATE.
+ */
+ void enableAutomaticNextButtonState();
+ bool isAutomaticNextButtonStateEnabled() const;
+
+ /** removes a page from the history. Should be called when the page is being disabled
+ */
+ void removePageFromHistory(WizardTypes::WizardState nToRemove);
+
+ /** skip a state
+
+ The method behaves as if from the current state, <arg>_nSteps</arg> <method>travelNext</method>s were
+ called, but without actually creating or displaying the \EDntermediate pages. Only the
+ (<arg>_nSteps</arg> + 1)th page is created.
+
+ The skipped states appear in the state history, so <method>travelPrevious</method> will make use of them.
+
+ A very essential precondition for using this method is that your <method>determineNextState</method>
+ method is able to determine the next state without actually having the page of the current state.
+
+ @see skipUntil
+ @see skipBackwardUntil
+ */
+ void skip();
+
+ /** skips one or more states, until a given state is reached
+
+ The method behaves as if from the current state, <method>travelNext</method>s were called
+ successively, until <arg>_nTargetState</arg> is reached, but without actually creating or
+ displaying the \EDntermediate pages.
+
+ The skipped states appear in the state history, so <method>travelPrevious</method> will make use of them.
+
+ @return
+ <TRUE/> if and only if traveling was successful
+
+ @see skip
+ @see skipBackwardUntil
+ */
+ bool skipUntil(WizardTypes::WizardState nTargetState);
+
+ /** moves back one or more states, until a given state is reached
+
+ This method allows traveling backwards more than one state without actually showing the intermediate
+ states.
+
+ For instance, if you want to travel two steps backward at a time, you could used
+ two travelPrevious calls, but this would <em>show</em> both pages, which is not necessary,
+ since you're interested in the target page only. Using <member>skipBackwardUntil</member> relieves
+ you of this.
+
+ @return
+ <TRUE/> if and only if traveling was successful
+
+ @see skipUntil
+ @see skip
+ */
+ bool skipBackwardUntil(WizardTypes::WizardState nTargetState);
+
+ /** returns the current state of the machine
+
+ Vulgo, this is the identifier of the current tab page :)
+ */
+ WizardTypes::WizardState getCurrentState() const { return GetCurLevel(); }
+
+ virtual IWizardPageController*
+ getPageController( TabPage* _pCurrentPage ) const;
+
+ /** retrieves a copy of the state history, i.e. all states we already visited
+ */
+ void getStateHistory(std::vector<WizardTypes::WizardState>& out_rHistory);
+
/** declares a valid path in the wizard
The very first path which is declared is automatically activated.
@@ -141,15 +366,6 @@ namespace vcl
*/
void activatePath( RoadmapWizardTypes::PathId _nPathId, bool _bDecideForIt = false );
- /** determine the next state to travel from the given one
-
- This method (which is declared in OWizardMachine and overwritten here)
- ensures that traveling happens along the active path.
-
- @see activatePath
- */
- virtual WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const override;
-
/** en- or disables a state
In the wizard's roadmap, states to travel to can be freely chosen. To prevent
@@ -176,9 +392,6 @@ namespace vcl
*/
bool knowsState(WizardTypes::WizardState nState) const;
- // OWizardMachine overriables
- virtual void enterState(WizardTypes::WizardState nState) override;
-
/** returns a human readable name for a given state
There is a default implementation for this method, which returns the display name
@@ -188,13 +401,6 @@ namespace vcl
*/
virtual OUString getStateDisplayName(WizardTypes::WizardState nState) const;
- /** creates a page for a given state
-
- This member is inherited from OWizardMachine, and default-implemented in this class
- for all states which have been described using describeState.
- */
- virtual VclPtr<TabPage> createPage(WizardTypes::WizardState nState) override;
-
private:
DECL_DLLPRIVATE_LINK( OnRoadmapItemSelected, LinkParamNone*, void );
@@ -203,8 +409,39 @@ namespace vcl
*/
VCL_DLLPRIVATE void implUpdateRoadmap( );
- private:
VCL_DLLPRIVATE void impl_construct();
+
+ public:
+ class AccessGuard
+ {
+ friend class RoadmapWizardTravelSuspension;
+ private:
+ AccessGuard() { }
+ };
+
+ void suspendTraveling( AccessGuard );
+ void resumeTraveling( AccessGuard );
+ bool isTravelingSuspended() const;
+
+ protected:
+ TabPage* GetOrCreatePage(const WizardTypes::WizardState i_nState);
+
+ private:
+ VCL_DLLPRIVATE void ImplInitData();
+ VCL_DLLPRIVATE void ImplCalcSize( Size& rSize );
+ VCL_DLLPRIVATE void ImplPosCtrls();
+ VCL_DLLPRIVATE void ImplPosTabPage();
+ VCL_DLLPRIVATE void ImplShowTabPage( TabPage* pPage );
+ VCL_DLLPRIVATE TabPage* ImplGetPage( sal_uInt16 nLevel ) const;
+
+
+ DECL_DLLPRIVATE_LINK(OnNextPage, Button*, void);
+ DECL_DLLPRIVATE_LINK(OnPrevPage, Button*, void);
+ DECL_DLLPRIVATE_LINK(OnFinish, Button*, void);
+
+ VCL_DLLPRIVATE void implResetDefault(vcl::Window const * _pWindow);
+ VCL_DLLPRIVATE void implUpdateTitle();
+ VCL_DLLPRIVATE void implConstruct( const WizardButtonFlags _nButtonFlags );
};
class VCL_DLLPUBLIC RoadmapWizardMachine : public vcl::WizardMachine
@@ -280,7 +517,7 @@ namespace vcl
/** determine the next state to travel from the given one
- This method (which is declared in OWizardMachine and overwritten here)
+ This method (which is declared in WizardMachine and overwritten here)
ensures that traveling happens along the active path.
@see activatePath
@@ -309,7 +546,7 @@ namespace vcl
*/
void enableState(WizardTypes::WizardState nState, bool _bEnable = true);
- // OWizardMachine overriables
+ // WizardMachine overriables
virtual void enterState(WizardTypes::WizardState nState) override;
/** returns a human readable name for a given state
@@ -330,6 +567,26 @@ namespace vcl
VCL_DLLPRIVATE void implUpdateRoadmap( );
};
+ /// helper class to temporarily suspend any traveling in the wizard
+ class RoadmapWizardTravelSuspension
+ {
+ public:
+ RoadmapWizardTravelSuspension(RoadmapWizard& rWizard)
+ : m_pOWizard(&rWizard)
+ {
+ m_pOWizard->suspendTraveling(RoadmapWizard::AccessGuard());
+ }
+
+ ~RoadmapWizardTravelSuspension()
+ {
+ if (m_pOWizard)
+ m_pOWizard->resumeTraveling(RoadmapWizard::AccessGuard());
+ }
+
+ private:
+ VclPtr<RoadmapWizard> m_pOWizard;
+ };
+
} // namespace vcl