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 


Log Message:
* More textblock work. Start the movement of the cursor


===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_text_view.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- etk_text_view.c     15 Feb 2006 21:01:33 -0000      1.3
+++ etk_text_view.c     16 Feb 2006 15:35:58 -0000      1.4
@@ -23,6 +23,7 @@
 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);
+static void _etk_text_view_key_down_cb(Etk_Object *object, 
Etk_Event_Key_Up_Down *event, void *data);
 
 static Etk_Signal *_etk_text_view_signals[ETK_TEXT_VIEW_NUM_SIGNALS];
 
@@ -77,6 +78,7 @@
 
    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);
 }
 
 /* Destroys the text view */
@@ -135,4 +137,18 @@
    }
 }
 
+/* Called when a key is pressed */
+static void _etk_text_view_key_down_cb(Etk_Object *object, 
Etk_Event_Key_Up_Down *event, void *data)
+{
+   Etk_Text_View *text_view;
+
+   if (!(text_view = ETK_TEXT_VIEW(object)) || !event)
+      return;
+   
+   if (strcmp(event->key, "Left") == 0)
+      etk_textblock_iter_go_to_prev_char(text_view->textblock->cursor);
+   else if (strcmp(event->key, "Right") == 0)
+      etk_textblock_iter_go_to_next_char(text_view->textblock->cursor);
+}
+
 /** @} */
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_textblock.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- etk_textblock.c     16 Feb 2006 11:58:40 -0000      1.3
+++ etk_textblock.c     16 Feb 2006 15:35:58 -0000      1.4
@@ -10,6 +10,7 @@
 
 static void _etk_textblock_constructor(Etk_Textblock *textblock);
 static void _etk_textblock_destructor(Etk_Textblock *textblock);
+static void _etk_textblock_cursor_object_update(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);
@@ -91,6 +92,12 @@
    evas_object_smart_member_add(textblock->clip, textblock->smart_object);
    evas_object_lower(textblock->clip);*/
    /* TODO: realize: creates selection rects, clip, cursor, timer  */
+   
+   textblock->cursor_object = evas_object_rectangle_add(evas);
+   /* TODO: theme */
+   evas_object_color_set(textblock->cursor_object, 255, 128, 0, 80);
+   evas_object_smart_member_add(textblock->cursor_object, 
textblock->smart_object);
+   _etk_textblock_cursor_object_update(textblock);
 }
 
 /* TODO: doc */
@@ -169,6 +176,52 @@
    evas_textblock_cursor_copy(iter->cursor, dest_iter->cursor);
 }
 
+/* TODO: doc */
+void etk_textblock_iter_go_to_start(Etk_Textblock_Iter *iter)
+{
+   if (!iter || !iter->textblock || !iter->cursor)
+      return;
+   
+   evas_textblock_cursor_node_first(iter->cursor);
+   while (!evas_textblock_cursor_node_text_get(iter->cursor) && 
evas_textblock_cursor_node_next(iter->cursor));
+   evas_textblock_cursor_char_first(iter->cursor);
+   
+   _etk_textblock_cursor_object_update(iter->textblock);
+}
+
+/* TODO: doc */
+void etk_textblock_iter_go_to_end(Etk_Textblock_Iter *iter)
+{
+   if (!iter || !iter->textblock || !iter->cursor)
+      return;
+   
+   evas_textblock_cursor_node_last(iter->cursor);
+   while (!evas_textblock_cursor_node_text_get(iter->cursor) && 
evas_textblock_cursor_node_prev(iter->cursor));
+   evas_textblock_cursor_char_last(iter->cursor);
+   
+   _etk_textblock_cursor_object_update(iter->textblock);
+}
+
+/* TODO: doc */
+void etk_textblock_iter_go_to_prev_char(Etk_Textblock_Iter *iter)
+{
+   if (!iter || !iter->textblock || !iter->cursor)
+      return;
+   
+   evas_textblock_cursor_char_prev(iter->cursor);
+   _etk_textblock_cursor_object_update(iter->textblock);
+}
+
+/* TODO: doc */
+void etk_textblock_iter_go_to_next_char(Etk_Textblock_Iter *iter)
+{
+   if (!iter || !iter->textblock || !iter->cursor)
+      return;
+   
+   evas_textblock_cursor_char_next(iter->cursor);
+   _etk_textblock_cursor_object_update(iter->textblock);
+}
+
 /**************************
  *
  * Etk specific functions
@@ -245,7 +298,7 @@
    
    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 */
+   /* TODO: does it need to be shown */
    evas_object_show(textblock->textblock_object);
    
    textblock->cursor = etk_textblock_iter_new(textblock);
@@ -281,6 +334,8 @@
       "plutôt naïve Louÿs rêva crapaüter Íosa Úrmhac Óighe pór Éava 
Ádhaim"
       "</blockquote>"
       );
+      
+   etk_textblock_iter_go_to_start(textblock->cursor);
 }
 
 /* Destroys the textblock */
@@ -329,6 +384,23 @@
  *
  **************************/
 
+/* Updates the position and the size of the cursor object */
+static void _etk_textblock_cursor_object_update(Etk_Textblock *textblock)
+{
+   Evas_Coord tbx, tby;
+   Evas_Coord cx, cy, cw, ch;
+   
+   if (!textblock || !textblock->cursor || !textblock->cursor->cursor)
+      return;
+   if (!textblock->textblock_object || !textblock->cursor_object)
+      return;
+   
+   evas_object_geometry_get(textblock->textblock_object, &tbx, &tby, NULL, 
NULL);
+   evas_textblock_cursor_char_geometry_get(textblock->cursor->cursor, &cx, 
&cy, &cw, &ch);
+   evas_object_move(textblock->cursor_object, tbx + cx, tby + cy);
+   evas_object_resize(textblock->cursor_object, cw, ch);
+}
+
 /* Changes the evas used by the textblock object */
 static void _etk_textblock_object_evas_set(Etk_Textblock *textblock, Evas 
*new_evas)
 {
@@ -370,6 +442,9 @@
       for (l = textblock->iterators; l; l = l->next)
       {
          iter = l->data;
+         if (iter->evas_changed)
+            continue;
+         
          evas_textblock_cursor_char_first(old_cursor);
          if (evas_textblock_cursor_compare(old_cursor, iter->cursor) <= 0)
          {
@@ -380,7 +455,6 @@
                iter->cursor = evas_object_textblock_cursor_new(new_tbo);
                evas_textblock_cursor_copy(new_cursor, iter->cursor);
                evas_textblock_cursor_pos_set(iter->cursor, 
evas_textblock_cursor_pos_get(cursor));
-               
                evas_textblock_cursor_free(cursor);
                iter->evas_changed = ETK_TRUE;
             }
@@ -425,6 +499,12 @@
    textblock->textblock_object = new_tbo;
 }
 
+/**************************
+ *
+ * Smart object functions
+ *
+ **************************/
+
 /* 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)
 {
@@ -448,11 +528,12 @@
    if (!obj || !(textblock = evas_object_smart_data_get(obj)))
       return;
    
-   /* TODO: smart_resize: update selection_rects, cursor_object  */
+   /* TODO: smart_resize: update selection_rects  */
    if (textblock->textblock_object)
       evas_object_resize(textblock->textblock_object, w, h);
    if (textblock->clip)
       evas_object_resize(textblock->clip, w, h);
+   _etk_textblock_cursor_object_update(textblock);
 }
 
 /* Called when the smart object of the textblock is shown */
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_textblock.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- etk_textblock.h     16 Feb 2006 11:58:40 -0000      1.3
+++ etk_textblock.h     16 Feb 2006 15:35:58 -0000      1.4
@@ -63,6 +63,12 @@
 void etk_textblock_iter_free(Etk_Textblock_Iter *iter);
 void etk_textblock_iter_copy(Etk_Textblock_Iter *iter, Etk_Textblock_Iter 
*dest_iter);
 
+void etk_textblock_iter_go_to_start(Etk_Textblock_Iter *iter);
+void etk_textblock_iter_go_to_end(Etk_Textblock_Iter *iter);
+
+void etk_textblock_iter_go_to_prev_char(Etk_Textblock_Iter *iter);
+void etk_textblock_iter_go_to_next_char(Etk_Textblock_Iter *iter);
+
 /** @} */
 
 #endif




-------------------------------------------------------
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