-
Notifications
You must be signed in to change notification settings - Fork 2
/
BooleanConfigItemGUI.cpp
176 lines (148 loc) · 3.79 KB
/
BooleanConfigItemGUI.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Statsgen Includes
#include "BooleanConfigItemGUI.h"
#include "GlobalStatistics.h"
#include "Progress.h"
BEGIN_EVENT_TABLE(BooleanConfigItemGUI, wxPanel)
EVT_SIZE(BooleanConfigItemGUI::OnResize)
EVT_CHECKBOX(WINDOW_ID_TEXTCTRL_CONFIGVALUE,BooleanConfigItemGUI::OnTextChange)
END_EVENT_TABLE()
BooleanConfigItemGUI::BooleanConfigItemGUI()
{
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","Constructor")
STATSGEN_DEBUG_FUNCTION_END
}
void BooleanConfigItemGUI::OnTextChange(wxCommandEvent& event)
{
wxString msg;
wxString key;
wxString value;
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","OnTextChange")
if (textEdit.GetValue())
{
value="Y";
}
else
{
value="N";
}
if (configKey.Length()>0)
{
globalStatistics.configData.WriteTextValue(configKey,
value);
}
if (GetParent()!=NULL)
{
wxCommandEvent newEvent;
newEvent.SetId(WINDOW_ID_TEXTCTRL_CONFIGVALUE);
newEvent.SetEventType(wxEVT_COMMAND_TEXT_UPDATED);
STATSGEN_DEBUG(DEBUG_ALWAYS,"Popping event");
GetParent()->AddPendingEvent(newEvent);
}
STATSGEN_DEBUG_FUNCTION_END
}
BooleanConfigItemGUI::~BooleanConfigItemGUI()
{
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","Destructor")
STATSGEN_DEBUG_FUNCTION_END
}
void BooleanConfigItemGUI::SetConfigKey(wxString &configKeyIn)
{
wxString value;
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","SetConfigKey")
configKey=configKeyIn;
if (configKey.Length()>0)
{
STATSGEN_DEBUG(DEBUG_ALWAYS,"ConfigKeyLength>0")
globalStatistics.configData.ReadTextValue(configKey,
&value,
(char *)defaultValue.GetData());
STATSGEN_DEBUG(DEBUG_ALWAYS,"textEdit.SetValue")
textEdit.SetValue( (value.CmpNoCase("Y")==0));
}
STATSGEN_DEBUG_FUNCTION_END
}
void BooleanConfigItemGUI::Set(
wxString &configKeyIn,
wxString &labelTextIn,
wxString &defaultValueIn)
{
wxSizeEvent event;
configKey=configKeyIn;
labelText=labelTextIn;
defaultValue=defaultValueIn;
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","Set")
//SetConfigKey(configKey);
STATSGEN_DEBUG(DEBUG_ALWAYS,"label.Create")
// Create the config items
label.Create(this,
-1,
labelText,
wxPoint(0,0));
textEdit.Create(this,
WINDOW_ID_TEXTCTRL_CONFIGVALUE,
_T(""));
SetConfigKey(configKey);
OnResize(event);
STATSGEN_DEBUG_FUNCTION_END
}
wxString BooleanConfigItemGUI::GetValue()
{
wxString value;
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","GetValue")
if (textEdit.GetValue())
{
value="Y";
}
else
{
value="N";
}
STATSGEN_DEBUG_FUNCTION_END
return (value);
}
int BooleanConfigItemGUI::GetLabelWidth()
{
wxSize itemSize;
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","GetLabelWidth")
itemSize=label.GetSize();
STATSGEN_DEBUG_FUNCTION_END
return (itemSize.GetWidth());
}
void BooleanConfigItemGUI::SetLabelWidth(int width)
{
wxSize itemSize;
wxPoint itemPosition;
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","SetLabelWidth")
itemSize=label.GetSize();
itemPosition=label.GetPosition();
label.SetSize(itemPosition.x,
itemPosition.y,
width,
itemSize.GetHeight());
STATSGEN_DEBUG_FUNCTION_END
}
void BooleanConfigItemGUI::OnResize(wxSizeEvent &event)
{
wxString msg;
wxSize itemSize;
int textWidth;
int textHeight;
int labelWidth;
int labelHeight;
int panelWidth;
int panelHeight;
STATSGEN_DEBUG_FUNCTION_START("BooleanConfigItemGUI","OnResize")
itemSize=GetSize();
panelWidth=itemSize.GetWidth();
panelHeight=itemSize.GetHeight();
itemSize=label.GetSize();
labelWidth=itemSize.GetWidth();
labelHeight=itemSize.GetHeight();
label.SetSize(0,0,labelWidth,labelHeight);
labelWidth+=5;
itemSize=textEdit.GetSize();
textWidth=itemSize.GetWidth();
textHeight=itemSize.GetHeight();
textEdit.SetSize(labelWidth,0,textWidth,textHeight);
STATSGEN_DEBUG_FUNCTION_END
}