RSS

(root)/iphone/common : 65 : source/GLString.m

To get this branch, use:
bzr branch /browse/iphone/common

« back to all changes in this revision

Viewing changes to source/GLString.m

Dömötör Gulyás
2010-07-04 17:06:19
Revision ID: dognotdog@gmail.com-20100704150619-3vjoon64s20bvxxw
improved device detection; adds CGPosition animation; adds GLString classes

Show diffs side-by-side

added added

removed removed

 
1
 
 
2
#import "GLString.h"
 
3
#import "gfx.h"
 
4
#import "VertexArray.h"
 
5
 
 
6
#import <OpenGLES/ES2/gl.h>
 
7
#import <CoreGraphics/CoreGraphics.h>
 
8
 
 
9
 
 
10
// The following is a NSBezierPath category to allow
 
11
// for rounded corners of the border
 
12
 
 
13
 
 
14
 
 
15
#pragma mark -
 
16
 
 
17
@implementation GLQuartzTexture
 
18
 
 
19
- (id) init
 
20
{
 
21
        if (!(self = [super init]))
 
22
                return nil;
 
23
 
 
24
        antialias = YES;
 
25
        subpixelAA = YES;
 
26
        filterTexture = NO;
 
27
        
 
28
        texturePadding = 1.0;
 
29
        requiresUpdate = YES;
 
30
 
 
31
        return self;
 
32
}
 
33
 
 
34
- (void) finalize
 
35
{
 
36
        if (texName)
 
37
                [GLResourceDisposal disposeOfResourcesWithTypes: texName, GL_TEXTURE, NULL];
 
38
 
 
39
        [super finalize];
 
40
}
 
41
 
 
42
- (void) deleteTexture
 
43
{
 
44
        if (texName)
 
45
        {
 
46
                glDeleteTextures(1, &texName);
 
47
                texName = 0;
 
48
                requiresUpdate = YES;
 
49
                textureSize = CGSizeZero;
 
50
        }
 
51
}
 
52
 
 
53
- (void) freeGLResources
 
54
{
 
55
        [self deleteTexture];
 
56
}
 
57
 
 
58
- (void) updateTextureIfRequired
 
59
{
 
60
        if (requiresUpdate)
 
61
                [self genTexture];
 
62
}
 
63
 
 
64
- (void) bindTexture
 
65
{
 
66
        if (!texName)
 
67
                [self genTexture];
 
68
        glBindTexture(GL_TEXTURE_2D, texName);
 
69
}
 
70
 
 
71
- (void) setAntialias:(BOOL)request
 
72
{
 
73
        antialias = request;
 
74
        requiresUpdate = YES;
 
75
}
 
76
 
 
77
- (void) setSubpixelAA:(BOOL)request
 
78
{
 
79
        subpixelAA = request;
 
80
        requiresUpdate = YES;
 
81
}
 
82
 
 
83
- (void) setFilterTexture:(BOOL)request
 
84
{
 
85
        filterTexture = request;
 
86
        requiresUpdate = YES;
 
87
}
 
88
 
 
89
- (void) setMipmapTexture:(BOOL)request
 
90
{
 
91
        mipmapTexture = request;
 
92
        requiresUpdate = YES;
 
93
}
 
94
 
 
95
- (void) setTexturePadding:(double)rad
 
96
{
 
97
        texturePadding = rad;
 
98
        requiresUpdate = YES;
 
99
}
 
100
 
 
101
- (void) doQuartzDrawingInContext: (CGContextRef) context sized: (CGSize) imgSize
 
102
{
 
103
}
 
104
 
 
105
- (void) generateTextureSized: (CGSize) texSize; // generates the texture without drawing texture to current context
 
106
{               
 
107
        CGSize previousSize = textureSize;
 
108
        
 
109
        int width = texSize.width;
 
110
        int height = texSize.height;
 
111
 
 
112
        void* spriteData = calloc(1, width * height * 4);
 
113
        
 
114
        
 
115
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
 
116
        CGContextRef spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, colorSpace, kCGImageAlphaPremultipliedLast);
 
117
        assert(spriteContext);
 
118
        
 
119
        UIGraphicsPushContext(spriteContext);
 
120
 
 
121
        CGContextSetShouldSmoothFonts(spriteContext, subpixelAA);
 
122
 
 
123
        [self doQuartzDrawingInContext: spriteContext sized: texSize];
 
124
 
 
125
        UIGraphicsPopContext();
 
126
        CGContextRelease(spriteContext);
 
127
        CGColorSpaceRelease(colorSpace);
 
128
        
 
129
        if (!texName)
 
130
                glGenTextures(1, &texName);
 
131
        glBindTexture(GL_TEXTURE_2D, texName);
 
132
 
 
133
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData);
 
134
 
 
135
        free(spriteData);
 
136
 
 
137
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 
138
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
139
 
 
140
        if (mipmapTexture)
 
141
                glGenerateMipmap(GL_TEXTURE_2D);
 
142
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterTexture ? (mipmapTexture ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) : GL_NEAREST);
 
143
 
 
144
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterTexture ? GL_LINEAR : GL_NEAREST);
 
145
        
 
146
        textureSize = texSize;
 
147
        
 
148
        requiresUpdate = NO;
 
149
}
 
150
 
 
151
- (CGSize) updatedTextureSize
 
152
{
 
153
        return CGSizeZero;
 
154
}
 
155
 
 
156
- (void) genTexture
 
157
{
 
158
        [self generateTextureSized: [self updatedTextureSize]];
 
159
}
 
160
 
 
161
- (CGSize) textureSize
 
162
{
 
163
        if (requiresUpdate)
 
164
                return [self updatedTextureSize];
 
165
        else
 
166
                return textureSize;
 
167
}
 
168
 
 
169
- (void) drawWithBounds:(CGRect)bounds
 
170
{
 
171
        [self updateTextureIfRequired];
 
172
 
 
173
        if ([self texName])
 
174
        {
 
175
                
 
176
                //glDisable (GL_DEPTH_TEST); // ensure text is not remove by depth buffer test.
 
177
                //glEnable (GL_BLEND); // for text fading
 
178
                //glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // ditto
 
179
                glEnable (GL_TEXTURE_2D);       
 
180
                
 
181
                glBindTexture (GL_TEXTURE_2D, [self texName]);
 
182
                
 
183
                [[VertexArray sharedQuad] draw];
 
184
                
 
185
        }
 
186
}
 
187
 
 
188
- (void) drawAtPoint:(CGPoint)point scaled: (double) scale
 
189
{
 
190
        [self drawWithBounds: CGRectMake(point.x-[self texturePadding]*scale, point.y-[self texturePadding]*scale, [self textureSize].width*scale, [self textureSize].height*scale)];
 
191
}
 
192
- (void) drawAtPoint:(CGPoint)point
 
193
{
 
194
        [self drawAtPoint: point scaled: 1.0];
 
195
}
 
196
 
 
197
- (void) drawCenteredAtPoint:(CGPoint)point scaled: (double) scale
 
198
{
 
199
        [self drawWithBounds: CGRectMake(point.x-0.5*[self textureSize].width*scale, point.y-0.5*[self textureSize].height*scale, [self textureSize].width*scale, [self textureSize].height*scale)];
 
200
}
 
201
- (void) drawCenteredAtPoint:(CGPoint)point
 
202
{
 
203
        [self drawCenteredAtPoint: point scaled: 1.0];
 
204
}
 
205
 
 
206
 
 
207
@synthesize antialias, subpixelAA, texturePadding, filterTexture, mipmapTexture, textureSize, texName;
 
208
 
 
209
@end
 
210
 
 
211
#pragma mark -
 
212
 
 
213
@implementation GLQuartzBox
 
214
 
 
215
- (id) init
 
216
{
 
217
        if (!(self = [super init]))
 
218
                return nil;
 
219
 
 
220
        cornerRadius = 4.0;
 
221
        borderWidth = 1.0;
 
222
//      borderColor = [NSColor clearColor];
 
223
 
 
224
        return self;
 
225
}
 
226
 
 
227
CGPathRef CGPathWithRoundedRect(CGRect rect, CGFloat r)
 
228
{
 
229
        CGMutablePathRef path = CGPathCreateMutable();
 
230
        CGPathMoveToPoint(path, NULL,
 
231
                rect.origin.x + rect.size.width - r,    rect.origin.y);
 
232
        CGPathAddArcToPoint(path, NULL,
 
233
                rect.origin.x + rect.size.width,                rect.origin.y,
 
234
                rect.origin.x + rect.size.width,                rect.origin.y + r, r);
 
235
        CGPathAddLineToPoint(path, NULL,
 
236
                rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - r);
 
237
        CGPathAddArcToPoint(path, NULL,
 
238
                rect.origin.x + rect.size.width,                rect.origin.y + rect.size.height,
 
239
                rect.origin.x + rect.size.width - r,    rect.origin.y + rect.size.height, r);
 
240
        CGPathAddLineToPoint(path, NULL,
 
241
                rect.origin.x + r, rect.origin.y + rect.size.height);
 
242
        CGPathAddArcToPoint(path, NULL,
 
243
                rect.origin.x,                                                  rect.origin.y + rect.size.height,
 
244
                rect.origin.x,                                                  rect.origin.y + rect.size.height - r, r);
 
245
        CGPathAddLineToPoint(path, NULL,
 
246
                rect.origin.x, rect.origin.y + r);
 
247
        CGPathAddArcToPoint(path, NULL,
 
248
                rect.origin.x,                                                  rect.origin.y,
 
249
                rect.origin.x + r,                                              rect.origin.y, r);
 
250
        CGPathAddLineToPoint(path, NULL,
 
251
                rect.origin.x + r,                                              rect.origin.y);
 
252
                
 
253
        CGPathCloseSubpath(path);
 
254
        return path;
 
255
}
 
256
 
 
257
- (void) doQuartzDrawingInContext: (CGContextRef) context sized: (CGSize) imgSize
 
258
{
 
259
        float borderAlpha = 0.0;
 
260
        float boxAlpha = 0.0;
 
261
                
 
262
        if (borderColor)
 
263
                borderAlpha = CGColorGetAlpha([borderColor CGColor]);
 
264
        if (boxColor)
 
265
                boxAlpha = CGColorGetAlpha([boxColor CGColor]);
 
266
 
 
267
        double bw = (borderAlpha ? borderWidth : 0.0);
 
268
        
 
269
        if (boxAlpha)
 
270
        { // this should be == 0.0f but need to make sure
 
271
                [boxColor set];
 
272
                CGPathRef path = CGPathWithRoundedRect(CGRectInset(CGRectMake(texturePadding, texturePadding, frameSize.width, frameSize.height), 0.5*borderWidth, 0.5*borderWidth), cornerRadius);
 
273
                CGContextAddPath(context, path);
 
274
                CGContextDrawPath(context, kCGPathFill);
 
275
        }
 
276
 
 
277
        if (borderAlpha)
 
278
        {
 
279
                [borderColor set]; 
 
280
                CGPathRef path = CGPathWithRoundedRect(CGRectInset(CGRectMake(texturePadding, texturePadding, frameSize.width, frameSize.height), 0.5*borderWidth, 0.5*borderWidth), cornerRadius);
 
281
 
 
282
                CGContextAddPath(context, path);
 
283
                CGContextSetLineWidth(context, bw);
 
284
                CGContextDrawPath(context, kCGPathStroke);
 
285
        }
 
286
        
 
287
}
 
288
 
 
289
- (CGSize) updatedTextureSize
 
290
{
 
291
        CGSize texSize = CGSizeMake(ceil(frameSize.width+2.0*texturePadding), ceil(frameSize.height+2.0*texturePadding));
 
292
        return texSize;
 
293
}
 
294
 
 
295
- (void) setBoxColor:(UIColor *)color // set default text color
 
296
{
 
297
        [boxColor autorelease];
 
298
        boxColor = [color retain];
 
299
        requiresUpdate = YES;
 
300
}
 
301
 
 
302
 
 
303
- (void) setBorderColor:(UIColor *)color // set default text color
 
304
{
 
305
        [borderColor autorelease];
 
306
        borderColor = [color retain];
 
307
        requiresUpdate = YES;
 
308
}
 
309
 
 
310
- (void) setCornerRadius:(double)rad
 
311
{
 
312
        cornerRadius = rad;
 
313
        requiresUpdate = YES;
 
314
}
 
315
 
 
316
- (void) setBorderWidth:(double)rad
 
317
{
 
318
        borderWidth = rad;
 
319
        requiresUpdate = YES;
 
320
}
 
321
 
 
322
@synthesize cornerRadius, borderWidth, boxColor, borderColor, frameSize;
 
323
 
 
324
@end
 
325
 
 
326
#pragma mark -
 
327
 
 
328
@implementation GLQuartzArc
 
329
 
 
330
- (id) init
 
331
{
 
332
        if (!(self = [super init]))
 
333
                return nil;
 
334
 
 
335
        outerRadius = 10.0;
 
336
        borderWidth = 1.0;
 
337
        endAngle = 2.0*M_PI;
 
338
        cornerRadius = 5.0;
 
339
 
 
340
        return self;
 
341
}
 
342
 
 
343
- (void) doQuartzDrawingInContext: (CGContextRef) context sized: (CGSize) imgSize // generates the texture without drawing texture to current context
 
344
{
 
345
        double bw = (CGColorGetAlpha([borderColor CGColor]) ? borderWidth : 0.0);
 
346
        
 
347
//      double meanRadius = 0.5*(innerRadius+outerRadius);
 
348
//      double rdiff = (outerRadius-innerRadius);
 
349
        double angleRange = endAngle - startAngle;
 
350
//      double innerOffset = texturePadding + rdiff;
 
351
        
 
352
        double cornerCenterRadius = outerRadius - cornerRadius;
 
353
        double cornerAngle = cornerRadius/cornerCenterRadius;
 
354
        
 
355
        BOOL fullCircle = (angleRange > 2.0*M_PI*(1.0-FLT_EPSILON));
 
356
        
 
357
        if (fullCircle)
 
358
        {
 
359
                cornerAngle = 0.0;
 
360
                cornerCenterRadius = outerRadius;
 
361
                endAngle = 2.0*M_PI + startAngle;
 
362
        }
 
363
                
 
364
        double startArc = startAngle + cornerAngle;
 
365
        double endArc = endAngle - cornerAngle;
 
366
        
 
367
        CGPoint center = CGPointMake(imgSize.width*0.5, imgSize.height*0.5);
 
368
        
 
369
        CGMutablePathRef path = CGPathCreateMutable();
 
370
//      [path setLineJoinStyle: NSRoundLineJoinStyle];
 
371
//      [path setLineJoinStyle: NSBevelLineJoinStyle];
 
372
 
 
373
        CGPathMoveToPoint(path, NULL, center.x + cos(startAngle)*cornerCenterRadius, center.y + sin(startAngle)*cornerCenterRadius);
 
374
        
 
375
        double startArcDegrees = 180.0/M_PI*startArc;
 
376
        double endArcDegrees = 180.0/M_PI*endArc;
 
377
        double startAngleDegrees = 180.0/M_PI*startAngle;
 
378
        double endAngleDegrees = 180.0/M_PI*endAngle;
 
379
        
 
380
        if (!fullCircle && (cornerRadius > 0.0))
 
381
        {
 
382
                CGPoint cc = CGPointMake(center.x + cos(startArc)*cornerCenterRadius, center.y + sin(startArc)*cornerCenterRadius);
 
383
                CGPathAddArc(path, NULL, cc.x, cc.y, cornerRadius, startAngleDegrees - 90.0, startArcDegrees, NO);
 
384
        }
 
385
        
 
386
        CGPathAddArc(path, NULL, center.x, center.y, cornerRadius, startArcDegrees, endArcDegrees, NO);
 
387
 
 
388
        if (!fullCircle && (cornerRadius > 0.0))
 
389
        {
 
390
                CGPoint cc = CGPointMake(center.x + cos(endArc)*cornerCenterRadius, center.y + sin(endArc)*cornerCenterRadius);
 
391
                CGPathAddArc(path, NULL, cc.x, cc.y, cornerRadius, endAngleDegrees, endArcDegrees + 90, NO);
 
392
        }
 
393
        
 
394
 
 
395
        if (innerRadius > 0.0)
 
396
        {
 
397
                if (fullCircle)
 
398
                {
 
399
                        CGPathCloseSubpath(path);
 
400
                        CGPathMoveToPoint(path, NULL, center.x + cos(endArc)*innerRadius, center.y + sin(endArc)*innerRadius);
 
401
                }
 
402
        
 
403
                CGPathAddArc(path, NULL, center.x, center.y, innerRadius, endArcDegrees, startArcDegrees, YES);
 
404
 
 
405
 
 
406
        }
 
407
        else if (!fullCircle)
 
408
                CGPathAddLineToPoint(path, NULL, center.x, center.y);
 
409
 
 
410
        CGPathCloseSubpath(path);
 
411
 
 
412
        if (CGColorGetAlpha([fillColor CGColor]))
 
413
        { // this should be == 0.0f but need to make sure
 
414
                [fillColor set];
 
415
                CGContextAddPath(context, path);
 
416
                CGContextDrawPath(context, kCGPathFill);
 
417
        }
 
418
 
 
419
        if (CGColorGetAlpha([borderColor CGColor]))
 
420
        {
 
421
                [borderColor set];
 
422
                CGContextSetLineWidth(context, bw);
 
423
                CGContextAddPath(context, path);
 
424
                CGContextDrawPath(context, kCGPathStroke);
 
425
        }
 
426
        
 
427
}
 
428
 
 
429
- (CGSize) updatedTextureSize
 
430
{
 
431
        CGSize texSize = CGSizeMake(ceil(2.0*outerRadius+2.0*texturePadding), ceil(2.0*outerRadius+2.0*texturePadding));
 
432
        return texSize;
 
433
}
 
434
 
 
435
- (void) setFillColor:(UIColor *)color
 
436
{
 
437
        [fillColor autorelease];
 
438
        fillColor = [color retain];
 
439
        requiresUpdate = YES;
 
440
}
 
441
 
 
442
 
 
443
- (void) setBorderColor:(UIColor *)color
 
444
{
 
445
        [borderColor autorelease];
 
446
        borderColor = [color retain];
 
447
        requiresUpdate = YES;
 
448
}
 
449
 
 
450
- (void) setOuterRadius:(double)rad
 
451
{
 
452
        outerRadius = rad;
 
453
        requiresUpdate = YES;
 
454
}
 
455
 
 
456
- (void) setInnerRadius:(double)rad
 
457
{
 
458
        innerRadius = rad;
 
459
        requiresUpdate = YES;
 
460
}
 
461
 
 
462
- (void) setBorderWidth:(double)rad
 
463
{
 
464
        borderWidth = rad;
 
465
        requiresUpdate = YES;
 
466
}
 
467
 
 
468
- (void) setCornerRadius:(double)rad
 
469
{
 
470
        cornerRadius = rad;
 
471
        requiresUpdate = YES;
 
472
}
 
473
 
 
474
- (void) setStartAngle:(double)rad
 
475
{
 
476
        startAngle = rad;
 
477
        requiresUpdate = YES;
 
478
}
 
479
 
 
480
- (void) setEndAngle:(double)rad
 
481
{
 
482
        endAngle = rad;
 
483
        requiresUpdate = YES;
 
484
}
 
485
 
 
486
@synthesize innerRadius, outerRadius, startAngle, endAngle, borderWidth, cornerRadius, fillColor, borderColor;
 
487
 
 
488
@end
 
489
 
 
490
#pragma mark -
 
491
 
 
492
@implementation GLString
 
493
 
 
494
+ (UIFont*) defaultFont
 
495
{
 
496
        UIFont*         font = [UIFont systemFontOfSize: [UIFont systemFontSize]];
 
497
        return font;
 
498
}
 
499
 
 
500
 
 
501
#pragma mark -
 
502
#pragma mark Initializers
 
503
 
 
504
// designated initializer
 
505
- (id) initWithString:(NSString *)aString withFont: (UIFont*) aFont withTextColor:(UIColor *)text withBoxColor:(UIColor *)box withBorderColor:(UIColor *)border
 
506
{
 
507
        if (!(self = [super init]))
 
508
                return nil;
 
509
 
 
510
        string = aString;
 
511
        
 
512
        font = [aFont retain];
 
513
 
 
514
        self.textColor = text;
 
515
        self.boxColor = box;
 
516
        self.borderColor = border;
 
517
        staticFrame = NO;
 
518
        marginSize.width = 4.0f; // standard margins
 
519
        marginSize.height = 2.0f;
 
520
 
 
521
        return self;
 
522
}
 
523
 
 
524
// basic methods that pick up defaults
 
525
- (id) initWithString:(NSString *)astring;
 
526
{
 
527
        return [self initWithString: astring withFont: [GLString defaultFont] withTextColor:[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f] withBoxColor:[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.0f] withBorderColor:[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.0f]];
 
528
}
 
529
 
 
530
- (id) initWithString:(NSString *)aString withFont:(UIFont *)aFont
 
531
{
 
532
        return [self initWithString: aString withFont: aFont withTextColor: nil withBoxColor: nil withBorderColor: nil];
 
533
}
 
534
 
 
535
- (CGSize) frameSize
 
536
{
 
537
        if (NO == staticFrame)
 
538
        { // find frame size if we have not already found it
 
539
                frameSize = [string sizeWithFont: font]; // current string size
 
540
                frameSize.width += marginSize.width * 2.0f; // add padding
 
541
                frameSize.height += marginSize.height * 2.0f;
 
542
        }
 
543
        return frameSize;
 
544
}
 
545
 
 
546
- (CGSize) updatedTextureSize
 
547
{
 
548
        if (NO == staticFrame)
 
549
        { // find frame size if we have not already found it
 
550
                frameSize = [string sizeWithFont: font]; // current string size
 
551
                frameSize.width += marginSize.width * 2.0f; // add padding
 
552
                frameSize.height += marginSize.height * 2.0f;
 
553
        }
 
554
        return [super updatedTextureSize];
 
555
}
 
556
 
 
557
- (void) doQuartzDrawingInContext: (CGContextRef) context sized: (CGSize) imgSize // generates the texture without drawing texture to current context
 
558
{
 
559
        
 
560
        [super doQuartzDrawingInContext: context sized: imgSize];
 
561
        
 
562
        [textColor set]; 
 
563
        [string drawAtPoint: CGPointMake(marginSize.width+texturePadding, marginSize.height+texturePadding) withFont: font]; // draw at offset position
 
564
}
 
565
 
 
566
 
 
567
- (void) setTextColor:(UIColor *)color // set default text color
 
568
{
 
569
        [textColor autorelease];
 
570
        textColor = [color retain];
 
571
        requiresUpdate = YES;
 
572
}
 
573
 
 
574
 
 
575
#pragma mark Margin Size
 
576
 
 
577
// these will force the texture to be regenerated at the next draw
 
578
- (void) setMargins:(CGSize)size // set offset size and size to fit with offset
 
579
{
 
580
        marginSize = size;
 
581
        if (NO == staticFrame) { // ensure dynamic frame sizes will be recalculated
 
582
                frameSize.width = 0.0f;
 
583
                frameSize.height = 0.0f;
 
584
        }
 
585
        requiresUpdate = YES;
 
586
}
 
587
 
 
588
- (CGSize) marginSize
 
589
{
 
590
        return marginSize;
 
591
}
 
592
 
 
593
 
 
594
#pragma mark Frame
 
595
 
 
596
 
 
597
- (BOOL) staticFrame
 
598
{
 
599
        return staticFrame;
 
600
}
 
601
 
 
602
- (void) useStaticFrame:(CGSize)size // set static frame size and size to frame
 
603
{
 
604
        requiresUpdate = requiresUpdate || !staticFrame || !CGSizeEqualToSize(frameSize,size);
 
605
        frameSize = size;
 
606
        staticFrame = YES;
 
607
}
 
608
 
 
609
- (void) useDynamicFrame
 
610
{
 
611
        if (staticFrame) { // set to dynamic frame and set to regen texture
 
612
                staticFrame = NO;
 
613
                frameSize.width = 0.0f; // ensure frame sizes will be recalculated
 
614
                frameSize.height = 0.0f;
 
615
                requiresUpdate = YES;
 
616
        }
 
617
}
 
618
 
 
619
#pragma mark String
 
620
 
 
621
- (void) setString:(NSString *)theString // set string after initial creation
 
622
{
 
623
        [string autorelease];
 
624
        string = [theString copy];
 
625
        if (NO == staticFrame) { // ensure dynamic frame sizes will be recalculated
 
626
                frameSize.width = 0.0f;
 
627
                frameSize.height = 0.0f;
 
628
        }
 
629
        requiresUpdate = YES;
 
630
}
 
631
 
 
632
- (void) setFont: (UIFont*) aFont
 
633
{
 
634
        [font release];
 
635
        font = [aFont retain];
 
636
        if (NO == staticFrame) { // ensure dynamic frame sizes will be recalculated
 
637
                frameSize.width = 0.0f;
 
638
                frameSize.height = 0.0f;
 
639
        }
 
640
        requiresUpdate = YES;
 
641
}
 
642
 
 
643
@synthesize textColor;
 
644
 
 
645
@end

Loggerhead 1.17 is a web-based interface for Bazaar branches