ASPiK SDK
quartzgraphicspath.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __quartzgraphicspath__
6 #define __quartzgraphicspath__
7 
8 #include "../../cgraphicspath.h"
9 #include "../../cgradient.h"
10 
11 #if MAC
12 
13 #include "macglobals.h"
14 #if TARGET_OS_IPHONE
15  #include <CoreGraphics/CoreGraphics.h>
16  #include <ImageIO/ImageIO.h>
17 #else
18  #include <ApplicationServices/ApplicationServices.h>
19 #endif
20 
21 namespace VSTGUI {
22 class CoreTextFont;
23 class CDrawContext;
24 
25 //------------------------------------------------------------------------------------
26 class QuartzGraphicsPath : public CGraphicsPath
27 {
28 public:
29  QuartzGraphicsPath ();
30  QuartzGraphicsPath (const CoreTextFont* font, UTF8StringPtr text);
31  ~QuartzGraphicsPath () noexcept override;
32 
33  void pixelAlign (CDrawContext* context);
34  CGPathRef getCGPathRef ();
35  void dirty () override;
36 
37  bool hitTest (const CPoint& p, bool evenOddFilled = false, CGraphicsTransform* transform = nullptr) override;
38  CPoint getCurrentPosition () override;
39  CRect getBoundingBox () override;
40 
41  CGradient* createGradient (double color1Start, double color2Start, const CColor& color1, const CColor& color2) override;
42 
43  static CGAffineTransform createCGAffineTransform (const CGraphicsTransform& t);
44 
45 //------------------------------------------------------------------------------------
46 protected:
47  CGMutablePathRef path;
48  CGMutablePathRef originalTextPath;
49  bool isPixelAlligned;
50 };
51 
52 //-----------------------------------------------------------------------------
53 class QuartzGradient : public CGradient
54 {
55 public:
56  explicit QuartzGradient (const ColorStopMap& map);
57  QuartzGradient (double _color1Start, double _color2Start, const CColor& _color1, const CColor& _color2);
58  ~QuartzGradient () noexcept override;
59 
60  operator CGGradientRef () const;
61 
62  void addColorStop (const std::pair<double, CColor>& colorStop) override;
63  void addColorStop (std::pair<double, CColor>&& colorStop) override;
64 
65 protected:
66  void createCGGradient () const;
67  void releaseCGGradient ();
68 
69  mutable CGGradientRef gradient;
70 };
71 
72 } // namespace
73 
74 #endif
75 
76 #endif // __quartzgraphicspath__
Definition: customcontrols.cpp:8