-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigitField.m
More file actions
86 lines (69 loc) · 1.74 KB
/
DigitField.m
File metadata and controls
86 lines (69 loc) · 1.74 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
//
// DigitField.m
// MathHelp
//
// Created by Dominic Surrao on 6/13/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
// Modifications
// 5/29/2011 Added charValue property, displayCharValue method
//
#import "DigitField.h"
@implementation DigitField
-(DigitField *) initWithTextField:(UITextField *) iTextField : (int) iDecimalPosition {
textField = iTextField;
decimalPosition = iDecimalPosition;
[self setCharValue:[iTextField text]];
return self;
}
-(UITextField *) getTextField {
return textField;
}
-(DigitField *) getCarryDigitField {
return carryDigitField;
}
-(int) getDecimalPosition {
return decimalPosition;
}
-(void) setCarryDigitField:(DigitField *)iCarryDigitField {
carryDigitField = iCarryDigitField;
}
-(DigitField *) getCarryTargetDigitField {
return carryTargetDigitField;
}
-(void) setCarryTargetDigitField:(DigitField *)iCarryTargetDigitField {
carryTargetDigitField = iCarryTargetDigitField;
}
-(NSString *) getCharValue {
return charValue;
}
-(void) setCharValue:(NSString *)iCharValue {
/* release any previous value */
charValue = iCharValue;
}
-(void) displayCharValue {
textField.text = charValue;
}
/*
colors from
http : //www.colourlovers.com/web/blog/2008/04/22/all-120-crayon-names-color-codes-and-fun-facts
*/
-(void) enable {
textField.userInteractionEnabled = YES;
textField.backgroundColor = [UIColor whiteColor];
textField.borderStyle = UITextBorderStyleBezel;
}
-(void) disable {
textField.userInteractionEnabled = NO;
textField.backgroundColor = [UIColor colorWithRed:0.5 green:0.5 blue:1.0 alpha:0.2];
textField.borderStyle = UITextBorderStyleLine;
}
-(bool) isEnabled {
if (textField.userInteractionEnabled == YES) {
return (true);
}
else {
return (false);
}
}
@end