]>
git.saurik.com Git - wxWidgets.git/blob - samples/scroll/scroll.cpp
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
| wxTAB_TRAVERSAL
)
83 SetBackgroundColour( *wxWHITE
);
85 (void) new wxButton( this, -1, "wxButton", wxPoint(10,10) );
87 (void) new wxTextCtrl( this, -1, "wxTextCtrl", wxPoint(10,50) );
89 (void) new wxRadioButton( this, -1, "Disable", wxPoint(10,90) );
100 (void) new wxComboBox( this, -1, "This", wxPoint(10,130), wxDefaultSize
, 5, choices
);
102 (void) new wxRadioBox( this, -1, "This", wxPoint(10,200), wxDefaultSize
, 5, choices
);
105 MyCanvas::~MyCanvas()
109 void MyCanvas::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
113 wxPaintDC
dc( this );
116 dc
.DrawText( "Some text", 10, 10 );
118 dc
.DrawRectangle( 50, 30, 200, 200 );
123 const int ID_QUIT
= 108;
124 const int ID_ABOUT
= 109;
126 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
128 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
129 EVT_MENU (ID_ABOUT
, MyFrame::OnAbout
)
130 EVT_MENU (ID_QUIT
, MyFrame::OnQuit
)
134 : wxFrame( (wxFrame
*)NULL
, -1, "wxScrolledWindow sample",
135 wxPoint(20,20), wxSize(470,360) )
137 wxMenu
*file_menu
= new wxMenu();
138 file_menu
->Append( ID_ABOUT
, "&About..");
139 file_menu
->Append( ID_QUIT
, "E&xit\tAlt-X");
141 wxMenuBar
*menu_bar
= new wxMenuBar();
142 menu_bar
->Append(file_menu
, "&File");
144 SetMenuBar( menu_bar
);
147 int widths
[] = { -1, 100 };
148 SetStatusWidths( 2, widths
);
150 m_canvas
= new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
151 m_canvas
->SetScrollbars( 10, 10, 50, 100 );
154 void MyFrame::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
159 void MyFrame::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
161 (void)wxMessageBox( "wxScroll demo\n"
162 "Robert Roebling (c) 1998",
163 "About wxScroll Demo", wxICON_INFORMATION
| wxOK
);
166 //-----------------------------------------------------------------------------
168 //-----------------------------------------------------------------------------
172 wxFrame
*frame
= new MyFrame();