• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_TEXT_TEXT_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_TEXT_COMPONENT_H
18 
19 #include <string>
20 
21 #include "base/utils/macros.h"
22 #include "core/components/common/layout/constants.h"
23 #include "core/components/common/properties/color.h"
24 #include "core/components/common/properties/shadow.h"
25 #include "core/components/common/properties/text_style.h"
26 #include "core/pipeline/base/component_group.h"
27 #include "core/components/declaration/text/text_declaration.h"
28 
29 namespace OHOS::Ace {
30 
31 // A component can show text.
32 class ACE_EXPORT TextComponent : public ComponentGroup {
33     DECLARE_ACE_TYPE(TextComponent, ComponentGroup);
34 
35 public:
36     explicit TextComponent(const std::string& data);
37     ~TextComponent() override = default;
38 
39     RefPtr<RenderNode> CreateRenderNode() override;
40     RefPtr<Element> CreateElement() override;
41     uint32_t Compare(const RefPtr<Component>& component) const override;
42 
43     const std::string& GetData() const;
44     void SetData(const std::string& data);
45 
46     const TextStyle& GetTextStyle() const;
47     void SetTextStyle(const TextStyle& textStyle);
48 
49     const Color& GetFocusColor() const;
50     void SetFocusColor(const Color& focusColor);
51 
52     bool GetMaxWidthLayout() const;
53     void SetMaxWidthLayout(bool isMaxWidthLayout);
54 
55     bool GetAutoMaxLines() const;
56     void SetAutoMaxLines(bool autoMaxLines);
57 
58     bool IsChanged() const;
59     void SetIsChanged(bool isChanged);
60 
61     void SetOnClick(const EventMarker& onClick);
62 
63     const RefPtr<TextDeclaration>& GetDeclaration() const;
64     void SetDeclaration(const RefPtr<TextDeclaration>& declaration);
65     Dimension GetDeclarationHeight() const;
66 
67     void SetRemoteMessageEvent(const EventMarker& eventId);
68 private:
69     RefPtr<TextDeclaration> declaration_;
70 };
71 
72 } // namespace OHOS::Ace
73 
74 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_TEXT_COMPONENT_H
75