Kaydet (Commit) 71c56174 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor Roadmap to use RenderContext, some cleanup

Change-Id: I4750c17ae7110b0102ebdd141a31ab2a52c4e774
üst 01f1a5b1
...@@ -25,100 +25,90 @@ ...@@ -25,100 +25,90 @@
#include <svtools/hyperlabel.hxx> #include <svtools/hyperlabel.hxx>
class Bitmap; class Bitmap;
namespace svt namespace svt
{ {
struct RoadmapTypes
{
public:
typedef sal_Int16 ItemId;
typedef sal_Int32 ItemIndex;
};
struct RoadmapTypes class RoadmapImpl;
{ class RoadmapItem;
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;
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 SetRoadmapBitmap( const BitmapEx& maBitmap, bool _bInvalidate = true );
void ChangeRoadmapItemID( ItemId _nID, ItemId _NewID, ItemIndex _nStartIndex = 0 );
void SetRoadmapInteractive( bool _bInteractive ); void EnableRoadmapItem( ItemId _nItemId, bool _bEnable, ItemIndex _nStartIndex = 0 );
bool IsRoadmapInteractive();
void SetRoadmapComplete( bool _bComplete ); void ChangeRoadmapItemLabel( ItemId _nID, const OUString& sLabel, ItemIndex _nStartIndex = 0 );
bool IsRoadmapComplete() const; void ChangeRoadmapItemID( ItemId _nID, ItemId _NewID, ItemIndex _nStartIndex = 0 );
ItemIndex GetItemCount() const; void SetRoadmapInteractive( bool _bInteractive );
ItemId GetItemID( ItemIndex _nIndex ) const; bool IsRoadmapInteractive();
void InsertRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled = true ); void SetRoadmapComplete( bool _bComplete );
void ReplaceRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled ); bool IsRoadmapComplete() const;
void DeleteRoadmapItem( ItemIndex _nIndex );
ItemId GetCurrentRoadmapItemID() const; ItemIndex GetItemCount() const;
bool SelectRoadmapItemByID( ItemId _nItemID ); ItemId GetItemID( ItemIndex _nIndex ) const;
void SetItemSelectHdl( const Link<>& _rHdl ); void InsertRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled = true );
Link<> GetItemSelectHdl( ) const; void ReplaceRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled );
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE; void DeleteRoadmapItem( ItemIndex _nIndex );
virtual void GetFocus() SAL_OVERRIDE;
ItemId GetCurrentRoadmapItemID() const;
bool SelectRoadmapItemByID( ItemId _nItemID );
protected: void SetItemSelectHdl( const Link<>& _rHdl );
bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE; Link<> GetItemSelectHdl( ) const;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
virtual void GetFocus() SAL_OVERRIDE;
protected: protected:
/// called when an item has been selected by any means bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
void Select();
private: protected:
DECL_LINK(ImplClickHdl, HyperLabel*); /// called when an item has been selected by any means
void Select();
RoadmapItem* GetByIndex( ItemIndex _nItemIndex ); private:
const RoadmapItem* GetByIndex( ItemIndex _nItemIndex ) const; DECL_LINK(ImplClickHdl, HyperLabel*);
RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 ); RoadmapItem* GetByIndex( ItemIndex _nItemIndex );
const RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 ) const; const RoadmapItem* GetByIndex( ItemIndex _nItemIndex ) const;
RoadmapItem* GetPreviousHyperLabel( ItemIndex _Index);
void DrawHeadline(); RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 );
void DeselectOldRoadmapItems(); const RoadmapItem* GetByID( ItemId _nID, ItemIndex _nStartIndex = 0 ) const;
ItemId GetNextAvailableItemId( ItemIndex _NewIndex ); RoadmapItem* GetPreviousHyperLabel( ItemIndex _Index);
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 );
};
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 } // namespace svt
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -83,7 +83,6 @@ private: ...@@ -83,7 +83,6 @@ private:
void ImplUpdatePosSize(); void ImplUpdatePosSize();
}; };
//= RoadmapImpl //= RoadmapImpl
class RoadmapImpl : public RoadmapTypes class RoadmapImpl : public RoadmapTypes
...@@ -94,9 +93,11 @@ protected: ...@@ -94,9 +93,11 @@ protected:
BitmapEx m_aPicture; BitmapEx m_aPicture;
HL_Vector m_aRoadmapSteps; HL_Vector m_aRoadmapSteps;
ItemId m_iCurItemID; ItemId m_iCurItemID;
bool m_bInteractive; bool m_bInteractive : 1;
bool m_bComplete; bool m_bComplete : 1;
Size m_aItemSizePixel; Size m_aItemSizePixel;
public:
bool m_bPaintInitialized : 1;
public: public:
RoadmapImpl(const ORoadmap& rAntiImpl) RoadmapImpl(const ORoadmap& rAntiImpl)
...@@ -104,6 +105,7 @@ public: ...@@ -104,6 +105,7 @@ public:
, m_iCurItemID(-1) , m_iCurItemID(-1)
, m_bInteractive(true) , m_bInteractive(true)
, m_bComplete(true) , m_bComplete(true)
, m_bPaintInitialized(false)
, InCompleteHyperLabel(NULL) , InCompleteHyperLabel(NULL)
{} {}
...@@ -198,25 +200,23 @@ void RoadmapImpl::initItemSize() ...@@ -198,25 +200,23 @@ void RoadmapImpl::initItemSize()
ORoadmap::ORoadmap(vcl::Window* _pParent, WinBits _nWinStyle) ORoadmap::ORoadmap(vcl::Window* _pParent, WinBits _nWinStyle)
: Control(_pParent, _nWinStyle) : Control(_pParent, _nWinStyle)
, m_pImpl(new RoadmapImpl(*this)) , m_pImpl(new RoadmapImpl(*this))
{ {
implInit();
} }
void ORoadmap::implInit(vcl::RenderContext& rRenderContext)
void ORoadmap::implInit()
{ {
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
Color aTextColor = rStyleSettings.GetFieldTextColor(); Color aTextColor = rStyleSettings.GetFieldTextColor();
vcl::Font aFont = GetFont( ); vcl::Font aFont = rRenderContext.GetFont();
aFont.SetColor( aTextColor ); aFont.SetColor(aTextColor);
aFont.SetWeight( WEIGHT_BOLD ); aFont.SetWeight(WEIGHT_BOLD);
aFont.SetUnderline( UNDERLINE_SINGLE ); aFont.SetUnderline(UNDERLINE_SINGLE);
SetFont( aFont ); rRenderContext.SetFont(aFont);
SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) ); rRenderContext.SetBackground(Wallpaper(rStyleSettings.GetFieldColor()));
m_pImpl->InCompleteHyperLabel = NULL; m_pImpl->InCompleteHyperLabel = NULL;
m_pImpl->setCurItemID(-1 ); m_pImpl->setCurItemID(-1);
m_pImpl->setComplete( true ); m_pImpl->setComplete(true);
m_pImpl->m_bPaintInitialized = true;
// Roadmap control should be reachable as one unit with a Tab key // Roadmap control should be reachable as one unit with a Tab key
// the next Tab key should spring out of the control. // the next Tab key should spring out of the control.
...@@ -232,7 +232,7 @@ void ORoadmap::implInit() ...@@ -232,7 +232,7 @@ void ORoadmap::implInit()
// on this with calculating a new bold font. // on this with calculating a new bold font.
// Unfortunately, the OutputDevice does not offer a notify mechanism for a changed 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 // So settings the font from outside is simply a forbidded scenario at the moment
EnableMapMode(false); rRenderContext.EnableMapMode(false);
} }
ORoadmap::~ORoadmap() ORoadmap::~ORoadmap()
...@@ -561,36 +561,39 @@ bool ORoadmap::SelectRoadmapItemByID( ItemId _nNewID ) ...@@ -561,36 +561,39 @@ bool ORoadmap::SelectRoadmapItemByID( ItemId _nNewID )
void ORoadmap::Paint(vcl::RenderContext& rRenderContext, const Rectangle& _rRect) void ORoadmap::Paint(vcl::RenderContext& rRenderContext, const Rectangle& _rRect)
{ {
if (!m_pImpl->m_bPaintInitialized)
implInit(rRenderContext);
Control::Paint(rRenderContext, _rRect); Control::Paint(rRenderContext, _rRect);
// draw the bitmap // draw the bitmap
if ( !!m_pImpl->getPicture() ) if (!!m_pImpl->getPicture())
{ {
Size aBitmapSize = m_pImpl->getPicture().GetSizePixel(); 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 // draw it
DrawBitmapEx( aBitmapPos, m_pImpl->getPicture() ); rRenderContext.DrawBitmapEx( aBitmapPos, m_pImpl->getPicture() );
} }
// draw the headline // 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 // draw it
DrawText( Rectangle( aTextPos, aOutputSize ), GetText(), TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); rRenderContext.DrawText(Rectangle(aTextPos, aOutputSize), GetText(),
DrawTextLine( aTextPos, aOutputSize.Width(), STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, false ); TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK);
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); rRenderContext.DrawTextLine(aTextPos, aOutputSize.Width(), STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, false);
SetLineColor( rStyleSettings.GetFieldTextColor()); const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
SetTextColor(rStyleSettings.GetFieldTextColor()); rRenderContext.SetLineColor(rStyleSettings.GetFieldTextColor());
rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
} }
RoadmapItem* ORoadmap::GetByPointer(vcl::Window* pWindow) RoadmapItem* ORoadmap::GetByPointer(vcl::Window* pWindow)
......
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