Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
gxkparam.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 __GXK_PARAM_H__
3 #define __GXK_PARAM_H__
4 
5 #include "gxkutils.hh"
6 
7 /* --- macros --- */
8 #define GXK_IS_PARAM(p) (p && G_IS_PARAM_SPEC (p->pspec))
9 
10 /* --- typedefs, structures & enums --- */
11 typedef struct _GxkParamBinding GxkParamBinding;
12 typedef struct {
13  GParamSpec *pspec;
14  GValue value;
15  GSList *objects; /* of type GObject* */
16  guint8 size_group;
17  guint8 updating; /* flag to guard value against updates (recursions) */
18  guint8 grouping; /* stop_grouping() call pending */
19  guint editable : 1; /* whether widgets should be editable */
20  guint sensitive : 1; /* whether widgets should be sensitive */
21  guint constant : 1; /* whether binding allowes writes */
22  guint ueditable : 1; /* user determined editability */
23  guint breadonly : 1; /* binding is temporarily RO */
24  guint greadonly : 1; /* GUI is temporarily RO */
25  /* binding data */
26  GxkParamBinding *binding;
27  union {
28  gpointer v_pointer;
29  gulong v_long;
30  } bdata[1]; /* flexible array */
31 } GxkParam;
33 {
34  guint16 n_data_fields;
35  void (*setup) (GxkParam *param,
36  gpointer user_data);
37  void (*set_value) (GxkParam *param,
38  const GValue *value);
39  void (*get_value) (GxkParam *param,
40  GValue *value);
41  /* optional: */
42  void (*destroy) (GxkParam *param);
43  gboolean (*check_writable) (GxkParam *param);
44  void (*start_grouping) (GxkParam *param);
45  void (*stop_grouping) (GxkParam *param);
46 };
47 typedef void (*GxkParamUpdateFunc) (GxkParam *param,
48  GtkObject *object);
49 
50 /* --- functions --- */
51 GxkParam* gxk_param_new (GParamSpec *pspec,
52  GxkParamBinding *binding,
53  gpointer user_data);
54 GxkParam* gxk_param_new_constant (GParamSpec *pspec,
55  GxkParamBinding *binding,
56  gpointer user_data);
57 void gxk_param_update (GxkParam *param);
58 void gxk_param_start_grouping (GxkParam *param);
59 void gxk_param_stop_grouping (GxkParam *param);
60 void gxk_param_add_grab_widget (GxkParam *param,
61  GtkWidget *widget);
62 void gxk_param_add_object (GxkParam *param,
63  GtkObject *object);
64 void gxk_param_apply_value (GxkParam *param);
65 void gxk_param_apply_default (GxkParam *param);
66 void gxk_param_set_editable (GxkParam *param,
67  gboolean editable);
68 const gchar* gxk_param_get_name (GxkParam *param);
69 gchar* gxk_param_dup_tooltip (GxkParam *param);
70 void gxk_param_set_devel_tips (gboolean enabled);
71 void gxk_param_destroy (GxkParam *param);
72 void gxk_object_set_param_callback (GtkObject *object,
73  GxkParamUpdateFunc ufunc);
74 
75 
76 /* --- param value binding --- */
77 typedef void (*GxkParamValueNotify) (gpointer notify_data,
78  GxkParam *param);
79 GxkParam* gxk_param_new_value (GParamSpec *pspec,
80  GxkParamValueNotify notify,
81  gpointer notify_data);
82 GxkParam* gxk_param_new_constant_value (GParamSpec *pspec,
83  GxkParamValueNotify notify,
84  gpointer notify_data);
85 
86 /* --- param object binding --- */
87 GxkParam* gxk_param_new_object (GParamSpec *pspec,
88  GObject *object);
89 void gxk_param_set_object (GxkParam *param,
90  GObject *object);
91 GObject* gxk_param_get_object (GxkParam *param);
92 
93 
94 /* --- param view/editor --- */
95 typedef struct {
96  const char *name, *nick;
98 typedef struct {
99  GxkParamEditorIdent ident;
100  struct {
101  GType type;
102  const char *type_name;
103  guint all_int_nums : 1;
104  guint all_float_nums : 1;
105  } type_match;
106  struct {
107  const char *options; /* required pspec options */
108  gint8 rating;
109  guint editing : 1;
110  } features;
111  GtkWidget* (*create_widget) (GxkParam *param,
112  const gchar *tooltip,
113  guint variant);
114  void (*update) (GxkParam *param,
115  GtkWidget *widget);
116  guint variant;
118 void gxk_param_register_editor (GxkParamEditor *editor,
119  const gchar *i18n_domain);
120 void gxk_param_register_aliases (const gchar **aliases);
121 gchar** gxk_param_list_editors (void);
122 guint gxk_param_editor_score (const gchar *editor_name,
123  GParamSpec *pspec);
124 const gchar* gxk_param_lookup_editor (const gchar *editor_name,
125  GParamSpec *pspec);
126 GtkWidget* gxk_param_create_editor (GxkParam *param,
127  const gchar *editor_name);
128 void gxk_param_editor_debug_score (GParamSpec *pspec);
129 
130 /* --- param editor size groups --- */
131 typedef struct {
132  guint may_resize : 1; /* whether the specified chars/digits may be adjusted */
133  guint request_fractions : 1; /* whether fractional digits should be size requested */
134  guint char_chars, char_digits;
135  guint uchar_chars, uchar_digits;
136  guint int_chars, int_digits;
137  guint uint_chars, uint_digits;
138  guint long_chars, long_digits;
139  guint ulong_chars, ulong_digits;
140  guint int64_chars, int64_digits;
141  guint uint64_chars, uint64_digits;
142  guint float_chars, float_digits;
143  guint double_chars, double_digits;
144  guint string_chars, string_digits;
146 guint gxk_param_create_size_group (void);
147 void gxk_param_set_sizes (guint size_group,
148  const GxkParamEditorSizes *esizes);
149 void gxk_param_set_size_group (GxkParam *param,
150  guint size_group);
151 const GxkParamEditorSizes* gxk_param_get_editor_sizes (GxkParam *param);
152 guint gxk_param_get_digits (gdouble value,
153  guint base);
154 
155 
156 /* --- param implementation utils --- */
157 gboolean gxk_param_entry_key_press (GtkEntry *entry,
158  GdkEventKey *event);
159 void gxk_param_entry_set_text (GxkParam *param,
160  GtkWidget *entry,
161  const gchar *text);
162 void gxk_param_entry_connect_handlers (GxkParam *param,
163  GtkWidget *entry,
164  void (*changed) (GtkWidget*,
165  GxkParam*));
166 gboolean gxk_param_ensure_focus (GtkWidget *widget);
167 GtkAdjustment* gxk_param_get_adjustment (GxkParam *param);
168 GtkAdjustment* gxk_param_get_adjustment_with_stepping (GxkParam *param,
169  gdouble pstepping);
170 GtkAdjustment* gxk_param_get_log_adjustment (GxkParam *param);
171 GtkAdjustment* gxk_param_get_decibel_adjustment (GxkParam *param);
172 
173 #endif /* __GXK_PARAM_H__ */
174 
175 /* vim:set ts=8 sts=2 sw=2: */
Definition: gxkparam.hh:32
Definition: gxkparam.hh:95
Definition: gxkparam.hh:12
Definition: gxkparam.hh:131
Definition: gxkparam.hh:98