Enlightenment CVS committal

Author  : codewarrior
Project : e17
Module  : libs/esmart

Dir     : e17/libs/esmart/src/lib/esmart_textarea


Modified Files:
        Esmart_Textarea.h esmart_textarea_callbacks.c 
        esmart_textarea_private.c esmart_textarea_private.h 
        esmart_textarea_public.c 


Log Message:
paved way for mouse selection
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_textarea/Esmart_Textarea.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- Esmart_Textarea.h   1 Apr 2005 12:26:43 -0000       1.4
+++ Esmart_Textarea.h   2 Apr 2005 00:01:10 -0000       1.5
@@ -24,6 +24,14 @@
      ESMART_TEXTAREA_MOUSE_MODIFIER_RIGHT = 0x4,
 };
 
+struct _Esmart_Text_Area_Coord {            /* a coord, x, y and char pos */
+   Evas_Coord x;                         
+   Evas_Coord y;
+   int pos;
+};
+
+typedef struct _Esmart_Text_Area_Coord Esmart_Text_Area_Coord;
+
 struct _Esmart_Text_Area {                  /* our typical text area */   
    Evas_Object  *text;
    Evas_Object  *bg;
@@ -31,6 +39,8 @@
    unsigned int  key_modifiers;
    unsigned int  in_selection;
    unsigned int  mouse_modifiers;
+   Esmart_Text_Area_Coord sel_start;
+   Esmart_Text_Area_Coord sel_end;   
 };
 
 typedef struct _Esmart_Text_Area Esmart_Text_Area;
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_textarea/esmart_textarea_callbacks.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- esmart_textarea_callbacks.c 29 Mar 2005 20:39:41 -0000      1.1
+++ esmart_textarea_callbacks.c 2 Apr 2005 00:01:11 -0000       1.2
@@ -51,6 +51,36 @@
    _esmart_textarea_cursor_goto_cursor(t);
 }
 
+/* callback for when the mouse moves, for selection */
+void
+_esmart_textarea_cb_mouse_move(void *data, Evas *e, Evas_Object *obj,
+                               void *event_info) {
+   Evas_Event_Mouse_Move *ev = event_info;
+   Esmart_Text_Area *t = data;
+      
+   if((t->mouse_modifiers & ESMART_TEXTAREA_MOUSE_MODIFIER_LEFT))
+     {
+       int pos, cx, cy;
+       evas_object_geometry_get(t->text, &cx, &cy, NULL, NULL);
+       cx = ev->cur.canvas.x - cx;
+       cy = ev->cur.canvas.y - cy;
+       pos = evas_object_textblock_char_coords_get(t->text,cx,cy,NULL,NULL,
+                                                   NULL,NULL);
+       if(pos > t->sel_start.pos) // moved right or down
+         {
+            printf("moving right / down\n");
+         }
+       else if(pos < t->sel_start.pos) // moved left or up
+         {
+            printf("moving left / up\n");
+         }
+       else // stayed on same char
+         {
+            printf("still in place!\n");
+         }
+     }   
+}
+
 /* callback for when a mouse button is pressed, cursor movement + selection */
 void
 _esmart_textarea_cb_mouse_down(void *data, Evas *e, Evas_Object *obj,
@@ -60,24 +90,33 @@
    int cx, cy, index;
    
    /* set mouse down modifier, needed for selection / dragging */
-   switch(ev->button) {
-    case 1:
-      t->mouse_modifiers &= ESMART_TEXTAREA_MOUSE_MODIFIER_LEFT;
-      break;
-    case 2:
-      t->mouse_modifiers &= ESMART_TEXTAREA_MOUSE_MODIFIER_RIGHT;
-      break;
-    case 3:
-      t->mouse_modifiers &= ESMART_TEXTAREA_MOUSE_MODIFIER_MIDDLE;
-      break;
-   }
-   evas_object_geometry_get(t->text, &cx, &cy, NULL, NULL);
-   cx = ev->canvas.x - cx;
-   cy = ev->canvas.y - cy;
-   index = evas_object_textblock_char_coords_get(t->text,
-                                                cx,cy,NULL,NULL,NULL,NULL);
-   evas_object_textblock_cursor_pos_set(t->text, index);
-   _esmart_textarea_cursor_goto_cursor(t);   
+   switch(ev->button)
+     {
+      case 1:
+       t->mouse_modifiers |= ESMART_TEXTAREA_MOUSE_MODIFIER_LEFT;
+               
+       evas_object_geometry_get(t->text, &cx, &cy, NULL, NULL);
+       cx = ev->canvas.x - cx;
+       cy = ev->canvas.y - cy;
+       index = evas_object_textblock_char_coords_get(t->text,
+                                                     cx,cy,NULL,NULL,
+                                                     NULL,NULL);
+       evas_object_textblock_cursor_pos_set(t->text, index);
+       _esmart_textarea_cursor_goto_cursor(t);
+       
+       /* save current coord for selection */
+       t->sel_start.x = ev->canvas.x;
+       t->sel_start.y = ev->canvas.y;
+       t->sel_start.pos = index;
+       break;
+      case 2:
+       t->mouse_modifiers |= ESMART_TEXTAREA_MOUSE_MODIFIER_MIDDLE;    
+       break;
+       
+      case 3:
+       t->mouse_modifiers |= ESMART_TEXTAREA_MOUSE_MODIFIER_RIGHT;     
+       break;
+     }
 }
 
 void
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_textarea/esmart_textarea_private.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- esmart_textarea_private.c   1 Apr 2005 12:26:43 -0000       1.5
+++ esmart_textarea_private.c   2 Apr 2005 00:01:11 -0000       1.6
@@ -40,8 +40,10 @@
                                  _esmart_textarea_cb_key_up, t);   
    evas_object_event_callback_add(t->text, EVAS_CALLBACK_MOUSE_DOWN, 
                                  _esmart_textarea_cb_mouse_down, t);
-   evas_object_event_callback_add(t->text, EVAS_CALLBACK_MOUSE_DOWN, 
-                                 _esmart_textarea_cb_mouse_up, t);   
+   evas_object_event_callback_add(t->text, EVAS_CALLBACK_MOUSE_UP,
+                                 _esmart_textarea_cb_mouse_up, t);
+   evas_object_event_callback_add(t->text, EVAS_CALLBACK_MOUSE_MOVE,
+                                 _esmart_textarea_cb_mouse_move, t);
 
    t->bg = evas_object_rectangle_add(evas);
    evas_object_color_set(t->bg, 255, 255, 255, 255);
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_textarea/esmart_textarea_private.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- esmart_textarea_private.h   1 Apr 2005 12:26:43 -0000       1.4
+++ esmart_textarea_private.h   2 Apr 2005 00:01:11 -0000       1.5
@@ -55,6 +55,7 @@
 void              _esmart_textarea_cb_key_down(void *data, Evas *e, 
Evas_Object *obj, void *event_info);
 void              _esmart_textarea_cb_mouse_down(void *data, Evas *e, 
Evas_Object *obj, void *event_info);
 void              _esmart_textarea_cb_mouse_up(void *data, Evas *e, 
Evas_Object *obj, void *event_info);
+void              _esmart_textarea_cb_mouse_move(void *data, Evas *e, 
Evas_Object *obj, void *event_info);
 
 /* textarea smart functions */
 Evas_Smart       *esmart_textarea_smart_get();
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_textarea/esmart_textarea_public.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- esmart_textarea_public.c    1 Apr 2005 12:26:43 -0000       1.4
+++ esmart_textarea_public.c    2 Apr 2005 00:01:11 -0000       1.5
@@ -129,7 +129,10 @@
 Evas_Object *
 esmart_textarea_bg_get(Evas_Object *o)
 {
-      return _esmart_textarea_bg_get(o);
+   Esmart_Text_Area *t;
+   
+   t = evas_object_smart_data_get(o);   
+   return _esmart_textarea_bg_get(t);
 }
 
 




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to