ui/common/menu.h

branch
newapi
changeset 175
2cb06c231057
child 207
93b9f502cb88
equal deleted inserted replaced
174:0358f1d9c506 175:2cb06c231057
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef UIC_MENU_H
30 #define UIC_MENU_H
31
32 #include "../ui/menu.h"
33
34 #include <cx/linked_list.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 typedef struct UiMenuItemI UiMenuItemI;
41 typedef struct UiMenu UiMenu;
42 typedef struct UiMenuItem UiMenuItem;
43 typedef struct UiStMenuItem UiStMenuItem;
44 typedef struct UiCheckItem UiCheckItem;
45 typedef struct UiCheckItemNV UiCheckItemNV;
46 typedef struct UiMenuItemList UiMenuItemList;
47 typedef struct UiMenuItemListNV UiMenuItemListNV;
48
49 enum UiMenuItemType {
50 UI_MENU = 0,
51 UI_MENU_SUBMENU,
52 UI_MENU_ITEM,
53 UI_MENU_STOCK_ITEM,
54 UI_MENU_CHECK_ITEM,
55 UI_MENU_CHECK_ITEM_NV,
56 UI_MENU_ITEM_LIST,
57 UI_MENU_ITEM_LIST_NV,
58 UI_MENU_SEPARATOR
59 };
60
61 typedef enum UiMenuItemType UiMenuItemType;
62
63 struct UiMenuItemI {
64 UiMenuItemI *prev;
65 UiMenuItemI *next;
66 UiMenuItemType type;
67 };
68
69 struct UiMenu {
70 UiMenuItemI item;
71 char *label;
72 UiMenuItemI *items_begin;
73 UiMenuItemI *items_end;
74 UiMenu *parent;
75 };
76
77 struct UiMenuItem {
78 UiMenuItemI item;
79 ui_callback callback;
80 char *label;
81 void *userdata;
82 CxList *groups;
83 };
84
85 struct UiStMenuItem {
86 UiMenuItemI item;
87 ui_callback callback;
88 char *stockid;
89 void *userdata;
90 CxList *groups;
91 };
92
93 struct UiCheckItem {
94 UiMenuItemI item;
95 char *label;
96 ui_callback callback;
97 void *userdata;
98 };
99
100 struct UiCheckItemNV {
101 UiMenuItemI item;
102 char *label;
103 char *varname;
104 };
105
106 struct UiMenuItemList {
107 UiMenuItemI item;
108 ui_callback callback;
109 void *userdata;
110 UiList *list;
111 };
112
113 struct UiMenuItemListNV {
114 UiMenuItemI item;
115 ui_callback callback;
116 void *userdata;
117 const char *varname;
118 };
119
120 UiMenu* uic_get_menu_list(void);
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #endif /* UIC_MENU_H */
127

mercurial