diff options
author | Douglas Mencken <dougmencken@gmail.com> | 2016-04-04 20:58:01 -0400 |
---|---|---|
committer | Douglas Mencken <dougmencken@gmail.com> | 2017-01-12 06:35:54 -0500 |
commit | 95804fcdc669df00dfb3e3794d9796e525534900 (patch) | |
tree | bda54206b4e2273fb421b05342de1ca892258992 | |
parent | 9190249d7ab3701e0db4aa70d8484a03fb347c16 (diff) |
vcl.osx: make panes of tabs look Jaguarish
plus turn off excessive borders for elements of interface
Change-Id: Ief2718eafc8b6a8a12d281ad2988ace0977d9741
-rw-r--r-- | vcl/osx/salnativewidgets.cxx | 147 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 276 |
2 files changed, 244 insertions, 179 deletions
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx index 2c3ce4d1b9db..7e0e40de2eb1 100644 --- a/vcl/osx/salnativewidgets.cxx +++ b/vcl/osx/salnativewidgets.cxx @@ -490,8 +490,10 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, aComboInfo.value = kThemeButtonOn; aComboInfo.adornment = kThemeAdornmentNone; +# if ( MACOSX_SDK_VERSION > 1060 ) if( nState & ControlState::FOCUSED ) aComboInfo.adornment |= kThemeAdornmentFocus; +# endif HIThemeDrawButton(&rc, &aComboInfo, mrContext, kHIThemeOrientationNormal,&rc); bOK = true; @@ -667,8 +669,10 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, aPushInfo.adornment = ( nState & ControlState::DEFAULT ) ? kThemeAdornmentDefault : kThemeAdornmentNone; +# if ( MACOSX_SDK_VERSION > 1060 ) if( nState & ControlState::FOCUSED ) aPushInfo.adornment |= kThemeAdornmentFocus; +# endif HIThemeDrawButton( &rc, &aPushInfo, mrContext, kHIThemeOrientationNormal, nullptr ); bOK = true; @@ -696,11 +700,14 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, ButtonValue aButtonValue = aValue.getTristateVal(); aInfo.value = ImplGetButtonValue( aButtonValue ); - aInfo.adornment = ( nState & ControlState::DEFAULT ) ? - kThemeAdornmentDefault : - kThemeAdornmentNone; + aInfo.adornment = ( nState & ControlState::DEFAULT ) ? kThemeAdornmentDefault : kThemeAdornmentNone; +# if ( MACOSX_SDK_VERSION > 1060 ) if( nState & ControlState::FOCUSED ) aInfo.adornment |= kThemeAdornmentFocus; +# else + rc.origin.y -= 1; +# endif + HIThemeDrawButton( &rc, &aInfo, mrContext, kHIThemeOrientationNormal, nullptr ); bOK = true; } @@ -881,20 +888,28 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, case ControlType::TabPane: { HIThemeTabPaneDrawInfo aTabPaneDrawInfo; - aTabPaneDrawInfo.version = 1; +# if ( MACOSX_SDK_VERSION <= 1060 ) + aTabPaneDrawInfo.version = 0; // 0 for Jaguar-era tabs +# else + aTabPaneDrawInfo.version = 1; // 1 for "modern" tabs +# endif aTabPaneDrawInfo.state = kThemeStateActive; - aTabPaneDrawInfo.direction=kThemeTabNorth; - aTabPaneDrawInfo.size=kHIThemeTabSizeNormal; - aTabPaneDrawInfo.kind=kHIThemeTabKindNormal; - - //the border is outside the rect rc for Carbon - //but for VCL it should be inside - rc.origin.x+=1; - rc.origin.y-=TAB_HEIGHT_NORMAL/2; - rc.size.height+=TAB_HEIGHT_NORMAL/2; - rc.size.width-=2; + aTabPaneDrawInfo.direction = kThemeTabNorth; + aTabPaneDrawInfo.size = kHIThemeTabSizeNormal; + aTabPaneDrawInfo.kind = kHIThemeTabKindNormal; + aTabPaneDrawInfo.adornment = kThemeAdornmentNone; + + // the border is outside the rect rc for Carbon + // but for VCL it is inside + rc.origin.x += 1; + rc.size.width -= 2; + if ( aTabPaneDrawInfo.version == 1 ) + { + rc.origin.y -= TAB_HEIGHT_NORMAL >> 1; + rc.size.height += TAB_HEIGHT_NORMAL >> 1; + } - HIThemeDrawTabPane(&rc, &aTabPaneDrawInfo, mrContext, kHIThemeOrientationNormal); + HIThemeDrawTabPane( &rc, &aTabPaneDrawInfo, mrContext, kHIThemeOrientationNormal ); bOK = true; } @@ -903,52 +918,66 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, case ControlType::TabItem: { HIThemeTabDrawInfo aTabItemDrawInfo; - aTabItemDrawInfo.version=1; - aTabItemDrawInfo.style=kThemeTabNonFront; - aTabItemDrawInfo.direction=kThemeTabNorth; - aTabItemDrawInfo.size=kHIThemeTabSizeNormal; - aTabItemDrawInfo.adornment=kHIThemeTabAdornmentTrailingSeparator; - //State - if(nState & ControlState::SELECTED) { - aTabItemDrawInfo.style=kThemeTabFront; +# if ( MACOSX_SDK_VERSION <= 1060 ) + aTabItemDrawInfo.version = 0; // 0 for Jaguar-era tabs +# else + aTabItemDrawInfo.version = 1; // 1 for "modern" tabs +# endif + aTabItemDrawInfo.direction = kThemeTabNorth; + aTabItemDrawInfo.size = kHIThemeTabSizeNormal; + aTabItemDrawInfo.style = kThemeTabNonFront; + + if( nState & ControlState::SELECTED ) { + aTabItemDrawInfo.style = kThemeTabFront; } - if(nState & ControlState::FOCUSED) { - aTabItemDrawInfo.adornment|=kHIThemeTabAdornmentFocus; +# if ( MACOSX_SDK_VERSION > 1060 ) + aTabItemDrawInfo.adornment = kHIThemeTabAdornmentTrailingSeparator; + if( nState & ControlState::FOCUSED ) { + aTabItemDrawInfo.adornment |= kHIThemeTabAdornmentFocus; } - - //first, last or middle tab - aTabItemDrawInfo.position=kHIThemeTabPositionMiddle; - - TabitemValue const * pTabValue = static_cast<TabitemValue const *>(&aValue); - TabitemFlags nAlignment = pTabValue->mnAlignment; - //TabitemFlags::LeftAligned (and TabitemFlags::RightAligned) for the leftmost (or rightmost) tab - //when there are several lines of tabs because there is only one first tab and one - //last tab and TabitemFlags::FirstInGroup (and TabitemFlags::LastInGroup) because when the - //line width is different from window width, there may not be TabitemFlags::RightAligned - if( ( (nAlignment & TabitemFlags::LeftAligned)&&(nAlignment & TabitemFlags::RightAligned) ) || - ( (nAlignment & TabitemFlags::FirstInGroup)&&(nAlignment & TabitemFlags::LastInGroup) ) - ) //tab alone - aTabItemDrawInfo.position=kHIThemeTabPositionOnly; - else if((nAlignment & TabitemFlags::LeftAligned)||(nAlignment & TabitemFlags::FirstInGroup)) - aTabItemDrawInfo.position=kHIThemeTabPositionFirst; - else if((nAlignment & TabitemFlags::RightAligned)||(nAlignment & TabitemFlags::LastInGroup)) - aTabItemDrawInfo.position=kHIThemeTabPositionLast; - - //support for RTL - //see issue 79748 - if( AllSettings::GetLayoutRTL() ) { - if( aTabItemDrawInfo.position == kHIThemeTabPositionFirst ) - aTabItemDrawInfo.position = kHIThemeTabPositionLast; - else if( aTabItemDrawInfo.position == kHIThemeTabPositionLast ) +# else + aTabItemDrawInfo.adornment = kThemeAdornmentNone; +# endif + + // by default it is tab somewhere in the middle + aTabItemDrawInfo.position = kHIThemeTabPositionMiddle; + + if ( aTabItemDrawInfo.version == 1 ) { + TabitemValue const * pTabValue = static_cast<TabitemValue const *>(&aValue); + TabitemFlags nAlignment = pTabValue->mnAlignment; + //TabitemFlags::LeftAligned (and TabitemFlags::RightAligned) for the leftmost (or rightmost) tab + //when there are several lines of tabs because there is only one first tab and one + //last tab and TabitemFlags::FirstInGroup (and TabitemFlags::LastInGroup) because when the + //line width is different from window width, there may not be TabitemFlags::RightAligned + if( ( (nAlignment & TabitemFlags::LeftAligned)&&(nAlignment & TabitemFlags::RightAligned) ) || + ( (nAlignment & TabitemFlags::FirstInGroup)&&(nAlignment & TabitemFlags::LastInGroup) ) + ) // tab alone + aTabItemDrawInfo.position = kHIThemeTabPositionOnly; + else if((nAlignment & TabitemFlags::LeftAligned)||(nAlignment & TabitemFlags::FirstInGroup)) + aTabItemDrawInfo.position = kHIThemeTabPositionFirst; + else if((nAlignment & TabitemFlags::RightAligned)||(nAlignment & TabitemFlags::LastInGroup)) + aTabItemDrawInfo.position = kHIThemeTabPositionLast; + + //support for RTL + //see issue 79748 + if( AllSettings::GetLayoutRTL() ) { + if( aTabItemDrawInfo.position == kHIThemeTabPositionFirst ) + aTabItemDrawInfo.position = kHIThemeTabPositionLast; + else if( aTabItemDrawInfo.position == kHIThemeTabPositionLast ) aTabItemDrawInfo.position = kHIThemeTabPositionFirst; + } } - rc.size.width+=2;//because VCL has 2 empty pixels between 2 tabs - rc.origin.x-=1; + rc.origin.x -= 1; + if ( aTabItemDrawInfo.version == 0 ) { + rc.origin.y += 2; + } else { + rc.size.width += 2; // because VCL has 2 empty pixels between 2 tabs + } - HIThemeDrawTab(&rc, &aTabItemDrawInfo, mrContext, kHIThemeOrientationNormal, &rc ); + HIThemeDrawTab( &rc, &aTabItemDrawInfo, mrContext, kHIThemeOrientationNormal, &rc ); - bOK=true; + bOK = true; } break; @@ -965,8 +994,10 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, aListInfo.value = kThemeButtonOn; aListInfo.adornment = kThemeAdornmentDefault; +# if ( MACOSX_SDK_VERSION > 1060 ) if( nState & ControlState::FOCUSED ) aListInfo.adornment |= kThemeAdornmentFocus; +# endif HIThemeDrawButton(&rc, &aListInfo, mrContext, kHIThemeOrientationNormal,&rc); bOK = true; @@ -984,7 +1015,9 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, rc.size.height+=1; HIThemeDrawFrame(&rc, &aTextDrawInfo, mrContext, kHIThemeOrientationNormal); +# if ( MACOSX_SDK_VERSION > 1060 ) if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, mrContext, kHIThemeOrientationNormal); +# endif bOK=true; break; @@ -1014,7 +1047,9 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, HIThemeDrawFrame(&rc, &aTextDrawInfo, mrContext, kHIThemeOrientationNormal); +# if ( MACOSX_SDK_VERSION > 1060 ) if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, mrContext, kHIThemeOrientationNormal); +# endif bOK=true; } @@ -1043,7 +1078,9 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, HIThemeDrawFrame(&rc, &aTextDrawInfo, mrContext, kHIThemeOrientationNormal); +# if ( MACOSX_SDK_VERSION > 1060 ) if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, mrContext, kHIThemeOrientationNormal); +# endif //buttons: const SpinbuttonValue* pSpinButtonVal = (aValue.getType() == ControlType::SpinButtons) ? static_cast<const SpinbuttonValue*>(&aValue) : nullptr; @@ -1091,8 +1128,10 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, (nLowerState & ControlState::DEFAULT) ) ? kThemeAdornmentDefault : kThemeAdornmentNone; +# if ( MACOSX_SDK_VERSION > 1060 ) if( (nUpperState & ControlState::FOCUSED) || (nLowerState & ControlState::FOCUSED)) aSpinInfo.adornment |= kThemeAdornmentFocus; +# endif HIThemeDrawButton( &buttonRc, &aSpinInfo, mrContext, kHIThemeOrientationNormal, nullptr ); } diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index ee31141867f6..fb39272cf87e 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -359,164 +359,185 @@ namespace MinimumRaggednessWrap bool TabControl::ImplPlaceTabs( long nWidth ) { - if ( nWidth <= 0 ) - return false; if ( mpTabCtrlData->maItemList.empty() ) return false; - long nMaxWidth = nWidth; + long origWidth = nWidth; + nWidth -= 16; + if ( nWidth <= 0 ) + return false; const long nOffsetX = 2 + GetItemsOffset().X(); const long nOffsetY = 2 + GetItemsOffset().Y(); - //fdo#66435 throw Knuth/Tex minimum raggedness algorithm at the problem - //of ugly bare tabs on lines of their own + // fdo#66435 throw Knuth/Tex minimum raggedness algorithm at the problem + // of single bare tab on lines of their own - //collect widths - std::vector<sal_Int32> aWidths; + // collect widths + std::vector< sal_Int32 > aWidths; for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin(); it != mpTabCtrlData->maItemList.end(); ++it ) { - aWidths.push_back(ImplGetItemSize( &(*it), nMaxWidth ).Width()); + aWidths.push_back( ImplGetItemSize( &(*it), nWidth ).Width() ); } - //aBreakIndexes will contain the indexes of the last tab on each row - std::deque<size_t> aBreakIndexes(MinimumRaggednessWrap::GetEndOfLineIndexes(aWidths, nMaxWidth - nOffsetX - 2)); + // fill aBreakIndexes with indexes of the last tab on each row + long lineW = nWidth - nOffsetX - 2; + std::deque< size_t > aBreakIndexes( MinimumRaggednessWrap::GetEndOfLineIndexes( aWidths, lineW ) ); - if ( (mnMaxPageWidth > 0) && (mnMaxPageWidth < nMaxWidth) ) - nMaxWidth = mnMaxPageWidth; - nMaxWidth -= GetItemsOffset().X(); + if ( ( mnMaxPageWidth > 0 ) && ( mnMaxPageWidth < nWidth ) ) + nWidth = mnMaxPageWidth; - long nX = nOffsetX; - long nY = nOffsetY; + nWidth -= GetItemsOffset().X(); - sal_uInt16 nLines = 0; - sal_uInt16 nCurLine = 0; + const size_t magicMaxLines = 100; // magic number of maximum lines - long nLineWidthAry[100]; - sal_uInt16 nLinePosAry[101]; - nLineWidthAry[0] = 0; - nLinePosAry[0] = 0; + long maxLineWidth = 0; + long nLineWidths[ magicMaxLines ]; + nLineWidths[ 0 ] = 0; + sal_uInt16 nLineFirstTabNums[ magicMaxLines + 1 ]; + nLineFirstTabNums[ 0 ] = 0; - size_t nIndex = 0; - sal_uInt16 nPos = 0; + long nX = nOffsetX; + long nY = nOffsetY; - for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin(); - it != mpTabCtrlData->maItemList.end(); ++it, ++nIndex ) - { - Size aSize = ImplGetItemSize( &(*it), nMaxWidth ); + sal_uInt16 nLines = 0; // number of lines + sal_uInt16 nChosenLine = 0; // line which is active now + sal_uInt16 nIndex = 0; + for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin() ; + it != mpTabCtrlData->maItemList.end() ; + ++it, ++nIndex ) + { bool bNewLine = false; - if (!aBreakIndexes.empty() && nIndex > aBreakIndexes.front()) + if ( !aBreakIndexes.empty() && nIndex > aBreakIndexes.front() ) { aBreakIndexes.pop_front(); - bNewLine = true; + bNewLine = true; // this tab is on new line } - if ( bNewLine && (nWidth > 2+nOffsetX) ) + Size aSize = ImplGetItemSize( &(*it), nWidth ); + + if ( bNewLine && ( nWidth > 2 + nOffsetX ) ) { - if ( nLines == 99 ) + nLines++; + if ( nLines == magicMaxLines ) break; nX = nOffsetX; nY += aSize.Height(); - nLines++; - nLineWidthAry[nLines] = 0; - nLinePosAry[nLines] = nPos; + + nLineWidths[ nLines ] = 0; + nLineFirstTabNums[ nLines ] = nIndex; } Rectangle aNewRect( Point( nX, nY ), aSize ); - if ( mbSmallInvalidate && (it->maRect != aNewRect) ) + if ( mbSmallInvalidate && ( it->maRect != aNewRect ) ) mbSmallInvalidate = false; it->maRect = aNewRect; it->mnLine = nLines; it->mbFullVisible = true; - nLineWidthAry[nLines] += aSize.Width(); + nLineWidths[ nLines ] += aSize.Width(); + if ( ( !maxLineWidth ) || ( nLineWidths[ nLines ] > maxLineWidth ) ) + maxLineWidth = nLineWidths[ nLines ]; + nX += aSize.Width(); if ( it->mnId == mnCurPageId ) - nCurLine = nLines; - - nPos++; + nChosenLine = nLines; } + nLineFirstTabNums[ nLines + 1 ] = static_cast< sal_uInt16 >( mpTabCtrlData->maItemList.size() ); + + const long firstTabXWhenAlignedLeft = 1 + ( ( origWidth - nWidth ) >> 1 ); + if ( nLines ) - { // two or more lines - long nLineHeightAry[100]; - long nIH = mpTabCtrlData->maItemList[0].maRect.Bottom()-2; + { // two or more lines + const long tabHeight = mpTabCtrlData->maItemList[0].maRect.Bottom() - 2; + long nLineHeights[ nLines + 1 ]; - for ( sal_uInt16 i = 0; i < nLines+1; i++ ) + for ( sal_uInt16 line = 0; line < nLines + 1; line++ ) { - if ( i <= nCurLine ) - nLineHeightAry[i] = nIH*(nLines-(nCurLine-i)) + GetItemsOffset().Y(); + if ( line <= nChosenLine ) + nLineHeights[ line ] = tabHeight * ( nLines - ( nChosenLine - line ) ) + GetItemsOffset().Y(); else - nLineHeightAry[i] = nIH*(i-nCurLine-1) + GetItemsOffset().Y(); + nLineHeights[ line ] = tabHeight * ( line - nChosenLine - 1 ) + GetItemsOffset().Y(); } - nLinePosAry[nLines+1] = (sal_uInt16)mpTabCtrlData->maItemList.size(); - - long nDX = 0; - long nModDX = 0; - long nIDX = 0; + sal_uInt32 item = 0; + sal_uInt16 lineN = 0; + bool bNewLine = false; + long lastX = firstTabXWhenAlignedLeft; - sal_uInt16 i = 0; - sal_uInt16 n = 0; for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin(); - it != mpTabCtrlData->maItemList.end(); ++it ) + it != mpTabCtrlData->maItemList.end(); ++it, item++ ) { - if ( i == nLinePosAry[n] ) + if ( item == nLineFirstTabNums[ lineN ] ) { - if ( n == nLines+1 ) + if ( lineN == nLines + 1 ) break; - nIDX = 0; - if( nLinePosAry[n+1]-i > 0 ) - { - nDX = ( nWidth - nOffsetX - nLineWidthAry[n] ) / ( nLinePosAry[n+1] - i ); - nModDX = ( nWidth - nOffsetX - nLineWidthAry[n] ) % ( nLinePosAry[n+1] - i ); - } - else - { - // FIXME: this is a case of tabctrl way too small - nDX = 0; - nModDX = 0; - } - n++; + lineN++; + bNewLine = true; } - it->maRect.Left() += nIDX; - it->maRect.Right() += nIDX + nDX; - it->maRect.Top() = nLineHeightAry[n-1]; - it->maRect.Bottom() = nLineHeightAry[n-1] + nIH; - nIDX += nDX; + it->maRect.Top() = nLineHeights[ lineN - 1 ]; + it->maRect.Bottom() = nLineHeights[ lineN - 1 ] + tabHeight; - if ( nModDX ) + long lastTabOnPreviousLine = 0; + if ( lineN > 0 ) + lastTabOnPreviousLine = nLineFirstTabNums[ lineN - 1 ]; + long itemsInRow = nLineFirstTabNums[ lineN ] - lastTabOnPreviousLine; + + it->maRect.Right() += firstTabXWhenAlignedLeft; + + if( ImplGetSVData()->maNWFData.mbCenteredTabs ) { - nIDX++; - it->maRect.Right()++; - nModDX--; + long nDeltaWidth = 0; + long nModDW = 0; + if ( maxLineWidth > nLineWidths[ lineN ] ) + { + nDeltaWidth = ( maxLineWidth - nLineWidths[ lineN ] ) / itemsInRow; + nModDW = ( maxLineWidth - nLineWidths[ lineN ] ) % itemsInRow; + } + if ( nDeltaWidth > 0 ) + it->maRect.Right() += nDeltaWidth; + if ( nModDW > 0 ) + it->maRect.Right() += ( nModDW >> 1 ); } - i++; + if ( bNewLine ) + { + lastX = firstTabXWhenAlignedLeft; + bNewLine = false; + } + it->maRect.Left() = lastX; + lastX = it->maRect.Right(); } } else - { // only one line - if(ImplGetSVData()->maNWFData.mbCenteredTabs) - { - int nRightSpace = nMaxWidth;//space left on the right by the tabs - for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin(); - it != mpTabCtrlData->maItemList.end(); ++it ) - { - nRightSpace -= it->maRect.Right()-it->maRect.Left(); - } + { // only one line + long firstTabX = firstTabXWhenAlignedLeft; + + if( ImplGetSVData()->maNWFData.mbCenteredTabs ) + { // place them into the middle + long spaceLeft = nWidth; // space left after tabs for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin(); it != mpTabCtrlData->maItemList.end(); ++it ) { - it->maRect.Left() += nRightSpace / 2; - it->maRect.Right() += nRightSpace / 2; + spaceLeft -= it->maRect.Right() - it->maRect.Left(); } + firstTabX += ( 1 + spaceLeft ) >> 1; + } + + long lastX = firstTabX; + for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin(); + it != mpTabCtrlData->maItemList.end(); ++it ) + { + it->maRect.Left() = lastX; + it->maRect.Right() += firstTabX; + lastX = it->maRect.Right(); } } @@ -525,59 +546,63 @@ bool TabControl::ImplPlaceTabs( long nWidth ) Rectangle TabControl::ImplGetTabRect( sal_uInt16 nItemPos, long nWidth, long nHeight ) { - Size aWinSize = Control::GetOutputSizePixel(); - if ( nWidth < 0 ) - nWidth = aWinSize.Width(); - if ( nHeight < 0 ) - nHeight = aWinSize.Height(); - if ( mpTabCtrlData->maItemList.empty() ) { - long nW = nWidth-TAB_OFFSET*2; - long nH = nHeight-TAB_OFFSET*2; - return (nW > 0 && nH > 0) - ? Rectangle( Point( TAB_OFFSET, TAB_OFFSET ), Size( nW, nH ) ) - : Rectangle(); + long nW = nWidth - TAB_OFFSET * 2; + long nH = nHeight - TAB_OFFSET * 2; + return ( nW > 0 && nH > 0 ) + ? Rectangle( Point( TAB_OFFSET, TAB_OFFSET ), Size( nW, nH ) ) + : Rectangle(); + } + + if ( ( nWidth < 0 ) || ( nHeight < 0 ) ) { + Size aWinSize = Control::GetOutputSizePixel(); + if ( nWidth < 0 ) + nWidth = aWinSize.Width(); + if ( nHeight < 0 ) + nHeight = aWinSize.Height(); } if ( nItemPos == TAB_PAGERECT ) { - sal_uInt16 nLastPos; + sal_uInt16 nCurPagePos = 0; if ( mnCurPageId ) - nLastPos = GetPagePos( mnCurPageId ); - else - nLastPos = 0; - - Rectangle aRect = ImplGetTabRect( nLastPos, nWidth, nHeight ); - long nW = nWidth-TAB_OFFSET*2; - long nH = nHeight-aRect.Bottom()-TAB_OFFSET*2; - aRect = (nW > 0 && nH > 0) - ? Rectangle( Point( TAB_OFFSET, aRect.Bottom()+TAB_OFFSET ), Size( nW, nH ) ) - : Rectangle(); + nCurPagePos = GetPagePos( mnCurPageId ); + + Rectangle aRect = ImplGetTabRect( nCurPagePos, nWidth, nHeight ); + long nW = nWidth; + long nH = nHeight - aRect.Bottom(); + nW -= TAB_OFFSET * 2; + nH -= TAB_OFFSET * 2; + aRect = ( nW > 0 && nH > 0 ) + ? Rectangle( Point( TAB_OFFSET, aRect.Bottom() + TAB_OFFSET ), Size( nW, nH ) ) + : Rectangle(); return aRect; } nWidth -= 1; - if ( (nWidth <= 0) || (nHeight <= 0) ) + if ( ( nWidth <= 0 ) || ( nHeight <= 0 ) ) return Rectangle(); - if ( mbFormat || (mnLastWidth != nWidth) || (mnLastHeight != nHeight) ) + if ( mbFormat || ( mnLastWidth != nWidth ) || ( mnLastHeight != nHeight ) ) { - vcl::Font aFont( GetFont() ); - aFont.SetTransparent( true ); - SetFont( aFont ); + ///vcl::Font aFont( GetFont() ); + ///aFont.SetTransparent( true ); + ///SetFont( aFont ); + // calculate offsets & sizes for each tab bool bRet = ImplPlaceTabs( nWidth ); if ( !bRet ) return Rectangle(); - mnLastWidth = nWidth; - mnLastHeight = nHeight; - mbFormat = false; + mnLastWidth = nWidth; + mnLastHeight = nHeight; + mbFormat = false; } - return size_t(nItemPos) < mpTabCtrlData->maItemList.size() ? mpTabCtrlData->maItemList[nItemPos].maRect : Rectangle(); + return static_cast< size_t >( nItemPos ) < mpTabCtrlData->maItemList.size() + ? mpTabCtrlData->maItemList[ nItemPos ].maRect : Rectangle(); } void TabControl::ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId ) @@ -1612,10 +1637,11 @@ void TabControl::SetTabPageSizePixel( const Size& rSize ) ImplFreeLayoutData(); Size aNewSize( rSize ); - aNewSize.Width() += TAB_OFFSET*2; - Rectangle aRect = ImplGetTabRect( TAB_PAGERECT, - aNewSize.Width(), aNewSize.Height() ); - aNewSize.Height() += aRect.Top()+TAB_OFFSET; + + aNewSize.Width() += TAB_OFFSET + TAB_OFFSET; + Rectangle aRect = ImplGetTabRect( TAB_PAGERECT, aNewSize.Width(), aNewSize.Height() ); + aNewSize.Height() += aRect.Top() + TAB_OFFSET; + Window::SetOutputSizePixel( aNewSize ); } |