Guest User

Untitled

a guest
Oct 22nd, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //// General Declarations
  2. CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
  3.  
  4. //// Color Declarations
  5. NSColor* dark1 = [NSColor colorWithCalibratedRed: 0.15 green: 0.16 blue: 0.19 alpha: 1];
  6. NSColor* dark2 = [NSColor colorWithCalibratedRed: 0 green: 0 blue: 0 alpha: 1];
  7. NSColor* white = [NSColor colorWithCalibratedRed: 1 green: 1 blue: 1 alpha: 1];
  8. NSColor* white25 = [NSColor colorWithCalibratedHue: [white hueComponent] saturation: [white saturationComponent] brightness: 0.25 alpha: [white alphaComponent]];
  9. NSColor* white3 = [NSColor colorWithCalibratedHue: [white hueComponent] saturation: [white saturationComponent] brightness: 0.03 alpha: [white alphaComponent]];
  10. NSColor* arrowColor = [NSColor colorWithCalibratedRed: 0.76 green: 0.76 blue: 0.76 alpha: 1];
  11. NSColor* black = [NSColor colorWithCalibratedRed: 0 green: 0 blue: 0 alpha: 1];
  12. NSColor* black80 = [black colorWithAlphaComponent: 0.8];
  13. NSColor* lightBack = [NSColor colorWithCalibratedRed: 0.99 green: 0.98 blue: 0.96 alpha: 1];
  14.  
  15. //// Gradient Declarations
  16. NSGradient* darkBackgroundRgadient = [[NSGradient alloc] initWithStartingColor: dark1 endingColor: dark2];
  17.  
  18. //// Shadow Declarations
  19. NSShadow* shadow = [[NSShadow alloc] init];
  20. [shadow setShadowColor: white25];
  21. [shadow setShadowOffset: NSMakeSize(0, -1)];
  22. [shadow setShadowBlurRadius: 0];
  23. NSShadow* arrowShadow = [[NSShadow alloc] init];
  24. [arrowShadow setShadowColor: [NSColor blackColor]];
  25. [arrowShadow setShadowOffset: NSMakeSize(0, -1)];
  26. [arrowShadow setShadowBlurRadius: 0];
  27. NSShadow* innerShadow = [[NSShadow alloc] init];
  28. [innerShadow setShadowColor: white3];
  29. [innerShadow setShadowOffset: NSMakeSize(0, -1)];
  30. [innerShadow setShadowBlurRadius: 5];
  31. NSShadow* outerShadow = [[NSShadow alloc] init];
  32. [outerShadow setShadowColor: black80];
  33. [outerShadow setShadowOffset: NSMakeSize(0, -1)];
  34. [outerShadow setShadowBlurRadius: 2];
  35.  
  36. //// Abstracted Graphic Attributes
  37. NSRect bigBack2Rect = NSMakeRect(0, 0, 305, 64);
  38. NSRect bigBackRect = NSMakeRect(6.5, 6.5, 293, 51);
  39. NSString* yearContent = "83";
  40. NSFont* yearFont = [NSFont fontWithName: "Helvetica-Bold" size: 27.5];
  41. NSString* year2Content = "19";
  42. NSFont* year2Font = [NSFont fontWithName: "Helvetica-Bold" size: 27.5];
  43. NSString* monthContent = "03";
  44. NSFont* monthFont = [NSFont fontWithName: "Helvetica-Bold" size: 27.5];
  45. NSString* dayContent = "28";
  46. NSFont* dayFont = [NSFont fontWithName: "Helvetica-Bold" size: 27.5];
  47.  
  48. //// BigBack 2 Drawing
  49. NSBezierPath* bigBack2Path = [NSBezierPath bezierPathWithRect: bigBack2Rect];
  50. [lightBack setFill];
  51. [bigBack2Path fill];
  52.  
  53. //// BigBack Drawing
  54. NSBezierPath* bigBackPath = [NSBezierPath bezierPathWithRect: bigBackRect];
  55. [white setFill];
  56. [bigBackPath fill];
  57.  
  58. [[NSColor lightGrayColor] setStroke];
  59. [bigBackPath setLineWidth: 1];
  60. [bigBackPath stroke];
  61.  
  62. //// DigBackYear Drawing
  63. NSBezierPath* digBackYearPath = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(224, 13, 43, 36) xRadius: 4 yRadius: 4];
  64. [NSGraphicsContext saveGraphicsState];
  65. [outerShadow set];
  66. CGContextBeginTransparencyLayer(context, NULL);
  67. [darkBackgroundRgadient drawInBezierPath: digBackYearPath angle: 90];
  68. CGContextEndTransparencyLayer(context);
  69.  
  70. ////// DigBackYear Inner Shadow
  71. NSRect digBackYearBorderRect = NSInsetRect([digBackYearPath bounds], -innerShadow.shadowBlurRadius, -innerShadow.shadowBlurRadius);
  72. digBackYearBorderRect = NSOffsetRect(digBackYearBorderRect, -innerShadow.shadowOffset.width, innerShadow.shadowOffset.height);
  73. digBackYearBorderRect = NSInsetRect(NSUnionRect(digBackYearBorderRect, [digBackYearPath bounds]), -1, -1);
  74.  
  75. NSBezierPath* digBackYearNegativePath = [NSBezierPath bezierPathWithRect: digBackYearBorderRect];
  76. [digBackYearNegativePath appendBezierPath: digBackYearPath];
  77. [digBackYearNegativePath setWindingRule: NSEvenOddWindingRule];
  78.  
  79. [NSGraphicsContext saveGraphicsState]; {
  80. NSShadow* innerShadowWithOffset = [innerShadow copy];
  81. CGFloat xOffset = innerShadowWithOffset.shadowOffset.width + round(digBackYearBorderRect.size.width);
  82. CGFloat yOffset = innerShadowWithOffset.shadowOffset.height;
  83. innerShadowWithOffset.shadowOffset = NSMakeSize(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset));
  84. [innerShadowWithOffset set];
  85. [[NSColor grayColor] setFill];
  86. [digBackYearPath addClip];
  87. NSAffineTransform* transform = [NSAffineTransform transform];
  88. [transform translateXBy: -round(digBackYearBorderRect.size.width) yBy: 0];
  89. [[transform transformBezierPath: digBackYearNegativePath] fill];
  90. }
  91. [NSGraphicsContext restoreGraphicsState];
  92.  
  93. [NSGraphicsContext restoreGraphicsState];
  94.  
  95. //// Year Drawing
  96. NSRect yearRect = NSMakeRect(225, 14, 42, 37);
  97. NSMutableParagraphStyle* yearStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
  98. [yearStyle setAlignment: NSCenterTextAlignment];
  99.  
  100. NSDictionary* yearFontAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
  101. yearFont, NSFontAttributeName,
  102. white, NSForegroundColorAttributeName,
  103. yearStyle, NSParagraphStyleAttributeName, nil];
  104.  
  105. [yearContent drawInRect: yearRect withAttributes: yearFontAttributes];
  106.  
  107. //// YearLine2 Drawing
  108. NSBezierPath* yearLine2Path = [NSBezierPath bezierPath];
  109. [yearLine2Path moveToPoint: NSMakePoint(224, 29.5)];
  110. [yearLine2Path lineToPoint: NSMakePoint(267, 29.5)];
  111. [yearLine2Path setMiterLimit: 1];
  112. [dark2 setFill];
  113. [yearLine2Path fill];
  114.  
  115. [NSGraphicsContext saveGraphicsState];
  116. [shadow set];
  117. [dark2 setStroke];
  118. [yearLine2Path setLineWidth: 1];
  119. [yearLine2Path stroke];
  120. [NSGraphicsContext restoreGraphicsState];
  121.  
  122. //// UpDownBackYear Drawing
  123. NSBezierPath* upDownBackYearPath = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(272, 13, 20, 36) xRadius: 4 yRadius: 4];
  124. [NSGraphicsContext saveGraphicsState];
  125. [outerShadow set];
  126. CGContextBeginTransparencyLayer(context, NULL);
  127. [darkBackgroundRgadient drawInBezierPath: upDownBackYearPath angle: 90];
  128. CGContextEndTransparencyLayer(context);
  129.  
  130. ////// UpDownBackYear Inner Shadow
  131. NSRect upDownBackYearBorderRect = NSInsetRect([upDownBackYearPath bounds], -innerShadow.shadowBlurRadius, -innerShadow.shadowBlurRadius);
  132. upDownBackYearBorderRect = NSOffsetRect(upDownBackYearBorderRect, -innerShadow.shadowOffset.width, innerShadow.shadowOffset.height);
  133. upDownBackYearBorderRect = NSInsetRect(NSUnionRect(upDownBackYearBorderRect, [upDownBackYearPath bounds]), -1, -1);
  134.  
  135. NSBezierPath* upDownBackYearNegativePath = [NSBezierPath bezierPathWithRect: upDownBackYearBorderRect];
  136. [upDownBackYearNegativePath appendBezierPath: upDownBackYearPath];
  137. [upDownBackYearNegativePath setWindingRule: NSEvenOddWindingRule];
  138.  
  139. [NSGraphicsContext saveGraphicsState]; {
  140. NSShadow* innerShadowWithOffset = [innerShadow copy];
  141. CGFloat xOffset = innerShadowWithOffset.shadowOffset.width + round(upDownBackYearBorderRect.size.width);
  142. CGFloat yOffset = innerShadowWithOffset.shadowOffset.height;
  143. innerShadowWithOffset.shadowOffset = NSMakeSize(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset));
  144. [innerShadowWithOffset set];
  145. [[NSColor grayColor] setFill];
  146. [upDownBackYearPath addClip];
  147. NSAffineTransform* transform = [NSAffineTransform transform];
  148. [transform translateXBy: -round(upDownBackYearBorderRect.size.width) yBy: 0];
  149. [[transform transformBezierPath: upDownBackYearNegativePath] fill];
  150. }
  151. [NSGraphicsContext restoreGraphicsState];
  152.  
  153. [NSGraphicsContext restoreGraphicsState];
  154.  
  155. //// YearLine3 Drawing
  156. NSBezierPath* yearLine3Path = [NSBezierPath bezierPath];
  157. [yearLine3Path moveToPoint: NSMakePoint(272, 29.5)];
  158. [yearLine3Path lineToPoint: NSMakePoint(292, 29.5)];
  159. [yearLine3Path setMiterLimit: 1];
  160. [dark2 setFill];
  161. [yearLine3Path fill];
  162.  
  163. [NSGraphicsContext saveGraphicsState];
  164. [shadow set];
  165. [dark2 setStroke];
  166. [yearLine3Path setLineWidth: 1];
  167. [yearLine3Path stroke];
  168. [NSGraphicsContext restoreGraphicsState];
  169.  
  170. //// Up Drawing
  171. NSBezierPath* upPath = [NSBezierPath bezierPath];
  172. [upPath moveToPoint: NSMakePoint(277, 25)];
  173. [upPath lineToPoint: NSMakePoint(287, 25)];
  174. [upPath lineToPoint: NSMakePoint(282, 20)];
  175. [upPath lineToPoint: NSMakePoint(277, 25)];
  176. [upPath closePath];
  177. [NSGraphicsContext saveGraphicsState];
  178. [arrowShadow set];
  179. [arrowColor setFill];
  180. [upPath fill];
  181. [NSGraphicsContext restoreGraphicsState];
  182.  
  183. //// Down Drawing
  184. NSBezierPath* downPath = [NSBezierPath bezierPath];
  185. [downPath moveToPoint: NSMakePoint(277, 37)];
  186. [downPath lineToPoint: NSMakePoint(287, 37)];
  187. [downPath lineToPoint: NSMakePoint(282, 42)];
  188. [downPath lineToPoint: NSMakePoint(277, 37)];
  189. [downPath closePath];
  190. [NSGraphicsContext saveGraphicsState];
  191. [arrowShadow set];
  192. [arrowColor setFill];
  193. [downPath fill];
  194. [NSGraphicsContext restoreGraphicsState];
  195.  
  196. //// DigBackYear1 Drawing
  197. NSBezierPath* digBackYear1Path = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(176, 13, 43, 36) xRadius: 4 yRadius: 4];
  198. [NSGraphicsContext saveGraphicsState];
  199. [outerShadow set];
  200. CGContextBeginTransparencyLayer(context, NULL);
  201. [darkBackgroundRgadient drawInBezierPath: digBackYear1Path angle: 90];
  202. CGContextEndTransparencyLayer(context);
  203.  
  204. ////// DigBackYear1 Inner Shadow
  205. NSRect digBackYear1BorderRect = NSInsetRect([digBackYear1Path bounds], -innerShadow.shadowBlurRadius, -innerShadow.shadowBlurRadius);
  206. digBackYear1BorderRect = NSOffsetRect(digBackYear1BorderRect, -innerShadow.shadowOffset.width, innerShadow.shadowOffset.height);
  207. digBackYear1BorderRect = NSInsetRect(NSUnionRect(digBackYear1BorderRect, [digBackYear1Path bounds]), -1, -1);
  208.  
  209. NSBezierPath* digBackYear1NegativePath = [NSBezierPath bezierPathWithRect: digBackYear1BorderRect];
  210. [digBackYear1NegativePath appendBezierPath: digBackYear1Path];
  211. [digBackYear1NegativePath setWindingRule: NSEvenOddWindingRule];
  212.  
  213. [NSGraphicsContext saveGraphicsState]; {
  214. NSShadow* innerShadowWithOffset = [innerShadow copy];
  215. CGFloat xOffset = innerShadowWithOffset.shadowOffset.width + round(digBackYear1BorderRect.size.width);
  216. CGFloat yOffset = innerShadowWithOffset.shadowOffset.height;
  217. innerShadowWithOffset.shadowOffset = NSMakeSize(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset));
  218. [innerShadowWithOffset set];
  219. [[NSColor grayColor] setFill];
  220. [digBackYear1Path addClip];
  221. NSAffineTransform* transform = [NSAffineTransform transform];
  222. [transform translateXBy: -round(digBackYear1BorderRect.size.width) yBy: 0];
  223. [[transform transformBezierPath: digBackYear1NegativePath] fill];
  224. }
  225. [NSGraphicsContext restoreGraphicsState];
  226.  
  227. [NSGraphicsContext restoreGraphicsState];
  228.  
  229. //// year2 Drawing
  230. NSRect year2Rect = NSMakeRect(177, 14, 42, 37);
  231. NSMutableParagraphStyle* year2Style = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
  232. [year2Style setAlignment: NSCenterTextAlignment];
  233.  
  234. NSDictionary* year2FontAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
  235. year2Font, NSFontAttributeName,
  236. white, NSForegroundColorAttributeName,
  237. year2Style, NSParagraphStyleAttributeName, nil];
  238.  
  239. [year2Content drawInRect: year2Rect withAttributes: year2FontAttributes];
  240.  
  241. //// YearLine Drawing
  242. NSBezierPath* yearLinePath = [NSBezierPath bezierPath];
  243. [yearLinePath moveToPoint: NSMakePoint(176, 29.5)];
  244. [yearLinePath lineToPoint: NSMakePoint(219, 29.5)];
  245. [yearLinePath setMiterLimit: 1];
  246. [dark2 setFill];
  247. [yearLinePath fill];
  248.  
  249. [NSGraphicsContext saveGraphicsState];
  250. [shadow set];
  251. [dark2 setStroke];
  252. [yearLinePath setLineWidth: 1];
  253. [yearLinePath stroke];
  254. [NSGraphicsContext restoreGraphicsState];
  255.  
  256. //// DigBackMonth Drawing
  257. NSBezierPath* digBackMonthPath = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(95, 13, 43, 36) xRadius: 4 yRadius: 4];
  258. [NSGraphicsContext saveGraphicsState];
  259. [outerShadow set];
  260. CGContextBeginTransparencyLayer(context, NULL);
  261. [darkBackgroundRgadient drawInBezierPath: digBackMonthPath angle: 90];
  262. CGContextEndTransparencyLayer(context);
  263.  
  264. ////// DigBackMonth Inner Shadow
  265. NSRect digBackMonthBorderRect = NSInsetRect([digBackMonthPath bounds], -innerShadow.shadowBlurRadius, -innerShadow.shadowBlurRadius);
  266. digBackMonthBorderRect = NSOffsetRect(digBackMonthBorderRect, -innerShadow.shadowOffset.width, innerShadow.shadowOffset.height);
  267. digBackMonthBorderRect = NSInsetRect(NSUnionRect(digBackMonthBorderRect, [digBackMonthPath bounds]), -1, -1);
  268.  
  269. NSBezierPath* digBackMonthNegativePath = [NSBezierPath bezierPathWithRect: digBackMonthBorderRect];
  270. [digBackMonthNegativePath appendBezierPath: digBackMonthPath];
  271. [digBackMonthNegativePath setWindingRule: NSEvenOddWindingRule];
  272.  
  273. [NSGraphicsContext saveGraphicsState]; {
  274. NSShadow* innerShadowWithOffset = [innerShadow copy];
  275. CGFloat xOffset = innerShadowWithOffset.shadowOffset.width + round(digBackMonthBorderRect.size.width);
  276. CGFloat yOffset = innerShadowWithOffset.shadowOffset.height;
  277. innerShadowWithOffset.shadowOffset = NSMakeSize(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset));
  278. [innerShadowWithOffset set];
  279. [[NSColor grayColor] setFill];
  280. [digBackMonthPath addClip];
  281. NSAffineTransform* transform = [NSAffineTransform transform];
  282. [transform translateXBy: -round(digBackMonthBorderRect.size.width) yBy: 0];
  283. [[transform transformBezierPath: digBackMonthNegativePath] fill];
  284. }
  285. [NSGraphicsContext restoreGraphicsState];
  286.  
  287. [NSGraphicsContext restoreGraphicsState];
  288.  
  289. //// Month Drawing
  290. NSRect monthRect = NSMakeRect(96, 14, 42, 37);
  291. NSMutableParagraphStyle* monthStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
  292. [monthStyle setAlignment: NSCenterTextAlignment];
  293.  
  294. NSDictionary* monthFontAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
  295. monthFont, NSFontAttributeName,
  296. white, NSForegroundColorAttributeName,
  297. monthStyle, NSParagraphStyleAttributeName, nil];
  298.  
  299. [monthContent drawInRect: monthRect withAttributes: monthFontAttributes];
  300.  
  301. //// MonthLine Drawing
  302. NSBezierPath* monthLinePath = [NSBezierPath bezierPath];
  303. [monthLinePath moveToPoint: NSMakePoint(95, 29.5)];
  304. [monthLinePath lineToPoint: NSMakePoint(138, 29.5)];
  305. [monthLinePath setMiterLimit: 1];
  306. [dark2 setFill];
  307. [monthLinePath fill];
  308.  
  309. [NSGraphicsContext saveGraphicsState];
  310. [shadow set];
  311. [dark2 setStroke];
  312. [monthLinePath setLineWidth: 1];
  313. [monthLinePath stroke];
  314. [NSGraphicsContext restoreGraphicsState];
  315.  
  316. //// UpDownBackMonth Drawing
  317. NSBezierPath* upDownBackMonthPath = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(143, 13, 20, 36) xRadius: 4 yRadius: 4];
  318. [NSGraphicsContext saveGraphicsState];
  319. [outerShadow set];
  320. CGContextBeginTransparencyLayer(context, NULL);
  321. [darkBackgroundRgadient drawInBezierPath: upDownBackMonthPath angle: 90];
  322. CGContextEndTransparencyLayer(context);
  323.  
  324. ////// UpDownBackMonth Inner Shadow
  325. NSRect upDownBackMonthBorderRect = NSInsetRect([upDownBackMonthPath bounds], -innerShadow.shadowBlurRadius, -innerShadow.shadowBlurRadius);
  326. upDownBackMonthBorderRect = NSOffsetRect(upDownBackMonthBorderRect, -innerShadow.shadowOffset.width, innerShadow.shadowOffset.height);
  327. upDownBackMonthBorderRect = NSInsetRect(NSUnionRect(upDownBackMonthBorderRect, [upDownBackMonthPath bounds]), -1, -1);
  328.  
  329. NSBezierPath* upDownBackMonthNegativePath = [NSBezierPath bezierPathWithRect: upDownBackMonthBorderRect];
  330. [upDownBackMonthNegativePath appendBezierPath: upDownBackMonthPath];
  331. [upDownBackMonthNegativePath setWindingRule: NSEvenOddWindingRule];
  332.  
  333. [NSGraphicsContext saveGraphicsState]; {
  334. NSShadow* innerShadowWithOffset = [innerShadow copy];
  335. CGFloat xOffset = innerShadowWithOffset.shadowOffset.width + round(upDownBackMonthBorderRect.size.width);
  336. CGFloat yOffset = innerShadowWithOffset.shadowOffset.height;
  337. innerShadowWithOffset.shadowOffset = NSMakeSize(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset));
  338. [innerShadowWithOffset set];
  339. [[NSColor grayColor] setFill];
  340. [upDownBackMonthPath addClip];
  341. NSAffineTransform* transform = [NSAffineTransform transform];
  342. [transform translateXBy: -round(upDownBackMonthBorderRect.size.width) yBy: 0];
  343. [[transform transformBezierPath: upDownBackMonthNegativePath] fill];
  344. }
  345. [NSGraphicsContext restoreGraphicsState];
  346.  
  347. [NSGraphicsContext restoreGraphicsState];
  348.  
  349. //// MonthLine2 Drawing
  350. NSBezierPath* monthLine2Path = [NSBezierPath bezierPath];
  351. [monthLine2Path moveToPoint: NSMakePoint(143, 29.5)];
  352. [monthLine2Path lineToPoint: NSMakePoint(163, 29.5)];
  353. [monthLine2Path setMiterLimit: 1];
  354. [dark2 setFill];
  355. [monthLine2Path fill];
  356.  
  357. [NSGraphicsContext saveGraphicsState];
  358. [shadow set];
  359. [dark2 setStroke];
  360. [monthLine2Path setLineWidth: 1];
  361. [monthLine2Path stroke];
  362. [NSGraphicsContext restoreGraphicsState];
  363.  
  364. //// Up 2 Drawing
  365. NSBezierPath* up2Path = [NSBezierPath bezierPath];
  366. [up2Path moveToPoint: NSMakePoint(148, 25)];
  367. [up2Path lineToPoint: NSMakePoint(158, 25)];
  368. [up2Path lineToPoint: NSMakePoint(153, 20)];
  369. [up2Path lineToPoint: NSMakePoint(148, 25)];
  370. [up2Path closePath];
  371. [NSGraphicsContext saveGraphicsState];
  372. [arrowShadow set];
  373. [arrowColor setFill];
  374. [up2Path fill];
  375. [NSGraphicsContext restoreGraphicsState];
  376.  
  377. //// Down 2 Drawing
  378. NSBezierPath* down2Path = [NSBezierPath bezierPath];
  379. [down2Path moveToPoint: NSMakePoint(148, 37)];
  380. [down2Path lineToPoint: NSMakePoint(158, 37)];
  381. [down2Path lineToPoint: NSMakePoint(153, 42)];
  382. [down2Path lineToPoint: NSMakePoint(148, 37)];
  383. [down2Path closePath];
  384. [NSGraphicsContext saveGraphicsState];
  385. [arrowShadow set];
  386. [arrowColor setFill];
  387. [down2Path fill];
  388. [NSGraphicsContext restoreGraphicsState];
  389.  
  390. //// DigBackDay Drawing
  391. NSBezierPath* digBackDayPath = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(14, 13, 43, 36) xRadius: 4 yRadius: 4];
  392. [NSGraphicsContext saveGraphicsState];
  393. [outerShadow set];
  394. CGContextBeginTransparencyLayer(context, NULL);
  395. [darkBackgroundRgadient drawInBezierPath: digBackDayPath angle: 90];
  396. CGContextEndTransparencyLayer(context);
  397.  
  398. ////// DigBackDay Inner Shadow
  399. NSRect digBackDayBorderRect = NSInsetRect([digBackDayPath bounds], -innerShadow.shadowBlurRadius, -innerShadow.shadowBlurRadius);
  400. digBackDayBorderRect = NSOffsetRect(digBackDayBorderRect, -innerShadow.shadowOffset.width, innerShadow.shadowOffset.height);
  401. digBackDayBorderRect = NSInsetRect(NSUnionRect(digBackDayBorderRect, [digBackDayPath bounds]), -1, -1);
  402.  
  403. NSBezierPath* digBackDayNegativePath = [NSBezierPath bezierPathWithRect: digBackDayBorderRect];
  404. [digBackDayNegativePath appendBezierPath: digBackDayPath];
  405. [digBackDayNegativePath setWindingRule: NSEvenOddWindingRule];
  406.  
  407. [NSGraphicsContext saveGraphicsState]; {
  408. NSShadow* innerShadowWithOffset = [innerShadow copy];
  409. CGFloat xOffset = innerShadowWithOffset.shadowOffset.width + round(digBackDayBorderRect.size.width);
  410. CGFloat yOffset = innerShadowWithOffset.shadowOffset.height;
  411. innerShadowWithOffset.shadowOffset = NSMakeSize(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset));
  412. [innerShadowWithOffset set];
  413. [[NSColor grayColor] setFill];
  414. [digBackDayPath addClip];
  415. NSAffineTransform* transform = [NSAffineTransform transform];
  416. [transform translateXBy: -round(digBackDayBorderRect.size.width) yBy: 0];
  417. [[transform transformBezierPath: digBackDayNegativePath] fill];
  418. }
  419. [NSGraphicsContext restoreGraphicsState];
  420.  
  421. [NSGraphicsContext restoreGraphicsState];
  422.  
  423. //// day Drawing
  424. NSRect dayRect = NSMakeRect(15, 14, 42, 37);
  425. NSMutableParagraphStyle* dayStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
  426. [dayStyle setAlignment: NSCenterTextAlignment];
  427.  
  428. NSDictionary* dayFontAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
  429. dayFont, NSFontAttributeName,
  430. white, NSForegroundColorAttributeName,
  431. dayStyle, NSParagraphStyleAttributeName, nil];
  432.  
  433. [dayContent drawInRect: dayRect withAttributes: dayFontAttributes];
  434.  
  435. //// DayLine Drawing
  436. NSBezierPath* dayLinePath = [NSBezierPath bezierPath];
  437. [dayLinePath moveToPoint: NSMakePoint(14, 29.5)];
  438. [dayLinePath lineToPoint: NSMakePoint(57, 29.5)];
  439. [dayLinePath setMiterLimit: 1];
  440. [dark2 setFill];
  441. [dayLinePath fill];
  442.  
  443. [NSGraphicsContext saveGraphicsState];
  444. [shadow set];
  445. [dark2 setStroke];
  446. [dayLinePath setLineWidth: 1];
  447. [dayLinePath stroke];
  448. [NSGraphicsContext restoreGraphicsState];
  449.  
  450. //// UpDownBackDay Drawing
  451. NSBezierPath* upDownBackDayPath = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(62, 13, 20, 36) xRadius: 4 yRadius: 4];
  452. [NSGraphicsContext saveGraphicsState];
  453. [outerShadow set];
  454. CGContextBeginTransparencyLayer(context, NULL);
  455. [darkBackgroundRgadient drawInBezierPath: upDownBackDayPath angle: 90];
  456. CGContextEndTransparencyLayer(context);
  457.  
  458. ////// UpDownBackDay Inner Shadow
  459. NSRect upDownBackDayBorderRect = NSInsetRect([upDownBackDayPath bounds], -innerShadow.shadowBlurRadius, -innerShadow.shadowBlurRadius);
  460. upDownBackDayBorderRect = NSOffsetRect(upDownBackDayBorderRect, -innerShadow.shadowOffset.width, innerShadow.shadowOffset.height);
  461. upDownBackDayBorderRect = NSInsetRect(NSUnionRect(upDownBackDayBorderRect, [upDownBackDayPath bounds]), -1, -1);
  462.  
  463. NSBezierPath* upDownBackDayNegativePath = [NSBezierPath bezierPathWithRect: upDownBackDayBorderRect];
  464. [upDownBackDayNegativePath appendBezierPath: upDownBackDayPath];
  465. [upDownBackDayNegativePath setWindingRule: NSEvenOddWindingRule];
  466.  
  467. [NSGraphicsContext saveGraphicsState]; {
  468. NSShadow* innerShadowWithOffset = [innerShadow copy];
  469. CGFloat xOffset = innerShadowWithOffset.shadowOffset.width + round(upDownBackDayBorderRect.size.width);
  470. CGFloat yOffset = innerShadowWithOffset.shadowOffset.height;
  471. innerShadowWithOffset.shadowOffset = NSMakeSize(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset));
  472. [innerShadowWithOffset set];
  473. [[NSColor grayColor] setFill];
  474. [upDownBackDayPath addClip];
  475. NSAffineTransform* transform = [NSAffineTransform transform];
  476. [transform translateXBy: -round(upDownBackDayBorderRect.size.width) yBy: 0];
  477. [[transform transformBezierPath: upDownBackDayNegativePath] fill];
  478. }
  479. [NSGraphicsContext restoreGraphicsState];
  480.  
  481. [NSGraphicsContext restoreGraphicsState];
  482.  
  483. //// DayLine2 Drawing
  484. NSBezierPath* dayLine2Path = [NSBezierPath bezierPath];
  485. [dayLine2Path moveToPoint: NSMakePoint(62, 29.5)];
  486. [dayLine2Path lineToPoint: NSMakePoint(82, 29.5)];
  487. [dayLine2Path setMiterLimit: 1];
  488. [dark2 setFill];
  489. [dayLine2Path fill];
  490.  
  491. [NSGraphicsContext saveGraphicsState];
  492. [shadow set];
  493. [dark2 setStroke];
  494. [dayLine2Path setLineWidth: 1];
  495. [dayLine2Path stroke];
  496. [NSGraphicsContext restoreGraphicsState];
  497.  
  498. //// Up 3 Drawing
  499. NSBezierPath* up3Path = [NSBezierPath bezierPath];
  500. [up3Path moveToPoint: NSMakePoint(67, 25)];
  501. [up3Path lineToPoint: NSMakePoint(77, 25)];
  502. [up3Path lineToPoint: NSMakePoint(72, 20)];
  503. [up3Path lineToPoint: NSMakePoint(67, 25)];
  504. [up3Path closePath];
  505. [NSGraphicsContext saveGraphicsState];
  506. [arrowShadow set];
  507. [arrowColor setFill];
  508. [up3Path fill];
  509. [NSGraphicsContext restoreGraphicsState];
  510.  
  511. //// Down 3 Drawing
  512. NSBezierPath* down3Path = [NSBezierPath bezierPath];
  513. [down3Path moveToPoint: NSMakePoint(67, 37)];
  514. [down3Path lineToPoint: NSMakePoint(77, 37)];
  515. [down3Path lineToPoint: NSMakePoint(72, 42)];
  516. [down3Path lineToPoint: NSMakePoint(67, 37)];
  517. [down3Path closePath];
  518. [NSGraphicsContext saveGraphicsState];
  519. [arrowShadow set];
  520. [arrowColor setFill];
  521. [down3Path fill];
  522. [NSGraphicsContext restoreGraphicsState];
Add Comment
Please, Sign In to add comment