2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2011 Krzysztof Foltman
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CBOX_MENUITEM_H
20 #define CBOX_MENUITEM_H
27 struct cbox_menu_item
;
28 struct cbox_menu_item_command
;
29 struct cbox_menu_item_static
;
30 struct cbox_menu_item_menu
;
31 struct cbox_menu_state
;
33 struct cbox_menu_measure
40 struct cbox_menu_item_class
42 void (*measure
)(struct cbox_menu_item
*item
, struct cbox_menu_state
*state
);
43 void (*draw
)(struct cbox_menu_item
*item
, struct cbox_menu_state
*state
, gchar
*value
, int hilited
);
44 gchar
*(*format_value
)(const struct cbox_menu_item
*item
, struct cbox_menu_state
*state
);
45 int (*on_key
)(struct cbox_menu_item
*item
, struct cbox_menu_state
*state
, int key
);
46 int (*on_idle
)(struct cbox_menu_item
*item
, struct cbox_menu_state
*state
);
47 void (*destroy
)(struct cbox_menu_item
*item
);
51 typedef int (*cbox_menu_item_execute_func
)(struct cbox_menu_item_command
*item
, void *context
);
52 typedef char *(*cbox_menu_item_format_value
)(const struct cbox_menu_item_static
*item
, void *context
);
57 struct cbox_menu_item_class
*item_class
;
60 /* TODO: is_active? */
63 struct cbox_menu_item_command
65 struct cbox_menu_item item
;
66 int (*execute
)(struct cbox_menu_item_command
*item
, void *menu_context
);
69 struct cbox_menu_item_int
71 struct cbox_menu_item item
;
75 int (*on_change
)(struct cbox_menu_item_int
*item
, void *menu_context
);
78 struct cbox_menu_item_double
80 struct cbox_menu_item item
;
85 double (*step
)(struct cbox_menu_item_double
*item
, int where
);
86 int (*on_change
)(struct cbox_menu_item_double
*item
, void *menu_context
);
89 struct cbox_menu_item_static
91 struct cbox_menu_item item
;
92 char *(*format_value
)(const struct cbox_menu_item_static
*item
, void *menu_context
);
95 typedef struct cbox_menu
*(*create_menu_func
)(struct cbox_menu_item_menu
*item
, void *menu_context
);
97 struct cbox_menu_item_menu
99 struct cbox_menu_item item
;
100 struct cbox_menu
*menu
;
101 create_menu_func create_menu
;
104 extern struct cbox_menu_item
*cbox_menu_item_new_command(const char *label
, cbox_menu_item_execute_func exec
, void *item_context
);
105 extern struct cbox_menu_item
*cbox_menu_item_new_static(const char *label
, cbox_menu_item_format_value fmt
, void *item_context
);
106 extern struct cbox_menu_item
*cbox_menu_item_new_int(const char *label
, int *value
, int vmin
, int vmax
, void *item_context
);
107 extern struct cbox_menu_item
*cbox_menu_item_new_menu(const char *label
, struct cbox_menu
*menu
, void *item_context
);
108 extern struct cbox_menu_item
*cbox_menu_item_new_dynamic_menu(const char *label
, create_menu_func func
, void *item_context
);
109 extern void cbox_menu_item_destroy(struct cbox_menu_item
*);