refactor desktop classes to use RenderContext

Change-Id: I2338733e76968aeb69a57c60edd9d04d29e8321c
This commit is contained in:
Tomaž Vajngerl
2015-05-15 20:39:27 +09:00
parent 264fb9f163
commit a6c85d74ea
3 changed files with 132 additions and 137 deletions

View File

@@ -491,34 +491,34 @@ void ExtensionBox_Impl::selectEntry( const long nPos )
} }
void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEntry ) void ExtensionBox_Impl::DrawRow(vcl::RenderContext& rRenderContext, const Rectangle& rRect, const TEntry_Impl& rEntry)
{ {
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
if (rEntry->m_bActive) if (rEntry->m_bActive)
SetTextColor( rStyleSettings.GetHighlightTextColor() ); rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
else if ((rEntry->m_eState != REGISTERED) && (rEntry->m_eState != NOT_AVAILABLE)) else if ((rEntry->m_eState != REGISTERED) && (rEntry->m_eState != NOT_AVAILABLE))
SetTextColor( rStyleSettings.GetDisableColor() ); rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
else if (IsControlForeground()) else if (IsControlForeground())
SetTextColor( GetControlForeground() ); rRenderContext.SetTextColor(GetControlForeground());
else else
SetTextColor( rStyleSettings.GetFieldTextColor() ); rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
if (rEntry->m_bActive) if (rEntry->m_bActive)
{ {
SetLineColor(); rRenderContext.SetLineColor();
SetFillColor( rStyleSettings.GetHighlightColor() ); rRenderContext.SetFillColor(rStyleSettings.GetHighlightColor());
DrawRect( rRect ); rRenderContext.DrawRect(rRect);
} }
else else
{ {
if (IsControlBackground()) if (IsControlBackground())
SetBackground( GetControlBackground() ); rRenderContext.SetBackground(GetControlBackground());
else else
SetBackground( rStyleSettings.GetFieldColor() ); rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
SetTextFillColor(); rRenderContext.SetTextFillColor();
Erase( rRect ); rRenderContext.Erase(rRect);
} }
// Draw extension icon // Draw extension icon
@@ -531,16 +531,18 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEnt
aImage = rEntry->m_aIcon; aImage = rEntry->m_aIcon;
Size aImageSize = aImage.GetSizePixel(); Size aImageSize = aImage.GetSizePixel();
if ((aImageSize.Width() <= ICON_WIDTH ) && ( aImageSize.Height() <= ICON_HEIGHT ) ) if ((aImageSize.Width() <= ICON_WIDTH ) && ( aImageSize.Height() <= ICON_HEIGHT ) )
DrawImage( Point( aPos.X()+((ICON_WIDTH-aImageSize.Width())/2), aPos.Y()+((ICON_HEIGHT-aImageSize.Height())/2) ), aImage ); rRenderContext.DrawImage(Point(aPos.X() + ((ICON_WIDTH - aImageSize.Width()) / 2),
aPos.Y() + ((ICON_HEIGHT - aImageSize.Height()) / 2)),
aImage);
else else
DrawImage( aPos, Size( ICON_WIDTH, ICON_HEIGHT ), aImage ); rRenderContext.DrawImage(aPos, Size(ICON_WIDTH, ICON_HEIGHT), aImage);
// Setup fonts // Setup fonts
vcl::Font aStdFont( GetFont() ); vcl::Font aStdFont(rRenderContext.GetFont());
vcl::Font aBoldFont(aStdFont); vcl::Font aBoldFont(aStdFont);
aBoldFont.SetWeight(WEIGHT_BOLD); aBoldFont.SetWeight(WEIGHT_BOLD);
SetFont( aBoldFont ); rRenderContext.SetFont(aBoldFont);
long aTextHeight = GetTextHeight(); long aTextHeight = rRenderContext.GetTextHeight();
// Init publisher link here // Init publisher link here
if (!rEntry->m_pPublisher && !rEntry->m_sPublisher.isEmpty()) if (!rEntry->m_pPublisher && !rEntry->m_sPublisher.isEmpty())
@@ -565,23 +567,23 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEnt
nMaxTitleWidth -= rEntry->m_pPublisher->GetSizePixel().Width() + (2 * SPACE_BETWEEN); nMaxTitleWidth -= rEntry->m_pPublisher->GetSizePixel().Width() + (2 * SPACE_BETWEEN);
} }
long aVersionWidth = GetTextWidth( rEntry->m_sVersion ); long aVersionWidth = rRenderContext.GetTextWidth(rEntry->m_sVersion);
long aTitleWidth = GetTextWidth( rEntry->m_sTitle ) + (aTextHeight / 3); long aTitleWidth = rRenderContext.GetTextWidth(rEntry->m_sTitle) + (aTextHeight / 3);
aPos = rRect.TopLeft() + Point(ICON_OFFSET, TOP_OFFSET); aPos = rRect.TopLeft() + Point(ICON_OFFSET, TOP_OFFSET);
if (aTitleWidth > nMaxTitleWidth - aVersionWidth) if (aTitleWidth > nMaxTitleWidth - aVersionWidth)
{ {
aTitleWidth = nMaxTitleWidth - aVersionWidth - (aTextHeight / 3); aTitleWidth = nMaxTitleWidth - aVersionWidth - (aTextHeight / 3);
OUString aShortTitle = GetEllipsisString( rEntry->m_sTitle, aTitleWidth ); OUString aShortTitle = rRenderContext.GetEllipsisString(rEntry->m_sTitle, aTitleWidth);
DrawText( aPos, aShortTitle ); rRenderContext.DrawText(aPos, aShortTitle);
aTitleWidth += (aTextHeight / 3); aTitleWidth += (aTextHeight / 3);
} }
else else
DrawText( aPos, rEntry->m_sTitle ); rRenderContext.DrawText(aPos, rEntry->m_sTitle);
SetFont( aStdFont ); rRenderContext.SetFont(aStdFont);
DrawText( Point( aPos.X() + aTitleWidth, aPos.Y() ), rEntry->m_sVersion ); rRenderContext.DrawText(Point(aPos.X() + aTitleWidth, aPos.Y()), rEntry->m_sVersion);
long nIconHeight = TOP_OFFSET + SMALL_ICON_SIZE; long nIconHeight = TOP_OFFSET + SMALL_ICON_SIZE;
long nTitleHeight = TOP_OFFSET + GetTextHeight(); long nTitleHeight = TOP_OFFSET + GetTextHeight();
@@ -610,7 +612,7 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEnt
if (rEntry->m_bHasButtons) if (rEntry->m_bHasButtons)
nExtraHeight = m_nExtraHeight; nExtraHeight = m_nExtraHeight;
DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight ), rRenderContext.DrawText(Rectangle(aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight),
sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
} }
else else
@@ -619,8 +621,8 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEnt
sDescription = sDescription.replace(0x000A, ' '); sDescription = sDescription.replace(0x000A, ' ');
const long nWidth = GetTextWidth( sDescription ); const long nWidth = GetTextWidth( sDescription );
if (nWidth > rRect.GetWidth() - aPos.X()) if (nWidth > rRect.GetWidth() - aPos.X())
sDescription = GetEllipsisString( sDescription, rRect.GetWidth() - aPos.X() ); sDescription = rRenderContext.GetEllipsisString(sDescription, rRect.GetWidth() - aPos.X());
DrawText( aPos, sDescription ); rRenderContext.DrawText(aPos, sDescription);
} }
// Draw publisher link // Draw publisher link
@@ -636,18 +638,18 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEnt
{ {
aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SMALL_ICON_SIZE), TOP_OFFSET ); aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SMALL_ICON_SIZE), TOP_OFFSET );
if (rEntry->m_bLocked) if (rEntry->m_bLocked)
DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), m_aLockedImage ); rRenderContext.DrawImage(aPos, Size(SMALL_ICON_SIZE, SMALL_ICON_SIZE), m_aLockedImage);
else else
DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), m_aSharedImage ); rRenderContext.DrawImage(aPos, Size(SMALL_ICON_SIZE, SMALL_ICON_SIZE), m_aSharedImage);
} }
if ((rEntry->m_eState == AMBIGUOUS ) || rEntry->m_bMissingDeps || rEntry->m_bMissingLic) if ((rEntry->m_eState == AMBIGUOUS ) || rEntry->m_bMissingDeps || rEntry->m_bMissingLic)
{ {
aPos = rRect.TopRight() + Point(-(RIGHT_ICON_OFFSET + SPACE_BETWEEN + 2 * SMALL_ICON_SIZE), TOP_OFFSET); aPos = rRect.TopRight() + Point(-(RIGHT_ICON_OFFSET + SPACE_BETWEEN + 2 * SMALL_ICON_SIZE), TOP_OFFSET);
DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), m_aWarningImage ); rRenderContext.DrawImage(aPos, Size(SMALL_ICON_SIZE, SMALL_ICON_SIZE), m_aWarningImage);
} }
SetLineColor( Color( COL_LIGHTGRAY ) ); rRenderContext.SetLineColor(Color(COL_LIGHTGRAY));
DrawLine( rRect.BottomLeft(), rRect.BottomRight() ); rRenderContext.DrawLine(rRect.BottomLeft(), rRect.BottomRight());
} }
@@ -747,7 +749,7 @@ bool ExtensionBox_Impl::HandleCursorKey( sal_uInt16 nKeyCode )
} }
void ExtensionBox_Impl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle &/*rPaintRect*/ ) void ExtensionBox_Impl::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rPaintRect*/)
{ {
if ( !m_bInDelete ) if ( !m_bInDelete )
DeleteRemoved(); DeleteRemoved();
@@ -756,7 +758,7 @@ void ExtensionBox_Impl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
RecalcAll(); RecalcAll();
Point aStart( 0, -m_nTopIndex ); Point aStart( 0, -m_nTopIndex );
Size aSize( GetOutputSizePixel() ); Size aSize(rRenderContext.GetOutputSizePixel());
if ( m_bHasScrollBar ) if ( m_bHasScrollBar )
aSize.Width() -= m_pScrollBar->GetSizePixel().Width(); aSize.Width() -= m_pScrollBar->GetSizePixel().Width();
@@ -768,7 +770,7 @@ void ExtensionBox_Impl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
{ {
aSize.Height() = (*iIndex)->m_bActive ? m_nActiveHeight : m_nStdHeight; aSize.Height() = (*iIndex)->m_bActive ? m_nActiveHeight : m_nStdHeight;
Rectangle aEntryRect( aStart, aSize ); Rectangle aEntryRect( aStart, aSize );
DrawRow( aEntryRect, *iIndex ); DrawRow(rRenderContext, aEntryRect, *iIndex);
aStart.Y() += aSize.Height(); aStart.Y() += aSize.Height();
} }
} }

View File

@@ -49,9 +49,6 @@ namespace dp_gui {
class TheExtensionManager; class TheExtensionManager;
// struct Entry_Impl
struct Entry_Impl; struct Entry_Impl;
typedef ::boost::shared_ptr< Entry_Impl > TEntry_Impl; typedef ::boost::shared_ptr< Entry_Impl > TEntry_Impl;
@@ -80,9 +77,9 @@ struct Entry_Impl
Image m_aIconHC; Image m_aIconHC;
VclPtr<FixedHyperlink> m_pPublisher; VclPtr<FixedHyperlink> m_pPublisher;
::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; css::uno::Reference<css::deployment::XPackage> m_xPackage;
Entry_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, Entry_Impl(const css::uno::Reference<css::deployment::XPackage> &xPackage,
const PackageState eState, const bool bReadOnly); const PackageState eState, const bool bReadOnly);
~Entry_Impl(); ~Entry_Impl();
@@ -90,14 +87,10 @@ struct Entry_Impl
void checkDependencies(); void checkDependencies();
}; };
// class ExtensionBox_Impl
class ExtensionBox_Impl; class ExtensionBox_Impl;
class ExtensionRemovedListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener > class ExtensionRemovedListener : public ::cppu::WeakImplHelper1<css::lang::XEventListener>
{ {
VclPtr<ExtensionBox_Impl> m_pParent; VclPtr<ExtensionBox_Impl> m_pParent;
@@ -108,19 +101,19 @@ public:
// XEventListener // XEventListener
virtual void SAL_CALL disposing( ::com::sun::star::lang::EventObject const & evt ) virtual void SAL_CALL disposing(css::lang::EventObject const& evt)
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
}; };
class ExtensionBox_Impl : public ::svt::IExtensionListBox class ExtensionBox_Impl : public ::svt::IExtensionListBox
{ {
bool m_bHasScrollBar; bool m_bHasScrollBar : 1;
bool m_bHasActive; bool m_bHasActive : 1;
bool m_bNeedsRecalc; bool m_bNeedsRecalc : 1;
bool m_bInCheckMode; bool m_bInCheckMode : 1;
bool m_bAdjustActive; bool m_bAdjustActive : 1;
bool m_bInDelete; bool m_bInDelete : 1;
//Must be guarded together with m_vEntries to ensure a valid index at all times. //Must be guarded together with m_vEntries to ensure a valid index at all times.
//Use m_entriesMutex as guard. //Use m_entriesMutex as guard.
long m_nActive; long m_nActive;
@@ -132,11 +125,12 @@ class ExtensionBox_Impl : public ::svt::IExtensionListBox
Image m_aLockedImage; Image m_aLockedImage;
Image m_aWarningImage; Image m_aWarningImage;
Image m_aDefaultImage; Image m_aDefaultImage;
Link<> m_aClickHdl; Link<> m_aClickHdl;
VclPtr<ScrollBar> m_pScrollBar; VclPtr<ScrollBar> m_pScrollBar;
com::sun::star::uno::Reference< ExtensionRemovedListener > m_xRemoveListener; css::uno::Reference<ExtensionRemovedListener> m_xRemoveListener;
TheExtensionManager *m_pManager; TheExtensionManager *m_pManager;
//This mutex is used for synchronizing access to m_vEntries. //This mutex is used for synchronizing access to m_vEntries.
@@ -158,13 +152,12 @@ class ExtensionBox_Impl : public ::svt::IExtensionListBox
::com::sun::star::deployment::XPackage> > m_vListenerAdded; ::com::sun::star::deployment::XPackage> > m_vListenerAdded;
//Removes the dead weak references from m_vListenerAdded //Removes the dead weak references from m_vListenerAdded
void cleanVecListenerAdded(); void cleanVecListenerAdded();
void addEventListenerOnce( ::com::sun::star::uno::Reference< void addEventListenerOnce(css::uno::Reference<css::deployment::XPackage> const & extension);
::com::sun::star::deployment::XPackage> const & extension);
void CalcActiveHeight( const long nPos ); void CalcActiveHeight( const long nPos );
long GetTotalHeight() const; long GetTotalHeight() const;
void SetupScrollBar(); void SetupScrollBar();
void DrawRow( const Rectangle& rRect, const TEntry_Impl& rEntry ); void DrawRow(vcl::RenderContext& rRenderContext, const Rectangle& rRect, const TEntry_Impl& rEntry);
bool HandleTabKey( bool bReverse ); bool HandleTabKey( bool bReverse );
bool HandleCursorKey( sal_uInt16 nKeyCode ); bool HandleCursorKey( sal_uInt16 nKeyCode );
bool FindEntryPos( const TEntry_Impl& rEntry, long nStart, long nEnd, long &nFound ); bool FindEntryPos( const TEntry_Impl& rEntry, long nStart, long nEnd, long &nFound );
@@ -204,10 +197,10 @@ public:
virtual void selectEntry( const long nPos ); virtual void selectEntry( const long nPos );
long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, long addEntry(const css::uno::Reference<css::deployment::XPackage> &xPackage,
bool bLicenseMissing = false ); bool bLicenseMissing = false );
void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void updateEntry(const css::uno::Reference<css::deployment::XPackage> &xPackage );
void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void removeEntry(const css::uno::Reference<css::deployment::XPackage> &xPackage );
void prepareChecking(); void prepareChecking();
void checkEntries(); void checkEntries();

View File

@@ -605,22 +605,22 @@ void SplashScreen::determineProgressRatioValues(
} }
} }
void SplashScreenWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle&) void SplashScreenWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
if (!pSpl || !pSpl->_bVisible) if (!pSpl || !pSpl->_bVisible)
return; return;
//native drawing //native drawing
// in case of native controls we need to draw directly to the window // in case of native controls we need to draw directly to the window
if( pSpl->_bNativeProgress && IsNativeControlSupported( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL ) ) if (pSpl->_bNativeProgress && rRenderContext.IsNativeControlSupported(CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL))
{ {
DrawBitmapEx( Point(), pSpl->_aIntroBmp ); rRenderContext.DrawBitmapEx(Point(), pSpl->_aIntroBmp);
ImplControlValue aValue( pSpl->_iProgress * pSpl->_barwidth / pSpl->_iMax); ImplControlValue aValue( pSpl->_iProgress * pSpl->_barwidth / pSpl->_iMax);
Rectangle aDrawRect( Point(pSpl->_tlx, pSpl->_tly), Size( pSpl->_barwidth, pSpl->_barheight)); Rectangle aDrawRect( Point(pSpl->_tlx, pSpl->_tly), Size( pSpl->_barwidth, pSpl->_barheight));
Rectangle aNativeControlRegion, aNativeContentRegion; Rectangle aNativeControlRegion, aNativeContentRegion;
if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, if (rRenderContext.GetNativeControlRegion(CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
ControlState::ENABLED, aValue, OUString(), ControlState::ENABLED, aValue, OUString(),
aNativeControlRegion, aNativeContentRegion)) aNativeControlRegion, aNativeContentRegion))
{ {
@@ -629,7 +629,7 @@ void SplashScreenWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rec
aDrawRect.Bottom() += (nProgressHeight - pSpl->_barheight)/2; aDrawRect.Bottom() += (nProgressHeight - pSpl->_barheight)/2;
} }
if( (DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, if ((rRenderContext.DrawNativeControl(CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
ControlState::ENABLED, aValue, pSpl->_sProgressText))) ControlState::ENABLED, aValue, pSpl->_sProgressText)))
{ {
return; return;
@@ -660,7 +660,7 @@ void SplashScreenWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rec
_vdev->SetTextColor(pSpl->_cProgressTextColor); _vdev->SetTextColor(pSpl->_cProgressTextColor);
_vdev->DrawText(Point(pSpl->_tlx, pSpl->_textBaseline), pSpl->_sProgressText); _vdev->DrawText(Point(pSpl->_tlx, pSpl->_textBaseline), pSpl->_sProgressText);
} }
DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev->GetOutputSizePixel(), *_vdev.get() ); rRenderContext.DrawOutDev(Point(), rRenderContext.GetOutputSizePixel(), Point(), _vdev->GetOutputSizePixel(), *_vdev.get());
} }