diff options
author | scaraveo <unknown> | 2007-06-01 00:57:26 +0000 |
---|---|---|
committer | scaraveo <unknown> | 2007-06-01 00:57:26 +0000 |
commit | 710f716e96f6e9ee9eb410b343b78b3c4d95bc46 (patch) | |
tree | 55e5547869daa67b6a639c89825058baf75545c7 /macosx/QuartzTextStyleAttribute.h | |
parent | cac98b923422b91839f7c285a9b78ea282cd6f0a (diff) | |
download | scintilla-mirror-710f716e96f6e9ee9eb410b343b78b3c4d95bc46.tar.gz |
integrate OS X support for scintilla. a big patch with a little commit message :)
- now uses namespaces (optionally for non-os x) to avoid conflicts with OS X libraries
- several fixes in the OS X layer since the branch was commited in 2005
- used in Komodo since 2005, so pretty stable
Diffstat (limited to 'macosx/QuartzTextStyleAttribute.h')
-rw-r--r-- | macosx/QuartzTextStyleAttribute.h | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/macosx/QuartzTextStyleAttribute.h b/macosx/QuartzTextStyleAttribute.h new file mode 100644 index 000000000..490ef7d02 --- /dev/null +++ b/macosx/QuartzTextStyleAttribute.h @@ -0,0 +1,146 @@ +/* + * QuartzTextStyleAttribute.h + * wtf + * + * Created by Evan Jones on Wed Oct 02 2002. + * Copyright (c) 2002 __MyCompanyName__. All rights reserved. + * + */ + + +#include <Carbon/Carbon.h> + +#ifndef _QUARTZ_TEXT_STYLE_ATTRIBUTE_H +#define _QUARTZ_TEXT_STYLE_ATTRIBUTE_H + +class QuartzTextStyleAttribute +{ +public: + virtual ByteCount getSize() const = 0; + virtual ATSUAttributeValuePtr getValuePtr() = 0; + virtual ATSUAttributeTag getTag() const = 0; +}; + +class QuartzTextSize : public QuartzTextStyleAttribute +{ +public: + QuartzTextSize( float points ) + { + size = X2Fix( points ); + } + + ByteCount getSize() const + { + return sizeof( size ); + } + + ATSUAttributeValuePtr getValuePtr() + { + return &size; + } + + ATSUAttributeTag getTag() const + { + return kATSUSizeTag; + } + +private: + Fixed size; +}; + +class QuartzTextStyleAttributeBoolean : public QuartzTextStyleAttribute +{ +public: + QuartzTextStyleAttributeBoolean( bool newVal ) : value( newVal ) {} + + ByteCount getSize() const + { + return sizeof( value ); + } + ATSUAttributeValuePtr getValuePtr() + { + return &value; + } + + virtual ATSUAttributeTag getTag() const = 0; + +private: + Boolean value; +}; + +class QuartzTextBold : public QuartzTextStyleAttributeBoolean +{ +public: + QuartzTextBold( bool newVal ) : QuartzTextStyleAttributeBoolean( newVal ) {} + ATSUAttributeTag getTag() const + { + return kATSUQDBoldfaceTag; + } +}; + +class QuartzTextItalic : public QuartzTextStyleAttributeBoolean +{ +public: + QuartzTextItalic( bool newVal ) : QuartzTextStyleAttributeBoolean( newVal ) {} + ATSUAttributeTag getTag() const + { + return kATSUQDItalicTag; + } +}; + +class QuartzTextUnderline : public QuartzTextStyleAttributeBoolean +{ +public: + QuartzTextUnderline( bool newVal ) : QuartzTextStyleAttributeBoolean( newVal ) {} + ATSUAttributeTag getTag() const { + return kATSUQDUnderlineTag; + } +}; + +class QuartzFont : public QuartzTextStyleAttribute +{ +public: + /** Create a font style from a name. */ + QuartzFont( const char* name, int length ) + { + assert( name != NULL && length > 0 && name[length] == '\0' ); + /*CFStringRef fontName = CFStringCreateWithCString( NULL, name, kCFStringEncodingMacRoman ); + + ATSFontRef fontRef = ATSFontFindFromName( fontName, kATSOptionFlagsDefault ); + assert( fontRef != NULL ); + fontid = fontRef; + + CFRelease( fontName );*/ + + OSStatus err; + err = ATSUFindFontFromName( const_cast<char*>( name ), length, kFontFullName, (unsigned) kFontNoPlatform, kFontRomanScript, (unsigned) kFontNoLanguage, &fontid ); + //assert( err == noErr && fontid != kATSUInvalidFontID ); + } + + ByteCount getSize() const + { + return sizeof( fontid ); + } + + ATSUAttributeValuePtr getValuePtr() + { + return &fontid; + } + + ATSUAttributeTag getTag() const + { + return kATSUFontTag; + } + + ATSUFontID getFontID() const + { + return fontid; + } + +private: + ATSUFontID fontid; +}; + + +#endif + |