|
|
|
@@ -2,7 +2,6 @@
|
|
|
|
|
// Name: svgtest.cpp
|
|
|
|
|
// Purpose: SVG sample
|
|
|
|
|
// Author: Chris Elliott
|
|
|
|
|
// Modified by:
|
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
@@ -23,16 +22,11 @@
|
|
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
|
#include "wx/wx.h"
|
|
|
|
|
#include "wx/mdi.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "wx/toolbar.h"
|
|
|
|
|
#include "wx/dcsvg.h"
|
|
|
|
|
#include "wx/vector.h"
|
|
|
|
|
#include "wx/notebook.h"
|
|
|
|
|
|
|
|
|
|
#include "bitmaps/new.xpm"
|
|
|
|
|
#include "bitmaps/save.xpm"
|
|
|
|
|
#include "bitmaps/help.xpm"
|
|
|
|
|
#include "SVGlogo24.xpm"
|
|
|
|
|
|
|
|
|
|
#ifndef wxHAS_IMAGES_IN_RESOURCES
|
|
|
|
@@ -41,9 +35,6 @@
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
class MyChild;
|
|
|
|
|
class MyCanvas;
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// classes
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
@@ -54,91 +45,86 @@ public:
|
|
|
|
|
bool OnInit() wxOVERRIDE;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MyFrame : public wxMDIParentFrame
|
|
|
|
|
// Existing pages:
|
|
|
|
|
enum Page
|
|
|
|
|
{
|
|
|
|
|
Page_Lines,
|
|
|
|
|
Page_Polygons,
|
|
|
|
|
Page_Text,
|
|
|
|
|
Page_Arcs,
|
|
|
|
|
Page_Checkmarks,
|
|
|
|
|
Page_ScaledText,
|
|
|
|
|
Page_Bitmaps,
|
|
|
|
|
Page_Clipping,
|
|
|
|
|
Page_TextPos,
|
|
|
|
|
Page_Max
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char* pageNames[] =
|
|
|
|
|
{
|
|
|
|
|
"Lines",
|
|
|
|
|
"Polygons",
|
|
|
|
|
"Text",
|
|
|
|
|
"Arcs",
|
|
|
|
|
"Checkmarks",
|
|
|
|
|
"Scaled text",
|
|
|
|
|
"Bitmaps",
|
|
|
|
|
"Clipping",
|
|
|
|
|
"Text position",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
wxCOMPILE_TIME_ASSERT( WXSIZEOF(pageNames) == Page_Max, PageNamesMismatch );
|
|
|
|
|
|
|
|
|
|
static const char* pageDescriptions[] =
|
|
|
|
|
{
|
|
|
|
|
"Green Cross, Cyan Line and spline",
|
|
|
|
|
"Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars",
|
|
|
|
|
"Swiss, Times text; red text, rotated and colored orange",
|
|
|
|
|
"This is an arc test page",
|
|
|
|
|
"Two check marks",
|
|
|
|
|
"Scaling test page",
|
|
|
|
|
"Icon and Bitmap ",
|
|
|
|
|
"Clipping region",
|
|
|
|
|
"Text position test page",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
wxCOMPILE_TIME_ASSERT( WXSIZEOF(pageDescriptions) == Page_Max, PageDescriptionsMismatch );
|
|
|
|
|
|
|
|
|
|
class MyPage : public wxScrolledWindow
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
MyPage(wxNotebook *parent, int index);
|
|
|
|
|
virtual void OnDraw(wxDC& dc) wxOVERRIDE;
|
|
|
|
|
bool OnSave(wxString);
|
|
|
|
|
private:
|
|
|
|
|
int m_index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MyFrame : public wxFrame
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
|
|
|
|
|
const wxPoint& pos, const wxSize& size, const long style);
|
|
|
|
|
const wxPoint& pos, const wxSize& size);
|
|
|
|
|
|
|
|
|
|
void InitToolBar(wxToolBar* toolBar);
|
|
|
|
|
|
|
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
|
void FileSavePicture(wxCommandEvent& event);
|
|
|
|
|
void OnAbout(wxCommandEvent& event);
|
|
|
|
|
void OnNewWindow(wxCommandEvent& event);
|
|
|
|
|
void OnQuit(wxCommandEvent& event);
|
|
|
|
|
void FileSavePicture (wxCommandEvent& event);
|
|
|
|
|
|
|
|
|
|
unsigned int GetCountOfChildren() const
|
|
|
|
|
{ return m_nWinCreated; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
unsigned int m_nWinCreated;
|
|
|
|
|
wxNotebook *m_notebook;
|
|
|
|
|
wxPanel *m_panel;
|
|
|
|
|
wxBoxSizer *m_sizerFrame;
|
|
|
|
|
|
|
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MyChild: public wxMDIChildFrame
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
MyChild(wxMDIParentFrame *parent, const wxString& title,
|
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
|
const long style = wxDEFAULT_FRAME_STYLE);
|
|
|
|
|
~MyChild();
|
|
|
|
|
|
|
|
|
|
void OnActivate(wxActivateEvent& event);
|
|
|
|
|
void OnQuit(wxCommandEvent& event);
|
|
|
|
|
bool OnSave(wxString filename);
|
|
|
|
|
|
|
|
|
|
MyFrame* GetFrame()
|
|
|
|
|
{ return m_frame; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
MyCanvas *m_canvas;
|
|
|
|
|
MyFrame *m_frame;
|
|
|
|
|
|
|
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MyCanvas : public wxScrolledWindow
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
MyCanvas(MyChild *parent, const wxPoint& pos, const wxSize& size);
|
|
|
|
|
virtual void OnDraw(wxDC& dc) wxOVERRIDE;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_index;
|
|
|
|
|
MyChild* m_child;
|
|
|
|
|
|
|
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// constants
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// menu items ids
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
MDI_QUIT = 100,
|
|
|
|
|
MDI_NEW_WINDOW,
|
|
|
|
|
MDI_SAVE,
|
|
|
|
|
MDI_REFRESH,
|
|
|
|
|
MDI_CHILD_QUIT,
|
|
|
|
|
MDI_ABOUT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// event tables
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
wxBEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
|
|
|
|
EVT_MENU(MDI_ABOUT, MyFrame::OnAbout)
|
|
|
|
|
EVT_MENU(MDI_NEW_WINDOW, MyFrame::OnNewWindow)
|
|
|
|
|
EVT_MENU(MDI_QUIT, MyFrame::OnQuit)
|
|
|
|
|
EVT_MENU (MDI_SAVE, MyFrame::FileSavePicture)
|
|
|
|
|
|
|
|
|
|
EVT_SIZE(MyFrame::OnSize)
|
|
|
|
|
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
|
|
|
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
|
|
|
|
|
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
|
|
|
|
|
EVT_MENU(wxID_SAVE, MyFrame::FileSavePicture)
|
|
|
|
|
wxEND_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
// ===========================================================================
|
|
|
|
@@ -155,37 +141,38 @@ bool MyApp::OnInit()
|
|
|
|
|
{
|
|
|
|
|
// Create the main frame window
|
|
|
|
|
|
|
|
|
|
MyFrame* frame = new MyFrame((wxFrame *)NULL, -1, wxT("SVG Demo"),
|
|
|
|
|
wxDefaultPosition, wxSize(500, 400),
|
|
|
|
|
wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL);
|
|
|
|
|
MyFrame* frame = new MyFrame(NULL, -1, wxT("SVG Demo"),
|
|
|
|
|
wxDefaultPosition, wxSize(500, 400));
|
|
|
|
|
|
|
|
|
|
frame->Show(true);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// MyFrame
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Define my frame constructor
|
|
|
|
|
MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
|
|
|
|
|
const wxPoint& pos, const wxSize& size, const long style)
|
|
|
|
|
: wxMDIParentFrame(parent, id, title, pos, size, style)
|
|
|
|
|
{
|
|
|
|
|
m_nWinCreated = 0;
|
|
|
|
|
|
|
|
|
|
MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
|
|
|
|
|
const wxPoint& pos, const wxSize& size)
|
|
|
|
|
: wxFrame(parent, id, title, pos, size)
|
|
|
|
|
{
|
|
|
|
|
SetIcon(wxICON(sample));
|
|
|
|
|
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
CreateStatusBar();
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
|
|
|
|
|
// Make a menubar
|
|
|
|
|
wxMenu *file_menu = new wxMenu;
|
|
|
|
|
|
|
|
|
|
file_menu->Append(MDI_NEW_WINDOW, wxT("&New test\tCtrl+N"));
|
|
|
|
|
file_menu->Append(MDI_QUIT, wxT("&Exit\tAlt+X"));
|
|
|
|
|
file_menu->Append(wxID_SAVE);
|
|
|
|
|
file_menu->Append(wxID_EXIT);
|
|
|
|
|
|
|
|
|
|
wxMenu *help_menu = new wxMenu;
|
|
|
|
|
help_menu->Append(MDI_ABOUT, wxT("&About"));
|
|
|
|
|
help_menu->Append(wxID_ABOUT);
|
|
|
|
|
|
|
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
|
|
|
|
|
|
|
|
@@ -195,12 +182,15 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
|
|
|
|
|
// Associate the menu bar with the frame
|
|
|
|
|
SetMenuBar(menu_bar);
|
|
|
|
|
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
CreateStatusBar();
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
// Create a notebook
|
|
|
|
|
m_notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_TOP);
|
|
|
|
|
|
|
|
|
|
CreateToolBar(wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL);
|
|
|
|
|
InitToolBar(GetToolBar());
|
|
|
|
|
//Add SVG Windows to a notebook
|
|
|
|
|
for (int i = 0; i < Page_Max; ++i)
|
|
|
|
|
{
|
|
|
|
|
m_notebook->AddPage(new MyPage(m_notebook, i), pageNames[i]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
|
|
@@ -208,97 +198,29 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
|
|
|
|
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
(void)wxMessageBox(wxT("wxWidgets SVG sample\n")
|
|
|
|
|
wxT("Author: Chris Elliott (c) 2002-2009\n")
|
|
|
|
|
wxT("Usage: click File|New to show tests"),
|
|
|
|
|
wxT("Authors:\n")
|
|
|
|
|
wxT(" Chris Elliott (c) 2002-2009\n")
|
|
|
|
|
wxT(" Prashant Kumar Nirmal (c) 2017\n")
|
|
|
|
|
wxT("Usage: click File|Save to Save the Selected SVG Test"),
|
|
|
|
|
wxT("About SVG Test"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
|
|
|
|
|
{
|
|
|
|
|
// Make another frame, containing a canvas
|
|
|
|
|
MyChild *subframe = new MyChild(this, wxT("SVG Frame"));
|
|
|
|
|
|
|
|
|
|
wxString title;
|
|
|
|
|
title.Printf(wxT("SVG Test Window %d"), m_nWinCreated );
|
|
|
|
|
|
|
|
|
|
// counts number of children previously, even if now closed
|
|
|
|
|
m_nWinCreated ++;
|
|
|
|
|
|
|
|
|
|
// Give it a title and icon
|
|
|
|
|
subframe->SetTitle(title);
|
|
|
|
|
subframe->SetIcon(wxICON(sample));
|
|
|
|
|
|
|
|
|
|
// Make a menubar
|
|
|
|
|
wxMenu *file_menu = new wxMenu;
|
|
|
|
|
|
|
|
|
|
file_menu->Append(MDI_NEW_WINDOW, wxT("&Another test\tCtrl+N"));
|
|
|
|
|
file_menu->Append(MDI_SAVE, wxT("&Save\tCtrl+S"), wxT("Save in SVG format"));
|
|
|
|
|
file_menu->Append(MDI_CHILD_QUIT, wxT("&Close child\tCtrl+F4"));
|
|
|
|
|
file_menu->Append(MDI_QUIT, wxT("&Exit\tAlt+X"));
|
|
|
|
|
|
|
|
|
|
wxMenu *help_menu = new wxMenu;
|
|
|
|
|
help_menu->Append(MDI_ABOUT, wxT("&About"));
|
|
|
|
|
|
|
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
|
|
|
|
|
|
|
|
|
menu_bar->Append(file_menu, wxT("&File"));
|
|
|
|
|
menu_bar->Append(help_menu, wxT("&Help"));
|
|
|
|
|
|
|
|
|
|
// Associate the menu bar with the frame
|
|
|
|
|
subframe->SetMenuBar(menu_bar);
|
|
|
|
|
|
|
|
|
|
subframe->Show(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyFrame::OnSize(wxSizeEvent& event)
|
|
|
|
|
{
|
|
|
|
|
int w, h;
|
|
|
|
|
GetClientSize(&w, &h);
|
|
|
|
|
|
|
|
|
|
GetClientWindow()->SetSize(0, 0, w, h);
|
|
|
|
|
event.Skip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyFrame::InitToolBar(wxToolBar* toolBar)
|
|
|
|
|
{
|
|
|
|
|
const int maxBitmaps = 3;
|
|
|
|
|
wxBitmap* bitmaps[maxBitmaps];
|
|
|
|
|
|
|
|
|
|
bitmaps[0] = new wxBitmap( new_xpm );
|
|
|
|
|
bitmaps[1] = new wxBitmap( save_xpm );
|
|
|
|
|
bitmaps[2] = new wxBitmap( help_xpm );
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < maxBitmaps; i++)
|
|
|
|
|
delete bitmaps[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyFrame::FileSavePicture (wxCommandEvent & WXUNUSED(event) )
|
|
|
|
|
void MyFrame::FileSavePicture(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
#if wxUSE_FILEDLG
|
|
|
|
|
MyChild * pChild = (MyChild *)GetActiveChild();
|
|
|
|
|
if (pChild == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MyPage * const page = (MyPage *) m_notebook->GetCurrentPage();
|
|
|
|
|
|
|
|
|
|
wxFileDialog dialog(this, wxT("Save Picture as"), wxEmptyString, pChild->GetTitle(),
|
|
|
|
|
wxFileDialog dialog(this, wxT("Save Picture as"), wxEmptyString,
|
|
|
|
|
m_notebook->GetPageText(m_notebook->GetSelection()),
|
|
|
|
|
wxT("SVG vector picture files (*.svg)|*.svg"),
|
|
|
|
|
wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
if (!pChild->OnSave ( dialog.GetPath() ))
|
|
|
|
|
if (!page->OnSave ( dialog.GetPath() ))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@@ -307,31 +229,30 @@ void MyFrame::FileSavePicture (wxCommandEvent & WXUNUSED(event) )
|
|
|
|
|
#endif // wxUSE_FILEDLG
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// MyCanvas
|
|
|
|
|
// MyPage
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
wxBEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
|
|
|
|
|
wxEND_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
// Define a constructor for my canvas
|
|
|
|
|
MyCanvas::MyCanvas(MyChild *parent, const wxPoint& pos, const wxSize& size)
|
|
|
|
|
: wxScrolledWindow(parent, wxID_ANY, pos, size, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL)
|
|
|
|
|
// Define a constructor for my page
|
|
|
|
|
MyPage::MyPage(wxNotebook *parent, int index)
|
|
|
|
|
: wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxHSCROLL)
|
|
|
|
|
{
|
|
|
|
|
SetBackgroundColour(*wxWHITE);
|
|
|
|
|
SetScrollbars(20, 20, 50, 50);
|
|
|
|
|
m_index = index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_child = parent;
|
|
|
|
|
m_index = m_child->GetFrame()->GetCountOfChildren() % 9;
|
|
|
|
|
bool MyPage::OnSave(wxString filename)
|
|
|
|
|
{
|
|
|
|
|
wxSVGFileDC svgDC (filename, 600, 650);
|
|
|
|
|
OnDraw (svgDC);
|
|
|
|
|
return svgDC.IsOk();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Define the repainting behaviour
|
|
|
|
|
void MyCanvas::OnDraw(wxDC& dc)
|
|
|
|
|
void MyPage::OnDraw(wxDC& dc)
|
|
|
|
|
{
|
|
|
|
|
// vars to use ...
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
wxString s;
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
// vars to use ...
|
|
|
|
|
wxPen wP;
|
|
|
|
|
wxBrush wB;
|
|
|
|
|
wxPoint points[6];
|
|
|
|
@@ -342,8 +263,7 @@ void MyCanvas::OnDraw(wxDC& dc)
|
|
|
|
|
|
|
|
|
|
switch (m_index)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 0:
|
|
|
|
|
case Page_Lines:
|
|
|
|
|
// draw lines to make a cross
|
|
|
|
|
dc.DrawLine(0, 0, 200, 200);
|
|
|
|
|
dc.DrawLine(200, 0, 0, 200);
|
|
|
|
@@ -355,12 +275,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:
|
|
|
|
|
case Page_Polygons:
|
|
|
|
|
// draw standard shapes
|
|
|
|
|
dc.SetBrush(*wxCYAN_BRUSH);
|
|
|
|
|
dc.SetPen(*wxRED_PEN);
|
|
|
|
@@ -380,12 +297,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:
|
|
|
|
|
case Page_Text:
|
|
|
|
|
// draw text in Arial or similar font
|
|
|
|
|
dc.DrawLine(50,25,50,35);
|
|
|
|
|
dc.DrawLine(45,30,55,30);
|
|
|
|
@@ -404,12 +318,9 @@ void MyCanvas::OnDraw(wxDC& dc)
|
|
|
|
|
.Italic().Bold());
|
|
|
|
|
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 :
|
|
|
|
|
case Page_Arcs:
|
|
|
|
|
// four arcs start and end points, center
|
|
|
|
|
dc.SetBrush(*wxGREEN_BRUSH);
|
|
|
|
|
dc.DrawArc ( 200,300, 370,230, 300,300 );
|
|
|
|
@@ -440,22 +351,16 @@ void MyCanvas::OnDraw(wxDC& dc)
|
|
|
|
|
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:
|
|
|
|
|
case Page_Checkmarks:
|
|
|
|
|
dc.DrawCheckMark ( 30,30,25,25);
|
|
|
|
|
dc.SetBrush (wxBrush (wxT("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:
|
|
|
|
|
case Page_ScaledText:
|
|
|
|
|
dc.SetFont(wxFontInfo(18)
|
|
|
|
|
.FaceName("Times New Roman")
|
|
|
|
|
.Family(wxFONTFAMILY_ROMAN)
|
|
|
|
@@ -484,20 +389,14 @@ void MyCanvas::OnDraw(wxDC& dc)
|
|
|
|
|
dc.DrawLine(0, 0, 200, 200);
|
|
|
|
|
dc.DrawLine(200, 0, 0, 200);
|
|
|
|
|
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:
|
|
|
|
|
case Page_Bitmaps:
|
|
|
|
|
dc.DrawIcon( wxICON(sample), 10, 10 );
|
|
|
|
|
dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
s = wxT("Icon and Bitmap ");
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
|
case Page_Clipping:
|
|
|
|
|
dc.SetTextForeground(wxT("RED"));
|
|
|
|
|
dc.DrawText(wxT("Red = Clipping Off"), 30, 5);
|
|
|
|
|
dc.SetTextForeground(wxT("GREEN"));
|
|
|
|
@@ -554,12 +453,9 @@ void MyCanvas::OnDraw(wxDC& dc)
|
|
|
|
|
dc.DestroyClippingRegion();
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
s = wxT("Clipping region");
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
case Page_TextPos:
|
|
|
|
|
wxString txtStr;
|
|
|
|
|
wxCoord txtX, txtY, txtW, txtH, txtDescent, txtEL;
|
|
|
|
|
wxCoord txtPad = 0;
|
|
|
|
@@ -598,65 +494,9 @@ void MyCanvas::OnDraw(wxDC& dc)
|
|
|
|
|
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.DrawRotatedText(txtStr, txtX, txtY, 45);
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
s = wxT("Text position test page");
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
m_child->SetStatusText(s);
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// MyChild
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Note that MDI_NEW_WINDOW and MDI_ABOUT commands get passed
|
|
|
|
|
// to the parent window for processing, so no need to
|
|
|
|
|
// duplicate event handlers here.
|
|
|
|
|
wxBEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
|
|
|
|
|
EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
|
|
|
|
|
wxEND_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title,
|
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
|
const long style)
|
|
|
|
|
: wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
|
|
|
|
|
{
|
|
|
|
|
m_frame = (MyFrame *) parent;
|
|
|
|
|
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
|
CreateStatusBar();
|
|
|
|
|
SetStatusText(title);
|
|
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
|
|
|
|
|
m_canvas = new MyCanvas(this, wxPoint(0, 0), GetClientSize());
|
|
|
|
|
|
|
|
|
|
// Give it scrollbars
|
|
|
|
|
m_canvas->SetScrollbars(20, 20, 50, 50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyChild::~MyChild()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
Close(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MyChild::OnSave(wxString filename)
|
|
|
|
|
{
|
|
|
|
|
wxSVGFileDC svgDC (filename, 600, 650);
|
|
|
|
|
m_canvas->OnDraw (svgDC);
|
|
|
|
|
return svgDC.IsOk();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyChild::OnActivate(wxActivateEvent& event)
|
|
|
|
|
{
|
|
|
|
|
if ( event.GetActive() && m_canvas )
|
|
|
|
|
m_canvas->SetFocus();
|
|
|
|
|
|
|
|
|
|
wxLogStatus("%s", pageDescriptions[m_index]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|