[Tomoe-cvs 1078] CVS update: libtomoe-gtk/src

Back to archive index

Hiroyuki Ikezoe ikezo****@users*****
2006年 11月 27日 (月) 13:00:29 JST


Index: libtomoe-gtk/src/tomoe-canvas.c
diff -u libtomoe-gtk/src/tomoe-canvas.c:1.36 libtomoe-gtk/src/tomoe-canvas.c:1.37
--- libtomoe-gtk/src/tomoe-canvas.c:1.36	Mon Nov 27 12:06:21 2006
+++ libtomoe-gtk/src/tomoe-canvas.c	Mon Nov 27 13:00:28 2006
@@ -28,8 +28,8 @@
 #include "tomoe-canvas.h"
 
 #define TOMOE_CANVAS_DEFAULT_SIZE 300
-#define TOMOE_WRITING_DEFAULT_SIZE 300
 #define TOMOE_CANVAS_DEFAULT_RATE 0.7
+#define TOMOE_WRITING_SIZE 100
 
 enum {
     FIND_SIGNAL,
@@ -190,8 +190,8 @@
     TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas);
     
     priv->size              = TOMOE_CANVAS_DEFAULT_SIZE;
-    priv->width             = 300;
-    priv->height            = 300;
+    priv->width             = TOMOE_CANVAS_DEFAULT_SIZE;
+    priv->height            = TOMOE_CANVAS_DEFAULT_SIZE;
 
     priv->handwrite_line_gc = NULL;
     priv->adjust_line_gc    = NULL;
@@ -439,15 +439,37 @@
     return retval;
 }
 
+static TomoeWriting *
+_tomoe_writing_new_scale_writing (TomoeWriting *writing, gdouble sx, gdouble sy)
+{
+    const GList *strokes, *list;
+    TomoeWriting *new = tomoe_writing_new ();
+
+    strokes = tomoe_writing_get_strokes (writing);
+    for (list= strokes; list; list = g_list_next (list)) {
+        GList *points = (GList *) list->data;
+        GList *point;
+        gboolean first = TRUE;
+        for ( point = points; point; point = g_list_next (point)) {
+            TomoePoint *cp = (TomoePoint *) point->data;
+            if (!first)
+                tomoe_writing_line_to (new, cp->x * sx, cp->y * sy);
+            else
+                tomoe_writing_move_to (new, cp->x * sx, cp->y * sy);
+            first = FALSE;
+        }
+    }
+    return new;
+}
 
 static void
 tomoe_canvas_real_find (TomoeCanvas *canvas)
 {
-    TomoeCanvasPriv *priv;
     GtkWidget *widget = GTK_WIDGET (canvas);
-    const GList *strokes, *list;
+    TomoeCanvasPriv *priv;
     TomoeWriting *writing;
     TomoeQuery *query;
+    const GList *strokes, *list;
     guint i;
 
     g_return_if_fail (TOMOE_IS_CANVAS (canvas));
@@ -458,43 +480,35 @@
 
     _init_gc (canvas);
 
-    writing = priv->writing;
-
     /* draw thin red lines and annotations for sparse points */
-    strokes = tomoe_writing_get_strokes (writing);
+    strokes = tomoe_writing_get_strokes (priv->writing);
     for (list = strokes, i = 1; list; list = g_list_next (list), i++) {
         GList *points = (GList *) list->data;
-        GList *point;
-        TomoePoint *pp = NULL;
-    
-        for (point = points; point; point = g_list_next (point)) {
-            TomoePoint *p = (TomoePoint *) point->data;
-            if (pp) {
-                tomoe_canvas_draw_line (canvas, pp, p,
-                                        priv->adjust_line_gc,
-                                        TRUE);
-            } else {
-                draw_annotate (points, canvas, i);
-            }
-            pp = p;
-        }
+ 
+        draw_annotate (points, canvas, i);
     }
 
     if (priv->candidates) {
         _g_list_free_all (priv->candidates, g_object_unref);
         priv->candidates     = NULL;
     }
+
+    writing = _tomoe_writing_new_scale_writing (priv->writing,
+                                                (gdouble) TOMOE_WRITING_SIZE / priv->width,
+                                                (gdouble) TOMOE_WRITING_SIZE / priv->height);
+
     query = tomoe_query_new ();
     tomoe_query_set_writing (query, writing);
     priv->candidates = tomoe_context_search (priv->context, query);
     g_object_unref (query);
-
+    g_object_unref (writing);
     gdk_draw_drawable(widget->window,
                       widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                       priv->pixmap,
                       0, 0,
                       0, 0,
                       widget->allocation.width, widget->allocation.height);
+
 }
 
 static void
@@ -589,29 +603,6 @@
     }
 }
 
-static TomoeWriting *
-_tomoe_writing_new_scale_writing (TomoeWriting *writing, gdouble sx, gdouble sy)
-{
-    const GList *strokes, *list;
-    TomoeWriting *new = tomoe_writing_new ();
-
-    strokes = tomoe_writing_get_strokes (writing);
-    for (list= strokes; list; list = g_list_next (list)) {
-        GList *points = (GList *) list->data;
-        GList *point;
-        gboolean first = TRUE;
-        for ( point = points; point; point = g_list_next (point)) {
-            TomoePoint *cp = (TomoePoint *) point->data;
-            if (!first)
-                tomoe_writing_line_to (new, cp->x * sx, cp->y * sy);
-            else
-                tomoe_writing_move_to (new, cp->x * sx, cp->y * sy);
-            first = FALSE;
-        }
-    }
-    return new;
-}
-
 static void
 tomoe_canvas_resize_writing (TomoeCanvas *canvas, gdouble x_rate, gdouble y_rate)
 {
@@ -960,17 +951,16 @@
     TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas);
     GtkWidget *widget = GTK_WIDGET (canvas);
     gint x, y, width, height;
-    gdouble factor = 1.0 / ((gdouble)TOMOE_WRITING_DEFAULT_SIZE / (gdouble)priv->size);
 
     gdk_draw_line (priv->pixmap,
                    line_gc,
-                   p1->x * factor, p1->y * factor,
-                   p2->x * factor, p2->y * factor);
+                   p1->x, p1->y,
+                   p2->x, p2->y);
     if (draw) {
-        x = (MIN (p1->x, p2->x) - 2) * factor;
-        y = (MIN (p1->y, p2->y) - 2) * factor;
-        width  = (abs (p1->x - p2->x) + (2 * 2)) * factor;
-        height = (abs (p1->y - p2->y) + (2 * 2)) * factor;
+        x = (MIN (p1->x, p2->x) - 2);
+        y = (MIN (p1->y, p2->y) - 2);
+        width  = abs (p1->x - p2->x) + (2 * 2);
+        height = abs (p1->y - p2->y) + (2 * 2);
 
         gtk_widget_queue_draw_area (widget, x, y, width, height);
     }
@@ -1102,16 +1092,15 @@
     gdouble dl;
     gint sign;
 
-    gdouble factor = 1.0 / ((gdouble)TOMOE_WRITING_DEFAULT_SIZE / (gdouble)priv->size);
-    x = ((TomoePoint*)(points->data))->x * factor;
-    y = ((TomoePoint*)(points->data))->y * factor;
+    x = ((TomoePoint*)(points->data))->x;
+    y = ((TomoePoint*)(points->data))->y;
 
     if (g_list_length (points) == 1) {
         dx = x;
         dy = y;
     } else {
-        dx = ((TomoePoint*)((g_list_last (points))->data))->x * factor - x;
-        dy = ((TomoePoint*)((g_list_last (points))->data))->y * factor - y;
+        dx = ((TomoePoint*)((g_list_last (points))->data))->x - x;
+        dy = ((TomoePoint*)((g_list_last (points))->data))->y - y;
     }
 
     dl = sqrt (dx*dx + dy*dy);


tomoe-cvs メーリングリストの案内
Back to archive index