X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/526954c5968baa29218c994ec48e476ae2bd4b9f..e0dec8753abaf97e006ea1185bfb6775b28df0a8:/samples/svg/svgtest.cpp diff --git a/samples/svg/svgtest.cpp b/samples/svg/svgtest.cpp index 78ffaf667b..ba6561bd06 100644 --- a/samples/svg/svgtest.cpp +++ b/samples/svg/svgtest.cpp @@ -36,10 +36,12 @@ #include "bitmaps/help.xpm" #include "SVGlogo24.xpm" -#if !defined(__WXMSW__) && !defined(__WXPM__) +#ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" #endif +#include + class MyChild; class MyCanvas; @@ -66,29 +68,29 @@ public: void OnNewWindow(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); void FileSavePicture (wxCommandEvent& event); - + unsigned int GetCountOfChildren() const { return m_nWinCreated; } private: unsigned int m_nWinCreated; - + DECLARE_EVENT_TABLE() }; class MyChild: public wxMDIChildFrame { public: - MyChild(wxMDIParentFrame *parent, const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, + 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; } @@ -108,7 +110,7 @@ public: private: int m_index; MyChild* m_child; - + DECLARE_EVENT_TABLE() }; @@ -160,8 +162,6 @@ bool MyApp::OnInit() frame->Show(true); - SetTopWindow(frame); - return true; } @@ -213,7 +213,7 @@ 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("Usage: click File|New to show tests"), wxT("About SVG Test")); } @@ -224,7 +224,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) wxString title; title.Printf(wxT("SVG Test Window %d"), m_nWinCreated ); - + // counts number of children previously, even if now closed m_nWinCreated ++; @@ -323,7 +323,7 @@ MyCanvas::MyCanvas(MyChild *parent, const wxPoint& pos, const wxSize& size) SetBackgroundColour(wxColour(wxT("WHITE"))); m_child = parent; - m_index = m_child->GetFrame()->GetCountOfChildren() % 7; + m_index = m_child->GetFrame()->GetCountOfChildren() % 8; } // Define the repainting behaviour @@ -495,6 +495,50 @@ void MyCanvas::OnDraw(wxDC& dc) #endif // wxUSE_STATUSBAR break; + case 7: + wxString txtStr; + wxCoord txtX, txtY, txtW, txtH, txtDescent, txtEL; + wxCoord txtPad = 0; + + wP = *wxRED_PEN; + dc.SetPen(wP); + //dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); + //dc.SetTextBackground(*wxBLUE); + + // Horizontal text + txtStr = wxT("Horizontal string"); + dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL); + txtX = 50; + txtY = 300; + dc.DrawRectangle(txtX, txtY, txtW + 2*txtPad, txtH + 2*txtPad); + dc.DrawText(txtStr, txtX + txtPad, txtY + txtPad); + + // Vertical text + txtStr = wxT("Vertical string"); + dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL); + txtX = 50; + txtY = 250; + dc.DrawRectangle(txtX, txtY - (txtW + 2*txtPad), txtH + 2*txtPad, txtW + 2*txtPad); + dc.DrawRotatedText(txtStr, txtX + txtPad, txtY - txtPad, 90); + + // 45 degree text + txtStr = wxT("45 deg string"); + dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL); + double lenW = (double)(txtW + 2*txtPad) / sqrt(2.0); + double lenH = (double)(txtH + 2*txtPad) / sqrt(2.0); + double padding = (double)txtPad / sqrt(2.0); + txtX = 150; + txtY = 200; + dc.DrawLine(txtX - padding, txtY, txtX + lenW, txtY - lenW); // top + dc.DrawLine(txtX + lenW, txtY - lenW, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); + 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); @@ -519,14 +563,14 @@ MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, : 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); }