fszontagh
2024-02-25 5d543bcc0d15b871315a2123aec01041d73c53fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
 
#include "ImageViewer.h"
 
#include "../res/add_image.png.h"
#include "../res/fullscreen.png.h"
#include "../res/reset_zoom.png.h"
#include "../res/rotate_left.png.h"
#include "../res/rotate_right.png.h"
#include "../res/zoom_in.png.h"
#include "../res/zoom_out.png.h"
 
// Using the construction of a static object to ensure that the help provider is set
// wx Manages the most recent HelpProvider passed to ::Set, but not the previous ones
// If ::Set gets called more than once, the previous one is returned and should be deleted
class wxFBContextSensitiveHelpSetter
{
public:
wxFBContextSensitiveHelpSetter()
{
wxSimpleHelpProvider* help = new wxSimpleHelpProvider();
wxHelpProvider* old = wxHelpProvider::Set( help );
if (old != 0){
delete old;
}
}
};
 
static wxFBContextSensitiveHelpSetter s_wxFBSetTheHelpProvider;
///////////////////////////////////////////////////////////////////////////
 
ImageWindow::ImageWindow( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
    this->SetSizeHints( wxDefaultSize, wxDefaultSize );
    this->SetBackgroundColour( wxColour( 60, 60, 60 ) );
    this->DragAcceptFiles( true );
 
    wxBoxSizer* bSizer1;
    bSizer1 = new wxBoxSizer( wxVERTICAL );
 
    wxBoxSizer* bSizer6;
    bSizer6 = new wxBoxSizer( wxHORIZONTAL );
 
    m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
    m_scrolledWindow1->SetScrollRate( 5, 5 );
    wxBoxSizer* bSizer3;
    bSizer3 = new wxBoxSizer( wxVERTICAL );
 
    m_bitmap1 = new wxStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
    bSizer3->Add( m_bitmap1, 1, wxEXPAND, 5 );
 
 
    m_scrolledWindow1->SetSizer( bSizer3 );
    m_scrolledWindow1->Layout();
    bSizer3->Fit( m_scrolledWindow1 );
    bSizer6->Add( m_scrolledWindow1, 1, wxEXPAND, 5 );
 
    m_scrolledWindow3 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxHSCROLL|wxVSCROLL );
    m_scrolledWindow3->SetScrollRate( 5, 5 );
    m_scrolledWindow3->SetMinSize( wxSize( 100,-1 ) );
 
    wxBoxSizer* bSizer7;
    bSizer7 = new wxBoxSizer( wxVERTICAL );
 
    m_details = new wxListCtrl( m_scrolledWindow3, wxID_ANY, wxDefaultPosition, wxSize( 100,-1 ), wxLC_SINGLE_SEL );
    bSizer7->Add( m_details, 1, wxEXPAND, 5 );
 
 
    m_scrolledWindow3->SetSizer( bSizer7 );
    m_scrolledWindow3->Layout();
    bSizer7->Fit( m_scrolledWindow3 );
    bSizer6->Add( m_scrolledWindow3, 0, wxEXPAND, 5 );
 
 
    bSizer1->Add( bSizer6, 1, wxEXPAND, 5 );
 
    wxBoxSizer* bSizer5;
    bSizer5 = new wxBoxSizer( wxVERTICAL );
 
    bSizer5->SetMinSize( wxSize( -1,100 ) );
    m_image_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( -1,140 ), wxLC_ICON );
    bSizer5->Add( m_image_list, 1, wxEXPAND, 5 );
 
 
    bSizer1->Add( bSizer5, 0, wxEXPAND, 5 );
 
 
    this->SetSizer( bSizer1 );
    this->Layout();
    m_statusBar1 = this->CreateStatusBar( 1, wxSTB_SIZEGRIP, wxID_ANY );
    m_toolBar1 = this->CreateToolBar( wxTB_DOCKABLE|wxTB_HORIZONTAL, wxID_ANY );
    m_open_image = m_toolBar1->AddTool( wxID_ANY, _("Open image"), add_image_png_to_wx_bitmap(), wxNullBitmap, wxITEM_NORMAL, _("Open an image (jpeg,png)"), _("Open a supported image file. (png, jpeg)"), NULL );
 
    m_toolBar1->AddSeparator();
 
    m_rotate_left = m_toolBar1->AddTool( wxID_ANY, _("Rotate -90"), rotate_left_png_to_wx_bitmap(), wxNullBitmap, wxITEM_NORMAL, _("Rotate the image -90°"), wxEmptyString, NULL );
 
    m_rotate_right = m_toolBar1->AddTool( wxID_ANY, _("Rotate +90"), rotate_right_png_to_wx_bitmap(), wxNullBitmap, wxITEM_NORMAL, _("Rotate the image +90°"), wxEmptyString, NULL );
 
    m_zoom_in = m_toolBar1->AddTool( wxID_ANY, _("Zoom in"), zoom_in_png_to_wx_bitmap(), wxNullBitmap, wxITEM_NORMAL, _("Zoom-in the image by 5%"), wxEmptyString, NULL );
 
    m_reset_zoom = m_toolBar1->AddTool( wxID_ANY, _("Reset zoom"), reset_zoom_png_to_wx_bitmap(), wxNullBitmap, wxITEM_NORMAL, _("Reset the zoom to fit into the window"), wxEmptyString, NULL );
 
    m_zoom_out = m_toolBar1->AddTool( wxID_ANY, _("Zoom out"), zoom_out_png_to_wx_bitmap(), wxNullBitmap, wxITEM_NORMAL, _("Zoom-out the image by 5%"), wxEmptyString, NULL );
 
    m_fullscreen = m_toolBar1->AddTool( wxID_ANY, _("Fullscreen"), fullscreen_png_to_wx_bitmap(), wxNullBitmap, wxITEM_NORMAL, _("Show in fullscreen"), wxEmptyString, NULL );
 
    m_toolBar1->Realize();
 
 
    this->Centre( wxBOTH );
 
    // Connect Events
    this->Connect( wxEVT_DROP_FILES, wxDropFilesEventHandler( ImageWindow::OnDropFile ) );
    this->Connect( wxEVT_KEY_UP, wxKeyEventHandler( ImageWindow::OnWindowKeyUp ) );
    this->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( ImageWindow::OnWindowMouseWheel ) );
    m_scrolledWindow1->Connect( wxEVT_KEY_UP, wxKeyEventHandler( ImageWindow::OnWindowKeyUp ), NULL, this );
    m_scrolledWindow1->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( ImageWindow::WindowOnSize ), NULL, this );
    m_bitmap1->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ImageWindow::OnBitmapDoubleLeftClick ), NULL, this );
    m_image_list->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( ImageWindow::OnListItemSelected ), NULL, this );
    this->Connect( m_rotate_left->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnRotateLeftClicked ) );
    this->Connect( m_rotate_right->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnRotateRightClicked ) );
    this->Connect( m_zoom_in->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnZoomInClicked ) );
    this->Connect( m_reset_zoom->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnZoomResetClicked ) );
    this->Connect( m_zoom_out->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnZoomOutClicked ) );
    this->Connect( m_fullscreen->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnShowFullScreenClick ) );
}
 
ImageWindow::~ImageWindow()
{
    // Disconnect Events
    this->Disconnect( wxEVT_DROP_FILES, wxDropFilesEventHandler( ImageWindow::OnDropFile ) );
    this->Disconnect( wxEVT_KEY_UP, wxKeyEventHandler( ImageWindow::OnWindowKeyUp ) );
    this->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( ImageWindow::OnWindowMouseWheel ) );
    m_scrolledWindow1->Disconnect( wxEVT_KEY_UP, wxKeyEventHandler( ImageWindow::OnWindowKeyUp ), NULL, this );
    m_scrolledWindow1->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( ImageWindow::WindowOnSize ), NULL, this );
    m_bitmap1->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ImageWindow::OnBitmapDoubleLeftClick ), NULL, this );
    m_image_list->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( ImageWindow::OnListItemSelected ), NULL, this );
    this->Disconnect( m_rotate_left->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnRotateLeftClicked ) );
    this->Disconnect( m_rotate_right->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnRotateRightClicked ) );
    this->Disconnect( m_zoom_in->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnZoomInClicked ) );
    this->Disconnect( m_reset_zoom->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnZoomResetClicked ) );
    this->Disconnect( m_zoom_out->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnZoomOutClicked ) );
    this->Disconnect( m_fullscreen->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( ImageWindow::OnShowFullScreenClick ) );
 
}