Embed the image into the event sample

Don't load it from the image sample directory, this doesn't necessarily
work under Unix if the image sample hadn't been built.

Just embed an XPM image directly into the sample, this is good enough
for demonstration purposes.
This commit is contained in:
Vadim Zeitlin
2017-11-22 03:03:48 +01:00
parent 020c598c18
commit 7535854ec4
2 changed files with 6 additions and 13 deletions

View File

@@ -298,8 +298,6 @@ bool MyApp::OnInit()
if ( !wxApp::OnInit() ) if ( !wxApp::OnInit() )
return false; return false;
wxImage::AddHandler(new wxJPEGHandler);
// create the main application window // create the main application window
MyFrame *frame = new MyFrame(wxT("Event wxWidgets Sample"), MyFrame *frame = new MyFrame(wxT("Event wxWidgets Sample"),
wxPoint(50, 50), wxSize(600, 340)); wxPoint(50, 50), wxSize(600, 340));

View File

@@ -1,6 +1,8 @@
#include "gestures.h" #include "gestures.h"
#include "wx/dcgraph.h" #include "wx/dcgraph.h"
#include "../image/horse.xpm"
MyGestureFrame::MyGestureFrame() MyGestureFrame::MyGestureFrame()
: wxFrame(NULL, wxID_ANY, "Multi-touch Gestures", wxDefaultPosition, wxSize(800, 600)) : wxFrame(NULL, wxID_ANY, "Multi-touch Gestures", wxDefaultPosition, wxSize(800, 600))
{ {
@@ -30,18 +32,11 @@ MyGestureFrame::MyGestureFrame()
Bind(wxEVT_CLOSE_WINDOW, &MyGestureFrame::OnQuit, this); Bind(wxEVT_CLOSE_WINDOW, &MyGestureFrame::OnQuit, this);
} }
MyGesturePanel::MyGesturePanel(MyGestureFrame *parent) : wxPanel(parent, wxID_ANY) MyGesturePanel::MyGesturePanel(MyGestureFrame *parent)
: wxPanel(parent, wxID_ANY),
m_bitmap(horse_xpm)
{ {
// Load an image Bind(wxEVT_PAINT, &MyGesturePanel::OnPaint, this);
if ( !m_bitmap.LoadFile("../image/horse.jpg", wxBITMAP_TYPE_JPEG) )
{
wxLogError("Can't load the image");
}
else
{
Bind(wxEVT_PAINT, &MyGesturePanel::OnPaint, this);
}
if ( !EnableTouchEvents(wxTOUCH_ALL_GESTURES) ) if ( !EnableTouchEvents(wxTOUCH_ALL_GESTURES) )
{ {