LibreOffice Module vcl (master)  1
wizdlg.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_VCL_WIZDLG_HXX
21 #define INCLUDED_VCL_WIZDLG_HXX
22 
23 #include <memory>
24 #include <vcl/toolkit/button.hxx>
25 #include <vcl/toolkit/dialog.hxx>
26 #include <vcl/roadmapwizard.hxx>
27 #include <vcl/tabpage.hxx>
28 
30 {
33 };
34 
35 namespace vcl
36 {
37  struct RoadmapWizardImpl;
38  class RoadmapWizard;
39 
40  namespace RoadmapWizardTypes
41  {
42  typedef VclPtr<TabPage> (* RoadmapPageFactory)( RoadmapWizard& );
43  };
44 
45  //= RoadmapWizard
46 
65  class RoadmapWizard final : public Dialog
66  {
67  private:
76  sal_uInt16 mnCurLevel;
77  sal_Int16 mnLeftAlignCount;
79 
80  DECL_LINK( ImplHandleWizardLayoutTimerHdl, Timer*, void );
81 
82  // IMPORTANT:
83  // traveling pages should not be done by calling these base class member, some mechanisms of this class
84  // here (e.g. committing page data) depend on having full control over page traveling.
85  // So use the travelXXX methods if you need to travel
86 
87  tools::Long LogicalCoordinateToPixel(int iCoordinate);
92  void SetLeftAlignedButtonCount( sal_Int16 _nCount );
93 
94  void CalcAndSetSize();
95 
96  public:
102 
103  private:
104  std::unique_ptr<WizardMachineImplData> m_xWizardImpl;
105  // hold members in this structure to allow keeping compatible when members are added
106  std::unique_ptr<RoadmapWizardImpl> m_xRoadmapImpl;
107 
108  public:
109  RoadmapWizard(vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default);
110  virtual ~RoadmapWizard( ) override;
111  virtual void dispose() override;
112 
113  virtual void Resize() override;
114  virtual void StateChanged( StateChangedType nStateChange ) override;
115  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
116 
117  void ActivatePage();
118 
119  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
120 
121  bool ShowPage( sal_uInt16 nLevel );
122  void Finish( tools::Long nResult = 0 );
123  sal_uInt16 GetCurLevel() const { return mnCurLevel; }
124 
125  void AddPage( TabPage* pPage );
126  void RemovePage( TabPage* pPage );
127  void SetPage( sal_uInt16 nLevel, TabPage* pPage );
128  TabPage* GetPage( sal_uInt16 nLevel ) const;
129 
130  void AddButton( Button* pButton, tools::Long nOffset = 0 );
131  void RemoveButton( Button* pButton );
132 
133  void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
134  const Size& GetPageSizePixel() const { return maPageSize; }
135 
136  void SetRoadmapHelpId( const OString& _rId );
137 
138  void InsertRoadmapItem(int nIndex, const OUString& rLabel, int nId, bool bEnabled);
139  void DeleteRoadmapItems();
140  int GetCurrentRoadmapItemID() const;
141  void SelectRoadmapItemByID(int nId, bool bGrabFocus = true);
142  void SetItemSelectHdl( const Link<LinkParamNone*,void>& _rHdl );
143  void ShowRoadmap(bool bShow);
144 
145  FactoryFunction GetUITestFactory() const override;
146 
147  private:
148 
151 
153  void enterState(WizardTypes::WizardState _nState);
154 
164 
166  void travelNext();
167 
169  void travelPrevious();
170 
174 
189  bool skipUntil(WizardTypes::WizardState nTargetState);
190 
207  bool skipBackwardUntil(WizardTypes::WizardState nTargetState);
208 
214 
222  OUString getStateDisplayName(WizardTypes::WizardState nState) const;
223 
224  DECL_LINK( OnRoadmapItemSelected, LinkParamNone*, void );
225 
229  void implUpdateRoadmap( );
230 
231  public:
233  {
235  private:
237  };
238 
239  void suspendTraveling( AccessGuard );
240  void resumeTraveling( AccessGuard );
241  bool isTravelingSuspended() const;
242 
243  private:
244  void GetOrCreatePage(const WizardTypes::WizardState i_nState);
245 
246  void ImplCalcSize( Size& rSize );
247  void ImplPosCtrls();
248  void ImplPosTabPage();
249  void ImplShowTabPage( TabPage* pPage );
250  TabPage* ImplGetPage( sal_uInt16 nLevel ) const;
251 
252 
253  DECL_LINK(OnNextPage, Button*, void);
254  DECL_LINK(OnPrevPage, Button*, void);
255  DECL_LINK(OnFinish, Button*, void);
256 
257  void implConstruct( const WizardButtonFlags _nButtonFlags );
258  };
259 
262  {
263  public:
265  : m_pOWizard(&rWizard)
266  {
267  m_pOWizard->suspendTraveling(RoadmapWizard::AccessGuard());
268  }
269 
271  {
272  if (m_pOWizard)
273  m_pOWizard->resumeTraveling(RoadmapWizard::AccessGuard());
274  }
275 
276  private:
278  };
279 
280 } // namespace vcl
281 
282 #endif
283 
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
wizard for a roadmap
Definition: wizdlg.hxx:65
void resumeTraveling(AccessGuard)
void ShowRoadmap(bool bShow)
VclPtr< vcl::Window > mpViewWindow
Definition: wizdlg.hxx:75
sal_uInt16 mnCurLevel
Definition: wizdlg.hxx:76
void Finish(tools::Long nResult=0)
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
std::unique_ptr< WizardMachineImplData > m_xWizardImpl
Definition: wizdlg.hxx:104
long Long
void ImplCalcSize(Size &rSize)
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
void SetItemSelectHdl(const Link< LinkParamNone *, void > &_rHdl)
sal_Int16 mnLeftAlignCount
Definition: wizdlg.hxx:77
RoadmapWizard(vcl::Window *pParent, WinBits nStyle=WB_STDDIALOG, InitFlag eFlag=InitFlag::Default)
ImplWizPageData * mpFirstPage
Definition: wizdlg.hxx:70
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
WizardButtonFlags
Definition: vclenum.hxx:276
StateChangedType
Definition: window.hxx:289
sal_Int64 WinBits
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
Definition: wizdlg.hxx:213
VclPtr< RoadmapWizard > m_pOWizard
Definition: wizdlg.hxx:277
VclPtr< TabPage > mpPage
Definition: wizdlg.hxx:32
FactoryFunction GetUITestFactory() const override
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
tools::Long LogicalCoordinateToPixel(int iCoordinate)
void SetLeftAlignedButtonCount(sal_Int16 _nCount)
sets the number of buttons which should be left-aligned.
ImplWizPageData * mpNext
Definition: wizdlg.hxx:31
VclPtr< TabPage > mpCurTabPage
Definition: wizdlg.hxx:72
void RemoveButton(Button *pButton)
VclPtr< TabPage > createPage(WizardTypes::WizardState nState)
to override to create new pages
sal_uInt16 GetCurLevel() const
Definition: wizdlg.hxx:123
ImplWizButtonData * mpFirstBtn
Definition: wizdlg.hxx:71
Use given parent or get a default one using GetDefaultParent(...)
TabPage * GetPage(sal_uInt16 nLevel) const
VclPtr< PushButton > m_pNextPage
Definition: wizdlg.hxx:99
DECL_LINK(ImplHandleWizardLayoutTimerHdl, Timer *, void)
void travelNext()
travel to the next state
sal_Int16 WizardState
OUString getStateDisplayName(WizardTypes::WizardState nState) const
returns a human readable name for a given state
WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const
determine the next state to travel from the given one
virtual bool EventNotify(NotifyEvent &rNEvt) override
const Size & GetPageSizePixel() const
Definition: wizdlg.hxx:134
void AddButton(Button *pButton, tools::Long nOffset=0)
void implUpdateRoadmap()
updates the roadmap control to show the given path, as far as possible (modulo conflicts with other p...
VclPtr< PushButton > mpNextBtn
Definition: wizdlg.hxx:74
virtual void Resize() override
bool isTravelingSuspended() const
virtual void StateChanged(StateChangedType nStateChange) override
void suspendTraveling(AccessGuard)
InitFlag
Definition: dialog.hxx:43
helper class to temporarily suspend any traveling in the wizard
Definition: wizdlg.hxx:261
VclPtr< PushButton > mpPrevBtn
Definition: wizdlg.hxx:73
std::unique_ptr< RoadmapWizardImpl > m_xRoadmapImpl
Definition: wizdlg.hxx:106
void SetRoadmapHelpId(const OString &_rId)
void RemovePage(TabPage *pPage)
void implConstruct(const WizardButtonFlags _nButtonFlags)
void GetOrCreatePage(const WizardTypes::WizardState i_nState)
VclPtr< CancelButton > m_pCancel
Definition: wizdlg.hxx:98
void SetPageSizePixel(const Size &rSize)
Definition: wizdlg.hxx:133
void SelectRoadmapItemByID(int nId, bool bGrabFocus=true)
void ImplShowTabPage(TabPage *pPage)
void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
void AddPage(TabPage *pPage)
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
int GetCurrentRoadmapItemID() const
bool ShowPage(sal_uInt16 nLevel)
Definition: timer.hxx:26
void travelPrevious()
travel to the previous state
void InsertRoadmapItem(int nIndex, const OUString &rLabel, int nId, bool bEnabled)
VclPtr< PushButton > m_pPrevPage
Definition: wizdlg.hxx:100
bool mbEmptyViewMargin
Definition: wizdlg.hxx:78
TabPage * ImplGetPage(sal_uInt16 nLevel) const
RoadmapWizardTravelSuspension(RoadmapWizard &rWizard)
Definition: wizdlg.hxx:264
VclPtr< OKButton > m_pFinish
Definition: wizdlg.hxx:97
VclPtr< HelpButton > m_pHelp
Definition: wizdlg.hxx:101
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
Idle maWizardLayoutIdle
Definition: wizdlg.hxx:68
void SetPage(sal_uInt16 nLevel, TabPage *pPage)
virtual ~RoadmapWizard() override