-
Notifications
You must be signed in to change notification settings - Fork 2
/
BoxedDropDown.cpp
112 lines (95 loc) · 2.65 KB
/
BoxedDropDown.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
// wxWindows includes
#include <wx/wx.h>
#include <wx/sizer.h>
// Statsgen includes
#include "BoxedDropDown.h"
#include "WindowIDs.h"
#include "ErrorData.h"
BoxedDropDown::BoxedDropDown()
{
STATSGEN_DEBUG_FUNCTION_START("BoxedDropDown","BoxedDropDown")
allEntriesAllowed=true;
STATSGEN_DEBUG_FUNCTION_END
}
void BoxedDropDown::AllEntriesAllowed(bool allEntries)
{
allEntriesAllowed=allEntries;
}
BoxedDropDown::~BoxedDropDown()
{
STATSGEN_DEBUG_FUNCTION_START("BoxedDropDown","~BoxedDropDown")
STATSGEN_DEBUG_FUNCTION_END
}
bool BoxedDropDown::CreateDialog(wxWindow *parent,
wxWindowID id,
const wxPoint &pos,
const wxSize &size,
long style,
const wxString &name)
{
bool retVal=true;
wxString label;
wxArrayString dropDownEntries;
wxSize itemSize;
wxPoint itemPosition;
wxString msg;
int dropDownWidth;
int dropDownHeight;
int boxWidth;
int boxHeight;
wxString defaultSelection="??";
wxString dialogName="BoxedDropDown";
STATSGEN_DEBUG_FUNCTION_START("BoxedDropDown","CreateDialog")
label=GetLabel();
DropDownEntries(dropDownEntries,defaultSelection);
if (allEntriesAllowed)
{
dropDownEntries.Insert(AllName(),0);
defaultSelection=AllName();
}
STATSGEN_DEBUG(DEBUG_ALWAYS,"Create")
Create(parent,id,pos,size,style,name);
STATSGEN_DEBUG(DEBUG_ALWAYS,"staticBox.Create")
staticBox.Create(this,-1,label);
STATSGEN_DEBUG(DEBUG_ALWAYS,"dropDown.Create")
//dropDown=new wxComboBox(&staticBox,
dropDown=new wxComboBox(this,
id,
defaultSelection,
wxDefaultPosition,
wxDefaultSize,
dropDownEntries,
wxCB_DROPDOWN |
wxCB_READONLY,
wxDefaultValidator,
dialogName);
STATSGEN_DEBUG(DEBUG_ALWAYS,"dropDown.SetValue")
dropDown->SetValue(defaultSelection);
STATSGEN_DEBUG(DEBUG_ALWAYS,"dropDown.GetSize")
itemSize=dropDown->GetSize();
dropDownHeight=itemSize.GetHeight();
dropDownWidth=itemSize.GetWidth();
boxWidth=dropDownWidth+STATIC_BOX_LEFT_GAP+STATIC_BOX_RIGHT_GAP;
boxHeight=dropDownHeight+STATIC_BOX_TOP_GAP+STATIC_BOX_BOTTOM_GAP;
itemPosition.x=0;
itemPosition.y=0;
STATSGEN_DEBUG(DEBUG_ALWAYS,"staticBox.set size")
staticBox.SetPosition(itemPosition);
staticBox.SetSize(wxSize(boxWidth,boxHeight));
itemPosition.x=STATIC_BOX_LEFT_GAP;
itemPosition.y=STATIC_BOX_TOP_GAP;
STATSGEN_DEBUG(DEBUG_ALWAYS,"dropDown.SetPosition")
dropDown->SetPosition(itemPosition);
STATSGEN_DEBUG(DEBUG_ALWAYS,"SetSize")
SetSize(wxSize(boxWidth+00,boxHeight+00));
STATSGEN_DEBUG_FUNCTION_END
return (retVal);
}
wxString BoxedDropDown::GetSelectedCode()
{
wxString name;
wxString code;
name=dropDown->GetValue();
code=FindCodeFromName(name);
return (code);
}