]>
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"
22 #include "wx/listctrl.h"
31 class MyCanvas
: public wxScrolledWindow
35 MyCanvas( wxWindow
*parent
, wxWindowID
, const wxPoint
&pos
, const wxSize
&size
);
37 void OnPaint( wxPaintEvent
&event
);
39 DECLARE_DYNAMIC_CLASS(MyCanvas
)
45 class MyFrame
: public wxFrame
50 void OnAbout( wxCommandEvent
&event
);
51 void OnQuit( wxCommandEvent
&event
);
55 DECLARE_DYNAMIC_CLASS(MyFrame
)
61 class MyApp
: public wxApp
64 virtual bool OnInit();
73 IMPLEMENT_DYNAMIC_CLASS(MyCanvas
, wxScrolledWindow
)
75 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
76 // EVT_PAINT(MyCanvas::OnPaint)
79 MyCanvas::MyCanvas( wxWindow
*parent
, wxWindowID id
,
80 const wxPoint
&pos
, const wxSize
&size
)
81 : wxScrolledWindow( parent
, id
, pos
, size
, wxSUNKEN_BORDER
| wxTAB_TRAVERSAL
, "test canvas" )
92 (void) new wxButton( this, -1, "wxButton", wxPoint(10,10) );
94 (void) new wxTextCtrl( this, -1, "wxTextCtrl", wxPoint(10,50) );
96 (void) new wxRadioButton( this, -1, "Disable", wxPoint(10,90) );
98 (void) new wxComboBox( this, -1, "This", wxPoint(10,130), wxDefaultSize
, 5, choices
);
100 (void) new wxRadioBox( this, -1, "This", wxPoint(10,200), wxDefaultSize
, 5, choices
, 2, wxRA_SPECIFY_COLS
);
102 (void) new wxRadioBox( this, -1, "This", wxPoint(10,300), wxDefaultSize
, 5, choices
, 2, wxRA_SPECIFY_ROWS
);
104 wxListCtrl
*m_listCtrl
= new wxListCtrl(
105 this, -1, wxPoint(200, 10), wxSize(180, 120),
106 wxLC_REPORT
| wxSIMPLE_BORDER
| wxLC_SINGLE_SEL
);
108 m_listCtrl
->InsertColumn(0, "First", wxLIST_FORMAT_LEFT
, 90);
109 m_listCtrl
->InsertColumn(1, "Last", wxLIST_FORMAT_LEFT
, 90);
111 for ( int i
=0; i
< 30; i
++)
114 sprintf(buf
, "Item %d", i
);
115 m_listCtrl
->InsertItem(i
, buf
);
117 m_listCtrl
->SetItemState( 3, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
119 (void) new wxListBox( this, -1, wxPoint(200,180), wxSize(180,120), 5, choices
, wxLB_ALWAYS_SB
);
121 wxWindow
*test
= new wxWindow( this, -1, wxPoint(10, 400), wxSize(130,120), wxSIMPLE_BORDER
| wxTAB_TRAVERSAL
);
122 test
->SetBackgroundColour( "WHEAT" );
123 wxButton
*test2
= new wxButton( test
, -1, "Hallo", wxPoint(10,10) );
125 test
= new wxWindow( this, -1, wxPoint(160, 400), wxSize(130,120), wxSUNKEN_BORDER
| wxTAB_TRAVERSAL
);
126 test
->SetBackgroundColour( "WHEAT" );
127 test
->SetCursor( wxCursor( wxCURSOR_NO_ENTRY
) );
128 test2
= new wxButton( test
, -1, "Hallo", wxPoint(10,10) );
129 test2
->SetCursor( wxCursor( wxCURSOR_PENCIL
) );
131 test
= new wxWindow( this, -1, wxPoint(310, 400), wxSize(130,120), wxRAISED_BORDER
| wxTAB_TRAVERSAL
);
132 test
->SetBackgroundColour( "WHEAT" );
133 test
->SetCursor( wxCursor( wxCURSOR_PENCIL
) );
134 test2
= new wxButton( test
, -1, "Hallo", wxPoint(10,10) );
135 test2
->SetCursor( wxCursor( wxCURSOR_NO_ENTRY
) );
137 SetBackgroundColour( "WHEAT" );
139 SetCursor( wxCursor( wxCURSOR_IBEAM
) );
142 MyCanvas::~MyCanvas()
146 void MyCanvas::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
148 wxPaintDC
dc( this );
151 dc
.DrawText( "Some text", 110, 10 );
153 dc
.DrawRectangle( 50, 30, 200, 200 );
158 const int ID_QUIT
= 108;
159 const int ID_ABOUT
= 109;
161 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
163 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
164 EVT_MENU (ID_ABOUT
, MyFrame::OnAbout
)
165 EVT_MENU (ID_QUIT
, MyFrame::OnQuit
)
169 : wxFrame( (wxFrame
*)NULL
, -1, "wxScrolledWindow sample",
170 wxPoint(20,20), wxSize(470,360) )
172 wxMenu
*file_menu
= new wxMenu();
173 file_menu
->Append( ID_ABOUT
, "&About..");
174 file_menu
->Append( ID_QUIT
, "E&xit\tAlt-X");
176 wxMenuBar
*menu_bar
= new wxMenuBar();
177 menu_bar
->Append(file_menu
, "&File");
179 SetMenuBar( menu_bar
);
182 int widths
[] = { -1, 100 };
183 SetStatusWidths( 2, widths
);
185 m_canvas
= new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
186 m_canvas
->SetScrollbars( 10, 10, 50, 100 );
189 void MyFrame::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
194 void MyFrame::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
196 (void)wxMessageBox( "wxScroll demo\n"
197 "Robert Roebling (c) 1998",
198 "About wxScroll Demo", wxICON_INFORMATION
| wxOK
);
201 //-----------------------------------------------------------------------------
203 //-----------------------------------------------------------------------------
207 wxFrame
*frame
= new MyFrame();