added possibility to view arbitrary images
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -84,7 +84,7 @@ public:
|
|||||||
MyImageFrame(wxFrame *parent, const wxBitmap& bitmap)
|
MyImageFrame(wxFrame *parent, const wxBitmap& bitmap)
|
||||||
: wxFrame(parent, -1, _T("Frame with image"),
|
: wxFrame(parent, -1, _T("Frame with image"),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxCAPTION),
|
wxCAPTION | wxSYSTEM_MENU),
|
||||||
m_bitmap(bitmap)
|
m_bitmap(bitmap)
|
||||||
{
|
{
|
||||||
SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());
|
SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());
|
||||||
@@ -458,7 +458,7 @@ 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->Append( ID_NEW, "&Show image...");
|
||||||
file_menu->AppendSeparator();
|
file_menu->AppendSeparator();
|
||||||
file_menu->Append( ID_ABOUT, "&About...");
|
file_menu->Append( ID_ABOUT, "&About...");
|
||||||
file_menu->AppendSeparator();
|
file_menu->AppendSeparator();
|
||||||
@@ -493,7 +493,19 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
|
|||||||
|
|
||||||
void MyFrame::OnNewFrame( wxCommandEvent &WXUNUSED(event) )
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user