Fixed warning, reformatted some code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-02-18 15:39:23 +00:00
parent d43851f77e
commit 038a5591e4

View File

@@ -7108,20 +7108,20 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
//Forward to new API. //Forward to new API.
DrawTextRectangle( dc, DrawTextRectangle( dc,
lines, lines,
rect, rect,
horizAlign, horizAlign,
vertAlign, vertAlign,
textOrientation ); textOrientation );
} }
void wxGrid::DrawTextRectangle( wxDC& dc, void wxGrid::DrawTextRectangle( wxDC& dc,
const wxArrayString& lines, const wxArrayString& lines,
const wxRect& rect, const wxRect& rect,
int horizAlign, int horizAlign,
int vertAlign, int vertAlign,
int textOrientation ) int textOrientation )
{ {
long textWidth, textHeight; long textWidth, textHeight;
long lineWidth, lineHeight; long lineWidth, lineHeight;
@@ -7132,80 +7132,80 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
nLines = lines.GetCount(); nLines = lines.GetCount();
if( nLines > 0 ) if( nLines > 0 )
{ {
int l; int l;
float x, y; float x = 0.0, y = 0.0;
if( textOrientation == wxHORIZONTAL ) if( textOrientation == wxHORIZONTAL )
GetTextBoxSize(dc, lines, &textWidth, &textHeight); GetTextBoxSize(dc, lines, &textWidth, &textHeight);
else else
GetTextBoxSize( dc, lines, &textHeight, &textWidth ); GetTextBoxSize( dc, lines, &textHeight, &textWidth );
switch( vertAlign ) switch( vertAlign )
{ {
case wxALIGN_BOTTOM: case wxALIGN_BOTTOM:
if( textOrientation == wxHORIZONTAL ) if( textOrientation == wxHORIZONTAL )
y = rect.y + (rect.height - textHeight - 1); y = rect.y + (rect.height - textHeight - 1);
else else
x = rect.x + rect.width - textWidth; x = rect.x + rect.width - textWidth;
break; break;
case wxALIGN_CENTRE: case wxALIGN_CENTRE:
if( textOrientation == wxHORIZONTAL ) if( textOrientation == wxHORIZONTAL )
y = rect.y + ((rect.height - textHeight)/2); y = rect.y + ((rect.height - textHeight)/2);
else else
x = rect.x + ((rect.width - textWidth)/2); x = rect.x + ((rect.width - textWidth)/2);
break; break;
case wxALIGN_TOP: case wxALIGN_TOP:
default: default:
if( textOrientation == wxHORIZONTAL ) if( textOrientation == wxHORIZONTAL )
y = rect.y + 1; y = rect.y + 1;
else else
x = rect.x + 1; x = rect.x + 1;
break;
}
// Align each line of a multi-line label
for( l = 0; l < nLines; l++ )
{
dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
switch( horizAlign )
{
case wxALIGN_RIGHT:
if( textOrientation == wxHORIZONTAL )
x = rect.x + (rect.width - lineWidth - 1);
else
y = rect.y + lineWidth + 1;
break;
case wxALIGN_CENTRE:
if( textOrientation == wxHORIZONTAL )
x = rect.x + ((rect.width - lineWidth)/2);
else
y = rect.y + rect.height - ((rect.height - lineWidth)/2);
break;
case wxALIGN_LEFT:
default:
if( textOrientation == wxHORIZONTAL )
x = rect.x + 1;
else
y = rect.y + rect.height - 1;
break; break;
} }
if( textOrientation == wxHORIZONTAL ) // Align each line of a multi-line label
{ for( l = 0; l < nLines; l++ )
dc.DrawText( lines[l], (int)x, (int)y ); {
y += lineHeight; dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
}
else switch( horizAlign )
{ {
dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 ); case wxALIGN_RIGHT:
x += lineHeight; if( textOrientation == wxHORIZONTAL )
} x = rect.x + (rect.width - lineWidth - 1);
} else
y = rect.y + lineWidth + 1;
break;
case wxALIGN_CENTRE:
if( textOrientation == wxHORIZONTAL )
x = rect.x + ((rect.width - lineWidth)/2);
else
y = rect.y + rect.height - ((rect.height - lineWidth)/2);
break;
case wxALIGN_LEFT:
default:
if( textOrientation == wxHORIZONTAL )
x = rect.x + 1;
else
y = rect.y + rect.height - 1;
break;
}
if( textOrientation == wxHORIZONTAL )
{
dc.DrawText( lines[l], (int)x, (int)y );
y += lineHeight;
}
else
{
dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 );
x += lineHeight;
}
}
} }
dc.DestroyClippingRegion(); dc.DestroyClippingRegion();
} }