InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IRefPointShape.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Bernd Paradies
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __IRefPointShape__
25 #define __IRefPointShape__
26 
27 #include "AppFrameworkID.h"
28 #include "IPMUnknown.h"
29 #include "Utils.h"
30 #include "PMPolygon4.h"
31 
32 #include "UIDRef.h"
33 
34 class UIDList;
35 class IGraphicsPort;
36 class IGraphicsContext;
37 
44 class IRefPointShape : public IPMUnknown
45 {
46 public:
47  enum { kDefaultIID = IID_IREFPOINTSHAPE };
48 
50  enum
51  {
53  kSize = 13
54  };
55 
60  virtual void Path(IGraphicsPort* gPort, const PBPMPoint& center) = 0;
61 
66  virtual void Draw(IGraphicsContext* gc, const PMPoint& center) = 0;
67 
73  virtual void Invalidate(IGraphicsContext* gc, const PMPoint& center, bool16 forceInval = kFalse) = 0;
74 
80  virtual PMRect GetBounds(IGraphicsContext* gc, const PMPoint& center) = 0;
81 };
82 
84 namespace PMPolygon4Extras
85 {
86  inline PMPoint TopLeft(const PMPolygon4& bounds4);
87  inline PMPoint TopCenter(const PMPolygon4& bounds4);
88  inline PMPoint TopRight(const PMPolygon4& bounds4);
89  inline PMPoint LeftCenter(const PMPolygon4& bounds4);
90  inline PMPoint Center(const PMPolygon4& bounds4);
91  inline PMPoint RightCenter(const PMPolygon4& bounds4);
92  inline PMPoint BottomLeft(const PMPolygon4& bounds4);
93  inline PMPoint BottomCenter(const PMPolygon4& bounds4);
94  inline PMPoint BottomRight(const PMPolygon4& bounds4);
95 
96  inline PMReal Left(const PMPolygon4& bounds4);
97  inline PMReal Top(const PMPolygon4& bounds4);
98  inline PMReal Right(const PMPolygon4& bounds4);
99  inline PMReal Bottom(const PMPolygon4& bounds4);
100 
101  inline PMPoint GetPoint(const PMPolygon4& bounds4, PMRect::PointIndex whichPoint);
102  inline PMPoint GetOppositePoint(const PMPolygon4& bounds4, PMRect::PointIndex whichPoint);
103 }
104 
105 inline PMPoint PMPolygon4Extras::TopLeft(const PMPolygon4& bounds4)
106 {
107  return bounds4[0];
108 }
109 inline PMPoint PMPolygon4Extras::TopCenter(const PMPolygon4& bounds4)
110 {
111  return (bounds4[0] + bounds4[1]) / 2;
112 }
113 inline PMPoint PMPolygon4Extras::TopRight(const PMPolygon4& bounds4)
114 {
115  return bounds4[1];
116 }
117 inline PMPoint PMPolygon4Extras::LeftCenter(const PMPolygon4& bounds4)
118 {
119  return (bounds4[0] + bounds4[3]) / 2;
120 }
121 inline PMPoint PMPolygon4Extras::Center(const PMPolygon4& bounds4)
122 {
123  return (bounds4[0] + bounds4[2]) / 2;
124 }
125 inline PMPoint PMPolygon4Extras::RightCenter(const PMPolygon4& bounds4)
126 {
127  return (bounds4[1] + bounds4[2]) / 2;
128 }
129 inline PMPoint PMPolygon4Extras::BottomLeft(const PMPolygon4& bounds4)
130 {
131  return bounds4[3];
132 }
133 inline PMPoint PMPolygon4Extras::BottomCenter(const PMPolygon4& bounds4)
134 {
135  return (bounds4[3] + bounds4[2]) / 2;
136 }
137 inline PMPoint PMPolygon4Extras::BottomRight(const PMPolygon4& bounds4)
138 {
139  return bounds4[2];
140 }
141 
142 inline PMReal PMPolygon4Extras::Left(const PMPolygon4& bounds4)
143 {
144  return bounds4[0].X();
145 }
146 inline PMReal PMPolygon4Extras::Top(const PMPolygon4& bounds4)
147 {
148  return bounds4[0].Y();
149 }
150 inline PMReal PMPolygon4Extras::Right(const PMPolygon4& bounds4)
151 {
152  return bounds4[2].X();
153 }
154 inline PMReal PMPolygon4Extras::Bottom(const PMPolygon4& bounds4)
155 {
156  return bounds4[2].Y();
157 }
158 
159 inline PMPoint PMPolygon4Extras::GetPoint(const PMPolygon4& bounds4, PMRect::PointIndex whichPoint)
160 {
161  PMPoint thePoint;
162 
163  switch (whichPoint)
164  {
165  case PMRect::kMiddleTop:
166  thePoint = PMPolygon4Extras::TopCenter(bounds4);
167  break;
168  case PMRect::kLeftMiddle:
169  thePoint = PMPolygon4Extras::LeftCenter(bounds4);
170  break;
172  thePoint = PMPolygon4Extras::BottomCenter(bounds4);
173  break;
175  thePoint = PMPolygon4Extras::RightCenter(bounds4);
176  break;
177  case PMRect::kLeftTop:
178  thePoint = PMPolygon4Extras::TopLeft(bounds4);
179  break;
180  case PMRect::kRightTop:
181  thePoint = PMPolygon4Extras::TopRight(bounds4);
182  break;
184  thePoint = PMPolygon4Extras::BottomRight(bounds4);
185  break;
186  case PMRect::kLeftBottom:
187  thePoint = PMPolygon4Extras::BottomLeft(bounds4);
188  break;
189  case PMRect::kCenter:
190  thePoint = PMPolygon4Extras::Center(bounds4);
191  break;
192  default:
193  ASSERT_FAIL("Invalid PointIndex in PMPolygon4Extras::GetPoint");
194  }
195  return thePoint;
196 }
197 
198 inline PMPoint PMPolygon4Extras::GetOppositePoint(const PMPolygon4& bounds4, PMRect::PointIndex whichPoint)
199 {
200  return GetPoint(bounds4, kEmptyRect.GetOppositePointIndex(whichPoint));
201 }
202 
203 #endif // __IRefPointShape__