-
Notifications
You must be signed in to change notification settings - Fork 2
/
ErrorPanel.cpp
117 lines (98 loc) · 2.5 KB
/
ErrorPanel.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// wx includes
#include <wx/wx.h>
#include <wx/string.h>
#include <wx/regex.h>
// Statsgen Includes
#include "ErrorPanel.h"
#include "GlobalStatistics.h"
#include "StaticFunctions.h"
#include "ProgressPanel.h"
BEGIN_EVENT_TABLE(ErrorPanel, wxPanel)
EVT_SIZE(ErrorPanel::OnResize)
END_EVENT_TABLE()
ErrorPanel::ErrorPanel(wxArrayString &errorsIn,wxArrayInt &severitiesIn)
{
errorDisplay=NULL;
errors=errorsIn;
severities=severitiesIn;
}
void ErrorPanel::Update()
{
wxListItem listColumn;
int errorIndex;
int errorCount;
int listIndex;
wxString error;
int severity;
wxBitmap bitmap;
imageList.Create(16,16);
for (severity=SeverityNotRun;severity<SeverityMax;severity++)
{
bitmap=ProgressPanel::SeverityImage(severity);
imageList.Add(bitmap);
}
errorDisplay->SetImageList(&imageList,wxIMAGE_LIST_NORMAL);
errorDisplay->SetImageList(&imageList,wxIMAGE_LIST_SMALL);
errorDisplay->Hide();
errorDisplay->DeleteAllColumns();
errorDisplay->DeleteAllItems();
listColumn.SetText("Severity");
errorDisplay->InsertColumn(0,listColumn);
listColumn.SetText("Text");
errorDisplay->InsertColumn(2,listColumn);
errorCount=errors.GetCount();
for (errorIndex=0;errorIndex<errorCount;errorIndex++)
{
wxString severityString;
error=errors.Item(errorIndex);
severity=severities.Item(errorIndex);
severityString=ProgressPanel::SeverityString(severity);
listIndex=errorDisplay->InsertItem(errorIndex,severityString);
errorDisplay->SetItemData(listIndex,errorIndex);
errorDisplay->SetItem(errorIndex,1,error);
errorDisplay->SetItem(errorIndex,0,severityString,severity);
}
errorDisplay->SetColumnWidth(0,wxLIST_AUTOSIZE);
errorDisplay->SetColumnWidth(1,wxLIST_AUTOSIZE);
errorDisplay->Show();
}
void ErrorPanel::CreateScreen()
{
wxString defaultValue="";
wxSizeEvent event;
if (errorDisplay==NULL)
{
globalStatistics.ReadPlayerCache();
errorDisplay=new wxListCtrl(this,
WINDOW_ID_LISTBOX_CONFIGITEMS,
wxDefaultPosition,
wxDefaultSize,
wxLC_REPORT);
Update();
}
else
{
// Screen is already created
}
}
void ErrorPanel::OnResize(wxSizeEvent &event)
{
wxSize itemSize;
int panelWidth;
int panelHeight;
int listHeight;
int listWidth;
wxString msg;
// Make sure the screen has been created
CreateScreen();
itemSize=GetSize();
panelWidth=itemSize.GetWidth();
panelHeight=itemSize.GetHeight();
listWidth=panelWidth-10;
listHeight=panelHeight;
if (listHeight<0)
{
listHeight=0;
}
errorDisplay->SetSize(0,0,listWidth,listHeight);
}