ASPiK SDK
cgraphicspath.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 __cgraphicspath__
6 #define __cgraphicspath__
7 
8 #include "vstguifwd.h"
9 #include "ccolor.h"
10 #include "crect.h"
11 #include <vector>
12 
13 namespace VSTGUI {
14 
15 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 {
21 public:
22  //-----------------------------------------------------------------------------
24  //-----------------------------------------------------------------------------
26 
34  virtual CGradient* createGradient (double color1Start, double color2Start, const CColor& color1, const CColor& color2) = 0;
36 
37  //-----------------------------------------------------------------------------
39  //-----------------------------------------------------------------------------
41 
42  virtual void addArc (const CRect& rect, double startAngle, double endAngle, bool clockwise);
44  virtual void addEllipse (const CRect& rect);
46  virtual void addRect (const CRect& rect);
48  virtual void addPath (const CGraphicsPath& path, CGraphicsTransform* transformation = nullptr);
50  virtual void addLine (const CPoint& to);
52  virtual void addBezierCurve (const CPoint& control1, const CPoint& control2, const CPoint& end);
54  virtual void beginSubpath (const CPoint& start);
56  virtual void closeSubpath ();
57 
58  inline void beginSubpath (CCoord x, CCoord y)
59  {
60  beginSubpath (CPoint (x, y));
61  }
62  inline void addLine (CCoord x, CCoord y)
63  {
64  addLine (CPoint(x, y));
65  }
66  inline void addBezierCurve (CCoord cp1x, CCoord cp1y, CCoord cp2x, CCoord cp2y, CCoord x, CCoord y)
67  {
68  addBezierCurve (CPoint (cp1x, cp1y), CPoint (cp2x, cp2y), CPoint (x, y));
69  }
71 
72  //-----------------------------------------------------------------------------
74  //-----------------------------------------------------------------------------
76  void addRoundRect (const CRect& size, CCoord radius);
78 
79  //-----------------------------------------------------------------------------
81  //-----------------------------------------------------------------------------
83  virtual bool hitTest (const CPoint& p, bool evenOddFilled = false, CGraphicsTransform* transform = nullptr) = 0;
85 
86  //-----------------------------------------------------------------------------
88  //-----------------------------------------------------------------------------
90  virtual CPoint getCurrentPosition () = 0;
91  virtual CRect getBoundingBox () = 0;
93 
94 protected:
95  CGraphicsPath () {}
96 
97  virtual void dirty () = 0;
98 
100 
101  struct Rect {
102  CCoord left;
103  CCoord top;
104  CCoord right;
105  CCoord bottom;
106  };
107 
108  struct Point {
109  CCoord x;
110  CCoord y;
111  };
112 
113  struct Arc {
114  Rect rect;
115  double startAngle;
116  double endAngle;
117  bool clockwise;
118  };
119 
120  struct BezierCurve {
121  Point control1;
122  Point control2;
123  Point end;
124  };
125 
126  struct Element {
127  enum Type {
128  kArc = 0,
129  kEllipse,
130  kRect,
131  kLine,
132  kBezierCurve,
133  kBeginSubpath,
134  kCloseSubpath
135  };
136 
137  Type type;
138  union Instruction {
139  Arc arc;
140  Rect rect;
141  BezierCurve curve;
142  Point point;
143  } instruction;
144  };
145 
146  inline void CRect2Rect (const CRect& rect, CGraphicsPath::Rect& r) const {r.left = rect.left;r.right = rect.right;r.top = rect.top;r.bottom = rect.bottom;}
147  inline void CPoint2Point (const CPoint& point, CGraphicsPath::Point& p) const {p.x = point.x;p.y = point.y;}
149 
150  using ElementList = std::vector<Element>;
151  ElementList elements;
152 };
153 
154 } // namespace
155 
156 #endif
virtual void beginSubpath(const CPoint &start)
Definition: cgraphicspath.cpp:134
Rect structure.
Definition: crect.h:17
virtual void addEllipse(const CRect &rect)
Definition: cgraphicspath.cpp:92
virtual void dirty()=0
platform object should be released
virtual void addRect(const CRect &rect)
Definition: cgraphicspath.cpp:102
virtual void addLine(const CPoint &to)
Definition: cgraphicspath.cpp:112
RGBA Color structure.
Definition: ccolor.h:15
virtual void addArc(const CRect &rect, double startAngle, double endAngle, bool clockwise)
Definition: cgraphicspath.cpp:79
virtual CGradient * createGradient(double color1Start, double color2Start, const CColor &color1, const CColor &color2)=0
creates a new gradient object, you must release it with forget() when you&#39;re done with it ...
Graphics Path Object.
Definition: cgraphicspath.h:19
Gradient Object [new in 4.0].
Definition: cgradient.h:19
Definition: customcontrols.cpp:8
virtual void addBezierCurve(const CPoint &control1, const CPoint &control2, const CPoint &end)
Definition: cgraphicspath.cpp:122
Definition: vstguibase.h:247
virtual void addPath(const CGraphicsPath &path, CGraphicsTransform *transformation=nullptr)
Definition: cgraphicspath.cpp:35
Graphics Transform Matrix.
Definition: cgraphicstransform.h:23
virtual void closeSubpath()
Definition: cgraphicspath.cpp:144
Point structure.
Definition: cpoint.h:17