Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
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 /* --- BstChoice --- */
8 /* BstChoice are simple inlined popup menus for modal selections.
9  */
10 struct BstChoice;
11 
12 GtkWidget* bst_choice_menu_createv (const gchar *menu_path,
13  BstChoice *first_choice,
14  ...);
15 void bst_choice_menu_add_choice_and_free (GtkWidget *menu,
16  BstChoice *choice);
17 void bst_choice_menu_set_item_sensitive (GtkWidget *menu,
18  gulong id,
19  gboolean sensitive);
20 GtkWidget* bst_choice_dialog_createv (BstChoice *first_choice,
21  ...) G_GNUC_NULL_TERMINATED;
22 gboolean bst_choice_selectable (GtkWidget *widget);
23 guint bst_choice_modal (GtkWidget *widget,
24  guint mouse_button,
25  guint32 time);
26 guint bst_choice_get_last (GtkWidget *widget);
27 void bst_choice_destroy (GtkWidget *choice);
28 
29 
30 /* --- BstChoice shortcuts --- */
31 #define BST_CHOICE_TITLE(name) (bst_choice_alloc (BST_CHOICE_TYPE_TITLE, \
32  (name), NULL, BST_STOCK_NONE, Bse::Icon()))
33 #define BST_CHOICE(id, name, bst_icon) (bst_choice_alloc (BST_CHOICE_TYPE_ITEM, \
34  (name), (void*) (size_t) (id), \
35  BST_STOCK_ ## bst_icon, Bse::Icon()))
36 #define BST_CHOICE_D(id, name, bst_icon) (bst_choice_alloc (BST_CHOICE_TYPE_ITEM | \
37  BST_CHOICE_FLAG_DEFAULT, \
38  (name), (void*) (size_t) (id), \
39  BST_STOCK_ ## bst_icon, Bse::Icon()))
40 #define BST_CHOICE_S(id, name, icon, s) (bst_choice_alloc (BST_CHOICE_TYPE_ITEM | \
41  ((s) ? (BstChoiceFlags) 0 : BST_CHOICE_FLAG_INSENSITIVE), \
42  (name), (void*) (size_t) (id), \
43  BST_STOCK_ ## icon, Bse::Icon()))
44 #define BST_CHOICE_SUBMENU(nam,menu,icn) (bst_choice_alloc (BST_CHOICE_TYPE_SUBMENU, \
45  (nam), (menu), BST_STOCK_ ## icn, Bse::Icon()))
46 #define BST_CHOICE_TEXT(name) (bst_choice_alloc (BST_CHOICE_TYPE_TEXT, \
47  (name), NULL, BST_STOCK_NONE, Bse::Icon()))
48 #define BST_CHOICE_SEPERATOR (bst_choice_alloc (BST_CHOICE_TYPE_SEPARATOR, \
49  "", NULL, BST_STOCK_NONE, Bse::Icon()))
50 #define BST_CHOICE_END (NULL)
51 
52 
53 /* --- private implementation stubs --- */
54 typedef enum
55 {
56  BST_CHOICE_TYPE_SEPARATOR = 0,
57  BST_CHOICE_TYPE_TITLE = 1,
58  BST_CHOICE_TYPE_TEXT = 2,
59  BST_CHOICE_TYPE_ITEM = 3,
60  BST_CHOICE_TYPE_SUBMENU = 4,
61  BST_CHOICE_TYPE_MASK = 0xff,
62  BST_CHOICE_FLAG_INSENSITIVE = (1 << 8),
63  BST_CHOICE_FLAG_DEFAULT = (1 << 9),
64  BST_CHOICE_FLAG_MASK = (~BST_CHOICE_TYPE_MASK)
65 } BstChoiceFlags;
66 BstChoice* bst_choice_alloc (BstChoiceFlags type,
67  const String &choice_name,
68  void *choice_id,
69  const String &icon_stock_id,
70  const Bse::Icon &bseicon);
71 
72 // == Flags Enumeration Operators in C++ ==
73 #ifdef __cplusplus
74 constexpr BstChoiceFlags operator& (BstChoiceFlags s1, BstChoiceFlags s2) { return BstChoiceFlags (s1 & (long long unsigned) s2); }
75 inline BstChoiceFlags& operator&= (BstChoiceFlags &s1, BstChoiceFlags s2) { s1 = s1 & s2; return s1; }
76 constexpr BstChoiceFlags operator| (BstChoiceFlags s1, BstChoiceFlags s2) { return BstChoiceFlags (s1 | (long long unsigned) s2); }
77 inline BstChoiceFlags& operator|= (BstChoiceFlags &s1, BstChoiceFlags s2) { s1 = s1 | s2; return s1; }
78 constexpr BstChoiceFlags operator~ (BstChoiceFlags s1) { return BstChoiceFlags (~(long long unsigned) s1); }
79 #endif // __cplusplus
80 
81 #endif /* __BST_MENUS_H__ */
Representation of an icon pixel image.
Definition: bseapi.idl:387
STL class.