summaryrefslogtreecommitdiffstats
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-04-21 15:00:34 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-04-21 15:03:13 +0100
commite29e3f47e687689c824d71718ae2ccaa4846ac51 (patch)
tree484aa0cf8d767a31d6470eb6c21339050a6f85a3 /svx
parentfix indent (diff)
downloadcore-e29e3f47e687689c824d71718ae2ccaa4846ac51.tar.gz
core-e29e3f47e687689c824d71718ae2ccaa4846ac51.zip
break out text drawing bit as UserDrawEntry
Change-Id: Icb1bcfb5f9f7475f67c9c001efdad2aa7e0d0834
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx57
1 files changed, 34 insertions, 23 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 19ea1e71d69c..031aabc237d4 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();