Permalink
Browse files

Added parameter to drawInContext to specify whether hyperlinks should…

… be drawn.
  • Loading branch information...
1 parent 73afbb8 commit 119420b6536bac6fd64e6ff6a81e9729d2fbcc5d @odrobnik odrobnik committed Aug 29, 2012
Showing with 13 additions and 3 deletions.
  1. +3 −2 Core/Source/DTCoreTextLayoutFrame.h
  2. +10 −1 Core/Source/DTCoreTextLayoutFrame.m
@@ -106,9 +106,10 @@ typedef void (^DTCoreTextLayoutFrameTextBlockHandler)(DTTextBlock *textBlock, CG
Draws the entire layout frame into the given graphics context.
@param context A graphics context to draw into
- @param drawImages Whether images should be draw together with the text. If you specify `NO` then space is left blank where images would go and you have to add your own views to display these images.
+ @param drawImages Whether images should be drawn together with the text. If you specify `NO` then space is left blank where images would go and you have to add your own views to display these images.
+ @param drawImages Whether hyperlinks should be drawn together with the text. If you specify `NO` then space is left blank where links would go and you have to add your own views to display these links.
*/
-- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages;
+- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLinks:(BOOL)drawLinks;
/**
@@ -682,7 +682,7 @@ - (CGRect)_frameForTextBlock:(DTTextBlock *)textBlock atIndex:(NSUInteger)locati
return frame;
}
-- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages
+- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLinks:(BOOL)drawLinks
{
CGContextSaveGState(context);
@@ -805,6 +805,10 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages
runIndex ++;
}
+ if (!drawLinks && oneRun.isHyperlink)
+ {
+ continue;
+ }
CGColorRef backgroundColor = (__bridge CGColorRef)[oneRun.attributes objectForKey:DTBackgroundColorAttribute];
@@ -940,6 +944,11 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages
continue;
}
+ if (!drawLinks && oneRun.isHyperlink)
+ {
+ continue;
+ }
+
CGPoint textPosition = CGPointMake(oneLine.frame.origin.x, self.frame.size.height - oneRun.frame.origin.y - oneRun.ascent);
NSInteger superscriptStyle = [[oneRun.attributes objectForKey:(id)kCTSuperscriptAttributeName] integerValue];

0 comments on commit 119420b

Please sign in to comment.