[Libreoffice-commits] core.git: include/vcl solenv/clang-format vcl/Library_vcl.mk vcl/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 12 18:29:46 UTC 2019
include/vcl/wizardmachine.hxx | 94 ++++-
include/vcl/wizdlg.hxx | 92 ----
solenv/clang-format/blacklist | 2
vcl/Library_vcl.mk | 1
vcl/source/control/wizardmachine.cxx | 579 ++++++++++++++++++++++++++++++-
vcl/source/control/wizdlg.cxx | 646 -----------------------------------
6 files changed, 654 insertions(+), 760 deletions(-)
New commits:
commit 166dc8778d79c2932800ee26a8e18994b5a6b884
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 12 15:29:17 2019 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 12 20:28:33 2019 +0200
merge OWizardMachine and WizardDialog
Change-Id: I9d8aa49eb4394b630197cac97777231ed87f7a75
Reviewed-on: https://gerrit.libreoffice.org/78834
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/wizardmachine.hxx b/include/vcl/wizardmachine.hxx
index 04fb2d1f6602..c61009494ad9 100644
--- a/include/vcl/wizardmachine.hxx
+++ b/include/vcl/wizardmachine.hxx
@@ -21,8 +21,9 @@
#include <memory>
#include <vcl/dllapi.h>
-#include <vcl/wizdlg.hxx>
#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/idle.hxx>
#include <vcl/tabpage.hxx>
namespace weld {
@@ -30,6 +31,9 @@ namespace weld {
class Container;
}
+struct ImplWizPageData;
+struct ImplWizButtonData;
+
namespace vcl
{
@@ -134,10 +138,26 @@ namespace vcl
they can implement non-linear traveling this way.
*/
- class VCL_DLLPUBLIC OWizardMachine : public WizardDialog, public WizardTypes
+ class VCL_DLLPUBLIC OWizardMachine : public ModalDialog, public WizardTypes
{
private:
- // TabPage* GetPage( sal_uInt16 nLevel ) const { return WizardDialog::GetPage(nLevel); }
+ 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<OWizardMachine*,void> maActivateHdl;
+ sal_Int16 mnLeftAlignCount;
+ bool mbEmptyViewMargin;
+
+ DECL_DLLPRIVATE_LINK( ImplHandleWizardLayoutTimerHdl, Timer*, void );
+
+ // TabPage* GetPage( sal_uInt16 nLevel ) const { return OWizardMachine::GetPage(nLevel); }
// TODO: probably the complete page handling (next, previous etc.) should be prohibited ...
// IMPORTANT:
@@ -145,6 +165,23 @@ namespace vcl
// 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:
VclPtr<OKButton> m_pFinish;
VclPtr<CancelButton> m_pCancel;
@@ -161,6 +198,40 @@ namespace vcl
virtual ~OWizardMachine() 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<OWizardMachine*,void>& rLink ) { maActivateHdl = rLink; }
+
/// enable (or disable) buttons
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable);
/// set the default style for a button
@@ -183,10 +254,6 @@ namespace vcl
virtual void updateTravelUI();
protected:
- // WizardDialog overridables
- virtual void ActivatePage() override;
- virtual bool DeactivatePage() override;
-
// our own overridables
/// to override to create new pages
@@ -306,7 +373,7 @@ namespace vcl
Vulgo, this is the identifier of the current tab page :)
*/
- WizardState getCurrentState() const { return WizardDialog::GetCurLevel(); }
+ WizardState getCurrentState() const { return GetCurLevel(); }
virtual IWizardPageController*
getPageController( TabPage* _pCurrentPage ) const;
@@ -331,6 +398,14 @@ namespace vcl
TabPage* GetOrCreatePage( const 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);
@@ -396,7 +471,6 @@ namespace vcl
virtual void updateTravelUI();
protected:
- // WizardDialog overridables
virtual void ActivatePage();
virtual bool DeactivatePage();
@@ -588,6 +662,8 @@ namespace vcl
} // namespace vcl
+#define WIZARDDIALOG_BUTTON_STDOFFSET_X 6
+#define WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X 3
#endif // INCLUDED_SVTOOLS_WIZARDMACHINE_HXX
diff --git a/include/vcl/wizdlg.hxx b/include/vcl/wizdlg.hxx
index 338816904ca0..3e87bff37c5b 100644
--- a/include/vcl/wizdlg.hxx
+++ b/include/vcl/wizdlg.hxx
@@ -21,13 +21,8 @@
#define INCLUDED_VCL_WIZDLG_HXX
#include <vcl/dllapi.h>
-#include <vcl/button.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/idle.hxx>
class TabPage;
-struct ImplWizPageData;
-struct ImplWizButtonData;
/*
@@ -170,93 +165,6 @@ IMPL_LINK( MyWizardDlg, ImplNextHdl, PushButton*, pBtn, void )
*/
-#define WIZARDDIALOG_BUTTON_STDOFFSET_X 6
-#define WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X 3
-
-
-class VCL_DLLPUBLIC WizardDialog : public ModalDialog
-{
-private:
- 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<WizardDialog*,void> maActivateHdl;
- sal_Int16 mnLeftAlignCount;
- bool mbEmptyViewMargin;
-
- DECL_DLLPRIVATE_LINK( ImplHandleWizardLayoutTimerHdl, Timer*, void );
-
-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();
-
-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;
-
-public:
- WizardDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription );
- virtual ~WizardDialog() 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<WizardDialog*,void>& rLink ) { maActivateHdl = rLink; }
-};
-
#endif // INCLUDED_VCL_WIZDLG_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 258d31436ff6..0bf27165bfe1 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -7946,7 +7946,6 @@ include/vcl/waitobj.hxx
include/vcl/wall.hxx
include/vcl/window.hxx
include/vcl/wizardmachine.hxx
-include/vcl/wizdlg.hxx
include/vcl/wmf.hxx
include/vcl/wmfexternal.hxx
include/vcl/wrkwin.hxx
@@ -17765,7 +17764,6 @@ vcl/source/control/tabctrl.cxx
vcl/source/control/throbber.cxx
vcl/source/control/thumbpos.hxx
vcl/source/control/wizardmachine.cxx
-vcl/source/control/wizdlg.cxx
vcl/source/edit/textdat2.hxx
vcl/source/edit/textdata.cxx
vcl/source/edit/textdoc.cxx
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index c8e4aa75dccb..c33dfbdbd987 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -213,7 +213,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/control/tabctrl \
vcl/source/control/throbber \
vcl/source/control/wizardmachine \
- vcl/source/control/wizdlg \
vcl/source/edit/vclmedit \
vcl/source/edit/textdata \
vcl/source/edit/textdoc \
diff --git a/vcl/source/control/wizardmachine.cxx b/vcl/source/control/wizardmachine.cxx
index fb309c46f8ec..823b20f69d7e 100644
--- a/vcl/source/control/wizardmachine.cxx
+++ b/vcl/source/control/wizardmachine.cxx
@@ -17,10 +17,11 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <vcl/event.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/wizardmachine.hxx>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
-#include <vcl/svapp.hxx>
#include <strings.hrc>
#include <svdata.hxx>
#include <stack>
@@ -28,12 +29,24 @@
#define HID_WIZARD_NEXT "SVT_HID_WIZARD_NEXT"
#define HID_WIZARD_PREVIOUS "SVT_HID_WIZARD_PREVIOUS"
+#define WIZARDDIALOG_BUTTON_OFFSET_Y 6
+#define WIZARDDIALOG_BUTTON_DLGOFFSET_X 6
+#define WIZARDDIALOG_VIEW_DLGOFFSET_X 6
+#define WIZARDDIALOG_VIEW_DLGOFFSET_Y 6
+
struct ImplWizPageData
{
ImplWizPageData* mpNext;
VclPtr<TabPage> mpPage;
};
+struct ImplWizButtonData
+{
+ ImplWizButtonData* mpNext;
+ VclPtr<Button> mpButton;
+ long mnOffset;
+};
+
namespace vcl
{
//= WizardPageImplData
@@ -110,8 +123,288 @@ namespace vcl
}
};
- OWizardMachine::OWizardMachine(vcl::Window* _pParent, WizardButtonFlags _nButtonFlags )
- :WizardDialog( _pParent, "WizardDialog", "svt/ui/wizarddialog.ui" )
+ void OWizardMachine::ImplInitData()
+ {
+ mpFirstPage = nullptr;
+ mpFirstBtn = nullptr;
+ mpCurTabPage = nullptr;
+ mpPrevBtn = nullptr;
+ mpNextBtn = nullptr;
+ mpViewWindow = nullptr;
+ mnCurLevel = 0;
+ meViewAlign = WindowAlign::Left;
+ mbEmptyViewMargin = false;
+ mnLeftAlignCount = 0;
+
+ maWizardLayoutIdle.SetPriority(TaskPriority::RESIZE);
+ maWizardLayoutIdle.SetInvokeHandler( LINK( this, OWizardMachine, ImplHandleWizardLayoutTimerHdl ) );
+ }
+
+ void OWizardMachine::SetLeftAlignedButtonCount( sal_Int16 _nCount )
+ {
+ mnLeftAlignCount = _nCount;
+ }
+
+ void OWizardMachine::SetEmptyViewMargin()
+ {
+ mbEmptyViewMargin = true;
+ }
+
+ void OWizardMachine::ImplCalcSize( Size& rSize )
+ {
+ // calculate ButtonBar height
+ long nMaxHeight = 0;
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData )
+ {
+ long nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
+ if ( nBtnHeight > nMaxHeight )
+ nMaxHeight = nBtnHeight;
+ pBtnData = pBtnData->mpNext;
+ }
+ if ( nMaxHeight )
+ nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
+ rSize.AdjustHeight(nMaxHeight );
+
+ // add in the view window size
+ if ( mpViewWindow && mpViewWindow->IsVisible() )
+ {
+ Size aViewSize = mpViewWindow->GetSizePixel();
+ if ( meViewAlign == WindowAlign::Top )
+ rSize.AdjustHeight(aViewSize.Height() );
+ else if ( meViewAlign == WindowAlign::Left )
+ rSize.AdjustWidth(aViewSize.Width() );
+ else if ( meViewAlign == WindowAlign::Bottom )
+ rSize.AdjustHeight(aViewSize.Height() );
+ else if ( meViewAlign == WindowAlign::Right )
+ rSize.AdjustWidth(aViewSize.Width() );
+ }
+ }
+
+ void OWizardMachine::queue_resize(StateChangedType /*eReason*/)
+ {
+ if (maWizardLayoutIdle.IsActive())
+ return;
+ if (IsInClose())
+ return;
+ maWizardLayoutIdle.Start();
+ }
+
+ IMPL_LINK_NOARG(OWizardMachine, ImplHandleWizardLayoutTimerHdl, Timer*, void)
+ {
+ ImplPosCtrls();
+ ImplPosTabPage();
+ }
+
+ void OWizardMachine::ImplPosCtrls()
+ {
+ Size aDlgSize = GetOutputSizePixel();
+ long nBtnWidth = 0;
+ long nMaxHeight = 0;
+ long nOffY = aDlgSize.Height();
+
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ int j = 0;
+ while ( pBtnData )
+ {
+ if (j >= mnLeftAlignCount)
+ {
+ Size aBtnSize = pBtnData->mpButton->GetSizePixel();
+ long nBtnHeight = aBtnSize.Height();
+ if ( nBtnHeight > nMaxHeight )
+ nMaxHeight = nBtnHeight;
+ nBtnWidth += aBtnSize.Width();
+ nBtnWidth += pBtnData->mnOffset;
+ }
+ pBtnData = pBtnData->mpNext;
+ j++;
+ }
+
+ if ( nMaxHeight )
+ {
+ long nOffX = aDlgSize.Width()-nBtnWidth-WIZARDDIALOG_BUTTON_DLGOFFSET_X;
+ long nOffLeftAlignX = LogicalCoordinateToPixel(6);
+ nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y+nMaxHeight;
+
+ pBtnData = mpFirstBtn;
+ int i = 0;
+ while ( pBtnData )
+ {
+ Size aBtnSize = pBtnData->mpButton->GetSizePixel();
+ if (i >= mnLeftAlignCount)
+ {
+ Point aPos( nOffX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
+ pBtnData->mpButton->SetPosPixel( aPos );
+ nOffX += aBtnSize.Width();
+ nOffX += pBtnData->mnOffset;
+ }
+ else
+ {
+ Point aPos( nOffLeftAlignX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
+ pBtnData->mpButton->SetPosPixel( aPos );
+ nOffLeftAlignX += aBtnSize.Width();
+ nOffLeftAlignX += pBtnData->mnOffset;
+ }
+
+ pBtnData = pBtnData->mpNext;
+ i++;
+ }
+
+ nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y;
+ }
+
+ if ( !(mpViewWindow && mpViewWindow->IsVisible()) )
+ return;
+
+ long nViewOffX = 0;
+ long nViewOffY = 0;
+ long nViewWidth = 0;
+ long nViewHeight = 0;
+ long nDlgHeight = nOffY;
+ PosSizeFlags nViewPosFlags = PosSizeFlags::Pos;
+ if ( meViewAlign == WindowAlign::Top )
+ {
+ nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2);
+ nViewPosFlags |= PosSizeFlags::Width;
+ }
+ else if ( meViewAlign == WindowAlign::Left )
+ {
+ if ( mbEmptyViewMargin )
+ {
+ nViewOffX = 0;
+ nViewOffY = 0;
+ nViewHeight = nDlgHeight;
+ }
+ else
+ {
+ nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2);
+ }
+ nViewPosFlags |= PosSizeFlags::Height;
+ }
+ else if ( meViewAlign == WindowAlign::Bottom )
+ {
+ nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = nDlgHeight-mpViewWindow->GetSizePixel().Height()-WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2);
+ nViewPosFlags |= PosSizeFlags::Width;
+ }
+ else if ( meViewAlign == WindowAlign::Right )
+ {
+ nViewOffX = aDlgSize.Width()-mpViewWindow->GetSizePixel().Width()-WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2);
+ nViewPosFlags |= PosSizeFlags::Height;
+ }
+ mpViewWindow->setPosSizePixel( nViewOffX, nViewOffY,
+ nViewWidth, nViewHeight,
+ nViewPosFlags );
+ }
+
+ long OWizardMachine::LogicalCoordinateToPixel(int iCoordinate){
+ Size aLocSize = LogicToPixel(Size(iCoordinate, 0), MapMode(MapUnit::MapAppFont));
+ int iPixelCoordinate = aLocSize.Width();
+ return iPixelCoordinate;
+ }
+
+ void OWizardMachine::ImplPosTabPage()
+ {
+ if ( !mpCurTabPage )
+ return;
+
+ if ( !IsInInitShow() )
+ {
+ // #100199# - On Unix initial size is equal to screen size, on Windows
+ // it's 0,0. One cannot calculate the size unless dialog is visible.
+ if ( !IsReallyVisible() )
+ return;
+ }
+
+ // calculate height of ButtonBar
+ long nMaxHeight = 0;
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData )
+ {
+ long nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
+ if ( nBtnHeight > nMaxHeight )
+ nMaxHeight = nBtnHeight;
+ pBtnData = pBtnData->mpNext;
+ }
+ if ( nMaxHeight )
+ nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
+
+ // position TabPage
+ Size aDlgSize = GetOutputSizePixel();
+ aDlgSize.AdjustHeight( -nMaxHeight );
+ long nOffX = 0;
+ long nOffY = 0;
+ if ( mpViewWindow && mpViewWindow->IsVisible() )
+ {
+ Size aViewSize = mpViewWindow->GetSizePixel();
+ if ( meViewAlign == WindowAlign::Top )
+ {
+ nOffY += aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ aDlgSize.AdjustHeight( -(aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y) );
+ }
+ else if ( meViewAlign == WindowAlign::Left )
+ {
+ long nViewOffset = mbEmptyViewMargin ? 0 : WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nOffX += aViewSize.Width() + nViewOffset;
+ aDlgSize.AdjustWidth( -nOffX );
+ }
+ else if ( meViewAlign == WindowAlign::Bottom )
+ aDlgSize.AdjustHeight( -(aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y) );
+ else if ( meViewAlign == WindowAlign::Right )
+ aDlgSize.AdjustWidth( -(aViewSize.Width()+WIZARDDIALOG_VIEW_DLGOFFSET_X) );
+ }
+ Point aPos( nOffX, nOffY );
+ mpCurTabPage->SetPosSizePixel( aPos, aDlgSize );
+ }
+
+ void OWizardMachine::ImplShowTabPage( TabPage* pTabPage )
+ {
+ if ( mpCurTabPage == pTabPage )
+ return;
+
+ TabPage* pOldTabPage = mpCurTabPage;
+ if ( pOldTabPage )
+ pOldTabPage->DeactivatePage();
+
+ mpCurTabPage = pTabPage;
+ if ( pTabPage )
+ {
+ ImplPosTabPage();
+ pTabPage->ActivatePage();
+ pTabPage->Show();
+ }
+
+ if ( pOldTabPage )
+ pOldTabPage->Hide();
+ }
+
+ TabPage* OWizardMachine::ImplGetPage( sal_uInt16 nLevel ) const
+ {
+ sal_uInt16 nTempLevel = 0;
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( (nTempLevel == nLevel) || !pPageData->mpNext )
+ break;
+
+ nTempLevel++;
+ pPageData = pPageData->mpNext;
+ }
+
+ if ( pPageData )
+ return pPageData->mpPage;
+ return nullptr;
+ }
+
+ OWizardMachine::OWizardMachine(vcl::Window* pParent, WizardButtonFlags _nButtonFlags)
+ :ModalDialog(pParent, "WizardDialog", "svt/ui/wizarddialog.ui")
,m_pFinish(nullptr)
,m_pCancel(nullptr)
,m_pNextPage(nullptr)
@@ -119,10 +412,11 @@ namespace vcl
,m_pHelp(nullptr)
,m_pImpl( new WizardMachineImplData )
{
+ ImplInitData();
+
implConstruct( _nButtonFlags );
}
-
void OWizardMachine::implConstruct( const WizardButtonFlags _nButtonFlags )
{
m_pImpl->sTitleBase = GetText();
@@ -219,9 +513,33 @@ namespace vcl
m_pImpl.reset();
}
- WizardDialog::dispose();
+ maWizardLayoutIdle.Stop();
+
+ // Remove all buttons
+ while ( mpFirstBtn )
+ RemoveButton( mpFirstBtn->mpButton );
+
+ // Remove all pages
+ while ( mpFirstPage )
+ RemovePage( mpFirstPage->mpPage );
+
+ mpCurTabPage.clear();
+ mpPrevBtn.clear();
+ mpNextBtn.clear();
+ mpViewWindow.clear();
+ ModalDialog::dispose();
}
+ void OWizardMachine::Resize()
+ {
+ if ( IsReallyShown() && !IsInInitShow() )
+ {
+ ImplPosCtrls();
+ ImplPosTabPage();
+ }
+
+ ModalDialog::Resize();
+ }
void OWizardMachine::implUpdateTitle()
{
@@ -237,6 +555,90 @@ namespace vcl
SetText(sCompleteTitle);
}
+ void OWizardMachine::CalcAndSetSize()
+ {
+ Size aDlgSize = GetPageSizePixel();
+ if ( !aDlgSize.Width() || !aDlgSize.Height() )
+ {
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( pPageData->mpPage )
+ {
+ Size aPageSize = pPageData->mpPage->GetSizePixel();
+ if ( aPageSize.Width() > aDlgSize.Width() )
+ aDlgSize.setWidth( aPageSize.Width() );
+ if ( aPageSize.Height() > aDlgSize.Height() )
+ aDlgSize.setHeight( aPageSize.Height() );
+ }
+
+ pPageData = pPageData->mpNext;
+ }
+ }
+ ImplCalcSize( aDlgSize );
+ SetOutputSizePixel( aDlgSize );
+ }
+
+ void OWizardMachine::StateChanged( StateChangedType nType )
+ {
+ if ( nType == StateChangedType::InitShow )
+ {
+ if ( IsDefaultSize() )
+ {
+ CalcAndSetSize();
+ }
+
+ ImplPosCtrls();
+ ImplPosTabPage();
+ ImplShowTabPage( ImplGetPage( mnCurLevel ) );
+ }
+
+ ModalDialog::StateChanged( nType );
+ }
+
+ bool OWizardMachine::EventNotify( NotifyEvent& rNEvt )
+ {
+ if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && mpPrevBtn && mpNextBtn )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
+ sal_uInt16 nKeyCode = aKeyCode.GetCode();
+
+ if ( aKeyCode.IsMod1() )
+ {
+ if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
+ {
+ if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
+ {
+ if ( mpPrevBtn->IsVisible() &&
+ mpPrevBtn->IsEnabled() && mpPrevBtn->IsInputEnabled() )
+ {
+ mpPrevBtn->SetPressed( true );
+ mpPrevBtn->SetPressed( false );
+ mpPrevBtn->Click();
+ }
+ return true;
+ }
+ }
+ else
+ {
+ if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
+ {
+ if ( mpNextBtn->IsVisible() &&
+ mpNextBtn->IsEnabled() && mpNextBtn->IsInputEnabled() )
+ {
+ mpNextBtn->SetPressed( true );
+ mpNextBtn->SetPressed( false );
+ mpNextBtn->Click();
+ }
+ return true;
+ }
+ }
+ }
+ }
+
+ return ModalDialog::EventNotify( rNEvt );
+ }
void OWizardMachine::setTitleBase(const OUString& _rTitleBase)
{
@@ -272,10 +674,9 @@ namespace vcl
return GetPage( i_nState );
}
-
void OWizardMachine::ActivatePage()
{
- WizardDialog::ActivatePage();
+ maActivateHdl.Call( this );
WizardState nCurrentLevel = GetCurLevel();
GetOrCreatePage( nCurrentLevel );
@@ -283,14 +684,12 @@ namespace vcl
enterState( nCurrentLevel );
}
-
bool OWizardMachine::DeactivatePage()
{
WizardState nCurrentState = getCurrentState();
- return leaveState(nCurrentState) && WizardDialog::DeactivatePage();
+ return leaveState(nCurrentState);
}
-
void OWizardMachine::defaultButton(WizardButtonFlags _nWizardButtonFlags)
{
// the new default button
@@ -312,6 +711,166 @@ namespace vcl
implResetDefault( this );
}
+ bool OWizardMachine::ShowNextPage()
+ {
+ return ShowPage( mnCurLevel+1 );
+ }
+
+ bool OWizardMachine::ShowPrevPage()
+ {
+ if ( !mnCurLevel )
+ return false;
+ return ShowPage( mnCurLevel-1 );
+ }
+
+ bool OWizardMachine::ShowPage( sal_uInt16 nLevel )
+ {
+ if ( DeactivatePage() )
+ {
+ mnCurLevel = nLevel;
+ ActivatePage();
+ ImplShowTabPage( ImplGetPage( mnCurLevel ) );
+ return true;
+ }
+ else
+ return false;
+ }
+
+ bool OWizardMachine::Finish( long nResult )
+ {
+ if ( DeactivatePage() )
+ {
+ if ( mpCurTabPage )
+ mpCurTabPage->DeactivatePage();
+
+ if ( IsInExecute() )
+ EndDialog( nResult );
+ else if ( GetStyle() & WB_CLOSEABLE )
+ Close();
+ return true;
+ }
+ else
+ return false;
+ }
+
+ void OWizardMachine::AddPage( TabPage* pPage )
+ {
+ ImplWizPageData* pNewPageData = new ImplWizPageData;
+ pNewPageData->mpNext = nullptr;
+ pNewPageData->mpPage = pPage;
+
+ if ( !mpFirstPage )
+ mpFirstPage = pNewPageData;
+ else
+ {
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData->mpNext )
+ pPageData = pPageData->mpNext;
+ pPageData->mpNext = pNewPageData;
+ }
+ }
+
+ void OWizardMachine::RemovePage( TabPage* pPage )
+ {
+ ImplWizPageData* pPrevPageData = nullptr;
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( pPageData->mpPage == pPage )
+ {
+ if ( pPrevPageData )
+ pPrevPageData->mpNext = pPageData->mpNext;
+ else
+ mpFirstPage = pPageData->mpNext;
+ if ( pPage == mpCurTabPage )
+ mpCurTabPage = nullptr;
+ delete pPageData;
+ return;
+ }
+
+ pPrevPageData = pPageData;
+ pPageData = pPageData->mpNext;
+ }
+
+ OSL_FAIL( "OWizardMachine::RemovePage() - Page not in list" );
+ }
+
+ void OWizardMachine::SetPage( sal_uInt16 nLevel, TabPage* pPage )
+ {
+ sal_uInt16 nTempLevel = 0;
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( (nTempLevel == nLevel) || !pPageData->mpNext )
+ break;
+
+ nTempLevel++;
+ pPageData = pPageData->mpNext;
+ }
+
+ if ( pPageData )
+ {
+ if ( pPageData->mpPage == mpCurTabPage )
+ mpCurTabPage = nullptr;
+ pPageData->mpPage = pPage;
+ }
+ }
+
+ TabPage* OWizardMachine::GetPage( sal_uInt16 nLevel ) const
+ {
+ sal_uInt16 nTempLevel = 0;
+
+ for (ImplWizPageData* pPageData = mpFirstPage; pPageData;
+ pPageData = pPageData->mpNext)
+ {
+ if ( nTempLevel == nLevel )
+ return pPageData->mpPage;
+ nTempLevel++;
+ }
+
+ return nullptr;
+ }
+
+ void OWizardMachine::AddButton( Button* pButton, long nOffset )
+ {
+ ImplWizButtonData* pNewBtnData = new ImplWizButtonData;
+ pNewBtnData->mpNext = nullptr;
+ pNewBtnData->mpButton = pButton;
+ pNewBtnData->mnOffset = nOffset;
+
+ if ( !mpFirstBtn )
+ mpFirstBtn = pNewBtnData;
+ else
+ {
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData->mpNext )
+ pBtnData = pBtnData->mpNext;
+ pBtnData->mpNext = pNewBtnData;
+ }
+ }
+
+ void OWizardMachine::RemoveButton( Button* pButton )
+ {
+ ImplWizButtonData* pPrevBtnData = nullptr;
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData )
+ {
+ if ( pBtnData->mpButton == pButton )
+ {
+ if ( pPrevBtnData )
+ pPrevBtnData->mpNext = pBtnData->mpNext;
+ else
+ mpFirstBtn = pBtnData->mpNext;
+ delete pBtnData;
+ return;
+ }
+
+ pPrevBtnData = pBtnData;
+ pBtnData = pBtnData->mpNext;
+ }
+
+ OSL_FAIL( "OWizardMachine::RemoveButton() - Button not in list" );
+ }
void OWizardMachine::implResetDefault(vcl::Window const * _pWindow)
{
diff --git a/vcl/source/control/wizdlg.cxx b/vcl/source/control/wizdlg.cxx
deleted file mode 100644
index 54b0e1f3df8a..000000000000
--- a/vcl/source/control/wizdlg.cxx
+++ /dev/null
@@ -1,646 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <osl/diagnose.h>
-#include <vcl/event.hxx>
-#include <vcl/button.hxx>
-#include <vcl/tabpage.hxx>
-#include <vcl/wizdlg.hxx>
-
-
-#define WIZARDDIALOG_BUTTON_OFFSET_Y 6
-#define WIZARDDIALOG_BUTTON_DLGOFFSET_X 6
-#define WIZARDDIALOG_VIEW_DLGOFFSET_X 6
-#define WIZARDDIALOG_VIEW_DLGOFFSET_Y 6
-
-
-struct ImplWizPageData
-{
- ImplWizPageData* mpNext;
- VclPtr<TabPage> mpPage;
-};
-
-
-struct ImplWizButtonData
-{
- ImplWizButtonData* mpNext;
- VclPtr<Button> mpButton;
- long mnOffset;
-};
-
-
-void WizardDialog::ImplInitData()
-{
- mpFirstPage = nullptr;
- mpFirstBtn = nullptr;
- mpCurTabPage = nullptr;
- mpPrevBtn = nullptr;
- mpNextBtn = nullptr;
- mpViewWindow = nullptr;
- mnCurLevel = 0;
- meViewAlign = WindowAlign::Left;
- mbEmptyViewMargin = false;
- mnLeftAlignCount = 0;
-
- maWizardLayoutIdle.SetPriority(TaskPriority::RESIZE);
- maWizardLayoutIdle.SetInvokeHandler( LINK( this, WizardDialog, ImplHandleWizardLayoutTimerHdl ) );
-}
-
-
-void WizardDialog::SetLeftAlignedButtonCount( sal_Int16 _nCount )
-{
- mnLeftAlignCount = _nCount;
-}
-
-
-void WizardDialog::SetEmptyViewMargin()
-{
- mbEmptyViewMargin = true;
-}
-
-
-void WizardDialog::ImplCalcSize( Size& rSize )
-{
- // calculate ButtonBar height
- long nMaxHeight = 0;
- ImplWizButtonData* pBtnData = mpFirstBtn;
- while ( pBtnData )
- {
- long nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
- if ( nBtnHeight > nMaxHeight )
- nMaxHeight = nBtnHeight;
- pBtnData = pBtnData->mpNext;
- }
- if ( nMaxHeight )
- nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
- rSize.AdjustHeight(nMaxHeight );
-
- // add in the view window size
- if ( mpViewWindow && mpViewWindow->IsVisible() )
- {
- Size aViewSize = mpViewWindow->GetSizePixel();
- if ( meViewAlign == WindowAlign::Top )
- rSize.AdjustHeight(aViewSize.Height() );
- else if ( meViewAlign == WindowAlign::Left )
- rSize.AdjustWidth(aViewSize.Width() );
- else if ( meViewAlign == WindowAlign::Bottom )
- rSize.AdjustHeight(aViewSize.Height() );
- else if ( meViewAlign == WindowAlign::Right )
- rSize.AdjustWidth(aViewSize.Width() );
- }
-}
-
-void WizardDialog::queue_resize(StateChangedType /*eReason*/)
-{
- if (maWizardLayoutIdle.IsActive())
- return;
- if (IsInClose())
- return;
- maWizardLayoutIdle.Start();
-}
-
-IMPL_LINK_NOARG( WizardDialog, ImplHandleWizardLayoutTimerHdl, Timer*, void )
-{
- ImplPosCtrls();
- ImplPosTabPage();
-}
-
-void WizardDialog::ImplPosCtrls()
-{
- Size aDlgSize = GetOutputSizePixel();
- long nBtnWidth = 0;
- long nMaxHeight = 0;
- long nOffY = aDlgSize.Height();
-
- ImplWizButtonData* pBtnData = mpFirstBtn;
- int j = 0;
- while ( pBtnData )
- {
- if (j >= mnLeftAlignCount)
- {
- Size aBtnSize = pBtnData->mpButton->GetSizePixel();
- long nBtnHeight = aBtnSize.Height();
- if ( nBtnHeight > nMaxHeight )
- nMaxHeight = nBtnHeight;
- nBtnWidth += aBtnSize.Width();
- nBtnWidth += pBtnData->mnOffset;
- }
- pBtnData = pBtnData->mpNext;
- j++;
- }
-
- if ( nMaxHeight )
- {
- long nOffX = aDlgSize.Width()-nBtnWidth-WIZARDDIALOG_BUTTON_DLGOFFSET_X;
- long nOffLeftAlignX = LogicalCoordinateToPixel(6);
- nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y+nMaxHeight;
-
- pBtnData = mpFirstBtn;
- int i = 0;
- while ( pBtnData )
- {
- Size aBtnSize = pBtnData->mpButton->GetSizePixel();
- if (i >= mnLeftAlignCount)
- {
- Point aPos( nOffX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
- pBtnData->mpButton->SetPosPixel( aPos );
- nOffX += aBtnSize.Width();
- nOffX += pBtnData->mnOffset;
- }
- else
- {
- Point aPos( nOffLeftAlignX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
- pBtnData->mpButton->SetPosPixel( aPos );
- nOffLeftAlignX += aBtnSize.Width();
- nOffLeftAlignX += pBtnData->mnOffset;
- }
-
- pBtnData = pBtnData->mpNext;
- i++;
- }
-
- nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y;
- }
-
- if ( !(mpViewWindow && mpViewWindow->IsVisible()) )
- return;
-
- long nViewOffX = 0;
- long nViewOffY = 0;
- long nViewWidth = 0;
- long nViewHeight = 0;
- long nDlgHeight = nOffY;
- PosSizeFlags nViewPosFlags = PosSizeFlags::Pos;
- if ( meViewAlign == WindowAlign::Top )
- {
- nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
- nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
- nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2);
- nViewPosFlags |= PosSizeFlags::Width;
- }
- else if ( meViewAlign == WindowAlign::Left )
- {
- if ( mbEmptyViewMargin )
- {
- nViewOffX = 0;
- nViewOffY = 0;
- nViewHeight = nDlgHeight;
- }
- else
- {
- nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
- nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
- nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2);
- }
- nViewPosFlags |= PosSizeFlags::Height;
- }
- else if ( meViewAlign == WindowAlign::Bottom )
- {
- nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
- nViewOffY = nDlgHeight-mpViewWindow->GetSizePixel().Height()-WIZARDDIALOG_VIEW_DLGOFFSET_Y;
- nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2);
- nViewPosFlags |= PosSizeFlags::Width;
- }
- else if ( meViewAlign == WindowAlign::Right )
- {
- nViewOffX = aDlgSize.Width()-mpViewWindow->GetSizePixel().Width()-WIZARDDIALOG_VIEW_DLGOFFSET_X;
- nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
- nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2);
- nViewPosFlags |= PosSizeFlags::Height;
- }
- mpViewWindow->setPosSizePixel( nViewOffX, nViewOffY,
- nViewWidth, nViewHeight,
- nViewPosFlags );
-}
-
-
-long WizardDialog::LogicalCoordinateToPixel(int iCoordinate){
- Size aLocSize = LogicToPixel(Size(iCoordinate, 0), MapMode(MapUnit::MapAppFont));
- int iPixelCoordinate = aLocSize.Width();
- return iPixelCoordinate;
-}
-
-
-void WizardDialog::ImplPosTabPage()
-{
- if ( !mpCurTabPage )
- return;
-
- if ( !IsInInitShow() )
- {
- // #100199# - On Unix initial size is equal to screen size, on Windows
- // it's 0,0. One cannot calculate the size unless dialog is visible.
- if ( !IsReallyVisible() )
- return;
- }
-
- // calculate height of ButtonBar
- long nMaxHeight = 0;
- ImplWizButtonData* pBtnData = mpFirstBtn;
- while ( pBtnData )
- {
- long nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
- if ( nBtnHeight > nMaxHeight )
- nMaxHeight = nBtnHeight;
- pBtnData = pBtnData->mpNext;
- }
- if ( nMaxHeight )
- nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
-
- // position TabPage
- Size aDlgSize = GetOutputSizePixel();
- aDlgSize.AdjustHeight( -nMaxHeight );
- long nOffX = 0;
- long nOffY = 0;
- if ( mpViewWindow && mpViewWindow->IsVisible() )
- {
- Size aViewSize = mpViewWindow->GetSizePixel();
- if ( meViewAlign == WindowAlign::Top )
- {
- nOffY += aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y;
- aDlgSize.AdjustHeight( -(aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y) );
- }
- else if ( meViewAlign == WindowAlign::Left )
- {
- long nViewOffset = mbEmptyViewMargin ? 0 : WIZARDDIALOG_VIEW_DLGOFFSET_X;
- nOffX += aViewSize.Width() + nViewOffset;
- aDlgSize.AdjustWidth( -nOffX );
- }
- else if ( meViewAlign == WindowAlign::Bottom )
- aDlgSize.AdjustHeight( -(aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y) );
- else if ( meViewAlign == WindowAlign::Right )
- aDlgSize.AdjustWidth( -(aViewSize.Width()+WIZARDDIALOG_VIEW_DLGOFFSET_X) );
- }
- Point aPos( nOffX, nOffY );
- mpCurTabPage->SetPosSizePixel( aPos, aDlgSize );
-}
-
-
-void WizardDialog::ImplShowTabPage( TabPage* pTabPage )
-{
- if ( mpCurTabPage == pTabPage )
- return;
-
- TabPage* pOldTabPage = mpCurTabPage;
- if ( pOldTabPage )
- pOldTabPage->DeactivatePage();
-
- mpCurTabPage = pTabPage;
- if ( pTabPage )
- {
- ImplPosTabPage();
- pTabPage->ActivatePage();
- pTabPage->Show();
- }
-
- if ( pOldTabPage )
- pOldTabPage->Hide();
-}
-
-
-TabPage* WizardDialog::ImplGetPage( sal_uInt16 nLevel ) const
-{
- sal_uInt16 nTempLevel = 0;
- ImplWizPageData* pPageData = mpFirstPage;
- while ( pPageData )
- {
- if ( (nTempLevel == nLevel) || !pPageData->mpNext )
- break;
-
- nTempLevel++;
- pPageData = pPageData->mpNext;
- }
-
- if ( pPageData )
- return pPageData->mpPage;
- return nullptr;
-}
-
-WizardDialog::WizardDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription ) :
- ModalDialog( pParent, rID, rUIXMLDescription )
-{
- ImplInitData();
-}
-
-WizardDialog::~WizardDialog()
-{
- disposeOnce();
-}
-
-void WizardDialog::dispose()
-{
- maWizardLayoutIdle.Stop();
-
- // Remove all buttons
- while ( mpFirstBtn )
- RemoveButton( mpFirstBtn->mpButton );
-
- // Remove all pages
- while ( mpFirstPage )
- RemovePage( mpFirstPage->mpPage );
-
- mpCurTabPage.clear();
- mpPrevBtn.clear();
- mpNextBtn.clear();
- mpViewWindow.clear();
- ModalDialog::dispose();
-}
-
-
-void WizardDialog::Resize()
-{
- if ( IsReallyShown() && !IsInInitShow() )
- {
- ImplPosCtrls();
- ImplPosTabPage();
- }
-
- Dialog::Resize();
-}
-
-void WizardDialog::CalcAndSetSize()
-{
- Size aDlgSize = GetPageSizePixel();
- if ( !aDlgSize.Width() || !aDlgSize.Height() )
- {
- ImplWizPageData* pPageData = mpFirstPage;
- while ( pPageData )
- {
- if ( pPageData->mpPage )
- {
- Size aPageSize = pPageData->mpPage->GetSizePixel();
- if ( aPageSize.Width() > aDlgSize.Width() )
- aDlgSize.setWidth( aPageSize.Width() );
- if ( aPageSize.Height() > aDlgSize.Height() )
- aDlgSize.setHeight( aPageSize.Height() );
- }
-
- pPageData = pPageData->mpNext;
- }
- }
- ImplCalcSize( aDlgSize );
- SetOutputSizePixel( aDlgSize );
-}
-
-void WizardDialog::StateChanged( StateChangedType nType )
-{
- if ( nType == StateChangedType::InitShow )
- {
- if ( IsDefaultSize() )
- {
- CalcAndSetSize();
- }
-
- ImplPosCtrls();
- ImplPosTabPage();
- ImplShowTabPage( ImplGetPage( mnCurLevel ) );
- }
-
- Dialog::StateChanged( nType );
-}
-
-
-bool WizardDialog::EventNotify( NotifyEvent& rNEvt )
-{
- if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && mpPrevBtn && mpNextBtn )
- {
- const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
- vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
- sal_uInt16 nKeyCode = aKeyCode.GetCode();
-
- if ( aKeyCode.IsMod1() )
- {
- if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
- {
- if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
- {
- if ( mpPrevBtn->IsVisible() &&
- mpPrevBtn->IsEnabled() && mpPrevBtn->IsInputEnabled() )
- {
- mpPrevBtn->SetPressed( true );
- mpPrevBtn->SetPressed( false );
- mpPrevBtn->Click();
- }
- return true;
- }
- }
- else
- {
- if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
- {
- if ( mpNextBtn->IsVisible() &&
- mpNextBtn->IsEnabled() && mpNextBtn->IsInputEnabled() )
- {
- mpNextBtn->SetPressed( true );
- mpNextBtn->SetPressed( false );
- mpNextBtn->Click();
- }
- return true;
- }
- }
- }
- }
-
- return Dialog::EventNotify( rNEvt );
-}
-
-
-void WizardDialog::ActivatePage()
-{
- maActivateHdl.Call( this );
-}
-
-
-bool WizardDialog::DeactivatePage()
-{
- return true;
-}
-
-
-bool WizardDialog::ShowNextPage()
-{
- return ShowPage( mnCurLevel+1 );
-}
-
-
-bool WizardDialog::ShowPrevPage()
-{
- if ( !mnCurLevel )
- return false;
- return ShowPage( mnCurLevel-1 );
-}
-
-
-bool WizardDialog::ShowPage( sal_uInt16 nLevel )
-{
- if ( DeactivatePage() )
- {
- mnCurLevel = nLevel;
- ActivatePage();
- ImplShowTabPage( ImplGetPage( mnCurLevel ) );
- return true;
- }
- else
- return false;
-}
-
-
-bool WizardDialog::Finish( long nResult )
-{
- if ( DeactivatePage() )
- {
- if ( mpCurTabPage )
- mpCurTabPage->DeactivatePage();
-
- if ( IsInExecute() )
- EndDialog( nResult );
- else if ( GetStyle() & WB_CLOSEABLE )
- Close();
- return true;
- }
- else
- return false;
-}
-
-
-void WizardDialog::AddPage( TabPage* pPage )
-{
- ImplWizPageData* pNewPageData = new ImplWizPageData;
- pNewPageData->mpNext = nullptr;
- pNewPageData->mpPage = pPage;
-
- if ( !mpFirstPage )
- mpFirstPage = pNewPageData;
- else
- {
- ImplWizPageData* pPageData = mpFirstPage;
- while ( pPageData->mpNext )
- pPageData = pPageData->mpNext;
- pPageData->mpNext = pNewPageData;
- }
-}
-
-
-void WizardDialog::RemovePage( TabPage* pPage )
-{
- ImplWizPageData* pPrevPageData = nullptr;
- ImplWizPageData* pPageData = mpFirstPage;
- while ( pPageData )
- {
- if ( pPageData->mpPage == pPage )
- {
- if ( pPrevPageData )
- pPrevPageData->mpNext = pPageData->mpNext;
- else
- mpFirstPage = pPageData->mpNext;
- if ( pPage == mpCurTabPage )
- mpCurTabPage = nullptr;
- delete pPageData;
- return;
- }
-
- pPrevPageData = pPageData;
- pPageData = pPageData->mpNext;
- }
-
- OSL_FAIL( "WizardDialog::RemovePage() - Page not in list" );
-}
-
-
-void WizardDialog::SetPage( sal_uInt16 nLevel, TabPage* pPage )
-{
- sal_uInt16 nTempLevel = 0;
- ImplWizPageData* pPageData = mpFirstPage;
- while ( pPageData )
- {
- if ( (nTempLevel == nLevel) || !pPageData->mpNext )
- break;
-
- nTempLevel++;
- pPageData = pPageData->mpNext;
- }
-
- if ( pPageData )
- {
- if ( pPageData->mpPage == mpCurTabPage )
- mpCurTabPage = nullptr;
- pPageData->mpPage = pPage;
- }
-}
-
-
-TabPage* WizardDialog::GetPage( sal_uInt16 nLevel ) const
-{
- sal_uInt16 nTempLevel = 0;
-
- for (ImplWizPageData* pPageData = mpFirstPage; pPageData;
- pPageData = pPageData->mpNext)
- {
- if ( nTempLevel == nLevel )
- return pPageData->mpPage;
- nTempLevel++;
- }
-
- return nullptr;
-}
-
-
-void WizardDialog::AddButton( Button* pButton, long nOffset )
-{
- ImplWizButtonData* pNewBtnData = new ImplWizButtonData;
- pNewBtnData->mpNext = nullptr;
- pNewBtnData->mpButton = pButton;
- pNewBtnData->mnOffset = nOffset;
-
- if ( !mpFirstBtn )
- mpFirstBtn = pNewBtnData;
- else
- {
- ImplWizButtonData* pBtnData = mpFirstBtn;
- while ( pBtnData->mpNext )
- pBtnData = pBtnData->mpNext;
- pBtnData->mpNext = pNewBtnData;
- }
-}
-
-
-void WizardDialog::RemoveButton( Button* pButton )
-{
- ImplWizButtonData* pPrevBtnData = nullptr;
- ImplWizButtonData* pBtnData = mpFirstBtn;
- while ( pBtnData )
- {
- if ( pBtnData->mpButton == pButton )
- {
- if ( pPrevBtnData )
- pPrevBtnData->mpNext = pBtnData->mpNext;
- else
- mpFirstBtn = pBtnData->mpNext;
- delete pBtnData;
- return;
- }
-
- pPrevBtnData = pBtnData;
- pBtnData = pBtnData->mpNext;
- }
-
- OSL_FAIL( "WizardDialog::RemoveButton() - Button not in list" );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list