Skip to content

Commit

Permalink
Added parameter to drawInContext to specify whether hyperlinks should…
Browse files Browse the repository at this point in the history
… be drawn.
  • Loading branch information
odrobnik committed Aug 29, 2012
1 parent 73afbb8 commit 119420b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Core/Source/DTCoreTextLayoutFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand Down
11 changes: 10 additions & 1 deletion Core/Source/DTCoreTextLayoutFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 119420b

Please sign in to comment.