Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/bin Modified Files: ewl_text_test.c Log Message: - do some cleanup in the ewl_widget that was missing - add in triggers for the ewl_text. This allows you to make things like html a href tags in ewl_text boxes - multiline triggers are not currently supported. - several bug fixes for the ewl_text stuff =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_text_test.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ewl_text_test.c 2 Jul 2005 05:59:02 -0000 1.1 +++ ewl_text_test.c 21 Jul 2005 00:47:57 -0000 1.2 @@ -11,11 +11,46 @@ __create_text_test_window, NULL); } +static void +__trigger_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, void *data) +{ + printf("%s\n", (char *)data); +} + +static void +__trigger_cb_mouse_in(Ewl_Widget *w, void *ev __UNUSED__, void *data __UNUSED__) +{ + Ewl_Text_Trigger *t; + + t = EWL_TEXT_TRIGGER(w); + + ewl_text_cursor_position_set(EWL_TEXT(t->parent), t->pos); + ewl_text_color_apply(EWL_TEXT(t->parent), 255, 0, 0, 255, t->len); + +#if 0 + printf("DUMP\n"); + ewl_text_btree_dump((EWL_TEXT(t->parent))->formatting, ""); + printf("DUMP DONE\n"); +#endif +} + +static void +__trigger_cb_mouse_out(Ewl_Widget *w, void *ev __UNUSED__, void *data __UNUSED__) +{ + Ewl_Text_Trigger *t; + + t = EWL_TEXT_TRIGGER(w); + + ewl_text_cursor_position_set(EWL_TEXT(t->parent), t->pos); + ewl_text_color_apply(EWL_TEXT(t->parent), 0, 0, 0, 255, t->len); +} + void __create_text_test_window(Ewl_Widget *w, void *ev __UNUSED__, void *data __UNUSED__) { Ewl_Widget *win, *o; + Ewl_Text_Trigger *trigger; text_button = w; @@ -41,12 +76,12 @@ ewl_container_child_append(EWL_CONTAINER(win), o); ewl_text_bg_color_set(EWL_TEXT(o), 50, 50, 50, 255); - ewl_text_text_insert(EWL_TEXT(o), "The first bunch of text\n", 0); + ewl_text_text_insert(EWL_TEXT(o), "The first bunch of text\n", 0); /* 24 */ ewl_text_cursor_position_set(EWL_TEXT(o), 10); ewl_text_color_apply(EWL_TEXT(o), 0, 0, 255, 255, 5); - ewl_text_text_append(EWL_TEXT(o), "The second bunch of text\n"); + ewl_text_text_append(EWL_TEXT(o), "The second bunch of text\n"); /* 25 */ ewl_text_font_size_set(EWL_TEXT(o), 20); ewl_text_styles_set(EWL_TEXT(o), EWL_TEXT_STYLE_DOUBLE_UNDERLINE @@ -55,29 +90,45 @@ ewl_text_double_underline_color_set(EWL_TEXT(o), 255, 0, 0, 255); ewl_text_shadow_color_set(EWL_TEXT(o), 128, 128, 128, 128); ewl_text_outline_color_set(EWL_TEXT(o), 200, 200, 200, 200); - ewl_text_text_append(EWL_TEXT(o), "The third bunch of text\n"); + ewl_text_text_append(EWL_TEXT(o), "The third bunch of text\n"); /* 24 */ + ewl_text_styles_set(EWL_TEXT(o), EWL_TEXT_STYLE_NONE); + ewl_text_text_insert(EWL_TEXT(o), "The fourth bunch of text\n", 31); /* 25 */ - ewl_text_text_insert(EWL_TEXT(o), "The fourth bunch of text\n", 31); + trigger = ewl_text_trigger_new(EWL_TEXT_TRIGGER_TYPE_TRIGGER); + trigger->pos = ewl_text_length_get(EWL_TEXT(o)); - ewl_text_text_insert(EWL_TEXT(o), "The fifth bunch of text\n", 0); + ewl_text_text_append(EWL_TEXT(o), "This is the link."); /* 17 */ + + trigger->len = ewl_text_cursor_position_get(EWL_TEXT(o)) - trigger->pos + 1; + + ewl_text_trigger_add(EWL_TEXT(o), trigger); + ewl_callback_append(EWL_WIDGET(trigger), EWL_CALLBACK_MOUSE_UP, + __trigger_cb, "You clicked the trigger, have a cookie."); + ewl_callback_append(EWL_WIDGET(trigger), EWL_CALLBACK_FOCUS_IN, + __trigger_cb_mouse_in, NULL); + ewl_callback_append(EWL_WIDGET(trigger), EWL_CALLBACK_FOCUS_OUT, + __trigger_cb_mouse_out, NULL); + + + ewl_text_text_insert(EWL_TEXT(o), "The fifth bunch of text\n", 0); /* 24 */ ewl_text_cursor_position_set(EWL_TEXT(o), 0); ewl_text_color_apply(EWL_TEXT(o), 255, 0, 0, 255, 24); - ewl_text_text_insert(EWL_TEXT(o), "The sixth bunch of text\n", 24); + ewl_text_text_insert(EWL_TEXT(o), "The sixth bunch of text\n", 24); /* 24 */ ewl_text_cursor_position_set(EWL_TEXT(o), 43); ewl_text_color_apply(EWL_TEXT(o), 0, 255, 0, 255, 14); ewl_text_color_set(EWL_TEXT(o), 255, 0, 0, 255); - ewl_text_text_append(EWL_TEXT(o), "And in red\n"); + ewl_text_text_append(EWL_TEXT(o), "And in red\n"); /* 11 */ ewl_widget_show(o); #if 0 - printf("DUMP\n"); + printf("-- DUMP --\n"); ewl_text_btree_dump((EWL_TEXT(o))->formatting, ""); - printf("DUMP DONE\n"); + printf("-- DUMP DONE --\n"); #endif } ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs