BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
gxkparam.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __GXK_PARAM_H__
00003 #define __GXK_PARAM_H__
00004 
00005 #include "gxkutils.hh"
00006 
00007 G_BEGIN_DECLS
00008 
00009 /* --- macros --- */
00010 #define GXK_IS_PARAM(p) (p && G_IS_PARAM_SPEC (p->pspec))
00011 
00012 /* --- typedefs, structures & enums --- */
00013 typedef struct _GxkParamBinding GxkParamBinding;
00014 typedef struct {
00015   GParamSpec      *pspec;
00016   GValue           value;
00017   GSList          *objects;       /* of type GObject* */
00018   guint8           size_group;
00019   guint8           updating;      /* flag to guard value against updates (recursions) */
00020   guint8           grouping;      /* stop_grouping() call pending */
00021   guint            editable : 1;  /* whether widgets should be editable */
00022   guint            sensitive : 1; /* whether widgets should be sensitive */
00023   guint            constant : 1;  /* whether binding allowes writes */
00024   guint            ueditable : 1; /* user determined editability */
00025   guint            breadonly : 1; /* binding is temporarily RO */
00026   guint            greadonly : 1; /* GUI is temporarily RO */
00027   /* binding data */
00028   GxkParamBinding *binding;
00029   union {
00030     gpointer    v_pointer;
00031     gulong      v_long;
00032   }                bdata[1];    /* flexible array */
00033 } GxkParam;
00034 struct _GxkParamBinding
00035 {
00036   guint16         n_data_fields;
00037   void          (*setup)                (GxkParam       *param,
00038                                          gpointer        user_data);
00039   void          (*set_value)            (GxkParam       *param,
00040                                          const GValue   *value);
00041   void          (*get_value)            (GxkParam       *param,
00042                                          GValue         *value);
00043   /* optional: */
00044   void          (*destroy)              (GxkParam       *param);
00045   gboolean      (*check_writable)       (GxkParam       *param);
00046   void          (*start_grouping)       (GxkParam       *param);
00047   void          (*stop_grouping)        (GxkParam       *param);
00048 };
00049 typedef void    (*GxkParamUpdateFunc)   (GxkParam       *param,
00050                                          GtkObject      *object);
00051 
00052 /* --- functions --- */
00053 GxkParam*     gxk_param_new                 (GParamSpec         *pspec,
00054                                              GxkParamBinding    *binding,
00055                                              gpointer            user_data);
00056 GxkParam*     gxk_param_new_constant        (GParamSpec         *pspec,
00057                                              GxkParamBinding    *binding,
00058                                              gpointer            user_data);
00059 void          gxk_param_update              (GxkParam           *param);
00060 void          gxk_param_start_grouping      (GxkParam           *param);
00061 void          gxk_param_stop_grouping       (GxkParam           *param);
00062 void          gxk_param_add_grab_widget     (GxkParam           *param,
00063                                              GtkWidget          *widget);
00064 void          gxk_param_add_object          (GxkParam           *param,
00065                                              GtkObject          *object);
00066 void          gxk_param_apply_value         (GxkParam           *param);
00067 void          gxk_param_apply_default       (GxkParam           *param);
00068 void          gxk_param_set_editable        (GxkParam           *param,
00069                                              gboolean            editable);
00070 const gchar*  gxk_param_get_name            (GxkParam           *param);
00071 gchar*        gxk_param_dup_tooltip         (GxkParam           *param);
00072 void          gxk_param_set_devel_tips      (gboolean            enabled);
00073 void          gxk_param_destroy             (GxkParam           *param);
00074 void          gxk_object_set_param_callback (GtkObject          *object,
00075                                              GxkParamUpdateFunc  ufunc);
00076 
00077 
00078 /* --- param value binding --- */
00079 typedef void (*GxkParamValueNotify)    (gpointer             notify_data,
00080                                         GxkParam            *param);
00081 GxkParam* gxk_param_new_value          (GParamSpec          *pspec,
00082                                         GxkParamValueNotify  notify,
00083                                         gpointer             notify_data);
00084 GxkParam* gxk_param_new_constant_value (GParamSpec          *pspec,
00085                                         GxkParamValueNotify  notify,
00086                                         gpointer             notify_data);
00087 
00088 /* --- param object binding --- */
00089 GxkParam* gxk_param_new_object          (GParamSpec         *pspec,
00090                                          GObject            *object);
00091 void      gxk_param_set_object          (GxkParam           *param,
00092                                          GObject            *object);
00093 GObject*  gxk_param_get_object          (GxkParam           *param);
00094 
00095 
00096 /* --- param view/editor --- */
00097 typedef struct {
00098   const char *name, *nick;
00099 } GxkParamEditorIdent;
00100 typedef struct {
00101   GxkParamEditorIdent ident;
00102   struct {
00103     GType        type;
00104     const char  *type_name;
00105     guint        all_int_nums : 1;
00106     guint        all_float_nums : 1;
00107   }              type_match;
00108   struct {
00109     const char *options;        /* required pspec options */
00110     gint8       rating;
00111     guint       editing : 1;
00112   }             features;
00113   GtkWidget*  (*create_widget)  (GxkParam       *param,
00114                                  const gchar    *tooltip,
00115                                  guint           variant);
00116   void        (*update)         (GxkParam       *param,
00117                                  GtkWidget      *widget);
00118   guint         variant;
00119 } GxkParamEditor;
00120 void         gxk_param_register_editor    (GxkParamEditor  *editor,
00121                                            const gchar     *i18n_domain);
00122 void         gxk_param_register_aliases   (const gchar    **aliases);
00123 gchar**      gxk_param_list_editors       (void);
00124 guint        gxk_param_editor_score       (const gchar     *editor_name,
00125                                            GParamSpec      *pspec);
00126 const gchar* gxk_param_lookup_editor      (const gchar     *editor_name,
00127                                            GParamSpec      *pspec);
00128 GtkWidget*   gxk_param_create_editor      (GxkParam        *param,
00129                                            const gchar     *editor_name);
00130 void         gxk_param_editor_debug_score (GParamSpec      *pspec);
00131 
00132 /* --- param editor size groups --- */
00133 typedef struct {
00134   guint may_resize : 1;                 /* whether the specified chars/digits may be adjusted */
00135   guint request_fractions : 1;          /* whether fractional digits should be size requested */
00136   guint char_chars,   char_digits;
00137   guint uchar_chars,  uchar_digits;
00138   guint int_chars,    int_digits;
00139   guint uint_chars,   uint_digits;
00140   guint long_chars,   long_digits;
00141   guint ulong_chars,  ulong_digits;
00142   guint int64_chars,  int64_digits;
00143   guint uint64_chars, uint64_digits;
00144   guint float_chars,  float_digits;
00145   guint double_chars, double_digits;
00146   guint string_chars, string_digits;
00147 } GxkParamEditorSizes;
00148 guint                      gxk_param_create_size_group (void);
00149 void                       gxk_param_set_sizes         (guint                      size_group,
00150                                                         const GxkParamEditorSizes *esizes);
00151 void                       gxk_param_set_size_group    (GxkParam                  *param,
00152                                                         guint                      size_group);
00153 const GxkParamEditorSizes* gxk_param_get_editor_sizes  (GxkParam                  *param);
00154 guint                      gxk_param_get_digits        (gdouble                    value,
00155                                                         guint                      base);
00156 
00157 
00158 /* --- param implementation utils --- */
00159 gboolean       gxk_param_entry_key_press        (GtkEntry    *entry,
00160                                                  GdkEventKey *event);
00161 void           gxk_param_entry_set_text         (GxkParam    *param,
00162                                                  GtkWidget   *entry,
00163                                                  const gchar *text);
00164 void           gxk_param_entry_connect_handlers (GxkParam    *param,
00165                                                  GtkWidget   *entry,
00166                                                  void       (*changed) (GtkWidget*,
00167                                                                         GxkParam*));
00168 gboolean       gxk_param_ensure_focus                 (GtkWidget *widget);
00169 GtkAdjustment* gxk_param_get_adjustment               (GxkParam  *param);
00170 GtkAdjustment* gxk_param_get_adjustment_with_stepping (GxkParam  *param,
00171                                                        gdouble    pstepping);
00172 GtkAdjustment* gxk_param_get_log_adjustment           (GxkParam  *param);
00173 GtkAdjustment* gxk_param_get_decibel_adjustment       (GxkParam  *param);
00174 
00175 G_END_DECLS
00176 
00177 #endif /* __GXK_PARAM_H__ */
00178 
00179 /* vim:set ts=8 sts=2 sw=2: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines