Permalink
Browse files

deprecated method and replaced with one with options bit mask

  • Loading branch information...
1 parent 45d0ce0 commit 80826ca7f10277310452c8a3710b8185a0f6a436 @odrobnik odrobnik committed Mar 21, 2013
@@ -408,8 +408,21 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
DTCoreTextLayoutFrame *theLayoutFrame = self.layoutFrame; // this is synchronized
+ // construct drawing options
+ DTCoreTextLayoutFrameDrawingOptions options = DTCoreTextLayoutFrameDrawingDefault;
+
+ if (!_shouldDrawImages)
+ {
+ options |= DTCoreTextLayoutFrameDrawingOmitAttachments;
+ }
+
+ if (!_shouldDrawImages)
+ {
+ options |= DTCoreTextLayoutFrameDrawingOmitLinks;
+ }
+
// need to prevent updating of string and drawing at the same time
- [theLayoutFrame drawInContext:ctx drawImages:_shouldDrawImages drawLinks:_shouldDrawLinks];
+ [theLayoutFrame drawInContext:ctx options:options];
if (_delegateFlags.delegateSupportsNotificationAfterDrawing)
{
@@ -420,7 +433,7 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
- [self.layoutFrame drawInContext:context drawImages:YES drawLinks:YES];
+ [self.layoutFrame drawInContext:context options:DTCoreTextLayoutFrameDrawingDefault];
}
- (void)relayoutText
@@ -22,6 +22,15 @@
typedef void (^DTCoreTextLayoutFrameTextBlockHandler)(DTTextBlock *textBlock, CGRect frame, CGContextRef context, BOOL *shouldDrawDefaultBackground);
+// the drawing options
+typedef enum
+{
+ DTCoreTextLayoutFrameDrawingDefault = 1<<0,
+ DTCoreTextLayoutFrameDrawingOmitLinks = 1<<1,
+ DTCoreTextLayoutFrameDrawingOmitAttachments = 1<<2,
+ DTCoreTextLayoutFrameDrawingDrawLinksHighlighted = 1<<3
+} DTCoreTextLayoutFrameDrawingOptions;
+
@class DTCoreTextLayouter;
@@ -113,14 +122,31 @@ typedef void (^DTCoreTextLayoutFrameTextBlockHandler)(DTTextBlock *textBlock, CG
/**
- Draws the entire layout frame into the given graphics context.
-
+ Draws the receiver into the given graphics context.
+
+ @warning This method is deprecated, use -[DTCoreTextLayoutFrame drawInContext:options:] instead
@param context A graphics context to draw into
@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 drawLinks 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 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 drawLinks:(BOOL)drawLinks;
+- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLinks:(BOOL)drawLinks __attribute__((deprecated("use -[DTCoreTextLayoutFrame drawInContext:options:] instead")));
+
+
+/**
+ Draws the receiver into the given graphics context.
+
+ Possible options are the following, you may combine them with a binary OR.
+
+ - DTCoreTextLayoutFrameDrawingDefault or 0
+ - DTCoreTextLayoutFrameDrawingOmitLinks
+ - DTCoreTextLayoutFrameDrawingOmitAttachments
+ - DTCoreTextLayoutFrameDrawingDrawLinksHighlighted
+
+ @param context A graphics context to draw into
+ @param options The drawing options. Use DTCoreTextLayoutFrameDrawingDefault or 0 to draw everything
+ */
+- (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawingOptions)options;
/**
@@ -822,6 +822,27 @@ - (void)_drawHorizontalRuleFromLine:(DTCoreTextLayoutLine *)line inContext:(CGCo
- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLinks:(BOOL)drawLinks
{
+ DTCoreTextLayoutFrameDrawingOptions options = DTCoreTextLayoutFrameDrawingDefault;
+
+ if (!drawImages)
+ {
+ options |= DTCoreTextLayoutFrameDrawingOmitAttachments;
+ }
+
+ if (!drawLinks)
+ {
+ options |= DTCoreTextLayoutFrameDrawingOmitLinks;
+ }
+
+ [self drawInContext:context options:options];
+}
+
+
+- (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawingOptions)options
+{
+ BOOL drawLinks = !(options & DTCoreTextLayoutFrameDrawingOmitLinks);
+ BOOL drawImages = !(options & DTCoreTextLayoutFrameDrawingOmitAttachments);
+
CGRect rect = CGContextGetClipBoundingBox(context);
if (!context)

0 comments on commit 80826ca

Please sign in to comment.