/
BBBApp.cpp
74 lines (61 loc) · 1.93 KB
/
BBBApp.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
#include "BBBApp.hpp"
#include "BBBFrame.hpp"
#include "panels_gfx.xpm"
#include <wx/bitmap.h>
#include <vector>
#include "wxlogger.hpp"
IMPLEMENT_APP(BBBApp)
std::vector<wxBitmap> panelImages;
/** OnInit
*
* Initializes the program
*/
bool BBBApp::OnInit()
{
srand(time(NULL));
logger.reset(new LoggerWx());
if (!wxApp::OnInit())
return false;
#ifndef __WIN32
wxHandleFatalExceptions();
#endif
wxInitAllImageHandlers();
SetVendorName("Bottomless Block Builder");
SetAppName("Bottomless Block Builder");
wxBitmap bitmap(panels_gfx_xpm);
panelImages.push_back(bitmap.GetSubBitmap(wxRect(112, 16, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(0, 0, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(16, 0, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(32, 0, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(48, 0, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(64, 0, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(80, 0, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(96, 0, 16, 16)));
panelImages.push_back(bitmap.GetSubBitmap(wxRect(112, 0, 16, 16)));
BBBFrame* frame = new BBBFrame();
frame->Show();
return true;
}
bool BBBApp::OnExceptionInMainLoop()
{
wxString error;
try {
throw; // Rethrow the current exception.
} catch (const std::exception& e) {
error = e.what();
} catch (const char* e) {
error = e;
} catch ( ... ) {
error = "unknown error.";
}
ErrorLog("Unexpected exception has occurred: %s, the program will terminate.", error.c_str().AsChar());
return false;
}
void BBBApp::OnFatalException()
{
ErrorLog("Unexpected exception has occurred: the program will terminate.");
}
void BBBApp::OnUnhandledException()
{
ErrorLog("Unexpected exception has occurred: the program will terminate.");
}