diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-08-04 15:43:37 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-08-04 15:48:49 +0100 |
commit | cc62d87d5f1abcff2affd56f1077114289c68c7e (patch) | |
tree | e7a607a96b4b1f7136788ee64b408616063cf412 /vcl/source/control/edit.cxx | |
parent | 97746e61ffe48cf3612d2dff5535914a8a1219f6 (diff) |
use same scheme in Edit and ListBox for rendering text in ::Draw
Change-Id: I5b17103e838f221cf3815002979c6b8c9c443300
Diffstat (limited to 'vcl/source/control/edit.cxx')
-rw-r--r-- | vcl/source/control/edit.cxx | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index b6a49898d7c8..8e41d0e457b0 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -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() ) |