[Tomoe-cvs 842] CVS update: tomoe/lib

Back to archive index

Takuro Ashie makei****@users*****
2006年 11月 22日 (水) 14:59:05 JST


Index: tomoe/lib/Makefile.am
diff -u tomoe/lib/Makefile.am:1.33 tomoe/lib/Makefile.am:1.34
--- tomoe/lib/Makefile.am:1.33	Wed Nov 22 11:34:58 2006
+++ tomoe/lib/Makefile.am	Wed Nov 22 14:59:05 2006
@@ -37,9 +37,9 @@
 	tomoe-context.h \
 	tomoe-config.h \
 	tomoe-dict.h \
-	tomoe-handwrite.h \
 	tomoe-recognizer.h \
-	tomoe-shelf.h
+	tomoe-shelf.h \
+	tomoe-writing.h
 
 lib_LTLIBRARIES = libtomoe.la
 libtomoe_la_SOURCES = \
@@ -50,10 +50,10 @@
 	tomoe-context.c \
 	tomoe-config.c \
 	tomoe-dict.c \
-	tomoe-handwrite.c \
 	tomoe-recognizer.c \
 	tomoe-recognizer-impl.h \
-	tomoe-shelf.c
+	tomoe-shelf.c \
+	tomoe-writing.c
 
 libtomoe_la_LDFLAGS =						\
   -version-info $(LT_VERSION_INFO)				\
Index: tomoe/lib/tomoe-char.h
diff -u tomoe/lib/tomoe-char.h:1.38 tomoe/lib/tomoe-char.h:1.39
--- tomoe/lib/tomoe-char.h:1.38	Wed Nov 22 13:25:38 2006
+++ tomoe/lib/tomoe-char.h	Wed Nov 22 14:59:05 2006
@@ -18,7 +18,7 @@
  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  *  Boston, MA  02111-1307  USA
  *
- *  $Id: tomoe-char.h,v 1.38 2006/11/22 04:25:38 kous Exp $
+ *  $Id: tomoe-char.h,v 1.39 2006/11/22 05:59:05 makeinu Exp $
  */
 
 /** @file tomoe-char.h
@@ -33,7 +33,7 @@
 G_BEGIN_DECLS
 
 #include <glib/garray.h>
-#include <tomoe-handwrite.h>
+#include <tomoe-writing.h>
 
 #define TOMOE_TYPE_CHAR            (tomoe_char_get_type ())
 #define TOMOE_CHAR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_CHAR, TomoeChar))
Index: tomoe/lib/tomoe-handwrite.c
diff -u tomoe/lib/tomoe-handwrite.c:1.25 tomoe/lib/tomoe-handwrite.c:removed
--- tomoe/lib/tomoe-handwrite.c:1.25	Wed Nov 22 11:59:29 2006
+++ tomoe/lib/tomoe-handwrite.c	Wed Nov 22 14:59:05 2006
@@ -1,284 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- *  Copyright (C) 2005 Takuro Ashie <ashie****@homa*****>
- *  Copyright (C) 2006 Juernjakob Harder <juern****@gmail*****>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the
- *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- *  Boston, MA  02111-1307  USA
- *
- *  $Id: tomoe-handwrite.c,v 1.25 2006/11/22 02:59:29 kous Exp $
- */
-
-#include <stdlib.h>
-#include "tomoe-handwrite.h"
-
-#define TOMOE_GLYPH_GET_PRIVATE(obj) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_GLYPH, TomoeGlyphPrivate))
-
-typedef struct _TomoeGlyphPrivate TomoeGlyphPrivate;
-typedef struct _TomoeStroke       TomoeStroke;
-
-struct _TomoeGlyphPrivate
-{
-    GList *stroke_first;
-    GList *stroke_last;
-};
-
-struct _TomoeStroke
-{
-    GList *point_first;
-    GList *point_last;
-};
-
-G_DEFINE_TYPE (TomoeGlyph, tomoe_glyph, G_TYPE_OBJECT)
-
-static void tomoe_glyph_dispose (GObject *object);
-static TomoePoint  *_point_new  (gint x, gint y);
-static TomoeStroke *_stroke_new (gint x, gint y);
-
-static void
-tomoe_glyph_class_init (TomoeGlyphClass *klass)
-{
-    GObjectClass *gobject_class;
-
-    gobject_class = G_OBJECT_CLASS (klass);
-
-    gobject_class->dispose = tomoe_glyph_dispose;
-
-    g_type_class_add_private (gobject_class, sizeof (TomoeGlyphPrivate));
-}
-
-static void
-tomoe_glyph_init (TomoeGlyph *glyph)
-{
-    TomoeGlyphPrivate *priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    priv->stroke_first = NULL;
-    priv->stroke_last  = NULL;
-}
-
-static void
-tomoe_glyph_dispose (GObject *object)
-{
-    TomoeGlyph *glyph = TOMOE_GLYPH (object);
-
-    tomoe_glyph_clear (glyph);
-
-    G_OBJECT_CLASS (tomoe_glyph_parent_class)->dispose (object);
-}
-
-TomoeGlyph *
-tomoe_glyph_new (void)
-{
-    TomoeGlyph *glyph = g_object_new(TOMOE_TYPE_GLYPH, NULL);
-    return glyph;
-}
-
-void
-tomoe_glyph_move_to (TomoeGlyph *glyph, gint x, gint y)
-{
-    TomoeGlyphPrivate *priv;
-
-    g_return_if_fail (TOMOE_IS_GLYPH (glyph));
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-
-    priv->stroke_last = g_list_append (priv->stroke_last, _stroke_new (x, y));
-    if (!priv->stroke_first)
-        priv->stroke_first = priv->stroke_last;
-    priv->stroke_last = g_list_last (priv->stroke_last);
-}
-
-void
-tomoe_glyph_line_to (TomoeGlyph *glyph, gint x, gint y)
-{
-    TomoeGlyphPrivate *priv;
-    TomoeStroke *s;
-
-    g_return_if_fail (TOMOE_IS_GLYPH (glyph));
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    g_return_if_fail (priv->stroke_last);
-
-    s = priv->stroke_last->data;
-    g_return_if_fail (s);
-
-    s->point_last = g_list_append (s->point_last, _point_new (x, y));
-    s->point_last = g_list_last (s->point_last);
-}
-
-void
-tomoe_glyph_clear (TomoeGlyph *glyph)
-{
-    TomoeGlyphPrivate *priv;
-    GList *node;
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    g_return_if_fail (priv);
-
-    for (node = priv->stroke_first; node; node = g_list_next (node)) {
-        TomoeStroke *s;
-
-        if (!node->data) continue;
-
-        s = node->data;
-        g_list_foreach (s->point_first, (GFunc) g_free, NULL);
-        g_list_free (s->point_first);
-        g_free (s);
-    }
-    g_list_free (priv->stroke_first);
-
-    priv->stroke_first = NULL;
-    priv->stroke_last  = NULL;
-}
-
-guint
-tomoe_glyph_get_number_of_strokes (TomoeGlyph *glyph)
-{
-    TomoeGlyphPrivate *priv;
-
-    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), 0);
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    g_return_val_if_fail (priv, 0);
-
-    return g_list_length (priv->stroke_first);
-}
-
-guint
-tomoe_glyph_get_number_of_points (TomoeGlyph *glyph, guint stroke)
-{
-    TomoeGlyphPrivate *priv;
-    TomoeStroke *s;
-
-    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), 0);
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    g_return_val_if_fail (priv && priv->stroke_first, 0);
-
-    s = g_list_nth_data (priv->stroke_first, stroke);
-    g_return_val_if_fail (s, 0);
-
-    return g_list_length (s->point_first);
-}
-
-gboolean
-tomoe_glyph_get_point (TomoeGlyph *glyph, guint stroke, guint point,
-                       gint *x, gint *y)
-{
-    TomoeGlyphPrivate *priv;
-    TomoeStroke *s;
-    TomoePoint *p;
-
-    if (x) *x = 0;
-    if (y) *y = 0;
-
-    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), FALSE);
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    g_return_val_if_fail (priv && priv->stroke_first, FALSE);
-
-    s = g_list_nth_data (priv->stroke_first, stroke);
-    g_return_val_if_fail (s, FALSE);
-    g_return_val_if_fail (s->point_first, FALSE);
-
-    p = g_list_nth_data (s->point_first, point);
-    g_return_val_if_fail (p, FALSE);
-
-    if (x) *x = p->x;
-    if (y) *y = p->y;
-
-    return TRUE;
-}
-
-gboolean
-tomoe_glyph_get_last_point (TomoeGlyph *glyph, gint *x, gint *y)
-{
-    TomoeGlyphPrivate *priv;
-    TomoeStroke *s;
-    TomoePoint *p;
-
-    if (x) *x = 0;
-    if (y) *y = 0;
-
-    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), FALSE);
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    g_return_val_if_fail (priv && priv->stroke_last, FALSE);
-
-    s = priv->stroke_last->data;
-    g_return_val_if_fail (s && s->point_last && s->point_last->data, FALSE);
-
-    p = s->point_last->data;
-
-    if (x) *x = p->x;
-    if (y) *y = p->y;
-
-    return TRUE;
-}
-
-void
-tomoe_glyph_remove_last_stroke (TomoeGlyph *glyph)
-{
-    TomoeGlyphPrivate *priv;
-    TomoeStroke *s;
-
-    g_return_if_fail (TOMOE_IS_GLYPH (glyph));
-
-    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
-    g_return_if_fail (priv);
-    if (!priv->stroke_last) return;
-
-    s = priv->stroke_last->data;
-    g_return_if_fail (s);
-
-    g_list_foreach (s->point_first, (GFunc) g_free, NULL);
-    g_list_free (s->point_first);
-
-    priv->stroke_last = g_list_remove (priv->stroke_last, s);
-    priv->stroke_last = g_list_last (priv->stroke_last);
-    if (!priv->stroke_last)
-        priv->stroke_first = NULL;
-    g_free (s);
-}
-
-static TomoePoint *
-_point_new (gint x, gint y)
-{
-    TomoePoint *p = g_new (TomoePoint, 1);
-
-    g_return_val_if_fail (p, NULL);
-
-    p->x = x;
-    p->y = y;
-
-    return p;
-}
-
-static TomoeStroke *
-_stroke_new (gint x, gint y)
-{
-    TomoeStroke *s = g_new (TomoeStroke, 1);
-
-    g_return_val_if_fail (s, NULL);
-
-    s->point_first = g_list_append (NULL, _point_new (x, y));
-    s->point_last  = s->point_first;
-
-    return s;
-}
-
-/*
-vi:ts=4:nowrap:ai:expandtab
-*/
Index: tomoe/lib/tomoe-handwrite.h
diff -u tomoe/lib/tomoe-handwrite.h:1.17 tomoe/lib/tomoe-handwrite.h:removed
--- tomoe/lib/tomoe-handwrite.h:1.17	Wed Nov 22 11:59:29 2006
+++ tomoe/lib/tomoe-handwrite.h	Wed Nov 22 14:59:05 2006
@@ -1,94 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- *  Copyright (C) 2005 Takuro Ashie <ashie****@homa*****>
- *  Copyright (C) 2006 Juernjakob Harder <juern****@gmail*****>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this program; if not, write to the
- *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- *  Boston, MA  02111-1307  USA
- *
- *  $Id: tomoe-handwrite.h,v 1.17 2006/11/22 02:59:29 kous Exp $
- */
-
-/** @file tomoe-handwrite.h
- *  @brief 
- */
-
-#ifndef __TOMOE_HANDWRITE_H__
-#define __TOMOE_HANDWRITE_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define TOMOE_TYPE_GLYPH            (tomoe_glyph_get_type ())
-#define TOMOE_GLYPH(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_GLYPH, TomoeGlyph))
-#define TOMOE_GLYPH_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_GLYPH, TomoeGlyphClass))
-#define TOMOE_IS_GLYPH(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_GLYPH))
-#define TOMOE_IS_GLYPH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_GLYPH))
-#define TOMOE_GLYPH_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_GLYPH, TomoeGlyphClass))
-
-typedef struct _TomoeGlyph      TomoeGlyph;
-typedef struct _TomoeGlyphClass TomoeGlyphClass;
-
-typedef struct _TomoePoint        TomoePoint;
-
-struct _TomoeGlyph
-{
-    GObject object;
-};
-
-struct _TomoeGlyphClass
-{
-    GObjectClass parent_class;
-};
-
-struct _TomoePoint
-{
-    gint x;
-    gint y;
-};
-
-GType           tomoe_glyph_get_type            (void) G_GNUC_CONST;
-TomoeGlyph     *tomoe_glyph_new                 (void);
-void            tomoe_glyph_move_to             (TomoeGlyph    *glyph,
-                                                 gint           x,
-                                                 gint           y);
-void            tomoe_glyph_line_to             (TomoeGlyph    *glyph,
-                                                 gint           x,
-                                                 gint           y);
-void            tomoe_glyph_clear               (TomoeGlyph    *glyph);
-guint           tomoe_glyph_get_number_of_strokes
-                                                (TomoeGlyph    *glyph);
-guint           tomoe_glyph_get_number_of_points(TomoeGlyph    *glyph,
-                                                 guint          stroke);
-gboolean        tomoe_glyph_get_point           (TomoeGlyph    *glyph,
-                                                 guint          stroke,
-                                                 guint          point,
-                                                 gint          *x,
-                                                 gint          *y);
-gboolean        tomoe_glyph_get_last_point      (TomoeGlyph    *glyph,
-                                                 gint          *x,
-                                                 gint          *y);
-void            tomoe_glyph_remove_last_stroke  (TomoeGlyph    *glyph);
-
-const GList    *tomoe_glyph_get_strokes         (TomoeGlyph    *glyph);
-
-G_END_DECLS
-
-#endif /* __TOMOE_HANDWRITE_H__ */
-
-/*
-vi:ts=4:nowrap:ai:expandtab
-*/
Index: tomoe/lib/tomoe-recognizer-impl.h
diff -u tomoe/lib/tomoe-recognizer-impl.h:1.6 tomoe/lib/tomoe-recognizer-impl.h:1.7
--- tomoe/lib/tomoe-recognizer-impl.h:1.6	Tue Nov 21 13:50:35 2006
+++ tomoe/lib/tomoe-recognizer-impl.h	Wed Nov 22 14:59:05 2006
@@ -17,7 +17,7 @@
  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  *  Boston, MA  02111-1307  USA
  *
- *  $Id: tomoe-recognizer-impl.h,v 1.6 2006/11/21 04:50:35 kous Exp $
+ *  $Id: tomoe-recognizer-impl.h,v 1.7 2006/11/22 05:59:05 makeinu Exp $
  */
 
 /**
@@ -33,7 +33,7 @@
 G_BEGIN_DECLS
 
 #include <tomoe-dict.h>
-#include <tomoe-handwrite.h>
+#include <tomoe-writing.h>
 
 typedef void       *(*TomoeRecognizerNewFunc)    (void);
 typedef void        (*TomoeRecognizerFreeFunc)   (void *recognizer);
Index: tomoe/lib/tomoe-recognizer.h
diff -u tomoe/lib/tomoe-recognizer.h:1.9 tomoe/lib/tomoe-recognizer.h:1.10
--- tomoe/lib/tomoe-recognizer.h:1.9	Tue Nov 21 14:05:43 2006
+++ tomoe/lib/tomoe-recognizer.h	Wed Nov 22 14:59:05 2006
@@ -17,7 +17,7 @@
  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  *  Boston, MA  02111-1307  USA
  *
- *  $Id: tomoe-recognizer.h,v 1.9 2006/11/21 05:05:43 makeinu Exp $
+ *  $Id: tomoe-recognizer.h,v 1.10 2006/11/22 05:59:05 makeinu Exp $
  */
 
 /**
@@ -33,7 +33,7 @@
 G_BEGIN_DECLS
 
 #include <tomoe-dict.h>
-#include <tomoe-handwrite.h>
+#include <tomoe-writing.h>
 
 #define TOMOE_TYPE_RECOGNIZER            (tomoe_recognizer_get_type ())
 #define TOMOE_RECOGNIZER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_RECOGNIZER, TomoeRecognizer))
Index: tomoe/lib/tomoe-writing.c
diff -u /dev/null tomoe/lib/tomoe-writing.c:1.1
--- /dev/null	Wed Nov 22 14:59:05 2006
+++ tomoe/lib/tomoe-writing.c	Wed Nov 22 14:59:05 2006
@@ -0,0 +1,284 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2005 Takuro Ashie <ashie****@homa*****>
+ *  Copyright (C) 2006 Juernjakob Harder <juern****@gmail*****>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the
+ *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ *  Boston, MA  02111-1307  USA
+ *
+ *  $Id: tomoe-writing.c,v 1.1 2006/11/22 05:59:05 makeinu Exp $
+ */
+
+#include <stdlib.h>
+#include "tomoe-writing.h"
+
+#define TOMOE_GLYPH_GET_PRIVATE(obj) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_GLYPH, TomoeGlyphPrivate))
+
+typedef struct _TomoeGlyphPrivate TomoeGlyphPrivate;
+typedef struct _TomoeStroke       TomoeStroke;
+
+struct _TomoeGlyphPrivate
+{
+    GList *stroke_first;
+    GList *stroke_last;
+};
+
+struct _TomoeStroke
+{
+    GList *point_first;
+    GList *point_last;
+};
+
+G_DEFINE_TYPE (TomoeGlyph, tomoe_glyph, G_TYPE_OBJECT)
+
+static void tomoe_glyph_dispose (GObject *object);
+static TomoePoint  *_point_new  (gint x, gint y);
+static TomoeStroke *_stroke_new (gint x, gint y);
+
+static void
+tomoe_glyph_class_init (TomoeGlyphClass *klass)
+{
+    GObjectClass *gobject_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+
+    gobject_class->dispose = tomoe_glyph_dispose;
+
+    g_type_class_add_private (gobject_class, sizeof (TomoeGlyphPrivate));
+}
+
+static void
+tomoe_glyph_init (TomoeGlyph *glyph)
+{
+    TomoeGlyphPrivate *priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    priv->stroke_first = NULL;
+    priv->stroke_last  = NULL;
+}
+
+static void
+tomoe_glyph_dispose (GObject *object)
+{
+    TomoeGlyph *glyph = TOMOE_GLYPH (object);
+
+    tomoe_glyph_clear (glyph);
+
+    G_OBJECT_CLASS (tomoe_glyph_parent_class)->dispose (object);
+}
+
+TomoeGlyph *
+tomoe_glyph_new (void)
+{
+    TomoeGlyph *glyph = g_object_new(TOMOE_TYPE_GLYPH, NULL);
+    return glyph;
+}
+
+void
+tomoe_glyph_move_to (TomoeGlyph *glyph, gint x, gint y)
+{
+    TomoeGlyphPrivate *priv;
+
+    g_return_if_fail (TOMOE_IS_GLYPH (glyph));
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+
+    priv->stroke_last = g_list_append (priv->stroke_last, _stroke_new (x, y));
+    if (!priv->stroke_first)
+        priv->stroke_first = priv->stroke_last;
+    priv->stroke_last = g_list_last (priv->stroke_last);
+}
+
+void
+tomoe_glyph_line_to (TomoeGlyph *glyph, gint x, gint y)
+{
+    TomoeGlyphPrivate *priv;
+    TomoeStroke *s;
+
+    g_return_if_fail (TOMOE_IS_GLYPH (glyph));
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    g_return_if_fail (priv->stroke_last);
+
+    s = priv->stroke_last->data;
+    g_return_if_fail (s);
+
+    s->point_last = g_list_append (s->point_last, _point_new (x, y));
+    s->point_last = g_list_last (s->point_last);
+}
+
+void
+tomoe_glyph_clear (TomoeGlyph *glyph)
+{
+    TomoeGlyphPrivate *priv;
+    GList *node;
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    g_return_if_fail (priv);
+
+    for (node = priv->stroke_first; node; node = g_list_next (node)) {
+        TomoeStroke *s;
+
+        if (!node->data) continue;
+
+        s = node->data;
+        g_list_foreach (s->point_first, (GFunc) g_free, NULL);
+        g_list_free (s->point_first);
+        g_free (s);
+    }
+    g_list_free (priv->stroke_first);
+
+    priv->stroke_first = NULL;
+    priv->stroke_last  = NULL;
+}
+
+guint
+tomoe_glyph_get_number_of_strokes (TomoeGlyph *glyph)
+{
+    TomoeGlyphPrivate *priv;
+
+    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), 0);
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    g_return_val_if_fail (priv, 0);
+
+    return g_list_length (priv->stroke_first);
+}
+
+guint
+tomoe_glyph_get_number_of_points (TomoeGlyph *glyph, guint stroke)
+{
+    TomoeGlyphPrivate *priv;
+    TomoeStroke *s;
+
+    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), 0);
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    g_return_val_if_fail (priv && priv->stroke_first, 0);
+
+    s = g_list_nth_data (priv->stroke_first, stroke);
+    g_return_val_if_fail (s, 0);
+
+    return g_list_length (s->point_first);
+}
+
+gboolean
+tomoe_glyph_get_point (TomoeGlyph *glyph, guint stroke, guint point,
+                       gint *x, gint *y)
+{
+    TomoeGlyphPrivate *priv;
+    TomoeStroke *s;
+    TomoePoint *p;
+
+    if (x) *x = 0;
+    if (y) *y = 0;
+
+    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), FALSE);
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    g_return_val_if_fail (priv && priv->stroke_first, FALSE);
+
+    s = g_list_nth_data (priv->stroke_first, stroke);
+    g_return_val_if_fail (s, FALSE);
+    g_return_val_if_fail (s->point_first, FALSE);
+
+    p = g_list_nth_data (s->point_first, point);
+    g_return_val_if_fail (p, FALSE);
+
+    if (x) *x = p->x;
+    if (y) *y = p->y;
+
+    return TRUE;
+}
+
+gboolean
+tomoe_glyph_get_last_point (TomoeGlyph *glyph, gint *x, gint *y)
+{
+    TomoeGlyphPrivate *priv;
+    TomoeStroke *s;
+    TomoePoint *p;
+
+    if (x) *x = 0;
+    if (y) *y = 0;
+
+    g_return_val_if_fail (TOMOE_IS_GLYPH (glyph), FALSE);
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    g_return_val_if_fail (priv && priv->stroke_last, FALSE);
+
+    s = priv->stroke_last->data;
+    g_return_val_if_fail (s && s->point_last && s->point_last->data, FALSE);
+
+    p = s->point_last->data;
+
+    if (x) *x = p->x;
+    if (y) *y = p->y;
+
+    return TRUE;
+}
+
+void
+tomoe_glyph_remove_last_stroke (TomoeGlyph *glyph)
+{
+    TomoeGlyphPrivate *priv;
+    TomoeStroke *s;
+
+    g_return_if_fail (TOMOE_IS_GLYPH (glyph));
+
+    priv = TOMOE_GLYPH_GET_PRIVATE(glyph);
+    g_return_if_fail (priv);
+    if (!priv->stroke_last) return;
+
+    s = priv->stroke_last->data;
+    g_return_if_fail (s);
+
+    g_list_foreach (s->point_first, (GFunc) g_free, NULL);
+    g_list_free (s->point_first);
+
+    priv->stroke_last = g_list_remove (priv->stroke_last, s);
+    priv->stroke_last = g_list_last (priv->stroke_last);
+    if (!priv->stroke_last)
+        priv->stroke_first = NULL;
+    g_free (s);
+}
+
+static TomoePoint *
+_point_new (gint x, gint y)
+{
+    TomoePoint *p = g_new (TomoePoint, 1);
+
+    g_return_val_if_fail (p, NULL);
+
+    p->x = x;
+    p->y = y;
+
+    return p;
+}
+
+static TomoeStroke *
+_stroke_new (gint x, gint y)
+{
+    TomoeStroke *s = g_new (TomoeStroke, 1);
+
+    g_return_val_if_fail (s, NULL);
+
+    s->point_first = g_list_append (NULL, _point_new (x, y));
+    s->point_last  = s->point_first;
+
+    return s;
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab
+*/
Index: tomoe/lib/tomoe-writing.h
diff -u /dev/null tomoe/lib/tomoe-writing.h:1.1
--- /dev/null	Wed Nov 22 14:59:05 2006
+++ tomoe/lib/tomoe-writing.h	Wed Nov 22 14:59:05 2006
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2005 Takuro Ashie <ashie****@homa*****>
+ *  Copyright (C) 2006 Juernjakob Harder <juern****@gmail*****>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the
+ *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ *  Boston, MA  02111-1307  USA
+ *
+ *  $Id: tomoe-writing.h,v 1.1 2006/11/22 05:59:05 makeinu Exp $
+ */
+
+/** @file tomoe-handwrite.h
+ *  @brief 
+ */
+
+#ifndef __TOMOE_HANDWRITE_H__
+#define __TOMOE_HANDWRITE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TOMOE_TYPE_GLYPH            (tomoe_glyph_get_type ())
+#define TOMOE_GLYPH(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_GLYPH, TomoeGlyph))
+#define TOMOE_GLYPH_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_GLYPH, TomoeGlyphClass))
+#define TOMOE_IS_GLYPH(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_GLYPH))
+#define TOMOE_IS_GLYPH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_GLYPH))
+#define TOMOE_GLYPH_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_GLYPH, TomoeGlyphClass))
+
+typedef struct _TomoeGlyph      TomoeGlyph;
+typedef struct _TomoeGlyphClass TomoeGlyphClass;
+
+typedef struct _TomoePoint        TomoePoint;
+
+struct _TomoeGlyph
+{
+    GObject object;
+};
+
+struct _TomoeGlyphClass
+{
+    GObjectClass parent_class;
+};
+
+struct _TomoePoint
+{
+    gint x;
+    gint y;
+};
+
+GType           tomoe_glyph_get_type            (void) G_GNUC_CONST;
+TomoeGlyph     *tomoe_glyph_new                 (void);
+void            tomoe_glyph_move_to             (TomoeGlyph    *glyph,
+                                                 gint           x,
+                                                 gint           y);
+void            tomoe_glyph_line_to             (TomoeGlyph    *glyph,
+                                                 gint           x,
+                                                 gint           y);
+void            tomoe_glyph_clear               (TomoeGlyph    *glyph);
+guint           tomoe_glyph_get_number_of_strokes
+                                                (TomoeGlyph    *glyph);
+guint           tomoe_glyph_get_number_of_points(TomoeGlyph    *glyph,
+                                                 guint          stroke);
+gboolean        tomoe_glyph_get_point           (TomoeGlyph    *glyph,
+                                                 guint          stroke,
+                                                 guint          point,
+                                                 gint          *x,
+                                                 gint          *y);
+gboolean        tomoe_glyph_get_last_point      (TomoeGlyph    *glyph,
+                                                 gint          *x,
+                                                 gint          *y);
+void            tomoe_glyph_remove_last_stroke  (TomoeGlyph    *glyph);
+
+const GList    *tomoe_glyph_get_strokes         (TomoeGlyph    *glyph);
+
+G_END_DECLS
+
+#endif /* __TOMOE_HANDWRITE_H__ */
+
+/*
+vi:ts=4:nowrap:ai:expandtab
+*/
Index: tomoe/lib/tomoe.h
diff -u tomoe/lib/tomoe.h:1.29 tomoe/lib/tomoe.h:1.30
--- tomoe/lib/tomoe.h:1.29	Wed Nov 22 10:59:09 2006
+++ tomoe/lib/tomoe.h	Wed Nov 22 14:59:05 2006
@@ -20,7 +20,7 @@
  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  *  Boston, MA  02111-1307  USA
  *
- *  $Id: tomoe.h,v 1.29 2006/11/22 01:59:09 kous Exp $
+ *  $Id: tomoe.h,v 1.30 2006/11/22 05:59:05 makeinu Exp $
  */
 
 /** @file tomoe.h
@@ -35,7 +35,7 @@
 G_BEGIN_DECLS
 
 #include "tomoe-config.h"
-#include "tomoe-handwrite.h"
+#include "tomoe-writing.h"
 #include "tomoe-recognizer.h"
 
 /**


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