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