use same scheme in Edit and ListBox for rendering text in ::Draw
Change-Id: I5b17103e838f221cf3815002979c6b8c9c443300
This commit is contained in:
@@ -1811,11 +1811,27 @@ void Edit::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawF
|
||||
}
|
||||
}
|
||||
|
||||
const long nOnePixel = GetDrawPixel( pDev, 1 );
|
||||
const long nOffX = 3*nOnePixel;
|
||||
DrawTextFlags nTextStyle = DrawTextFlags::VCenter;
|
||||
Rectangle aTextRect( aPos, aSize );
|
||||
|
||||
if ( GetStyle() & WB_CENTER )
|
||||
nTextStyle |= DrawTextFlags::Center;
|
||||
else if ( GetStyle() & WB_RIGHT )
|
||||
{
|
||||
nTextStyle |= DrawTextFlags::Right;
|
||||
aTextRect.Left() += nOffX;
|
||||
}
|
||||
else
|
||||
{
|
||||
nTextStyle |= DrawTextFlags::Left;
|
||||
aTextRect.Right() -= nOffX;
|
||||
}
|
||||
|
||||
OUString aText = ImplGetText();
|
||||
long nTextHeight = pDev->GetTextHeight();
|
||||
long nTextWidth = pDev->GetTextWidth( aText );
|
||||
long nOnePixel = GetDrawPixel( pDev, 1 );
|
||||
long nOffX = 3*nOnePixel;
|
||||
long nOffY = (aSize.Height() - nTextHeight) / 2;
|
||||
|
||||
// Clipping?
|
||||
@@ -1829,18 +1845,7 @@ void Edit::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawF
|
||||
pDev->IntersectClipRegion( aClip );
|
||||
}
|
||||
|
||||
if ( GetStyle() & WB_CENTER )
|
||||
{
|
||||
aPos.X() += (aSize.Width() - nTextWidth) / 2;
|
||||
nOffX = 0;
|
||||
}
|
||||
else if ( GetStyle() & WB_RIGHT )
|
||||
{
|
||||
aPos.X() += aSize.Width() - nTextWidth;
|
||||
nOffX = -nOffX;
|
||||
}
|
||||
|
||||
pDev->DrawText( Point( aPos.X() + nOffX, aPos.Y() + nOffY ), aText );
|
||||
pDev->DrawText( aTextRect, aText, nTextStyle );
|
||||
pDev->Pop();
|
||||
|
||||
if ( GetSubEdit() )
|
||||
|
@@ -412,7 +412,8 @@ void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, Dr
|
||||
}
|
||||
}
|
||||
|
||||
long nOnePixel = GetDrawPixel( pDev, 1 );
|
||||
const long nOnePixel = GetDrawPixel( pDev, 1 );
|
||||
const long nOffX = 3*nOnePixel;
|
||||
DrawTextFlags nTextStyle = DrawTextFlags::VCenter;
|
||||
Rectangle aTextRect( aPos, aSize );
|
||||
|
||||
@@ -423,15 +424,14 @@ void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, Dr
|
||||
else
|
||||
nTextStyle |= DrawTextFlags::Left;
|
||||
|
||||
aTextRect.Left() += 3*nOnePixel;
|
||||
aTextRect.Right() -= 3*nOnePixel;
|
||||
aTextRect.Left() += nOffX;
|
||||
aTextRect.Right() -= nOffX;
|
||||
|
||||
if ( IsDropDownBox() )
|
||||
{
|
||||
OUString aText = GetSelectEntry();
|
||||
long nTextHeight = pDev->GetTextHeight();
|
||||
long nTextWidth = pDev->GetTextWidth( aText );
|
||||
long nOffX = 3*nOnePixel;
|
||||
long nOffY = (aSize.Height()-nTextHeight) / 2;
|
||||
|
||||
// Clipping?
|
||||
|
Reference in New Issue
Block a user