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/button.hxx>
25 #include <vcl/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 : public Dialog
66  {
67  private:
76  sal_uInt16 mnCurLevel;
78  sal_Int16 mnLeftAlignCount;
80 
81  DECL_LINK( ImplHandleWizardLayoutTimerHdl, Timer*, void );
82 
83  // IMPORTANT:
84  // traveling pages should not be done by calling these base class member, some mechanisms of this class
85  // here (e.g. committing page data) depend on having full control over page traveling.
86  // So use the travelXXX methods if you need to travel
87 
88  protected:
89  long LogicalCoordinateToPixel(int iCoordinate);
94  void SetLeftAlignedButtonCount( sal_Int16 _nCount );
100  void SetEmptyViewMargin();
101 
102  void CalcAndSetSize();
103 
104  public:
110 
111  private:
112  std::unique_ptr<WizardMachineImplData> m_xWizardImpl;
113  // hold members in this structure to allow keeping compatible when members are added
114  std::unique_ptr<RoadmapWizardImpl> m_xRoadmapImpl;
115 
116  public:
117  RoadmapWizard(vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default);
118  virtual ~RoadmapWizard( ) override;
119  virtual void dispose() override;
120 
121  virtual void Resize() override;
122  virtual void StateChanged( StateChangedType nStateChange ) override;
123  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
124 
125  void ActivatePage();
126 
127  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
128 
129  bool ShowPage( sal_uInt16 nLevel );
130  bool Finish( long nResult = 0 );
131  sal_uInt16 GetCurLevel() const { return mnCurLevel; }
132 
133  void AddPage( TabPage* pPage );
134  void RemovePage( TabPage* pPage );
135  void SetPage( sal_uInt16 nLevel, TabPage* pPage );
136  TabPage* GetPage( sal_uInt16 nLevel ) const;
137 
138  void AddButton( Button* pButton, long nOffset = 0 );
139  void RemoveButton( Button* pButton );
140 
141  void SetPrevButton( PushButton* pButton ) { mpPrevBtn = pButton; }
142  void SetNextButton( PushButton* pButton ) { mpNextBtn = pButton; }
143 
144  void SetViewWindow( vcl::Window* pWindow ) { mpViewWindow = pWindow; }
145  void SetViewAlign( WindowAlign eAlign ) { meViewAlign = eAlign; }
146 
147  void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
148  const Size& GetPageSizePixel() const { return maPageSize; }
149 
151  void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable);
152 
154  bool canAdvance() const;
155 
156  void SetRoadmapHelpId( const OString& _rId );
157 
158  void InsertRoadmapItem(int nIndex, const OUString& rLabel, int nId, bool bEnabled);
159  void DeleteRoadmapItems();
160  int GetCurrentRoadmapItemID() const;
161  void SelectRoadmapItemByID(int nId);
162  void SetItemSelectHdl( const Link<LinkParamNone*,void>& _rHdl );
163  void ShowRoadmap(bool bShow);
164 
165  protected:
166 
169 
171  void enterState(WizardTypes::WizardState _nState);
172 
184 
194 
198  bool onFinish();
199 
201  bool travelNext();
202 
204  bool travelPrevious();
205 
212 
216 
231  bool skipUntil(WizardTypes::WizardState nTargetState);
232 
249  bool skipBackwardUntil(WizardTypes::WizardState nTargetState);
250 
256 
257  static IWizardPageController* getPageController( TabPage* _pCurrentPage );
258 
266  OUString getStateDisplayName(WizardTypes::WizardState nState) const;
267 
268  private:
269  DECL_LINK( OnRoadmapItemSelected, LinkParamNone*, void );
270 
274  void implUpdateRoadmap( );
275 
276  void impl_construct();
277 
278  public:
280  {
282  private:
284  };
285 
286  void suspendTraveling( AccessGuard );
287  void resumeTraveling( AccessGuard );
288  bool isTravelingSuspended() const;
289 
290  protected:
292 
293  private:
294  void ImplInitData();
295  void ImplCalcSize( Size& rSize );
296  void ImplPosCtrls();
297  void ImplPosTabPage();
298  void ImplShowTabPage( TabPage* pPage );
299  TabPage* ImplGetPage( sal_uInt16 nLevel ) const;
300 
301 
302  DECL_LINK(OnNextPage, Button*, void);
303  DECL_LINK(OnPrevPage, Button*, void);
304  DECL_LINK(OnFinish, Button*, void);
305 
306  void implUpdateTitle();
307  void implConstruct( const WizardButtonFlags _nButtonFlags );
308  };
309 
312  {
313  public:
315  : m_pOWizard(&rWizard)
316  {
317  m_pOWizard->suspendTraveling(RoadmapWizard::AccessGuard());
318  }
319 
321  {
322  if (m_pOWizard)
323  m_pOWizard->resumeTraveling(RoadmapWizard::AccessGuard());
324  }
325 
326  private:
328  };
329 
330 } // namespace vcl
331 
332 #endif
333 
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
WindowAlign
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 removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
std::unique_ptr< WizardMachineImplData > m_xWizardImpl
Definition: wizdlg.hxx:112
void SetNextButton(PushButton *pButton)
Definition: wizdlg.hxx:142
void ImplCalcSize(Size &rSize)
void SetItemSelectHdl(const Link< LinkParamNone *, void > &_rHdl)
sal_Int16 mnLeftAlignCount
Definition: wizdlg.hxx:78
RoadmapWizard(vcl::Window *pParent, WinBits nStyle=WB_STDDIALOG, InitFlag eFlag=InitFlag::Default)
ImplWizPageData * mpFirstPage
Definition: wizdlg.hxx:70
void AddButton(Button *pButton, long nOffset=0)
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
TabPage * GetOrCreatePage(const WizardTypes::WizardState i_nState)
WizardButtonFlags
Definition: vclenum.hxx:276
StateChangedType
Definition: window.hxx:311
sal_Int64 WinBits
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
Definition: wizdlg.hxx:255
bool onFinish()
called when the finish button is pressed
VclPtr< RoadmapWizard > m_pOWizard
Definition: wizdlg.hxx:327
VclPtr< TabPage > mpPage
Definition: wizdlg.hxx:32
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
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:131
ImplWizButtonData * mpFirstBtn
Definition: wizdlg.hxx:71
Use given parent or get a default one using GetDefaultParent(...)
void SelectRoadmapItemByID(int nId)
bool Finish(long nResult=0)
TabPage * GetPage(sal_uInt16 nLevel) const
VclPtr< PushButton > m_pNextPage
Definition: wizdlg.hxx:107
DECL_LINK(ImplHandleWizardLayoutTimerHdl, Timer *, void)
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
WindowAlign meViewAlign
Definition: wizdlg.hxx:77
const Size & GetPageSizePixel() const
Definition: wizdlg.hxx:148
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 SetEmptyViewMargin()
declares the view area to have an empty margin
void suspendTraveling(AccessGuard)
InitFlag
Definition: dialog.hxx:37
helper class to temporarily suspend any traveling in the wizard
Definition: wizdlg.hxx:311
long LogicalCoordinateToPixel(int iCoordinate)
void SetPrevButton(PushButton *pButton)
Definition: wizdlg.hxx:141
VclPtr< PushButton > mpPrevBtn
Definition: wizdlg.hxx:73
std::unique_ptr< RoadmapWizardImpl > m_xRoadmapImpl
Definition: wizdlg.hxx:114
void SetRoadmapHelpId(const OString &_rId)
bool travelNext()
travel to the next state
void RemovePage(TabPage *pPage)
void implConstruct(const WizardButtonFlags _nButtonFlags)
void SetViewWindow(vcl::Window *pWindow)
Definition: wizdlg.hxx:144
bool travelPrevious()
travel to the previous state
VclPtr< CancelButton > m_pCancel
Definition: wizdlg.hxx:106
void SetPageSizePixel(const Size &rSize)
Definition: wizdlg.hxx:147
void ImplShowTabPage(TabPage *pPage)
void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
void SetViewAlign(WindowAlign eAlign)
Definition: wizdlg.hxx:145
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 enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
enable (or disable) buttons
void InsertRoadmapItem(int nIndex, const OUString &rLabel, int nId, bool bEnabled)
VclPtr< PushButton > m_pPrevPage
Definition: wizdlg.hxx:108
bool mbEmptyViewMargin
Definition: wizdlg.hxx:79
TabPage * ImplGetPage(sal_uInt16 nLevel) const
RoadmapWizardTravelSuspension(RoadmapWizard &rWizard)
Definition: wizdlg.hxx:314
static IWizardPageController * getPageController(TabPage *_pCurrentPage)
VclPtr< OKButton > m_pFinish
Definition: wizdlg.hxx:105
VclPtr< HelpButton > m_pHelp
Definition: wizdlg.hxx:109
bool isAutomaticNextButtonStateEnabled() const
enables the automatic enabled/disabled state of the "Next" button
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:30
Idle maWizardLayoutIdle
Definition: wizdlg.hxx:68
void SetPage(sal_uInt16 nLevel, TabPage *pPage)
virtual ~RoadmapWizard() override
bool prepareLeaveCurrentState(WizardTypes::CommitPageReason eReason)
will be called when the current state is about to be left for the given reason
bool canAdvance() const
determines whether there is a next state to which we can advance