+const long ID_QUIT = wxID_EXIT;
+const long ID_ABOUT = wxID_ABOUT;
+const long ID_DELETE_ALL = 100;
+const long ID_INSERT_NEW = 101;
+
+// ----------------------------------------------------------------------
+// a trivial example
+// ----------------------------------------------------------------------
+
+// MySimpleCanvas: a scrolled window which draws a simple rectangle
+class MySimpleCanvas: public wxScrolledWindow
+{
+public:
+ MySimpleCanvas() { }
+ MySimpleCanvas(wxWindow *parent);
+
+private:
+ void OnPaint(wxPaintEvent& event);
+
+ enum
+ {
+ CANVAS_WIDTH = 292,
+ CANVAS_HEIGHT = 297
+ };
+
+ DECLARE_DYNAMIC_CLASS(MyCanvas)
+ DECLARE_EVENT_TABLE()
+};
+
+IMPLEMENT_DYNAMIC_CLASS(MySimpleCanvas, wxScrolledWindow)
+
+BEGIN_EVENT_TABLE(MySimpleCanvas, wxScrolledWindow)
+ EVT_PAINT( MySimpleCanvas::OnPaint)
+END_EVENT_TABLE()
+
+MySimpleCanvas::MySimpleCanvas(wxWindow *parent)
+ : wxScrolledWindow(parent, wxID_ANY,
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxSUNKEN_BORDER)
+{
+ SetScrollRate( 10, 10 );
+ SetVirtualSize( CANVAS_WIDTH, CANVAS_HEIGHT );
+ SetBackgroundColour( *wxWHITE );
+}
+
+void MySimpleCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+ wxPaintDC dc(this);
+ PrepareDC( dc );
+
+ dc.SetPen( *wxRED_PEN );
+ dc.SetBrush( *wxTRANSPARENT_BRUSH );
+ dc.DrawRectangle( 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT );
+}
+
+// MySimpleFrame: a frame which contains a MySimpleCanvas
+class MySimpleFrame: public wxFrame
+{
+public:
+ MySimpleFrame();
+
+private:
+ void OnClose(wxCommandEvent& WXUNUSED(event)) { Close(true); }
+
+ DECLARE_DYNAMIC_CLASS(MySimpleFrame)
+ DECLARE_EVENT_TABLE()
+};
+
+
+IMPLEMENT_DYNAMIC_CLASS( MySimpleFrame, wxFrame )
+
+BEGIN_EVENT_TABLE(MySimpleFrame,wxFrame)
+ EVT_MENU(wxID_CLOSE, MySimpleFrame::OnClose)
+END_EVENT_TABLE()
+
+MySimpleFrame::MySimpleFrame()
+ : wxFrame(NULL, wxID_ANY, _T("wxScrolledWindow sample"),
+ wxDefaultPosition, wxSize(200, 200))
+{
+ wxMenu *file_menu = new wxMenu();
+ file_menu->Append(wxID_CLOSE);
+
+ wxMenuBar *menu_bar = new wxMenuBar();
+ menu_bar->Append(file_menu, _T("&File"));
+
+ SetMenuBar( menu_bar );
+
+ new MySimpleCanvas(this);
+}
+
+// ----------------------------------------------------------------------
+// a complex example
+// ----------------------------------------------------------------------