Kaydet (Commit) 56a45fcf authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor StatusBar to use RenderContex

Change-Id: Id29dd8ad0d5de77738f162aed530ed191f326aa2
üst cba2ced9
...@@ -334,17 +334,17 @@ sal_uInt16 StatusBar::ImplGetFirstVisiblePos() const ...@@ -334,17 +334,17 @@ sal_uInt16 StatusBar::ImplGetFirstVisiblePos() const
return SAL_MAX_UINT16; return SAL_MAX_UINT16;
} }
void StatusBar::ImplDrawText(vcl::RenderContext& /*rRenderContext*/, bool bOffScreen, long nOldTextWidth) void StatusBar::ImplDrawText(vcl::RenderContext& rRenderContext, bool bOffScreen, long nOldTextWidth)
{ {
// prevent item box from being overwritten // prevent item box from being overwritten
Rectangle aTextRect; Rectangle aTextRect;
aTextRect.Left() = STATUSBAR_OFFSET_X+1; aTextRect.Left() = STATUSBAR_OFFSET_X + 1;
aTextRect.Top() = mnTextY; aTextRect.Top() = mnTextY;
if ( mbVisibleItems && (GetStyle() & WB_RIGHT) ) if (mbVisibleItems && (GetStyle() & WB_RIGHT))
aTextRect.Right() = mnDX - mnItemsWidth - 1; aTextRect.Right() = mnDX - mnItemsWidth - 1;
else else
aTextRect.Right() = mnDX - 1; aTextRect.Right() = mnDX - 1;
if ( aTextRect.Right() > aTextRect.Left() ) if (aTextRect.Right() > aTextRect.Left())
{ {
// compute position // compute position
OUString aStr = GetText(); OUString aStr = GetText();
...@@ -354,118 +354,125 @@ void StatusBar::ImplDrawText(vcl::RenderContext& /*rRenderContext*/, bool bOffSc ...@@ -354,118 +354,125 @@ void StatusBar::ImplDrawText(vcl::RenderContext& /*rRenderContext*/, bool bOffSc
aTextRect.Bottom() = aTextRect.Top()+GetTextHeight()+1; aTextRect.Bottom() = aTextRect.Top()+GetTextHeight()+1;
if ( bOffScreen ) if (bOffScreen)
{ {
long nMaxWidth = std::max( nOldTextWidth, GetTextWidth( aStr ) ); long nMaxWidth = std::max(nOldTextWidth, GetTextWidth(aStr));
Size aVirDevSize( nMaxWidth, aTextRect.GetHeight() ); Size aVirDevSize(nMaxWidth, aTextRect.GetHeight());
mpImplData->mpVirDev->SetOutputSizePixel( aVirDevSize ); mpImplData->mpVirDev->SetOutputSizePixel( aVirDevSize );
Rectangle aTempRect = aTextRect; Rectangle aTempRect = aTextRect;
aTempRect.SetPos( Point( 0, 0 ) ); aTempRect.SetPos(Point(0, 0));
mpImplData->mpVirDev->DrawText( aTempRect, aStr, TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS ); mpImplData->mpVirDev->DrawText( aTempRect, aStr, TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS );
DrawOutDev( aTextRect.TopLeft(), aVirDevSize, Point(), aVirDevSize, *mpImplData->mpVirDev ); rRenderContext.DrawOutDev(aTextRect.TopLeft(), aVirDevSize, Point(), aVirDevSize, *mpImplData->mpVirDev);
} }
else else
DrawText( aTextRect, aStr, TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS ); {
rRenderContext.DrawText(aTextRect, aStr, TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS);
}
} }
} }
void StatusBar::ImplDrawItem(vcl::RenderContext& /*rRenderContext*/, bool bOffScreen, sal_uInt16 nPos, bool bDrawText, bool bDrawFrame) void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen, sal_uInt16 nPos, bool bDrawText, bool bDrawFrame)
{ {
Rectangle aRect = ImplGetItemRectPos( nPos ); Rectangle aRect = ImplGetItemRectPos(nPos);
if ( aRect.IsEmpty() ) if (aRect.IsEmpty())
return; return;
// compute output region // compute output region
ImplStatusItem* pItem = (*mpItemList)[ nPos ]; ImplStatusItem* pItem = (*mpItemList)[nPos];
long nW = mpImplData->mnItemBorderWidth + 1; long nW = mpImplData->mnItemBorderWidth + 1;
Rectangle aTextRect( aRect.Left()+nW, aRect.Top()+nW, Rectangle aTextRect(aRect.Left() + nW, aRect.Top() + nW,
aRect.Right()-nW, aRect.Bottom()-nW ); aRect.Right() - nW, aRect.Bottom() - nW);
Size aTextRectSize( aTextRect.GetSize() );
Size aTextRectSize(aTextRect.GetSize());
if ( bOffScreen ) if (bOffScreen)
mpImplData->mpVirDev->SetOutputSizePixel( aTextRectSize ); {
mpImplData->mpVirDev->SetOutputSizePixel(aTextRectSize);
}
else else
{ {
vcl::Region aRegion( aTextRect ); vcl::Region aRegion(aTextRect);
SetClipRegion( aRegion ); rRenderContext.SetClipRegion(aRegion);
} }
// print text // print text
if ( bDrawText ) if (bDrawText)
{ {
Size aTextSize( GetTextWidth( pItem->maText ), GetTextHeight() ); Size aTextSize(rRenderContext.GetTextWidth(pItem->maText), rRenderContext.GetTextHeight());
Point aTextPos = ImplGetItemTextPos( aTextRectSize, aTextSize, pItem->mnBits ); Point aTextPos = ImplGetItemTextPos(aTextRectSize, aTextSize, pItem->mnBits);
if ( bOffScreen ) if (bOffScreen)
mpImplData->mpVirDev->DrawText( aTextPos, pItem->maText ); {
mpImplData->mpVirDev->DrawText(aTextPos, pItem->maText);
}
else else
{ {
aTextPos.X() += aTextRect.Left(); aTextPos.X() += aTextRect.Left();
aTextPos.Y() += aTextRect.Top(); aTextPos.Y() += aTextRect.Top();
DrawText( aTextPos, pItem->maText ); rRenderContext.DrawText(aTextPos, pItem->maText);
} }
} }
// call DrawItem if necessary // call DrawItem if necessary
if ( pItem->mnBits & SIB_USERDRAW ) if (pItem->mnBits & SIB_USERDRAW)
{ {
if ( bOffScreen ) if (bOffScreen)
{ {
mbInUserDraw = true; mbInUserDraw = true;
mpImplData->mpVirDev->EnableRTL( IsRTLEnabled() ); mpImplData->mpVirDev->EnableRTL( IsRTLEnabled() );
UserDrawEvent aODEvt( mpImplData->mpVirDev, Rectangle( Point(), aTextRectSize ), pItem->mnId ); UserDrawEvent aODEvt(mpImplData->mpVirDev, Rectangle(Point(), aTextRectSize), pItem->mnId);
UserDraw( aODEvt ); UserDraw(aODEvt);
mpImplData->mpVirDev->EnableRTL( false ); mpImplData->mpVirDev->EnableRTL(false);
mbInUserDraw = false; mbInUserDraw = false;
} }
else else
{ {
UserDrawEvent aODEvt( this, aTextRect, pItem->mnId ); UserDrawEvent aODEvt(this, aTextRect, pItem->mnId);
UserDraw( aODEvt ); UserDraw(aODEvt);
} }
} }
if ( bOffScreen ) if (bOffScreen)
DrawOutDev( aTextRect.TopLeft(), aTextRectSize, Point(), aTextRectSize, *mpImplData->mpVirDev ); rRenderContext.DrawOutDev(aTextRect.TopLeft(), aTextRectSize, Point(), aTextRectSize, *mpImplData->mpVirDev);
else else
SetClipRegion(); rRenderContext.SetClipRegion();
// show frame // show frame
if ( bDrawFrame ) if (bDrawFrame)
{ {
if( mpImplData->mbDrawItemFrames ) if (mpImplData->mbDrawItemFrames)
{ {
if( !(pItem->mnBits & SIB_FLAT) ) if (!(pItem->mnBits & SIB_FLAT))
{ {
sal_uInt16 nStyle; sal_uInt16 nStyle;
if ( pItem->mnBits & SIB_IN ) if (pItem->mnBits & SIB_IN)
nStyle = FRAME_DRAW_IN; nStyle = FRAME_DRAW_IN;
else else
nStyle = FRAME_DRAW_OUT; nStyle = FRAME_DRAW_OUT;
DecorationView aDecoView( this ); DecorationView aDecoView(&rRenderContext);
aDecoView.DrawFrame( aRect, nStyle ); aDecoView.DrawFrame(aRect, nStyle);
} }
} }
else if( nPos != ImplGetFirstVisiblePos() ) else if (nPos != ImplGetFirstVisiblePos())
{ {
// draw separator // draw separator
Point aFrom( aRect.TopLeft() ); Point aFrom(aRect.TopLeft());
aFrom.X()-=4; aFrom.X() -= 4;
aFrom.Y()++; aFrom.Y()++;
Point aTo( aRect.BottomLeft() ); Point aTo(aRect.BottomLeft());
aTo.X()-=4; aTo.X() -= 4;
aTo.Y()--; aTo.Y()--;
DecorationView aDecoView( this ); DecorationView aDecoView(&rRenderContext);
aDecoView.DrawSeparator( aFrom, aTo ); aDecoView.DrawSeparator(aFrom, aTo);
} }
} }
const OutputDevice *pOutDev = GetOutDev(); const OutputDevice* pOutDev = GetOutDev();
if ( !pOutDev->ImplIsRecordLayout() ) if (!pOutDev->ImplIsRecordLayout())
CallEventListeners( VCLEVENT_STATUSBAR_DRAWITEM, reinterpret_cast<void*>(pItem->mnId) ); CallEventListeners(VCLEVENT_STATUSBAR_DRAWITEM, reinterpret_cast<void*>(pItem->mnId));
} }
void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos, void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos,
...@@ -698,32 +705,32 @@ void StatusBar::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -698,32 +705,32 @@ void StatusBar::MouseButtonDown( const MouseEvent& rMEvt )
void StatusBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) void StatusBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
if ( mbFormat ) if (mbFormat)
ImplFormat(); ImplFormat();
sal_uInt16 nItemCount = sal_uInt16( mpItemList->size() ); sal_uInt16 nItemCount = sal_uInt16( mpItemList->size() );
if ( mbProgressMode ) if (mbProgressMode)
ImplDrawProgress(rRenderContext, true, 0, mnPercent); ImplDrawProgress(rRenderContext, true, 0, mnPercent);
else else
{ {
// draw text // draw text
if ( !mbVisibleItems || (GetStyle() & WB_RIGHT) ) if (!mbVisibleItems || (GetStyle() & WB_RIGHT))
ImplDrawText(rRenderContext, false, 0); ImplDrawText(rRenderContext, false, 0);
// draw items // draw items
if ( mbVisibleItems ) if (mbVisibleItems)
{ {
for ( sal_uInt16 i = 0; i < nItemCount; i++ ) for (sal_uInt16 i = 0; i < nItemCount; i++)
ImplDrawItem(rRenderContext, false, i, true, true); ImplDrawItem(rRenderContext, false, i, true, true);
} }
} }
// draw line at the top of the status bar (to visually distinguish it from // draw line at the top of the status bar (to visually distinguish it from
// shell / docking area) // shell / docking area)
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
SetLineColor( rStyleSettings.GetShadowColor() ); rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
DrawLine( Point( 0, 0 ), Point( mnDX-1, 0 ) ); rRenderContext.DrawLine(Point(0, 0), Point(mnDX-1, 0));
} }
void StatusBar::Move() void StatusBar::Move()
...@@ -1162,7 +1169,8 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText ) ...@@ -1162,7 +1169,8 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText )
if ( pItem->mbVisible && !mbFormat && ImplIsItemUpdate() ) if ( pItem->mbVisible && !mbFormat && ImplIsItemUpdate() )
{ {
Update(); Update();
ImplDrawItem(*this, true, nPos, true, false); Rectangle aRect = ImplGetItemRectPos(nPos);
Invalidate(aRect);
Flush(); Flush();
} }
} }
...@@ -1215,6 +1223,8 @@ void StatusBar::SetItemData( sal_uInt16 nItemId, void* pNewData ) ...@@ -1215,6 +1223,8 @@ void StatusBar::SetItemData( sal_uInt16 nItemId, void* pNewData )
!mbFormat && ImplIsItemUpdate() ) !mbFormat && ImplIsItemUpdate() )
{ {
Update(); Update();
Rectangle aRect = ImplGetItemRectPos(nPos);
Invalidate(aRect);
ImplDrawItem(*this, true, nPos, false, false); ImplDrawItem(*this, true, nPos, false, false);
Flush(); Flush();
} }
...@@ -1231,21 +1241,22 @@ void* StatusBar::GetItemData( sal_uInt16 nItemId ) const ...@@ -1231,21 +1241,22 @@ void* StatusBar::GetItemData( sal_uInt16 nItemId ) const
return NULL; return NULL;
} }
void StatusBar::RedrawItem( sal_uInt16 nItemId ) void StatusBar::RedrawItem(sal_uInt16 nItemId)
{ {
if ( mbFormat ) if ( mbFormat )
return; return;
sal_uInt16 nPos = GetItemPos( nItemId ); sal_uInt16 nPos = GetItemPos(nItemId);
if ( nPos == STATUSBAR_ITEM_NOTFOUND ) if ( nPos == STATUSBAR_ITEM_NOTFOUND )
return; return;
ImplStatusItem* pItem = (*mpItemList)[ nPos ]; ImplStatusItem* pItem = (*mpItemList)[ nPos ];
if ( pItem && (pItem->mnBits & SIB_USERDRAW) && if (pItem && (pItem->mnBits & SIB_USERDRAW) &&
pItem->mbVisible && ImplIsItemUpdate() ) pItem->mbVisible && ImplIsItemUpdate())
{ {
Update(); Update();
ImplDrawItem(*this, true, nPos, false, false); Rectangle aRect = ImplGetItemRectPos(nPos);
Invalidate(aRect);
Flush(); Flush();
} }
} }
...@@ -1360,7 +1371,7 @@ void StatusBar::SetProgressValue( sal_uInt16 nNewPercent ) ...@@ -1360,7 +1371,7 @@ void StatusBar::SetProgressValue( sal_uInt16 nNewPercent )
{ {
Update(); Update();
SetLineColor(); SetLineColor();
ImplDrawProgress(*this, false, mnPercent, nNewPercent); Invalidate();
Flush(); Flush();
} }
mnPercent = nNewPercent; mnPercent = nNewPercent;
...@@ -1383,29 +1394,27 @@ void StatusBar::EndProgressMode() ...@@ -1383,29 +1394,27 @@ void StatusBar::EndProgressMode()
} }
} }
void StatusBar::SetText( const OUString& rText ) void StatusBar::SetText(const OUString& rText)
{ {
if ( (!mbVisibleItems || (GetStyle() & WB_RIGHT)) && !mbProgressMode && if ((!mbVisibleItems || (GetStyle() & WB_RIGHT)) && !mbProgressMode && IsReallyVisible() && IsUpdateMode())
IsReallyVisible() && IsUpdateMode() )
{ {
if ( mbFormat ) if (mbFormat)
{ {
Invalidate(); Invalidate();
Window::SetText( rText ); Window::SetText(rText);
} }
else else
{ {
Update(); Update();
long nOldTextWidth = GetTextWidth( GetText() ); Window::SetText(rText);
Window::SetText( rText ); Invalidate();
ImplDrawText(*this, true, nOldTextWidth);
Flush(); Flush();
} }
} }
else if ( mbProgressMode ) else if (mbProgressMode)
{ {
maPrgsTxt = rText; maPrgsTxt = rText;
if ( IsReallyVisible() ) if (IsReallyVisible())
{ {
Invalidate(); Invalidate();
Update(); Update();
...@@ -1413,7 +1422,9 @@ void StatusBar::SetText( const OUString& rText ) ...@@ -1413,7 +1422,9 @@ void StatusBar::SetText( const OUString& rText )
} }
} }
else else
Window::SetText( rText ); {
Window::SetText(rText);
}
} }
Size StatusBar::CalcWindowSizePixel() const Size StatusBar::CalcWindowSizePixel() const
......
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