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 NWEB_SELECT_POPUP_MENU_H
17 #define NWEB_SELECT_POPUP_MENU_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 namespace OHOS::NWeb {
24 
25 class NWebSelectMenuBound {
26 public:
27     virtual ~NWebSelectMenuBound() = default;
28 
29     virtual int GetX() = 0;
30     virtual int GetY() = 0;
31     virtual int GetWidth() = 0;
32     virtual int GetHeight() = 0;
33 };
34 
35 enum SelectPopupMenuItemType {
36     SP_OPTION,
37     SP_CHECKABLE_OPTION,
38     SP_GROUP,
39     SP_SEPARATOR,
40     SP_SUBMENU,
41 };
42 
43 enum TextDirection {
44     SP_UNKNOWN,
45     SP_RTL,
46     SP_LTR,
47 };
48 
49 class NWebSelectPopupMenuItem {
50 public:
51     virtual ~NWebSelectPopupMenuItem() = default;
52 
53     virtual SelectPopupMenuItemType GetType() = 0;
54 
55     virtual std::string GetLabel() = 0;
56 
57     virtual uint32_t GetAction() = 0;
58 
59     virtual std::string GetToolTip() = 0;
60 
61     virtual bool GetIsChecked() = 0;
62 
63     virtual bool GetIsEnabled() = 0;
64 
65     virtual TextDirection GetTextDirection() = 0;
66 
67     virtual bool GetHasTextDirectionOverride() = 0;
68 };
69 
70 class NWebSelectPopupMenuParam {
71 public:
72     virtual ~NWebSelectPopupMenuParam() = default;
73 
74     virtual std::vector<std::shared_ptr<NWebSelectPopupMenuItem>> GetMenuItems() = 0;
75 
76     virtual int GetItemHeight() = 0;
77 
78     virtual int GetSelectedItem() = 0;
79 
80     virtual double GetItemFontSize() = 0;
81 
82     virtual bool GetIsRightAligned() = 0;
83 
84     virtual std::shared_ptr<NWebSelectMenuBound> GetSelectMenuBound() = 0;
85 
86     virtual bool GetIsAllowMultipleSelection() = 0;
87 };
88 
89 class NWebSelectPopupMenuCallback {
90 public:
91     virtual ~NWebSelectPopupMenuCallback() = default;
92 
93     virtual void Continue(const std::vector<int32_t>& indices) = 0;
94 
95     virtual void Cancel() = 0;
96 };
97 
98 } // namespace OHOS::NWeb
99 
100 #endif