1 #include "main.h"
2
3 //helper functions
4 enum wxbuildinfoformat {
5 short_f, long_f };
6
wxbuildinfo(wxbuildinfoformat format)7 wxString wxbuildinfo(wxbuildinfoformat format)
8 {
9 wxString wxbuild(wxVERSION_STRING);
10
11 if (format == long_f )
12 {
13 #if defined(__WXMSW__)
14 wxbuild << _T("-Windows");
15 #elif defined(__UNIX__)
16 wxbuild << _T("-Linux");
17 #endif
18
19 #if wxUSE_UNICODE
20 wxbuild << _T("-unicode build");
21 #else
22 wxbuild << _T("-ANSI build");
23 #endif // wxUSE_UNICODE
24 }
25
26 return wxbuild;
27 }
28
29 int idMenuQuit = wxNewId();
30 int idMenuAbout = wxNewId();
31
BEGIN_EVENT_TABLE(MyFrame,wxFrame)32 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
33 EVT_MENU(idMenuQuit, MyFrame::OnQuit)
34 EVT_MENU(idMenuAbout, MyFrame::OnAbout)
35 END_EVENT_TABLE()
36
37 MyFrame::MyFrame(wxFrame *frame, const wxString& title)
38 : wxFrame(frame, -1, title)
39 {
40 #if wxUSE_MENUS
41 // create a menu bar
42 wxMenuBar* mbar = new wxMenuBar();
43 wxMenu* fileMenu = new wxMenu(_T(""));
44 fileMenu->Append(idMenuQuit, _T("&Quit\tAlt-F4"), _T("Quit the application"));
45 mbar->Append(fileMenu, _T("&File"));
46
47 HexEditorCtrl *hexed = new HexEditorCtrl(this, -1, wxDefaultPosition, wxDefaultSize);
48
49 wxMenu* helpMenu = new wxMenu(_T(""));
50 helpMenu->Append(idMenuAbout, _T("&About\tF1"), _T("Show info about this application"));
51 mbar->Append(helpMenu, _T("&Help"));
52
53 SetMenuBar(mbar);
54 #endif // wxUSE_MENUS
55
56 #if wxUSE_STATUSBAR
57 // create a status bar with some information about the used wxWidgets version
58 CreateStatusBar(2);
59 SetStatusText(_T("HexEditorCtrl Status"),0);
60 SetStatusText(wxbuildinfo(short_f),1);
61 #endif // wxUSE_STATUSBAR
62 char *buf = new char [512];
63 for(unsigned i=0; i<512 ; i++)
64 buf[i]=i%256;
65 hexed->ReadFromBuffer( 0, 512, buf );
66
67 }
68
~MyFrame()69 MyFrame::~MyFrame()
70 {
71 }
72
OnQuit(wxCommandEvent & event)73 void MyFrame::OnQuit(wxCommandEvent& event)
74 {
75 Close();
76 }
77
OnAbout(wxCommandEvent & event)78 void MyFrame::OnAbout(wxCommandEvent& event)
79 {
80 wxString msg = wxbuildinfo(long_f);
81 wxMessageBox(msg, _T("Welcome to..."));
82 }
83
84