1
+
2
+ #include " main.hpp"
3
+
4
+
5
+ enum
6
+ {
7
+ // menu items
8
+ BUTTON_Quit = wxID_EXIT,
9
+
10
+ // it is important for the id corresponding to the "About" command to have
11
+ // this standard value as otherwise it won't be handled properly under Mac
12
+ // (where it is special and put into the "Apple" menu)
13
+ };
14
+
15
+
16
+
17
+ class AppMain : public wxApp
18
+ {
19
+ public:
20
+ // override base class virtuals
21
+ // ----------------------------
22
+
23
+ // this one is called on application startup and is a good place for the app
24
+ // initialization (doing it here and not in the ctor allows to have an error
25
+ // return: if OnInit() returns false, the application terminates)
26
+ virtual bool OnInit ();
27
+ private:
28
+ Kamera *kamera;
29
+ };
30
+
31
+
32
+ class FrameMain : public wxFrame
33
+ {
34
+ public:
35
+ // ctor(s)
36
+ FrameMain (const wxString& title);
37
+
38
+ // event handlers (these functions should _not_ be virtual)
39
+ void OnQuit (wxCommandEvent& event);
40
+ void OnPaint (wxPaintEvent& event);
41
+
42
+ private:
43
+ // any class wishing to process wxWidgets events must use this macro
44
+ wxButton *QuitBut;
45
+ void DrawImage (wxDC &dc);
46
+ Kamera *kamera;
47
+ DECLARE_EVENT_TABLE ()
48
+ };
49
+
50
+
51
+ BEGIN_EVENT_TABLE (FrameMain, wxFrame)
52
+ EVT_BUTTON(BUTTON_Quit, FrameMain::OnQuit)
53
+ EVT_PAINT(FrameMain::OnPaint)
54
+ END_EVENT_TABLE()
55
+
56
+
57
+ IMPLEMENT_APP(AppMain)
58
+
59
+
60
+
61
+
62
+ // frame constructor
63
+ FrameMain::FrameMain(const wxString& title)
64
+ : wxFrame(NULL , wxID_ANY, title, wxDefaultPosition, wxSize(640 ,480 ), 0)
65
+ {
66
+ SetBackgroundColour (wxColor (80 ,100 ,255 ));
67
+ SetBackgroundStyle (wxBG_STYLE_PAINT);
68
+ // set the frame icon
69
+ QuitBut = new wxButton (this , BUTTON_Quit, wxT (" Ukonèit" ), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxBU_EXACTFIT);
70
+ QuitBut->SetForegroundColour (wxColor (150 ,150 ,255 ));
71
+ int x, y;
72
+ QuitBut->GetSize (&x, &y);
73
+ QuitBut->SetPosition (wxPoint (640 -x, 0 ));
74
+
75
+
76
+ SetIcon (wxICON (sample));
77
+ Centre ();
78
+ kamera = new Kamera ();
79
+
80
+ }
81
+
82
+ void FrameMain::OnPaint (wxPaintEvent& event)
83
+ {
84
+ wxAutoBufferedPaintDC dc (this );
85
+ dc.SetBackground (wxBrush (this ->GetBackgroundColour ()));
86
+ dc.Clear ();
87
+ DrawImage (dc);
88
+ }
89
+
90
+ void FrameMain::DrawImage (wxDC &dc)
91
+ {
92
+
93
+ wxImage *image = new wxImage ();
94
+ kamera->Obrazek (image);
95
+
96
+ // image->Mirror(true);
97
+
98
+
99
+
100
+ wxSize imageSize = image->GetSize ();
101
+ wxBitmap bitmap = wxBitmap ((image->Rotate180 ()));
102
+ // delete image;
103
+ dc.DrawBitmap (bitmap,0 ,0 , false );
104
+ }
105
+
106
+ // event handlers
107
+
108
+ void FrameMain::OnQuit (wxCommandEvent& WXUNUSED (event))
109
+ {
110
+ // true is to force the frame to close
111
+ Close (true );
112
+ }
113
+
114
+
115
+ bool AppMain::OnInit ()
116
+ {
117
+ // call the base class initialization method, currently it only parses a
118
+ // few common command-line options but it could be do more in the future
119
+ if ( !wxApp::OnInit () )
120
+ return false ;
121
+
122
+ // create the main application window
123
+ FrameMain *frame = new FrameMain (" Spektrograf" );
124
+
125
+ // and show it (the frames, unlike simple controls, are not shown when
126
+ // created initially)
127
+
128
+ // wxInitAllImageHandlers();
129
+
130
+ // wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
131
+
132
+ // then simply create like this
133
+ // drawPane = new wxImagePanel( frame, wxT("image.jpg"), wxBITMAP_TYPE_JPEG);
134
+ // sizer->Add(drawPane, 1, wxEXPAND);
135
+
136
+ // frame->SetSizer(sizer);
137
+ frame->Show (true );
138
+
139
+ // kamera = new Kamera();
140
+
141
+ // kamera->Obrazek(img);
142
+
143
+ // success: wxApp::OnRun() will be called which will enter the main message
144
+ // loop and the application will run. If we returned false here, the
145
+ // application would exit immediately.
146
+ return true ;
147
+ }
0 commit comments