Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: fpdfsdk/include/pdfwindow/PWL_Utils.h

Issue 1823153002: Move the fpdfsdk/include/pdfwindow/ headers into fpdfsdk/pdfwindow. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/pdfwindow/PWL_SpecialButton.h ('k') | fpdfsdk/include/pdfwindow/PWL_Wnd.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_
8 #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_
9
10 #include "core/include/fpdfdoc/fpdf_vt.h" // For CPVT_WordRange.
11 #include "fpdfsdk/include/fxedit/fx_edit.h"
12 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
13
14 class CFX_PathData;
15 struct CPWL_Color;
16
17 template <class T>
18 T PWL_MIN(const T& i, const T& j) {
19 return ((i < j) ? i : j);
20 }
21 template <class T>
22 T PWL_MAX(const T& i, const T& j) {
23 return ((i > j) ? i : j);
24 }
25
26 #define PWL_PDF2WIN(color) (uint8_t(color * 255))
27 #define PWL_WIN2PDF(color) ((FX_FLOAT)((FX_FLOAT)color / 255.0f))
28
29 #define PWL_MAKEDWORD(low, high) \
30 ((FX_DWORD)((uint16_t)(low) | (FX_DWORD)(((uint16_t)(high)) << 16)))
31 #define PWL_GETLOWWORD(dword) ((uint16_t)(dword))
32 #define PWL_GETHIGHWORD(dword) ((uint16_t)(dword >> 16))
33
34 #define PWL_ICONTYPE_CHECKMARK 0
35 #define PWL_ICONTYPE_CIRCLE 1
36 #define PWL_ICONTYPE_COMMENT 2
37 #define PWL_ICONTYPE_CROSS 3
38 #define PWL_ICONTYPE_HELP 4
39 #define PWL_ICONTYPE_INSERTTEXT 5
40 #define PWL_ICONTYPE_KEY 6
41 #define PWL_ICONTYPE_NEWPARAGRAPH 7
42 #define PWL_ICONTYPE_TEXTNOTE 8
43 #define PWL_ICONTYPE_PARAGRAPH 9
44 #define PWL_ICONTYPE_RIGHTARROW 10
45 #define PWL_ICONTYPE_RIGHTPOINTER 11
46 #define PWL_ICONTYPE_STAR 12
47 #define PWL_ICONTYPE_UPARROW 13
48 #define PWL_ICONTYPE_UPLEFTARROW 14
49
50 #define PWL_ICONTYPE_GRAPH 15
51 #define PWL_ICONTYPE_PAPERCLIP 16
52 #define PWL_ICONTYPE_ATTACHMENT 17
53 #define PWL_ICONTYPE_TAG 18
54
55 #define PWL_ICONTYPE_FOXIT 19
56
57 #define PWL_ICONTYPE_UNKNOWN -1
58
59 // checkbox & radiobutton style
60 #define PCS_CHECK 0
61 #define PCS_CIRCLE 1
62 #define PCS_CROSS 2
63 #define PCS_DIAMOND 3
64 #define PCS_SQUARE 4
65 #define PCS_STAR 5
66
67 // pushbutton layout style
68 #define PPBL_LABEL 0
69 #define PPBL_ICON 1
70 #define PPBL_ICONTOPLABELBOTTOM 2
71 #define PPBL_LABELTOPICONBOTTOM 3
72 #define PPBL_ICONLEFTLABELRIGHT 4
73 #define PPBL_LABELLEFTICONRIGHT 5
74 #define PPBL_LABELOVERICON 6
75
76 class CPWL_Point : public CFX_FloatPoint {
77 public:
78 CPWL_Point() : CFX_FloatPoint(0.0f, 0.0f) {}
79 CPWL_Point(FX_FLOAT fx, FX_FLOAT fy) : CFX_FloatPoint(fx, fy) {}
80 CPWL_Point(const CPWL_Point& point) : CFX_FloatPoint(point.x, point.y) {}
81 };
82
83 enum PWL_PATHDATA_TYPE {
84 PWLPT_MOVETO,
85 PWLPT_LINETO,
86 PWLPT_BEZIERTO,
87 PWLPT_UNKNOWN
88 };
89
90 enum PWL_PATH_TYPE { PWLPT_PATHDATA, PWLPT_STREAM };
91
92 class CPWL_PathData {
93 public:
94 CPWL_PathData() : point(), type(PWLPT_UNKNOWN) {}
95 CPWL_PathData(const CPWL_Point& pt, PWL_PATHDATA_TYPE tp)
96 : point(pt), type(tp) {}
97
98 CPWL_Point point;
99 PWL_PATHDATA_TYPE type;
100 };
101
102 class IPWL_SpellCheck;
103
104 class CPWL_Utils {
105 public:
106 static CFX_FloatRect InflateRect(const CFX_FloatRect& rcRect, FX_FLOAT fSize);
107 static CFX_FloatRect DeflateRect(const CFX_FloatRect& rcRect, FX_FLOAT fSize);
108 static FX_BOOL IntersectRect(const CFX_FloatRect& rect1,
109 const CFX_FloatRect& rect2);
110 static FX_BOOL ContainsRect(const CFX_FloatRect& rcParent,
111 const CFX_FloatRect& rcChild);
112 static CFX_FloatRect ScaleRect(const CFX_FloatRect& rcRect, FX_FLOAT fScale);
113 static CPVT_WordRange OverlapWordRange(const CPVT_WordRange& wr1,
114 const CPVT_WordRange& wr2);
115 static CFX_FloatRect GetCenterSquare(const CFX_FloatRect& rect);
116 static CPWL_Color SubstractColor(const CPWL_Color& sColor,
117 FX_FLOAT fColorSub);
118 static CPWL_Color DevideColor(const CPWL_Color& sColor,
119 FX_FLOAT fColorDevide);
120 static CFX_FloatRect MaxRect(const CFX_FloatRect& rect1,
121 const CFX_FloatRect& rect2);
122 static CFX_FloatRect OffsetRect(const CFX_FloatRect& rect,
123 FX_FLOAT x,
124 FX_FLOAT y);
125 static CFX_FloatPoint OffsetPoint(const CFX_FloatPoint& point,
126 FX_FLOAT x,
127 FX_FLOAT y);
128 static FX_COLORREF PWLColorToFXColor(const CPWL_Color& color,
129 int32_t nTransparancy = 255);
130 static FX_BOOL IsBlackOrWhite(const CPWL_Color& color);
131 static CPWL_Color GetReverseColor(const CPWL_Color& color);
132
133 static CFX_ByteString GetColorAppStream(const CPWL_Color& color,
134 const FX_BOOL& bFillOrStroke = TRUE);
135 static CFX_ByteString GetBorderAppStream(const CFX_FloatRect& rect,
136 FX_FLOAT fWidth,
137 const CPWL_Color& color,
138 const CPWL_Color& crLeftTop,
139 const CPWL_Color& crRightBottom,
140 int32_t nStyle,
141 const CPWL_Dash& dash);
142 static CFX_ByteString GetCircleBorderAppStream(
143 const CFX_FloatRect& rect,
144 FX_FLOAT fWidth,
145 const CPWL_Color& color,
146 const CPWL_Color& crLeftTop,
147 const CPWL_Color& crRightBottom,
148 int32_t nStyle,
149 const CPWL_Dash& dash);
150 static CFX_ByteString GetRectFillAppStream(const CFX_FloatRect& rect,
151 const CPWL_Color& color);
152 static CFX_ByteString GetCircleFillAppStream(const CFX_FloatRect& rect,
153 const CPWL_Color& color);
154
155 static CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
156 IFX_Edit_FontMap* pFontMap,
157 CPDF_Stream* pIconStream,
158 CPDF_IconFit& IconFit,
159 const CFX_WideString& sLabel,
160 const CPWL_Color& crText,
161 FX_FLOAT fFontSize,
162 int32_t nLayOut);
163 static CFX_ByteString GetCheckBoxAppStream(const CFX_FloatRect& rcBBox,
164 int32_t nStyle,
165 const CPWL_Color& crText);
166 static CFX_ByteString GetRadioButtonAppStream(const CFX_FloatRect& rcBBox,
167 int32_t nStyle,
168 const CPWL_Color& crText);
169
170 static CFX_ByteString GetEditAppStream(IFX_Edit* pEdit,
171 const CFX_FloatPoint& ptOffset,
172 const CPVT_WordRange* pRange = NULL,
173 FX_BOOL bContinuous = TRUE,
174 uint16_t SubWord = 0);
175 static CFX_ByteString GetEditSelAppStream(
176 IFX_Edit* pEdit,
177 const CFX_FloatPoint& ptOffset,
178 const CPVT_WordRange* pRange = NULL);
179 static CFX_ByteString GetSpellCheckAppStream(
180 IFX_Edit* pEdit,
181 IPWL_SpellCheck* pSpellCheck,
182 const CFX_FloatPoint& ptOffset,
183 const CPVT_WordRange* pRange = NULL);
184 static CFX_ByteString GetTextAppStream(const CFX_FloatRect& rcBBox,
185 IFX_Edit_FontMap* pFontMap,
186 const CFX_WideString& sText,
187 int32_t nAlignmentH,
188 int32_t nAlignmentV,
189 FX_FLOAT fFontSize,
190 FX_BOOL bMultiLine,
191 FX_BOOL bAutoReturn,
192 const CPWL_Color& crText);
193 static CFX_ByteString GetDropButtonAppStream(const CFX_FloatRect& rcBBox);
194
195 static void DrawFillRect(CFX_RenderDevice* pDevice,
196 CFX_Matrix* pUser2Device,
197 const CFX_FloatRect& rect,
198 const CPWL_Color& color,
199 int32_t nTransparancy);
200 static void DrawFillRect(CFX_RenderDevice* pDevice,
201 CFX_Matrix* pUser2Device,
202 const CFX_FloatRect& rect,
203 const FX_COLORREF& color);
204 static void DrawStrokeRect(CFX_RenderDevice* pDevice,
205 CFX_Matrix* pUser2Device,
206 const CFX_FloatRect& rect,
207 const FX_COLORREF& color,
208 FX_FLOAT fWidth);
209 static void DrawStrokeLine(CFX_RenderDevice* pDevice,
210 CFX_Matrix* pUser2Device,
211 const CFX_FloatPoint& ptMoveTo,
212 const CFX_FloatPoint& ptLineTo,
213 const FX_COLORREF& color,
214 FX_FLOAT fWidth);
215 static void DrawBorder(CFX_RenderDevice* pDevice,
216 CFX_Matrix* pUser2Device,
217 const CFX_FloatRect& rect,
218 FX_FLOAT fWidth,
219 const CPWL_Color& color,
220 const CPWL_Color& crLeftTop,
221 const CPWL_Color& crRightBottom,
222 int32_t nStyle,
223 int32_t nTransparancy);
224 static void DrawFillArea(CFX_RenderDevice* pDevice,
225 CFX_Matrix* pUser2Device,
226 const CFX_FloatPoint* pPts,
227 int32_t nCount,
228 const FX_COLORREF& color);
229 static void DrawShadow(CFX_RenderDevice* pDevice,
230 CFX_Matrix* pUser2Device,
231 FX_BOOL bVertical,
232 FX_BOOL bHorizontal,
233 CFX_FloatRect rect,
234 int32_t nTransparancy,
235 int32_t nStartGray,
236 int32_t nEndGray);
237 static void DrawEditSpellCheck(CFX_RenderDevice* pDevice,
238 CFX_Matrix* pUser2Device,
239 IFX_Edit* pEdit,
240 const CFX_FloatRect& rcClip,
241 const CFX_FloatPoint& ptOffset,
242 const CPVT_WordRange* pRange,
243 IPWL_SpellCheck* pSpellCheck);
244
245 public:
246 static void ConvertCMYK2RGB(FX_FLOAT dC,
247 FX_FLOAT dM,
248 FX_FLOAT dY,
249 FX_FLOAT dK,
250 FX_FLOAT& dR,
251 FX_FLOAT& dG,
252 FX_FLOAT& dB);
253 static void ConvertRGB2CMYK(FX_FLOAT dR,
254 FX_FLOAT dG,
255 FX_FLOAT dB,
256 FX_FLOAT& dC,
257 FX_FLOAT& dM,
258 FX_FLOAT& dY,
259 FX_FLOAT& dK);
260
261 static void ConvertRGB2GRAY(FX_FLOAT dR,
262 FX_FLOAT dG,
263 FX_FLOAT dB,
264 FX_FLOAT& dGray);
265 static void ConvertGRAY2RGB(FX_FLOAT dGray,
266 FX_FLOAT& dR,
267 FX_FLOAT& dG,
268 FX_FLOAT& dB);
269
270 static void ConvertCMYK2GRAY(FX_FLOAT dC,
271 FX_FLOAT dM,
272 FX_FLOAT dY,
273 FX_FLOAT dK,
274 FX_FLOAT& dGray);
275 static void ConvertGRAY2CMYK(FX_FLOAT dGray,
276 FX_FLOAT& dC,
277 FX_FLOAT& dM,
278 FX_FLOAT& dY,
279 FX_FLOAT& dK);
280
281 static void PWLColorToARGB(const CPWL_Color& color,
282 int32_t& alpha,
283 FX_FLOAT& red,
284 FX_FLOAT& green,
285 FX_FLOAT& blue);
286
287 public:
288 static CFX_ByteString GetIconAppStream(
289 int32_t nType,
290 const CFX_FloatRect& rect,
291 const CPWL_Color& crFill,
292 const CPWL_Color& crStroke = PWL_DEFAULT_BLACKCOLOR);
293 static void DrawIconAppStream(CFX_RenderDevice* pDevice,
294 CFX_Matrix* pUser2Device,
295 int32_t nType,
296 const CFX_FloatRect& rect,
297 const CPWL_Color& crFill,
298 const CPWL_Color& crStroke,
299 const int32_t nTransparancy);
300
301 private:
302 static CFX_ByteString GetAppStreamFromArray(const CPWL_PathData* pPathData,
303 int32_t nCount);
304 static void GetPathDataFromArray(CFX_PathData& path,
305 const CPWL_PathData* pPathData,
306 int32_t nCount);
307
308 static CFX_ByteString GetAppStream_Check(const CFX_FloatRect& rcBBox,
309 const CPWL_Color& crText);
310 static CFX_ByteString GetAppStream_Circle(const CFX_FloatRect& rcBBox,
311 const CPWL_Color& crText);
312 static CFX_ByteString GetAppStream_Cross(const CFX_FloatRect& rcBBox,
313 const CPWL_Color& crText);
314 static CFX_ByteString GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
315 const CPWL_Color& crText);
316 static CFX_ByteString GetAppStream_Square(const CFX_FloatRect& rcBBox,
317 const CPWL_Color& crText);
318 static CFX_ByteString GetAppStream_Star(const CFX_FloatRect& rcBBox,
319 const CPWL_Color& crText);
320
321 static CFX_ByteString GetAP_Check(const CFX_FloatRect& crBBox);
322 static CFX_ByteString GetAP_Circle(const CFX_FloatRect& crBBox);
323 static CFX_ByteString GetAP_Cross(const CFX_FloatRect& crBBox);
324 static CFX_ByteString GetAP_Diamond(const CFX_FloatRect& crBBox);
325 static CFX_ByteString GetAP_Square(const CFX_FloatRect& crBBox);
326 static CFX_ByteString GetAP_Star(const CFX_FloatRect& crBBox);
327 static CFX_ByteString GetAP_HalfCircle(const CFX_FloatRect& crBBox,
328 FX_FLOAT fRotate);
329
330 static void GetGraphics_Checkmark(CFX_ByteString& sPathData,
331 CFX_PathData& path,
332 const CFX_FloatRect& crBBox,
333 const PWL_PATH_TYPE type);
334 static void GetGraphics_Circle(CFX_ByteString& sPathData,
335 CFX_PathData& path,
336 const CFX_FloatRect& crBBox,
337 const PWL_PATH_TYPE type);
338 static void GetGraphics_Comment(CFX_ByteString& sPathData,
339 CFX_PathData& path,
340 const CFX_FloatRect& crBBox,
341 const PWL_PATH_TYPE type);
342 static void GetGraphics_Cross(CFX_ByteString& sPathData,
343 CFX_PathData& path,
344 const CFX_FloatRect& crBBox,
345 const PWL_PATH_TYPE type);
346 static void GetGraphics_Help(CFX_ByteString& sPathData,
347 CFX_PathData& path,
348 const CFX_FloatRect& crBBox,
349 const PWL_PATH_TYPE type);
350 static void GetGraphics_InsertText(CFX_ByteString& sPathData,
351 CFX_PathData& path,
352 const CFX_FloatRect& crBBox,
353 const PWL_PATH_TYPE type);
354 static void GetGraphics_Key(CFX_ByteString& sPathData,
355 CFX_PathData& path,
356 const CFX_FloatRect& crBBox,
357 const PWL_PATH_TYPE type);
358 static void GetGraphics_NewParagraph(CFX_ByteString& sPathData,
359 CFX_PathData& path,
360 const CFX_FloatRect& crBBox,
361 const PWL_PATH_TYPE type);
362 static void GetGraphics_TextNote(CFX_ByteString& sPathData,
363 CFX_PathData& path,
364 const CFX_FloatRect& crBBox,
365 const PWL_PATH_TYPE type);
366 static void GetGraphics_Paragraph(CFX_ByteString& sPathData,
367 CFX_PathData& path,
368 const CFX_FloatRect& crBBox,
369 const PWL_PATH_TYPE type);
370 static void GetGraphics_RightArrow(CFX_ByteString& sPathData,
371 CFX_PathData& path,
372 const CFX_FloatRect& crBBox,
373 const PWL_PATH_TYPE type);
374 static void GetGraphics_RightPointer(CFX_ByteString& sPathData,
375 CFX_PathData& path,
376 const CFX_FloatRect& crBBox,
377 const PWL_PATH_TYPE type);
378 static void GetGraphics_Star(CFX_ByteString& sPathData,
379 CFX_PathData& path,
380 const CFX_FloatRect& crBBox,
381 const PWL_PATH_TYPE type);
382 static void GetGraphics_UpArrow(CFX_ByteString& sPathData,
383 CFX_PathData& path,
384 const CFX_FloatRect& crBBox,
385 const PWL_PATH_TYPE type);
386 static void GetGraphics_UpLeftArrow(CFX_ByteString& sPathData,
387 CFX_PathData& path,
388 const CFX_FloatRect& crBBox,
389 const PWL_PATH_TYPE type);
390 static void GetGraphics_Graph(CFX_ByteString& sPathData,
391 CFX_PathData& path,
392 const CFX_FloatRect& crBBox,
393 const PWL_PATH_TYPE type);
394 static void GetGraphics_Paperclip(CFX_ByteString& sPathData,
395 CFX_PathData& path,
396 const CFX_FloatRect& crBBox,
397 const PWL_PATH_TYPE type);
398 static void GetGraphics_Attachment(CFX_ByteString& sPathData,
399 CFX_PathData& path,
400 const CFX_FloatRect& crBBox,
401 const PWL_PATH_TYPE type);
402 static void GetGraphics_Tag(CFX_ByteString& sPathData,
403 CFX_PathData& path,
404 const CFX_FloatRect& crBBox,
405 const PWL_PATH_TYPE type);
406 static void GetGraphics_Foxit(CFX_ByteString& sPathData,
407 CFX_PathData& path,
408 const CFX_FloatRect& crBBox,
409 const PWL_PATH_TYPE type);
410 };
411
412 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/pdfwindow/PWL_SpecialButton.h ('k') | fpdfsdk/include/pdfwindow/PWL_Wnd.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698