summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-25 16:18:23 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-25 16:31:23 +0900
commitdd0996f7b230e76f35cc3464b85dd46e90098c3d (patch)
treebfc142cc03255debbaa7badabe56d3cb82412d2f
parent950b6046c7618cf4792d9f70c4fab9a6a8dde5cf (diff)
use RenderContext in user draw, use ApplySettings
Change-Id: I6cc22677000459a5f19bfb207007f5c246f187e0
-rw-r--r--vcl/inc/ilstbox.hxx8
-rw-r--r--vcl/source/control/combobox.cxx2
-rw-r--r--vcl/source/control/ilstbox.cxx135
-rw-r--r--vcl/source/control/lstbox.cxx6
4 files changed, 47 insertions, 104 deletions
diff --git a/vcl/inc/ilstbox.hxx b/vcl/inc/ilstbox.hxx
index 8a5bca2a608b..363483e209f7 100644
--- a/vcl/inc/ilstbox.hxx
+++ b/vcl/inc/ilstbox.hxx
@@ -564,11 +564,11 @@ private:
bool mbInUserDraw : 1;
bool mbEdgeBlending : 1;
- void ImplDraw( bool bLayout = false );
+ void ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout = false);
protected:
virtual void FillLayoutData() const SAL_OVERRIDE;
-public:
+public:
ImplWin( vcl::Window* pParent, WinBits nWinStyle = 0 );
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
@@ -598,7 +598,8 @@ public:
void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
- void DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false );
+ void DrawEntry(vcl::RenderContext& rRenderContext, bool bDrawImage, bool bDrawText,
+ bool bDrawTextAtImagePos = false, bool bLayout = false);
bool GetEdgeBlending() const { return mbEdgeBlending; }
void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
@@ -606,7 +607,6 @@ public:
virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
using Control::ImplInitSettings;
- void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
};
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 59656c90344f..f16fd05ed0f2 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1131,7 +1131,7 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines
void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
{
- mpImplLB->GetMainWindow()->ImplInitSettings( true, true, true );
+ mpImplLB->GetMainWindow()->ApplySettings(*pDev);
Point aPos = pDev->LogicToPixel( rPos );
Size aSize = pDev->LogicToPixel( rSize );
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index 28e5889fcdd4..5bdc36be8bd9 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -502,7 +502,7 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle )
SetTextFillColor();
SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
- ImplInitSettings( true, true, true );
+ ApplySettings(*this);
ImplCalcMetrics();
}
@@ -537,35 +537,6 @@ void ImplListBoxWindow::ApplySettings(vcl::RenderContext& rRenderContext)
rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
}
-void ImplListBoxWindow::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
-{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
- if (bFont)
- {
- vcl::Font aFont = rStyleSettings.GetFieldFont();
- if (IsControlFont())
- aFont.Merge(GetControlFont());
- SetZoomedPointFont(*this, aFont);
- }
-
- if (bFont || bForeground)
- {
- Color aTextColor = rStyleSettings.GetFieldTextColor();
- if (IsControlForeground())
- aTextColor = GetControlForeground();
- SetTextColor( aTextColor );
- }
-
- if (bBackground)
- {
- if (IsControlBackground())
- SetBackground(GetControlBackground());
- else
- SetBackground(rStyleSettings.GetFieldColor());
- }
-}
-
void ImplListBoxWindow::ImplCalcMetrics()
{
mnMaxWidth = 0;
@@ -1743,7 +1714,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32
}
else
{
- ImplInitSettings(false, true, false);
+ ApplySettings(*this);
if (!IsEnabled())
rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
rRenderContext.SetTextFillColor();
@@ -1765,7 +1736,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32
nCurr = GetEntryList()->FindEntry(GetEntryList()->GetEntryText(nCurr));
nCurr = sal::static_int_cast<sal_Int32>(nCurr - GetEntryList()->GetMRUCount());
- UserDrawEvent aUDEvt(this, aRect, nPos, nCurr);
+ UserDrawEvent aUDEvt(&rRenderContext, aRect, nPos, nCurr);
userDrawSignal(&aUDEvt);
mbInUserDraw = false;
}
@@ -2088,7 +2059,7 @@ void ImplListBoxWindow::StateChanged( StateChangedType nType )
if ( nType == StateChangedType::Zoom )
{
- ImplInitSettings( true, false, false );
+ ApplySettings(*this);
ImplCalcMetrics();
Invalidate();
}
@@ -2099,18 +2070,18 @@ void ImplListBoxWindow::StateChanged( StateChangedType nType )
}
else if ( nType == StateChangedType::ControlFont )
{
- ImplInitSettings( true, false, false );
+ ApplySettings(*this);
ImplCalcMetrics();
Invalidate();
}
else if ( nType == StateChangedType::ControlForeground )
{
- ImplInitSettings( false, true, false );
+ ApplySettings(*this);
Invalidate();
}
else if ( nType == StateChangedType::ControlBackground )
{
- ImplInitSettings( false, false, true );
+ ApplySettings(*this);
Invalidate();
}
else if( nType == StateChangedType::Enable )
@@ -2131,7 +2102,7 @@ void ImplListBoxWindow::DataChanged( const DataChangedEvent& rDCEvt )
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
{
ImplClearLayoutData();
- ImplInitSettings( true, true, true );
+ ApplySettings(*this);
ImplCalcMetrics();
Invalidate();
}
@@ -2652,7 +2623,8 @@ void ImplWin::MouseButtonDown( const MouseEvent& )
void ImplWin::FillLayoutData() const
{
mpControlData->mpLayoutData = new vcl::ControlLayoutData();
- const_cast<ImplWin*>(this)->ImplDraw( true );
+ ImplWin* pThis = const_cast<ImplWin*>(this);
+ pThis->ImplDraw(*pThis, true);
}
bool ImplWin::PreNotify( NotifyEvent& rNEvt )
@@ -2676,17 +2648,17 @@ bool ImplWin::PreNotify( NotifyEvent& rNEvt )
return Control::PreNotify(rNEvt);
}
-void ImplWin::ImplDraw( bool bLayout )
+void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout)
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- if( ! bLayout )
+ if (!bLayout)
{
bool bNativeOK = false;
ControlState nState = ControlState::ENABLED;
- if ( IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
- && IsNativeControlSupported(CTRL_LISTBOX, HAS_BACKGROUND_TEXTURE) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
+ && rRenderContext.IsNativeControlSupported(CTRL_LISTBOX, HAS_BACKGROUND_TEXTURE) )
{
// Repaint the (focused) area similarly to
// ImplSmallBorderWindowView::DrawWindow() in
@@ -2728,17 +2700,17 @@ void ImplWin::ImplDraw( bool bLayout )
nState, aControlValue, OUString() );
}
- bNativeOK = DrawNativeControl( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
- aControlValue, OUString() );
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_LISTBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
+ nState, aControlValue, OUString());
}
- if( IsEnabled() )
+ if (IsEnabled())
{
if (HasFocus() && !ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea)
{
- SetTextColor( rStyleSettings.GetHighlightTextColor() );
- SetFillColor( rStyleSettings.GetHighlightColor() );
- DrawRect( maFocusRect );
+ rRenderContext.SetTextColor( rStyleSettings.GetHighlightTextColor() );
+ rRenderContext.SetFillColor( rStyleSettings.GetHighlightColor() );
+ rRenderContext.DrawRect( maFocusRect );
}
else
{
@@ -2757,31 +2729,31 @@ void ImplWin::ImplDraw( bool bLayout )
else
aColor = rStyleSettings.GetFieldTextColor();
}
- if( IsControlForeground() )
+ if (IsControlForeground())
aColor = GetControlForeground();
- SetTextColor( aColor );
- if ( !bNativeOK )
- Erase( maFocusRect );
+ rRenderContext.SetTextColor(aColor);
+ if (!bNativeOK)
+ rRenderContext.Erase(maFocusRect);
}
}
else // Disabled
{
- SetTextColor( rStyleSettings.GetDisableColor() );
- if ( !bNativeOK )
- Erase( maFocusRect );
+ rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
+ if (!bNativeOK)
+ rRenderContext.Erase(maFocusRect);
}
}
if ( IsUserDrawEnabled() )
{
mbInUserDraw = true;
- UserDrawEvent aUDEvt( this, maFocusRect, mnItemPos, 0 );
+ UserDrawEvent aUDEvt(&rRenderContext, maFocusRect, mnItemPos, 0);
userDrawSignal( &aUDEvt );
mbInUserDraw = false;
}
else
{
- DrawEntry( true, true, false, bLayout );
+ DrawEntry(rRenderContext, true, true, false, bLayout);
}
}
@@ -2805,47 +2777,18 @@ void ImplWin::ApplySettings(vcl::RenderContext& rRenderContext)
rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
}
-void ImplWin::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
+void ImplWin::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
- if (bFont)
- {
- vcl::Font aFont = rStyleSettings.GetFieldFont();
- if (IsControlFont())
- aFont.Merge(GetControlFont());
- SetZoomedPointFont(*this, aFont);
- }
-
- if (bFont || bForeground)
- {
- Color aTextColor = rStyleSettings.GetFieldTextColor();
- if (IsControlForeground())
- aTextColor = GetControlForeground();
- SetTextColor( aTextColor );
- }
-
- if (bBackground)
- {
- if (IsControlBackground())
- SetBackground(GetControlBackground());
- else
- SetBackground(rStyleSettings.GetFieldColor());
- }
+ ImplDraw(rRenderContext);
}
-void ImplWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
-{
- ImplDraw();
-}
-
-void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos, bool bLayout )
+void ImplWin::DrawEntry(vcl::RenderContext& rRenderContext, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos, bool bLayout)
{
long nBorder = 1;
- Size aOutSz = GetOutputSizePixel();
+ Size aOutSz = rRenderContext.GetOutputSizePixel();
bool bImage = !!maImage;
- if( bDrawImage && bImage && !bLayout )
+ if (bDrawImage && bImage && !bLayout)
{
DrawImageFlags nStyle = DrawImageFlags::NONE;
Size aImgSz = maImage.GetSizePixel();
@@ -2857,13 +2800,13 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP
if ( !IsZoom() )
{
- DrawImage( aPtImg, *pImage, nStyle );
+ rRenderContext.DrawImage( aPtImg, *pImage, nStyle );
}
else
{
aImgSz.Width() = CalcZoom( aImgSz.Width() );
aImgSz.Height() = CalcZoom( aImgSz.Height() );
- DrawImage( aPtImg, aImgSz, *pImage, nStyle );
+ rRenderContext.DrawImage( aPtImg, aImgSz, *pImage, nStyle );
}
const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0);
@@ -2877,7 +2820,7 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP
if(!aBlendFrame.IsEmpty())
{
- DrawBitmapEx(aPtImg, aBlendFrame);
+ rRenderContext.DrawBitmapEx(aPtImg, aBlendFrame);
}
}
}
@@ -2905,7 +2848,7 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP
MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
OUString* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
- DrawText( aTextRect, maString, nTextStyle, pVector, pDisplayText );
+ rRenderContext.DrawText( aTextRect, maString, nTextStyle, pVector, pDisplayText );
}
if( HasFocus() && !bLayout )
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 857f78f3d714..bd5bb65f7800 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -375,7 +375,7 @@ void ListBox::ApplySettings(vcl::RenderContext& rRenderContext)
void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
{
- mpImplLB->GetMainWindow()->ImplInitSettings( true, true, true );
+ mpImplLB->GetMainWindow()->ApplySettings(*pDev);
Point aPos = pDev->LogicToPixel( rPos );
Size aSize = pDev->LogicToPixel( rSize );
@@ -555,7 +555,7 @@ void ListBox::DataChanged( const DataChangedEvent& rDCEvt )
if ( mpImplWin )
{
mpImplWin->SetSettings( GetSettings() ); // If not yet set...
- mpImplWin->ImplInitSettings(true, true, true);
+ mpImplWin->ApplySettings(*this);
mpBtn->SetSettings( GetSettings() );
ImplInitDropDownButton( mpBtn );
@@ -1386,7 +1386,7 @@ void ListBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawTe
if (rEvt.GetDevice() == mpImplLB->GetMainWindow())
mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetDevice(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
else if (rEvt.GetDevice() == mpImplWin)
- mpImplWin->DrawEntry(bDrawImage, bDrawText, bDrawTextAtImagePos);
+ mpImplWin->DrawEntry(*rEvt.GetDevice(), bDrawImage, bDrawText, bDrawTextAtImagePos);
}
void ListBox::SetUserItemSize( const Size& rSz )