-
Notifications
You must be signed in to change notification settings - Fork 2
/
GenericOKCancelDialog.cpp
159 lines (127 loc) · 3.41 KB
/
GenericOKCancelDialog.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
// Statsgen Includes
#include <wx/wx.h>
#include "GenericOKCancelDialog.h"
#include "GlobalStatistics.h"
BEGIN_EVENT_TABLE(GenericOKCancelDialog, wxDialog)
EVT_SIZE(GenericOKCancelDialog::OnResize)
EVT_BUTTON(WINDOW_ID_BUTTON_SAVE,GenericOKCancelDialog::OnSave)
EVT_BUTTON(WINDOW_ID_BUTTON_QUIT,GenericOKCancelDialog::OnQuit)
END_EVENT_TABLE()
GenericOKCancelDialog::GenericOKCancelDialog(wxWindow *parent,
wxWindowID id,
const wxString &title,
const wxPoint &pos,
const wxSize &size,
long style,
const wxString &name):
wxDialog(parent,
id,
title,
pos,
size,
style,
name)
{
configPanel=NULL;
}
void GenericOKCancelDialog::OnQuit(wxCommandEvent& event)
{
EndModal(event.GetId());
}
void GenericOKCancelDialog::OnSave(wxCommandEvent& event)
{
EndModal(event.GetId());
}
GenericOKCancelDialog::~GenericOKCancelDialog()
{
}
void GenericOKCancelDialog::SetPanel(wxPanel *configPanelIn)
{
configPanel=configPanelIn;
}
void GenericOKCancelDialog::CreateDialog()
{
wxString label="Generic Configuration";
wxString defaultValue="";
wxString configKey;
wxSizeEvent event;
wxPanel *configPanel;
wxPoint configItemsPosition=wxDefaultPosition;
wxSize configItemsSize=wxDefaultSize;
STATSGEN_DEBUG_FUNCTION_START("GenericOKCancelDialog","CreateDialog")
saveButton.Create(this,
WINDOW_ID_BUTTON_SAVE,
_T(WINDOW_ID_BUTTON_SAVE_TEXT),
wxDefaultPosition);
quitButton.Create(this,
WINDOW_ID_BUTTON_QUIT,
_T(WINDOW_ID_BUTTON_QUIT_TEXT),
wxDefaultPosition);
OnResize(event);
STATSGEN_DEBUG_FUNCTION_END
}
bool GenericOKCancelDialog::DisplayDialog(wxPanel *panel)
{
int dialogRetVal;
bool retVal;
// Called when we want to pop the dialog box
// into existance for the first time
SetPanel(panel);
// First we want to create all the items in the dialog box
CreateDialog();
// Now we can resize every item in the dialog to fit nicely
// Then we pop it into existance
dialogRetVal=ShowModal();
// Now we do what is necessary dependent on the return code
switch (dialogRetVal)
{
case WINDOW_ID_BUTTON_SAVE:
retVal=true;
break;
case WINDOW_ID_BUTTON_QUIT:
default:
retVal=false;
break;
}
return (retVal);
}
void GenericOKCancelDialog::OnResize(wxSizeEvent &event)
{
wxString msg;
int dialogWidth;
int dialogHeight;
int quitWidth;
int quitHeight;
int saveWidth;
int saveHeight;
int panelWidth;
int panelHeight;
wxSize itemSize;
wxPoint itemPosition;
int yPosition;
STATSGEN_DEBUG_FUNCTION_START("GenericOKCancelDialog","OnResize")
itemSize=GetSize();
dialogWidth=itemSize.GetWidth();
dialogHeight=itemSize.GetHeight();
// Quit and Save buttons are at the bottom of the screen
itemSize=quitButton.GetSize();
quitWidth=itemSize.GetWidth();
quitHeight=itemSize.GetHeight();
itemSize=saveButton.GetSize();
saveWidth=itemSize.GetWidth();
saveHeight=itemSize.GetHeight();
panelHeight=dialogHeight-saveHeight-DIALOG_BOTTOM_BORDER_SIZE;
panelWidth=dialogWidth;
// Panel
yPosition=0;
configPanel->SetSize(0,yPosition,panelWidth,panelHeight);
// Save button
itemPosition.x=BUTTON_WIDTH_GAP;
itemPosition.y=dialogHeight-saveHeight-DIALOG_BOTTOM_BORDER_SIZE;
saveButton.SetPosition(itemPosition);
// Quit button
itemPosition.x=saveWidth+BUTTON_WIDTH_GAP+BUTTON_WIDTH_GAP;
itemPosition.y=dialogHeight-quitHeight-DIALOG_BOTTOM_BORDER_SIZE;
quitButton.SetPosition(itemPosition);
STATSGEN_DEBUG_FUNCTION_END
}