• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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_TEXT_VIEW_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_TEXT_VIEW_H
18 
19 #include <functional>
20 #include <string>
21 
22 #include "core/components/common/properties/text_style.h"
23 #include "core/components_ng/pattern/text/text_model.h"
24 
25 namespace OHOS::Ace::NG {
26 
27 class ACE_EXPORT TextModelNG : public TextModel {
28 public:
29     void Create(const std::string& content) override;
30     void SetFont(const Font& value) override;
31     void SetFontSize(const Dimension& value) override;
32     void SetTextColor(const Color& value) override;
33     void SetTextSelection(int32_t startIndex, int32_t endIndex) override;
34     void SetTextShadow(const std::vector<Shadow>& value) override;
35     void SetItalicFontStyle(Ace::FontStyle value) override;
36     void SetFontWeight(FontWeight value) override;
37     void SetFontFamily(const std::vector<std::string>& value) override;
38     void SetTextAlign(TextAlign value) override;
39     void SetTextOverflow(TextOverflow value) override;
40     void SetMaxLines(uint32_t value) override;
41     void SetTextIndent(const Dimension& value) override;
42     void SetLineHeight(const Dimension& value) override;
43     void SetTextDecoration(TextDecoration value) override;
44     void SetTextDecorationColor(const Color& value) override;
45     void SetTextDecorationStyle(TextDecorationStyle value) override;
46     void SetBaselineOffset(const Dimension& value) override;
47     void SetWordBreak(WordBreak value) override;
48     void SetEllipsisMode(EllipsisMode modal) override;
49     void SetTextCase(TextCase value) override;
50     void SetLetterSpacing(const Dimension& value) override;
51     void SetAdaptMinFontSize(const Dimension& value) override;
52     void SetAdaptMaxFontSize(const Dimension& value) override;
53     void SetHeightAdaptivePolicy(TextHeightAdaptivePolicy value) override;
54     void SetTextDetectEnable(bool value) override;
55     void SetTextDetectConfig(const std::string& value, std::function<void(const std::string&)>&& onResult) override;
56     // TODO: add extra event for text.
57     void SetOnClick(std::function<void(const BaseEventInfo* info)>&& click) override;
58     void ClearOnClick() override;
59     void SetRemoteMessage(std::function<void()>&& event) override;
60     void SetCopyOption(CopyOptions copyOption) override;
61     void SetOnCopy(std::function<void(const std::string&)>&& func) override;
62     void SetOnDragStart(NG::OnDragStartFunc&& onDragStart) override;
63     void SetOnDragEnter(NG::OnDragDropFunc&& onDragEnter) override;
64     void SetOnDragMove(NG::OnDragDropFunc&& onDragMove) override;
65     void SetOnDragLeave(NG::OnDragDropFunc&& onDragLeave) override;
66     void SetOnDrop(NG::OnDragDropFunc&& onDrop) override;
67     void SetDraggable(bool draggable) override;
68     void SetMenuOptionItems(std::vector<MenuOptionsParam>&& menuOptionsItems) override;
69     void BindSelectionMenu(TextSpanType& spanType, TextResponseType& responseType, std::function<void()>& buildFunc,
70         SelectMenuParam& menuParam) override;
71     void SetOnTextSelectionChange(std::function<void(int32_t, int32_t)>&& func) override;
72     RefPtr<TextControllerBase> GetTextController() override;
73     void SetClipEdge() override;
74     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId, const std::string& content);
75     static void InitText(FrameNode* frameNode, std::string& value);
76     static void SetFontWeight(FrameNode* frameNode, Ace::FontWeight value);
77     static void SetItalicFontStyle(FrameNode* frameNode, Ace::FontStyle value);
78     static void SetTextAlign(FrameNode* frameNode, Ace::TextAlign value);
79     static void SetTextColor(FrameNode* frameNode, const Color& value);
80     static void SetFontSize(FrameNode* frameNode, const Dimension& value);
81     static void SetLineHeight(FrameNode* frameNode, const Dimension& value);
82     static void SetTextOverflow(FrameNode* frameNode, TextOverflow value);
83     static void SetTextDecoration(FrameNode* frameNode, TextDecoration value);
84     static void SetTextDecorationColor(FrameNode* frameNode, const Color& value);
85     static void SetTextDecorationStyle(FrameNode* frameNode, TextDecorationStyle value);
86     static void SetTextCase(FrameNode* frameNode, TextCase value);
87     static void SetMaxLines(FrameNode* frameNode, uint32_t value);
88     static void SetAdaptMinFontSize(FrameNode* frameNode, const Dimension& value);
89     static void SetDraggable(FrameNode* frameNode, bool draggable);
90     static void SetAdaptMaxFontSize(FrameNode* frameNode, const Dimension& value);
91     static void SetFontFamily(FrameNode* frameNode, const std::vector<std::string>& value);
92     static void SetCopyOption(FrameNode* frameNode, CopyOptions copyOption);
93     static void SetTextShadow(FrameNode* frameNode, const std::vector<Shadow>& value);
94     static void SetHeightAdaptivePolicy(FrameNode* frameNode, TextHeightAdaptivePolicy value);
95     static void SetTextIndent(FrameNode* frameNode, const Dimension& value);
96     static void SetBaselineOffset(FrameNode* frameNode, const Dimension& value);
97     static void SetLetterSpacing(FrameNode* frameNode, const Dimension& value);
98     static void SetFont(FrameNode* frameNode, const Font& value);
99     static void SetWordBreak(FrameNode* frameNode, WordBreak value);
100     static void SetEllipsisMode(FrameNode* frameNode, EllipsisMode value);
101 };
102 } // namespace OHOS::Ace::NG
103 
104 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_TEXT_VIEW_H
105