summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-16 21:48:32 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-16 21:59:41 +0900
commit579b9d92c4451f86469a62a4531b026358dd52c7 (patch)
tree1fe713b70f00c6e1c08e6ca0e475a115ccc46747 /sd
parentd346ea574726459559044e9d4870e9b7b9815d13 (diff)
refactor ClientBox to use RenderContext
Change-Id: I028da90804992a30a8d547198aa15bcc2f32e365
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/dlg/RemoteDialogClientBox.cxx84
-rw-r--r--sd/source/ui/dlg/RemoteDialogClientBox.hxx136
2 files changed, 110 insertions, 110 deletions
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index bc95d253e4c9..24a5821bf390 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -282,73 +282,71 @@ void ClientBox::selectEntry( const long nPos )
guard.clear();
}
-void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry& rEntry )
+void ClientBox::DrawRow(vcl::RenderContext& rRenderContext, const Rectangle& rRect, const TClientBoxEntry& rEntry)
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- if ( rEntry->m_bActive )
- SetTextColor( rStyleSettings.GetHighlightTextColor() );
+ if (rEntry->m_bActive)
+ SetTextColor(rStyleSettings.GetHighlightTextColor());
else
- SetTextColor( rStyleSettings.GetFieldTextColor() );
+ 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())
+ SetBackground(GetControlBackground());
else
- SetBackground( rStyleSettings.GetFieldColor() );
+ SetBackground(rStyleSettings.GetFieldColor());
- SetTextFillColor();
- Erase( rRect );
+ rRenderContext.SetTextFillColor();
+ rRenderContext.Erase(rRect);
}
// FIXME: draw bluetooth or wifi icon
- Point aPos( rRect.TopLeft() );
+ Point aPos(rRect.TopLeft());
// 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();
// Get max title width
long nMaxTitleWidth = rRect.GetWidth() - ICON_OFFSET;
nMaxTitleWidth -= ( 2 * SMALL_ICON_SIZE ) + ( 4 * SPACE_BETWEEN );
- long aTitleWidth = GetTextWidth( rEntry->m_pClientInfo->mName ) + (aTextHeight / 3);
+ long aTitleWidth = rRenderContext.GetTextWidth(rEntry->m_pClientInfo->mName) + (aTextHeight / 3);
- aPos = rRect.TopLeft() + Point( ICON_OFFSET, TOP_OFFSET );
+ aPos = rRect.TopLeft() + Point(ICON_OFFSET, TOP_OFFSET);
- if ( aTitleWidth > nMaxTitleWidth )
+ if (aTitleWidth > nMaxTitleWidth)
{
aTitleWidth = nMaxTitleWidth - (aTextHeight / 3);
- OUString aShortTitle = GetEllipsisString( rEntry->m_pClientInfo->mName,
- aTitleWidth );
- DrawText( aPos, aShortTitle );
+ OUString aShortTitle = rRenderContext.GetEllipsisString(rEntry->m_pClientInfo->mName, aTitleWidth );
+ rRenderContext.DrawText(aPos, aShortTitle);
aTitleWidth += (aTextHeight / 3);
}
else
- DrawText( aPos, rEntry->m_pClientInfo->mName );
+ rRenderContext.DrawText(aPos, rEntry->m_pClientInfo->mName);
- SetFont( aStdFont );
+ SetFont(aStdFont);
aPos.Y() += aTextHeight;
- if ( rEntry->m_bActive )
+ if (rEntry->m_bActive)
{
OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
- DrawText( m_sPinTextRect,
- sPinText, 0 );
+ DrawText(m_sPinTextRect, sPinText, 0);
}
- SetLineColor( Color( COL_LIGHTGRAY ) );
- DrawLine( rRect.BottomLeft(), rRect.BottomRight() );
+ rRenderContext.SetLineColor(Color(COL_LIGHTGRAY));
+ rRenderContext.DrawLine(rRect.BottomLeft(), rRect.BottomRight());
}
void ClientBox::RecalcAll()
@@ -486,28 +484,28 @@ bool ClientBox::HandleCursorKey( sal_uInt16 nKeyCode )
return true;
}
-void ClientBox::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle &/*rPaintRect*/ )
+void ClientBox::Paint(vcl::RenderContext& rRenderContext, const Rectangle &/*rPaintRect*/)
{
- if ( !m_bInDelete )
+ if (!m_bInDelete)
DeleteRemoved();
- if ( m_bNeedsRecalc )
+ if (m_bNeedsRecalc)
RecalcAll();
- Point aStart( 0, -m_nTopIndex );
- Size aSize( GetOutputSizePixel() );
+ Point aStart(0, -m_nTopIndex);
+ Size aSize(rRenderContext.GetOutputSizePixel());
- if ( m_bHasScrollBar )
+ if (m_bHasScrollBar)
aSize.Width() -= m_aScrollBar->GetSizePixel().Width();
- const ::osl::MutexGuard aGuard( m_entriesMutex );
+ const ::osl::MutexGuard aGuard(m_entriesMutex);
typedef std::vector< TClientBoxEntry >::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 );
+ Rectangle aEntryRect(aStart, aSize);
+ DrawRow(rRenderContext, aEntryRect, *iIndex);
aStart.Y() += aSize.Height();
}
}
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.hxx b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
index f27d159ad4ae..5f60f8572a2a 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.hxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
@@ -52,14 +52,14 @@ namespace sd {
struct ClientBoxEntry;
struct ClientInfo;
-typedef ::boost::shared_ptr< ClientBoxEntry > TClientBoxEntry;
+typedef boost::shared_ptr<ClientBoxEntry> TClientBoxEntry;
struct ClientBoxEntry
{
- bool m_bActive :1;
- ::boost::shared_ptr<ClientInfo> m_pClientInfo;
+ bool m_bActive :1;
+ boost::shared_ptr<ClientInfo> m_pClientInfo;
- ClientBoxEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
+ ClientBoxEntry(boost::shared_ptr<ClientInfo> pClientInfo);
~ClientBoxEntry();
};
@@ -67,47 +67,49 @@ struct ClientBoxEntry
// class ExtensionBox_Impl
class ClientBox;
-class ClientRemovedListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
+class ClientRemovedListener : public ::cppu::WeakImplHelper1<css::lang::XEventListener>
{
- VclPtr<ClientBox> m_pParent;
+ VclPtr<ClientBox> m_pParent;
public:
- ClientRemovedListener( ClientBox *pParent ) { m_pParent = pParent; }
- virtual ~ClientRemovedListener();
+ ClientRemovedListener(ClientBox *pParent)
+ {
+ m_pParent = pParent;
+ }
+ virtual ~ClientRemovedListener();
// 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 ClientBox:
- public Control
+class ClientBox : public Control
{
- 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;
+ long m_nActive;
+ long m_nTopIndex;
+ long m_nStdHeight;
+ long m_nActiveHeight;
+ long m_nExtraHeight;
Size m_aOutputSize;
Link<> m_aClickHdl;
Link<> m_aDeauthoriseHdl;
- VclPtr<NumericBox> m_aPinBox;
- VclPtr<PushButton> m_aDeauthoriseButton;
- Rectangle m_sPinTextRect;
+ VclPtr<NumericBox> m_aPinBox;
+ VclPtr<PushButton> m_aDeauthoriseButton;
+ Rectangle m_sPinTextRect;
- VclPtr<ScrollBar> m_aScrollBar;
+ VclPtr<ScrollBar> m_aScrollBar;
- com::sun::star::uno::Reference< ClientRemovedListener > m_xRemoveListener;
+ css::uno::Reference< ClientRemovedListener > m_xRemoveListener;
//This mutex is used for synchronizing access to m_vEntries.
//Currently it is used to synchronize adding, removing entries and
@@ -120,13 +122,13 @@ class ClientBox:
std::vector< TClientBoxEntry > m_vEntries;
std::vector< TClientBoxEntry > m_vRemovedEntries;
- void CalcActiveHeight( const long nPos );
- long GetTotalHeight() const;
- void SetupScrollBar();
- void DrawRow(const Rectangle& rRect, const TClientBoxEntry& rEntry);
- bool HandleTabKey( bool bReverse );
- bool HandleCursorKey( sal_uInt16 nKeyCode );
- void DeleteRemoved();
+ void CalcActiveHeight( const long nPos );
+ long GetTotalHeight() const;
+ void SetupScrollBar();
+ void DrawRow(vcl::RenderContext& rRenderContext, const Rectangle& rRect, const TClientBoxEntry& rEntry);
+ bool HandleTabKey( bool bReverse );
+ bool HandleCursorKey( sal_uInt16 nKeyCode );
+ void DeleteRemoved();
DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar* );
DECL_DLLPRIVATE_LINK( DeauthoriseHdl, void * );
@@ -135,42 +137,42 @@ class ClientBox:
void checkIndex(sal_Int32 pos) const;
public:
- ClientBox( vcl::Window* pParent, WinBits nStyle );
- virtual ~ClientBox();
- virtual void dispose() SAL_OVERRIDE;
-
- void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- void Paint( vcl::RenderContext& rRenderContext, const Rectangle &rPaintRect ) SAL_OVERRIDE;
- void Resize() SAL_OVERRIDE;
- Size GetOptimalSize() const SAL_OVERRIDE;
- bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
-
- const Size GetMinOutputSizePixel() const;
- void SetExtraSize( long nSize ) { m_nExtraHeight = nSize; }
- TClientBoxEntry GetEntryData( long nPos ) { return m_vEntries[ nPos ]; }
- long GetActiveEntryIndex();
- long GetEntryCount() { return (long) m_vEntries.size(); }
- Rectangle GetEntryRect( const long nPos ) const;
- bool HasActive() { return m_bHasActive; }
- long PointToPos( const Point& rPos );
- void SetScrollHdl( const Link<>& rLink );
- void DoScroll( long nDelta );
- void SetHyperlinkHdl( const Link<>& rLink ){ m_aClickHdl = rLink; }
- void RecalcAll();
- void RemoveUnlocked();
-
- void selectEntry( const long nPos );
- long addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
- void clearEntries();
-
- void prepareChecking();
- void checkEntries();
+ ClientBox( vcl::Window* pParent, WinBits nStyle );
+ virtual ~ClientBox();
+ virtual void dispose() SAL_OVERRIDE;
+
+ void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+ void Paint( vcl::RenderContext& rRenderContext, const Rectangle &rPaintRect ) SAL_OVERRIDE;
+ void Resize() SAL_OVERRIDE;
+ Size GetOptimalSize() const SAL_OVERRIDE;
+ bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
+
+ const Size GetMinOutputSizePixel() const;
+ void SetExtraSize( long nSize ) { m_nExtraHeight = nSize; }
+ TClientBoxEntry GetEntryData( long nPos ) { return m_vEntries[ nPos ]; }
+ long GetActiveEntryIndex();
+ long GetEntryCount() { return (long) m_vEntries.size(); }
+ Rectangle GetEntryRect( const long nPos ) const;
+ bool HasActive() { return m_bHasActive; }
+ long PointToPos( const Point& rPos );
+ void SetScrollHdl( const Link<>& rLink );
+ void DoScroll( long nDelta );
+ void SetHyperlinkHdl( const Link<>& rLink ){ m_aClickHdl = rLink; }
+ void RecalcAll();
+ void RemoveUnlocked();
+
+ void selectEntry( const long nPos );
+ long addEntry(boost::shared_ptr<ClientInfo> pClientInfo);
+ void clearEntries();
+
+ void prepareChecking();
+ void checkEntries();
OUString getPin();
- void populateEntries();
+ void populateEntries();
};
-}
+} // end namespace sd
#endif // INCLUDED_SD_SOURCE_UI_DLG_REMOTEDIALOGCLIENTBOX_HXX