X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cdf3a589b2bb01c3ca1dc4e35661d864b2a2c227..da7d0696d138988ff5d2253eb39e5a73de02aa11:/samples/svg/svgtest.cpp?ds=sidebyside diff --git a/samples/svg/svgtest.cpp b/samples/svg/svgtest.cpp index a8f76a6f61..4e29ebcb8c 100644 --- a/samples/svg/svgtest.cpp +++ b/samples/svg/svgtest.cpp @@ -1,12 +1,3 @@ -// biol75@york.ac.uk (Chris Elliott) March 2000 - -#ifdef __BIDE__ -#define _NO_VCL -#include "condefs.h" -USERC("svg.rc"); -//--------------------------------------------------------------------------- -#define WinMain WinMain -#endif ///////////////////////////////////////////////////////////////////////////// // Name: svgtest.cpp // Purpose: SVG sample @@ -36,14 +27,16 @@ USERC("svg.rc"); #include "wx/mdi.h" #endif -#include -#include +#include "wx/toolbar.h" +#include "wx/dcsvg.h" + +#include "mondrian.xpm" #include "bitmaps/new.xpm" #include "bitmaps/save.xpm" #include "bitmaps/help.xpm" #include "SVGlogo24.xpm" - + class MyChild; // Define a new application @@ -81,7 +74,7 @@ class MyCanvas : public wxScrolledWindow { public: int m_index ; - + MyChild * m_child ; MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size); virtual void OnDraw(wxDC& dc); @@ -158,7 +151,7 @@ bool MyApp::OnInit() frame = new MyFrame((wxFrame *)NULL, -1, wxT("SVG Demo"), wxPoint(-1, -1), wxSize(500, 400), wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL); - + // Make a menubar wxMenu *file_menu = new wxMenu; @@ -177,13 +170,15 @@ bool MyApp::OnInit() // Associate the menu bar with the frame frame->SetMenuBar(menu_bar); +#if wxUSE_STATUSBAR frame->CreateStatusBar(); +#endif // wxUSE_STATUSBAR - frame->Show(TRUE); + frame->Show(true); SetTopWindow(frame); - return TRUE; + return true; } @@ -214,22 +209,22 @@ void MyFrame::OnClose(wxCloseEvent& event) event.Skip(); return ; } - if ( m_children.Number () < 1 ) + if ( m_children.GetCount () < 1 ) { event.Skip(); return ; } // now try the children - wxNode * pNode = m_children.GetFirst (); - wxNode * pNext ; + wxObjectList::compatibility_iterator pNode = m_children.GetFirst (); + wxObjectList::compatibility_iterator pNext ; MyChild * pChild ; while ( pNode ) { pNext = pNode -> GetNext (); - pChild = (MyChild*) pNode -> Data (); + pChild = (MyChild*) pNode -> GetData (); if (pChild -> Close ()) { - delete pNode ; + m_children.Erase(pNode) ; } else { @@ -250,9 +245,9 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) { - (void)wxMessageBox(wxT("wxWindows 2.0 SVG 1.0 Test\n" - "Author: Chris Elliott (c) 2002\n" - "Usage: svg.exe \nClick File | New to show tests\n\n"), wxT("About SVG Test")); + (void)wxMessageBox(wxT("wxWidgets 2.0 SVG 1.0 Test\n") + wxT("Author: Chris Elliott (c) 2002\n") + wxT("Usage: svg.exe \nClick File | New to show tests\n\n"), wxT("About SVG Test")); } @@ -265,7 +260,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) wxPoint(-1, -1), wxSize(-1, -1), wxDEFAULT_FRAME_STYLE ) ) ; - subframe = (MyChild *) m_children.GetLast() -> Data (); + subframe = (MyChild *) m_children.GetLast() -> GetData (); wxString title; title.Printf(wxT("SVG Test Window %d"), nWinCreated ); // counts number of children previously, even if now closed @@ -294,16 +289,17 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) // Associate the menu bar with the frame subframe->SetMenuBar(menu_bar); - subframe->Show(TRUE); + subframe->Show(true); } -void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event)) +void MyFrame::OnSize(wxSizeEvent& event) { int w, h; GetClientSize(&w, &h); GetClientWindow()->SetSize(0, 0, w, h); + event.Skip(); } @@ -319,12 +315,12 @@ void MyFrame::InitToolBar(wxToolBar* toolBar) int width = 16; int currentX = 5; - toolBar->AddTool( MDI_NEW_WINDOW, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, wxT("New SVG test window")); + toolBar->AddTool( MDI_NEW_WINDOW, *(bitmaps[0]), wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, wxT("New SVG test window")); currentX += width + 5; - toolBar->AddTool( MDI_SAVE, *bitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, wxT("Save test in SVG format")); + toolBar->AddTool( MDI_SAVE, *bitmaps[1], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, wxT("Save test in SVG format")); currentX += width + 5; - toolBar->AddSeparator(); - toolBar->AddTool(MDI_ABOUT, *bitmaps[2], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, wxT("Help")); + toolBar->AddSeparator(); + toolBar->AddTool(MDI_ABOUT, *bitmaps[2], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, wxT("Help")); toolBar->Realize(); @@ -336,15 +332,16 @@ void MyFrame::InitToolBar(wxToolBar* toolBar) void MyFrame::FileSavePicture (wxCommandEvent & WXUNUSED(event) ) { +#if wxUSE_FILEDLG MyChild * pChild = (MyChild *)GetActiveChild (); - if (pChild == NULL) + if (pChild == NULL) { return ; } wxFileDialog dialog(this, wxT("Save Picture as"), wxEmptyString, pChild->GetTitle(), wxT("SVG vector picture files (*.svg)|*.svg"), - wxSAVE|wxOVERWRITE_PROMPT); + wxFD_SAVE|wxFD_OVERWRITE_PROMPT); if (dialog.ShowModal() == wxID_OK) { @@ -354,6 +351,7 @@ void MyFrame::FileSavePicture (wxCommandEvent & WXUNUSED(event) ) } } return ; +#endif // wxUSE_FILEDLG } @@ -379,7 +377,7 @@ MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size) wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL) { m_child = (MyChild *) parent ; - SetBackgroundColour(wxColour("WHITE")); + SetBackgroundColour(wxColour(_T("WHITE"))); m_index = m_child->m_frame->nWinCreated % 7 ; } @@ -388,7 +386,9 @@ wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL) void MyCanvas::OnDraw(wxDC& dc) { // vars to use ... +#if wxUSE_STATUSBAR wxString s ; +#endif // wxUSE_STATUSBAR wxPen wP ; wxBrush wB ; wxPoint points[6]; @@ -398,7 +398,7 @@ void MyCanvas::OnDraw(wxDC& dc) dc.SetFont(*wxSWISS_FONT); dc.SetPen(*wxGREEN_PEN); - + switch (m_index) { default: @@ -414,7 +414,9 @@ void MyCanvas::OnDraw(wxDC& dc) dc.DrawPoint (25,15) ; dc.DrawLine(50, 30, 200, 30); dc.DrawSpline(50, 200, 50, 100, 200, 10); +#if wxUSE_STATUSBAR s = wxT("Green Cross, Cyan Line and spline"); +#endif // wxUSE_STATUSBAR break ; case 1: @@ -422,10 +424,10 @@ void MyCanvas::OnDraw(wxDC& dc) dc.SetBrush(*wxCYAN_BRUSH); dc.SetPen(*wxRED_PEN); dc.DrawRectangle(10, 10, 100, 70); - wB = wxBrush ("DARK ORCHID", wxTRANSPARENT); + wB = wxBrush (_T("DARK ORCHID"), wxTRANSPARENT); dc.SetBrush (wB); dc.DrawRoundedRectangle(50, 50, 100, 70, 20); - dc.SetBrush (wxBrush("GOLDENROD", wxSOLID) ); + dc.SetBrush (wxBrush(_T("GOLDENROD"), wxSOLID) ); dc.DrawEllipse(100, 100, 100, 50); points[0].x = 100; points[0].y = 200; @@ -437,7 +439,9 @@ void MyCanvas::OnDraw(wxDC& dc) dc.DrawPolygon(5, points); dc.DrawLines (6, points, 160); +#if wxUSE_STATUSBAR s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars"); +#endif // wxUSE_STATUSBAR break ; case 2: @@ -446,35 +450,37 @@ void MyCanvas::OnDraw(wxDC& dc) dc.DrawLine(45,30,55,30); dc.DrawText(wxT("This is a Swiss-style string"), 50, 30); wC = dc.GetTextForeground() ; - dc.SetTextForeground ("FIREBRICK"); - + dc.SetTextForeground (_T("FIREBRICK")); + // no effect in msw ?? - dc.SetTextBackground ("WHEAT"); + dc.SetTextBackground (_T("WHEAT")); dc.DrawText(wxT("This is a Red string"), 50, 200); dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45); dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90); - wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, FALSE, wxT("Times New Roman")); + wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman")); dc.SetFont(wF); dc.SetTextForeground (wC) ; 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"); +#endif // wxUSE_STATUSBAR break ; case 3 : // four arcs start and end points, center dc.SetBrush(*wxGREEN_BRUSH); - dc.DrawArc ( 200,300, 370,230, 300.0,300.0 ); + dc.DrawArc ( 200,300, 370,230, 300,300 ); dc.SetBrush(*wxBLUE_BRUSH); - dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270.0,270.0 ); + dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 ); dc.SetDeviceOrigin(-10,-10); - dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270.0,270.0 ); + dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 ); dc.SetDeviceOrigin(0,0); - wP.SetColour ("CADET BLUE"); + wP.SetColour (_T("CADET BLUE")); dc.SetPen(wP); - dc.DrawArc ( 75,125, 110, 40, 75.0, 75.0 ); + dc.DrawArc ( 75,125, 110, 40, 75, 75 ); - wP.SetColour ("SALMON"); + wP.SetColour (_T("SALMON")); dc.SetPen(wP); dc.SetBrush(*wxRED_BRUSH); //top left corner, width and height, start and end angle @@ -485,25 +491,29 @@ void MyCanvas::OnDraw(wxDC& dc) wP.SetWidth(3); dc.SetPen(wP); //wxTRANSPARENT)); - dc.SetBrush (wxBrush ("SALMON",wxSOLID)) ; + dc.SetBrush (wxBrush (_T("SALMON"),wxSOLID)) ; dc.DrawEllipticArc(300, 0,200,100, 0.0,145.0) ; //same end point dc.DrawEllipticArc(300, 50,200,100,90.0,145.0) ; dc.DrawEllipticArc(300,100,200,100,90.0,345.0) ; +#if wxUSE_STATUSBAR s = wxT("This is an arc test page"); +#endif // wxUSE_STATUSBAR break ; case 4: dc.DrawCheckMark ( 30,30,25,25); - dc.SetBrush (wxBrush ("SALMON",wxTRANSPARENT)); + dc.SetBrush (wxBrush (_T("SALMON"),wxTRANSPARENT)); dc.DrawCheckMark ( 80,50,75,75); dc.DrawRectangle ( 80,50,75,75); +#if wxUSE_STATUSBAR s = wxT("Two check marks"); +#endif // wxUSE_STATUSBAR break ; case 5: - wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, FALSE, wxT("Times New Roman")); + wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman")); dc.SetFont(wF); dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); @@ -528,18 +538,24 @@ void MyCanvas::OnDraw(wxDC& dc) dc.SetMapMode (wxMM_METRIC) ; //svg ignores this dc.DrawLine(0, 0, 200, 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"); +#endif // wxUSE_STATUSBAR break ; case 6: - dc.DrawIcon( wxICON(mondrian), 10, 10 ); - dc.DrawBitmap ( wxBITMAP (svgbitmap), 50,15); + dc.DrawIcon( wxIcon(mondrian_xpm), 10, 10 ); + dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15); +#if wxUSE_STATUSBAR s = wxT("Icon and Bitmap "); +#endif // wxUSE_STATUSBAR break ; } +#if wxUSE_STATUSBAR m_child->SetStatusText(s); +#endif // wxUSE_STATUSBAR } @@ -556,8 +572,10 @@ const long style) { m_frame = (MyFrame *) parent ; +#if wxUSE_STATUSBAR CreateStatusBar(); - SetStatusText(title); + SetStatusText(title); +#endif // wxUSE_STATUSBAR int w, h ; GetClientSize ( &w, &h ); @@ -576,7 +594,7 @@ MyChild::~MyChild() void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event)) { - Close(TRUE); + Close(true); }