Enlightenment CVS committal

Author  : moom16
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_text_view.c etk_textblock.c etk_textblock.h etk_widget.c 


Log Message:
* More work on the text view (it still far from being usable!!)


===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_text_view.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etk_text_view.c     15 Feb 2006 18:36:55 -0000      1.2
+++ etk_text_view.c     15 Feb 2006 21:01:33 -0000      1.3
@@ -19,6 +19,7 @@
 };
 
 static void _etk_text_view_constructor(Etk_Text_View *text_view);
+static void _etk_text_view_destructor(Etk_Text_View *text_view);
 static void _etk_text_view_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry);
 static void _etk_text_view_realize_cb(Etk_Object *object, void *data);
 static void _etk_text_view_unrealize_cb(Etk_Object *object, void *data);
@@ -41,8 +42,7 @@
 
    if (!text_view_type)
    {
-      /* TODO: destructor */
-      text_view_type = etk_type_new("Etk_Text_View", ETK_WIDGET_TYPE, 
sizeof(Etk_Text_View), ETK_CONSTRUCTOR(_etk_text_view_constructor), NULL);
+      text_view_type = etk_type_new("Etk_Text_View", ETK_WIDGET_TYPE, 
sizeof(Etk_Text_View), ETK_CONSTRUCTOR(_etk_text_view_constructor), 
ETK_DESTRUCTOR(_etk_text_view_destructor));
 
       _etk_text_view_signals[ETK_TEXT_VIEW_TEXT_CHANGED_SIGNAL] = 
etk_signal_new("text_changed", text_view_type, -1, etk_marshaller_VOID__VOID, 
NULL, NULL);
    }
@@ -66,7 +66,7 @@
  *
  **************************/
 
-/* Initializes the default values of the text_view */
+/* Initializes the default values of the text view */
 static void _etk_text_view_constructor(Etk_Text_View *text_view)
 {
    if (!text_view)
@@ -79,6 +79,15 @@
    etk_signal_connect("unrealize", ETK_OBJECT(text_view), 
ETK_CALLBACK(_etk_text_view_unrealize_cb), NULL);
 }
 
+/* Destroys the text view */
+static void _etk_text_view_destructor(Etk_Text_View *text_view)
+{
+   if (!text_view)
+      return;
+   etk_object_destroy(ETK_OBJECT(text_view->textblock));
+   text_view->textblock = NULL;
+}
+
 /* TODO: Renders the textblock object */
 static void _etk_text_view_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry)
 {
@@ -87,9 +96,8 @@
    if (!(text_view = ETK_TEXT_VIEW(widget)))
       return;
    
-   printf("text_view_size_allocate\n");
-   evas_object_move(text_view->textblock->textblock_object, geometry.x, 
geometry.y);
-   evas_object_resize(text_view->textblock->textblock_object, geometry.w, 
geometry.h);
+   evas_object_move(text_view->textblock->smart_object, geometry.x, 
geometry.y);
+   evas_object_resize(text_view->textblock->smart_object, geometry.w, 
geometry.h);
 }
 
 /**************************
@@ -107,8 +115,9 @@
    if (!(text_view = ETK_TEXT_VIEW(object)) || !(evas = 
etk_widget_toplevel_evas_get(ETK_WIDGET(text_view))))
       return;
 
-   //etk_textblock_realize(text_view->textblock, evas);
-   etk_widget_member_object_add(ETK_WIDGET(text_view), 
text_view->textblock->textblock_object);
+   etk_textblock_realize(text_view->textblock, evas);
+   etk_widget_member_object_add(ETK_WIDGET(text_view), 
text_view->textblock->smart_object);
+   evas_object_show(text_view->textblock->smart_object);
 }
 
 /* Called when the text view is unrealized */
@@ -119,8 +128,11 @@
    if (!(text_view = ETK_TEXT_VIEW(object)))
       return;
    
-   etk_widget_member_object_del(ETK_WIDGET(text_view), 
text_view->textblock->textblock_object);
-   //etk_textblock_unrealize(text_view->textblock);
+   if (text_view->textblock)
+   {
+      etk_widget_member_object_del(ETK_WIDGET(text_view), 
text_view->textblock->smart_object);
+      etk_textblock_unrealize(text_view->textblock);
+   }
 }
 
 /** @} */
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_textblock.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_textblock.c     15 Feb 2006 18:36:55 -0000      1.1
+++ etk_textblock.c     15 Feb 2006 21:01:33 -0000      1.2
@@ -10,10 +10,19 @@
 
 static void _etk_textblock_constructor(Etk_Textblock *textblock);
 static void _etk_textblock_destructor(Etk_Textblock *textblock);
+static void _etk_textblock_object_evas_set(Etk_Textblock *textblock, Evas 
*new_evas);
+
+static void _etk_textblock_smart_move_cb(Evas_Object *obj, Evas_Coord x, 
Evas_Coord y);
+static void _etk_textblock_smart_resize_cb(Evas_Object *obj, Evas_Coord w, 
Evas_Coord h);
+static void _etk_textblock_smart_show_cb(Evas_Object *obj);
+static void _etk_textblock_smart_hide_cb(Evas_Object *obj);
+static void _etk_textblock_smart_clip_set_cb(Evas_Object *obj, Evas_Object 
*clip);
+static void _etk_textblock_smart_clip_unset_cb(Evas_Object *obj);
 
 static Evas *_etk_textblock_evas = NULL;
 static unsigned char _etk_textblock_pixel_buffer[ETK_TEXTBLOCK_EVAS_SIZE * 
ETK_TEXTBLOCK_EVAS_SIZE * 3];
 static Evas_Textblock_Style *_etk_textblock_style = NULL;
+static Evas_Smart *_etk_textblock_smart = NULL;
 static int _etk_textblock_count = 0;
 
 /**************************
@@ -50,6 +59,38 @@
 {
    if (!textblock || !evas)
       return;
+   
+   _etk_textblock_object_evas_set(textblock, evas);
+   
+   if (!_etk_textblock_smart)
+   {
+      _etk_textblock_smart = evas_smart_new(
+         "etk_textblock_smart_object",
+         NULL, /* add */
+         NULL, /* del */
+         NULL, /* layer_set */
+         NULL, /* raise */
+         NULL, /* lower */
+         NULL, /* stack_above */
+         NULL, /* stack_below */
+         _etk_textblock_smart_move_cb, /* move */
+         _etk_textblock_smart_resize_cb, /* resize */
+         _etk_textblock_smart_show_cb, /* show */
+         _etk_textblock_smart_hide_cb, /* hide */
+         NULL, /* color_set */
+         _etk_textblock_smart_clip_set_cb, /* clip_set */
+         _etk_textblock_smart_clip_unset_cb, /* clip_unset */
+         NULL); /* data*/
+   }
+   textblock->smart_object = evas_object_smart_add(evas, _etk_textblock_smart);
+   evas_object_smart_data_set(textblock->smart_object, textblock);
+   evas_object_smart_member_add(textblock->textblock_object, 
textblock->smart_object);
+   
+   /*textblock->clip = evas_object_rectangle_add(evas);
+   evas_object_color_set(textblock->clip, 255, 128, 0, 80);
+   evas_object_smart_member_add(textblock->clip, textblock->smart_object);
+   evas_object_lower(textblock->clip);*/
+   /* TODO: realize: creates selection rects, clip, cursor, timer  */
 }
 
 /* TODO: doc */
@@ -58,21 +99,37 @@
    if (!textblock)
       return;
    
-   ecore_timer_del(textblock->cursor_timer);
-   textblock->cursor_timer = NULL;
-   
-   //_etk_textblock_object_evas_change(textblock, textblock->textblock_object, 
_etk_textblock_evas);
-   
-   evas_object_del(textblock->cursor_object);
-   textblock->cursor_object = NULL;
-   evas_object_del(textblock->clip);
-   textblock->clip = NULL;
+   if (textblock->cursor_timer)
+   {
+      ecore_timer_del(textblock->cursor_timer);
+      textblock->cursor_timer = NULL;
+   }
    
    while (textblock->selection_rects)
    {
       evas_object_del(textblock->selection_rects->data);
       textblock->selection_rects = 
evas_list_remove_list(textblock->selection_rects, textblock->selection_rects);
    }
+   
+   if (textblock->cursor_object)
+   {
+      evas_object_del(textblock->cursor_object);
+      textblock->cursor_object = NULL;
+   }
+   if (textblock->clip)
+   {
+      evas_object_del(textblock->clip);
+      textblock->clip = NULL;
+   }
+   if (textblock->smart_object)
+   {
+      if (textblock->textblock_object)
+         evas_object_smart_member_del(textblock->textblock_object);
+      evas_object_del(textblock->smart_object);
+      textblock->smart_object = NULL;
+   }
+   
+   _etk_textblock_object_evas_set(textblock, _etk_textblock_evas);
 }
 
 /**************************
@@ -87,6 +144,7 @@
    if (!textblock)
       return;
    
+   textblock->smart_object = NULL;
    textblock->textblock_object = NULL;
    textblock->cursor_object = NULL;
    textblock->clip = NULL;
@@ -147,9 +205,196 @@
    
    textblock->textblock_object = 
evas_object_textblock_add(_etk_textblock_evas);
    evas_object_textblock_style_set(textblock->textblock_object, 
_etk_textblock_style);
+   /* TODO; does it need to be shown */
+   evas_object_show(textblock->textblock_object);
+   
+   /* TODO: testing */
+   evas_object_textblock_text_markup_set
+     (textblock->textblock_object,
+      "<center><h1>Title</h1></center><br>"
+      "<p><tab>A pragraph here <red>red text</red> and stuff.</p>"
+      "<p>And escaping &lt; and &gt; as well as &amp; as <h1>normal.</h1></p>"
+      "<p>If you want a newline use &lt;br&gt;<br>woo a new line!</p>"
+      "<right>Right "
+      "<style=outline color=#fff outline_color=#000>aligned</> "
+      "<style=shadow shadow_color=#fff8>text</> "
+      "<style=soft_shadow shadow_color=#0002>should</> "
+      "<style=glow color=#fff glow2_color=#fe87 glow_color=#f214 >go here</> "
+      "<style=far_shadow shadow_color=#0005>as it is</> "
+      "<style=outline_shadow color=#fff outline_color=#8228 
shadow_color=#005>within</> "
+      "<style=outline_soft_shadow color=#fff outline_color=#8228 
shadow_color=#0002>right tags</> "
+      "<style=far_soft_shadow color=#fff shadow_color=#0002>to make it align 
to the</> "
+      "<underline=on underline_color=#00f>right hand</> "
+      "<backing=on backing_color=#fff8>side 
</><backing_color=#ff08>of</><backing_color=#0f08> </>"
+      "<strikethrough=on strikethrough_color=#f0f8>the textblock</>.</right>"
+      "<p>And "
+      "<underline=double underline_color=#f00 underline2_color=#00f>now we 
need</> "
+      "to test some <color=#f00 font_size=8>C</><color=#0f0 font_size=10>O</>"
+      "<color=#00f font_size=12>L</><color=#fff font_size=14>O</>"
+      "<color=#ff0 font_size=16>R</><color=#0ff font_size=18> Bla Rai</>"
+      "<color=#f0f font_size=20> Stuff</>.</p>"
+      "<blockquote>"
+      "(日本語 カタカナ ひらがな) "
+      "Heizölrückstoßabdämpfung fløde pingüino kilómetros cœur déçu 
l'âme "
+      "plutôt naïve Louÿs rêva crapaüter Íosa Úrmhac Óighe pór Éava 
Ádhaim"
+      "</blockquote>"
+      );
 }
 
 /* Destroys the textblock */
 static void _etk_textblock_destructor(Etk_Textblock *textblock)
 {
+   if (!textblock)
+      return;
+   
+   if (textblock->cursor_timer)
+      ecore_timer_del(textblock->cursor_timer);
+   
+   while (textblock->selection_rects)
+   {
+      evas_object_del(textblock->selection_rects->data);
+      textblock->selection_rects = 
evas_list_remove_list(textblock->selection_rects, textblock->selection_rects);
+   }
+   
+   if (textblock->cursor_object)
+      evas_object_del(textblock->cursor_object);
+   if (textblock->clip)
+      evas_object_del(textblock->clip);
+   if (textblock->textblock_object)
+      evas_object_del(textblock->textblock_object);
+   if (textblock->smart_object)
+      evas_object_del(textblock->smart_object);
+   
+   _etk_textblock_count--;
+   if (_etk_textblock_count <= 0)
+   {
+      if (_etk_textblock_style)
+      {
+         evas_textblock_style_free(_etk_textblock_style);
+         _etk_textblock_style = NULL;
+      }
+      if (_etk_textblock_evas)
+      {
+         evas_free(_etk_textblock_evas);
+         _etk_textblock_evas = NULL;
+      }
+   }
+}
+
+/**************************
+ *
+ * Private functions
+ *
+ **************************/
+
+/* Changes the evas used by the textblock object */
+static void _etk_textblock_object_evas_set(Etk_Textblock *textblock, Evas 
*new_evas)
+{
+   Evas_Object *new_tbo;
+   
+   if (!textblock || !new_evas)
+      return;
+   if (new_evas == evas_object_evas_get(textblock->textblock_object))
+      return;
+   
+   new_tbo = evas_object_textblock_add(new_evas);
+   evas_object_textblock_style_set(new_tbo, _etk_textblock_style);
+   
+   /* TODO */
+   evas_object_textblock_text_markup_set(new_tbo, "This is a test");
+   
+   evas_object_del(textblock->textblock_object);
+   textblock->textblock_object = new_tbo;
+}
+
+/* Called when the smart object of the textblock is moved */
+static void _etk_textblock_smart_move_cb(Evas_Object *obj, Evas_Coord x, 
Evas_Coord y)
+{
+   Etk_Textblock *textblock;
+   
+   if (!obj || !(textblock = evas_object_smart_data_get(obj)))
+      return;
+   
+   /* TODO: smart_move: update selection_rects, cursor_object  */
+   if (textblock->textblock_object)
+      evas_object_move(textblock->textblock_object, x, y);
+   if (textblock->clip)
+      evas_object_move(textblock->clip, x, y);
+}
+
+/* Called when the smart object of the textblock is resized */
+static void _etk_textblock_smart_resize_cb(Evas_Object *obj, Evas_Coord w, 
Evas_Coord h)
+{
+   Etk_Textblock *textblock;
+   
+   if (!obj || !(textblock = evas_object_smart_data_get(obj)))
+      return;
+   
+   /* TODO: smart_resize: update selection_rects, cursor_object  */
+   if (textblock->textblock_object)
+      evas_object_resize(textblock->textblock_object, w, h);
+   if (textblock->clip)
+      evas_object_resize(textblock->clip, w, h);
+}
+
+/* Called when the smart object of the textblock is shown */
+static void _etk_textblock_smart_show_cb(Evas_Object *obj)
+{
+   Evas_List *l;
+   Etk_Textblock *textblock;
+   
+   if (!obj || !(textblock = evas_object_smart_data_get(obj)))
+      return;
+   
+   if (textblock->textblock_object)
+      evas_object_show(textblock->textblock_object);
+   /* TODO: smart_show: restart timer */
+   if (textblock->cursor_object)
+      evas_object_show(textblock->cursor_object);
+   if (textblock->clip)
+      evas_object_show(textblock->clip);
+   
+   for (l = textblock->selection_rects; l; l = l->next)
+      evas_object_show(l->data);
+}
+
+/* Called when the smart object of the textblock is hidden */
+static void _etk_textblock_smart_hide_cb(Evas_Object *obj)
+{
+   Evas_List *l;
+   Etk_Textblock *textblock;
+   
+   if (!obj || !(textblock = evas_object_smart_data_get(obj)))
+      return;
+   
+   if (textblock->textblock_object)
+      evas_object_hide(textblock->textblock_object);
+   /* TODO: smart_hide: stop timer */
+   if (textblock->cursor_object)
+      evas_object_hide(textblock->cursor_object);
+   if (textblock->clip)
+      evas_object_hide(textblock->clip);
+   
+   for (l = textblock->selection_rects; l; l = l->next)
+      evas_object_hide(l->data);
+}
+
+/* Called when the smart object of the textblock is clipped */
+static void _etk_textblock_smart_clip_set_cb(Evas_Object *obj, Evas_Object 
*clip)
+{
+   Etk_Textblock *textblock;
+   
+   if (!obj || !clip || !(textblock = evas_object_smart_data_get(obj)) || 
!textblock->clip)
+      return;
+   evas_object_clip_set(textblock->clip, clip);
+}
+
+/* Called when the smart object of the textblock is unclipped */
+static void _etk_textblock_smart_clip_unset_cb(Evas_Object *obj)
+{
+   Etk_Textblock *textblock;
+   
+   if (!obj || !(textblock = evas_object_smart_data_get(obj)) || 
!textblock->clip)
+      return;
+   evas_object_clip_unset(textblock->clip);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_textblock.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_textblock.h     15 Feb 2006 18:36:55 -0000      1.1
+++ etk_textblock.h     15 Feb 2006 21:01:33 -0000      1.2
@@ -39,6 +39,7 @@
    /* Inherit from Etk_Object */
    Etk_Object object;
    
+   Evas_Object *smart_object;
    Evas_Object *textblock_object;
    Evas_Object *cursor_object;
    Evas_Object *clip;
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_widget.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- etk_widget.c        15 Feb 2006 15:03:17 -0000      1.35
+++ etk_widget.c        15 Feb 2006 21:01:33 -0000      1.36
@@ -1589,6 +1589,8 @@
    widget->need_theme_min_size_recalc = ETK_FALSE;
    widget->swallowed = ETK_FALSE;
    widget->accepts_dnd = ETK_FALSE;
+   widget->dnd_source = ETK_FALSE;
+   widget->dnd_dest = ETK_FALSE;
    widget->dnd_types = NULL;
    widget->dnd_types_num = 0;
    




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to