Ewl_Callback: The Callback Mechanisms
Detailed Description
Defines methods for creating and modifying callbacks on widgetsTutorial
Data Structures | |
struct | Ewl_Callback |
Contains information about a callback. More... | |
struct | Ewl_Callback_Custom |
Contains information about custom callbacks. More... | |
Defines | |
#define | EWL_CALLBACK(callback) ((Ewl_Callback *) callback) |
#define | EWL_CALLBACK_CUSTOM(cb) ((Ewl_Callback_Custom *)cb) |
#define | EWL_CALLBACK_FLAG_INTERCEPT(w, t) w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_INTERCEPT |
#define | EWL_CALLBACK_FLAG_NOINTERCEPT(w, t) |
#define | EWL_CALLBACK_FLAG_NONOTIFY(w, t) w->callbacks[EWL_CALLBACK_INDEX(t)].mask &= ~EWL_CALLBACK_NOTIFY_NOTIFY |
#define | EWL_CALLBACK_FLAG_NOTIFY(w, t) w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_NOTIFY |
#define | EWL_CALLBACK_FLAGS(w, t) (w->callbacks[EWL_CALLBACK_INDEX(t)].mask) |
#define | EWL_CALLBACK_FUNCTION(cb_func) ((Ewl_Callback_Function) cb_func) |
#define | EWL_CALLBACK_INDEX(t) ((t < EWL_CALLBACK_MAX) ? t : EWL_CALLBACK_MAX) |
#define | EWL_CALLBACK_LEN(w, t) (w->callbacks[EWL_CALLBACK_INDEX(t)].len) |
#define | EWL_CALLBACK_LIST(w, t) (w->callbacks[EWL_CALLBACK_INDEX(t)].list) |
#define | EWL_CALLBACK_NOTIFY_MASK (0x3) |
#define | EWL_CALLBACK_POS(w, t) w->callbacks[EWL_CALLBACK_INDEX(t)].index |
#define | EWL_CALLBACK_SET_DIRECT(w, t) w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_TYPE_DIRECT |
#define | EWL_CALLBACK_SET_NODIRECT(w, t) w->callbacks[EWL_CALLBACK_INDEX(t)].mask &= ~EWL_CALLBACK_TYPE_DIRECT |
Typedefs | |
typedef Ewl_Callback | Ewl_Callback |
typedef Ewl_Callback_Custom | Ewl_Callback_Custom |
typedef void(*) | Ewl_Callback_Function (Ewl_Widget *widget, void *ev_data, void *user_data) |
Functions | |
Ewl_Callback * | ewl_callback_append (Ewl_Widget *widget, unsigned int type, Ewl_Callback_Function func, void *user_data) |
Append a callback of the specified type. | |
void | ewl_callback_call (Ewl_Widget *widget, unsigned int type) |
Execute callbacks of specified types for the widget. | |
void | ewl_callback_call_with_event_data (Ewl_Widget *widget, unsigned int type, void *event_data) |
Execute callbacks with event data. | |
void | ewl_callback_clear (Ewl_Widget *widget) |
void | ewl_callback_del (Ewl_Widget *w, unsigned int t, Ewl_Callback_Function f) |
Delete the specified callback function from the widget. | |
void | ewl_callback_del_callback (Ewl_Widget *w, unsigned int t, Ewl_Callback *cb) |
void | ewl_callback_del_type (Ewl_Widget *w, unsigned int t) |
void | ewl_callback_del_with_data (Ewl_Widget *w, unsigned int t, Ewl_Callback_Function f, void *data) |
Delete the specified callback function from the widget. | |
Ewl_Callback * | ewl_callback_insert_after (Ewl_Widget *w, unsigned int t, Ewl_Callback_Function f, void *user_data, Ewl_Callback_Function after, void *after_data) |
Add a callback after a previous callback in list. | |
Ewl_Callback * | ewl_callback_prepend (Ewl_Widget *widget, unsigned int type, Ewl_Callback_Function func, void *user_data) |
prepend a callback of the specified type | |
unsigned int | ewl_callback_type_add (void) |
Creates and returns a new callback identifier. | |
int | ewl_callbacks_init (void) |
Setup internal registration variables for callbacks. | |
void | ewl_callbacks_shutdown (void) |
Destroy internal registration variables for callbacks. |
Define Documentation
#define EWL_CALLBACK | ( | callback | ) | ((Ewl_Callback *) callback) |
Typecasts a pointer to an Ewl_Callback pointer.
#define EWL_CALLBACK_CUSTOM | ( | cb | ) | ((Ewl_Callback_Custom *)cb) |
Typecasts a pointer to an Ewl_Callback_Custom pointer.
#define EWL_CALLBACK_FLAG_INTERCEPT | ( | w, | |||
t | ) | w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_INTERCEPT |
Sets the callback intercept flag from a widget for a certain event type.
#define EWL_CALLBACK_FLAG_NOINTERCEPT | ( | w, | |||
t | ) |
Value:
w->callbacks[EWL_CALLBACK_INDEX(t)].mask = \ w->callbacks[EWL_CALLBACK_INDEX(t)].mask & ~EWL_CALLBACK_NOTIFY_INTERCEPT
#define EWL_CALLBACK_FLAG_NONOTIFY | ( | w, | |||
t | ) | w->callbacks[EWL_CALLBACK_INDEX(t)].mask &= ~EWL_CALLBACK_NOTIFY_NOTIFY |
Remove the callback notify flag from a widget for a certain event type.
#define EWL_CALLBACK_FLAG_NOTIFY | ( | w, | |||
t | ) | w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_NOTIFY |
Sets the callback notify flag from a widget for a certain event type.
#define EWL_CALLBACK_FLAGS | ( | w, | |||
t | ) | (w->callbacks[EWL_CALLBACK_INDEX(t)].mask) |
Retrives the callback flags from a widget for a certain event type.
#define EWL_CALLBACK_FUNCTION | ( | cb_func | ) | ((Ewl_Callback_Function) cb_func) |
Typecasts a pointer to an Ewl_Callback_Function pointer.
#define EWL_CALLBACK_INDEX | ( | t | ) | ((t < EWL_CALLBACK_MAX) ? t : EWL_CALLBACK_MAX) |
Retrieves the actual array index for t
#define EWL_CALLBACK_LEN | ( | w, | |||
t | ) | (w->callbacks[EWL_CALLBACK_INDEX(t)].len) |
Retrives the length from a widget for a certain event type.
#define EWL_CALLBACK_LIST | ( | w, | |||
t | ) | (w->callbacks[EWL_CALLBACK_INDEX(t)].list) |
Retrives the callback list from a widget for a certain event type.
#define EWL_CALLBACK_NOTIFY_MASK (0x3) |
The value to binary AND with the callback pointer to check the notifiers.
#define EWL_CALLBACK_POS | ( | w, | |||
t | ) | w->callbacks[EWL_CALLBACK_INDEX(t)].index |
Retrives the current callback position from a widget for an event type.
#define EWL_CALLBACK_SET_DIRECT | ( | w, | |||
t | ) | w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_TYPE_DIRECT |
Sets the callback direct flag for a centain event type
#define EWL_CALLBACK_SET_NODIRECT | ( | w, | |||
t | ) | w->callbacks[EWL_CALLBACK_INDEX(t)].mask &= ~EWL_CALLBACK_TYPE_DIRECT |
Clears the callback direct flag from a widget for a certain event type
Typedef Documentation
typedef struct Ewl_Callback Ewl_Callback |
The callbacks used internally for tracking event actions.
typedef struct Ewl_Callback_Custom Ewl_Callback_Custom |
The custom callbacks for extended events
typedef void(*) Ewl_Callback_Function(Ewl_Widget *widget, void *ev_data, void *user_data) |
A shortcut for declaring functions that take a callback funciton pointer.
Function Documentation
Ewl_Callback* ewl_callback_append | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
Ewl_Callback_Function | f, | |||
void * | user_data | |||
) |
Append a callback of the specified type.
- Parameters:
-
w,: the widget to attach the callback t,: the type of the callback that is being attached f,: the function to attach as a callback user_data,: the data to be passed to the callback function
- Returns:
- Returns NULL on failure, a pointer to the new callback on success.
- Note:
- Use the returned callback pointer only for ewl_callback_del_callback().
void ewl_callback_call | ( | Ewl_Widget * | w, | |
unsigned int | t | |||
) |
Execute callbacks of specified types for the widget.
- Parameters:
-
w,: the widget to execute the callbacks t,: the type of the callbacks to be executed
- Returns:
- Returns no value.
void ewl_callback_call_with_event_data | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
void * | ev_data | |||
) |
Execute callbacks with event data.
- Parameters:
-
w,: the widget to execute the callbacks t,: the type of the callbacks to be executed ev_data,: the event data to pass to the callbacks
- Returns:
- Returns no value.
void ewl_callback_clear | ( | Ewl_Widget * | widget | ) |
void ewl_callback_del | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
Ewl_Callback_Function | f | |||
) |
Delete the specified callback function from the widget.
- Parameters:
-
w,: the widget to delete the callback t,: the type of event associated with the callback f,: the function called by the callback
- Returns:
- Returns no value. Delete and frees the callback that calls function f when event t occurs to widget w.
void ewl_callback_del_callback | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
Ewl_Callback * | cb | |||
) |
void ewl_callback_del_type | ( | Ewl_Widget * | w, | |
unsigned int | t | |||
) |
void ewl_callback_del_with_data | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
Ewl_Callback_Function | f, | |||
void * | d | |||
) |
Delete the specified callback function from the widget.
- Parameters:
-
w,: the widget to delete the callback t,: the type of event associated with the callback f,: the function called by the callback d,: the data passed to the callback
- Returns:
- Returns no value. Delete and frees the callback that calls function f when event t occurs to widget w.
Ewl_Callback* ewl_callback_insert_after | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
Ewl_Callback_Function | f, | |||
void * | user_data, | |||
Ewl_Callback_Function | after, | |||
void * | after_data | |||
) |
Add a callback after a previous callback in list.
- Parameters:
-
w,: the widget to insert the callback t,: the type of the callback that is being attached f,: the function to attach as a callback user_data,: the data to be passed to the callback function after,: the function of the callback to append after after_data,: the user data of the callback to append after
- Returns:
- Returns 0 on failure, the id of the new callback on success.
Ewl_Callback* ewl_callback_prepend | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
Ewl_Callback_Function | f, | |||
void * | user_data | |||
) |
prepend a callback of the specified type
- Parameters:
-
w,: the widget to attach the callback t,: the type of the callback that is being attached f,: the function to attach as a callback user_data,: the data to be passed to the callback function
- Returns:
- Returns 0 on failure, the pointer to the new callback on success.
unsigned int ewl_callback_type_add | ( | void | ) |
Creates and returns a new callback identifier.
- Returns:
- Returns a new callback identifier
int ewl_callbacks_init | ( | void | ) |
Setup internal registration variables for callbacks.
- Returns:
- Returns no value.
W/o shared callbacks ewl_test with all windows open has a top line of: 21279 ningerso 19 0 22972 22M 9412 R 6.0 8.0 0:40 ewl_test With shared callbacks ewl_test with all windows open has a top line of: 15901 ningerso 10 0 20120 19M 9148 S 0.0 7.0 0:34 ewl_test
So using shared callbacks saves us over 2 MB of memory in this case.
Ecore_list as the callback storage with all tests open has a top line of: 9121 dsinclai 15 0 71156 17m 4276 S 0.0 1.8 0:11.06 ewl_test Using an array as the callback storage with all tests open has a top line of: 21727 dsinclai 15 0 68360 15m 4304 S 0.0 1.5 0:09.73 ewl_test
So using an array for the callbacks saves us about 2MB of memory in this case.
void ewl_callbacks_shutdown | ( | void | ) |
Destroy internal registration variables for callbacks.
- Returns:
- Returns no value.