• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FXJS_CJS_COLOR_H_
8 #define FXJS_CJS_COLOR_H_
9 
10 #include <vector>
11 
12 #include "fpdfsdk/pwl/cpwl_wnd.h"
13 #include "fxjs/JS_Define.h"
14 
15 class color : public CJS_EmbedObj {
16  public:
17   static v8::Local<v8::Array> ConvertPWLColorToArray(CJS_Runtime* pRuntime,
18                                                      const CFX_Color& color);
19   static CFX_Color ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
20                                           v8::Local<v8::Array> array);
21 
22   explicit color(CJS_Object* pJSObject);
23   ~color() override;
24 
25   CJS_Return get_black(CJS_Runtime* pRuntime);
26   CJS_Return set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
27 
28   CJS_Return get_blue(CJS_Runtime* pRuntime);
29   CJS_Return set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
30 
31   CJS_Return get_cyan(CJS_Runtime* pRuntime);
32   CJS_Return set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
33 
34   CJS_Return get_dark_gray(CJS_Runtime* pRuntime);
35   CJS_Return set_dark_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
36 
37   CJS_Return get_gray(CJS_Runtime* pRuntime);
38   CJS_Return set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
39 
40   CJS_Return get_green(CJS_Runtime* pRuntime);
41   CJS_Return set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
42 
43   CJS_Return get_light_gray(CJS_Runtime* pRuntime);
44   CJS_Return set_light_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
45 
46   CJS_Return get_magenta(CJS_Runtime* pRuntime);
47   CJS_Return set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
48 
49   CJS_Return get_red(CJS_Runtime* pRuntime);
50   CJS_Return set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
51 
52   CJS_Return get_transparent(CJS_Runtime* pRuntime);
53   CJS_Return set_transparent(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
54 
55   CJS_Return get_white(CJS_Runtime* pRuntime);
56   CJS_Return set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
57 
58   CJS_Return get_yellow(CJS_Runtime* pRuntime);
59   CJS_Return set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
60 
61   CJS_Return convert(CJS_Runtime* pRuntime,
62                      const std::vector<v8::Local<v8::Value>>& params);
63   CJS_Return equal(CJS_Runtime* pRuntime,
64                    const std::vector<v8::Local<v8::Value>>& params);
65 
66  private:
67   CJS_Return GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* val);
68   CJS_Return SetPropertyHelper(CJS_Runtime* pRuntime,
69                                v8::Local<v8::Value> vp,
70                                CFX_Color* val);
71 
72   CFX_Color m_crTransparent;
73   CFX_Color m_crBlack;
74   CFX_Color m_crWhite;
75   CFX_Color m_crRed;
76   CFX_Color m_crGreen;
77   CFX_Color m_crBlue;
78   CFX_Color m_crCyan;
79   CFX_Color m_crMagenta;
80   CFX_Color m_crYellow;
81   CFX_Color m_crDKGray;
82   CFX_Color m_crGray;
83   CFX_Color m_crLTGray;
84 };
85 
86 class CJS_Color : public CJS_Object {
87  public:
88   static void DefineJSObjects(CFXJS_Engine* pEngine);
89 
CJS_Color(v8::Local<v8::Object> pObject)90   explicit CJS_Color(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Color()91   ~CJS_Color() override {}
92 
93   JS_STATIC_PROP(black, black, color);
94   JS_STATIC_PROP(blue, blue, color);
95   JS_STATIC_PROP(cyan, cyan, color);
96   JS_STATIC_PROP(dkGray, dark_gray, color);
97   JS_STATIC_PROP(gray, gray, color);
98   JS_STATIC_PROP(green, green, color);
99   JS_STATIC_PROP(ltGray, light_gray, color);
100   JS_STATIC_PROP(magenta, magenta, color);
101   JS_STATIC_PROP(red, red, color);
102   JS_STATIC_PROP(transparent, transparent, color);
103   JS_STATIC_PROP(white, white, color);
104   JS_STATIC_PROP(yellow, yellow, color);
105 
106   JS_STATIC_METHOD(convert, color);
107   JS_STATIC_METHOD(equal, color);
108 
109  private:
110   static int ObjDefnID;
111   static const JSPropertySpec PropertySpecs[];
112   static const JSMethodSpec MethodSpecs[];
113 };
114 
115 #endif  // FXJS_CJS_COLOR_H_
116