[Libreoffice-commits] core.git: 2 commits - vcl/source
Caolán McNamara
caolanm at redhat.com
Thu Aug 4 14:49:22 UTC 2016
vcl/source/control/edit.cxx | 30 ++++++++++++++++--------------
vcl/source/control/listbox.cxx | 8 ++++----
2 files changed, 20 insertions(+), 18 deletions(-)
New commits:
commit 628a21e7e4dad565f676252fdd50cd7423e12f6f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Aug 4 15:46:48 2016 +0100
like listbox put margins on both sides of an edit too
Change-Id: I425b1005297b20ace85181edce72ab5829006a0e
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 8e41d0e..d4d9936 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1819,15 +1819,12 @@ void Edit::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawF
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;
- }
+
+ aTextRect.Left() += nOffX;
+ aTextRect.Right() -= nOffX;
OUString aText = ImplGetText();
long nTextHeight = pDev->GetTextHeight();
commit cc62d87d5f1abcff2affd56f1077114289c68c7e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Aug 4 15:43:37 2016 +0100
use same scheme in Edit and ListBox for rendering text in ::Draw
Change-Id: I5b17103e838f221cf3815002979c6b8c9c443300
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index b6a4989..8e41d0e 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() )
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index 5b35044..b95c1dc 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -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?
More information about the Libreoffice-commits
mailing list