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_FORM_FORM_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FORM_FORM_COMPONENT_H
18 
19 #include "core/components/box/box_component.h"
20 #include "core/components/form/resource/form_request_data.h"
21 #include "core/pipeline/base/element.h"
22 
23 namespace OHOS::Ace {
24 
25 class ACE_EXPORT FormComponent : public RenderComponent {
26     DECLARE_ACE_TYPE(FormComponent, RenderComponent);
27 
28 public:
29     FormComponent() = default;
30     ~FormComponent() override = default;
31 
32     RefPtr<RenderNode> CreateRenderNode() override;
33     RefPtr<Element> CreateElement() override;
34 
SetFormRequestInfo(const RequestFormInfo & info)35     void SetFormRequestInfo(const RequestFormInfo& info)
36     {
37         info_ = info;
38     }
39 
GetFormRequestInfo()40     RequestFormInfo GetFormRequestInfo() const
41     {
42         return info_;
43     }
44 
SetAllowUpdate(bool allow)45     void SetAllowUpdate(bool allow)
46     {
47         info_.allowUpdate = allow;
48     }
49 
IsAllowUpdate()50     bool IsAllowUpdate() const
51     {
52         return info_.allowUpdate;
53     }
54 
SetDimension(int32_t dimension)55     void SetDimension(int32_t dimension)
56     {
57         info_.dimension = dimension;
58     }
59 
SetModuleName(const std::string & name)60     void SetModuleName(const std::string& name)
61     {
62         info_.moduleName = name;
63     }
64 
SetCardSize(const Dimension & width,const Dimension & height)65     void SetCardSize(const Dimension& width, const Dimension& height)
66     {
67         info_.width = width;
68         info_.height = height;
69     }
70 
GetWidth()71     const Dimension& GetWidth() const
72     {
73         return info_.width;
74     }
75 
GetHeight()76     const Dimension& GetHeight() const
77     {
78         return info_.height;
79     }
80 
SetOnAcquireFormEventId(const EventMarker & event)81     void SetOnAcquireFormEventId(const EventMarker& event)
82     {
83         onAcquireForm_ = event;
84     }
85 
GetOnAcquireFormEventId()86     const EventMarker& GetOnAcquireFormEventId() const
87     {
88         return onAcquireForm_;
89     }
90 
SetOnErrorEventId(const EventMarker & event)91     void SetOnErrorEventId(const EventMarker& event)
92     {
93         onError_ = event;
94     }
95 
GetOnErrorEvent()96     const EventMarker& GetOnErrorEvent() const
97     {
98         return onError_;
99     }
100 
SetOnUninstallEventId(const EventMarker & event)101     void SetOnUninstallEventId(const EventMarker& event)
102     {
103         onUninstall_ = event;
104     }
105 
GetOnUninstallEvent()106     const EventMarker& GetOnUninstallEvent() const
107     {
108         return onUninstall_;
109     }
110 
SetOnRouterEventId(const EventMarker & event)111     void SetOnRouterEventId(const EventMarker& event)
112     {
113         onRouter_ = event;
114     }
115 
GetOnRouterEvent()116     const EventMarker& GetOnRouterEvent() const
117     {
118         return onRouter_;
119     }
120 
121 private:
122     RequestFormInfo info_;
123     EventMarker onAcquireForm_;
124     EventMarker onError_;
125     EventMarker onUninstall_;
126     EventMarker onRouter_;
127 };
128 
129 } // namespace OHOS::Ace
130 
131 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FORM_FORM_COMPONENT_H
132