2 #include <wx/image.h> |
2 #include <wx/image.h> |
3 #include <wx/bitmap.h> |
3 #include <wx/bitmap.h> |
4 #include <wx/dc.h> |
4 #include <wx/dc.h> |
5 #include <iostream> |
5 #include <iostream> |
6 #include "wxPictureWindow.hpp" |
6 #include "wxPictureWindow.hpp" |
|
7 #include "MainWindow.hpp" |
7 |
8 |
8 const int factor = 3; |
9 const int factor = 3; |
9 |
10 |
10 BEGIN_EVENT_TABLE(wxPictureWindow, wxScrolledWindow) |
11 BEGIN_EVENT_TABLE(wxPictureWindow, wxScrolledWindow) |
11 EVT_MOUSE_EVENTS (wxPictureWindow::OnMouse) |
12 EVT_MOUSE_EVENTS (wxPictureWindow::OnMouse) |
|
13 EVT_KEY_UP (wxPictureWindow::OnKey) |
12 END_EVENT_TABLE() |
14 END_EVENT_TABLE() |
13 |
15 |
14 wxPictureWindow::wxPictureWindow(const wxImage &img, const CropArea area, wxWindow *parent) |
16 wxPictureWindow::wxPictureWindow(const wxImage &img, const CropArea area, wxWindow *parent) |
15 :wxScrolledWindow(parent, wxID_ANY), |
17 :wxScrolledWindow(parent, wxID_ANY), |
16 _bmp(wxBitmap(img)), |
|
17 _area(area) |
18 _area(area) |
18 { |
19 { |
19 SetVirtualSize(_bmp.GetWidth(), _bmp.GetHeight()); |
20 SetImg(img); |
20 SetScrollRate(10, 10); |
|
21 _area.x /= factor; |
21 _area.x /= factor; |
22 _area.y /= factor; |
22 _area.y /= factor; |
23 _area.width /= factor; |
23 _area.width /= factor; |
24 _area.height /= factor; |
24 _area.height /= factor; |
|
25 SetScrollRate(10, 10); |
|
26 SetFocus(); |
|
27 } |
|
28 |
|
29 void |
|
30 wxPictureWindow::SetImg(const wxImage &img) |
|
31 { |
|
32 SetVirtualSize(_bmp.GetWidth(), _bmp.GetHeight()); |
|
33 _bmp = wxBitmap(img); |
25 } |
34 } |
26 |
35 |
27 void wxPictureWindow::OnDraw(wxDC &dc) |
36 void wxPictureWindow::OnDraw(wxDC &dc) |
28 { |
37 { |
29 dc.DrawBitmap(_bmp, 0, 0, false); |
38 dc.DrawBitmap(_bmp, 0, 0, false); |
60 std::cout << _area.x * factor << " "; |
69 std::cout << _area.x * factor << " "; |
61 std::cout << _area.y * factor << " "; |
70 std::cout << _area.y * factor << " "; |
62 std::cout << _area.width * factor << " "; |
71 std::cout << _area.width * factor << " "; |
63 std::cout << _area.height * factor << std::endl; |
72 std::cout << _area.height * factor << std::endl; |
64 } |
73 } |
|
74 |
|
75 void |
|
76 wxPictureWindow::OnKey(wxKeyEvent &e) |
|
77 { |
|
78 using namespace std; |
|
79 if (e.GetKeyCode() == WXK_ESCAPE) |
|
80 { |
|
81 cout << "escape" << endl;; |
|
82 wxCommandEvent e(EVT_NEXTPICTURE); |
|
83 GetParent()->AddPendingEvent(e); |
|
84 } |
|
85 else |
|
86 e.Skip(); |
|
87 } |