blob: 03aa7357ab7caebf29b148201b998a00f8a5a660 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Dan Sinclaire0345a42017-10-30 20:20:42 +00007#ifndef FXJS_CJS_COLOR_H_
8#define FXJS_CJS_COLOR_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Dan Sinclair3ebd1212016-03-09 09:59:23 -050010#include <vector>
11
Lei Zhang31beedc2018-10-18 21:09:55 +000012#include "fxjs/cjs_object.h"
Tom Sepez221f0b32018-06-04 22:11:27 +000013#include "fxjs/js_define.h"
Tom Sepez9a3f8122015-04-07 15:35:48 -070014
Tom Sepez55865452018-08-27 20:18:04 +000015class CJS_Color final : public CJS_Object {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070016 public:
Lei Zhangad1f7b42018-07-11 13:04:43 +000017 static int GetObjDefnID();
Dan Sinclairf7435522018-02-05 22:27:22 +000018 static void DefineJSObjects(CFXJS_Engine* pEngine);
Dan Sinclair3a1ba8e2017-10-26 09:28:59 -040019 static v8::Local<v8::Array> ConvertPWLColorToArray(CJS_Runtime* pRuntime,
20 const CFX_Color& color);
Dan Sinclair0e187d82017-10-23 12:08:34 -040021 static CFX_Color ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
Dan Sinclair3a1ba8e2017-10-26 09:28:59 -040022 v8::Local<v8::Array> array);
Dan Sinclair0e187d82017-10-23 12:08:34 -040023
Tom Sepez36aae4f2018-06-04 19:44:37 +000024 CJS_Color(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
Dan Sinclairf7435522018-02-05 22:27:22 +000025 ~CJS_Color() override;
26
Nico Weber563f62a2019-02-12 18:47:12 +000027 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)
Dan Sinclairf7435522018-02-05 22:27:22 +000039
Nico Weber563f62a2019-02-12 18:47:12 +000040 JS_STATIC_METHOD(convert, CJS_Color)
41 JS_STATIC_METHOD(equal, CJS_Color)
Dan Sinclairf7435522018-02-05 22:27:22 +000042
43 private:
44 static int ObjDefnID;
45 static const char kName[];
46 static const JSPropertySpec PropertySpecs[];
47 static const JSMethodSpec MethodSpecs[];
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048
Tom Sepez3a6d0582018-08-17 19:28:52 +000049 CJS_Result get_black(CJS_Runtime* pRuntime);
50 CJS_Result set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040051
Tom Sepez3a6d0582018-08-17 19:28:52 +000052 CJS_Result get_blue(CJS_Runtime* pRuntime);
53 CJS_Result set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040054
Tom Sepez3a6d0582018-08-17 19:28:52 +000055 CJS_Result get_cyan(CJS_Runtime* pRuntime);
56 CJS_Result set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040057
Tom Sepez3a6d0582018-08-17 19:28:52 +000058 CJS_Result get_dark_gray(CJS_Runtime* pRuntime);
59 CJS_Result set_dark_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040060
Tom Sepez3a6d0582018-08-17 19:28:52 +000061 CJS_Result get_gray(CJS_Runtime* pRuntime);
62 CJS_Result set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040063
Tom Sepez3a6d0582018-08-17 19:28:52 +000064 CJS_Result get_green(CJS_Runtime* pRuntime);
65 CJS_Result set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040066
Tom Sepez3a6d0582018-08-17 19:28:52 +000067 CJS_Result get_light_gray(CJS_Runtime* pRuntime);
68 CJS_Result set_light_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040069
Tom Sepez3a6d0582018-08-17 19:28:52 +000070 CJS_Result get_magenta(CJS_Runtime* pRuntime);
71 CJS_Result set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040072
Tom Sepez3a6d0582018-08-17 19:28:52 +000073 CJS_Result get_red(CJS_Runtime* pRuntime);
74 CJS_Result set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040075
Tom Sepez3a6d0582018-08-17 19:28:52 +000076 CJS_Result get_transparent(CJS_Runtime* pRuntime);
77 CJS_Result set_transparent(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040078
Tom Sepez3a6d0582018-08-17 19:28:52 +000079 CJS_Result get_white(CJS_Runtime* pRuntime);
80 CJS_Result set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
dan sinclaircbe23db2017-10-19 14:29:33 -040081
Tom Sepez3a6d0582018-08-17 19:28:52 +000082 CJS_Result get_yellow(CJS_Runtime* pRuntime);
83 CJS_Result set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070084
Tom Sepez3a6d0582018-08-17 19:28:52 +000085 CJS_Result convert(CJS_Runtime* pRuntime,
Dan Sinclair8f524d62017-10-25 13:30:31 -040086 const std::vector<v8::Local<v8::Value>>& params);
Tom Sepez3a6d0582018-08-17 19:28:52 +000087 CJS_Result equal(CJS_Runtime* pRuntime,
Dan Sinclair8f524d62017-10-25 13:30:31 -040088 const std::vector<v8::Local<v8::Value>>& params);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070089
Tom Sepez3a6d0582018-08-17 19:28:52 +000090 CJS_Result GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* val);
91 CJS_Result SetPropertyHelper(CJS_Runtime* pRuntime,
Dan Sinclair8f524d62017-10-25 13:30:31 -040092 v8::Local<v8::Value> vp,
93 CFX_Color* val);
Tom Sepez37a35df2017-02-21 11:43:14 -080094
Dan Sinclair7f55a542017-07-13 14:17:10 -040095 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;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700107};
108
Dan Sinclaire0345a42017-10-30 20:20:42 +0000109#endif // FXJS_CJS_COLOR_H_