• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef TEXTNODE_JS_H
17 #define TEXTNODE_JS_H
18 
19 #include <meta/interface/intf_object.h>
20 
21 #include "BaseObjectJS.h"
22 #include "NodeImpl.h"
23 #include "ColorProxy.h"
24 
25 class TextNodeJS : public BaseObject, NodeImpl {
26 public:
27     static constexpr uint32_t ID = 140;
28     static void Init(napi_env env, napi_value exports);
29     TextNodeJS(napi_env, napi_callback_info);
30     ~TextNodeJS() override;
31     void* GetInstanceImpl(uint32_t) override;
32 
33 private:
34     void DisposeNative(void*) override;
35     void Finalize(napi_env env) override;
36 
37 private:
38     napi_value GetText(NapiApi::FunctionContext<>& ctx);
39     void SetText(NapiApi::FunctionContext<BASE_NS::string>& ctx);
40     napi_value GetFont(NapiApi::FunctionContext<>& ctx);
41     void SetFont(NapiApi::FunctionContext<BASE_NS::string>& ctx);
42     napi_value GetColor(NapiApi::FunctionContext<>& ctx);
43     void SetColor(NapiApi::FunctionContext<NapiApi::Object>& ctx);
44     napi_value GetFontSize(NapiApi::FunctionContext<>& ctx);
45     void SetFontSize(NapiApi::FunctionContext<float>& ctx);
46 
47 private:
48     BASE_NS::unique_ptr<ColorProxy> color_;
49 };
50 
51 #endif // TEXTNODE_JS_H
52