• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_INTERFACE_INNERKITS_FORM_RENDERER_DELEGATE_IMPL_H
17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DELEGATE_IMPL_H
18 
19 #include "form_renderer_delegate_stub.h"
20 
21 namespace OHOS {
22 namespace Ace {
23 /**
24  * @class FormRendererDelegate
25  * FormRendererDelegate interface is used to form renderer delegate.
26  */
27 class ACE_EXPORT FormRendererDelegateImpl : public FormRendererDelegateStub {
28 public:
29     FormRendererDelegateImpl() = default;
30     ~FormRendererDelegateImpl() override = default;
31     /**
32      * @brief OnSurfaceCreate.
33      * @param surfaceNode The surfaceNode.
34      * @param formJsInfo The formJsInfo.
35      * @param want The want.
36      */
37     int32_t OnSurfaceCreate(const std::shared_ptr<Rosen::RSSurfaceNode>& surfaceNode,
38         const OHOS::AppExecFwk::FormJsInfo& formJsInfo, const AAFwk::Want& want) override;
39     /**
40      * @brief OnActionEvent.
41      * @param action The action.
42      */
43     int32_t OnActionEvent(const std::string& action) override;
44     /**
45      * @brief OnError.
46      * @param code The code.
47      * @param msg The msg.
48      */
49     int32_t OnError(const std::string& code, const std::string& msg) override;
50     /**
51      * @brief OnSurfaceChange.
52      * @param width
53      * @param height
54      */
55     int32_t OnSurfaceChange(float width, float height) override;
56 
57     int32_t OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos) override;
58 
59     void SetSurfaceCreateEventHandler(std::function<void(const std::shared_ptr<Rosen::RSSurfaceNode>&,
60             const OHOS::AppExecFwk::FormJsInfo&, const AAFwk::Want&)>&& listener);
61     void SetActionEventHandler(std::function<void(const std::string&)>&& listener);
62     void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& listener);
63     void SetSurfaceChangeEventHandler(std::function<void(float width, float height)>&& listener);
64     void SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& listener);
65 
66 private:
67     std::function<void(
68         const std::shared_ptr<Rosen::RSSurfaceNode>&, const OHOS::AppExecFwk::FormJsInfo&, const AAFwk::Want&)>
69         surfaceCreateEventHandler_;
70     std::function<void(const std::string&)> actionEventHandler_;
71     std::function<void(const std::string&, const std::string&)> errorEventHandler_;
72     std::function<void(float width, float height)> surfaceChangeEventHandler_;
73     std::function<void(const std::vector<std::string>&)> formLinkInfoUpdateHandler_;
74 };
75 } // namespace Ace
76 } // namespace OHOS
77 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DELEGATE_IMPL_H
78