-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
84 lines (64 loc) · 1.79 KB
/
main.cpp
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
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <wx/dc.h>
#include <wx/dcbuffer.h>
#include "GUI/ddsGUI.h"
#include "GUI/ImageHandlerDDS.h"
#include "DDS/ddsLoader.h"
using namespace std;
class mainApp: public wxApp
{
public:
virtual bool OnInit();
};
wxIMPLEMENT_APP(mainApp);
class subFrame : public mainFrame
{
protected:
wxImage bitmap;
public:
subFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ) :
mainFrame(parent, id, title, pos, size, style | wxFULL_REPAINT_ON_RESIZE)
{
SetBackgroundStyle(wxBackgroundStyle::wxBG_STYLE_PAINT);
}
void SetFile(const wxString& path)
{
if (!bitmap.LoadFile(path))
return;
this->SetSize(bitmap.GetWidth(), bitmap.GetHeight());
Refresh();
}
void OnPaint(wxPaintEvent& evt)
{
wxBufferedPaintDC dc(this); // use buffered version to avoid flicker
dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear();
if (!bitmap.IsOk())
return;
int w, h;
GetSize(&w, &h);
wxImage picture = bitmap.Scale(w, h, wxImageResizeQuality::wxIMAGE_QUALITY_BICUBIC);
dc.DrawBitmap(wxBitmap(picture, dc), 0, 0);
}
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(subFrame, mainFrame)
EVT_PAINT(subFrame::OnPaint)
END_EVENT_TABLE()
bool mainApp::OnInit()
{
wxInitAllImageHandlers();
wxImage::AddHandler(new ImageHandlerDDS());
subFrame* frame = new subFrame(NULL);
frame->Show(true);
if (argc == 2)
{
frame->SetTitle(argv[1]);
frame->SetFile(argv[1]);
}
SetTopWindow(frame);
return true;
}