]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/canvas/simple/simple.cpp
made operator==() and \!=() const (still doesn't make them correct probably)
[wxWidgets.git] / contrib / samples / canvas / simple / simple.cpp
index 3ee80e97b09b78948664885b6f94ae2df09e7565..46385b28f1e64ac08cedc6878c7b64e4a6899baf 100644 (file)
@@ -20,7 +20,7 @@
 #include "simple.h"
 
 // Include icon header
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
     #include "mondrian.xpm"
 #endif
 
@@ -38,6 +38,7 @@
 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
     EVT_MENU(ID_QUIT, MyFrame::OnQuit)
     EVT_CLOSE(MyFrame::OnCloseWindow)
+    EVT_TIMER(-1, MyFrame::OnTimer)
 END_EVENT_TABLE()
 
 MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
@@ -55,8 +56,7 @@ MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
     m_admin = new wxCanvasAdmin;
     wxCanvas *canvas = new wxCanvas( m_admin, this, -1 );
     
-    canvas->SetScroll( 0, 0, 400, 600 );
-    canvas->SetMappingScroll( 0, 0, 400, 600, FALSE );
+    canvas->SetScrollbars( 10, 10, 40, 40 );
     
     // The wxCanvasAdmin need to know about all Admin wxCanvas objects.
     m_admin->Append( canvas );
@@ -71,11 +71,15 @@ MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
 
     // Bunch of rects and images.
     wxBitmap bitmap( smile_xpm );
-    wxImage image( bitmap );
+    wxImage image( bitmap.ConvertToImage() );
 
     m_smile1 = new wxCanvasImage( image, 0,70,32,32 );
     root->Append( m_smile1 );
 
+    wxCanvasCircle *circ = new wxCanvasCircle( 170,70,50 );
+    circ->SetBrush( *wxBLUE_BRUSH );
+    root->Append( circ );
+    
     int i;
     for (i = 10; i < 300; i+=10)
     {
@@ -100,6 +104,14 @@ MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
     
     // One object group is the root object.
     canvas->SetRoot( root );
+    
+    m_timer = new wxTimer( this );
+    m_timer->Start( 80, FALSE );
+}
+
+MyFrame::~MyFrame()
+{
+    delete m_timer;
 }
 
 void MyFrame::CreateMyMenuBar()
@@ -127,6 +139,14 @@ void MyFrame::OnCloseWindow( wxCloseEvent &event )
     Destroy();
 }
 
+void MyFrame::OnTimer( wxTimerEvent &event )
+{
+    m_smile1->MoveRelative( 1, 0);
+    m_smile2->MoveRelative( 1, 0);
+    
+    wxWakeUpIdle();
+}
+
 //------------------------------------------------------------------------------
 // MyApp
 //------------------------------------------------------------------------------