25 |
#include <Foundation/NSGeometry.h> |
#include <Foundation/NSGeometry.h> |
26 |
|
|
27 |
#include "Interface/UiLabel.h" |
#include "Interface/UiLabel.h" |
28 |
|
#include "Interface/UiText.h" |
29 |
|
|
30 |
|
@interface UiLabel (Private) |
31 |
|
+ (unsigned) _textSize; |
32 |
|
@end |
33 |
|
|
34 |
@implementation UiLabel |
@implementation UiLabel |
35 |
|
|
36 |
|
+ (unsigned) _textSize |
37 |
|
{ |
38 |
|
return 18; |
39 |
|
} |
40 |
|
|
41 |
/* Must crash if text is nil Must crash if width or height < 0 */ |
/* Must crash if text is nil Must crash if width or height < 0 */ |
42 |
- (id) initWithText: (NSString *)text |
- (id) initWithText: (NSString *)text |
43 |
position: (NSPoint)position |
position: (NSPoint)position |
50 |
if (self != nil) |
if (self != nil) |
51 |
{ |
{ |
52 |
_text = RETAIN (text); |
_text = RETAIN (text); |
53 |
|
_uiText = [UiText textWithText: text |
54 |
|
height: [UiLabel _textSize]]; |
55 |
|
|
56 |
|
|
57 |
[self sizeToFit]; |
[self sizeToFit]; |
58 |
} |
} |
63 |
- (void) dealloc |
- (void) dealloc |
64 |
{ |
{ |
65 |
RELEASE(_text); |
RELEASE(_text); |
66 |
|
RELEASE(_uiText); |
67 |
|
|
68 |
[super dealloc]; |
[super dealloc]; |
69 |
} |
} |
80 |
NSParameterAssert (text); |
NSParameterAssert (text); |
81 |
NSParameterAssert ([text length] != 0); |
NSParameterAssert ([text length] != 0); |
82 |
|
|
83 |
RELEASE(_text); |
ASSIGN(_text, text); |
84 |
_text = RETAIN(text); |
ASSIGN(_uiText, [UiText textWithText: text |
85 |
|
height: [UiLabel _textSize]]); |
86 |
|
|
87 |
[self sizeToFit]; |
[self sizeToFit]; |
88 |
} |
} |
90 |
/** |
/** |
91 |
* method who calculate the width and the height of the widget. |
* method who calculate the width and the height of the widget. |
92 |
*/ |
*/ |
93 |
- (void) sizeToFit |
- (void) sizeToFit |
94 |
{ |
{ |
95 |
/* FIXME - not implemented */ |
[self setSize: [_uiText size]]; |
96 |
} |
} |
97 |
|
|
98 |
|
|
99 |
|
- (void) display |
100 |
|
{ |
101 |
|
[super display]; |
102 |
|
|
103 |
|
glColor3f (0.0, 0.0, 0.0); |
104 |
|
[_uiText display]; |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
@end |
@end |