4 * Author: Robert Roebling
6 * Copyright: (C) 1998, Robert Roebling
10 // For compilers that support precompilation, includes "wx/wx.h".
11 #include "wx/wxprec.h"
30 class MyCanvas
: public wxScrolledWindow
34 MyCanvas( wxWindow
*parent
, wxWindowID
, const wxPoint
&pos
, const wxSize
&size
);
36 void OnPaint( wxPaintEvent
&event
);
38 DECLARE_DYNAMIC_CLASS(MyCanvas
)
44 class MyFrame
: public wxFrame
49 void OnAbout( wxCommandEvent
&event
);
50 void OnQuit( wxCommandEvent
&event
);
54 DECLARE_DYNAMIC_CLASS(MyFrame
)
60 class MyApp
: public wxApp
63 virtual bool OnInit();
72 IMPLEMENT_DYNAMIC_CLASS(MyCanvas
, wxScrolledWindow
)
74 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
75 EVT_PAINT(MyCanvas
::OnPaint
)
78 MyCanvas
::MyCanvas( wxWindow
*parent
, wxWindowID id
,
79 const wxPoint
&pos
, const wxSize
&size
)
80 : wxScrolledWindow( parent
, id
, pos
, size
, wxSUNKEN_BORDER
)
82 (void) new wxButton( this, -1, "wxButton", wxPoint(10,10) );
84 (void) new wxTextCtrl( this, -1, "wxTextCtrl", wxPoint(10,50) );
86 (void) new wxCheckBox( this, -1, "Disable", wxPoint(10,90) );
97 (void) new wxComboBox( this, -1, "This", wxPoint(10,130), wxDefaultSize
, 5, choices
);
99 (void) new wxRadioBox( this, -1, "This", wxPoint(10,200), wxDefaultSize
, 5, choices
);
102 MyCanvas
::~MyCanvas()
106 void MyCanvas
::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
108 wxPaintDC
dc( this );
111 dc
.DrawText( "Some text", 10, 10 );
113 dc
.DrawRectangle( 50, 30, 200, 200 );
118 const int ID_QUIT
= 108;
119 const int ID_ABOUT
= 109;
121 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
123 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
124 EVT_MENU (ID_ABOUT
, MyFrame
::OnAbout
)
125 EVT_MENU (ID_QUIT
, MyFrame
::OnQuit
)
129 : wxFrame( (wxFrame
*)NULL
, -1, "wxScrolledWindow sample",
130 wxPoint(20,20), wxSize(470,360) )
132 wxMenu
*file_menu
= new wxMenu();
133 file_menu
->Append( ID_ABOUT
, "&About..");
134 file_menu
->Append( ID_QUIT
, "E&xit\tAlt-X");
136 wxMenuBar
*menu_bar
= new wxMenuBar();
137 menu_bar
->Append(file_menu
, "&File");
139 SetMenuBar( menu_bar
);
142 int widths
[] = { -1, 100 };
143 SetStatusWidths( 2, widths
);
145 m_canvas
= new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
146 m_canvas
->SetScrollbars( 10, 10, 50, 100 );
149 void MyFrame
::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
154 void MyFrame
::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
156 (void)wxMessageBox( "wxScroll demo\n"
157 "Robert Roebling (c) 1998",
158 "About wxScroll Demo", wxICON_INFORMATION
| wxOK
);
161 //-----------------------------------------------------------------------------
163 //-----------------------------------------------------------------------------
167 wxFrame
*frame
= new MyFrame();