forked from tcobbs/ldview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocationDialog.cpp
97 lines (85 loc) · 1.81 KB
/
LocationDialog.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
#include "LocationDialog.h"
#include "ModelWindow.h"
#include "Resource.h"
#include <LDLib/LDUserDefaultsKeys.h>
#include <TCFoundation/TCUserDefaults.h>
#if defined(_MSC_VER) && _MSC_VER >= 1400 && defined(_DEBUG)
#define new DEBUG_CLIENTBLOCK
#endif // _DEBUG
LocationDialog::LocationDialog(HINSTANCE hInstance, int dialogId):
CUIDialog(hInstance, NULL)
, m_dialogId(dialogId)
, m_x(0.0)
, m_y(0.0)
, m_z(0.0)
{
}
LocationDialog::~LocationDialog(void)
{
}
void LocationDialog::dealloc(void)
{
if (hWindow)
{
DestroyWindow(hWindow);
}
CUIDialog::dealloc();
}
INT_PTR LocationDialog::doModal(ModelWindow *modelWindow)
{
HWND hParentWnd = GetParent(modelWindow->getHWindow());
return CUIDialog::doModal(m_dialogId, hParentWnd);
}
BOOL LocationDialog::doInitDialog(HWND /*hKbControl*/)
{
windowSetValue(IDC_X, m_x);
windowSetValue(IDC_Y, m_y);
windowSetValue(IDC_Z, m_z);
return TRUE;
}
BOOL LocationDialog::verifyField(
UINT fieldID,
float &value,
float min,
float max,
bool checkMin /*= true*/,
bool checkMax /*= true*/)
{
if (windowGetValue(fieldID, value))
{
bool changed = false;
if (checkMin && value < min)
{
value = min;
changed = true;
}
if (checkMax && value > max)
{
value = max;
changed = true;
}
if (changed)
{
windowSetValue(fieldID, value);
textFieldSetSelection(fieldID, 0, -1);
MessageBeep(MB_ICONHAND);
}
return TRUE;
}
else
{
return FALSE;
}
}
void LocationDialog::updateEnabled(void)
{
BOOL xOK = verifyField(IDC_X, m_x, 0.0f, 0.0f, false, false);
BOOL yOK = verifyField(IDC_Y, m_y, 0.0f, 0.0f, false, false);
BOOL zOK = verifyField(IDC_Z, m_z, 0.0f, 0.0f, false, false);
EnableWindow(GetDlgItem(hWindow, IDOK), xOK && yOK && zOK);
}
LRESULT LocationDialog::doTextFieldChange(int /*controlId*/, HWND /*control*/)
{
updateEnabled();
return 0;
}