summaryrefslogtreecommitdiff
path: root/desktop/source/deployment/gui
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-15 20:39:27 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-16 21:57:15 +0900
commita6c85d74ea03b35f03217daad9869f4458aa0c0f (patch)
tree30420d2cb105e31496426b071bfe349ca60ea6bc /desktop/source/deployment/gui
parent264fb9f16336e2cfd8f937b630fc167faab0aae3 (diff)
refactor desktop classes to use RenderContext
Change-Id: I2338733e76968aeb69a57c60edd9d04d29e8321c
Diffstat (limited to 'desktop/source/deployment/gui')
-rw-r--r--desktop/source/deployment/gui/dp_gui_extlistbox.cxx148
-rw-r--r--desktop/source/deployment/gui/dp_gui_extlistbox.hxx101
2 files changed, 122 insertions, 127 deletions
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index 7988fc9052d1..e1cf1da17e4f 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -491,97 +491,99 @@ 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();
-
- if ( rEntry->m_bActive )
- SetTextColor( rStyleSettings.GetHighlightTextColor() );
- else if ( ( rEntry->m_eState != REGISTERED ) && ( rEntry->m_eState != NOT_AVAILABLE ) )
- SetTextColor( rStyleSettings.GetDisableColor() );
- else if ( IsControlForeground() )
- SetTextColor( GetControlForeground() );
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+
+ if (rEntry->m_bActive)
+ rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
+ else if ((rEntry->m_eState != REGISTERED) && (rEntry->m_eState != NOT_AVAILABLE))
+ rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
+ else if (IsControlForeground())
+ rRenderContext.SetTextColor(GetControlForeground());
else
- SetTextColor( rStyleSettings.GetFieldTextColor() );
+ rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
- if ( rEntry->m_bActive )
+ if (rEntry->m_bActive)
{
- SetLineColor();
- SetFillColor( rStyleSettings.GetHighlightColor() );
- DrawRect( rRect );
+ rRenderContext.SetLineColor();
+ rRenderContext.SetFillColor(rStyleSettings.GetHighlightColor());
+ rRenderContext.DrawRect(rRect);
}
else
{
- if( IsControlBackground() )
- SetBackground( GetControlBackground() );
+ if (IsControlBackground())
+ rRenderContext.SetBackground(GetControlBackground());
else
- SetBackground( rStyleSettings.GetFieldColor() );
+ rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
- SetTextFillColor();
- Erase( rRect );
+ rRenderContext.SetTextFillColor();
+ rRenderContext.Erase(rRect);
}
// Draw extension icon
Point aPos( rRect.TopLeft() );
- aPos += Point( TOP_OFFSET, TOP_OFFSET );
+ aPos += Point(TOP_OFFSET, TOP_OFFSET);
Image aImage;
- if ( ! rEntry->m_aIcon )
+ if (!rEntry->m_aIcon)
aImage = m_aDefaultImage;
else
aImage = rEntry->m_aIcon;
Size aImageSize = aImage.GetSizePixel();
- 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 );
+ if ((aImageSize.Width() <= ICON_WIDTH ) && ( aImageSize.Height() <= ICON_HEIGHT ) )
+ rRenderContext.DrawImage(Point(aPos.X() + ((ICON_WIDTH - aImageSize.Width()) / 2),
+ aPos.Y() + ((ICON_HEIGHT - aImageSize.Height()) / 2)),
+ aImage);
else
- DrawImage( aPos, Size( ICON_WIDTH, ICON_HEIGHT ), aImage );
+ rRenderContext.DrawImage(aPos, Size(ICON_WIDTH, ICON_HEIGHT), aImage);
// Setup fonts
- vcl::Font aStdFont( GetFont() );
- vcl::Font aBoldFont( aStdFont );
- aBoldFont.SetWeight( WEIGHT_BOLD );
- SetFont( aBoldFont );
- long aTextHeight = GetTextHeight();
+ vcl::Font aStdFont(rRenderContext.GetFont());
+ vcl::Font aBoldFont(aStdFont);
+ aBoldFont.SetWeight(WEIGHT_BOLD);
+ rRenderContext.SetFont(aBoldFont);
+ long aTextHeight = rRenderContext.GetTextHeight();
// Init publisher link here
- if ( !rEntry->m_pPublisher && !rEntry->m_sPublisher.isEmpty() )
+ if (!rEntry->m_pPublisher && !rEntry->m_sPublisher.isEmpty())
{
- rEntry->m_pPublisher = VclPtr<FixedHyperlink>::Create( this );
+ rEntry->m_pPublisher = VclPtr<FixedHyperlink>::Create(this);
rEntry->m_pPublisher->SetBackground();
- rEntry->m_pPublisher->SetPaintTransparent( true );
- rEntry->m_pPublisher->SetURL( rEntry->m_sPublisherURL );
- rEntry->m_pPublisher->SetText( rEntry->m_sPublisher );
- Size aSize = FixedText::CalcMinimumTextSize( rEntry->m_pPublisher );
- rEntry->m_pPublisher->SetSizePixel( aSize );
+ rEntry->m_pPublisher->SetPaintTransparent(true);
+ rEntry->m_pPublisher->SetURL(rEntry->m_sPublisherURL);
+ rEntry->m_pPublisher->SetText(rEntry->m_sPublisher);
+ Size aSize = FixedText::CalcMinimumTextSize(rEntry->m_pPublisher);
+ rEntry->m_pPublisher->SetSizePixel(aSize);
- if ( m_aClickHdl.IsSet() )
+ if (m_aClickHdl.IsSet())
rEntry->m_pPublisher->SetClickHdl( m_aClickHdl );
}
// Get max title width
long nMaxTitleWidth = rRect.GetWidth() - ICON_OFFSET;
- nMaxTitleWidth -= ( 2 * SMALL_ICON_SIZE ) + ( 4 * SPACE_BETWEEN );
- if ( rEntry->m_pPublisher )
+ nMaxTitleWidth -= (2 * SMALL_ICON_SIZE) + (4 * SPACE_BETWEEN);
+ if (rEntry->m_pPublisher)
{
- 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 aTitleWidth = GetTextWidth( rEntry->m_sTitle ) + (aTextHeight / 3);
+ long aVersionWidth = rRenderContext.GetTextWidth(rEntry->m_sVersion);
+ 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);
- OUString aShortTitle = GetEllipsisString( rEntry->m_sTitle, aTitleWidth );
- DrawText( aPos, aShortTitle );
+ OUString aShortTitle = rRenderContext.GetEllipsisString(rEntry->m_sTitle, aTitleWidth);
+ rRenderContext.DrawText(aPos, aShortTitle);
aTitleWidth += (aTextHeight / 3);
}
else
- DrawText( aPos, rEntry->m_sTitle );
+ rRenderContext.DrawText(aPos, rEntry->m_sTitle);
- SetFont( aStdFont );
- DrawText( Point( aPos.X() + aTitleWidth, aPos.Y() ), rEntry->m_sVersion );
+ rRenderContext.SetFont(aStdFont);
+ rRenderContext.DrawText(Point(aPos.X() + aTitleWidth, aPos.Y()), rEntry->m_sVersion);
long nIconHeight = TOP_OFFSET + SMALL_ICON_SIZE;
long nTitleHeight = TOP_OFFSET + GetTextHeight();
@@ -592,9 +594,9 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEnt
// draw description
OUString sDescription;
- if ( !rEntry->m_sErrorText.isEmpty() )
+ if (!rEntry->m_sErrorText.isEmpty())
{
- if ( rEntry->m_bActive )
+ if (rEntry->m_bActive)
sDescription = rEntry->m_sErrorText + "\n" + rEntry->m_sDescription;
else
sDescription = rEntry->m_sErrorText;
@@ -603,51 +605,51 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl& rEnt
sDescription = rEntry->m_sDescription;
aPos.Y() += aTextHeight;
- if ( rEntry->m_bActive )
+ if (rEntry->m_bActive)
{
long nExtraHeight = 0;
- if ( rEntry->m_bHasButtons )
+ if (rEntry->m_bHasButtons)
nExtraHeight = m_nExtraHeight;
- DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight ),
- sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+ rRenderContext.DrawText(Rectangle(aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight),
+ sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
}
else
{
//replace LF to space, so words do not stick together in one line view
sDescription = sDescription.replace(0x000A, ' ');
const long nWidth = GetTextWidth( sDescription );
- if ( nWidth > rRect.GetWidth() - aPos.X() )
- sDescription = GetEllipsisString( sDescription, rRect.GetWidth() - aPos.X() );
- DrawText( aPos, sDescription );
+ if (nWidth > rRect.GetWidth() - aPos.X())
+ sDescription = rRenderContext.GetEllipsisString(sDescription, rRect.GetWidth() - aPos.X());
+ rRenderContext.DrawText(aPos, sDescription);
}
// Draw publisher link
- if ( rEntry->m_pPublisher )
+ if (rEntry->m_pPublisher)
{
rEntry->m_pPublisher->Show();
aPos = rRect.TopLeft() + Point( ICON_OFFSET + nMaxTitleWidth + (2*SPACE_BETWEEN), TOP_OFFSET );
- rEntry->m_pPublisher->SetPosPixel( aPos );
+ rEntry->m_pPublisher->SetPosPixel(aPos);
}
// Draw status icons
- if ( !rEntry->m_bUser )
+ if (!rEntry->m_bUser)
{
aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SMALL_ICON_SIZE), TOP_OFFSET );
- if ( rEntry->m_bLocked )
- DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), m_aLockedImage );
+ if (rEntry->m_bLocked)
+ rRenderContext.DrawImage(aPos, Size(SMALL_ICON_SIZE, SMALL_ICON_SIZE), m_aLockedImage);
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 );
- DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), m_aWarningImage );
+ aPos = rRect.TopRight() + Point(-(RIGHT_ICON_OFFSET + SPACE_BETWEEN + 2 * SMALL_ICON_SIZE), TOP_OFFSET);
+ rRenderContext.DrawImage(aPos, Size(SMALL_ICON_SIZE, SMALL_ICON_SIZE), m_aWarningImage);
}
- SetLineColor( Color( COL_LIGHTGRAY ) );
- DrawLine( rRect.BottomLeft(), rRect.BottomRight() );
+ rRenderContext.SetLineColor(Color(COL_LIGHTGRAY));
+ 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 )
DeleteRemoved();
@@ -756,7 +758,7 @@ void ExtensionBox_Impl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
RecalcAll();
Point aStart( 0, -m_nTopIndex );
- Size aSize( GetOutputSizePixel() );
+ Size aSize(rRenderContext.GetOutputSizePixel());
if ( m_bHasScrollBar )
aSize.Width() -= m_pScrollBar->GetSizePixel().Width();
@@ -764,11 +766,11 @@ void ExtensionBox_Impl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
const ::osl::MutexGuard aGuard( m_entriesMutex );
typedef std::vector< TEntry_Impl >::iterator ITER;
- for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex )
+ for (ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex)
{
aSize.Height() = (*iIndex)->m_bActive ? m_nActiveHeight : m_nStdHeight;
Rectangle aEntryRect( aStart, aSize );
- DrawRow( aEntryRect, *iIndex );
+ DrawRow(rRenderContext, aEntryRect, *iIndex);
aStart.Y() += aSize.Height();
}
}
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
index d1a634203bb1..6a027c48ba12 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
@@ -49,9 +49,6 @@ namespace dp_gui {
class TheExtensionManager;
-
-// struct Entry_Impl
-
struct Entry_Impl;
typedef ::boost::shared_ptr< Entry_Impl > TEntry_Impl;
@@ -80,24 +77,20 @@ struct Entry_Impl
Image m_aIconHC;
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,
- const PackageState eState, const bool bReadOnly );
+ Entry_Impl(const css::uno::Reference<css::deployment::XPackage> &xPackage,
+ const PackageState eState, const bool bReadOnly);
~Entry_Impl();
- sal_Int32 CompareTo( const CollatorWrapper *pCollator, const TEntry_Impl& rEntry ) const;
- void checkDependencies();
+ sal_Int32 CompareTo(const CollatorWrapper *pCollator, const TEntry_Impl& rEntry) const;
+ void checkDependencies();
};
-
-// 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;
@@ -108,35 +101,36 @@ public:
// XEventListener
- virtual void SAL_CALL disposing( ::com::sun::star::lang::EventObject const & evt )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL disposing(css::lang::EventObject const& evt)
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
};
class ExtensionBox_Impl : public ::svt::IExtensionListBox
{
- bool m_bHasScrollBar;
- bool m_bHasActive;
- bool m_bNeedsRecalc;
- bool m_bInCheckMode;
- bool m_bAdjustActive;
- bool m_bInDelete;
+ bool m_bHasScrollBar : 1;
+ bool m_bHasActive : 1;
+ bool m_bNeedsRecalc : 1;
+ bool m_bInCheckMode : 1;
+ bool m_bAdjustActive : 1;
+ bool m_bInDelete : 1;
//Must be guarded together with m_vEntries to ensure a valid index at all times.
//Use m_entriesMutex as guard.
- long m_nActive;
- long m_nTopIndex;
- long m_nStdHeight;
- long m_nActiveHeight;
- long m_nExtraHeight;
- Image m_aSharedImage;
- Image m_aLockedImage;
- Image m_aWarningImage;
- Image m_aDefaultImage;
- Link<> m_aClickHdl;
+ long m_nActive;
+ long m_nTopIndex;
+ long m_nStdHeight;
+ long m_nActiveHeight;
+ long m_nExtraHeight;
+ Image m_aSharedImage;
+ Image m_aLockedImage;
+ Image m_aWarningImage;
+ Image m_aDefaultImage;
+
+ Link<> m_aClickHdl;
VclPtr<ScrollBar> m_pScrollBar;
- com::sun::star::uno::Reference< ExtensionRemovedListener > m_xRemoveListener;
+ css::uno::Reference<ExtensionRemovedListener> m_xRemoveListener;
TheExtensionManager *m_pManager;
//This mutex is used for synchronizing access to m_vEntries.
@@ -158,17 +152,16 @@ class ExtensionBox_Impl : public ::svt::IExtensionListBox
::com::sun::star::deployment::XPackage> > m_vListenerAdded;
//Removes the dead weak references from m_vListenerAdded
void cleanVecListenerAdded();
- void addEventListenerOnce( ::com::sun::star::uno::Reference<
- ::com::sun::star::deployment::XPackage> const & extension);
+ void addEventListenerOnce(css::uno::Reference<css::deployment::XPackage> const & extension);
- void CalcActiveHeight( const long nPos );
- long GetTotalHeight() const;
- void SetupScrollBar();
- void DrawRow( const Rectangle& rRect, const TEntry_Impl& rEntry );
- bool HandleTabKey( bool bReverse );
- bool HandleCursorKey( sal_uInt16 nKeyCode );
- bool FindEntryPos( const TEntry_Impl& rEntry, long nStart, long nEnd, long &nFound );
- void DeleteRemoved();
+ void CalcActiveHeight( const long nPos );
+ long GetTotalHeight() const;
+ void SetupScrollBar();
+ void DrawRow(vcl::RenderContext& rRenderContext, const Rectangle& rRect, const TEntry_Impl& rEntry);
+ bool HandleTabKey( bool bReverse );
+ bool HandleCursorKey( sal_uInt16 nKeyCode );
+ bool FindEntryPos( const TEntry_Impl& rEntry, long nStart, long nEnd, long &nFound );
+ void DeleteRemoved();
DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar * );
@@ -184,11 +177,11 @@ public:
virtual ~ExtensionBox_Impl();
virtual void dispose() SAL_OVERRIDE;
- virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle &rPaintRect ) SAL_OVERRIDE;
- virtual void Resize() SAL_OVERRIDE;
- virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
- virtual Size GetOptimalSize() const SAL_OVERRIDE;
+ virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+ virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle &rPaintRect ) SAL_OVERRIDE;
+ virtual void Resize() SAL_OVERRIDE;
+ virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
+ virtual Size GetOptimalSize() const SAL_OVERRIDE;
void SetExtraSize( long nSize ) { m_nExtraHeight = nSize; }
TEntry_Impl GetEntryData( long nPos ) { return m_vEntries[ nPos ]; }
@@ -203,16 +196,16 @@ public:
void RemoveUnlocked();
- virtual void selectEntry( const long nPos );
- long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
+ virtual void selectEntry( const long nPos );
+ long addEntry(const css::uno::Reference<css::deployment::XPackage> &xPackage,
bool bLicenseMissing = false );
- void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
- void removeEntry( 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 css::uno::Reference<css::deployment::XPackage> &xPackage );
- void prepareChecking();
- void checkEntries();
+ void prepareChecking();
+ void checkEntries();
- TheExtensionManager* getExtensionManager() const { return m_pManager; }
+ TheExtensionManager* getExtensionManager() const { return m_pManager; }
void setExtensionManager(TheExtensionManager* pManager) { m_pManager = pManager; }