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