1 /*
2  * Copyright (c) 2021-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_FORM_RENDER_FORM_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FORM_RENDER_FORM_H
18 
19 #include "core/components/form/form_component.h"
20 #include "core/components/form/sub_container.h"
21 #include "core/pipeline/base/render_sub_container.h"
22 
23 namespace OHOS::Ace {
24 
25 class RenderForm : public RenderSubContainer {
26 DECLARE_ACE_TYPE(RenderForm, RenderSubContainer);
27 
28 public:
29     static RefPtr<RenderNode> Create();
30 
31     ~RenderForm() override = default;
32 
33     void Update(const RefPtr<Component>& component) override;
34     void PerformLayout() override;
35 
GetDrawDelegate()36     virtual std::unique_ptr<DrawDelegate> GetDrawDelegate()
37     {
38         return nullptr;
39     }
RemoveChildren()40     virtual void RemoveChildren() {}
41 
42     bool TouchTest(const Point& globalPoint,
43         const Point& parentLocalPoint, const TouchRestrict& touchRestrict, TouchTestResult& result) override;
44 
SetSubContainer(const WeakPtr<SubContainer> & container)45     void SetSubContainer(const WeakPtr<SubContainer>& container)
46     {
47         subContainer_ = container;
48     }
49 
GetSubPipelineContext()50     RefPtr<PipelineBase> GetSubPipelineContext() override
51     {
52         auto context = subContainer_.Upgrade();
53         if (context) {
54             return context->GetPipelineContext();
55         }
56         return nullptr;
57     }
58 
59 private:
60     Dimension rootWidht_ = 0.0_vp;
61     Dimension rootHeight_ = 0.0_vp;
62     Size drawSize_;
63     WeakPtr<SubContainer> subContainer_;
64 };
65 
66 } // namespace OHOS::Ace
67 
68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FORM_RENDER_FORM_H
69