From 7535854ec40d94723aa5f4b9fb0210a56629a46f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 22 Nov 2017 03:03:48 +0100 Subject: [PATCH] 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. --- samples/event/event.cpp | 2 -- samples/event/gestures.cpp | 17 ++++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/samples/event/event.cpp b/samples/event/event.cpp index b397f828aa..7e1af4cf80 100644 --- a/samples/event/event.cpp +++ b/samples/event/event.cpp @@ -298,8 +298,6 @@ bool MyApp::OnInit() if ( !wxApp::OnInit() ) return false; - wxImage::AddHandler(new wxJPEGHandler); - // create the main application window MyFrame *frame = new MyFrame(wxT("Event wxWidgets Sample"), wxPoint(50, 50), wxSize(600, 340)); diff --git a/samples/event/gestures.cpp b/samples/event/gestures.cpp index 06b6cd794a..f28c53dc89 100644 --- a/samples/event/gestures.cpp +++ b/samples/event/gestures.cpp @@ -1,6 +1,8 @@ #include "gestures.h" #include "wx/dcgraph.h" +#include "../image/horse.xpm" + MyGestureFrame::MyGestureFrame() : wxFrame(NULL, wxID_ANY, "Multi-touch Gestures", wxDefaultPosition, wxSize(800, 600)) { @@ -30,18 +32,11 @@ MyGestureFrame::MyGestureFrame() 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 - if ( !m_bitmap.LoadFile("../image/horse.jpg", wxBITMAP_TYPE_JPEG) ) - { - wxLogError("Can't load the image"); - } - - else - { - Bind(wxEVT_PAINT, &MyGesturePanel::OnPaint, this); - } + Bind(wxEVT_PAINT, &MyGesturePanel::OnPaint, this); if ( !EnableTouchEvents(wxTOUCH_ALL_GESTURES) ) {