ui/gtk/menu.h

changeset 0
1f419bd32da1
child 16
a499c8a72c15
equal deleted inserted replaced
-1:000000000000 0:1f419bd32da1
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2014 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 MENU_H
30 #define MENU_H
31
32 #include "../ui/menu.h"
33 #include "../../ucx/list.h"
34 #include "toolkit.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
47 typedef GtkWidget*(*ui_menu_add_f)(GtkWidget *, UiMenuItemI*, UiObject*);
48
49 struct UiMenuItemI {
50 ui_menu_add_f add_to;
51 };
52
53 struct UiMenu {
54 UiMenuItemI item;
55 char *label;
56 UcxList *items;
57 UiMenu *parent;
58 };
59
60 struct UiMenuItem {
61 UiMenuItemI item;
62 ui_callback callback;
63 char *label;
64 void *userdata;
65 };
66
67 struct UiStMenuItem {
68 UiMenuItemI item;
69 ui_callback callback;
70 char *stockid;
71 void *userdata;
72 };
73
74 struct UiCheckItem {
75 UiMenuItemI item;
76 char *label;
77 ui_callback callback;
78 void *userdata;
79 };
80
81 struct UiCheckItemNV {
82 UiMenuItemI item;
83 char *label;
84 char *varname;
85 };
86
87 GtkWidget *ui_create_menubar(UiObject *obj);
88
89 void add_menu_widget(GtkWidget *parent, UiMenuItemI *item, UiObject *obj);
90 void add_menuitem_widget(GtkWidget *parent, UiMenuItemI *item, UiObject *obj);
91 void add_menuitem_st_widget(GtkWidget *p, UiMenuItemI *item, UiObject *obj);
92 void add_menuseparator_widget(GtkWidget *p, UiMenuItemI *item, UiObject *obj);
93 void add_checkitem_widget(GtkWidget *p, UiMenuItemI *item, UiObject *obj);
94 void add_checkitemnv_widget(GtkWidget *p, UiMenuItemI *item, UiObject *obj);
95
96 void ui_menu_event_wrapper(GtkMenuItem *item, UiEventData *event);
97 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event);
98 int ui_checkitem_get(UiInteger *i);
99 void ui_checkitem_set(UiInteger *i, int value);
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif /* MENU_H */
106

mercurial