21 #include <officecfg/Office/Common.hxx>
25 #include <strings.hrc>
34 #define WIZARDDIALOG_BUTTON_OFFSET_Y 6
35 #define WIZARDDIALOG_BUTTON_DLGOFFSET_X 6
36 #define WIZARDDIALOG_VIEW_DLGOFFSET_X 6
37 #define WIZARDDIALOG_VIEW_DLGOFFSET_Y 6
43 :
BuilderPage(pPage, pController, rUIXMLDescription, rID)
95 nBarWidth += nBtnWidth;
98 if ( nBtnHeight > nMaxHeight )
99 nMaxHeight = nBtnHeight;
100 pBtnData = pBtnData->
mpNext;
114 if (nBarWidth > rSize.
Width())
148 if ( nBtnHeight > nMaxHeight )
149 nMaxHeight = nBtnHeight;
150 nBtnWidth += aBtnSize.
Width();
153 pBtnData = pBtnData->
mpNext;
170 Point aPos( nOffX, nOffY+((nMaxHeight-aBtnSize.
Height())/2) );
172 nOffX += aBtnSize.
Width();
177 Point aPos( nOffLeftAlignX, nOffY+((nMaxHeight-aBtnSize.
Height())/2) );
179 nOffLeftAlignX += aBtnSize.
Width();
180 nOffLeftAlignX += pBtnData->
mnOffset;
183 pBtnData = pBtnData->
mpNext;
205 nViewHeight = nDlgHeight;
216 nViewWidth, nViewHeight,
223 int iPixelCoordinate = aLocSize.
Width();
224 return iPixelCoordinate;
246 if ( nBtnHeight > nMaxHeight )
247 nMaxHeight = nBtnHeight;
248 pBtnData = pBtnData->
mpNext;
263 nOffX += aViewSize.
Width() + nViewOffset;
266 Point aPos( nOffX, nOffY );
290 sal_uInt16 nTempLevel = 0;
294 if ( (nTempLevel == nLevel) || !pPageData->
mpNext )
298 pPageData = pPageData->
mpNext;
405 pPageData = pPageData->
mpNext;
436 sal_uInt16 nKeyCode = aKeyCode.
GetCode();
476 if (
nullptr !=
GetPage( i_nState ) )
480 DBG_ASSERT( pNewPage,
"RoadmapWizard::GetOrCreatePage: invalid new page (NULL)!" );
527 pNewPageData->
mpNext =
nullptr;
528 pNewPageData->
mpPage = pPage;
535 while ( pPageData->
mpNext )
536 pPageData = pPageData->
mpNext;
537 pPageData->
mpNext = pNewPageData;
547 if ( pPageData->
mpPage == pPage )
559 pPrevPageData = pPageData;
560 pPageData = pPageData->
mpNext;
563 OSL_FAIL(
"RoadmapWizard::RemovePage() - Page not in list" );
568 sal_uInt16 nTempLevel = 0;
572 if ( (nTempLevel == nLevel) || !pPageData->
mpNext )
576 pPageData = pPageData->
mpNext;
583 pPageData->
mpPage = pPage;
589 sal_uInt16 nTempLevel = 0;
592 pPageData = pPageData->
mpNext)
594 if ( nTempLevel == nLevel )
595 return pPageData->mpPage;
605 pNewBtnData->
mpNext =
nullptr;
614 while ( pBtnData->
mpNext )
615 pBtnData = pBtnData->
mpNext;
616 pBtnData->
mpNext = pNewBtnData;
626 if ( pBtnData->
mpButton == pButton )
636 pPrevBtnData = pBtnData;
637 pBtnData = pBtnData->
mpNext;
640 OSL_FAIL(
"RoadmapWizard::RemoveButton() - Button not in list" );
645 if ( isTravelingSuspended() )
654 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_xWizardImpl->aStateHistory;
655 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_xWizardImpl->aStateHistory;
658 while ( nCurrentRollbackState != _nTargetState )
660 DBG_ASSERT( !aTravelVirtually.empty(),
"RoadmapWizard::skipBackwardUntil: this target state does not exist in the history!" );
661 nCurrentRollbackState = aTravelVirtually.top();
662 aTravelVirtually.pop();
678 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_xWizardImpl->aStateHistory;
679 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_xWizardImpl->aStateHistory;
680 while ( nCurrentState != _nTargetState )
685 OSL_FAIL(
"RoadmapWizard::skipUntil: the given target state does not exist!" );
690 aTravelVirtually.push( nCurrentState );
693 nCurrentState = nNextState;
701 OSL_FAIL(
"RoadmapWizard::skipUntil: very unpolite..." );
746 std::stack< WizardTypes::WizardState > aTemp;
751 if(nPreviousState != nToRemove)
752 aTemp.push( nPreviousState );
756 while(!aTemp.empty())
765 if ( isTravelingSuspended() )
773 if ( isTravelingSuspended() )
797 : AssistantController(pParent,
"vcl/ui/wizard.ui",
"Wizard")
798 , m_pCurTabPage(nullptr)
800 , m_pFirstPage(nullptr)
801 , m_xFinish(m_xAssistant->weld_widget_for_response(
RET_OK))
802 , m_xCancel(m_xAssistant->weld_widget_for_response(
RET_CANCEL))
803 , m_xNextPage(m_xAssistant->weld_widget_for_response(
RET_YES))
804 , m_xPrevPage(m_xAssistant->weld_widget_for_response(
RET_NO))
805 , m_xHelp(m_xAssistant->weld_widget_for_response(
RET_HELP))
816 officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
878 OUString sCompleteTitle(
m_pImpl->sTitleBase);
882 if ( pCurrentPage && !pCurrentPage->
GetPageTitle().isEmpty() )
892 m_pImpl->sTitleBase = _rTitleBase;
898 if (
nullptr ==
GetPage( i_nState ) )
900 std::unique_ptr<BuilderPage> xNewPage =
createPage( i_nState );
901 DBG_ASSERT( xNewPage,
"WizardMachine::GetOrCreatePage: invalid new page (NULL)!" );
904 while (
m_pImpl->nFirstUnknownPage < i_nState )
910 if (
m_pImpl->nFirstUnknownPage == i_nState )
918 SetPage(i_nState, std::move(xNewPage));
960 m_xAssistant->change_default_widget(
nullptr, _pNewDefButton);
972 m_xHelp->set_sensitive(_bEnable);
981 OSL_ENSURE( pController,
"WizardMachine::enterState: no controller for the given page!" );
1010 if ( isTravelingSuspended() )
1033 return _nCurrentState + 1;
1039 ENSURE_OR_RETURN( pController !=
nullptr,
"WizardMachine::prepareLeaveCurrentState: no controller for the current page!",
true );
1050 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_pImpl->aStateHistory;
1051 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_pImpl->aStateHistory;
1054 while ( nCurrentRollbackState != _nTargetState )
1056 DBG_ASSERT( !aTravelVirtually.empty(),
"WizardMachine::skipBackwardUntil: this target state does not exist in the history!" );
1057 nCurrentRollbackState = aTravelVirtually.top();
1058 aTravelVirtually.pop();
1060 m_pImpl->aStateHistory = aTravelVirtually;
1063 m_pImpl->aStateHistory = aOldStateHistory;
1078 std::stack< WizardTypes::WizardState > aTravelVirtually =
m_pImpl->aStateHistory;
1079 std::stack< WizardTypes::WizardState > aOldStateHistory =
m_pImpl->aStateHistory;
1080 while ( nCurrentState != _nTargetState )
1085 OSL_FAIL(
"WizardMachine::skipUntil: the given target state does not exist!" );
1090 aTravelVirtually.push( nCurrentState );
1093 nCurrentState = nNextState;
1095 m_pImpl->aStateHistory = aTravelVirtually;
1101 OSL_FAIL(
"WizardMachine::skipUntil: very unpolite..." );
1102 m_pImpl->aStateHistory = aOldStateHistory;
1121 m_pImpl->aStateHistory.push(nCurrentState);
1124 nCurrentState = nNextState;
1131 OSL_FAIL(
"RoadmapWizard::skip: very unpolite...");
1155 m_pImpl->aStateHistory.push(nCurrentState);
1177 m_xAssistant->set_current_page(OString::number(nState));
1201 DBG_ASSERT(!
m_pImpl->aStateHistory.empty(),
"WizardMachine::travelPrevious: have no previous page!");
1215 m_pImpl->aStateHistory.push(nPreviousState);
1227 std::stack< WizardTypes::WizardState > aTemp;
1228 while(!
m_pImpl->aStateHistory.empty())
1232 if(nPreviousState != nToRemove)
1233 aTemp.push( nPreviousState );
1237 while(!aTemp.empty())
1239 m_pImpl->aStateHistory.push( aTemp.top() );
1247 m_pImpl->m_bAutoNextButtonState =
true;
1253 return m_pImpl->m_bAutoNextButtonState;
1258 if ( isTravelingSuspended() )
1266 if ( isTravelingSuspended() )
1280 std::stack< WizardTypes::WizardState > aHistoryCopy(
m_pImpl->aStateHistory );
1281 while ( !aHistoryCopy.empty() )
1283 _out_rHistory.push_back( aHistoryCopy.top() );
1296 OSL_ENSURE( pController !=
nullptr,
"RoadmapWizard::updateTravelUI: no controller for the current page!" );
1299 ( !pController || pController->
canAdvance() )
1306 return m_pImpl->m_bTravelingSuspended;
1311 DBG_ASSERT( !
m_pImpl->m_bTravelingSuspended,
"WizardMachine::suspendTraveling: already suspended!" );
1312 m_pImpl->m_bTravelingSuspended =
true;
1320 DBG_ASSERT(
m_pImpl->m_bTravelingSuspended,
"WizardMachine::resumeTraveling: nothing to resume!" );
1321 m_pImpl->m_bTravelingSuspended =
false;
1341 pNewPageData->
mpNext =
nullptr;
1342 pNewPageData->
mxPage = std::move(xPage);
1349 while ( pPageData->
mpNext )
1350 pPageData = pPageData->
mpNext;
1351 pPageData->
mpNext = pNewPageData;
1361 if (pPageData->
mxPage.get() == pPage)
1373 pPrevPageData = pPageData;
1374 pPageData = pPageData->
mpNext;
1377 OSL_FAIL(
"WizardMachine::RemovePage() - Page not in list" );
1382 sal_uInt16 nTempLevel = 0;
1386 if ( (nTempLevel == nLevel) || !pPageData->
mpNext )
1390 pPageData = pPageData->
mpNext;
1397 pPageData->
mxPage = std::move(xPage);
1403 sal_uInt16 nTempLevel = 0;
1406 pPageData = pPageData->
mpNext)
1408 if ( nTempLevel == nLevel )
1409 return pPageData->mxPage.get();
#define LINK(Instance, Class, Member)
std::unique_ptr< weld::Button > m_xPrevPage
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
bool IsInputEnabled() const
bool isTravelingSuspended() const
virtual bool canAdvance() const override
determines whether or not it is allowed to advance to a next page
void resumeTraveling(AccessGuard)
virtual bool leaveState(WizardTypes::WizardState nState)
will be called when the given state is left
virtual bool EventNotify(NotifyEvent &rNEvt) override
virtual bool Close() override
void setWidth(tools::Long nWidth)
VclPtr< vcl::Window > mpViewWindow
virtual void initializePage()=0
void EndDialog(tools::Long nResult=RET_CANCEL)
void suspendTraveling(AccessGuard)
void Finish(tools::Long nResult=0)
virtual void ActivatePage()
tools::Long LogicalCoordinateToPixel(int iCoordinate) const
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
std::unique_ptr< WizardMachineImplData > m_xWizardImpl
virtual void updateTravelUI() override
updates the user interface which deals with traveling in the wizard
#define WIZARDDIALOG_VIEW_DLGOFFSET_X
std::unique_ptr< WizardMachineImplData > m_pImpl
void ImplCalcSize(Size &rSize)
virtual Size GetSizePixel() const
virtual void SetSizePixel(const Size &rNewSize)
sal_Int16 mnLeftAlignCount
void enableAutomaticNextButtonState()
enables the automatic enabled/disabled state of the "Next" button
ImplWizPageData * mpFirstPage
sal_uInt16 GetCode() const
is - no, not a wizard for a roadmap, but the base class for wizards supporting a roadmap.
#define WIZARDDIALOG_BUTTON_OFFSET_Y
virtual bool canAdvance() const
determines whether there is a next state to which we can advance
const KeyEvent * GetKeyEvent() const
virtual ~WizardMachine() override
virtual IWizardPageController * getPageController(BuilderPage *pCurrentPage) const
void SetHelpId(const OString &)
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
std::unique_ptr< weld::Button > m_xHelp
void defaultButton(WizardButtonFlags _nWizardButtonFlags)
set the default style for a button
constexpr tools::Long Width() const
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
void SetPage(WizardTypes::WizardState nLevel, std::unique_ptr< BuilderPage > xPage)
const OUString & GetPageTitle() const
bool IsDefaultSize() const
constexpr sal_uInt16 KEY_PAGEUP
virtual void SetOutputSizePixel(const Size &rNewSize)
#define WZS_INVALID_STATE
void removePageFromHistory(WizardTypes::WizardState nToRemove)
removes a page from the history.
VCL_DLLPRIVATE void implConstruct(const WizardButtonFlags _nButtonFlags)
virtual void Deactivate()
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
void SetLeftAlignedButtonCount(sal_Int16 _nCount)
sets the number of buttons which should be left-aligned.
std::unique_ptr< weld::Button > m_xCancel
VclPtr< TabPage > mpCurTabPage
void RemoveButton(Button *pButton)
VclPtr< TabPage > createPage(WizardTypes::WizardState nState)
to override to create new pages
void updateDialogTravelUI()
updates the travel-related UI elements of the OWizardMachine we live in (if any)
sal_uInt16 GetCurLevel() const
OUString VclResId(TranslateId aId)
ImplWizButtonData * mpFirstBtn
void SetMinOutputSizePixel(const Size &rSize)
WizPageData * m_pFirstPage
std::unique_ptr< weld::Button > m_xNextPage
virtual WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const
determine the next state to travel from the given one
bool isAutomaticNextButtonStateEnabled() const
virtual void Activate() override
virtual bool prepareLeaveCurrentState(WizardTypes::CommitPageReason eReason)
will be called when the current state is about to be left for the given reason
TabPage * GetPage(sal_uInt16 nLevel) const
Point LogicToPixel(const Point &rLogicPt) const
#define DBG_ASSERT(sCon, aError)
VclPtr< PushButton > m_pNextPage
weld::DialogController * m_pDialogController
void travelNext()
travel to the next state
virtual bool canAdvance() const =0
determines whether or not it is allowed to advance to a next page
OWizardPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OString &rID)
virtual void SetText(const OUString &rStr) override
#define WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X
WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const
determine the next state to travel from the given one
virtual bool commitPage(WizardTypes::CommitPageReason _eReason)=0
virtual bool DeactivatePage()
#define ENSURE_OR_RETURN(c, m, r)
virtual bool EventNotify(NotifyEvent &rNEvt) override
bool IsInInitShow() const
constexpr sal_uInt16 KEY_PAGEDOWN
const Size & GetPageSizePixel() const
MouseNotifyEvent GetType() const
void AddButton(Button *pButton, tools::Long nOffset=0)
VclPtr< PushButton > mpNextBtn
virtual ~OWizardPage() override
virtual void Resize() override
bool isTravelingSuspended() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
virtual void StateChanged(StateChangedType nStateChange) override
void RemovePage(const BuilderPage *pPage)
implements some kind of finite automata, where the states of the automata exactly correlate with tab ...
bool IsReallyShown() const
WizardTypes::WizardState getCurrentState() const
returns the current state of the machine
virtual bool onFinish()
called when the finish button is pressed
void AddPage(std::unique_ptr< BuilderPage > xPage)
void suspendTraveling(AccessGuard)
bool travelNext()
travel to the next state
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
#define WIZARDDIALOG_VIEW_DLGOFFSET_Y
bool skipUntil(WizardTypes::WizardState nTargetState)
skips one or more states, until a given state is reached
constexpr OStringLiteral HID_WIZARD_NEXT
void set_id(const OUString &rID)
Sets an ID.
helper class to temporarily suspend any traveling in the wizard
virtual bool commitPage(WizardTypes::CommitPageReason _eReason) override
virtual void Resize() override
const vcl::KeyCode & GetKeyCode() const
VclPtr< PushButton > mpPrevBtn
virtual void StateChanged(StateChangedType nStateChange) override
std::unique_ptr< weld::Button > m_xFinish
WizardMachine(weld::Window *_pParent, WizardButtonFlags _nButtonFlags)
constexpr tools::Long Height() const
void RemovePage(TabPage *pPage)
void implConstruct(const WizardButtonFlags _nButtonFlags)
void getStateHistory(std::vector< WizardTypes::WizardState > &out_rHistory)
retrieves a copy of the state history, i.e.
virtual OUString GetText() const override
#define WIZARDDIALOG_BUTTON_STDOFFSET_X
void GetOrCreatePage(const WizardTypes::WizardState i_nState)
bool Finish(short nResult=RET_CANCEL)
void setTitleBase(const OUString &_rTitleBase)
set the base of the title to use - the title of the current page is appended
tools::Long AdjustWidth(tools::Long n)
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
VclPtr< CancelButton > m_pCancel
bool travelPrevious()
travel to the previous state
VCL_DLLPRIVATE void implUpdateTitle()
void resumeTraveling(AccessGuard)
void ImplShowTabPage(TabPage *pPage)
std::unique_ptr< BuilderPage > mxPage
void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
void AddPage(TabPage *pPage)
tools::Long AdjustHeight(tools::Long n)
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
enable (or disable) buttons
Size GetOutputSizePixel() const
bool skipBackwardUntil(WizardTypes::WizardState nTargetState)
moves back one or more states, until a given state is reached
bool ShowPage(sal_uInt16 nLevel)
void setHeight(tools::Long nHeight)
virtual void Start(bool bStartTimer=true) override
Schedules the task for execution.
BuilderPage * m_pCurTabPage
BuilderPage * GetPage(WizardTypes::WizardState eState) const
#define WIZARDDIALOG_BUTTON_DLGOFFSET_X
WinBits const WB_CLOSEABLE
virtual std::unique_ptr< BuilderPage > createPage(WizardTypes::WizardState _nState)=0
to override to create new pages
void travelPrevious()
travel to the previous state
virtual void updateTravelUI()
updates the user interface which deals with traveling in the wizard
VclPtr< PushButton > m_pPrevPage
bool IsReallyVisible() const
SAL_DLLPRIVATE bool IsInClose() const
IMPL_LINK_NOARG(QuickSelectionEngine_Data, SearchStringTimeout, Timer *, void)
BuilderPage * GetOrCreatePage(const WizardTypes::WizardState i_nState)
TabPage * ImplGetPage(sal_uInt16 nLevel) const
virtual void enterState(WizardTypes::WizardState _nState)
will be called when a new page is about to be displayed
std::unique_ptr< weld::Assistant > m_xAssistant
bool ShowPage(WizardTypes::WizardState nState)
constexpr OStringLiteral HID_WIZARD_PREVIOUS
VclPtr< OKButton > m_pFinish
virtual void SetPosPixel(const Point &rNewPos)
WizardTypes::WizardState m_nCurState
VclPtr< HelpButton > m_pHelp
constexpr sal_uInt16 KEY_TAB
helper class to temporarily suspend any traveling in the wizard
void SetPage(sal_uInt16 nLevel, TabPage *pPage)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
virtual void initializePage() override