[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/layout.hxx|6 ++ vcl/source/window/dialog.cxx |4 ++-- vcl/source/window/dlgctrl.cxx | 18 +- vcl/source/window/layout.cxx | 26 ++ 4 files changed, 43 insertions(+), 11 deletions(-) New commits: commit 8372d258ad499162a4ba9888c8792454ad4d8f8e Author: Caolán McNamara caol...@redhat.com Date: Wed Sep 26 21:35:55 2012 +0100 truly skip unshown widgets in tab traversal make tab traversal of dialog widgets hidden because their containers are hidden and/or disabled Change-Id: I1947584717030f3703c018cbf05235811df7835e diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index 34c5696..4735528 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -483,6 +483,12 @@ Window* getNonLayoutParent(Window *pParent); //Get first real parent which is not a layout widget Window* getNonLayoutRealParent(Window *pParent); +//return true if this window and its stack of containers are all shown +bool isVisibleInLayout(const Window *pWindow); + +//return true if this window and its stack of containers are all enabled +bool isEnabledInLayout(const Window *pWindow); + //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); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 64907b2..03624ee 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1134,8 +1134,8 @@ void Dialog::GrabFocusToFirstControl() // Control in der TabSteuerung den Focus geben if ( !pFocusControl || !(pFocusControl-GetStyle() WB_TABSTOP) || - !pFocusControl-IsVisible() || - !pFocusControl-IsEnabled() || !pFocusControl-IsInputEnabled() ) + !isVisibleInLayout(pFocusControl) || + !isEnabledInLayout(pFocusControl) || !pFocusControl-IsInputEnabled() ) { sal_uInt16 n = 0; pFocusControl = ImplGetDlgWindow( n, DLGWINDOW_FIRST ); diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index 7f419c4..7598ea1 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -94,7 +94,7 @@ static Window* ImplGetSubChildWindow( Window* pParent, sal_uInt16 n, sal_uInt16 pWindow = pWindow-ImplGetWindow(); // Unsichtbare und disablte Fenster werden uebersprungen -if ( pTabPage || pWindow-IsVisible() ) +if ( pTabPage || isVisibleInLayout(pWindow) ) { // Wenn das letzte Control ein TabControl war, wird von // diesem die TabPage genommen @@ -167,7 +167,7 @@ static Window* ImplGetChildWindow( Window* pParent, sal_uInt16 n, sal_uInt16 nI if ( bTestEnable ) { sal_uInt16 n2 = nIndex; -while ( pWindow (!pWindow-IsEnabled() || !pWindow-IsInputEnabled()) ) +while ( pWindow (!isEnabledInLayout(pWindow) || !pWindow-IsInputEnabled()) ) { n2 = nIndex+1; nIndex = 0; @@ -184,7 +184,7 @@ static Window* ImplGetChildWindow( Window* pParent, sal_uInt16 n, sal_uInt16 nI nIndex = 0; pWindow = ImplGetSubChildWindow( pParent, n, nIndex ); } -while ( pWindow n (!pWindow-IsEnabled() || !pWindow-IsInputEnabled()) ); +while ( pWindow n (!isEnabledInLayout(pWindow) || !pWindow-IsInputEnabled()) ); } } return pWindow; @@ -278,7 +278,7 @@ Window* Window::ImplGetDlgWindow( sal_uInt16 nIndex, sal_uInt16 nType, while ( (i != nStartIndex) (i != nStartIndex2) ); if ( (i == nStartIndex2) - (!(pWindow-GetStyle() WB_TABSTOP) || !pWindow-IsEnabled()) ) + (!(pWindow-GetStyle() WB_TABSTOP) || !isEnabledInLayout(pWindow)) ) i = nStartIndex; } } @@ -816,7 +816,7 @@ sal_Bool Window::ImplDlgCtrl( const KeyEvent rKEvt, sal_Bool bKeyInput ) nStyle = pWindow-GetStyle(); -if ( pWindow-IsVisible() pWindow-IsEnabled() pWindow-IsInputEnabled() ) +if ( isVisibleInLayout(pWindow) isEnabledInLayout(pWindow) pWindow-IsInputEnabled() ) { if ( pWindow != pSWindow ) pWindow-ImplControlFocus( GETFOCUS_CURSOR | GETFOCUS_BACKWARD ); @@ -842,7 +842,7 @@ sal_Bool Window::ImplDlgCtrl( const KeyEvent rKEvt, sal_Bool bKeyInput ) if ( nStyle WB_GROUP ) break; -if ( pWindow-IsVisible() pWindow-IsEnabled() pWindow-IsInputEnabled() ) +if ( isVisibleInLayout(pWindow) isEnabledInLayout(pWindow) pWindow-IsInputEnabled() ) { pWindow-ImplControlFocus( GETFOCUS_CURSOR | GETFOCUS_BACKWARD ); return
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/button.hxx|1 + vcl/source/control/button.cxx | 16 2 files changed, 17 insertions(+) New commits: commit b731fb5140ccffe893992e7ed5f36e1a442d4aa0 Author: Caolán McNamara caol...@redhat.com Date: Tue Sep 25 13:30:57 2012 +0100 support has-default for buttons Change-Id: I4b3b6bfa3fadaed0770b5e5254f5afc4c67de191 diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx index 31191f5..a613a01 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -200,6 +200,7 @@ public: voidSetToggleHdl( const Link rLink ) { maToggleHdl = rLink; } const Link GetToggleHdl() const { return maToggleHdl; } +virtual bool set_property(const rtl::OString rKey, const rtl::OString rValue); virtual void take_properties(Window rOther); }; diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 8395ff8..0b4fe60 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1747,6 +1747,22 @@ Size PushButton::GetOptimalSize(WindowSizeType eType) const } } +bool PushButton::set_property(const rtl::OString rKey, const rtl::OString rValue) +{ +if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM(has-default))) +{ +WinBits nBits = GetStyle(); +nBits = ~(WB_DEFBUTTON); +if (toBool(rValue)) +nBits |= WB_DEFBUTTON; +SetStyle(nBits); +} +else +return Control::set_property(rKey, rValue); +return true; +} + + // === void OKButton::ImplInit( Window* pParent, WinBits nStyle ) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/button.hxx|1 + vcl/source/control/button.cxx |7 +++ 2 files changed, 8 insertions(+) New commits: commit 977868c3e4f91be07e359b32158d4ccf90bcdf88 Author: Caolán McNamara caol...@redhat.com Date: Tue Sep 18 14:22:28 2012 +0100 copy the button data Change-Id: I3014106791b761e6aad5ea355402f9a2850f5bb5 diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx index 5a73e0a..31191f5 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -95,6 +95,7 @@ public: voidSetFocusRect( const Rectangle rFocusRect ); bool IsSmallSymbol () const; +virtual void take_properties(Window rOther); }; // diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 3e54e84..8395ff8 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -109,6 +109,13 @@ Button::Button( WindowType nType ) : mpButtonData = new ImplCommonButtonData; } +void Button::take_properties(Window rOther) +{ +Control::take_properties(rOther); +Button rOtherButton = static_castButton(rOther); +*mpButtonData = *rOtherButton.mpButtonData; +} + // --- Button::~Button() ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/svids.hrc| 11 - vcl/source/src/print.src | 383 --- 2 files changed, 394 deletions(-) New commits: commit 00a937e40bac1f7c14d14765941ac86d83a666ba Author: Caolán McNamara caol...@redhat.com Date: Mon Sep 10 17:08:44 2012 +0100 delete print dialog .src now Change-Id: Ia1ca185b0abfac6443c819d4143298e7bfca66e5 diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc index db2648f..d7577bc 100644 --- a/vcl/inc/svids.hrc +++ b/vcl/inc/svids.hrc @@ -63,17 +63,6 @@ #define SV_MENU_MAC_SHOWALL 2005 #define SV_MENU_MAC_QUITAPP 2006 -#define SV_DLG_PRINT2048 -#define SV_PRINT_OK 1 -#define SV_PRINT_CANCEL 2 -#define SV_PRINT_HELP 3 -#define SV_PRINT_PAGE_PREVIEW 4 -#define SV_PRINT_PAGE_TXT 5 -#define SV_PRINT_PAGE_FORWARD 6 -#define SV_PRINT_PAGE_BACKWARD 7 -#define SV_PRINT_PAGE_EDIT 8 -#define SV_PRINT_TABCTRL9 - #define SV_PRINT_TAB_NUP 1 #define SV_PRINT_PRT_NUP_LAYOUT_FL 1 #define SV_PRINT_PRT_NUP_BROCHURE_BTN 3 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 19092ba..726ae45 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -27,389 +27,6 @@ #include svids.hrc -ModalDialog SV_DLG_PRINT -{ -HelpID = .HelpID:vcl:PrintDialog:Dialog; -Text [en-US] = Print; -Closeable = TRUE; -Sizeable = TRUE; -Moveable = TRUE; -Maxable = TRUE; -SVLook = TRUE; - -Size = MAP_APPFONT( 350, 215 ); - -OKButton SV_PRINT_OK -{ -DefButton = TRUE; -Pos = MAP_APPFONT( 240, 195 ); -Size = MAP_APPFONT( 50, 15 ); -Text [en-US] = ~Print; -HelpID = .HelpID:vcl:PrintDialog:OK; -}; -CancelButton SV_PRINT_CANCEL -{ -Pos = MAP_APPFONT( 295, 195 ); -Size = MAP_APPFONT( 50, 15 ); -HelpID = .HelpID:vcl:PrintDialog:Cancel; -}; -HelpButton SV_PRINT_HELP -{ -Pos = MAP_APPFONT( 5, 5 ); -Size = MAP_APPFONT( 50, 15 ); -HelpID = .HelpID:vcl:PrintDialog:Help; -}; - -Window SV_PRINT_PAGE_PREVIEW -{ -Pos = MAP_APPFONT( 5, 5 ); -Size = MAP_APPFONT( 130, 130 ); -Border = FALSE; -HelpID = .HelpID:vcl:PrintDialog:Preview; -}; -NumericField SV_PRINT_PAGE_EDIT -{ -Pos = MAP_APPFONT( 5, 140 ); -Size = MAP_APPFONT( 30, 12 ); -SVLook = TRUE; -Spin = FALSE; -Border = TRUE; -HelpID = .HelpID:vcl:PrintDialog:PageEdit; -}; -FixedText SV_PRINT_PAGE_TXT -{ -Pos = MAP_APPFONT( 40,142 ); -Size = MAP_APPFONT( 30, 12 ); -Text [ en-US ] = / %n; -VCenter = TRUE; -HelpID = .HelpID:vcl:PrintDialog:NumPagesText; -}; -PushButton SV_PRINT_PAGE_FORWARD -{ -Pos = MAP_APPFONT( 95, 140 ); -Size = MAP_APPFONT( 15, 12 ); -HelpID = .HelpID:vcl:PrintDialog:ForwardBtn; -}; -PushButton SV_PRINT_PAGE_BACKWARD -{ -Pos = MAP_APPFONT( 80, 140 ); -Size = MAP_APPFONT( 15, 12 ); -HelpID = .HelpID:vcl:PrintDialog:BackwardBtn; -}; -TabControl SV_PRINT_TABCTRL -{ -Pos = MAP_APPFONT( 140, 5 ); -Size = MAP_APPFONT( 205, 175 ); -HelpID = .HelpID:vcl:PrintDialog:TabPages; -}; -FixedLine SV_PRINT_BUTTONLINE -{ -Pos = MAP_APPFONT( 0, 185 ); -Size = MAP_APPFONT( 350, 8 ); -}; -TabPage SV_PRINT_TAB_NUP -{ -HelpID = .HelpID:vcl:PrintDialog:NUpPage; -Text [en-US] = Page Layout; -Hide = TRUE; - -FixedLine SV_PRINT_PRT_NUP_LAYOUT_FL -{ -Pos = MAP_APPFONT( 5, 5 ); -Size = MAP_APPFONT( 150, 10 ); -Text [en-US] = Layout; -}; -RadioButton SV_PRINT_PRT_NUP_BROCHURE_BTN -{ -HelpID = .HelpID:vcl:PrintDialog:NUpPage:Brochure; -Pos = MAP_APPFONT( 0, 0 ); -Size = MAP_APPFONT( 10, 10 ); -Text = ; -}; -RadioButton SV_PRINT_PRT_NUP_PAGES_BTN -{ -HelpID = .HelpID:vcl:PrintDialog:NUpPage:PagesPerSheet; -Pos = MAP_APPFONT( 0, 0 ); -Size = MAP_APPFONT( 10, 10 ); -Text [en-US] = Pa~ges per sheet; -}; -ListBox SV_PRINT_PRT_NUP_PAGES_BOX -{ -HelpID = .HelpID:vcl:PrintDialog:NUpPage:PagesPerSheetBox; -Pos = MAP_APPFONT( 0, 0 ); -Size = MAP_APPFONT( 10, 80 ); -Border = TRUE; -DropDown = TRUE; -CurPos = 0; -StringList [en-US] = -{ - 1; 1; ; - 2; 2; ; - 4; 4; ; - 6; 6; ; - 9; 9; ; -
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/layout.hxx | 24 ++- vcl/source/window/layout.cxx | 67 --- 2 files changed, 68 insertions(+), 23 deletions(-) New commits: commit 5f0b8da8cab56fbb107a19b48acc058efbd6692e Author: Caolán McNamara caol...@redhat.com Date: Fri Aug 31 09:16:39 2012 +0100 make spanning of empty row/cols work better Change-Id: I4ef6cee2ffdfced8d98dc48cf21a142bb15fd4a3 diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index db35196..3da9edd 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -313,7 +313,29 @@ private: bool m_bColumnHomogeneous; int m_nRowSpacing; int m_nColumnSpacing; -typedef boost::multi_arrayWindow*, 2 array_type; + +struct GridEntry +{ +Window *pChild; +sal_Int32 nSpanWidth; +sal_Int32 nSpanHeight; +GridEntry() +: pChild(0) +, nSpanWidth(0) +, nSpanHeight(0) +{ +} +}; + +typedef boost::multi_arrayGridEntry, 2 array_type; + +struct ExtendedGridEntry : GridEntry +{ +int x; +int y; +}; + +typedef boost::multi_arrayExtendedGridEntry, 2 ext_array_type; array_type assembleGrid() const; bool isNullGrid(const array_type A) const; diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index bd27819..db51243 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -385,7 +385,7 @@ void VclButtonBox::setAllocation(const Size rAllocation) VclGrid::array_type VclGrid::assembleGrid() const { -array_type A; +ext_array_type A; for (Window* pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild-GetWindow(WINDOW_NEXT)) @@ -410,9 +410,23 @@ VclGrid::array_type VclGrid::assembleGrid() const A.resize(boost::extents[nCurrentMaxXPos+1][nCurrentMaxYPos+1]); } -A[nLeftAttach][nTopAttach] = pChild; -} +ExtendedGridEntry rEntry = A[nLeftAttach][nTopAttach]; +rEntry.pChild = pChild; +rEntry.nSpanWidth = nWidth; +rEntry.nSpanHeight = nHeight; +rEntry.x = nLeftAttach; +rEntry.y = nTopAttach; +for (sal_Int32 nSpanX = 0; nSpanX nWidth; ++nSpanX) +{ +for (sal_Int32 nSpanY = 0; nSpanY nHeight; ++nSpanY) +{ +ExtendedGridEntry rSpan = A[nLeftAttach+nSpanX][nTopAttach+nSpanY]; +rSpan.x = nLeftAttach; +rSpan.y = nTopAttach; +} +} +} //see if we have any empty rows/cols sal_Int32 nMaxX = A.shape()[0]; @@ -425,16 +439,12 @@ VclGrid::array_type VclGrid::assembleGrid() const { for (sal_Int32 y = 0; y nMaxY; ++y) { -const Window *pChild = A[x][y]; -if (pChild) +const GridEntry rEntry = A[x][y]; +const Window *pChild = rEntry.pChild; +if (pChild pChild-IsVisible()) { -sal_Int32 nWidth = pChild-get_grid_width(); -for (sal_Int32 nSpanX = 0; nSpanX nWidth; ++nSpanX) -aNonEmptyCols[x+nSpanX] = true; - -sal_Int32 nHeight = pChild-get_grid_height(); -for (sal_Int32 nSpanY = 0; nSpanY nHeight; ++nSpanY) -aNonEmptyRows[y+nSpanY] = true; +aNonEmptyCols[x] = true; +aNonEmptyRows[y] = true; } } } @@ -442,9 +452,19 @@ VclGrid::array_type VclGrid::assembleGrid() const sal_Int32 nNonEmptyCols = std::count(aNonEmptyCols.begin(), aNonEmptyCols.end(), true); sal_Int32 nNonEmptyRows = std::count(aNonEmptyRows.begin(), aNonEmptyRows.end(), true); -//no empty rows or cols -if (nNonEmptyCols == nMaxX nNonEmptyRows == nMaxY) -return A; +//reduce the spans of elements that span empty rows or columns +for (sal_Int32 x = 0; x nMaxX; ++x) +{ +for (sal_Int32 y = 0; y nMaxY; ++y) +{ +ExtendedGridEntry rSpan = A[x][y]; +ExtendedGridEntry rEntry = A[rSpan.x][rSpan.y]; +if (!aNonEmptyCols[x]) +--rEntry.nSpanWidth; +if (!aNonEmptyRows[y]) +--rEntry.nSpanHeight; +} +} //make new grid without empty rows and columns array_type B(boost::extents[nNonEmptyCols][nNonEmptyRows]); @@ -456,7 +476,8 @@ VclGrid::array_type VclGrid::assembleGrid() const { if (aNonEmptyRows[y] == false) continue; -B[x2][y2++] = A[x][y]; +GridEntry rEntry = A[x][y]; +B[x2][y2++] = rEntry; } ++x2; } @@ -486,19 +507,20 @@ void VclGrid::calcMaxs(const array_type A, std::vectorValue rWidths, std::ve { for (sal_Int32 y = 0; y nMaxY; ++y) { -const Window *pChild = A[x][y]; +const GridEntry
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/layout.hxx |5 + vcl/inc/vcl/tabctrl.hxx| 13 + vcl/source/control/tabctrl.cxx | 105 - vcl/source/window/layout.cxx | 53 vcl/source/window/window2.cxx | 38 -- 5 files changed, 134 insertions(+), 80 deletions(-) New commits: commit 8a2a5d01e8e8e25525d5873ca5caecbac5946a03 Author: Caolán McNamara caol...@redhat.com Date: Thu Aug 23 15:18:14 2012 +0100 we can need to redo the layout even when the sizes don't change i.e. container remains the same size, but something inside it has disappeared, requiring contents to be readjusted We still want to minimize recalculations, so mark parent containers as dirty on queue_resize of a widget and we can retain the layout tree of the clean ones and just move them into their new positions as big fat blocks Change-Id: I8c5d9b836b48c98765b5cc41be72eaa2913ae7d8 diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index 42071ce..c7af5b9 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -52,11 +52,16 @@ public: { return m_nBorderWidth; } +void markLayoutDirty() +{ +m_bLayoutDirty = true; +} protected: virtual Size calculateRequisition() const = 0; virtual void setAllocation(const Size rAllocation) = 0; private: int m_nBorderWidth; +bool m_bLayoutDirty; }; class VCL_DLLPUBLIC VclBox : public VclContainer diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx index 7d9257e..c8c92c6 100644 --- a/vcl/inc/vcl/tabctrl.hxx +++ b/vcl/inc/vcl/tabctrl.hxx @@ -67,6 +67,7 @@ private: sal_BoolmbRestoreHelpId; sal_BoolmbRestoreUnqId; sal_BoolmbSmallInvalidate; +boolmbLayoutDirty; LinkmaActivateHdl; LinkmaDeactivateHdl; @@ -197,6 +198,18 @@ public: // rename nOldId to nNewId); void ReassignPageId(sal_uInt16 nOldId, sal_uInt16 nNewId); + +using Control::SetPosSizePixel; +virtual void SetPosSizePixel(const Point rNewPos, const Size rNewSize); +virtual void SetSizePixel(const Size rNewSize); + +Size calculateRequisition() const; +void setAllocation(const Size rAllocation); + +void markLayoutDirty() +{ +mbLayoutDirty = true; +} }; #endif // _SV_TABCTRL_HXX diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 11ea115..9a3e2f9 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -102,6 +102,8 @@ struct ImplTabCtrlData void TabControl::ImplInit( Window* pParent, WinBits nStyle ) { +mbLayoutDirty = true; + if ( !(nStyle WB_NOTABSTOP) ) nStyle |= WB_TABSTOP; if ( !(nStyle WB_NOGROUP) ) @@ -1238,7 +1240,7 @@ void TabControl::ImplPaint( const Rectangle rRect, bool bLayout ) // --- -void TabControl::Resize() +void TabControl::setAllocation(const Size rAllocation) { ImplFreeLayoutData(); @@ -1262,7 +1264,7 @@ void TabControl::Resize() // Aktuelle TabPage resizen/positionieren sal_Bool bTabPage = ImplPosCurTabPage(); // Feststellen, was invalidiert werden muss -Size aNewSize = Control::GetOutputSizePixel(); +Size aNewSize = rAllocation; long nNewWidth = aNewSize.Width(); for( std::vector ImplTabItem ::iterator it = mpTabCtrlData-maItemList.begin(); it != mpTabCtrlData-maItemList.end(); ++it ) @@ -1295,6 +1297,29 @@ void TabControl::Resize() else Invalidate(); } + +mbLayoutDirty = false; +} + +void TabControl::SetPosSizePixel(const Point rNewPos, const Size rNewSize) +{ +Window::SetPosSizePixel(rNewPos, rNewSize); +//if size changed, TabControl::Resize got called already +if (mbLayoutDirty) +setAllocation(rNewSize); +} + +void TabControl::SetSizePixel(const Size rNewSize) +{ +Window::SetSizePixel(rNewSize); +//if size changed, TabControl::Resize got called already +if (mbLayoutDirty) +setAllocation(rNewSize); +} + +void TabControl::Resize() +{ +setAllocation(Control::GetOutputSizePixel()); } // --- @@ -2142,57 +2167,55 @@ Point TabControl::GetItemsOffset() const // --- -Size TabControl::GetOptimalSize(WindowSizeType eType) const +Size TabControl::calculateRequisition() const { -switch (eType) { -case WINDOWSIZE_MINIMUM: -return mpTabCtrlData ? mpTabCtrlData-maMinSize : Size(); +Size aOptimalPageSize(0, 0); +long nTabLabelsBottom = 0; +long nTotalTabLabelWidths = 0; -default: +for( std::vector ImplTabItem ::const_iterator it = mpTabCtrlData-maItemList.begin(); + it !=
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/builder.hxx | 20 +-- vcl/source/window/builder.cxx | 55 ++ 2 files changed, 37 insertions(+), 38 deletions(-) New commits: commit 367dfa8dd0cea9558d3922a0e0ab6e0c81e6fdbc Author: Caolán McNamara caol...@redhat.com Date: Thu Aug 23 15:38:30 2012 +0100 Move all the state we need just during parsing to one place and throw the lot away when finished with it Change-Id: Ie64d3fa4cea41fa1ec956538616f73204957f311 diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 7ee38b5..d77b139 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -75,7 +75,6 @@ private: { } }; -std::vectorModelAndId m_aModels; struct StringPair { @@ -89,10 +88,8 @@ private: }; typedef StringPair RadioButtonGroupMap; -std::vectorRadioButtonGroupMap m_aGroupMaps; - typedef StringPair ComboBoxModelMap; -std::vectorComboBoxModelMap m_aModelMaps; + ListStore *get_model_by_name(rtl::OString sID); static void mungemodel(ListBox rTarget, ListStore rStore); @@ -108,22 +105,31 @@ private: m_aAdjustment.swap(rAdjustment); } }; -std::vectorAdjustmentAndId m_aAdjustments; typedef StringPair SpinButtonAdjustmentMap; -std::vectorSpinButtonAdjustmentMap m_aAdjustmentMaps; + Adjustment *get_adjustment_by_name(rtl::OString sID); static void mungeadjustment(NumericFormatter rTarget, Adjustment rAdjustment); typedef std::maprtl::OString, rtl::OString WidgetTranslations; typedef std::maprtl::OString, WidgetTranslations Translations; -Translations m_aTranslations; + +struct ParserState +{ +std::vectorRadioButtonGroupMap m_aGroupMaps; +std::vectorComboBoxModelMap m_aModelMaps; +std::vectorModelAndId m_aModels; +std::vectorAdjustmentAndId m_aAdjustments; +std::vectorSpinButtonAdjustmentMap m_aAdjustmentMaps; +Translations m_aTranslations; +}; rtl::OString getTranslation(const rtl::OString rId, const rtl::OString rProperty) const; rtl::OString m_sID; rtl::OString m_sHelpRoot; Window *m_pParent; +ParserState *m_pParserState; Window *get_by_name(rtl::OString sID); public: diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 379a6fc..c45494f 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -44,6 +44,7 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIF : m_sID(sID) , m_sHelpRoot(rtl::OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8)) , m_pParent(pParent) +, m_pParserState(new ParserState) { sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); if (nIdx != -1) @@ -84,8 +85,8 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIF handleChild(pParent, reader); //Set radiobutton groups when everything has been imported -for (std::vectorRadioButtonGroupMap::iterator aI = m_aGroupMaps.begin(), - aEnd = m_aGroupMaps.end(); aI != aEnd; ++aI) +for (std::vectorRadioButtonGroupMap::iterator aI = m_pParserState-m_aGroupMaps.begin(), + aEnd = m_pParserState-m_aGroupMaps.end(); aI != aEnd; ++aI) { RadioButton *pOne = getRadioButton(aI-m_sID); RadioButton *pOther = getRadioButton(aI-m_sValue); @@ -93,12 +94,10 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIF if (pOne pOther) pOne-group(*pOther); } -//drop maps now -std::vectorRadioButtonGroupMap().swap(m_aGroupMaps); //Set ComboBox models when everything has been imported -for (std::vectorComboBoxModelMap::iterator aI = m_aModelMaps.begin(), - aEnd = m_aModelMaps.end(); aI != aEnd; ++aI) +for (std::vectorComboBoxModelMap::iterator aI = m_pParserState-m_aModelMaps.begin(), + aEnd = m_pParserState-m_aModelMaps.end(); aI != aEnd; ++aI) { ListBox *pTarget = getListBox(aI-m_sID); ListStore *pStore = get_model_by_name(aI-m_sValue); @@ -106,18 +105,15 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIF if (pTarget pStore) mungemodel(*pTarget, *pStore); } -//drop maps now -std::vectorComboBoxModelMap().swap(m_aModelMaps); -for (std::vectorModelAndId::iterator aI = m_aModels.begin(), - aEnd = m_aModels.end(); aI != aEnd; ++aI) +for (std::vectorModelAndId::iterator aI = m_pParserState-m_aModels.begin(), + aEnd = m_pParserState-m_aModels.end(); aI != aEnd; ++aI) { delete aI-m_pModel; } -std::vectorModelAndId().swap(m_aModels); //Set SpinButton adjustments when everything has been imported -for (std::vectorSpinButtonAdjustmentMap::iterator aI = m_aAdjustmentMaps.begin(), - aEnd = m_aAdjustmentMaps.end(); aI !=
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/layout.hxx| 10 - vcl/inc/vcl/window.hxx| 16 vcl/inc/window.h |5 ++ vcl/source/window/layout.cxx | 37 +--- vcl/source/window/window.cxx |5 ++ vcl/source/window/window2.cxx | 75 ++ 6 files changed, 117 insertions(+), 31 deletions(-) New commits: commit 6bbcb2efa300b285e6fcfb545641d530c47cc173 Author: Caolán McNamara caol...@redhat.com Date: Thu Aug 23 16:43:09 2012 +0100 add left/right/top/bottom margin support Change-Id: Ia43941071f3e1f1a364558e93928bce094d4c81f diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index c7af5b9..1d1653a 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -42,16 +42,7 @@ public: virtual void SetPosSizePixel(const Point rNewPos, const Size rNewSize); virtual void SetPosPixel(const Point rAllocPos); virtual void SetSizePixel(const Size rAllocation); -virtual bool set_property(const rtl::OString rKey, const rtl::OString rValue); -void set_border_width(int nBorderWidth) -{ -m_nBorderWidth = nBorderWidth; -} -int get_border_width() const -{ -return m_nBorderWidth; -} void markLayoutDirty() { m_bLayoutDirty = true; @@ -60,7 +51,6 @@ protected: virtual Size calculateRequisition() const = 0; virtual void setAllocation(const Size rAllocation) = 0; private: -int m_nBorderWidth; bool m_bLayoutDirty; }; diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx index 0f9c8a5..8ef3ce4 100644 --- a/vcl/inc/vcl/window.hxx +++ b/vcl/inc/vcl/window.hxx @@ -1187,6 +1187,21 @@ public: */ void set_fill(bool bFill); +void set_border_width(sal_Int32 nBorderWidth); +sal_Int32 get_border_width() const; + +void set_margin_left(sal_Int32 nWidth); +sal_Int32 get_margin_left() const; + +void set_margin_right(sal_Int32 nWidth); +sal_Int32 get_margin_right() const; + +void set_margin_top(sal_Int32 nWidth); +sal_Int32 get_margin_top() const; + +void set_margin_bottom(sal_Int32 nWidth); +sal_Int32 get_margin_bottom() const; + /* * Gets how the widget is packed with reference to the start or end of the parent */ @@ -1247,7 +1262,6 @@ public: */ void set_grid_top_attach(sal_Int32 nAttach); - /* * Sets a widget property * diff --git a/vcl/inc/window.h b/vcl/inc/window.h index cf27c16..dd7718b 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -323,6 +323,11 @@ public: sal_Int32 mnGridLeftAttach; sal_Int32 mnGridTopAttach; sal_Int32 mnGridWidth; +sal_Int32 mnBorderWidth; +sal_Int32 mnMarginLeft; +sal_Int32 mnMarginRight; +sal_Int32 mnMarginTop; +sal_Int32 mnMarginBottom; sal_uInt8 mbFrame:1, mbBorderWin:1, mbOverlapWin:1, diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 2290edd..303f057 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -32,7 +32,6 @@ VclContainer::VclContainer(Window *pParent) : Window(WINDOW_CONTAINER) -, m_nBorderWidth(0) , m_bLayoutDirty(true) { ImplInit(pParent, 0, NULL); @@ -44,20 +43,25 @@ Size VclContainer::GetOptimalSize(WindowSizeType eType) const return Window::GetOptimalSize(eType); Size aSize = calculateRequisition(); -aSize.Width() += m_nBorderWidth*2; -aSize.Height() += m_nBorderWidth*2; +sal_Int32 nBorderWidth = get_border_width(); +aSize.Width() += nBorderWidth*2 + get_margin_left() + get_margin_right(); +aSize.Height() += nBorderWidth*2 + get_margin_top() + get_margin_top(); return aSize; } void VclContainer::SetPosSizePixel(const Point rAllocPos, const Size rAllocation) { Size aAllocation = rAllocation; -aAllocation.Width() -= m_nBorderWidth*2; -aAllocation.Height() -= m_nBorderWidth*2; +sal_Int32 nBorderWidth = get_border_width(); +sal_Int32 nLeft = get_margin_left(); +sal_Int32 nTop = get_margin_top(); + +aAllocation.Width() -= nBorderWidth*2 + nLeft + get_margin_right(); +aAllocation.Height() -= nBorderWidth*2 + nTop + get_margin_bottom(); Point aAllocPos = rAllocPos; -aAllocPos.X() += m_nBorderWidth; -aAllocPos.Y() += m_nBorderWidth; +aAllocPos.X() += nBorderWidth + nLeft; +aAllocPos.Y() += nBorderWidth + nTop; bool bPosChanged = aAllocPos != GetPosPixel(); bool bSizeChanged = aAllocation != GetSizePixel(); @@ -78,8 +82,9 @@ void VclContainer::SetPosSizePixel(const Point rAllocPos, const Size rAllocati void VclContainer::SetPosPixel(const Point rAllocPos) { Point aAllocPos = rAllocPos; -aAllocPos.X() += m_nBorderWidth; -aAllocPos.Y() += m_nBorderWidth; +sal_Int32 nBorderWidth = get_border_width();
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/builder.hxx|2 - vcl/inc/vcl/window.hxx | 10 - vcl/source/control/button.cxx | 45 + vcl/source/control/edit.cxx|7 +++--- vcl/source/control/field.cxx | 14 +++- vcl/source/control/fixed.cxx | 14 +++- vcl/source/control/lstbox.cxx | 14 +++- vcl/source/control/spinfld.cxx |2 - vcl/source/window/builder.cxx | 38 -- vcl/source/window/dialog.cxx | 19 +++-- vcl/source/window/tabpage.cxx |6 +++-- vcl/source/window/window.cxx | 43 +-- 12 files changed, 117 insertions(+), 97 deletions(-) New commits: commit 39b28d6d7e121f733054135e834487fdd0920561 Author: Caolán McNamara caol...@redhat.com Date: Mon Aug 20 09:59:16 2012 +0100 Keep binary resource help id on retro-fit We use our new help id for a full conversion, but for retro-fit we retain the old help id Change-Id: I341e72b4c01ff2350292a0947848aafeea524d45 diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 05c40d4..e43ac1b 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -183,7 +183,7 @@ public: VclBuilderContainer(); virtual ~VclBuilderContainer(); static VclBuilder* overrideResourceWithUIXML(Window *pWindow, const ResId rResId); -static bool replace_buildable(Window *pParent, sal_Int32 nID, Window rReplacement); +static bool replace_buildable(Window *pParent, const ResId rResId, Window rReplacement); }; diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx index f08ad45..0f9c8a5 100644 --- a/vcl/inc/vcl/window.hxx +++ b/vcl/inc/vcl/window.hxx @@ -349,6 +349,13 @@ class Dialog; class WindowImpl; class VclBuilder; +struct WindowResHeader +{ +sal_uLong nObjMask; +rtl::OString aHelpId; +sal_uLong nRSStyle; +}; + class VCL_DLLPUBLIC Window : public OutputDevice { friend class Cursor; @@ -395,8 +402,9 @@ private: public: SAL_DLLPRIVATE voidImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData ); SAL_DLLPRIVATE WinBits ImplInitRes( const ResId rResId ); +SAL_DLLPRIVATE WindowResHeader ImplLoadResHeader( const ResId rResId ); SAL_DLLPRIVATE voidImplLoadRes( const ResId rResId ); -SAL_DLLPRIVATE voidImplWindowRes( const ResId rResId ); +SAL_DLLPRIVATE voidloadAndSetJustHelpID( const ResId rResId ); SAL_DLLPRIVATE voidImplSetFrameParent( const Window* pParent ); SAL_DLLPRIVATE voidImplInsertWindow( Window* pParent ); SAL_DLLPRIVATE voidImplRemoveWindow( sal_Bool bRemoveFrameData ); diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index b5d09f1..4c14d47 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1206,12 +1206,13 @@ PushButton::PushButton( Window* pParent, WinBits nStyle ) : PushButton::PushButton( Window* pParent, const ResId rResId ) : Button( WINDOW_PUSHBUTTON ) { -if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this)) +rResId.SetRT( RSC_PUSHBUTTON ); +WinBits nStyle = ImplInitRes( rResId ); + +if (VclBuilderContainer::replace_buildable(pParent, rResId, *this)) return; ImplInitPushButtonData(); -rResId.SetRT( RSC_PUSHBUTTON ); -WinBits nStyle = ImplInitRes( rResId ); ImplInit( pParent, nStyle ); ImplLoadRes( rResId ); @@ -1761,11 +1762,12 @@ OKButton::OKButton( Window* pParent, WinBits nStyle ) : OKButton::OKButton( Window* pParent, const ResId rResId ) : PushButton( WINDOW_OKBUTTON ) { -if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this)) -return; - rResId.SetRT( RSC_OKBUTTON ); WinBits nStyle = ImplInitRes( rResId ); + +if (VclBuilderContainer::replace_buildable(pParent, rResId, *this)) +return; + ImplInit( pParent, nStyle ); ImplLoadRes( rResId ); @@ -1784,7 +1786,6 @@ void OKButton::take_properties(Window rOther) void OKButton::Click() { -SAL_WARN_IF(!GetClickHdl(), vcl, No handler installed for OKButton); // Ist kein Link gesetzt, dann schliesse Parent if ( !GetClickHdl() ) { @@ -1838,11 +1839,12 @@ CancelButton::CancelButton( Window* pParent, WinBits nStyle ) : CancelButton::CancelButton( Window* pParent, const ResId rResId ) : PushButton( WINDOW_CANCELBUTTON ) { -if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this)) -return; - rResId.SetRT( RSC_CANCELBUTTON ); WinBits nStyle = ImplInitRes( rResId ); + +if (VclBuilderContainer::replace_buildable(pParent, rResId, *this)) +return; + ImplInit( pParent, nStyle ); ImplLoadRes( rResId ); @@ -1861,7 +1863,6 @@ void
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/builder.hxx |4 ++-- vcl/source/uipreviewer/previewer.cxx |2 +- vcl/source/window/builder.cxx| 13 +++-- vcl/source/window/dialog.cxx | 17 ++--- vcl/source/window/window2.cxx|4 +++- 5 files changed, 27 insertions(+), 13 deletions(-) New commits: commit d9a6a2b3967b47644d3ade05aa82f608b638d2c7 Author: Caolán McNamara caol...@redhat.com Date: Thu Aug 16 14:04:00 2012 +0100 Cut Gordian Knot of helpids with .ui format There isn't really an equivalent feature in gtk as help ids (apparently anyway) Rather than munge one in, use the widget id + path as an unique help identifier For the retro-fit where code remains unchanged, don't override the .res loaded id with the .ui generated id Change-Id: I1befe77408cb317e0462dacb26b7d12f9399d372 diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 7b9823f..ff346dd 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -43,7 +43,6 @@ class VCL_DLLPUBLIC VclBuilder public: typedef std::maprtl::OString, rtl::OString stringmap; private: -//todo merge into Windows UniqueID/HelpID ? struct WinAndId { rtl::OString m_sID; @@ -122,9 +121,10 @@ private: rtl::OString getTranslation(const rtl::OString rId, const rtl::OString rProperty) const; rtl::OString m_sID; +rtl::OString m_sHelpRoot; Window *m_pParent; public: -VclBuilder(Window *pParent, rtl::OUString sUIFile, rtl::OString sID = rtl::OString()); +VclBuilder(Window *pParent, rtl::OUString sUIRootDir, rtl::OUString sUIFile, rtl::OString sID = rtl::OString()); ~VclBuilder(); Window *get_widget_root(); Window *get_by_name(rtl::OString sID); diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx index e18730b..42c0353 100644 --- a/vcl/source/uipreviewer/previewer.cxx +++ b/vcl/source/uipreviewer/previewer.cxx @@ -85,7 +85,7 @@ int UIPreviewApp::Main() Dialog *pDialog = new Dialog(NULL, WB_STDDIALOG); { -VclBuilder aBuilder(pDialog, uifiles[0]); +VclBuilder aBuilder(pDialog, rtl::OUString(), uifiles[0]); Dialog *pRealDialog = dynamic_castDialog*(aBuilder.get_widget_root()); if (!pRealDialog) diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 0176bfa..a9e5601 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -39,10 +39,18 @@ #include vcl/tabpage.hxx #include window.h -VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri, rtl::OString sID) +VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIFile, rtl::OString sID) : m_sID(sID) +, m_sHelpRoot(rtl::OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8)) , m_pParent(pParent) { +sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); +if (nIdx != -1) +m_sHelpRoot = m_sHelpRoot.copy(0, nIdx); +m_sHelpRoot = m_sHelpRoot + rtl::OString('/'); + +rtl::OUString sUri = sUIDir + sUIFile; + ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); for (int i = aLocale.Country.isEmpty() ? 1 : 0; i 2; ++i) { @@ -375,7 +383,8 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString name, const fprintf(stderr, TO-DO, implement %s\n, name.getStr()); if (pWindow) { -fprintf(stderr, for %s, created %p child of %p (%p/%p/%p)\n, name.getStr(), pWindow, pParent, pWindow-mpWindowImpl-mpParent, pWindow-mpWindowImpl-mpRealParent, pWindow-mpWindowImpl-mpBorderWindow); +pWindow-SetHelpId(m_sHelpRoot + id); +fprintf(stderr, for %s, created %p child of %p (%p/%p/%p) with helpid %s\n, name.getStr(), pWindow, pParent, pWindow-mpWindowImpl-mpParent, pWindow-mpWindowImpl-mpRealParent, pWindow-mpWindowImpl-mpBorderWindow, pWindow-GetHelpId().getStr()); m_aChildren.push_back(WinAndId(id, pWindow)); } return pWindow; diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 0b97fdc..d4d2d43 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -510,7 +510,7 @@ Dialog::Dialog(Window* pParent, const rtl::OString rID, const rtl::OUString rU { ImplInitDialogData(); ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE); -m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID); +m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); } Dialog::Dialog(Window* pParent, const rtl::OString rID, const rtl::OUString rUIXMLDescription, WindowType nType) @@ -518,7 +518,7 @@ Dialog::Dialog(Window* pParent, const rtl::OString rID, const rtl::OUString rU { ImplInitDialogData(); ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE); -m_pUIBuilder = new VclBuilder(this, getUIRootDir() + rUIXMLDescription, rID); +
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/layout.hxx | 10 +++ vcl/source/window/layout.cxx | 110 +-- 2 files changed, 85 insertions(+), 35 deletions(-) New commits: commit fad6985ea2e36d7d5fe176a4c32318a911172059 Author: Caolán McNamara caol...@redhat.com Date: Thu Aug 16 17:19:22 2012 +0100 honour hexpand/vexpand in the grid Change-Id: I6f57592d83a53de0933d669438851c9a326af02e diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index aa78852..ca6d50f 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -315,7 +315,15 @@ private: array_type assembleGrid() const; bool isNullGrid(const array_type A) const; -void calcMaxs(const array_type A, std::vectorlong rWidths, std::vectorlong rHeights) const; +public: +struct Value +{ +long m_nValue; +bool m_bExpand; +Value() : m_nValue(0), m_bExpand(false) {} +}; +private: +void calcMaxs(const array_type A, std::vectorValue rWidths, std::vectorValue rHeights) const; virtual Size calculateRequisition() const; virtual void setAllocation(const Size rAllocation); diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 6c9305c..1bc2233 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -400,11 +400,6 @@ VclGrid::array_type VclGrid::assembleGrid() const { array_type A; -rtl::OString sLeftAttach(RTL_CONSTASCII_STRINGPARAM(left-attach)); -rtl::OString sWidth(RTL_CONSTASCII_STRINGPARAM(width)); -rtl::OString sTopAttach(RTL_CONSTASCII_STRINGPARAM(top-attach)); -rtl::OString sHeight(RTL_CONSTASCII_STRINGPARAM(height)); - for (Window* pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild-GetWindow(WINDOW_NEXT)) { @@ -492,7 +487,7 @@ bool VclGrid::isNullGrid(const array_type A) const return false; } -void VclGrid::calcMaxs(const array_type A, std::vectorlong rWidths, std::vectorlong rHeights) const +void VclGrid::calcMaxs(const array_type A, std::vectorValue rWidths, std::vectorValue rHeights) const { sal_Int32 nMaxX = A.shape()[0]; sal_Int32 nMaxY = A.shape()[1]; @@ -500,9 +495,6 @@ void VclGrid::calcMaxs(const array_type A, std::vectorlong rWidths, std::vec rWidths.resize(nMaxX); rHeights.resize(nMaxY); -rtl::OString sWidth(RTL_CONSTASCII_STRINGPARAM(width)); -rtl::OString sHeight(RTL_CONSTASCII_STRINGPARAM(height)); - for (sal_Int32 x = 0; x nMaxX; ++x) { for (sal_Int32 y = 0; y nMaxY; ++y) @@ -514,15 +506,34 @@ void VclGrid::calcMaxs(const array_type A, std::vectorlong rWidths, std::vec sal_Int32 nWidth = pChild-get_grid_width(); for (sal_Int32 nSpanX = 0; nSpanX nWidth; ++nSpanX) -rWidths[x+nSpanX] = std::max(rWidths[x+nSpanX], aChildSize.Width()/nWidth); +{ +rWidths[x+nSpanX].m_nValue = std::max(rWidths[x+nSpanX].m_nValue, aChildSize.Width()/nWidth); +rWidths[x+nSpanX].m_bExpand = rWidths[x+nSpanX].m_bExpand | pChild-get_hexpand(); +} sal_Int32 nHeight = pChild-get_grid_height(); for (sal_Int32 nSpanY = 0; nSpanY nHeight; ++nSpanY) -rHeights[y+nSpanY] = std::max(rHeights[y+nSpanY], aChildSize.Height()/nHeight); +{ +rHeights[y+nSpanY].m_nValue = std::max(rHeights[y+nSpanY].m_nValue, aChildSize.Height()/nHeight); +rHeights[y+nSpanY].m_bExpand = rHeights[y+nSpanY].m_bExpand | pChild-get_vexpand(); +} } } } +bool compareValues(const VclGrid::Value i, const VclGrid::Value j) +{ +return i.m_nValue j.m_nValue; +} + +VclGrid::Value accumulateValues(const VclGrid::Value i, const VclGrid::Value j) +{ +VclGrid::Value aRet; +aRet.m_nValue = i.m_nValue + j.m_nValue; +aRet.m_bExpand = i.m_bExpand | j.m_bExpand; +return aRet; +} + Size VclGrid::calculateRequisition() const { array_type A = assembleGrid(); @@ -530,19 +541,19 @@ Size VclGrid::calculateRequisition() const if (isNullGrid(A)) return Size(); -std::vectorlong aWidths; -std::vectorlong aHeights; +std::vectorValue aWidths; +std::vectorValue aHeights; calcMaxs(A, aWidths, aHeights); long nTotalWidth = 0; if (get_column_homogeneous()) { -nTotalWidth = *std::max_element(aWidths.begin(), aWidths.end()); +nTotalWidth = std::max_element(aWidths.begin(), aWidths.end(), compareValues)-m_nValue; nTotalWidth *= aWidths.size(); } else { -nTotalWidth = std::accumulate(aWidths.begin(), aWidths.end(), 0); +nTotalWidth = std::accumulate(aWidths.begin(), aWidths.end(), Value(), accumulateValues).m_nValue; } nTotalWidth += get_column_spacing() * (aWidths.size()-1); @@ -550,12 +561,12 @@ Size VclGrid::calculateRequisition() const long nTotalHeight = 0; if
[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
vcl/inc/vcl/builder.hxx | 10 ++ vcl/source/window/builder.cxx | 163 +- 2 files changed, 154 insertions(+), 19 deletions(-) New commits: commit 6bf05406c6d352543ea93ac7d5e1db7851d08fca Author: Caolán McNamara caol...@redhat.com Date: Tue Aug 7 15:27:51 2012 +0100 handle translations Change-Id: Idb88fe3a32349f6a3cf343db884e9cc38d699660 diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 7a21a99..c9d0ee0 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -113,6 +113,12 @@ private: Adjustment *get_adjustment_by_name(rtl::OString sID); static void mungeadjustment(MetricField rTarget, Adjustment rAdjustment); +typedef std::maprtl::OString, rtl::OString WidgetTranslations; +typedef std::maprtl::OString, WidgetTranslations Translations; +Translations m_aTranslations; + +rtl::OString getTranslation(const rtl::OString rId, const rtl::OString rProperty) const; + rtl::OString m_sID; Window *m_pParent; public: @@ -133,11 +139,13 @@ private: bool extractModel(const rtl::OString id, stringmap rVec); bool extractAdjustment(const rtl::OString id, stringmap rVec); +void handleTranslations(xmlreader::XmlReader reader); + void handleChild(Window *pParent, xmlreader::XmlReader reader); Window* handleObject(Window *pParent, xmlreader::XmlReader reader); void handlePacking(Window *pCurrent, xmlreader::XmlReader reader); void applyPackingProperty(Window *pCurrent, xmlreader::XmlReader reader); -void collectProperty(xmlreader::XmlReader reader, stringmap rVec); +void collectProperty(xmlreader::XmlReader reader, const rtl::OString rID, stringmap rVec); void handleListStore(xmlreader::XmlReader reader, const rtl::OString rID); void handleAdjustment(const rtl::OString rID, stringmap rProperties); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 5073ac0..465a806 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -34,6 +34,7 @@ #include vcl/fixed.hxx #include vcl/layout.hxx #include vcl/lstbox.hxx +#include vcl/svapp.hxx #include vcl/tabctrl.hxx #include vcl/tabpage.hxx #include window.h @@ -42,6 +43,33 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri, rtl::OString sID) : m_sID(sID) , m_pParent(pParent) { +::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); +for (int i = aLocale.Country.isEmpty() ? 1 : 0; i 2; ++i) +{ +rtl::OUStringBuffer aTransBuf; +sal_Int32 nLastSlash = sUri.lastIndexOf('/'); +aTransBuf.append(sUri.copy(0, nLastSlash)).append(/res/).append(aLocale.Language); +switch (i) +{ +case 0: +aTransBuf.append('-').append(aLocale.Country); +break; +default: +break; +} +aTransBuf.append(sUri.copy(nLastSlash)); + +rtl::OUString sTransUri = aTransBuf.makeStringAndClear(); +try +{ +xmlreader::XmlReader reader(sTransUri); +handleTranslations(reader); +} +catch (const ::com::sun::star::uno::Exception ) +{ +} +} + xmlreader::XmlReader reader(sUri); handleChild(pParent, reader); @@ -92,6 +120,9 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri, rtl::OString sID) std::vectorSpinButtonAdjustmentMap().swap(m_aAdjustmentMaps); std::vectorAdjustmentAndId().swap(m_aAdjustments); +//drop maps now +Translations().swap(m_aTranslations); + //auto-show (really necessary ?, maybe drop it when complete) for (std::vectorWinAndId::iterator aI = m_aChildren.begin(), aEnd = m_aChildren.end(); aI != aEnd; ++aI) @@ -114,6 +145,53 @@ VclBuilder::~VclBuilder() } } +void VclBuilder::handleTranslations(xmlreader::XmlReader reader) +{ +xmlreader::Span name; +int nsId; +rtl::OString sType; + +rtl::OString sID, sProperty; + +while(1) +{ +xmlreader::XmlReader::Result res = reader.nextItem( +xmlreader::XmlReader::TEXT_NORMALIZED, name, nsId); + +if (res == xmlreader::XmlReader::RESULT_BEGIN) +{ +if (name.equals(RTL_CONSTASCII_STRINGPARAM(e))) +{ +while (reader.nextAttribute(nsId, name)) +{ +if (name.equals(RTL_CONSTASCII_STRINGPARAM(g))) +{ +name = reader.getAttributeValue(false); +sID = rtl::OString(name.begin, name.length); +} +else if (name.equals(RTL_CONSTASCII_STRINGPARAM(i))) +{ +name = reader.getAttributeValue(false); +sProperty = rtl::OString(name.begin, name.length); +} +} +} +