Avoid ugly cast in the svg sample

Just use wxLogStatus() instead of manually setting the status text, as this
also allows to get rid of wxUSE_STATUSBAR checks (wxLogStatus() is always
declared and just does nothing in this case).
This commit is contained in:
Vadim Zeitlin
2017-03-31 17:09:04 +02:00
parent 367cf2da5c
commit fe562d8bcd

View File

@@ -231,9 +231,7 @@ bool MyPage::OnSave(wxString filename)
void MyPage::OnDraw(wxDC& dc) void MyPage::OnDraw(wxDC& dc)
{ {
// vars to use ... // vars to use ...
#if wxUSE_STATUSBAR
wxString s; wxString s;
#endif // wxUSE_STATUSBAR
wxPen wP; wxPen wP;
wxBrush wB; wxBrush wB;
wxPoint points[6]; wxPoint points[6];
@@ -257,9 +255,7 @@ void MyPage::OnDraw(wxDC& dc)
dc.DrawPoint (25,15); dc.DrawPoint (25,15);
dc.DrawLine(50, 30, 200, 30); dc.DrawLine(50, 30, 200, 30);
dc.DrawSpline(50, 200, 50, 100, 200, 10); dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
s = wxT("Green Cross, Cyan Line and spline"); s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
break; break;
case 1: case 1:
@@ -282,9 +278,7 @@ void MyPage::OnDraw(wxDC& dc)
dc.DrawPolygon(5, points); dc.DrawPolygon(5, points);
dc.DrawLines (6, points, 160); dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars"); s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
break; break;
case 2: case 2:
@@ -306,9 +300,7 @@ void MyPage::OnDraw(wxDC& dc)
.Italic().Bold()); .Italic().Bold());
dc.SetTextForeground (wC); dc.SetTextForeground (wC);
dc.DrawText(wxT("This is a Times-style string"), 50, 60); dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
s = wxT("Swiss, Times text; red text, rotated and colored orange"); s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
break; break;
case 3 : case 3 :
@@ -342,9 +334,7 @@ void MyPage::OnDraw(wxDC& dc)
dc.DrawEllipticArc(300, 50,200,100,90.0,145.0); dc.DrawEllipticArc(300, 50,200,100,90.0,145.0);
dc.DrawEllipticArc(300,100,200,100,90.0,345.0); dc.DrawEllipticArc(300,100,200,100,90.0,345.0);
#if wxUSE_STATUSBAR
s = wxT("This is an arc test page"); s = wxT("This is an arc test page");
#endif // wxUSE_STATUSBAR
break; break;
case 4: case 4:
@@ -352,9 +342,7 @@ void MyPage::OnDraw(wxDC& dc)
dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT)); dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
dc.DrawCheckMark ( 80,50,75,75); dc.DrawCheckMark ( 80,50,75,75);
dc.DrawRectangle ( 80,50,75,75); dc.DrawRectangle ( 80,50,75,75);
#if wxUSE_STATUSBAR
s = wxT("Two check marks"); s = wxT("Two check marks");
#endif // wxUSE_STATUSBAR
break; break;
case 5: case 5:
@@ -386,17 +374,13 @@ void MyPage::OnDraw(wxDC& dc)
dc.DrawLine(0, 0, 200, 200); dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200); dc.DrawLine(200, 0, 0, 200);
dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60); dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
#if wxUSE_STATUSBAR
s = wxT("Scaling test page"); s = wxT("Scaling test page");
#endif // wxUSE_STATUSBAR
break; break;
case 6: case 6:
dc.DrawIcon( wxICON(sample), 10, 10 ); dc.DrawIcon( wxICON(sample), 10, 10 );
dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15); dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
#if wxUSE_STATUSBAR
s = wxT("Icon and Bitmap "); s = wxT("Icon and Bitmap ");
#endif // wxUSE_STATUSBAR
break; break;
case 7: case 7:
@@ -456,9 +440,7 @@ void MyPage::OnDraw(wxDC& dc)
dc.DestroyClippingRegion(); dc.DestroyClippingRegion();
*/ */
#if wxUSE_STATUSBAR
s = wxT("Clipping region"); s = wxT("Clipping region");
#endif // wxUSE_STATUSBAR
break; break;
case 8: case 8:
@@ -500,13 +482,10 @@ void MyPage::OnDraw(wxDC& dc)
dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH); dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH);
dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom
dc.DrawRotatedText(txtStr, txtX, txtY, 45); dc.DrawRotatedText(txtStr, txtX, txtY, 45);
#if wxUSE_STATUSBAR
s = wxT("Text position test page"); s = wxT("Text position test page");
#endif // wxUSE_STATUSBAR
break; break;
} }
#if wxUSE_STATUSBAR
( (wxFrame *)wxGetTopLevelParent(this) )->SetStatusText(s); wxLogStatus("%s", s);
#endif // wxUSE_STATUSBAR
} }