]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/canvas/test/test.cpp
4 * Author: Robert Roebling
6 * Copyright: (C) 1998, Robert Roebling
9 // For compilers that support precompilation, includes "wx/wx.h".
10 #include "wx/wxprec.h"
26 #include "wx/canvas/canvas.h"
35 class MyFrame
: public wxFrame
41 void OnAbout( wxCommandEvent
&event
);
42 void OnNewFrame( wxCommandEvent
&event
);
43 void OnQuit( wxCommandEvent
&event
);
44 void OnTimer( wxTimerEvent
&event
);
51 DECLARE_DYNAMIC_CLASS(MyFrame
)
57 class MyApp
: public wxApp
60 virtual bool OnInit();
69 const int ID_QUIT
= 108;
70 const int ID_ABOUT
= 109;
72 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
74 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
75 EVT_MENU (ID_ABOUT
, MyFrame::OnAbout
)
76 EVT_MENU (ID_QUIT
, MyFrame::OnQuit
)
77 EVT_TIMER (-1, MyFrame::OnTimer
)
81 : wxFrame( (wxFrame
*)NULL
, -1, "wxCanvas sample",
82 wxPoint(20,20), wxSize(470,360) )
84 wxMenu
*file_menu
= new wxMenu();
85 file_menu
->Append( ID_ABOUT
, "&About...");
86 file_menu
->AppendSeparator();
87 file_menu
->Append( ID_QUIT
, "E&xit");
89 wxMenuBar
*menu_bar
= new wxMenuBar();
90 menu_bar
->Append(file_menu
, "&File");
92 SetMenuBar( menu_bar
);
95 int widths
[] = { -1, 100 };
96 SetStatusWidths( 2, widths
);
98 m_canvas
= new wxCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
100 m_canvas
->SetArea( 400, 600 );
102 wxBitmap
bitmap( smile_xpm
);
103 wxImage
image( bitmap
);
104 m_co
= new wxCanvasImage( image
, 10, 50 );
105 m_canvas
->Append( m_co
);
107 m_canvas
->Append( new wxCanvasImage( image
, 80, 50 ) );
109 wxButton
*button
= new wxButton( m_canvas
, -1, "Hello", wxPoint(130,50) );
110 m_canvas
->Append( new wxCanvasControl( button
) );
112 m_canvas
->Append( new wxCanvasText( "Hello", 180, 50 ) );
114 m_timer
= new wxTimer( this );
115 m_timer
->Start( 100, FALSE
);
123 void MyFrame::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
128 void MyFrame::OnTimer( wxTimerEvent
&WXUNUSED(event
) )
130 m_co
->Move( m_co
->GetX()+1, m_co
->GetY() );
134 void MyFrame::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
136 (void)wxMessageBox( "wxCanvas demo\n"
137 "Robert Roebling (c) 1998,2000",
138 "About wxCanvas Demo", wxICON_INFORMATION
| wxOK
);
141 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------
148 wxImage::AddHandler( new wxPNGHandler
);
151 wxFrame
*frame
= new MyFrame();