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 94 95 96 97 98 99 100
|
/* FreeJ
* (c) Copyright 2009 Andrea Guzzo <xant@dyne.org>
*
* This source code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Public License as published
* by the Free Software Foundation; either version 3 of the License,
* or (at your option) any later version.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please refer to the GNU Public License for more details.
*
* You should have received a copy of the GNU Public License along with
* this source code; if not, write to:
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
//
// GLString.h
//
// Imported from apple "CocoaGL" example and extended
// to fit freej integration.
#import <Cocoa/Cocoa.h>
#import <OpenGL/gl.h>
#import <OpenGL/glext.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/CGLContext.h>
#include <QuartzCore/CVPixelBuffer.h>
@interface NSBezierPath (RoundRect)
+ (NSBezierPath *)bezierPathWithRoundedRect:(NSRect)rect cornerRadius:(float)radius;
- (void)appendBezierPathWithRoundedRect:(NSRect)rect cornerRadius:(float)radius;
@end
@interface GLString : NSObject {
CGLContextObj cgl_ctx; // current context at time of texture creation
GLuint texName;
NSSize texSize;
NSAttributedString * string;
NSColor * textColor; // default is opaque white
NSColor * boxColor; // default transparent or none
NSColor * borderColor; // default transparent or none
BOOL staticFrame; // default in NO
BOOL antialias; // default to YES
NSSize marginSize; // offset or frame size, default is 4 width 2 height
NSSize frameSize; // offset or frame size, default is 4 width 2 height
float cRadius; // Corner radius, if 0 just a rectangle. Defaults to 4.0f
NSImage * image;
NSBitmapImageRep * bitmap;
BOOL requiresUpdate;
}
// this API requires a current rendering context and all operations will be performed in regards to thar context
// the same context should be current for all method calls for a particular object instance
// designated initializer
- (id) initWithAttributedString:(NSAttributedString *)attributedString;
- (id) initWithString:(NSString *)aString withFont:font withTextColor:(NSColor *)text BoxColor:(NSColor *)box BorderColor:(NSColor *)border;
- (id) initWithString:(NSString *)aString withAttributes:(NSDictionary *)attribs;
- (void) dealloc;
- (GLuint) texName; // 0 if no texture allocated
- (NSSize) texSize; // actually size of texture generated in texels, (0, 0) if no texture allocated
- (NSColor *) textColor; // get the pre-multiplied default text color (includes alpha) string attributes could override this
- (NSColor *) boxColor; // get the pre-multiplied box color (includes alpha) alpha of 0.0 means no background box
- (NSColor *) borderColor; // get the pre-multiplied border color (includes alpha) alpha of 0.0 means no border
- (BOOL) staticFrame; // returns whether or not a static frame will be used
- (NSSize) frameSize; // returns either dynamc frame (text size + margins) or static frame size (switch with staticFrame)
- (NSSize) marginSize; // current margins for text offset and pads for dynamic frame
// these will force the texture to be regenerated at the next draw
- (void) setMargins:(NSSize)size; // set offset size and size to fit with offset
- (void) useStaticFrame:(NSSize)size; // set static frame size and size to frame
- (void) useDynamicFrame; // set static frame size and size to frame
- (void) setString:(NSAttributedString *)attributedString; // set string after initial creation
- (void) setString:(NSString *)aString withAttributes:(NSDictionary *)attribs; // set string after initial creation
- (void) setTextColor:(NSColor *)color; // set default text color
- (void) setBoxColor:(NSColor *)color; // set default text color
- (void) setBorderColor:(NSColor *)color; // set default text color
- (BOOL) antialias;
- (void) setAntialias:(bool)request;
- (CVPixelBufferRef) drawOnBuffer:(CVPixelBufferRef)pixelBuffer;
@end
|