• 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 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 struct SelectMenuBound {
26     int x = -1;
27     int y = -1;
28     int width = -1;
29     int height = -1;
30 };
31 
32 enum SelectPopupMenuItemType {
33     SP_OPTION,
34     SP_CHECKABLE_OPTION,
35     SP_GROUP,
36     SP_SEPARATOR,
37     SP_SUBMENU,
38 };
39 
40 enum TextDirection {
41     SP_UNKNOWN,
42     SP_RTL,
43     SP_LTR,
44 };
45 
46 struct SelectPopupMenuItem {
47     std::string label = "";
48     std::string toolTip = "";
49     SelectPopupMenuItemType type = SP_OPTION;
50     uint32_t action = 0;
51     TextDirection textDirection = SP_UNKNOWN;
52     bool enabled = false;
53     bool hasTextDirectionOverride = false;
54     bool checked = false;
55 };
56 
57 struct NWebSelectPopupMenuParam {
58     SelectMenuBound bounds;
59     int itemHeight = -1;
60     double itemFontSize = -1;
61     int selectedItem = -1;
62     std::vector<SelectPopupMenuItem> menuItems;
63     bool rightAligned = false;
64     bool allowMultipleSelection = false;
65 };
66 
67 class NWebSelectPopupMenuCallback {
68 public:
69     virtual ~NWebSelectPopupMenuCallback() = default;
70 
71     virtual void Continue(const std::vector<int32_t>& indices) = 0;
72 
73     virtual void Cancel() = 0;
74 };
75 }
76 #endif