Kaydet (Commit) 9bb59aab authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor SwColumnOnlyExample to use RenderContext

Change-Id: I4c15bb0428005031ea3b4766eb4221ff48d91514
üst 43ce2db6
...@@ -336,49 +336,49 @@ SwColumnOnlyExample::SwColumnOnlyExample(vcl::Window* pParent) ...@@ -336,49 +336,49 @@ SwColumnOnlyExample::SwColumnOnlyExample(vcl::Window* pParent)
VCL_BUILDER_FACTORY(SwColumnOnlyExample) VCL_BUILDER_FACTORY(SwColumnOnlyExample)
void SwColumnOnlyExample::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& /*rRect*/ ) void SwColumnOnlyExample::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
{ {
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
const Color& rFieldColor = rStyleSettings.GetFieldColor(); const Color& rFieldColor = rStyleSettings.GetFieldColor();
const Color& rDlgColor = rStyleSettings.GetDialogColor(); const Color& rDlgColor = rStyleSettings.GetDialogColor();
const Color& rFieldTextColor = SwViewOption::GetFontColor(); const Color& rFieldTextColor = SwViewOption::GetFontColor();
Color aGrayColor(COL_LIGHTGRAY); Color aGrayColor(COL_LIGHTGRAY);
if(rFieldColor == aGrayColor) if (rFieldColor == aGrayColor)
aGrayColor.Invert(); aGrayColor.Invert();
Size aLogSize(PixelToLogic(GetOutputSizePixel())); Size aLogSize(rRenderContext.PixelToLogic(rRenderContext.GetOutputSizePixel()));
Rectangle aCompleteRect(Point(0,0), aLogSize); Rectangle aCompleteRect(Point(0,0), aLogSize);
SetLineColor(rDlgColor); rRenderContext.SetLineColor(rDlgColor);
SetFillColor(rDlgColor); rRenderContext.SetFillColor(rDlgColor);
DrawRect(aCompleteRect); rRenderContext.DrawRect(aCompleteRect);
SetLineColor( rFieldTextColor ); rRenderContext.SetLineColor(rFieldTextColor);
Point aTL( (aLogSize.Width() - m_aFrmSize.Width()) / 2, Point aTL((aLogSize.Width() - m_aFrmSize.Width()) / 2,
(aLogSize.Height() - m_aFrmSize.Height()) / 2); (aLogSize.Height() - m_aFrmSize.Height()) / 2);
Rectangle aRect(aTL, m_aFrmSize); Rectangle aRect(aTL, m_aFrmSize);
//draw a shadow rectangle //draw a shadow rectangle
SetFillColor( Color(COL_GRAY) ); rRenderContext.SetFillColor(Color(COL_GRAY));
Rectangle aShadowRect(aRect); Rectangle aShadowRect(aRect);
aShadowRect.Move(aTL.Y(), aTL.Y()); aShadowRect.Move(aTL.Y(), aTL.Y());
DrawRect(aShadowRect); rRenderContext.DrawRect(aShadowRect);
SetFillColor( rFieldColor ); rRenderContext.SetFillColor(rFieldColor);
DrawRect(aRect); rRenderContext.DrawRect(aRect);
SetFillColor( aGrayColor ); rRenderContext.SetFillColor(aGrayColor);
//column separator? //column separator?
long nLength = aLogSize.Height() - 2 * aTL.Y(); long nLength = aLogSize.Height() - 2 * aTL.Y();
Point aUp( aTL ); Point aUp(aTL);
Point aDown( aTL.X(), nLength ); Point aDown(aTL.X(), nLength);
bool bLines = false; bool bLines = false;
if(m_aCols.GetLineAdj() != COLADJ_NONE) if (m_aCols.GetLineAdj() != COLADJ_NONE)
{ {
bLines = true; bLines = true;
sal_uInt16 nPercent = m_aCols.GetLineHeight(); sal_uInt16 nPercent = m_aCols.GetLineHeight();
if( nPercent != 100 ) if (nPercent != 100)
{ {
nLength -= nLength * nPercent / 100; nLength -= nLength * nPercent / 100;
switch(m_aCols.GetLineAdj()) switch(m_aCols.GetLineAdj())
...@@ -389,36 +389,37 @@ void SwColumnOnlyExample::Paint( vcl::RenderContext& /*rRenderContext*/, const R ...@@ -389,36 +389,37 @@ void SwColumnOnlyExample::Paint( vcl::RenderContext& /*rRenderContext*/, const R
aUp.Y() += nLength / 2; aUp.Y() += nLength / 2;
aDown.Y() -= nLength / 2; aDown.Y() -= nLength / 2;
break; break;
default:; //prevent warning default:
break; //prevent warning
} }
} }
} }
const SwColumns& rCols = m_aCols.GetColumns(); const SwColumns& rCols = m_aCols.GetColumns();
sal_uInt16 nColCount = rCols.size(); sal_uInt16 nColCount = rCols.size();
if( nColCount ) if (nColCount)
{ {
DrawRect(aRect); rRenderContext.DrawRect(aRect);
SetFillColor( rFieldColor ); rRenderContext.SetFillColor(rFieldColor);
Rectangle aFrmRect(aTL, m_aFrmSize); Rectangle aFrmRect(aTL, m_aFrmSize);
long nSum = aTL.X(); long nSum = aTL.X();
for(sal_uInt16 i = 0; i < nColCount; i++) for (sal_uInt16 i = 0; i < nColCount; i++)
{ {
const SwColumn* pCol = &rCols[i]; const SwColumn* pCol = &rCols[i];
aFrmRect.Left() = nSum + pCol->GetLeft();//nSum + pCol->GetLeft() + aTL.X(); aFrmRect.Left() = nSum + pCol->GetLeft(); //nSum + pCol->GetLeft() + aTL.X();
nSum += pCol->GetWishWidth(); nSum += pCol->GetWishWidth();
aFrmRect.Right() = nSum - pCol->GetRight(); aFrmRect.Right() = nSum - pCol->GetRight();
DrawRect(aFrmRect); rRenderContext.DrawRect(aFrmRect);
} }
if(bLines ) if (bLines)
{ {
nSum = aTL.X(); nSum = aTL.X();
for(sal_uInt16 i = 0; i < nColCount - 1; i++) for (sal_uInt16 i = 0; i < nColCount - 1; i++)
{ {
nSum += rCols[i].GetWishWidth(); nSum += rCols[i].GetWishWidth();
aUp.X() = nSum; aUp.X() = nSum;
aDown.X() = nSum; aDown.X() = nSum;
DrawLine(aUp, aDown); rRenderContext.DrawLine(aUp, aDown);
} }
} }
} }
...@@ -488,6 +489,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point ...@@ -488,6 +489,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point
const bool bSecond, const bool bEnabled) const bool bSecond, const bool bEnabled)
{ {
SwPageExample::DrawPage(rRenderContext, rOrg, bSecond, bEnabled); SwPageExample::DrawPage(rRenderContext, rOrg, bSecond, bEnabled);
if (pGridItem && pGridItem->GetGridType()) if (pGridItem && pGridItem->GetGridType())
{ {
//paint the grid now //paint the grid now
...@@ -549,7 +551,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point ...@@ -549,7 +551,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point
aCharRect.Move(0, nYStart); aCharRect.Move(0, nYStart);
} }
if(pGridItem->IsRubyTextBelow()) if (pGridItem->IsRubyTextBelow())
m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight); m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight);
else else
m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight); m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight);
...@@ -567,7 +569,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point ...@@ -567,7 +569,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point
{ {
Point aStart = aCharRect.TopLeft(); Point aStart = aCharRect.TopLeft();
Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft(); Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft();
while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right()) while (m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
{ {
rRenderContext.DrawLine(aStart, aEnd); rRenderContext.DrawLine(aStart, aEnd);
if(m_bVertical) if(m_bVertical)
......
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