Kaydet (Commit) 21a0496a authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Jan Holesovsky

use RenderContext in user draw, use ApplySettings

Change-Id: I6cc22677000459a5f19bfb207007f5c246f187e0
Signed-off-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 8c7e2b27
...@@ -564,11 +564,11 @@ private: ...@@ -564,11 +564,11 @@ private:
bool mbInUserDraw : 1; bool mbInUserDraw : 1;
bool mbEdgeBlending : 1; bool mbEdgeBlending : 1;
void ImplDraw( bool bLayout = false ); void ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout = false);
protected: protected:
virtual void FillLayoutData() const SAL_OVERRIDE; virtual void FillLayoutData() const SAL_OVERRIDE;
public:
public:
ImplWin( vcl::Window* pParent, WinBits nWinStyle = 0 ); ImplWin( vcl::Window* pParent, WinBits nWinStyle = 0 );
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
...@@ -598,7 +598,8 @@ public: ...@@ -598,7 +598,8 @@ public:
void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } 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; } bool GetEdgeBlending() const { return mbEdgeBlending; }
void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; } void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
...@@ -606,7 +607,6 @@ public: ...@@ -606,7 +607,6 @@ public:
virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE; virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
using Control::ImplInitSettings; using Control::ImplInitSettings;
void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
}; };
......
...@@ -1131,7 +1131,7 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ...@@ -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 ) 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 ); Point aPos = pDev->LogicToPixel( rPos );
Size aSize = pDev->LogicToPixel( rSize ); Size aSize = pDev->LogicToPixel( rSize );
......
...@@ -502,7 +502,7 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle ) ...@@ -502,7 +502,7 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle )
SetTextFillColor(); SetTextFillColor();
SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) ); SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
ImplInitSettings( true, true, true ); ApplySettings(*this);
ImplCalcMetrics(); ImplCalcMetrics();
} }
...@@ -537,35 +537,6 @@ void ImplListBoxWindow::ApplySettings(vcl::RenderContext& rRenderContext) ...@@ -537,35 +537,6 @@ void ImplListBoxWindow::ApplySettings(vcl::RenderContext& rRenderContext)
rRenderContext.SetBackground(rStyleSettings.GetFieldColor()); 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() void ImplListBoxWindow::ImplCalcMetrics()
{ {
mnMaxWidth = 0; mnMaxWidth = 0;
...@@ -1743,7 +1714,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 ...@@ -1743,7 +1714,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32
} }
else else
{ {
ImplInitSettings(false, true, false); ApplySettings(*this);
if (!IsEnabled()) if (!IsEnabled())
rRenderContext.SetTextColor(rStyleSettings.GetDisableColor()); rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
rRenderContext.SetTextFillColor(); rRenderContext.SetTextFillColor();
...@@ -1765,7 +1736,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 ...@@ -1765,7 +1736,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32
nCurr = GetEntryList()->FindEntry(GetEntryList()->GetEntryText(nCurr)); nCurr = GetEntryList()->FindEntry(GetEntryList()->GetEntryText(nCurr));
nCurr = sal::static_int_cast<sal_Int32>(nCurr - GetEntryList()->GetMRUCount()); nCurr = sal::static_int_cast<sal_Int32>(nCurr - GetEntryList()->GetMRUCount());
UserDrawEvent aUDEvt(this, aRect, nPos, nCurr); UserDrawEvent aUDEvt(&rRenderContext, aRect, nPos, nCurr);
userDrawSignal(&aUDEvt); userDrawSignal(&aUDEvt);
mbInUserDraw = false; mbInUserDraw = false;
} }
...@@ -2088,7 +2059,7 @@ void ImplListBoxWindow::StateChanged( StateChangedType nType ) ...@@ -2088,7 +2059,7 @@ void ImplListBoxWindow::StateChanged( StateChangedType nType )
if ( nType == StateChangedType::Zoom ) if ( nType == StateChangedType::Zoom )
{ {
ImplInitSettings( true, false, false ); ApplySettings(*this);
ImplCalcMetrics(); ImplCalcMetrics();
Invalidate(); Invalidate();
} }
...@@ -2099,18 +2070,18 @@ void ImplListBoxWindow::StateChanged( StateChangedType nType ) ...@@ -2099,18 +2070,18 @@ void ImplListBoxWindow::StateChanged( StateChangedType nType )
} }
else if ( nType == StateChangedType::ControlFont ) else if ( nType == StateChangedType::ControlFont )
{ {
ImplInitSettings( true, false, false ); ApplySettings(*this);
ImplCalcMetrics(); ImplCalcMetrics();
Invalidate(); Invalidate();
} }
else if ( nType == StateChangedType::ControlForeground ) else if ( nType == StateChangedType::ControlForeground )
{ {
ImplInitSettings( false, true, false ); ApplySettings(*this);
Invalidate(); Invalidate();
} }
else if ( nType == StateChangedType::ControlBackground ) else if ( nType == StateChangedType::ControlBackground )
{ {
ImplInitSettings( false, false, true ); ApplySettings(*this);
Invalidate(); Invalidate();
} }
else if( nType == StateChangedType::Enable ) else if( nType == StateChangedType::Enable )
...@@ -2131,7 +2102,7 @@ void ImplListBoxWindow::DataChanged( const DataChangedEvent& rDCEvt ) ...@@ -2131,7 +2102,7 @@ void ImplListBoxWindow::DataChanged( const DataChangedEvent& rDCEvt )
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
{ {
ImplClearLayoutData(); ImplClearLayoutData();
ImplInitSettings( true, true, true ); ApplySettings(*this);
ImplCalcMetrics(); ImplCalcMetrics();
Invalidate(); Invalidate();
} }
...@@ -2652,7 +2623,8 @@ void ImplWin::MouseButtonDown( const MouseEvent& ) ...@@ -2652,7 +2623,8 @@ void ImplWin::MouseButtonDown( const MouseEvent& )
void ImplWin::FillLayoutData() const void ImplWin::FillLayoutData() const
{ {
mpControlData->mpLayoutData = new vcl::ControlLayoutData(); 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 ) bool ImplWin::PreNotify( NotifyEvent& rNEvt )
...@@ -2676,17 +2648,17 @@ bool ImplWin::PreNotify( NotifyEvent& rNEvt ) ...@@ -2676,17 +2648,17 @@ bool ImplWin::PreNotify( NotifyEvent& rNEvt )
return Control::PreNotify(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; bool bNativeOK = false;
ControlState nState = ControlState::ENABLED; ControlState nState = ControlState::ENABLED;
if ( IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL) if (rRenderContext.IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
&& IsNativeControlSupported(CTRL_LISTBOX, HAS_BACKGROUND_TEXTURE) ) && rRenderContext.IsNativeControlSupported(CTRL_LISTBOX, HAS_BACKGROUND_TEXTURE) )
{ {
// Repaint the (focused) area similarly to // Repaint the (focused) area similarly to
// ImplSmallBorderWindowView::DrawWindow() in // ImplSmallBorderWindowView::DrawWindow() in
...@@ -2728,17 +2700,17 @@ void ImplWin::ImplDraw( bool bLayout ) ...@@ -2728,17 +2700,17 @@ void ImplWin::ImplDraw( bool bLayout )
nState, aControlValue, OUString() ); nState, aControlValue, OUString() );
} }
bNativeOK = DrawNativeControl( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aCtrlRegion, nState, bNativeOK = rRenderContext.DrawNativeControl(CTRL_LISTBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
aControlValue, OUString() ); nState, aControlValue, OUString());
} }
if( IsEnabled() ) if (IsEnabled())
{ {
if (HasFocus() && !ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea) if (HasFocus() && !ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea)
{ {
SetTextColor( rStyleSettings.GetHighlightTextColor() ); rRenderContext.SetTextColor( rStyleSettings.GetHighlightTextColor() );
SetFillColor( rStyleSettings.GetHighlightColor() ); rRenderContext.SetFillColor( rStyleSettings.GetHighlightColor() );
DrawRect( maFocusRect ); rRenderContext.DrawRect( maFocusRect );
} }
else else
{ {
...@@ -2757,31 +2729,31 @@ void ImplWin::ImplDraw( bool bLayout ) ...@@ -2757,31 +2729,31 @@ void ImplWin::ImplDraw( bool bLayout )
else else
aColor = rStyleSettings.GetFieldTextColor(); aColor = rStyleSettings.GetFieldTextColor();
} }
if( IsControlForeground() ) if (IsControlForeground())
aColor = GetControlForeground(); aColor = GetControlForeground();
SetTextColor( aColor ); rRenderContext.SetTextColor(aColor);
if ( !bNativeOK ) if (!bNativeOK)
Erase( maFocusRect ); rRenderContext.Erase(maFocusRect);
} }
} }
else // Disabled else // Disabled
{ {
SetTextColor( rStyleSettings.GetDisableColor() ); rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
if ( !bNativeOK ) if (!bNativeOK)
Erase( maFocusRect ); rRenderContext.Erase(maFocusRect);
} }
} }
if ( IsUserDrawEnabled() ) if ( IsUserDrawEnabled() )
{ {
mbInUserDraw = true; mbInUserDraw = true;
UserDrawEvent aUDEvt( this, maFocusRect, mnItemPos, 0 ); UserDrawEvent aUDEvt(&rRenderContext, maFocusRect, mnItemPos, 0);
userDrawSignal( &aUDEvt ); userDrawSignal( &aUDEvt );
mbInUserDraw = false; mbInUserDraw = false;
} }
else else
{ {
DrawEntry( true, true, false, bLayout ); DrawEntry(rRenderContext, true, true, false, bLayout);
} }
} }
...@@ -2805,47 +2777,18 @@ void ImplWin::ApplySettings(vcl::RenderContext& rRenderContext) ...@@ -2805,47 +2777,18 @@ void ImplWin::ApplySettings(vcl::RenderContext& rRenderContext)
rRenderContext.SetBackground(rStyleSettings.GetFieldColor()); 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());
}
}
void ImplWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
{ {
ImplDraw(); ImplDraw(rRenderContext);
} }
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; long nBorder = 1;
Size aOutSz = GetOutputSizePixel(); Size aOutSz = rRenderContext.GetOutputSizePixel();
bool bImage = !!maImage; bool bImage = !!maImage;
if( bDrawImage && bImage && !bLayout ) if (bDrawImage && bImage && !bLayout)
{ {
DrawImageFlags nStyle = DrawImageFlags::NONE; DrawImageFlags nStyle = DrawImageFlags::NONE;
Size aImgSz = maImage.GetSizePixel(); Size aImgSz = maImage.GetSizePixel();
...@@ -2857,13 +2800,13 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP ...@@ -2857,13 +2800,13 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP
if ( !IsZoom() ) if ( !IsZoom() )
{ {
DrawImage( aPtImg, *pImage, nStyle ); rRenderContext.DrawImage( aPtImg, *pImage, nStyle );
} }
else else
{ {
aImgSz.Width() = CalcZoom( aImgSz.Width() ); aImgSz.Width() = CalcZoom( aImgSz.Width() );
aImgSz.Height() = CalcZoom( aImgSz.Height() ); aImgSz.Height() = CalcZoom( aImgSz.Height() );
DrawImage( aPtImg, aImgSz, *pImage, nStyle ); rRenderContext.DrawImage( aPtImg, aImgSz, *pImage, nStyle );
} }
const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0);
...@@ -2877,7 +2820,7 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP ...@@ -2877,7 +2820,7 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP
if(!aBlendFrame.IsEmpty()) if(!aBlendFrame.IsEmpty())
{ {
DrawBitmapEx(aPtImg, aBlendFrame); rRenderContext.DrawBitmapEx(aPtImg, aBlendFrame);
} }
} }
} }
...@@ -2905,7 +2848,7 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP ...@@ -2905,7 +2848,7 @@ void ImplWin::DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImageP
MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
OUString* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : 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 ) if( HasFocus() && !bLayout )
......
...@@ -375,7 +375,7 @@ void ListBox::ApplySettings(vcl::RenderContext& rRenderContext) ...@@ -375,7 +375,7 @@ void ListBox::ApplySettings(vcl::RenderContext& rRenderContext)
void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) 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 ); Point aPos = pDev->LogicToPixel( rPos );
Size aSize = pDev->LogicToPixel( rSize ); Size aSize = pDev->LogicToPixel( rSize );
...@@ -555,7 +555,7 @@ void ListBox::DataChanged( const DataChangedEvent& rDCEvt ) ...@@ -555,7 +555,7 @@ void ListBox::DataChanged( const DataChangedEvent& rDCEvt )
if ( mpImplWin ) if ( mpImplWin )
{ {
mpImplWin->SetSettings( GetSettings() ); // If not yet set... mpImplWin->SetSettings( GetSettings() ); // If not yet set...
mpImplWin->ImplInitSettings(true, true, true); mpImplWin->ApplySettings(*this);
mpBtn->SetSettings( GetSettings() ); mpBtn->SetSettings( GetSettings() );
ImplInitDropDownButton( mpBtn ); ImplInitDropDownButton( mpBtn );
...@@ -1386,7 +1386,7 @@ void ListBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawTe ...@@ -1386,7 +1386,7 @@ void ListBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawTe
if (rEvt.GetDevice() == mpImplLB->GetMainWindow()) if (rEvt.GetDevice() == mpImplLB->GetMainWindow())
mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetDevice(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos ); mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetDevice(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
else if (rEvt.GetDevice() == mpImplWin) else if (rEvt.GetDevice() == mpImplWin)
mpImplWin->DrawEntry(bDrawImage, bDrawText, bDrawTextAtImagePos); mpImplWin->DrawEntry(*rEvt.GetDevice(), bDrawImage, bDrawText, bDrawTextAtImagePos);
} }
void ListBox::SetUserItemSize( const Size& rSz ) void ListBox::SetUserItemSize( const Size& rSz )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment