23 |
|
|
24 |
#include <Foundation/NSException.h> |
#include <Foundation/NSException.h> |
25 |
|
|
26 |
#include "Interface/UiTextfield.h" |
#include "Interface/UiTextField.h" |
27 |
|
|
28 |
/** |
/** |
29 |
* UiTextField implementation |
* UiTextField implementation |
37 |
* @param (NSPoint)position the position of the widget |
* @param (NSPoint)position the position of the widget |
38 |
* @param (NSSize)size the size of the widget |
* @param (NSSize)size the size of the widget |
39 |
*/ |
*/ |
40 |
- (id) initWithText: (NSString *)text |
- (id) initWithText: (NSMutableString *)text |
41 |
position: (NSPoint)position |
position: (NSPoint)position |
42 |
size: (NSSize)size; |
height: (unsigned)height |
43 |
{ |
{ |
44 |
NSParameterAssert (text); |
NSParameterAssert (text); |
45 |
NSParameterAssert ([text length] != 0); |
NSParameterAssert ([text length] != 0); |
46 |
|
|
47 |
self = [super initWithPosition: position |
self = [super initWithPosition: position |
48 |
size: size]; |
size: NSZeroSize]; |
49 |
if (self != nil) |
if (self != nil) |
50 |
{ |
{ |
51 |
_text = RETAIN (text); |
_text = RETAIN (text); |
52 |
|
_cursor = 0; |
53 |
|
_height = height; |
54 |
|
_color = blueColor; |
55 |
|
_renderText = [[UiText alloc] initWithText: text |
56 |
|
height: _height]; |
57 |
} |
} |
58 |
|
|
59 |
return self; |
return self; |
61 |
|
|
62 |
- (void) dealloc |
- (void) dealloc |
63 |
{ |
{ |
64 |
RELEASE(_text); |
RELEASE (_text); |
65 |
|
RELEASE (_renderText); |
66 |
|
|
67 |
[super dealloc]; |
[super dealloc]; |
68 |
} |
} |
69 |
|
|
70 |
/** |
/** |
71 |
* Returns the text displayed in the widget |
* Returns the text displayed in the widget |
72 |
*/ |
*/ |
73 |
- (NSString *) text |
- (NSMutableString *) text |
74 |
{ |
{ |
75 |
return _text; |
return _text; |
76 |
} |
} |
79 |
* sets the text |
* sets the text |
80 |
* @param (NSString *) text a non-nil NSString |
* @param (NSString *) text a non-nil NSString |
81 |
*/ |
*/ |
82 |
- (void) setText: (NSString *) text |
- (void) setText: (NSMutableString *)text |
83 |
{ |
{ |
84 |
NSParameterAssert (text); |
NSParameterAssert (text); |
85 |
NSParameterAssert ([text length] != 0); |
// NSParameterAssert ([text length] != 0); |
86 |
|
|
87 |
ASSIGN(_text, text); |
ASSIGN(_text, text); |
88 |
|
|
89 |
|
RELEASE (_renderText); |
90 |
|
|
91 |
|
_renderText = [[UiText alloc] initWithText: _text |
92 |
|
height: _height]; |
93 |
|
} |
94 |
|
|
95 |
|
- (unsigned) cursor |
96 |
|
{ |
97 |
|
return _cursor; |
98 |
|
} |
99 |
|
|
100 |
|
- (void) setCursor: (unsigned)cursor |
101 |
|
{ |
102 |
|
_cursor = cursor; |
103 |
|
} |
104 |
|
|
105 |
|
- (unsigned) height |
106 |
|
{ |
107 |
|
return _height; |
108 |
|
} |
109 |
|
|
110 |
|
- (void) setHeight: (unsigned)height |
111 |
|
{ |
112 |
|
_height = height; |
113 |
} |
} |
114 |
|
|
115 |
@end |
@end |