Enlightenment CVS committal Author : ningerso Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_entry.c ewl_entry.h Log Message: Demo DND functionality in the text editor test. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_entry.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -3 -r1.63 -r1.64 --- ewl_entry.c 16 Aug 2006 16:10:01 -0000 1.63 +++ ewl_entry.c 7 Sep 2006 18:58:16 -0000 1.64 @@ -35,6 +35,7 @@ int ewl_entry_init(Ewl_Entry *e) { + const char *text_types[] = { "UTF8_STRING", "text/plain", NULL }; Ewl_Widget *w; DENTER_FUNCTION(DLEVEL_STABLE); @@ -54,6 +55,8 @@ ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_FOCUS_IN); ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_FOCUS_OUT); + ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_DND_POSITION); + ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_DND_DATA); /* setup the cursor */ e->cursor = ewl_entry_cursor_new(e); @@ -68,6 +71,7 @@ * to show the cursor */ ewl_entry_editable_set(e, TRUE); ewl_text_selectable_set(EWL_TEXT(e), TRUE); + ewl_dnd_accepts_types_set(e, text_types); /* setup callbacks */ ewl_callback_append(w, EWL_CALLBACK_FOCUS_IN, @@ -84,6 +88,10 @@ ewl_entry_cb_disable, NULL); ewl_callback_append(w, EWL_CALLBACK_WIDGET_ENABLE, ewl_entry_cb_enable, NULL); + ewl_callback_append(w, EWL_CALLBACK_DND_POSITION, + ewl_entry_cb_dnd_position, NULL); + ewl_callback_append(w, EWL_CALLBACK_DND_DATA, + ewl_entry_cb_dnd_data, NULL); DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -508,6 +516,53 @@ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); /* XXX do we leave the cursor at the start? or move to the end? */ + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param w: The widget to work with + * @param ev: DND positioin event + * @param data: UNUSED + * @return Returns no value + * @brief The dnd mouse move callback + */ +void +ewl_entry_cb_dnd_position(Ewl_Widget *w, void *ev, void *data __UNUSED__) +{ + Ewl_Event_Dnd_Position *event = ev; + Ewl_Text *txt = EWL_TEXT(w); + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + + ewl_widget_focus_send(w); + ewl_text_cursor_position_set(txt, ewl_text_coord_index_map(txt, event->x, event->y)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param w: The widget to work with + * @param ev: DND positioin event + * @param data: UNUSED + * @return Returns no value + * @brief The dnd mouse move callback + */ +void +ewl_entry_cb_dnd_data(Ewl_Widget *w, void *ev, void *data __UNUSED__) +{ + Ewl_Event_Dnd_Data *event = ev; + Ewl_Text *txt = EWL_TEXT(w); + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + + ewl_text_text_insert(txt, event->data, ewl_text_cursor_position_get(txt)); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_entry.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_entry.h 11 May 2006 04:01:20 -0000 1.21 +++ ewl_entry.h 7 Sep 2006 18:58:16 -0000 1.22 @@ -67,6 +67,8 @@ void ewl_entry_cb_focus_out(Ewl_Widget *w, void *ev, void *data); void ewl_entry_cb_disable(Ewl_Widget *w, void *ev, void *data); void ewl_entry_cb_enable(Ewl_Widget *w, void *ev, void *data); +void ewl_entry_cb_dnd_position(Ewl_Widget *w, void *ev, void *data); +void ewl_entry_cb_dnd_data(Ewl_Widget *w, void *ev, void *data); void ewl_entry_cursor_move_left(Ewl_Entry *e); void ewl_entry_cursor_move_right(Ewl_Entry *e); ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs