• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_SPAN_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_SPAN_MODEL_NG_H
18 
19 #include <functional>
20 #include <string>
21 
22 #include "interfaces/native/node/styled_string.h"
23 
24 #include "core/components_ng/pattern/text/span_model.h"
25 #include "core/components_ng/pattern/text/span_node.h"
26 namespace OHOS::Ace::NG {
27 class ACE_EXPORT SpanModelNG : public SpanModel {
28 public:
29     void Create(const std::u16string& content) override;
30     void Create(const std::u16string& content, RefPtr<ResourceObject>& resObj) override;
31     void SetFont(const Font& value) override;
32     void ResetFont() override;
33     void SetFontSize(const Dimension& value) override;
34     void ResetFontSize() override;
35     void SetTextColor(const Color& value) override;
36     void ResetTextColor() override;
37     void SetItalicFontStyle(Ace::FontStyle value) override;
38     void ResetItalicFontStyle() override;
39     void SetFontWeight(FontWeight value) override;
40     void ResetFontWeight() override;
41     void SetFontFamily(const std::vector<std::string>& value) override;
42     void ResetFontFamily() override;
43     void SetTextDecoration(TextDecoration value) override;
44     void SetTextDecorationStyle(TextDecorationStyle value) override;
45     void SetTextDecorationColor(const Color& value) override;
46     void SetTextCase(TextCase value) override;
47     void SetTextShadow(const std::vector<Shadow>& value) override;
48     void SetLetterSpacing(const Dimension& value) override;
49     void SetBaselineOffset(const Dimension& value) override;
50     void SetLineHeight(const Dimension& value) override;
51     void SetOnClick(std::function<void(BaseEventInfo* info)>&& click) override;
52     void ClearOnClick() override;
53     void SetAccessibilityText(const std::string& text) override;
54     void SetAccessibilityDescription(const std::string& description) override;
55     void SetAccessibilityImportance(const std::string& importance) override;
56     void SetLineThicknessScale(float value) override;
57     void SetOnHover(OnHoverFunc&& onHoverEventFunc) override;
58     void ResetOnHover() override;
59 
60     static RefPtr<SpanNode> CreateSpanNode(int32_t nodeId, const std::u16string& content);
61     static void InitSpan(UINode* uiNode, const std::u16string& content);
62     static void SetFontWeight(UINode* uiNode, FontWeight value);
63     static void ResetFontWeight(UINode* uiNode);
64     static void SetTextCase(UINode* uiNode, TextCase value);
65     static void ResetTextCase(UINode* uiNode);
66     static void SetItalicFontStyle(UINode* uiNode, Ace::FontStyle value);
67     static void ResetItalicFontStyle(UINode* uiNode);
68     static void SetLineHeight(UINode* uiNode, const Dimension& value);
69     static void ResetLineHeight(UINode* uiNode);
70     static void SetFontSize(UINode* uiNode, const Dimension& value);
71     static void ResetFontSize(UINode* uiNode);
72     static void SetFontFamily(UINode* uiNode, const std::vector<std::string>& value);
73     static void ResetFontFamily(UINode* uiNode);
74     static void SetTextDecoration(UINode* uiNode, TextDecoration value);
75     static void ResetTextDecoration(UINode* uiNode);
76     static void SetTextDecorationStyle(UINode* uiNode, TextDecorationStyle value);
77     static void ResetTextDecorationStyle(UINode* uiNode);
78     static void SetTextDecorationColor(UINode* uiNode, const Color& value);
79     static void ResetTextDecorationColor(UINode* uiNode);
80     static void SetTextColor(UINode* uiNode, const Color& value);
81     static void ResetTextColor(UINode* uiNode);
82     static void SetLetterSpacing(UINode* uiNode, const Dimension& value);
83     static void ResetLetterSpacing(UINode* uiNode);
84     static void SetBaselineOffset(UINode* uiNode, const Dimension& value);
85     static void SetFont(UINode* uiNode, const Font& value);
86     static void ResetFont(UINode* uiNode);
87     static std::u16string GetContent(UINode* uiNode);
88     static Ace::TextDecoration GetTextDecoration(UINode* uiNode);
89     static Color GetTextDecorationColor(UINode* uiNode);
90     static Ace::TextDecorationStyle GetTextDecorationStyle(UINode* uiNode);
91     static Color GetFontColor(UINode* uiNode);
92     static Dimension GetFontSize(UINode* uiNode);
93     static Ace::FontStyle GetFontStyle(UINode* uiNode);
94     static FontWeight GetFontWeight(UINode* uiNode);
95     static Dimension GetTextLineHeight(UINode* uiNode);
96     static Ace::TextCase GetTextCase(UINode* uiNode);
97     static Dimension GetLetterSpacing(UINode* uiNode);
98     static Dimension GetBaselineOffset(UINode* uiNode);
99     static TextStyle GetDefaultTextStyle(int32_t themeScopeId);
100     void CreateContainSpan() override;
101     void SetTextBackgroundStyle(const TextBackgroundStyle& style) override;
102     static void SetTextBackgroundStyle(UINode* uiNode, const TextBackgroundStyle& style);
103     static void SetTextBackgroundStyleByBaseSpan(UINode* uiNode, const TextBackgroundStyle& style);
104     static TextBackgroundStyle GetSpanTextBackgroundStyle(UINode* uiNode);
105     static void SetTextShadow(UINode* uiNode, const std::vector<Shadow>& value);
106     static void ResetTextShadow(UINode* uiNode);
107     static std::vector<Shadow> GetTextShadow(UINode* uiNode);
108     static void SetOnClick(UINode* uiNode, GestureEventFunc&& click);
109     static void ClearOnClick(UINode* uiNode);
110     static void SetOnLongPress(UINode* uiNode, GestureEventFunc&& onLongPress);
111     static void ClearOnLongPress(UINode* uiNode);
112     static void SetAccessibilityText(UINode* uiNode, const std::string& text);
113     static void SetAccessibilityDescription(UINode* uiNode, const std::string& description);
114     static void SetAccessibilityImportance(UINode* uiNode, const std::string& importance);
115     static void SetOnHover(UINode* uiNode, OnHoverFunc&& onHoverEventFunc);
116     static void ResetOnHover(UINode* uiNode);
117     static std::vector<std::string> GetSpanFontFamily(UINode* uiNode);
118     // impl in render/adapter/span_model_adapter.cpp
119     static RefPtr<SpanItem> CreateSpanItem(ArkUI_SpanItem* item);
120     static ParagraphStyle CreateParagraphStyle(ArkUI_StyledString* styledString);
121     static void SetLineThicknessScale(UINode *uiNode, float value);
122     static void ResetLineThicknessScale(UINode* uiNode);
123 };
124 } // namespace OHOS::Ace::NG
125 
126 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_SPAN_MODEL_NG_H
127