-// 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
#include "wx/mdi.h"
#endif
-#include <wx/toolbar.h>
-#include <wx/svg/dcsvg.h>
+#include "wx/toolbar.h"
+#include "wx/dcsvg.h"
-#include "mondrian.xpm"
+#include "mondrian.xpm"
#include "bitmaps/new.xpm"
#include "bitmaps/save.xpm"
#include "bitmaps/help.xpm"
#include "SVGlogo24.xpm"
-
+
class MyChild;
// Define a new application
{
public:
int m_index ;
-
+
MyChild * m_child ;
MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size);
virtual void OnDraw(wxDC& dc);
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;
// 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;
}
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 )
{
pChild = (MyChild*) pNode -> GetData ();
if (pChild -> Close ())
{
- delete pNode ;
+ m_children.Erase(pNode) ;
}
else
{
// Associate the menu bar with the frame
subframe->SetMenuBar(menu_bar);
- subframe->Show(TRUE);
+ subframe->Show(true);
}
bitmaps[1] = new wxBitmap( save_xpm );
bitmaps[2] = new wxBitmap( help_xpm );
- int width = 16;
- int currentX = 5;
-
- toolBar->AddTool( MDI_NEW_WINDOW, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (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"));
- currentX += width + 5;
- toolBar->AddSeparator();
- toolBar->AddTool(MDI_ABOUT, *bitmaps[2], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, wxT("Help"));
+ toolBar->AddTool(MDI_NEW_WINDOW, wxEmptyString, *(bitmaps[0]), wxS("New SVG test window"));
+ toolBar->AddTool(MDI_SAVE, wxEmptyString, *bitmaps[1], wxS("Save test in SVG format"));
+ toolBar->AddSeparator();
+ toolBar->AddTool(MDI_ABOUT, wxEmptyString, *bitmaps[2], wxS("Help"));
toolBar->Realize();
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)
{
}
}
return ;
+#endif // wxUSE_FILEDLG
}
void MyCanvas::OnDraw(wxDC& dc)
{
// vars to use ...
+#if wxUSE_STATUSBAR
wxString s ;
+#endif // wxUSE_STATUSBAR
wxPen wP ;
wxBrush wB ;
wxPoint points[6];
dc.SetFont(*wxSWISS_FONT);
dc.SetPen(*wxGREEN_PEN);
-
+
switch (m_index)
{
default:
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:
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(10, 10, 100, 70);
- wB = wxBrush (_T("DARK ORCHID"), wxTRANSPARENT);
+ wB = wxBrush (_T("DARK ORCHID"), wxBRUSHSTYLE_TRANSPARENT);
dc.SetBrush (wB);
dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
- dc.SetBrush (wxBrush(_T("GOLDENROD"), wxSOLID) );
+ dc.SetBrush (wxBrush(_T("GOLDENROD")) );
dc.DrawEllipse(100, 100, 100, 50);
points[0].x = 100; points[0].y = 200;
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:
dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
wC = dc.GetTextForeground() ;
dc.SetTextForeground (_T("FIREBRICK"));
-
+
// no effect in msw ??
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 :
wP.SetWidth(3);
dc.SetPen(wP);
//wxTRANSPARENT));
- dc.SetBrush (wxBrush (_T("SALMON"),wxSOLID)) ;
+ dc.SetBrush (wxBrush (_T("SALMON"))) ;
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 (_T("SALMON"),wxTRANSPARENT));
+ dc.SetBrush (wxBrush (_T("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
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);
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_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
}
{
m_frame = (MyFrame *) parent ;
+#if wxUSE_STATUSBAR
CreateStatusBar();
- SetStatusText(title);
+ SetStatusText(title);
+#endif // wxUSE_STATUSBAR
int w, h ;
GetClientSize ( &w, &h );
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
{
- Close(TRUE);
+ Close(true);
}
{
wxSVGFileDC svgDC (filename, 600, 650) ;
m_canvas->OnDraw (svgDC);
- return svgDC.Ok();
+ return svgDC.IsOk();
}