--- a/wxPictureWindow.cpp Sat Nov 01 20:57:17 2008 +0100
+++ b/wxPictureWindow.cpp Sun Apr 24 14:03:52 2011 +0200
@@ -4,24 +4,33 @@
#include <wx/dc.h>
#include <iostream>
#include "wxPictureWindow.hpp"
+#include "MainWindow.hpp"
const int factor = 3;
BEGIN_EVENT_TABLE(wxPictureWindow, wxScrolledWindow)
EVT_MOUSE_EVENTS (wxPictureWindow::OnMouse)
+ EVT_KEY_UP (wxPictureWindow::OnKey)
END_EVENT_TABLE()
wxPictureWindow::wxPictureWindow(const wxImage &img, const CropArea area, wxWindow *parent)
:wxScrolledWindow(parent, wxID_ANY),
- _bmp(wxBitmap(img)),
_area(area)
{
- SetVirtualSize(_bmp.GetWidth(), _bmp.GetHeight());
- SetScrollRate(10, 10);
+ SetImg(img);
_area.x /= factor;
_area.y /= factor;
_area.width /= factor;
_area.height /= factor;
+ SetScrollRate(10, 10);
+ SetFocus();
+}
+
+void
+wxPictureWindow::SetImg(const wxImage &img)
+{
+ SetVirtualSize(_bmp.GetWidth(), _bmp.GetHeight());
+ _bmp = wxBitmap(img);
}
void wxPictureWindow::OnDraw(wxDC &dc)
@@ -62,3 +71,17 @@
std::cout << _area.width * factor << " ";
std::cout << _area.height * factor << std::endl;
}
+
+void
+wxPictureWindow::OnKey(wxKeyEvent &e)
+{
+ using namespace std;
+ if (e.GetKeyCode() == WXK_ESCAPE)
+ {
+ cout << "escape" << endl;;
+ wxCommandEvent e(EVT_NEXTPICTURE);
+ GetParent()->AddPendingEvent(e);
+ }
+ else
+ e.Skip();
+}