summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-11 12:25:55 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-11 13:57:30 +0900
commit71c561740d3a11081c7737376948212fb0937fe4 (patch)
tree5a58c21d0b2742678b92511cc50d32f4b6220af1
parent01f1a5b106ca2a324619ca02e7df6aba872c9a35 (diff)
refactor Roadmap to use RenderContext, some cleanup
Change-Id: I4750c17ae7110b0102ebdd141a31ab2a52c4e774
-rw-r--r--svtools/inc/roadmap.hxx126
-rw-r--r--svtools/source/control/roadmap.cxx63
2 files changed, 91 insertions, 98 deletions
diff --git a/svtools/inc/roadmap.hxx b/svtools/inc/roadmap.hxx
index 412bc4a3a344..a4e943166faa 100644
--- a/svtools/inc/roadmap.hxx
+++ b/svtools/inc/roadmap.hxx
@@ -25,100 +25,90 @@
#include <svtools/hyperlabel.hxx>
-
-
-
class Bitmap;
namespace svt
{
+struct RoadmapTypes
+{
+public:
+ typedef sal_Int16 ItemId;
+ typedef sal_Int32 ItemIndex;
+};
- struct RoadmapTypes
- {
- public:
- typedef sal_Int16 ItemId;
- typedef sal_Int32 ItemIndex;
- };
-
- class RoadmapImpl;
- class RoadmapItem;
-
-
- //= Roadmap
-
- class SVT_DLLPUBLIC ORoadmap : public Control, public RoadmapTypes
- {
- protected:
- RoadmapImpl* m_pImpl;
- // Window overridables
- void Paint( vcl::RenderContext& rRenderContext, const Rectangle& _rRect ) SAL_OVERRIDE;
- void implInit();
-
- public:
- ORoadmap( vcl::Window* _pParent, WinBits _nWinStyle = 0 );
- virtual ~ORoadmap( );
- virtual void dispose() SAL_OVERRIDE;
+class RoadmapImpl;
+class RoadmapItem;
- void SetRoadmapBitmap( const BitmapEx& maBitmap, bool _bInvalidate = true );
+class SVT_DLLPUBLIC ORoadmap : public Control, public RoadmapTypes
+{
+protected:
+ RoadmapImpl* m_pImpl;
+ // Window overridables
+ void Paint(vcl::RenderContext& rRenderContext, const Rectangle& _rRect) SAL_OVERRIDE;
+ void implInit(vcl::RenderContext& rRenderContext);
- void EnableRoadmapItem( ItemId _nItemId, bool _bEnable, ItemIndex _nStartIndex = 0 );
+public:
+ ORoadmap( vcl::Window* _pParent, WinBits _nWinStyle = 0 );
+ virtual ~ORoadmap( );
+ virtual void dispose() SAL_OVERRIDE;
- void ChangeRoadmapItemLabel( ItemId _nID, const OUString& sLabel, ItemIndex _nStartIndex = 0 );
- void ChangeRoadmapItemID( ItemId _nID, ItemId _NewID, ItemIndex _nStartIndex = 0 );
+ void SetRoadmapBitmap( const BitmapEx& maBitmap, bool _bInvalidate = true );
- void SetRoadmapInteractive( bool _bInteractive );
- bool IsRoadmapInteractive();
+ void EnableRoadmapItem( ItemId _nItemId, bool _bEnable, ItemIndex _nStartIndex = 0 );
- void SetRoadmapComplete( bool _bComplete );
- bool IsRoadmapComplete() const;
+ void ChangeRoadmapItemLabel( ItemId _nID, const OUString& sLabel, ItemIndex _nStartIndex = 0 );
+ void ChangeRoadmapItemID( ItemId _nID, ItemId _NewID, ItemIndex _nStartIndex = 0 );
- ItemIndex GetItemCount() const;
- ItemId GetItemID( ItemIndex _nIndex ) const;
+ void SetRoadmapInteractive( bool _bInteractive );
+ bool IsRoadmapInteractive();
- void InsertRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled = true );
- void ReplaceRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled );
- void DeleteRoadmapItem( ItemIndex _nIndex );
+ void SetRoadmapComplete( bool _bComplete );
+ bool IsRoadmapComplete() const;
- ItemId GetCurrentRoadmapItemID() const;
- bool SelectRoadmapItemByID( ItemId _nItemID );
+ ItemIndex GetItemCount() const;
+ ItemId GetItemID( ItemIndex _nIndex ) const;
- void SetItemSelectHdl( const Link<>& _rHdl );
- Link<> GetItemSelectHdl( ) const;
- virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
- virtual void GetFocus() SAL_OVERRIDE;
+ void InsertRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled = true );
+ void ReplaceRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled );
+ void DeleteRoadmapItem( ItemIndex _nIndex );
+ ItemId GetCurrentRoadmapItemID() const;
+ bool SelectRoadmapItemByID( ItemId _nItemID );
- protected:
- bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
+ void SetItemSelectHdl( const Link<>& _rHdl );
+ Link<> GetItemSelectHdl( ) const;
+ virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
+ virtual void GetFocus() SAL_OVERRIDE;
- protected:
- /// called when an item has been selected by any means
- void Select();
+protected:
+ bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
- private:
- DECL_LINK(ImplClickHdl, HyperLabel*);
+protected:
+ /// called when an item has been selected by any means
+ void Select();
- RoadmapItem* GetByIndex( ItemIndex _nItemIndex );
- const RoadmapItem* GetByIndex( ItemIndex _nItemIndex ) const;
+private:
+ DECL_LINK(ImplClickHdl, HyperLabel*);
- RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 );
- const RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 ) const;
- RoadmapItem* GetPreviousHyperLabel( ItemIndex _Index);
+ RoadmapItem* GetByIndex( ItemIndex _nItemIndex );
+ const RoadmapItem* GetByIndex( ItemIndex _nItemIndex ) const;
- void DrawHeadline();
- void DeselectOldRoadmapItems();
- ItemId GetNextAvailableItemId( ItemIndex _NewIndex );
- ItemId GetPreviousAvailableItemId( ItemIndex _NewIndex );
- RoadmapItem* GetByPointer(vcl::Window* pWindow);
- RoadmapItem* InsertHyperLabel( ItemIndex _Index, const OUString& _aStr, ItemId _RMID, bool _bEnabled, bool _bIncomplete );
- void UpdatefollowingHyperLabels( ItemIndex _Index );
- };
+ RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 );
+ const RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 ) const;
+ RoadmapItem* GetPreviousHyperLabel( ItemIndex _Index);
+ void DrawHeadline(vcl::RenderContext& rRenderContext);
+ void DeselectOldRoadmapItems();
+ ItemId GetNextAvailableItemId( ItemIndex _NewIndex );
+ ItemId GetPreviousAvailableItemId( ItemIndex _NewIndex );
+ RoadmapItem* GetByPointer(vcl::Window* pWindow);
+ RoadmapItem* InsertHyperLabel( ItemIndex _Index, const OUString& _aStr, ItemId _RMID, bool _bEnabled, bool _bIncomplete );
+ void UpdatefollowingHyperLabels( ItemIndex _Index );
+};
} // namespace svt
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/control/roadmap.cxx b/svtools/source/control/roadmap.cxx
index f96a7cd1ad38..742cae6142ca 100644
--- a/svtools/source/control/roadmap.cxx
+++ b/svtools/source/control/roadmap.cxx
@@ -83,7 +83,6 @@ private:
void ImplUpdatePosSize();
};
-
//= RoadmapImpl
class RoadmapImpl : public RoadmapTypes
@@ -94,9 +93,11 @@ protected:
BitmapEx m_aPicture;
HL_Vector m_aRoadmapSteps;
ItemId m_iCurItemID;
- bool m_bInteractive;
- bool m_bComplete;
+ bool m_bInteractive : 1;
+ bool m_bComplete : 1;
Size m_aItemSizePixel;
+public:
+ bool m_bPaintInitialized : 1;
public:
RoadmapImpl(const ORoadmap& rAntiImpl)
@@ -104,6 +105,7 @@ public:
, m_iCurItemID(-1)
, m_bInteractive(true)
, m_bComplete(true)
+ , m_bPaintInitialized(false)
, InCompleteHyperLabel(NULL)
{}
@@ -198,25 +200,23 @@ void RoadmapImpl::initItemSize()
ORoadmap::ORoadmap(vcl::Window* _pParent, WinBits _nWinStyle)
: Control(_pParent, _nWinStyle)
, m_pImpl(new RoadmapImpl(*this))
-
{
- implInit();
}
-
-void ORoadmap::implInit()
+void ORoadmap::implInit(vcl::RenderContext& rRenderContext)
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
Color aTextColor = rStyleSettings.GetFieldTextColor();
- vcl::Font aFont = GetFont( );
- aFont.SetColor( aTextColor );
- aFont.SetWeight( WEIGHT_BOLD );
- aFont.SetUnderline( UNDERLINE_SINGLE );
- SetFont( aFont );
- SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
+ vcl::Font aFont = rRenderContext.GetFont();
+ aFont.SetColor(aTextColor);
+ aFont.SetWeight(WEIGHT_BOLD);
+ aFont.SetUnderline(UNDERLINE_SINGLE);
+ rRenderContext.SetFont(aFont);
+ rRenderContext.SetBackground(Wallpaper(rStyleSettings.GetFieldColor()));
m_pImpl->InCompleteHyperLabel = NULL;
- m_pImpl->setCurItemID(-1 );
- m_pImpl->setComplete( true );
+ m_pImpl->setCurItemID(-1);
+ m_pImpl->setComplete(true);
+ m_pImpl->m_bPaintInitialized = true;
// Roadmap control should be reachable as one unit with a Tab key
// the next Tab key should spring out of the control.
@@ -232,7 +232,7 @@ void ORoadmap::implInit()
// on this with calculating a new bold font.
// Unfortunately, the OutputDevice does not offer a notify mechanism for a changed font.
// So settings the font from outside is simply a forbidded scenario at the moment
- EnableMapMode(false);
+ rRenderContext.EnableMapMode(false);
}
ORoadmap::~ORoadmap()
@@ -561,36 +561,39 @@ bool ORoadmap::SelectRoadmapItemByID( ItemId _nNewID )
void ORoadmap::Paint(vcl::RenderContext& rRenderContext, const Rectangle& _rRect)
{
+ if (!m_pImpl->m_bPaintInitialized)
+ implInit(rRenderContext);
Control::Paint(rRenderContext, _rRect);
// draw the bitmap
- if ( !!m_pImpl->getPicture() )
+ if (!!m_pImpl->getPicture())
{
Size aBitmapSize = m_pImpl->getPicture().GetSizePixel();
- Size aMySize = GetOutputSizePixel();
+ Size aMySize = rRenderContext.GetOutputSizePixel();
- Point aBitmapPos( aMySize.Width() - aBitmapSize.Width(), aMySize.Height() - aBitmapSize.Height() );
+ Point aBitmapPos(aMySize.Width() - aBitmapSize.Width(), aMySize.Height() - aBitmapSize.Height());
// draw it
- DrawBitmapEx( aBitmapPos, m_pImpl->getPicture() );
+ rRenderContext.DrawBitmapEx( aBitmapPos, m_pImpl->getPicture() );
}
// draw the headline
- DrawHeadline();
+ DrawHeadline(rRenderContext);
}
-void ORoadmap::DrawHeadline()
+void ORoadmap::DrawHeadline(vcl::RenderContext& rRenderContext)
{
- Point aTextPos = LogicToPixel( Point( ROADMAP_INDENT_X, 8 ), MAP_APPFONT );
+ Point aTextPos = LogicToPixel(Point(ROADMAP_INDENT_X, 8), MAP_APPFONT);
- Size aOutputSize( GetOutputSizePixel() );
+ Size aOutputSize(rRenderContext.GetOutputSizePixel());
// draw it
- DrawText( Rectangle( aTextPos, aOutputSize ), GetText(), TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
- DrawTextLine( aTextPos, aOutputSize.Width(), STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, false );
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- SetLineColor( rStyleSettings.GetFieldTextColor());
- SetTextColor(rStyleSettings.GetFieldTextColor());
+ rRenderContext.DrawText(Rectangle(aTextPos, aOutputSize), GetText(),
+ TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK);
+ rRenderContext.DrawTextLine(aTextPos, aOutputSize.Width(), STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, false);
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ rRenderContext.SetLineColor(rStyleSettings.GetFieldTextColor());
+ rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
}
RoadmapItem* ORoadmap::GetByPointer(vcl::Window* pWindow)