summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2012-01-25 12:36:17 +0000
committerEike Rathke <erack@redhat.com>2012-05-11 14:40:01 +0200
commita2859b0bdf4bc84ea02c3a59ae4d626739732643 (patch)
tree788e29645fafc22fa43a72a2c32cf630ce9ce71d
parentcf4410701e76cda3bf70032a5f1ac60c1ae9b261 (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 ) (cherry picked from commit 7580fff93292d08bc6f42792f256b832f5c4bad6) Signed-off-by: Eike Rathke <erack@redhat.com>
-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 b7592e30c025..b61ccb9e40a9 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1133,6 +1133,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;
}
@@ -1163,13 +1172,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 ae8383d1e727..b0facf100455 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -207,6 +207,8 @@ private:
ScInputBarGroup& mrGroupBar;
long mnLines;
long mnLastExpandedLines;
+ long mnTextHeight;
+ long mnBorderHeight;
bool mbInvalidate;
};