diff options
-rw-r--r-- | cui/source/inc/chardlg.hxx | 22 | ||||
-rw-r--r-- | sfx2/inc/sfx2/tabdlg.hxx | 6 | ||||
-rw-r--r-- | sw/source/ui/inc/chrdlg.hxx | 4 | ||||
-rw-r--r-- | sw/source/ui/inc/wordcountdialog.hxx | 26 | ||||
-rw-r--r-- | vcl/inc/vcl/layout.hxx | 67 | ||||
-rw-r--r-- | vcl/source/control/button.cxx | 16 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 40 | ||||
-rw-r--r-- | vcl/source/window/dlgctrl.cxx | 9 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 35 | ||||
-rw-r--r-- | vcl/source/window/tabpage.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 2 |
11 files changed, 137 insertions, 92 deletions
diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index 05a1eaeb7030..5366de7a5ece 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -90,8 +90,8 @@ class SvxCharNamePage : public SvxCharBasePage { private: - VBox m_aBox; - Grid m_aGrid; + VclVBox m_aBox; + VclGrid m_aGrid; FixedLine* m_pWestLine; FixedText* m_pWestFontNameFT; @@ -192,8 +192,8 @@ class SvxCharEffectsPage : public SvxCharBasePage { private: - VBox m_aBox; - Grid m_aGrid; + VclVBox m_aBox; + VclGrid m_aGrid; FixedText m_aFontColorFT; ColorListBox m_aFontColorLB; @@ -278,11 +278,11 @@ class SvxCharPositionPage : public SvxCharBasePage { private: - VBox m_aBox; + VclVBox m_aBox; FixedLine m_aPositionLine; - Grid m_aPositionGrid; + VclGrid m_aPositionGrid; RadioButton m_aHighPosBtn; RadioButton m_aNormalPosBtn; RadioButton m_aLowPosBtn; @@ -294,20 +294,20 @@ private: FixedLine m_aRotationScalingFL; - HBox m_aRotationBox; + VclHBox m_aRotationBox; FixedLine m_aScalingFL; RadioButton m_a0degRB; RadioButton m_a90degRB; RadioButton m_a270degRB; CheckBox m_aFitToLineCB; - HBox m_aScaleBox; + VclHBox m_aScaleBox; FixedText m_aScaleWidthFT; MetricField m_aScaleWidthMF; FixedLine m_aKerningLine; - HBox m_aKerningBox; + VclHBox m_aKerningBox; ListBox m_aKerningLB; FixedText m_aKerningFT; MetricField m_aKerningEdit; @@ -364,8 +364,8 @@ public: class SvxCharTwoLinesPage : public SvxCharBasePage { private: - VBox m_aBox; - Grid m_aGrid; + VclVBox m_aBox; + VclGrid m_aGrid; FixedLine m_aSwitchOnLine; CheckBox m_aTwoLinesBtn; diff --git a/sfx2/inc/sfx2/tabdlg.hxx b/sfx2/inc/sfx2/tabdlg.hxx index 69fd8c2b61cf..b7d682ddb8b8 100644 --- a/sfx2/inc/sfx2/tabdlg.hxx +++ b/sfx2/inc/sfx2/tabdlg.hxx @@ -65,11 +65,11 @@ friend class SfxTabDialogController; SfxViewFrame* pFrame; - VBox vbox; - VBox content_area; + VclVBox vbox; + VclVBox content_area; TabControl aTabCtrl; - HButtonBox action_area; + VclHButtonBox action_area; OKButton aOKBtn; PushButton* pUserBtn; CancelButton aCancelBtn; diff --git a/sw/source/ui/inc/chrdlg.hxx b/sw/source/ui/inc/chrdlg.hxx index dcefa97f1af4..729a00484fbd 100644 --- a/sw/source/ui/inc/chrdlg.hxx +++ b/sw/source/ui/inc/chrdlg.hxx @@ -60,8 +60,8 @@ public: class SwCharURLPage : public SfxTabPage { - VBox m_aBox; - Grid m_aGrid; + VclVBox m_aBox; + VclGrid m_aGrid; FixedLine aURLFL; diff --git a/sw/source/ui/inc/wordcountdialog.hxx b/sw/source/ui/inc/wordcountdialog.hxx index 5caa4b7625aa..02015c19b8aa 100644 --- a/sw/source/ui/inc/wordcountdialog.hxx +++ b/sw/source/ui/inc/wordcountdialog.hxx @@ -37,42 +37,42 @@ struct SwDocStat; class SwWordCountDialog { - VBox vbox; - VBox content_area; + VclVBox vbox; + VclVBox content_area; - HBox aCurrentSelection; + VclHBox aCurrentSelection; FixedText aCurrentSelectionText; FixedLine aCurrentSelectionLine; - VBox aSelectionBox; - HBox aSelectionRow1; + VclVBox aSelectionBox; + VclHBox aSelectionRow1; FixedText aCurrentWordFT; FixedInfo aCurrentWordFI; - HBox aSelectionRow2; + VclHBox aSelectionRow2; FixedText aCurrentCharacterFT; FixedInfo aCurrentCharacterFI; - HBox aSelectionRow3; + VclHBox aSelectionRow3; FixedText aCurrentCharacterExcludingSpacesFT; FixedInfo aCurrentCharacterExcludingSpacesFI; - HBox aDoc; + VclHBox aDoc; FixedText aDocText; FixedLine aDocLine; - VBox aDocBox; - HBox aDocRow1; + VclVBox aDocBox; + VclHBox aDocRow1; FixedText aDocWordFT; FixedInfo aDocWordFI; - HBox aDocRow2; + VclHBox aDocRow2; FixedText aDocCharacterFT; FixedInfo aDocCharacterFI; - HBox aDocRow3; + VclHBox aDocRow3; FixedText aDocCharacterExcludingSpacesFT; FixedInfo aDocCharacterExcludingSpacesFI; FixedLine aBottomFL; - HButtonBox action_area; + VclHButtonBox action_area; OKButton aOK; HelpButton aHelp; diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index b9885c6af1e2..fc7e0a1d69d1 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -32,20 +32,29 @@ #include <vcl/window.hxx> #include <boost/multi_array.hpp> +class VCL_DLLPUBLIC VclContainer : public Window +{ +public: + VclContainer(Window *pParent) : Window(pParent) {} +protected: + virtual Size calculateRequisition() const = 0; + virtual void setAllocation(const Size &rAllocation) = 0; +}; + enum VclPackType { VCL_PACK_START = 0, VCL_PACK_END = 1 }; -class VCL_DLLPUBLIC Box : public Window +class VCL_DLLPUBLIC VclBox : public VclContainer { protected: bool m_bHomogeneous; int m_nSpacing; public: - Box(Window *pParent, bool bHomogeneous, int nSpacing) - : Window(pParent) + VclBox(Window *pParent, bool bHomogeneous, int nSpacing) + : VclContainer(pParent) , m_bHomogeneous(bHomogeneous) , m_nSpacing(nSpacing) { @@ -69,11 +78,11 @@ protected: virtual void setSecondaryCoordinate(Point &rPos, long) const = 0; }; -class VCL_DLLPUBLIC VBox : public Box +class VCL_DLLPUBLIC VclVBox : public VclBox { public: - VBox(Window *pParent, bool bHomogeneous = false, int nSpacing = 0) - : Box(pParent, bHomogeneous, nSpacing) + VclVBox(Window *pParent, bool bHomogeneous = false, int nSpacing = 0) + : VclBox(pParent, bHomogeneous, nSpacing) { } protected: @@ -111,11 +120,11 @@ protected: } }; -class VCL_DLLPUBLIC HBox : public Box +class VCL_DLLPUBLIC VclHBox : public VclBox { public: - HBox(Window *pParent, bool bHomogeneous = false, int nSpacing = 0) - : Box(pParent, bHomogeneous, nSpacing) + VclHBox(Window *pParent, bool bHomogeneous = false, int nSpacing = 0) + : VclBox(pParent, bHomogeneous, nSpacing) { } protected: @@ -153,11 +162,11 @@ protected: } }; -class VCL_DLLPUBLIC ButtonBox : public Box +class VCL_DLLPUBLIC VclButtonBox : public VclBox { public: - ButtonBox(Window *pParent, int nSpacing) - : Box(pParent, true, nSpacing) + VclButtonBox(Window *pParent, int nSpacing) + : VclBox(pParent, true, nSpacing) { } protected: @@ -165,11 +174,11 @@ protected: virtual void setAllocation(const Size &rAllocation); }; -class VCL_DLLPUBLIC VButtonBox : public ButtonBox +class VCL_DLLPUBLIC VclVButtonBox : public VclButtonBox { public: - VButtonBox(Window *pParent, int nSpacing = 0) - : ButtonBox(pParent, nSpacing) + VclVButtonBox(Window *pParent, int nSpacing = 0) + : VclButtonBox(pParent, nSpacing) { } protected: @@ -207,11 +216,11 @@ protected: } }; -class VCL_DLLPUBLIC HButtonBox : public ButtonBox +class VCL_DLLPUBLIC VclHButtonBox : public VclButtonBox { public: - HButtonBox(Window *pParent, int nSpacing = 0) - : ButtonBox(pParent, nSpacing) + VclHButtonBox(Window *pParent, int nSpacing = 0) + : VclButtonBox(pParent, nSpacing) { } protected: @@ -249,7 +258,7 @@ protected: } }; -class VCL_DLLPUBLIC Grid : public Window +class VCL_DLLPUBLIC VclGrid : public VclContainer { private: bool m_bRowHomogeneous; @@ -262,11 +271,11 @@ private: bool isNullGrid(const array_type& A) const; void calcMaxs(const array_type &A, std::vector<long> &rWidths, std::vector<long> &rHeights) const; - Size calculateRequisition() const; - void setAllocation(const Size &rAllocation); + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); public: - Grid(Window *pParent) - : Window(pParent) + VclGrid(Window *pParent) + : VclContainer(pParent) , m_bRowHomogeneous(false), m_bColumnHomogeneous(false) , m_nRowSpacing(0), m_nColumnSpacing(0) { @@ -313,10 +322,22 @@ public: VCL_DLLPUBLIC void setGridAttach(Window &rWidget, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nWidth = 1, sal_Int32 nHeight = 1); +// retro-fitting utilities // + //Get a Size which is large enough to contain all children with //an equal amount of space at top left and bottom right Size getLegacyBestSizeForChildren(const Window &rWindow); +//Get first parent which is not a layout widget +Window* getLegacyNonLayoutParent(Window *pParent); + +//Get next window after pChild of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(WINDOW_NEXT); +//in a flat hierarchy where dialogs only have one layer +//of children +Window* nextLogicalChildOfParent(Window *pTopLevel, Window *pChild); + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 202490f96bfb..675889dbe444 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1759,25 +1759,13 @@ OKButton::OKButton( Window* pParent, const ResId& rResId ) : // ----------------------------------------------------------------------- -namespace -{ - Window* getFirstNonLayoutParent(Window *pParent) - { - while (pParent && dynamic_cast<const Box*>(pParent)) - { - pParent = pParent->GetParent(); - } - return pParent; - } -} - void OKButton::Click() { SAL_WARN_IF(!GetClickHdl(), "vcl", "No handler installed for OKButton"); // close parent if no link set if ( !GetClickHdl() ) { - Window* pParent = getFirstNonLayoutParent(GetParent()); + Window* pParent = getLegacyNonLayoutParent(GetParent()); if ( pParent->IsSystemWindow() ) { if ( pParent->IsDialog() ) @@ -1844,7 +1832,7 @@ void CancelButton::Click() // close parent if link not set if ( !GetClickHdl() ) { - Window* pParent = getFirstNonLayoutParent(GetParent()); + Window* pParent = getLegacyNonLayoutParent(GetParent()); if ( pParent->IsSystemWindow() ) { if ( pParent->IsDialog() ) diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index d361c40c96bf..3dd5ff149e0d 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -46,6 +46,7 @@ #include <vcl/decoview.hxx> #include <vcl/msgbox.hxx> #include <vcl/unowrap.hxx> +#include <iostream> #ifdef ANDROID #include <osl/detail/android-bootstrap.h> @@ -116,6 +117,31 @@ void ImplHideSplash() pSVData->mpIntroWindow->Hide(); } +//Get next window after pChild of a pTopLevel window as +//if any intermediate layout widgets didn't exist +Window * nextLogicalChildOfParent(Window *pTopLevel, Window *pChild) +{ + Window *pLastChild = pChild; + + if (dynamic_cast<VclContainer*>(pChild)) + pChild = pChild->GetWindow(WINDOW_FIRSTCHILD); + else + pChild = pChild->GetWindow(WINDOW_NEXT); + + while (!pChild) + { + Window *pParent = pLastChild->GetParent(); + if (!pParent) + return NULL; + if (pParent == pTopLevel) + return NULL; + pLastChild = pParent; + pChild = pParent->GetWindow(WINDOW_NEXT); + } + + return pChild; +} + // ----------------------------------------------------------------------- void ImplWindowAutoMnemonic( Window* pWindow ) @@ -130,7 +156,7 @@ void ImplWindowAutoMnemonic( Window* pWindow ) { pChild = pGetChild->ImplGetWindow(); aMnemonicGenerator.RegisterMnemonic( pChild->GetText() ); - pGetChild = pGetChild->GetWindow( WINDOW_NEXT ); + pGetChild = nextLogicalChildOfParent(pWindow, pGetChild); } // Bei TabPages auch noch die Controls vom Dialog beruecksichtigen @@ -147,7 +173,7 @@ void ImplWindowAutoMnemonic( Window* pWindow ) { pChild = pGetChild->ImplGetWindow(); aMnemonicGenerator.RegisterMnemonic( pChild->GetText() ); - pGetChild = pGetChild->GetWindow( WINDOW_NEXT ); + pGetChild = nextLogicalChildOfParent(pWindow, pGetChild); } } } @@ -164,7 +190,7 @@ void ImplWindowAutoMnemonic( Window* pWindow ) pChild->SetText( aText ); } - pGetChild = pGetChild->GetWindow( WINDOW_NEXT ); + pGetChild = nextLogicalChildOfParent(pWindow, pGetChild); } } @@ -173,9 +199,9 @@ static Window* getActionAreaButtonList(Dialog *pDialog) Window* pChild; if (pDialog->isLayoutEnabled()) { - Box *pBox = dynamic_cast<Box*>(pDialog->GetWindow(WINDOW_FIRSTCHILD)); - HButtonBox *pButtonBox = pBox ? - dynamic_cast<HButtonBox*>(pBox->GetWindow(WINDOW_LASTCHILD)) : 0; + VclBox *pBox = dynamic_cast<VclBox*>(pDialog->GetWindow(WINDOW_FIRSTCHILD)); + VclButtonBox *pButtonBox = pBox ? + dynamic_cast<VclButtonBox*>(pBox->GetWindow(WINDOW_LASTCHILD)) : 0; pChild = pButtonBox ? pButtonBox->GetWindow(WINDOW_FIRSTCHILD) : 0; } else @@ -968,7 +994,7 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal bool Dialog::isLayoutEnabled() const { //Has one child, and that child is a container => we're layout enabled - return (GetChildCount() == 1 && dynamic_cast<const Box*>(GetChild(0))); + return (GetChildCount() == 1 && dynamic_cast<const VclContainer*>(GetChild(0))); } Size Dialog::GetOptimalSize(WindowSizeType eType) const diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index f6d96be1f417..ffe3a4ab5988 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -33,6 +33,7 @@ #include <window.h> #include <vcl/event.hxx> +#include <vcl/layout.hxx> #include <vcl/svapp.hxx> #include <vcl/tabpage.hxx> #include <vcl/tabctrl.hxx> @@ -123,7 +124,7 @@ static Window* ImplGetSubChildWindow( Window* pParent, sal_uInt16 n, sal_uInt16& pTabPage = pTempTabPage; break; } - pTempWindow = pTempWindow->GetWindow( WINDOW_NEXT ); + pTempWindow = nextLogicalChildOfParent(pTabControl, pTempWindow); } } } @@ -141,7 +142,7 @@ static Window* ImplGetSubChildWindow( Window* pParent, sal_uInt16 n, sal_uInt16& pWindow = pTabPage; else { - pWindow = pNextWindow->GetWindow( WINDOW_NEXT ); + pWindow = nextLogicalChildOfParent(pParent, pNextWindow); pNextWindow = pWindow; } } @@ -828,7 +829,7 @@ sal_Bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, sal_Bool bKeyInput ) { Window* pWindow; WinBits nStyle; - pWindow = pSWindow->GetWindow( WINDOW_NEXT ); + pWindow = nextLogicalChildOfParent(this, pSWindow); while ( pWindow ) { pWindow = pWindow->ImplGetWindow(); @@ -844,7 +845,7 @@ sal_Bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, sal_Bool bKeyInput ) return sal_True; } - pWindow = pWindow->GetWindow( WINDOW_NEXT ); + pWindow = nextLogicalChildOfParent(this, pWindow); } } else diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 9e3cc6e79c07..f5d8b4124ee5 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -28,7 +28,7 @@ #include <vcl/layout.hxx> -Size Box::calculateRequisition() const +Size VclBox::calculateRequisition() const { long nMaxChildDimension = 0; @@ -76,14 +76,14 @@ Size Box::calculateRequisition() const return aSize; } -Size Box::GetOptimalSize(WindowSizeType eType) const +Size VclBox::GetOptimalSize(WindowSizeType eType) const { if (eType == WINDOWSIZE_MAXIMUM) return Window::GetOptimalSize(eType); return calculateRequisition(); } -void Box::setAllocation(const Size &rAllocation) +void VclBox::setAllocation(const Size &rAllocation) { sal_uInt16 nChildren = GetChildCount(); if (!nChildren) @@ -205,7 +205,7 @@ void Box::setAllocation(const Size &rAllocation) } } -void Box::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation) +void VclBox::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation) { Window::SetPosSizePixel(rAllocPos, rAllocation); setAllocation(rAllocation); @@ -216,7 +216,7 @@ void Box::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation) #define DEFAULT_CHILD_MIN_WIDTH 85 #define DEFAULT_CHILD_MIN_HEIGHT 27 -Size ButtonBox::calculateRequisition() const +Size VclButtonBox::calculateRequisition() const { sal_uInt16 nVisibleChildren = 0; @@ -262,7 +262,7 @@ Size ButtonBox::calculateRequisition() const } -void ButtonBox::setAllocation(const Size &rAllocation) +void VclButtonBox::setAllocation(const Size &rAllocation) { sal_uInt16 nChildren = GetChildCount(); if (!nChildren) @@ -318,7 +318,7 @@ void ButtonBox::setAllocation(const Size &rAllocation) } } -Grid::array_type Grid::assembleGrid() const +VclGrid::array_type VclGrid::assembleGrid() const { array_type A; @@ -356,7 +356,7 @@ Grid::array_type Grid::assembleGrid() const return A; } -bool Grid::isNullGrid(const array_type &A) const +bool VclGrid::isNullGrid(const array_type &A) const { sal_Int32 nMaxX = A.shape()[0]; sal_Int32 nMaxY = A.shape()[1]; @@ -366,7 +366,7 @@ bool Grid::isNullGrid(const array_type &A) const return false; } -void Grid::calcMaxs(const array_type &A, std::vector<long> &rWidths, std::vector<long> &rHeights) const +void VclGrid::calcMaxs(const array_type &A, std::vector<long> &rWidths, std::vector<long> &rHeights) const { sal_Int32 nMaxX = A.shape()[0]; sal_Int32 nMaxY = A.shape()[1]; @@ -397,14 +397,14 @@ void Grid::calcMaxs(const array_type &A, std::vector<long> &rWidths, std::vector } } -Size Grid::GetOptimalSize(WindowSizeType eType) const +Size VclGrid::GetOptimalSize(WindowSizeType eType) const { if (eType == WINDOWSIZE_MAXIMUM) return Window::GetOptimalSize(eType); return calculateRequisition(); } -Size Grid::calculateRequisition() const +Size VclGrid::calculateRequisition() const { array_type A = assembleGrid(); @@ -444,13 +444,13 @@ Size Grid::calculateRequisition() const return Size(nTotalWidth, nTotalHeight); } -void Grid::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation) +void VclGrid::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation) { Window::SetPosSizePixel(rAllocPos, rAllocation); setAllocation(rAllocation); } -void Grid::setAllocation(const Size& rAllocation) +void VclGrid::setAllocation(const Size& rAllocation) { array_type A = assembleGrid(); @@ -548,4 +548,13 @@ Size getLegacyBestSizeForChildren(const Window &rWindow) return aRet; } +Window* getLegacyNonLayoutParent(Window *pParent) +{ + while (pParent && dynamic_cast<const VclContainer*>(pParent)) + { + pParent = pParent->GetParent(); + } + return pParent; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx index cd0fbfedb00d..0fabc34ac6c1 100644 --- a/vcl/source/window/tabpage.cxx +++ b/vcl/source/window/tabpage.cxx @@ -206,7 +206,7 @@ void TabPage::DeactivatePage() bool TabPage::isLayoutEnabled() const { //Has one child, and that child is a container => we're layout enabled - return (GetChildCount() == 1 && dynamic_cast<const Box*>(GetChild(0))); + return (GetChildCount() == 1 && dynamic_cast<const VclContainer*>(GetChild(0))); } Size TabPage::GetOptimalSize(WindowSizeType eType) const diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 03112386797d..3ac0d3d13dfc 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -9591,7 +9591,7 @@ void Window::queueResize() if (!pParent->IsReallyShown()) { //resize dialog to fit requisition - const Box *pContainer = dynamic_cast<const Box*>(pParent->GetChild(0)); + const Window *pContainer = pParent->GetChild(0); Size aSize = pContainer->get_preferred_size(); Size aMax = pParent->GetOptimalSize(WINDOWSIZE_MAXIMUM); |