Skip to content
This repository
Browse code

deprecated method and replaced with one with options bit mask

  • Loading branch information...
commit 80826ca7f10277310452c8a3710b8185a0f6a436 1 parent 45d0ce0
Oliver Drobnik authored
17  Core/Source/DTAttributedTextContentView.m
@@ -408,8 +408,21 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
408 408
 	
409 409
 	DTCoreTextLayoutFrame *theLayoutFrame = self.layoutFrame; // this is synchronized
410 410
 	
  411
+	// construct drawing options
  412
+	DTCoreTextLayoutFrameDrawingOptions options = DTCoreTextLayoutFrameDrawingDefault;
  413
+	
  414
+	if (!_shouldDrawImages)
  415
+	{
  416
+		options |= DTCoreTextLayoutFrameDrawingOmitAttachments;
  417
+	}
  418
+	
  419
+	if (!_shouldDrawImages)
  420
+	{
  421
+		options |= DTCoreTextLayoutFrameDrawingOmitLinks;
  422
+	}
  423
+	
411 424
 	// need to prevent updating of string and drawing at the same time
412  
-	[theLayoutFrame drawInContext:ctx drawImages:_shouldDrawImages drawLinks:_shouldDrawLinks];
  425
+	[theLayoutFrame drawInContext:ctx options:options];
413 426
 	
414 427
 	if (_delegateFlags.delegateSupportsNotificationAfterDrawing)
415 428
 	{
@@ -420,7 +433,7 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
420 433
 - (void)drawRect:(CGRect)rect
421 434
 {
422 435
 	CGContextRef context = UIGraphicsGetCurrentContext();
423  
-	[self.layoutFrame drawInContext:context drawImages:YES drawLinks:YES];
  436
+	[self.layoutFrame drawInContext:context options:DTCoreTextLayoutFrameDrawingDefault];
424 437
 }
425 438
 
426 439
 - (void)relayoutText
32  Core/Source/DTCoreTextLayoutFrame.h
@@ -22,6 +22,15 @@
22 22
 
23 23
 typedef void (^DTCoreTextLayoutFrameTextBlockHandler)(DTTextBlock *textBlock, CGRect frame, CGContextRef context, BOOL *shouldDrawDefaultBackground); 
24 24
 
  25
+// the drawing options
  26
+typedef enum
  27
+{
  28
+	DTCoreTextLayoutFrameDrawingDefault              = 1<<0,
  29
+	DTCoreTextLayoutFrameDrawingOmitLinks            = 1<<1,
  30
+	DTCoreTextLayoutFrameDrawingOmitAttachments      = 1<<2,
  31
+	DTCoreTextLayoutFrameDrawingDrawLinksHighlighted = 1<<3
  32
+} DTCoreTextLayoutFrameDrawingOptions;
  33
+
25 34
 
26 35
 @class DTCoreTextLayouter;
27 36
 
@@ -113,14 +122,31 @@ typedef void (^DTCoreTextLayoutFrameTextBlockHandler)(DTTextBlock *textBlock, CG
113 122
 
114 123
 
115 124
 /**
116  
- Draws the entire layout frame into the given graphics context.
117  
- 
  125
+ Draws the receiver into the given graphics context.
  126
+
  127
+ @warning This method is deprecated, use -[DTCoreTextLayoutFrame drawInContext:options:] instead
118 128
  @param context A graphics context to draw into
119 129
  @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.
120 130
  @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.
121 131
  @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.
122 132
  */
123  
-- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLinks:(BOOL)drawLinks;
  133
+- (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLinks:(BOOL)drawLinks __attribute__((deprecated("use -[DTCoreTextLayoutFrame drawInContext:options:] instead")));
  134
+
  135
+
  136
+/**
  137
+ Draws the receiver into the given graphics context.
  138
+ 
  139
+ Possible options are the following, you may combine them with a binary OR.
  140
+ 
  141
+ - DTCoreTextLayoutFrameDrawingDefault or 0
  142
+ - DTCoreTextLayoutFrameDrawingOmitLinks
  143
+ - DTCoreTextLayoutFrameDrawingOmitAttachments
  144
+ - DTCoreTextLayoutFrameDrawingDrawLinksHighlighted
  145
+ 
  146
+ @param context A graphics context to draw into
  147
+ @param options The drawing options. Use DTCoreTextLayoutFrameDrawingDefault or 0 to draw everything
  148
+ */
  149
+- (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawingOptions)options;
124 150
 
125 151
 
126 152
 /**
21  Core/Source/DTCoreTextLayoutFrame.m
@@ -822,6 +822,27 @@ - (void)_drawHorizontalRuleFromLine:(DTCoreTextLayoutLine *)line inContext:(CGCo
822 822
 
823 823
 - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLinks:(BOOL)drawLinks
824 824
 {
  825
+	DTCoreTextLayoutFrameDrawingOptions options = DTCoreTextLayoutFrameDrawingDefault;
  826
+	
  827
+	if (!drawImages)
  828
+	{
  829
+		options |= DTCoreTextLayoutFrameDrawingOmitAttachments;
  830
+	}
  831
+	
  832
+	if (!drawLinks)
  833
+	{
  834
+		options |= DTCoreTextLayoutFrameDrawingOmitLinks;
  835
+	}
  836
+	
  837
+	[self drawInContext:context options:options];
  838
+}
  839
+
  840
+
  841
+- (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawingOptions)options
  842
+{
  843
+	BOOL drawLinks = !(options & DTCoreTextLayoutFrameDrawingOmitLinks);
  844
+	BOOL drawImages = !(options & DTCoreTextLayoutFrameDrawingOmitAttachments);
  845
+	
825 846
 	CGRect rect = CGContextGetClipBoundingBox(context);
826 847
 	
827 848
 	if (!context)

0 notes on commit 80826ca

Please sign in to comment.
Something went wrong with that request. Please try again.