[Libreoffice-commits] core.git: 2 commits - svx/source
Caolán McNamara
caolanm at redhat.com
Tue Apr 21 07:07:50 PDT 2015
svx/source/tbxctrls/tbcontrl.cxx | 66 +++++++++++++++++++++------------------
1 file changed, 37 insertions(+), 29 deletions(-)
New commits:
commit e29e3f47e687689c824d71718ae2ccaa4846ac51
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Apr 21 15:00:34 2015 +0100
break out text drawing bit as UserDrawEntry
Change-Id: Icb1bcfb5f9f7475f67c9c001efdad2aa7e0d0834
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 19ea1e7..031aabc2 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -158,6 +158,7 @@ private:
void ReleaseFocus();
Color TestColorsVisible(const Color &FontCol, const Color &BackCol);
+ void UserDrawEntry(const UserDrawEvent& rUDEvt, const OUString &rStyleName);
DECL_LINK( MenuSelectHdl, Menu * );
};
@@ -546,6 +547,38 @@ void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange )
}
}
+void SvxStyleBox_Impl::UserDrawEntry(const UserDrawEvent& rUDEvt, const OUString &rStyleName)
+{
+ OutputDevice *pDevice = rUDEvt.GetDevice();
+
+ // IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as
+ // nBorder, and we are adding 1 in order to look better when
+ // italics is present
+ const int nLeftDistance = 8;
+
+ Rectangle aTextRect;
+ pDevice->GetTextBoundRect(aTextRect, rStyleName);
+
+ Point aPos( rUDEvt.GetRect().TopLeft() );
+ aPos.X() += nLeftDistance;
+ if ( aTextRect.Bottom() > rUDEvt.GetRect().GetHeight() )
+ {
+ // the text does not fit, adjust the font size
+ double ratio = static_cast< double >( rUDEvt.GetRect().GetHeight() ) / aTextRect.Bottom();
+ vcl::Font aFont(pDevice->GetFont());
+ Size aPixelSize(aFont.GetSize());
+ aPixelSize.Width() *= ratio;
+ aPixelSize.Height() *= ratio;
+ aFont.SetSize(aPixelSize);
+ pDevice->SetFont(aFont);
+ }
+ else
+ aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aTextRect.Bottom() ) / 2;
+
+ pDevice->DrawText(aPos, rStyleName);
+}
+
+
void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
{
sal_uInt16 nItem = rUDEvt.GetItemId();
@@ -716,29 +749,7 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
}
}
- // IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as
- // nBorder, and we are adding 1 in order to look better when
- // italics is present
- const int nLeftDistance = 8;
-
- Rectangle aTextRect;
- pDevice->GetTextBoundRect( aTextRect, aStyleName );
-
- Point aPos( rUDEvt.GetRect().TopLeft() );
- aPos.X() += nLeftDistance;
- if ( aTextRect.Bottom() > rUDEvt.GetRect().GetHeight() )
- {
- // the text does not fit, adjust the font size
- double ratio = static_cast< double >( rUDEvt.GetRect().GetHeight() ) / aTextRect.Bottom();
- aPixelSize.Width() *= ratio;
- aPixelSize.Height() *= ratio;
- aFont.SetSize( aPixelSize );
- pDevice->SetFont( aFont );
- }
- else
- aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aTextRect.Bottom() ) / 2;
-
- pDevice->DrawText( aPos, aStyleName );
+ UserDrawEntry(rUDEvt, aStyleName);
pDevice->Pop();
commit 7cf22a0a3202da296c1d1a3dafe6e1e5e1d7405d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Apr 21 14:39:57 2015 +0100
fix indent
Change-Id: I2628ac3fbabe9f33c41c7f3612eae608fb854ae3
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index ea648c8..19ea1e7 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -643,8 +643,7 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
// setup the device & draw
vcl::Font aOldFont( pDevice->GetFont() );
- Color aOldColor( pDevice->GetTextColor() );
- Color aOldFillColor( pDevice->GetFillColor() );
+ pDevice->Push(PushFlags::FILLCOLOR | PushFlags::FONT | PushFlags::TEXTCOLOR);
Color aFontCol = COL_AUTO, aBackCol = COL_AUTO;
@@ -682,7 +681,7 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
break;
//TODO Draw the other background styles: gradient, hatching and bitmap
- }
+ }
// when the font and background color are too similar, adjust the Font-Color
if( (aFontCol != COL_AUTO) || (aBackCol != COL_AUTO) )
@@ -741,9 +740,7 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
pDevice->DrawText( aPos, aStyleName );
- pDevice->SetFillColor( aOldFillColor );
- pDevice->SetTextColor( aOldColor );
- pDevice->SetFont( aOldFont );
+ pDevice->Pop();
// draw separator, if present
DrawEntry( rUDEvt, false, false );
More information about the Libreoffice-commits
mailing list