• 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_MODEL_IMPL_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_MODEL_IMPL_H
18 
19 #include <functional>
20 #include <string>
21 
22 #include "core/components/common/properties/text_style.h"
23 #include "core/components/text/text_component_v2.h"
24 #include "core/components_ng/pattern/text/text_model.h"
25 
26 namespace OHOS::Ace::Framework {
27 class ACE_EXPORT TextModelImpl : public TextModel {
28 public:
29     void Create(const std::string& content) override;
30     void Create(const std::u16string& content) override;
Create(const RefPtr<SpanStringBase> & spanString)31     void Create(const RefPtr<SpanStringBase>& spanString) override {}
32     void SetFont(const Font& value) override;
33     void SetFontSize(const Dimension& value) override;
34     void SetTextColor(const Color& value) override;
ResetTextColor()35     void ResetTextColor() override {};
36     void SetTextShadow(const std::vector<Shadow>& value) override;
SetTextSelection(int32_t startIndex,int32_t endIndex)37     void SetTextSelection(int32_t startIndex, int32_t endIndex) override {};
SetTextSelectableMode(TextSelectableMode value)38     void SetTextSelectableMode(TextSelectableMode value) override {};
39     void SetTextCaretColor(const Color& value) override;
40     void SetSelectedBackgroundColor(const Color& value) override;
41     void SetItalicFontStyle(Ace::FontStyle value) override;
42     void SetFontWeight(FontWeight value) override;
SetVariableFontWeight(int32_t value)43     void SetVariableFontWeight(int32_t value) override {};
SetEnableVariableFontWeight(bool value)44     void SetEnableVariableFontWeight(bool value) override {};
45     void SetMinFontScale(const float value) override;
46     void SetMaxFontScale(const float value) override;
47     void SetFontFamily(const std::vector<std::string>& value) override;
48     void SetTextAlign(TextAlign value) override;
49     void SetTextOverflow(TextOverflow value) override;
50     void SetMaxLines(uint32_t value) override;
51     void SetTextIndent(const Dimension& value) override;
52     void SetLineHeight(const Dimension& value) override;
53     void SetLineSpacing(const Dimension& value) override;
54     void SetIsOnlyBetweenLines(bool isOnlyBetweenLines) override;
55     void SetGradientShaderStyle(NG::Gradient& gradient) override;
56     void SetColorShaderStyle(const Color& value) override;
57     void ResetGradientShaderStyle() override;
58     void SetOptimizeTrailingSpace(bool trim) override;
59     void SetTextDecoration(TextDecoration value) override;
60     void SetTextDecorationColor(const Color& value) override;
61     void SetTextDecorationStyle(TextDecorationStyle value) override;
62     void SetBaselineOffset(const Dimension& value) override;
63     void SetTextCase(TextCase value) override;
SetWordBreak(WordBreak value)64     void SetWordBreak(WordBreak value) override {};
SetLineBreakStrategy(LineBreakStrategy value)65     void SetLineBreakStrategy(LineBreakStrategy value) override {};
66     void SetLetterSpacing(const Dimension& value) override;
67     void SetAdaptMinFontSize(const Dimension& value) override;
68     void SetAdaptMaxFontSize(const Dimension& value) override;
69     void SetHeightAdaptivePolicy(TextHeightAdaptivePolicy value) override;
70     void SetTextDetectEnable(bool value) override;
71     void SetTextDetectConfig(const TextDetectConfig& textDetectConfig) override;
72     void OnSetHeight() override;
73     void OnSetWidth() override;
74     void OnSetAlign() override;
75     void SetOnClick(std::function<void(BaseEventInfo*)>&& click, double distanceThreshold) override;
ClearOnClick()76     void ClearOnClick() override {};
77     void SetRemoteMessage(std::function<void()>&& event) override;
78     void SetCopyOption(CopyOptions copyOption) override;
SetOnCopy(std::function<void (const std::u16string &)> && func)79     void SetOnCopy(std::function<void(const std::u16string&)>&& func) override {};
SetEllipsisMode(EllipsisMode modal)80     void SetEllipsisMode(EllipsisMode modal) override {};
SetClipEdge(bool clip)81     void SetClipEdge(bool clip) override {};
SetFontFeature(const std::list<std::pair<std::string,int32_t>> & value)82     void SetFontFeature(const std::list<std::pair<std::string, int32_t>>& value) override {};
SetMarqueeOptions(const NG::TextMarqueeOptions & options)83     void SetMarqueeOptions(const NG::TextMarqueeOptions& options) override {};
SetOnMarqueeStateChange(std::function<void (int32_t)> && func)84     void SetOnMarqueeStateChange(std::function<void(int32_t)>&& func) override {};
85     void SetOnDragStart(NG::OnDragStartFunc&& onDragStart) override;
86     void SetHalfLeading(bool halfLeading) override;
SetEnableHapticFeedback(bool state)87     void SetEnableHapticFeedback(bool state) override {};
SetEnableAutoSpacing(bool enabled)88     void SetEnableAutoSpacing(bool enabled) override {};
SetLineThicknessScale(float value)89     void SetLineThicknessScale(float value) override {};
SetTextVerticalAlign(TextVerticalAlign verticalAlign)90     void SetTextVerticalAlign(TextVerticalAlign verticalAlign) override {};
91 
92 private:
93     static RefPtr<TextComponentV2> GetComponent();
94 };
95 } // namespace OHOS::Ace::Framework
96 
97 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_MODEL_IMPL_H
98