Download

Support

Ewl_Callback: The Callback Mechanisms


Detailed Description

Defines methods for creating and modifying callbacks on widgets

Tutorial


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 struct Ewl_Callback Ewl_Callback
typedef struct Ewl_Callback_Custom Ewl_Callback_Custom
typedef void(* Ewl_Callback_Function )(Ewl_Widget *widget, void *ev_data, void *user_data)

Functions

int 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_cb_id (Ewl_Widget *w, unsigned int t, int cb_id)
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.
int 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.
int 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,
 )     w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_INTERCEPT

Sets the callback intercept flag from a widget for a certain event type.

Referenced by ewl_container_callback_intercept().

#define EWL_CALLBACK_FLAG_NOINTERCEPT ( w,
 ) 

Value:

w->callbacks[EWL_CALLBACK_INDEX(t)].mask = \
                        w->callbacks[EWL_CALLBACK_INDEX(t)].mask & ~EWL_CALLBACK_NOTIFY_INTERCEPT
Clears the callback intercept flag from a widget for a certain event type.

Referenced by ewl_container_callback_nointercept().

#define EWL_CALLBACK_FLAG_NONOTIFY ( w,
 )     w->callbacks[EWL_CALLBACK_INDEX(t)].mask &= ~EWL_CALLBACK_NOTIFY_NOTIFY

Remove the callback notify flag from a widget for a certain event type.

Referenced by ewl_container_callback_nonotify().

#define EWL_CALLBACK_FLAG_NOTIFY ( w,
 )     w->callbacks[EWL_CALLBACK_INDEX(t)].mask |= EWL_CALLBACK_NOTIFY_NOTIFY

Sets the callback notify flag from a widget for a certain event type.

Referenced by ewl_container_callback_notify().

#define EWL_CALLBACK_FLAGS ( w,
 )     (w->callbacks[EWL_CALLBACK_INDEX(t)].mask)

Retrives the callback flags from a widget for a certain event type.

Referenced by ewl_callback_call_with_event_data().

#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 < EWL_CALLBACK_MAX) ? t : EWL_CALLBACK_MAX)

Retrieves the actual array index for t

#define EWL_CALLBACK_LEN ( w,
 )     (w->callbacks[EWL_CALLBACK_INDEX(t)].len)

#define EWL_CALLBACK_LIST ( w,
 )     (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,
 )     w->callbacks[EWL_CALLBACK_INDEX(t)].index

Retrives the current callback position from a widget for an event type.

Referenced by ewl_callback_call_with_event_data().

#define EWL_CALLBACK_SET_DIRECT ( w,
 )     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,
 )     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.

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

int 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 0 on failure, the id of the new callback on success. Allocates a new callback for the specified widget that calls f with user_data as the data parameter when event ta occurs. This event is placed at the end of the callback chain.

References DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, EWL_CALLBACK_LEN, and EWL_WIDGET_TYPE.

Referenced by ewl_box_homogeneous_set(), ewl_box_init(), ewl_button_init(), ewl_calendar_init(), ewl_cell_init(), ewl_cell_state_change_cb_add(), ewl_check_init(), ewl_checkbutton_init(), ewl_colordialog_init(), ewl_colorpicker_init(), ewl_combo_cell_init(), ewl_combo_init(), ewl_container_init(), ewl_context_menu_attach(), ewl_context_menu_cb_child_add(), ewl_context_menu_init(), ewl_cursor_init(), ewl_datepicker_init(), ewl_embed_init(), ewl_entry_cb_mouse_down(), ewl_entry_editable_set(), ewl_entry_init(), ewl_expansion_init(), ewl_filedialog_init(), ewl_filepicker_init(), ewl_floater_follow_set(), ewl_freebox_init(), ewl_grid_init(), ewl_histogram_image_set(), ewl_histogram_init(), ewl_icon_editable_set(), ewl_icon_image_set(), ewl_image_init(), ewl_image_thumbnail_get(), ewl_list_cb_configure(), ewl_list_init(), ewl_media_init(), ewl_menu_from_info(), ewl_menu_init(), ewl_mvc_init(), ewl_notebook_page_tab_widget_set(), ewl_paned_grabber_init(), ewl_paned_init(), ewl_popup_follow_set(), ewl_popup_init(), ewl_progressbar_init(), ewl_radiobutton_init(), ewl_row_init(), ewl_scrollbar_init(), ewl_scrollpane_init(), ewl_scrollpane_kinetic_scrolling_set(), ewl_seeker_init(), ewl_spectrum_cb_mouse_down(), ewl_spectrum_init(), ewl_spinner_init(), ewl_statusbar_init(), ewl_table_init(), ewl_text_cb_mouse_down(), ewl_text_init(), ewl_text_selectable_set(), ewl_text_trigger_init(), ewl_tree_init(), ewl_tree_node_expandable_set(), ewl_tree_node_init(), ewl_widget_init(), ewl_window_init(), ewl_window_leader_set(), and ewl_window_transient_for().

void ewl_callback_del ( Ewl_Widget w,
unsigned int  t,
Ewl_Callback_Function  f 
)

void ewl_callback_del_cb_id ( Ewl_Widget w,
unsigned int  t,
int  cb_id 
)

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.

References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, EWL_CALLBACK_LEN, EWL_WIDGET_TYPE, func, and user_data.

Referenced by ewl_floater_follow_set(), ewl_popup_cb_destroy(), and ewl_popup_follow_set().

int 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. Same functionality as ewl_callback_append, but the callback is placed after the specified callback on the callback chain.

References DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, EWL_CALLBACK_LEN, EWL_WIDGET_TYPE, func, and user_data.

int 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 id of the new callback on success. Same functionality as ewl_callback_append, but the callback is placed at the beginning of the callback chain.

References DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, and EWL_WIDGET_TYPE.

Referenced by ewl_datepicker_init(), ewl_embed_init(), ewl_entry_init(), ewl_filelist_init(), ewl_filepicker_init(), ewl_floater_follow_set(), ewl_floater_init(), ewl_grid_init(), ewl_icon_init(), ewl_image_init(), ewl_image_thumbnail_init(), ewl_menu_init(), ewl_overlay_init(), ewl_popup_follow_set(), ewl_popup_init(), ewl_radiobutton_init(), ewl_seeker_init(), ewl_spinner_init(), ewl_table_add(), ewl_text_init(), ewl_text_trigger_init(), ewl_tree_init(), and ewl_window_init().

unsigned int ewl_callback_type_add ( void   ) 

Creates and returns a new callback identifier.

Returns:
Returns a new callback identifier

References DENTER_FUNCTION, DLEVEL_STABLE, and DRETURN_INT.

Referenced by ewl_dnd_init(), and ewl_init().

int ewl_callbacks_init ( void   ) 

Setup internal registration variables for callbacks.

Returns:
Returns no value. Sets up some important variables for tracking callbacks that allow shared callbacks.
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.

References DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, and EWL_CALLBACK_MAX.

Referenced by ewl_init().

void ewl_callbacks_shutdown ( void   ) 

Destroy internal registration variables for callbacks.

Returns:
Returns no value. Destroys some important variables for tracking callbacks that allow shared callbacks.

References DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, and IF_FREE_HASH.

Referenced by ewl_init().


Copyright © Enlightenment.org

Enlightened Widget Library Documentation Generated: Sat May 17 16:51:08 2008