summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-10-09 14:22:17 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-10-09 15:08:37 +0200
commita35df7f88161956f92e1d501c83a32f927268f98 (patch)
treefd240576e96888e5d3bf6d934748138915e1b99f /vcl
parentd5c18dc3e8bb107e8ddf960261bb9257f2e49a35 (diff)
Abstract out repeated code into lambdas
...to silence a clang-analyzer-deadcode.DeadStores on the last update of nLeft and nRight, each. Also, adding a gap of 3 to nRight in case no further buttons will be layed out next to maDockRect resp. maHideRect is irrelevant, as nRight will not be used for any further layout computations in those cases. Change-Id: I251d4470099b1f98782ebdfd0c776d881bb7fae5
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/brdwin.cxx72
1 files changed, 29 insertions, 43 deletions
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index cdc45bc068fe..773aaa7bf827 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -1431,74 +1431,60 @@ void ImplStdBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeigh
if ( pData->mnTitleType & (BORDERWINDOW_TITLE_NORMAL | BORDERWINDOW_TITLE_SMALL) )
{
- long nLeft = pData->maTitleRect.Left();
- long nRight = pData->maTitleRect.Right();
- long nItemTop = pData->maTitleRect.Top();
- long nItemBottom = pData->maTitleRect.Bottom();
- nLeft += 1;
- nRight -= 3;
- nItemTop += 2;
- nItemBottom -= 2;
+ long nLeft = pData->maTitleRect.Left() + 1;
+ long nRight = pData->maTitleRect.Right() - 3;
+ long const nItemTop = pData->maTitleRect.Top() + 2;
+ long const nItemBottom = pData->maTitleRect.Bottom() - 2;
+
+ auto addOnLeft = [&nLeft, nItemTop, nItemBottom](
+ Rectangle & rect, long width, long gap)
+ {
+ rect.Top() = nItemTop;
+ rect.Bottom() = nItemBottom;
+ rect.Left() = nLeft;
+ rect.Right() = rect.Left() + width;
+ nLeft += rect.GetWidth() + gap;
+ };
+ auto addSquareOnRight = [&nRight, nItemTop, nItemBottom](
+ Rectangle & rect, long gap)
+ {
+ rect.Top() = nItemTop;
+ rect.Bottom() = nItemBottom;
+ rect.Right() = nRight;
+ rect.Left() = rect.Right() - rect.GetHeight() + 1;
+ nRight -= rect.GetWidth() + gap;
+ };
if ( pBorderWindow->GetStyle() & WB_PINABLE )
{
Image aImage;
ImplGetPinImage( DrawButtonFlags::NONE, false, aImage );
- pData->maPinRect.Top() = nItemTop;
- pData->maPinRect.Bottom() = nItemBottom;
- pData->maPinRect.Left() = nLeft;
- pData->maPinRect.Right() = pData->maPinRect.Left()+aImage.GetSizePixel().Width();
- nLeft += pData->maPinRect.GetWidth()+3;
+ addOnLeft(pData->maPinRect, aImage.GetSizePixel().Width(), 3);
}
if ( pBorderWindow->GetStyle() & WB_CLOSEABLE )
{
- pData->maCloseRect.Top() = nItemTop;
- pData->maCloseRect.Bottom() = nItemBottom;
- pData->maCloseRect.Right() = nRight;
- pData->maCloseRect.Left() = pData->maCloseRect.Right()-pData->maCloseRect.GetHeight()+1;
- nRight -= pData->maCloseRect.GetWidth()+3;
+ addSquareOnRight(pData->maCloseRect, 3);
}
if ( pBorderWindow->mbMenuBtn )
{
- pData->maMenuRect.Top() = nItemTop;
- pData->maMenuRect.Bottom() = nItemBottom;
- pData->maMenuRect.Right() = nRight;
- pData->maMenuRect.Left() = pData->maMenuRect.Right()-pData->maMenuRect.GetHeight()+1;
- nRight -= pData->maMenuRect.GetWidth();
+ addSquareOnRight(pData->maMenuRect, 0);
}
if ( pBorderWindow->mbDockBtn )
{
- pData->maDockRect.Top() = nItemTop;
- pData->maDockRect.Bottom() = nItemBottom;
- pData->maDockRect.Right() = nRight;
- pData->maDockRect.Left() = pData->maDockRect.Right()-pData->maDockRect.GetHeight()+1;
- nRight -= pData->maDockRect.GetWidth();
- if ( !pBorderWindow->mbHideBtn &&
- !(pBorderWindow->GetStyle() & WB_ROLLABLE) )
- nRight -= 3;
+ addSquareOnRight(pData->maDockRect, 0);
}
if ( pBorderWindow->mbHideBtn )
{
- pData->maHideRect.Top() = nItemTop;
- pData->maHideRect.Bottom() = nItemBottom;
- pData->maHideRect.Right() = nRight;
- pData->maHideRect.Left() = pData->maHideRect.Right()-pData->maHideRect.GetHeight()+1;
- nRight -= pData->maHideRect.GetWidth();
- if ( !(pBorderWindow->GetStyle() & WB_ROLLABLE) )
- nRight -= 3;
+ addSquareOnRight(pData->maHideRect, 0);
}
if ( pBorderWindow->GetStyle() & WB_ROLLABLE )
{
- pData->maRollRect.Top() = nItemTop;
- pData->maRollRect.Bottom() = nItemBottom;
- pData->maRollRect.Right() = nRight;
- pData->maRollRect.Left() = pData->maRollRect.Right()-pData->maRollRect.GetHeight()+1;
- nRight -= pData->maRollRect.GetWidth();
+ addSquareOnRight(pData->maRollRect, 0);
}
}
else