Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cjs_color.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
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 "core/fxge/cfx_color.h"
13#include "fxjs/cjs_object.h"
14#include "fxjs/js_define.h"
15#include "third_party/base/containers/span.h"
16
17class CJS_Color final : public CJS_Object {
18 public:
19 static uint32_t GetObjDefnID();
20 static void DefineJSObjects(CFXJS_Engine* pEngine);
21 static v8::Local<v8::Array> ConvertPWLColorToArray(CJS_Runtime* pRuntime,
22 const CFX_Color& color);
23 static CFX_Color ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
24 v8::Local<v8::Array> array);
25
26 CJS_Color(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
27 ~CJS_Color() override;
28
29 JS_STATIC_PROP(black, black, CJS_Color)
30 JS_STATIC_PROP(blue, blue, CJS_Color)
31 JS_STATIC_PROP(cyan, cyan, CJS_Color)
32 JS_STATIC_PROP(dkGray, dark_gray, CJS_Color)
33 JS_STATIC_PROP(gray, gray, CJS_Color)
34 JS_STATIC_PROP(green, green, CJS_Color)
35 JS_STATIC_PROP(ltGray, light_gray, CJS_Color)
36 JS_STATIC_PROP(magenta, magenta, CJS_Color)
37 JS_STATIC_PROP(red, red, CJS_Color)
38 JS_STATIC_PROP(transparent, transparent, CJS_Color)
39 JS_STATIC_PROP(white, white, CJS_Color)
40 JS_STATIC_PROP(yellow, yellow, CJS_Color)
41
42 JS_STATIC_METHOD(convert, CJS_Color)
43 JS_STATIC_METHOD(equal, CJS_Color)
44
45 private:
46 static uint32_t ObjDefnID;
47 static const char kName[];
48 static const JSPropertySpec PropertySpecs[];
49 static const JSMethodSpec MethodSpecs[];
50
51 CJS_Result get_black(CJS_Runtime* pRuntime);
52 CJS_Result set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
53
54 CJS_Result get_blue(CJS_Runtime* pRuntime);
55 CJS_Result set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
56
57 CJS_Result get_cyan(CJS_Runtime* pRuntime);
58 CJS_Result set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
59
60 CJS_Result get_dark_gray(CJS_Runtime* pRuntime);
61 CJS_Result set_dark_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
62
63 CJS_Result get_gray(CJS_Runtime* pRuntime);
64 CJS_Result set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
65
66 CJS_Result get_green(CJS_Runtime* pRuntime);
67 CJS_Result set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
68
69 CJS_Result get_light_gray(CJS_Runtime* pRuntime);
70 CJS_Result set_light_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
71
72 CJS_Result get_magenta(CJS_Runtime* pRuntime);
73 CJS_Result set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
74
75 CJS_Result get_red(CJS_Runtime* pRuntime);
76 CJS_Result set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
77
78 CJS_Result get_transparent(CJS_Runtime* pRuntime);
79 CJS_Result set_transparent(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
80
81 CJS_Result get_white(CJS_Runtime* pRuntime);
82 CJS_Result set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
83
84 CJS_Result get_yellow(CJS_Runtime* pRuntime);
85 CJS_Result set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
86
87 CJS_Result convert(CJS_Runtime* pRuntime,
88 pdfium::span<v8::Local<v8::Value>> params);
89 CJS_Result equal(CJS_Runtime* pRuntime,
90 pdfium::span<v8::Local<v8::Value>> params);
91
92 CJS_Result GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* val);
93 CJS_Result SetPropertyHelper(CJS_Runtime* pRuntime,
94 v8::Local<v8::Value> vp,
95 CFX_Color* val);
96
97 CFX_Color m_crTransparent;
98 CFX_Color m_crBlack;
99 CFX_Color m_crWhite;
100 CFX_Color m_crRed;
101 CFX_Color m_crGreen;
102 CFX_Color m_crBlue;
103 CFX_Color m_crCyan;
104 CFX_Color m_crMagenta;
105 CFX_Color m_crYellow;
106 CFX_Color m_crDKGray;
107 CFX_Color m_crGray;
108 CFX_Color m_crLTGray;
109};
110
111#endif // FXJS_CJS_COLOR_H_
bool operator==(const CFX_Color &c1, const CFX_Color &c2)
Definition cfx_color.h:61
@ FXJSOBJTYPE_STATIC
static v8::Local< v8::Array > ConvertPWLColorToArray(CJS_Runtime *pRuntime, const CFX_Color &color)
Definition cjs_color.cpp:55
static CFX_Color ConvertArrayToPWLColor(CJS_Runtime *pRuntime, v8::Local< v8::Array > array)
Definition cjs_color.cpp:88
~CJS_Color() override
static uint32_t GetObjDefnID()
Definition cjs_color.cpp:42
CJS_Color(v8::Local< v8::Object > pObject, CJS_Runtime *pRuntime)
static void DefineJSObjects(CFXJS_Engine *pEngine)
Definition cjs_color.cpp:47
static void DefineProps(CFXJS_Engine *pEngine, uint32_t nObjDefnID, pdfium::span< const JSPropertySpec > consts)
static void DefineMethods(CFXJS_Engine *pEngine, uint32_t nObjDefnID, pdfium::span< const JSMethodSpec > consts)
static CJS_Result Success()
Definition cjs_result.h:27
static CJS_Result Failure(JSMessage id)
Definition cjs_result.h:34
bool EqualsASCII(ByteStringView that) const
Definition widestring.h:216
#define JS_STATIC_METHOD(method_name, class_name)
Definition js_define.h:155
#define JS_STATIC_PROP(err_name, prop_name, class_name)
Definition js_define.h:141
JSMessage
CFX_Color ConvertColorType(Type nConvertColorType) const
Definition cfx_color.cpp:75
Type nColorType
Definition cfx_color.h:54
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)
Definition cfx_color.h:27