]>
git.saurik.com Git - wxWidgets.git/blob - samples/image/image.cpp
4 * Author: Robert Roebling
6 * Copyright: (C) 1998, Robert Roebling
20 class MyCanvas
: public wxScrolledWindow
22 DECLARE_DYNAMIC_CLASS(MyCanvas
)
27 MyCanvas( wxWindow
*parent
, wxWindowID
, const wxPoint
&pos
, const wxSize
&size
);
29 void OnPaint( wxPaintEvent
&event
);
38 class MyFrame
: public wxFrame
40 DECLARE_DYNAMIC_CLASS(MyFrame
)
45 void OnSize( wxSizeEvent
&event
);
46 void OnAbout( wxCommandEvent
&event
);
47 void OnQuit( wxCommandEvent
&event
);
56 class MyApp
: public wxApp
61 virtual bool OnInit(void);
70 IMPLEMENT_DYNAMIC_CLASS(MyCanvas
, wxScrolledWindow
)
72 BEGIN_EVENT_TABLE(MyCanvas
,wxScrolledWindow
)
73 EVT_PAINT (MyCanvas::OnPaint
)
76 MyCanvas::MyCanvas( wxWindow
*parent
, const wxWindowID id
, const wxPoint
&pos
, const wxSize
&size
)
77 : wxScrolledWindow( parent
, id
, pos
, size
, wxSUNKEN_BORDER
)
80 image
.LoadFile( "../horse.png", wxBITMAP_TYPE_PNG
);
81 my_horse
= new wxBitmap( image
);
84 MyCanvas::~MyCanvas(void)
89 void MyCanvas::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
94 dc
.DrawBitmap( *my_horse
, 30, 120 );
100 const ID_ABOUT
= 109;
102 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
104 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
105 EVT_MENU (ID_ABOUT
, MyFrame::OnAbout
)
106 EVT_MENU (ID_QUIT
, MyFrame::OnQuit
)
109 MyFrame::MyFrame(void) :
110 wxFrame( (wxFrame
*) NULL
, -1, (char *) "Robert's Test application", wxPoint(20,20), wxSize(470,360) )
112 wxMenu
*file_menu
= new wxMenu();
113 file_menu
->Append( ID_ABOUT
, "About..");
114 file_menu
->Append( ID_QUIT
, "Exit");
116 wxMenuBar
*menu_bar
= new wxMenuBar();
117 menu_bar
->Append(file_menu
, "File");
118 menu_bar
->Show( TRUE
);
120 SetMenuBar( menu_bar
);
122 m_canvas
= new MyCanvas( this, -1, wxPoint(2,62), wxSize(300-4,120-4) );
123 m_canvas
->SetScrollbars( 10, 10, 50, 50 );
126 void MyFrame::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
131 void MyFrame::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
133 (void) wxMessageBox( "Image demo\nRobert Roebling (c) 1998", "About Image Demo", wxOK
);
136 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------
145 bool MyApp::OnInit(void)
147 wxImage::AddHandler( new wxPNGHandler
);
149 wxFrame
*frame
= new MyFrame();