Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk
Dir : e17/libs/etk/src/lib Modified Files: etk_textblock.c etk_textblock.h etk_text_view.c Log Message: * [Textview] Patch from ptomaine to add scrolling ability to the text-view. Thanks :) =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_textblock.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- etk_textblock.c 6 Oct 2006 17:04:15 -0000 1.29 +++ etk_textblock.c 19 Feb 2007 20:54:55 -0000 1.30 @@ -1160,6 +1160,85 @@ return tbo_sd->wrap; } +int etk_textblock_object_yoffset_get( Evas_Object *tbo ) +{ + Etk_Textblock_Object_SD *tbo_sd; + + if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo))) + return 0; + + return tbo_sd->yoffset; +} + +int etk_textblock_object_xoffset_get( Evas_Object *tbo ) +{ + Etk_Textblock_Object_SD *tbo_sd; + + if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo))) + return 0; + + return tbo_sd->xoffset; +} + +void etk_textblock_object_yoffset_set( Evas_Object *tbo, int yoffset ) +{ + Etk_Textblock_Object_SD *tbo_sd; + + if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo))) + return; + + tbo_sd->yoffset = yoffset; + + /* TODO: Update the object? */ +} + +void etk_textblock_object_xoffset_set( Evas_Object *tbo, int xoffset ) +{ + Etk_Textblock_Object_SD *tbo_sd; + + if (!tbo || !(tbo_sd = evas_object_smart_data_get(tbo))) + return; + + tbo_sd->xoffset = xoffset; + + /* TODO: Update the object? */ +} + +void etk_textblock_object_full_geometry_get( Evas_Object *tbo, int *x, int *y, int *w, int *h ) +{ + if(!tbo) + return; + + if(x) + { + evas_object_geometry_get( tbo, x, NULL, NULL, NULL ); + } + + if(y) + { + evas_object_geometry_get( tbo, NULL, y, NULL, NULL ); + } + + if(w) + { + evas_object_geometry_get( tbo, NULL, NULL, w, NULL ); + } + + if(h) + { + Etk_Textblock_Object_SD *tbo_sd; + Etk_Textblock_Object_Line *line; + + *h = 0; + + if( !( tbo_sd = evas_object_smart_data_get(tbo) ) ) + return; + + for (line = tbo_sd->lines; line; line = line->next) + *h += line->geometry.h; + } +} + /** * @brief Gets the cursor's iterator of the textblock object * @param tbo a textblock object @@ -3548,7 +3627,7 @@ /* We update the lines */ /* TODO: optimize: Updates all the lines in several times and use a binary tree! */ - y = 0; + y = - tbo_sd->yoffset; evas_object_geometry_get(tbo, &ox, &oy, &ow, &oh); for (line = tbo_sd->lines; line; line = line->next) { @@ -3563,7 +3642,7 @@ } else { - evas_object_move(line->object, ox + line->geometry.x, oy + line->geometry.y); + evas_object_move(line->object, tbo_sd->xoffset + ox + line->geometry.x, oy + line->geometry.y); evas_object_resize(line->object, line->geometry.w, line->geometry.h); evas_object_show(line->object); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_textblock.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- etk_textblock.h 21 Aug 2006 11:18:28 -0000 1.17 +++ etk_textblock.h 19 Feb 2007 20:54:55 -0000 1.18 @@ -241,6 +241,14 @@ void etk_textblock_object_cursor_visible_set(Evas_Object *tbo, Etk_Bool visible); Etk_Bool etk_textblock_object_cursor_visible_get(Evas_Object *tbo); +void etk_textblock_object_yoffset_set( Evas_Object *tbo, int yoffset ); +int etk_textblock_object_yoffset_get( Evas_Object *tbo ); + +void etk_textblock_object_xoffset_set( Evas_Object *tbo, int xoffset ); +int etk_textblock_object_xoffset_get( Evas_Object *tbo ); + +void etk_textblock_object_full_geometry_get( Evas_Object *tbo, int *x, int *y, int *w, int *h ); + /* Misc funcs */ int etk_textblock_unicode_length_get(const char *unicode_string); Etk_Bool etk_textblock_is_white_char(int c); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_text_view.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- etk_text_view.c 6 Oct 2006 17:04:15 -0000 1.14 +++ etk_text_view.c 19 Feb 2007 20:54:55 -0000 1.15 @@ -26,6 +26,8 @@ static void _etk_text_view_realize_cb(Etk_Object *object, void *data); static void _etk_text_view_unrealize_cb(Etk_Object *object, void *data); static void _etk_text_view_key_down_cb(Etk_Object *object, Etk_Event_Key_Down *event, void *data); +static void _etk_text_view_scroll_size_get(Etk_Widget *widget, Etk_Size scrollview_size, Etk_Size scrollbar_size, Etk_Size *scroll_size); +static void _etk_text_view_scroll(Etk_Widget *widget, int x, int y); static Etk_Signal *_etk_text_view_signals[ETK_TEXT_VIEW_NUM_SIGNALS]; @@ -121,6 +123,9 @@ ETK_WIDGET(text_view)->size_allocate = _etk_text_view_size_allocate; + ETK_WIDGET(text_view)->scroll = _etk_text_view_scroll; + ETK_WIDGET(text_view)->scroll_size_get = _etk_text_view_scroll_size_get; + etk_signal_connect("realize", ETK_OBJECT(text_view), ETK_CALLBACK(_etk_text_view_realize_cb), NULL); etk_signal_connect("unrealize", ETK_OBJECT(text_view), ETK_CALLBACK(_etk_text_view_unrealize_cb), NULL); etk_signal_connect("key_down", ETK_OBJECT(text_view), ETK_CALLBACK(_etk_text_view_key_down_cb), NULL); @@ -262,6 +267,30 @@ etk_textblock_delete_range(tb, cursor, selection); etk_textblock_insert(tb, cursor, event->string, -1); } +} + +/* Size of all the text_view for scrolling ability. */ +static void _etk_text_view_scroll_size_get(Etk_Widget *widget, Etk_Size scrollview_size, Etk_Size scrollbar_size, Etk_Size *scroll_size) +{ + Etk_Text_View *text_view; + + if(!(text_view = ETK_TEXT_VIEW(widget)) || !scroll_size ) + return; + + etk_textblock_object_full_geometry_get( text_view->textblock_object, NULL, NULL, &(scroll_size->w), &(scroll_size->h) ); +} + +static void _etk_text_view_scroll(Etk_Widget *widget, int x, int y) +{ + Etk_Text_View *text_view; + + if( !( text_view = ETK_TEXT_VIEW(widget) ) ) + return; + + etk_textblock_object_xoffset_set( text_view->textblock_object, x ); + etk_textblock_object_yoffset_set( text_view->textblock_object, y ); + + etk_widget_redraw_queue( widget ); } /** @} */ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs