BEAST - Free Software Audio Synthesizer and Tracker  0.10.0
bstmenus.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BST_MENUS_H__
3 #define __BST_MENUS_H__
4 
5 #include "bstutils.hh"
6 
7 G_BEGIN_DECLS
8 
9 /* --- BstChoice --- */
10 /* BstChoice are simple inlined popup menus for modal selections.
11  */
12 typedef struct _BstChoice BstChoice;
13 
14 GtkWidget* bst_choice_menu_createv (const gchar *menu_path,
15  BstChoice *first_choice,
16  ...);
17 void bst_choice_menu_add_choice_and_free (GtkWidget *menu,
18  BstChoice *choice);
19 void bst_choice_menu_set_item_sensitive (GtkWidget *menu,
20  gulong id,
21  gboolean sensitive);
22 GtkWidget* bst_choice_dialog_createv (BstChoice *first_choice,
23  ...) G_GNUC_NULL_TERMINATED;
24 gboolean bst_choice_selectable (GtkWidget *widget);
25 guint bst_choice_modal (GtkWidget *widget,
26  guint mouse_button,
27  guint32 time);
28 guint bst_choice_get_last (GtkWidget *widget);
29 void bst_choice_destroy (GtkWidget *choice);
30 
31 
32 /* --- BstChoice shortcuts --- */
33 #define BST_CHOICE_TITLE(name) (bst_choice_alloc (BST_CHOICE_TYPE_TITLE, \
34  (name), NULL, BST_STOCK_NONE, 0))
35 #define BST_CHOICE(id, name, bst_icon) (bst_choice_alloc (BST_CHOICE_TYPE_ITEM, \
36  (name), (void*) (size_t) (id), \
37  BST_STOCK_ ## bst_icon, 0))
38 #define BST_CHOICE_D(id, name, bst_icon) (bst_choice_alloc (BST_CHOICE_TYPE_ITEM | \
39  BST_CHOICE_FLAG_DEFAULT, \
40  (name), (void*) (size_t) (id), \
41  BST_STOCK_ ## bst_icon, 0))
42 #define BST_CHOICE_S(id, name, icon, s) (bst_choice_alloc (BST_CHOICE_TYPE_ITEM | \
43  ((s) ? (BstChoiceFlags) 0 : BST_CHOICE_FLAG_INSENSITIVE), \
44  (name), (void*) (size_t) (id), \
45  BST_STOCK_ ## icon, 0))
46 #define BST_CHOICE_SUBMENU(nam,menu,icn) (bst_choice_alloc (BST_CHOICE_TYPE_SUBMENU, \
47  (nam), (menu), BST_STOCK_ ## icn, 0))
48 #define BST_CHOICE_TEXT(name) (bst_choice_alloc (BST_CHOICE_TYPE_TEXT, \
49  (name), NULL, BST_STOCK_NONE, 0))
50 #define BST_CHOICE_SEPERATOR (bst_choice_alloc (BST_CHOICE_TYPE_SEPARATOR, \
51  NULL, NULL, BST_STOCK_NONE, 0))
52 #define BST_CHOICE_END (NULL)
53 
54 
55 /* --- private implementation stubs --- */
56 typedef enum
57 {
58  BST_CHOICE_TYPE_SEPARATOR = 0,
59  BST_CHOICE_TYPE_TITLE = 1,
60  BST_CHOICE_TYPE_TEXT = 2,
61  BST_CHOICE_TYPE_ITEM = 3,
62  BST_CHOICE_TYPE_SUBMENU = 4,
63  BST_CHOICE_TYPE_MASK = 0xff,
64  BST_CHOICE_FLAG_INSENSITIVE = (1 << 8),
65  BST_CHOICE_FLAG_DEFAULT = (1 << 9),
66  BST_CHOICE_FLAG_MASK = (~BST_CHOICE_TYPE_MASK)
67 } BstChoiceFlags;
68 BstChoice* bst_choice_alloc (BstChoiceFlags type,
69  const gchar *choice_name,
70  gpointer choice_id,
71  const gchar *icon_stock_id,
72  BseIc0n *bse_icon);
73 
74 G_END_DECLS
75 
76 // == Flags Enumeration Operators in C++ ==
77 #ifdef __cplusplus
78 constexpr BstChoiceFlags operator& (BstChoiceFlags s1, BstChoiceFlags s2) { return BstChoiceFlags (s1 & (long long unsigned) s2); }
79 inline BstChoiceFlags& operator&= (BstChoiceFlags &s1, BstChoiceFlags s2) { s1 = s1 & s2; return s1; }
80 constexpr BstChoiceFlags operator| (BstChoiceFlags s1, BstChoiceFlags s2) { return BstChoiceFlags (s1 | (long long unsigned) s2); }
81 inline BstChoiceFlags& operator|= (BstChoiceFlags &s1, BstChoiceFlags s2) { s1 = s1 | s2; return s1; }
82 constexpr BstChoiceFlags operator~ (BstChoiceFlags s1) { return BstChoiceFlags (~(long long unsigned) s1); }
83 #endif // __cplusplus
84 
85 #endif /* __BST_MENUS_H__ */