From bee798cf4a91030184e01073c9aaaa5a66174600 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 28 Sep 2012 11:50:31 +0100 Subject: improve conditional formatting height calculations. Change-Id: If5080892b820d268ffef22111d0caee217586b56 --- sc/source/ui/condformat/condformatdlg.cxx | 37 +++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 3be5bc2ba239..ef69309bc64b 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -511,30 +511,25 @@ void ScCondFrmtEntry::HideColorScaleElements() void ScCondFrmtEntry::SetHeight() { - if(mbActive) + long nPad = LogicToPixel(Size(42,2), MapMode(MAP_APPFONT)).getHeight(); + + // Calculate maximum height we need from visible widgets + sal_uInt16 nChildren = GetChildCount(); + + long nMaxHeight = 0; + for(sal_uInt16 i = 0; i < nChildren; i++) { - Size aSize = GetSizePixel(); - switch (meType) - { - case CONDITION: - case FORMULA: - aSize.Height() = 120; - break; - case COLORSCALE: - aSize.Height() = 200; - break; - case DATABAR: - aSize.Height() = 200; - break; - default: - break; - } - SetSizePixel(aSize); + Window *pChild = GetChild(i); + if(!pChild || !pChild->IsVisible()) + continue; + Point aPos = pChild->GetPosPixel(); + Size aSize = pChild->GetSizePixel(); + nMaxHeight = std::max(aPos.Y() + aSize.Height(), nMaxHeight); } - else + Size aSize = GetSizePixel(); + if(nMaxHeight > 0) { - Size aSize = GetSizePixel(); - aSize.Height() = 40; + aSize.Height() = nMaxHeight + nPad; SetSizePixel(aSize); } } -- cgit