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

refactor TableWindow, ColumnWindow to use RenderContext

Change-Id: I000ac253a57f9fdbb14c700e4a0163c3ba18a7bb
üst 2a5ef299
...@@ -269,38 +269,41 @@ void TableWindow::MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -269,38 +269,41 @@ void TableWindow::MouseButtonUp( const MouseEvent& rMEvt )
void TableWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) void TableWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
const long nSelectionWidth = mnTablePosX + nCol*mnTableCellWidth; const long nSelectionWidth = mnTablePosX + nCol * mnTableCellWidth;
const long nSelectionHeight = mnTablePosY + nLine*mnTableCellHeight; const long nSelectionHeight = mnTablePosY + nLine * mnTableCellHeight;
// the non-selected parts of the table // the non-selected parts of the table
SetLineColor( aLineColor ); rRenderContext.SetLineColor(aLineColor);
SetFillColor( aFillColor ); rRenderContext.SetFillColor(aFillColor);
DrawRect( Rectangle( nSelectionWidth, mnTablePosY, mnTableWidth, nSelectionHeight ) ); rRenderContext.DrawRect(Rectangle(nSelectionWidth, mnTablePosY, mnTableWidth, nSelectionHeight));
DrawRect( Rectangle( mnTablePosX, nSelectionHeight, nSelectionWidth, mnTableHeight ) ); rRenderContext.DrawRect(Rectangle(mnTablePosX, nSelectionHeight, nSelectionWidth, mnTableHeight));
DrawRect( Rectangle( nSelectionWidth, nSelectionHeight, mnTableWidth, mnTableHeight ) ); rRenderContext.DrawRect(Rectangle(nSelectionWidth, nSelectionHeight, mnTableWidth, mnTableHeight));
// the selection // the selection
if ( nCol > 0 && nLine > 0 ) if (nCol > 0 && nLine > 0)
{ {
SetFillColor( aHighlightFillColor ); rRenderContext.SetFillColor(aHighlightFillColor);
DrawRect( Rectangle( mnTablePosX, mnTablePosY, rRenderContext.DrawRect(Rectangle(mnTablePosX, mnTablePosY, nSelectionWidth, nSelectionHeight));
nSelectionWidth, nSelectionHeight ) );
} }
// lines inside of the table // lines inside of the table
SetLineColor( aLineColor ); rRenderContext.SetLineColor(aLineColor);
for ( long i = 1; i < TABLE_CELLS_VERT; ++i ) for (long i = 1; i < TABLE_CELLS_VERT; ++i)
DrawLine( Point( mnTablePosX, mnTablePosY + i*mnTableCellHeight ), {
Point( mnTableWidth, mnTablePosY + i*mnTableCellHeight ) ); rRenderContext.DrawLine(Point(mnTablePosX, mnTablePosY + i*mnTableCellHeight),
Point(mnTableWidth, mnTablePosY + i*mnTableCellHeight));
}
for ( long i = 1; i < TABLE_CELLS_HORIZ; ++i ) for (long i = 1; i < TABLE_CELLS_HORIZ; ++i)
DrawLine( Point( mnTablePosX + i*mnTableCellWidth, mnTablePosY ), {
Point( mnTablePosX + i*mnTableCellWidth, mnTableHeight ) ); rRenderContext.DrawLine(Point( mnTablePosX + i*mnTableCellWidth, mnTablePosY),
Point( mnTablePosX + i*mnTableCellWidth, mnTableHeight));
}
// the text near the mouse cursor telling the table dimensions // the text near the mouse cursor telling the table dimensions
if ( nCol && nLine ) if (nCol && nLine)
{ {
OUString aText; OUString aText;
aText += OUString::number( nCol ); aText += OUString::number( nCol );
...@@ -312,28 +315,30 @@ void TableWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle ...@@ -312,28 +315,30 @@ void TableWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle
aText += SVX_RESSTR(RID_SVXSTR_PAGES); aText += SVX_RESSTR(RID_SVXSTR_PAGES);
} }
Size aTextSize( GetTextWidth( aText ), GetTextHeight() ); Size aTextSize(rRenderContext.GetTextWidth(aText), rRenderContext.GetTextHeight());
long nTextX = nSelectionWidth + mnTableCellWidth; long nTextX = nSelectionWidth + mnTableCellWidth;
long nTextY = nSelectionHeight + mnTableCellHeight; long nTextY = nSelectionHeight + mnTableCellHeight;
const long nTipBorder = 2; const long nTipBorder = 2;
if ( aTextSize.Width() + mnTablePosX + mnTableCellWidth + 2*nTipBorder < nSelectionWidth ) if (aTextSize.Width() + mnTablePosX + mnTableCellWidth + 2 * nTipBorder < nSelectionWidth)
nTextX = nSelectionWidth - mnTableCellWidth - aTextSize.Width(); nTextX = nSelectionWidth - mnTableCellWidth - aTextSize.Width();
if ( aTextSize.Height() + mnTablePosY + mnTableCellHeight + 2*nTipBorder < nSelectionHeight ) if (aTextSize.Height() + mnTablePosY + mnTableCellHeight + 2 * nTipBorder < nSelectionHeight)
nTextY = nSelectionHeight - mnTableCellHeight - aTextSize.Height(); nTextY = nSelectionHeight - mnTableCellHeight - aTextSize.Height();
SetLineColor( aLineColor ); rRenderContext.SetLineColor(aLineColor);
SetFillColor( aBackgroundColor ); rRenderContext.SetFillColor(aBackgroundColor);
DrawRect( Rectangle ( nTextX - 2*nTipBorder, nTextY - 2*nTipBorder, rRenderContext.DrawRect(Rectangle(nTextX - 2 * nTipBorder,
nTextX + aTextSize.Width() + nTipBorder, nTextY + aTextSize.Height() + nTipBorder ) ); nTextY - 2 * nTipBorder,
nTextX + aTextSize.Width() + nTipBorder,
nTextY + aTextSize.Height() + nTipBorder));
// #i95350# force RTL output // #i95350# force RTL output
if ( IsRTLEnabled() ) if (IsRTLEnabled())
aText = OUString(0x202D) + aText; aText = OUString(0x202D) + aText;
DrawText( Point( nTextX, nTextY ), aText ); rRenderContext.DrawText(Point(nTextX, nTextY), aText);
} }
} }
...@@ -369,7 +374,7 @@ void TableWindow::Update( long nNewCol, long nNewLine ) ...@@ -369,7 +374,7 @@ void TableWindow::Update( long nNewCol, long nNewLine )
{ {
nCol = nNewCol; nCol = nNewCol;
nLine = nNewLine; nLine = nNewLine;
Invalidate( Rectangle( mnTablePosX, mnTablePosY, mnTableWidth, mnTableHeight ) ); Invalidate(Rectangle(mnTablePosX, mnTablePosY, mnTableWidth, mnTableHeight));
} }
} }
...@@ -631,57 +636,63 @@ void ColumnsWindow::MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -631,57 +636,63 @@ void ColumnsWindow::MouseButtonUp( const MouseEvent& rMEvt )
void ColumnsWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) void ColumnsWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
long i; long i;
long nLineWidth; long nLineWidth;
Size aSize = GetOutputSizePixel(); Size aSize = rRenderContext.GetOutputSizePixel();
for ( i = 0; i < nWidth; i++ ) for (i = 0; i < nWidth; i++)
{ {
if ( i < nCol ) if (i < nCol)
{ {
SetLineColor( aHighlightLineColor ); rRenderContext.SetLineColor(aHighlightLineColor);
SetFillColor( aHighlightFillColor ); rRenderContext.SetFillColor(aHighlightFillColor);
} }
else else
{ {
SetLineColor( aLineColor ); rRenderContext.SetLineColor(aLineColor);
SetFillColor( aFillColor ); rRenderContext.SetFillColor(aFillColor);
} }
DrawRect( Rectangle( i*nMX-1, -1, rRenderContext.DrawRect(Rectangle(i * nMX - 1, -1, i * nMX + nMX, aSize.Height() - nTextHeight + 1));
i*nMX+nMX, aSize.Height()-nTextHeight+1 ) );
long j = 4; long j = 4;
while ( j < aSize.Height()-nTextHeight-4 ) while (j < aSize.Height() - nTextHeight - 4)
{ {
if ( !(j % 16) ) if (!(j % 16))
nLineWidth = 10; nLineWidth = 10;
else else
nLineWidth = 4; nLineWidth = 4;
DrawLine( Point( i*nMX+4, j ), Point( i*nMX+nMX-nLineWidth-4, j ) ); rRenderContext.DrawLine(Point(i * nMX + 4, j), Point(i * nMX + nMX - nLineWidth - 4, j));
j += 4; j += 4;
} }
} }
SetLineColor(); rRenderContext.SetLineColor();
SetFillColor( aFaceColor ); rRenderContext.SetFillColor(aFaceColor);
OUString aText; OUString aText;
if ( nCol ) if (nCol)
aText = OUString::number(nCol); aText = OUString::number(nCol);
else else
aText = comphelper::string::remove(Button::GetStandardText(StandardButtonType::Cancel), '~'); aText = comphelper::string::remove(Button::GetStandardText(StandardButtonType::Cancel), '~');
Size aTextSize(GetTextWidth( aText ), GetTextHeight()); Size aTextSize(rRenderContext.GetTextWidth(aText), rRenderContext.GetTextHeight());
DrawText( Point( ( aSize.Width() - aTextSize.Width() ) / 2, aSize.Height() - nTextHeight + 2 ), aText ); rRenderContext.DrawText(Point((aSize.Width() - aTextSize.Width()) / 2, aSize.Height() - nTextHeight + 2), aText);
rRenderContext.DrawRect(Rectangle(0,
aSize.Height() - nTextHeight + 2,
(aSize.Width() - aTextSize.Width()) / 2 - 1,
aSize.Height()));
DrawRect( Rectangle( 0, aSize.Height()-nTextHeight+2, (aSize.Width()-aTextSize.Width())/2-1, aSize.Height() ) ); rRenderContext.DrawRect(Rectangle((aSize.Width() - aTextSize.Width()) / 2 + aTextSize.Width(),
DrawRect( Rectangle( (aSize.Width()-aTextSize.Width())/2+aTextSize.Width(), aSize.Height()-nTextHeight+2, aSize.Width(), aSize.Height() ) ); aSize.Height() - nTextHeight + 2,
aSize.Width(),
aSize.Height()));
SetLineColor( aLineColor ); rRenderContext.SetLineColor(aLineColor);
SetFillColor(); rRenderContext.SetFillColor();
DrawRect( Rectangle( 0, 0, aSize.Width() - 1, aSize.Height() - nTextHeight + 1 ) ); rRenderContext.DrawRect(Rectangle( 0, 0, aSize.Width() - 1, aSize.Height() - nTextHeight + 1));
} }
......
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