AeFloatFieldUI.c++
1.84 KB
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
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include "AeTypes.h"
#include "AeFieldUI.h"
#include "AeAsset.h"
#include "AeAssetUI.h"
AeFloatFieldUI::AeFloatFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
TJustify justify,
TFloatGetProc getProc,
TFloatSetProc setProc) :
AeFieldUI (name, isEditable, isSelectable, isHierarchical, False, justify, kFloatMaxLen)
{
fGetProc = getProc;
fSetProc = setProc;
fMin = FLT_MIN;
fMax = FLT_MAX;
fDefault = 0;
}
AeFloatFieldUI::AeFloatFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
TJustify justify,
TFloatGetProc getProc,
TFloatSetProc setProc,
float min, float max, float def) :
AeFieldUI (name, isEditable, isSelectable, isHierarchical, False, justify, kFloatMaxLen)
{
fGetProc = getProc;
fSetProc = setProc;
fMin = min;
fMax = max;
fDefault = def;
}
AeFloatFieldUI::~AeFloatFieldUI (void)
{
}
void
AeFloatFieldUI::GetValueString (AeAsset * asset, String string)
{
float value = fGetProc (asset);
sprintf (string, "%.1f", value);
}
Boolean
AeFloatFieldUI::SetValueString (AeAsset * asset, String string)
{
assert (fSetProc);
float value = atof (string);
assert (value >= fMin && value <= fMax);
if (value == fGetProc (asset))
return False;
fSetProc (asset, value);
return True;
}
Boolean
AeFloatFieldUI::VerifyValueString (String string)
{
float value = atof (string);
if (value < fMin || value > fMax)
return False;
return True;
}
Boolean
AeFloatFieldUI::VerifyInput (XmTextVerifyCallbackStruct * verify, const char * prevStr)
{
// we will need to fill this in as soon as we use an actual float field
return True;
}