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_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_MENU_MENU_ITEM_EVENT_HUB_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_MENU_MENU_ITEM_EVENT_HUB_H
18 
19 #include <cstdint>
20 
21 #include "core/components_ng/event/event_hub.h"
22 
23 namespace OHOS::Ace::NG {
24 class MenuItemEventHub : public EventHub {
25     DECLARE_ACE_TYPE(MenuItemEventHub, EventHub)
26 
27 public:
28     MenuItemEventHub() = default;
29     ~MenuItemEventHub() override = default;
30 
SetOnChange(const std::function<void (bool)> & onChange)31     void SetOnChange(const std::function<void(bool)>& onChange)
32     {
33         onChange_ = onChange;
34     }
35 
GetOnChange()36     std::function<void(bool)>&& GetOnChange()
37     {
38         return std::move(onChange_);
39     }
40 
SetSelectedChangeEvent(const std::function<void (bool)> & selectedChangeEvent)41     void SetSelectedChangeEvent(const std::function<void(bool)>& selectedChangeEvent)
42     {
43         selectedChangeEvent_ = selectedChangeEvent;
44     }
45 
GetSelectedChangeEvent()46     std::function<void(bool)>&& GetSelectedChangeEvent()
47     {
48         return std::move(selectedChangeEvent_);
49     }
50 
51 private:
52     // callback of menuItem
53     std::function<void(bool)> onChange_;
54     std::function<void(bool)> selectedChangeEvent_;
55 
56     ACE_DISALLOW_COPY_AND_MOVE(MenuItemEventHub);
57 };
58 } // namespace OHOS::Ace::NG
59 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_MENU_MENU_ITEM_EVENT_HUB_H
60