11: #define TMP1MAIN_H
12:
13: #ifndef WX_PRECOMP
14: #include
15: #endif
16:
17: #include "tmp1App.h"
18:
19: class RenderTimer; // make renderTimer.h not influence this file compling time
20:
21: class tmp1Frame: public wxFrame
22: {
23: public:
24: tmp1Frame(wxFrame *frame, const wxString& title);
25: ~tmp1Frame();
26:
27: // for painting
28: void PaintNow();
29: void render(wxDC& dc);
30:
31: private:
32: // derived from wxTimer
33: RenderTimer* timer;
34:
35: enum
36: {
37: idMenuQuit = 1000,
38: idMenuAbout,
39: idStartLoop,
40: idStopLoop
41: };
42:
43: void OnClose(wxCloseEvent& event);
44: void OnQuit(wxCommandEvent& event);
45: void OnAbout(wxCommandEvent& event);
46: void OnStartLoop(wxCommandEvent& event);
47: void OnStopLoop(wxCommandEvent& event);
48:
49: DECLARE_EVENT_TABLE()
50: };
51:
52: #endif // TMP1MAIN_H
tmp1Main.cpp
1: /***************************************************************
2: * Name: tmp1Main.cpp
3: * Purpose: Code for Application Frame
4: * Author: grass in moon
5: * Created: 2012-07-06
6: * Copyright: grass in moon (http://www.cppblog.com/grass-and-moon/)
7: * License:
8: **************************************************************/
9:
10: #ifdef WX_PRECOMP
11: #include "wx_pch.h"
12: #endif
13:
14: #ifdef __BORLANDC__
15: #pragma hdrstop
16: #endif //__BORLANDC__
17:
18: #include "tmp1Main.h"
20:
21: //helper functions
22: enum wxbuildinfoformat
23: {
24: short_f, long_f
25: };
26:
27: wxString wxbuildinfo(wxbuildinfoformat format)
28: {
29: wxString wxbuild(wxVERSION_STRING);
30:
31: if (format == long_f )
32: {
33: #if defined(__WXMSW__)
34: wxbuild << _T("-Windows");
35: #elif defined(__WXMAC__)
36: wxbuild << _T("-Mac");
37: #elif defined(__UNIX__)
38: wxbuild << _T("-Linux");
39: #endif
40:
41: #if wxUSE_UNICODE
42: wxbuild << _T("-Unicode build");
43: #else
44: wxbuild << _T("-ANSI build");
45: #endif // wxUSE_UNICODE
46: }
47:
48: return wxbuild;
49: }
50:
51: BEGIN_EVENT_TABLE(tmp1Frame, wxFrame)
52: EVT_CLOSE(tmp1Frame::OnClose)
53: EVT_MENU(idMenuQuit, tmp1Frame::OnQuit)
54: EVT_MENU(idMenuAbout, tmp1Frame::OnAbout)
55: EVT_MENU(idStartLoop, tmp1Frame::OnStartLoop)
56: EVT_MENU(idStopLoop, tmp1Frame::OnStopLoop)
57: END_EVENT_TABLE()
58:
59: tmp1Frame::tmp1Frame(wxFrame *frame, const wxString& title)
60: : wxFrame(frame, -1, title)
61: {
62: #if wxUSE_MENUS
63: // create a menu bar
64: wxMenuBar* mbar = new wxMenuBar();
65: wxMenu* fileMenu = new wxMenu(_T(""));
66: fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application"));
67: fileMenu->Append(idStartLoop, _("St&artLoop")); // for starting draw text
68: fileMenu->Append(idStopLoop, _("Sto&pLoop")); // for stoping draw text
69: mbar->Append(fileMenu, _("&File"));
70:
71: wxMenu* helpMenu = new wxMenu(_T(""));
72: helpMenu->Append(idMenuAbout, _("&About\tF1"), _("Show info about this application"));
73: mbar->Append(helpMenu, _("&Help"));
74:
75: SetMenuBar(mbar);
76: #endif // wxUSE_MENUS
77:
78: #if wxUSE_STATUSBAR
79: // create a stat