+ wxImage img2 = img.Rotate(frame->m_angle,
+ wxPoint(img.GetWidth() / 2, img.GetHeight() / 2), false);
+
+ // Add the cards to an array to be drawn later in OnPaint()
+ m_cards.Add(new MyRenderedCard(wxBitmap(img2), event.m_x, event.m_y));
+ Refresh(false);
+}
+
+void MyCanvas::OnPaint (wxPaintEvent &)
+{
+ size_t numCards = m_cards.GetCount();
+
+ wxPaintDC dc(this);
+ dc.BeginDrawing();
+
+ dc.SetTextForeground(wxColour(255, 255, 255));
+ dc.DrawText(wxT("Click on the canvas to draw a card."), 10, 10);
+
+ for (size_t i = 0; i < numCards; i++) {
+ MyRenderedCard & card = m_cards.Item(i);
+ dc.DrawBitmap(card.m_bmp, card.m_x, card.m_y, true);
+ }
+
+ dc.EndDrawing();
+}
+
+// ----------------------------------------------------------------------------
+// main frame
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU (ID_Quit, MyFrame::OnQuit)
+ EVT_MENU (ID_Angle, MyFrame::OnAngle)
+ EVT_MENU (ID_Clear, MyFrame::OnClear)
+END_EVENT_TABLE()
+
+MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
+ : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
+{
+ m_angle = 0.1;
+
+ m_canvas = new MyCanvas(this);
+
+ wxMenu *menuFile = new wxMenu;
+ menuFile->Append (ID_Angle, _T("Set &angle...\tCtrl-A"));
+ menuFile->Append (ID_Clear, _T("&Clear all cards\tCtrl-C"));
+ menuFile->AppendSeparator();
+ menuFile->Append (ID_Quit, _T("E&xit\tAlt-X"));
+
+ wxMenuBar *menuBar = new wxMenuBar;
+ menuBar->Append (menuFile, _T("&File"));
+
+ SetMenuBar (menuBar);
+}
+
+void MyFrame::OnAngle (wxCommandEvent &)
+{
+ long degrees = (long)((180*m_angle)/M_PI);
+ degrees = wxGetNumberFromUser(_T("Change the image rotation angle"),
+ _T("Angle in degrees:"),
+ _T("wxWidgets rotate sample"),
+ degrees,
+ -180, +180,
+ this);
+ if ( degrees != -1 )
+ m_angle = (degrees * M_PI) / 180.0;
+}