MyImageFrame(wxFrame *parent, const wxBitmap& bitmap)
: wxFrame(parent, -1, _T("Frame with image"),
wxDefaultPosition, wxDefaultSize,
- wxCAPTION),
+ wxCAPTION | wxSYSTEM_MENU),
m_bitmap(bitmap)
{
SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());
#if wxUSE_LIBPNG
if ( !image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ))
wxLogError("Can't save file");
-
+
image.Destroy();
image.LoadFile( dir + wxString("test.png") );
my_square = new wxBitmap( image.ConvertToBitmap() );
-
+
image.Destroy();
if ( !image.LoadFile( dir + wxString("horse.png")) )
wxPoint(20,20), wxSize(470,360) )
{
wxMenu *file_menu = new wxMenu();
- file_menu->Append( ID_NEW, "&New frame");
+ file_menu->Append( ID_NEW, "&Show image...");
file_menu->AppendSeparator();
file_menu->Append( ID_ABOUT, "&About...");
file_menu->AppendSeparator();
void MyFrame::OnNewFrame( wxCommandEvent &WXUNUSED(event) )
{
- (new MyImageFrame(this, *m_canvas->my_horse_bmp))->Show();
+ wxString filename = wxFileSelector(_T("Select image file"));
+ if ( !filename )
+ return;
+
+ wxImage image;
+ if ( !image.LoadFile(filename) )
+ {
+ wxLogError(_T("Couldn't load image from '%s'."), filename.c_str());
+
+ return;
+ }
+
+ (new MyImageFrame(this, image.ConvertToBitmap()))->Show();
}
//-----------------------------------------------------------------------------