diff options
author | Stefano Facchini <stefano.facchini@gmail.com> | 2013-08-22 21:48:19 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-08-26 20:09:48 +0000 |
commit | fa9a2aaa2246e6eb0665d36aa7c6c75fd31c4e3e (patch) | |
tree | c99ce936a5e8616ad5f2b7ac7fe162f9b06e164c | |
parent | 969d5a3b97903fe32b3a7da0c3de8bf86f323c17 (diff) |
fdo#66435: distribute tabs more evenly across rows
Change-Id: I9df2312f257867fc89aa29672f2d58ea40363b14
Reviewed-on: https://gerrit.libreoffice.org/5588
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 86e3eadd62a7..44491817ab95 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -403,6 +403,14 @@ Rectangle TabControl::ImplGetTabRect( sal_uInt16 nItemPos, long nWidth, long nHe long nLineWidthAry[100]; sal_uInt16 nLinePosAry[101]; + long nTotalWidth = nOffsetX; + for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin(); + it != mpTabCtrlData->maItemList.end(); ++it ) + { + nTotalWidth += ImplGetItemSize( &(*it), nMaxWidth ).Width(); + } + long nWrapWidth = nWidth / ceil((double)nTotalWidth / nWidth); + nLineWidthAry[0] = 0; nLinePosAry[0] = 0; for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin(); @@ -410,18 +418,6 @@ Rectangle TabControl::ImplGetTabRect( sal_uInt16 nItemPos, long nWidth, long nHe { aSize = ImplGetItemSize( &(*it), nMaxWidth ); - if ( ((nX+aSize.Width()) > nWidth - 2) && (nWidth > 2+nOffsetX) ) - { - if ( nLines == 99 ) - break; - - nX = nOffsetX; - nY += aSize.Height(); - nLines++; - nLineWidthAry[nLines] = 0; - nLinePosAry[nLines] = nPos; - } - Rectangle aNewRect( Point( nX, nY ), aSize ); if ( mbSmallInvalidate && (it->maRect != aNewRect) ) mbSmallInvalidate = sal_False; @@ -436,6 +432,23 @@ Rectangle TabControl::ImplGetTabRect( sal_uInt16 nItemPos, long nWidth, long nHe nCurLine = nLines; nPos++; + + if ( (nX > nWrapWidth - 2) && (nWidth > 2+nOffsetX) ) + { + if ( nLines == 99 ) + break; + + nX = nOffsetX; + nY += aSize.Height(); + nLines++; + nLineWidthAry[nLines] = 0; + nLinePosAry[nLines] = nPos; + } + } + + if ( nX == nOffsetX ) + { + nLines--; } if ( nLines && !mpTabCtrlData->maItemList.empty() ) |