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 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, | |||
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.
Referenced by ewl_container_callback_intercept().
#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
Referenced by ewl_container_callback_nointercept().
#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.
Referenced by ewl_container_callback_nonotify().
#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.
Referenced by ewl_container_callback_notify().
#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.
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 | ) | ((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.
Referenced by ewl_callback_append(), ewl_callback_call_with_event_data(), ewl_callback_clear(), ewl_callback_del(), ewl_callback_del_cb_id(), ewl_callback_del_type(), ewl_callback_del_with_data(), and ewl_callback_insert_after().
#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.
Referenced by ewl_callback_call_with_event_data().
#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
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_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. Executes the callback chain for the specified widget w, with event t.
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, ewl_callback_call_with_event_data(), and EWL_WIDGET_TYPE.
Referenced by ewl_check_cb_clicked(), ewl_checkbutton_cb_clicked(), ewl_datepicker_init(), ewl_embed_active_set(), ewl_embed_focused_widget_set(), ewl_embed_mouse_move_feed(), ewl_entry_cb_key_down(), ewl_image_file_set(), ewl_menu_cb_mouse_move(), ewl_notebook_visible_page_set(), ewl_radiobutton_cb_clicked(), ewl_range_value_set(), ewl_scrollpane_cb_hscroll(), ewl_scrollpane_cb_vscroll(), ewl_widget_disable(), ewl_widget_enable(), ewl_widget_hide(), ewl_widget_obscure(), ewl_widget_realize(), ewl_widget_reveal(), ewl_widget_show(), and ewl_widget_unrealize().
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. Similar to ewl_callback_call, but the event data is substituted by ev_data.
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, ewl_callback_call_with_event_data(), EWL_CALLBACK_FLAGS, EWL_CALLBACK_LEN, EWL_CALLBACK_NOTIFY_INTERCEPT, EWL_CALLBACK_NOTIFY_NOTIFY, EWL_CALLBACK_POS, EWL_WIDGET_TYPE, func, Ewl_Widget::parent, and user_data.
Referenced by ewl_button_cb_key_down(), ewl_callback_call(), ewl_callback_call_with_event_data(), ewl_container_cb_realize(), ewl_embed_dnd_data_received_feed(), ewl_embed_dnd_data_request_feed(), ewl_embed_dnd_drop_feed(), ewl_embed_dnd_position_feed(), ewl_embed_focused_widget_set(), ewl_embed_key_down_feed(), ewl_embed_key_up_feed(), ewl_embed_mouse_down_feed(), ewl_embed_mouse_move_feed(), ewl_embed_mouse_out_feed(), ewl_embed_mouse_up_feed(), ewl_embed_mouse_wheel_feed(), ewl_filelist_directory_set(), ewl_filelist_multiselect_set(), ewl_filelist_selected_files_change_notify(), ewl_widget_cb_mouse_up(), ewl_widget_parent_set(), ewl_widget_reparent(), and ewl_widget_state_set().
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.
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, EWL_CALLBACK_LEN, EWL_WIDGET_TYPE, and func.
Referenced by ewl_box_homogeneous_set(), ewl_box_init(), ewl_cell_state_change_cb_del(), ewl_checkbutton_init(), ewl_context_menu_cb_child_remove(), ewl_context_menu_detach(), ewl_entry_cb_mouse_up(), ewl_entry_editable_set(), ewl_floater_relative_set(), ewl_icon_editable_set(), ewl_menu_cb_destroy(), ewl_scrollpane_init(), ewl_scrollpane_kinetic_scrolling_set(), ewl_spectrum_cb_mouse_up(), ewl_spinner_init(), ewl_text_cb_mouse_up(), ewl_text_selectable_set(), ewl_tree_node_expandable_set(), ewl_tree_node_init(), and ewl_window_cb_realize_parent().
void ewl_callback_del_cb_id | ( | Ewl_Widget * | w, | |
unsigned int | t, | |||
int | cb_id | |||
) |
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, EWL_CALLBACK_LEN, EWL_WIDGET_TYPE, and id.
void ewl_callback_del_type | ( | Ewl_Widget * | w, | |
unsigned int | t | |||
) |
References DCHECK_PARAM_PTR, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, Ewl_Callback_Custom::event_id, EWL_CALLBACK_LEN, and EWL_CALLBACK_MAX.
Referenced by ewl_callback_clear(), and ewl_widget_destroy().
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.
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().