added test for bug #38

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6764 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-03-16 17:57:19 +00:00
parent 4e0dcbb14a
commit ab0f03868e

View File

@@ -68,6 +68,7 @@ public:
MyFrame(); MyFrame();
void OnAbout( wxCommandEvent &event ); void OnAbout( wxCommandEvent &event );
void OnNewFrame( wxCommandEvent &event );
void OnQuit( wxCommandEvent &event ); void OnQuit( wxCommandEvent &event );
MyCanvas *m_canvas; MyCanvas *m_canvas;
@@ -77,6 +78,30 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
class MyImageFrame : public wxFrame
{
public:
MyImageFrame(wxFrame *parent, const wxBitmap& bitmap)
: wxFrame(parent, -1, _T("Frame with image"),
wxDefaultPosition, wxDefaultSize,
wxCAPTION),
m_bitmap(bitmap)
{
SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());
}
void OnPaint(wxPaintEvent& WXUNUSED(event))
{
wxPaintDC dc( this );
dc.DrawBitmap( m_bitmap, 0, 0 );
}
private:
wxBitmap m_bitmap;
DECLARE_EVENT_TABLE()
};
// MyApp // MyApp
class MyApp: public wxApp class MyApp: public wxApp
@@ -93,6 +118,10 @@ IMPLEMENT_APP(MyApp)
IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow) IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow)
BEGIN_EVENT_TABLE(MyImageFrame, wxFrame)
EVT_PAINT(MyImageFrame::OnPaint)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_PAINT(MyCanvas::OnPaint) EVT_PAINT(MyCanvas::OnPaint)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -414,12 +443,14 @@ void MyCanvas::CreateAntiAliasedBitmap()
const int ID_QUIT = 108; const int ID_QUIT = 108;
const int ID_ABOUT = 109; const int ID_ABOUT = 109;
const int ID_NEW = 110;
IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame ) IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
BEGIN_EVENT_TABLE(MyFrame,wxFrame) BEGIN_EVENT_TABLE(MyFrame,wxFrame)
EVT_MENU (ID_ABOUT, MyFrame::OnAbout) EVT_MENU (ID_ABOUT, MyFrame::OnAbout)
EVT_MENU (ID_QUIT, MyFrame::OnQuit) EVT_MENU (ID_QUIT, MyFrame::OnQuit)
EVT_MENU (ID_NEW, MyFrame::OnNewFrame)
END_EVENT_TABLE() END_EVENT_TABLE()
MyFrame::MyFrame() MyFrame::MyFrame()
@@ -427,7 +458,10 @@ MyFrame::MyFrame()
wxPoint(20,20), wxSize(470,360) ) wxPoint(20,20), wxSize(470,360) )
{ {
wxMenu *file_menu = new wxMenu(); wxMenu *file_menu = new wxMenu();
file_menu->Append( ID_NEW, "&New frame");
file_menu->AppendSeparator();
file_menu->Append( ID_ABOUT, "&About..."); file_menu->Append( ID_ABOUT, "&About...");
file_menu->AppendSeparator();
file_menu->Append( ID_QUIT, "E&xit"); file_menu->Append( ID_QUIT, "E&xit");
wxMenuBar *menu_bar = new wxMenuBar(); wxMenuBar *menu_bar = new wxMenuBar();
@@ -457,6 +491,11 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
"About wxImage Demo", wxICON_INFORMATION | wxOK ); "About wxImage Demo", wxICON_INFORMATION | wxOK );
} }
void MyFrame::OnNewFrame( wxCommandEvent &WXUNUSED(event) )
{
(new MyImageFrame(this, *m_canvas->my_horse_bmp))->Show();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// MyApp // MyApp
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------