summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-14 14:04:58 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-14 14:04:58 +0900
commit5b4408dab502ffef99e57244832a332497989e99 (patch)
tree7eac8f66c2aa3b7494341a7ffe5e2703bf29ecb8 /starmath
parente42cc88032d3f59b289e5ff454101971eecc4bea (diff)
SmShowFont: change to save the font and use it in Paint + HiDPI
No painting should be performed outside of Paint hierarchy. Change-Id: I97a8d6429abcd6022e9bf89295dc2944485984eb
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/dialog.hxx2
-rw-r--r--starmath/source/dialog.cxx44
2 files changed, 23 insertions, 23 deletions
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx
index c67190b250b5..ec70f02ca8a6 100644
--- a/starmath/inc/dialog.hxx
+++ b/starmath/inc/dialog.hxx
@@ -81,6 +81,8 @@ class SmShowFont : public vcl::Window
{
virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
+ vcl::Font maFont;
+
public:
SmShowFont(vcl::Window *pParent, WinBits nStyle)
: Window(pParent, nStyle)
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 686c60c96e24..f28a9a291880 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -64,15 +64,15 @@ public:
SmFontStyles();
static sal_uInt16 GetCount() { return 4; }
- const OUString& GetStyleName( const vcl::Font &rFont ) const;
- const OUString& GetStyleName( sal_uInt16 nIdx ) const;
+ const OUString& GetStyleName(const vcl::Font& rFont) const;
+ const OUString& GetStyleName(sal_uInt16 nIdx) const;
};
SmFontStyles::SmFontStyles() :
- aNormal ( ResId( RID_FONTREGULAR, *SM_MOD()->GetResMgr() ) ),
- aBold ( ResId( RID_FONTBOLD, *SM_MOD()->GetResMgr() ) ),
- aItalic ( ResId( RID_FONTITALIC, *SM_MOD()->GetResMgr() ) )
+ aNormal (ResId(RID_FONTREGULAR, *SM_MOD()->GetResMgr())),
+ aBold (ResId(RID_FONTBOLD, *SM_MOD()->GetResMgr())),
+ aItalic (ResId(RID_FONTITALIC, *SM_MOD()->GetResMgr()))
{
aBoldItalic = aBold;
@@ -81,7 +81,7 @@ SmFontStyles::SmFontStyles() :
}
-const OUString& SmFontStyles::GetStyleName( const vcl::Font &rFont ) const
+const OUString& SmFontStyles::GetStyleName(const vcl::Font& rFont) const
{
//! compare also SmSpecialNode::Prepare
bool bBold = IsBold( rFont ),
@@ -146,16 +146,13 @@ void SetFontStyle(const OUString &rStyleName, vcl::Font &rFont)
rFont.SetWeight((nIndex & 0x2) ? WEIGHT_BOLD : WEIGHT_NORMAL);
}
-
-/**************************************************************************/
-
IMPL_LINK( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *,/*pButton*/ )
{
m_pZoom->Enable(m_pSizeZoomed->IsChecked());
return 0;
}
-SmPrintOptionsTabPage::SmPrintOptionsTabPage(vcl::Window *pParent, const SfxItemSet &rOptions)
+SmPrintOptionsTabPage::SmPrintOptionsTabPage(vcl::Window* pParent, const SfxItemSet& rOptions)
: SfxTabPage(pParent, "SmathSettings", "modules/smath/ui/smathsettings.ui", &rOptions)
{
get( m_pTitle, "title");
@@ -241,15 +238,24 @@ VclPtr<SfxTabPage> SmPrintOptionsTabPage::Create(vcl::Window* pWindow, const Sfx
return VclPtr<SmPrintOptionsTabPage>::Create(pWindow, rSet).get();
}
-void SmShowFont::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect )
+void SmShowFont::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
{
Window::Paint(rRenderContext, rRect);
+ Color aTxtColor(rRenderContext.GetTextColor());
+ vcl::Font aFont(maFont);
+ aFont.SetSize(Size(0, 24 * rRenderContext.GetDPIScaleFactor()));
+ aFont.SetAlign(ALIGN_TOP);
+ rRenderContext.SetFont(aFont);
+
+ // keep old text color (new font may have different color)
+ rRenderContext.SetTextColor(aTxtColor);
+
OUString sText(rRenderContext.GetFont().GetName());
- Size TextSize(rRenderContext.GetTextWidth(sText), rRenderContext.GetTextHeight());
+ Size aTextSize(rRenderContext.GetTextWidth(sText), rRenderContext.GetTextHeight());
- rRenderContext.DrawText(Point((GetOutputSize().Width() - TextSize.Width()) / 2,
- (GetOutputSize().Height() - TextSize.Height()) / 2), sText);
+ rRenderContext.DrawText(Point((rRenderContext.GetOutputSize().Width() - aTextSize.Width()) / 2,
+ (rRenderContext.GetOutputSize().Height() - aTextSize.Height()) / 2), sText);
}
VCL_BUILDER_DECL_FACTORY(SmShowFont)
@@ -270,16 +276,8 @@ Size SmShowFont::GetOptimalSize() const
void SmShowFont::SetFont(const vcl::Font& rFont)
{
- Color aTxtColor( GetTextColor() );
- vcl::Font aFont (rFont);
-
+ maFont = rFont;
Invalidate();
- aFont.SetSize(Size(0, 24));
- aFont.SetAlign(ALIGN_TOP);
- Window::SetFont(aFont);
-
- // keep old text color (new font may have different color)
- SetTextColor( aTxtColor );
}
IMPL_LINK( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )