lib/ewl_callback.h
Go to the documentation of this file.00001
00002 #ifndef EWL_CALLBACK_H
00003 #define EWL_CALLBACK_H
00004
00015 typedef struct Ewl_Callback Ewl_Callback;
00016
00021 #define EWL_CALLBACK(callback) ((Ewl_Callback *) callback)
00022
00026 typedef void (*Ewl_Callback_Function) (Ewl_Widget * widget, void *ev_data,
00027 void *user_data);
00028
00033 #define EWL_CALLBACK_FUNCTION(cb_func) ((Ewl_Callback_Function) cb_func)
00034
00038 struct Ewl_Callback
00039 {
00040 Ewl_Callback_Function func;
00041 void *user_data;
00042 int references;
00043 int id;
00044 };
00045
00046
00050 typedef struct Ewl_Callback_Custom Ewl_Callback_Custom;
00051
00056 #define EWL_CALLBACK_CUSTOM(cb) ((Ewl_Callback_Custom *)cb)
00057
00061 struct Ewl_Callback_Custom
00062 {
00063 Ewl_Callback cb;
00064 unsigned int event_id;
00065 };
00066
00071 #define EWL_CALLBACK_NOTIFY_MASK (0x3)
00072
00077 #define EWL_CALLBACK_INDEX(t) ((t < EWL_CALLBACK_MAX) ? t : EWL_CALLBACK_MAX)
00078
00083 #define EWL_CALLBACK_LIST(w, t) (w->callbacks[EWL_CALLBACK_INDEX(t)].list)
00084
00089 #define EWL_CALLBACK_FLAGS(w, t) (w->callbacks[EWL_CALLBACK_INDEX(t)].mask)
00090
00095 #define EWL_CALLBACK_LEN(w, t) (w->callbacks[EWL_CALLBACK_INDEX(t)].len)
00096
00101 #define EWL_CALLBACK_POS(w, t) w->callbacks[EWL_CALLBACK_INDEX(t)].index
00102
00107 #define EWL_CALLBACK_FLAG_INTERCEPT(w, t) \
00108 w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_INTERCEPT
00109
00114 #define EWL_CALLBACK_FLAG_NOINTERCEPT(w, t) \
00115 w->callbacks[EWL_CALLBACK_INDEX(t)].mask = \
00116 w->callbacks[EWL_CALLBACK_INDEX(t)].mask & ~EWL_CALLBACK_NOTIFY_INTERCEPT
00117
00122 #define EWL_CALLBACK_FLAG_NOTIFY(w, t) \
00123 w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_NOTIFY
00124
00129 #define EWL_CALLBACK_FLAG_NONOTIFY(w, t) \
00130 w->callbacks[EWL_CALLBACK_INDEX(t)].mask &= ~EWL_CALLBACK_NOTIFY_NOTIFY
00131
00136 #define EWL_CALLBACK_SET_DIRECT(w, t) \
00137 w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_TYPE_DIRECT
00138
00143 #define EWL_CALLBACK_SET_NODIRECT(w, t) \
00144 w->callbacks[EWL_CALLBACK_INDEX(t)].mask &= ~EWL_CALLBACK_TYPE_DIRECT
00145
00146 int ewl_callbacks_init(void);
00147 void ewl_callbacks_shutdown(void);
00148 unsigned int ewl_callback_type_add(void);
00149
00150 int ewl_callback_append(Ewl_Widget * widget, unsigned int type,
00151 Ewl_Callback_Function func,
00152 void *user_data);
00153 int ewl_callback_prepend(Ewl_Widget * widget,
00154 unsigned int type,
00155 Ewl_Callback_Function func,
00156 void *user_data);
00157 int ewl_callback_insert_after(Ewl_Widget * w, unsigned int t,
00158 Ewl_Callback_Function f,
00159 void *user_data,
00160 Ewl_Callback_Function after,
00161 void *after_data);
00162 void ewl_callback_clear(Ewl_Widget * widget);
00163 void ewl_callback_call(Ewl_Widget * widget, unsigned int type);
00164 void ewl_callback_call_with_event_data(Ewl_Widget * widget,
00165 unsigned int type,
00166 void *event_data);
00167 void ewl_callback_del_type(Ewl_Widget * w, unsigned int t);
00168 void ewl_callback_del_cb_id(Ewl_Widget * w, unsigned int t,
00169 int cb_id);
00170 void ewl_callback_del(Ewl_Widget * w, unsigned int t,
00171 Ewl_Callback_Function f);
00172 void ewl_callback_del_with_data(Ewl_Widget * w, unsigned int t,
00173 Ewl_Callback_Function f, void *data);
00174
00179 #endif