DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
/* * QuartzTextLayout.h * * Original Code by Evan Jones on Wed Oct 02 2002. * Contributors: * Shane Caraveo, ActiveState * Bernd Paradies, Adobe * */ #ifndef _QUARTZ_TEXT_LAYOUT_H #define _QUARTZ_TEXT_LAYOUT_H #include
#include "QuartzTextStyle.h" class QuartzTextLayout { public: /** Create a text layout for drawing on the specified context. */ QuartzTextLayout( CGContextRef context ) : layout( NULL ), unicode_string( NULL ), unicode_length( 0 ) { OSStatus err = ATSUCreateTextLayout( &layout ); if (0 != err) layout = NULL; setContext(context); ATSUAttributeTag tag = kATSULineLayoutOptionsTag; ByteCount size = sizeof( ATSLineLayoutOptions ); ATSLineLayoutOptions rendering = kATSLineUseDeviceMetrics; //| kATSLineFractDisable | kATSLineUseQDRendering ATSUAttributeValuePtr valuePtr = &rendering; err = ATSUSetLayoutControls( layout, 1, &tag, &size, &valuePtr ); } ~QuartzTextLayout() { if (NULL != layout) ATSUDisposeTextLayout( layout ); layout = NULL; if ( unicode_string != NULL ) { delete[] unicode_string; unicode_string = NULL; unicode_length = 0; } } /** Assign a string to the text layout object. */ // TODO: Create a UTF8 version // TODO: Optimise the ASCII version by not copying so much OSStatus setText( const UInt8* buffer, size_t byteLength, CFStringEncoding encoding ) { if (NULL == layout) return -1; CFStringRef str = CFStringCreateWithBytes( NULL, buffer, byteLength, encoding, false ); if (!str) return -1; unicode_length = CFStringGetLength( str ); if (unicode_string) delete[] unicode_string; unicode_string = new UniChar[ unicode_length ]; CFStringGetCharacters( str, CFRangeMake( 0, unicode_length ), unicode_string ); CFRelease( str ); str = NULL; OSStatus err; err = ATSUSetTextPointerLocation( layout, unicode_string, kATSUFromTextBeginning, kATSUToTextEnd, unicode_length ); if( err != noErr ) return err; // Turn on the default font fallbacks return ATSUSetTransientFontMatching( layout, true ); } inline void setText( const UInt8* buffer, size_t byteLength, const QuartzTextStyle& r ) { this->setText( buffer, byteLength, kCFStringEncodingUTF8 ); ATSUSetRunStyle( layout, r.getATSUStyle(), 0, unicode_length ); } /** Apply the specified text style on the entire range of text. */ void setStyle( const QuartzTextStyle& style ) { ATSUSetRunStyle( layout, style.getATSUStyle(), kATSUFromTextBeginning, kATSUToTextEnd ); } /** Draw the text layout into the current CGContext at the specified position, flipping the CGContext's Y axis if required. * @param x The x axis position to draw the baseline in the current CGContext. * @param y The y axis position to draw the baseline in the current CGContext. * @param flipTextYAxis If true, the CGContext's Y axis will be flipped before drawing the text, and restored afterwards. Use this when drawing in an HIView's CGContext, where the origin is the top left corner. */ void draw( float x, float y, bool flipTextYAxis = false ) { if (NULL == layout || 0 == unicode_length) return; if ( flipTextYAxis ) { CGContextSaveGState( gc ); CGContextScaleCTM( gc, 1.0, -1.0 ); y = -y; } OSStatus err; err = ATSUDrawText( layout, kATSUFromTextBeginning, kATSUToTextEnd, X2Fix( x ), X2Fix( y ) ); if ( flipTextYAxis ) CGContextRestoreGState( gc ); } /** Sets a single text layout control on the ATSUTextLayout object. * @param tag The control to set. * @param size The size of the parameter pointed to by value. * @param value A pointer to the new value for the control. */ void setControl( ATSUAttributeTag tag, ByteCount size, ATSUAttributeValuePtr value ) { ATSUSetLayoutControls( layout, 1, &tag, &size, &value ); } ATSUTextLayout getLayout() { return layout; } inline CFIndex getLength() const { return unicode_length; } inline void setContext (CGContextRef context) { gc = context; if (NULL != layout) setControl( kATSUCGContextTag, sizeof( gc ), &gc ); } private: ATSUTextLayout layout; UniChar* unicode_string; int unicode_length; CGContextRef gc; }; #endif
QuartzTextLayout.h
Page URL
File URL
Prev
7/20
Next
Download
( 4 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.