Hello.
I made a patch for Etk to add scrolling ability to Etk_Text_View. It
isn't very good, but it works.
I made modifications in etk_test program also to demonstrate it. See Tag
Presentation.
The annoying thing is that it sometimes does not calculate the size right
(it gets mistaken by 1 pixel). So scrollbars sometimes are visible if
there is no need and you can slide them by 1 pixel.
The other is that i didn't comment it out. Sorry for that.
Regards, ptomaine.
? etk_text_view_scroll.patch
Index: src/bin/etk_text_view_test.c
===================================================================
RCS file: /var/cvs/e/e17/libs/etk/src/bin/etk_text_view_test.c,v
retrieving revision 1.16
diff -u -r1.16 etk_text_view_test.c
--- src/bin/etk_text_view_test.c 6 Oct 2006 17:04:13 -0000 1.16
+++ src/bin/etk_text_view_test.c 16 Feb 2007 17:59:12 -0000
@@ -72,6 +72,7 @@
static Etk_Widget *win = NULL;
Etk_Widget *vbox;
Etk_Widget *text_view;
+ Etk_Widget *scrolled_view;
if (win)
{
@@ -134,8 +135,12 @@
"<i>right_margin:</i> The right margin of the paragraph, in pixels"
"</p>",
ETK_TRUE);
+
+ scrolled_view = etk_scrolled_view_new();
+
+ etk_bin_child_set( ETK_BIN(scrolled_view), text_view );
- etk_box_append(ETK_BOX(vbox), text_view, ETK_BOX_START,
ETK_BOX_EXPAND_FILL, 0);
+ etk_box_append(ETK_BOX(vbox), scrolled_view, ETK_BOX_START,
ETK_BOX_EXPAND_FILL, 0);
etk_widget_show_all(win);
}
Index: src/lib/etk_text_view.c
===================================================================
RCS file: /var/cvs/e/e17/libs/etk/src/lib/etk_text_view.c,v
retrieving revision 1.14
diff -u -r1.14 etk_text_view.c
--- src/lib/etk_text_view.c 6 Oct 2006 17:04:15 -0000 1.14
+++ src/lib/etk_text_view.c 16 Feb 2007 17:59:12 -0000
@@ -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);
@@ -264,4 +269,28 @@
}
}
+/* 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 );
+}
+
/** @} */
Index: src/lib/etk_textblock.c
===================================================================
RCS file: /var/cvs/e/e17/libs/etk/src/lib/etk_textblock.c,v
retrieving revision 1.29
diff -u -r1.29 etk_textblock.c
--- src/lib/etk_textblock.c 6 Oct 2006 17:04:15 -0000 1.29
+++ src/lib/etk_textblock.c 16 Feb 2007 17:59:13 -0000
@@ -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);
Index: src/lib/etk_textblock.h
===================================================================
RCS file: /var/cvs/e/e17/libs/etk/src/lib/etk_textblock.h,v
retrieving revision 1.17
diff -u -r1.17 etk_textblock.h
--- src/lib/etk_textblock.h 21 Aug 2006 11:18:28 -0000 1.17
+++ src/lib/etk_textblock.h 16 Feb 2007 17:59:13 -0000
@@ -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);
-------------------------------------------------------------------------
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-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel