summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2012-01-25 12:36:17 +0000
committerNoel Power <noel.power@novell.com>2012-01-25 12:41:32 +0000
commit7580fff93292d08bc6f42792f256b832f5c4bad6 (patch)
treeaabf7c545e89bcbb073cafc297483a4920cbf318
parent259e0dfc293d455f1ea777de132730f7e5fde22d (diff)
fix initial height of multiline input window
There is a hardcoded preferred height for the input window that was getting picked up becuase the result of GetTextHeight was just '1' ( due to no font being set up ) We shouldn't use a hardcoded value, we should always use the proper text height e.g. the result of a successfull call to GetTextHeight() ( the patch makes sure we get a decent result from this call )
-rw-r--r--sc/source/ui/app/inputwin.cxx18
-rw-r--r--sc/source/ui/inc/inputwin.hxx2
2 files changed, 13 insertions, 7 deletions
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 1ae727c201e1..3771d375b0a8 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1128,6 +1128,15 @@ ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen, ScTabViewShell* pViewSh
mnLastExpandedLines( INPUTWIN_MULTILINES ),
mbInvalidate( false )
{
+ // Calculate the text height, need to set a font for that. Probably we could set the font
+ // here ( on this Window ) and avoid the temp Window. OTOH vcl is such a mystery I prefer
+ // to minimise possible unexpected side-affects this way
+ Window aTmp(this, WB_BORDER );
+ aTmp.SetFont(aTextFont);
+ mnTextHeight = LogicToPixel(Size(0,aTmp.GetTextHeight())).Height() ;
+ Size aBorder;
+ aBorder = CalcWindowSize( aBorder);
+ mnBorderHeight = aBorder.Height();
nTextStartPos = TEXT_MULTI_STARTPOS;
}
@@ -1158,13 +1167,8 @@ EditView* ScMultiTextWnd::GetEditView()
long ScMultiTextWnd::GetPixelHeightForLines( long nLines )
{
- long height = ( LogicToPixel(Size(0,GetTextHeight())).Height() );
- // need to figure out why GetTextHeight is not set up when I need it
- // some initialisation timing issue ?
- height = Max ( long( 14 ), height );
- // add padding ( for the borders of the window I guess ) otherwise we
- // chop slightly the top and bottom of whatever is in the inputbox
- return ( nLines * height ) + 4;
+ // add padding ( for the borders of the window )
+ return ( nLines * mnTextHeight ) + mnBorderHeight;
}
void ScMultiTextWnd::SetNumLines( long nLines )
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index eec7fede9ad4..185ac45d065c 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -204,6 +204,8 @@ private:
ScInputBarGroup& mrGroupBar;
long mnLines;
long mnLastExpandedLines;
+ long mnTextHeight;
+ long mnBorderHeight;
bool mbInvalidate;
};