diff options
author | nyamatongwe <unknown> | 2009-05-14 12:10:06 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2009-05-14 12:10:06 +0000 |
commit | 805e109be2f52c0ea446511fc33efb3746a3bc18 (patch) | |
tree | 3b57cf166d494a0dba47befcea94deba3da0fbda /cocoa/QuartzTextStyle.h | |
parent | 8e12be32e9d14363f1e2f0fe6fc305b68a64ceb5 (diff) | |
download | scintilla-mirror-805e109be2f52c0ea446511fc33efb3746a3bc18.tar.gz |
First upload of Cocoa platform from Mike Lischke at Sun.
Diffstat (limited to 'cocoa/QuartzTextStyle.h')
-rw-r--r-- | cocoa/QuartzTextStyle.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/cocoa/QuartzTextStyle.h b/cocoa/QuartzTextStyle.h new file mode 100644 index 000000000..36729b77b --- /dev/null +++ b/cocoa/QuartzTextStyle.h @@ -0,0 +1,90 @@ +/* + * QuartzTextStyle.h + * + * Created by Evan Jones on Wed Oct 02 2002. + * + */ + +#ifndef _QUARTZ_TEXT_STYLE_H +#define _QUARTZ_TEXT_STYLE_H + +#include "QuartzTextStyleAttribute.h" + +class QuartzTextStyle +{ +public: + QuartzTextStyle() + { + ATSUCreateStyle( &style ); + } + + ~QuartzTextStyle() + { + if ( style != NULL ) + ATSUDisposeStyle( style ); + style = NULL; + } + + void setAttribute( ATSUAttributeTag tag, ByteCount size, ATSUAttributeValuePtr value ) + { + ATSUSetAttributes( style, 1, &tag, &size, &value ); + } + + void setAttribute( QuartzTextStyleAttribute& attribute ) + { + setAttribute( attribute.getTag(), attribute.getSize(), attribute.getValuePtr() ); + } + + void getAttribute( ATSUAttributeTag tag, ByteCount size, ATSUAttributeValuePtr value, ByteCount* actualSize ) + { + ATSUGetAttribute( style, tag, size, value, actualSize ); + } + + template <class T> + T getAttribute( ATSUAttributeTag tag ) + { + T value; + ByteCount actualSize; + ATSUGetAttribute( style, tag, sizeof( T ), &value, &actualSize ); + return value; + } + + // TODO: Is calling this actually faster than calling setAttribute multiple times? + void setAttributes( QuartzTextStyleAttribute* attributes[], int number ) + { + // Create the parallel arrays and initialize them properly + ATSUAttributeTag* tags = new ATSUAttributeTag[ number ]; + ByteCount* sizes = new ByteCount[ number ]; + ATSUAttributeValuePtr* values = new ATSUAttributeValuePtr[ number ]; + + for ( int i = 0; i < number; ++ i ) + { + tags[i] = attributes[i]->getTag(); + sizes[i] = attributes[i]->getSize(); + values[i] = attributes[i]->getValuePtr(); + } + + ATSUSetAttributes( style, number, tags, sizes, values ); + + // Free the arrays that were allocated + delete[] tags; + delete[] sizes; + delete[] values; + } + + void setFontFeature( ATSUFontFeatureType featureType, ATSUFontFeatureSelector selector ) + { + ATSUSetFontFeatures( style, 1, &featureType, &selector ); + } + + const ATSUStyle& getATSUStyle() const + { + return style; + } + +private: + ATSUStyle style; +}; + +#endif + |