[cairo-commit] goocanvas/docs Makefile.am, 1.5, 1.6 architecture.xml, NONE, 1.1 coordinates.xml, NONE, 1.1 creating-items.xml, 1.4, 1.5 goocanvas-docs.sgml, 1.8, 1.9 model-view-canvas.xml, 1.2, 1.3 simple-canvas.xml, 1.2, 1.3 wysiwyg.xml, 1.1, 1.2

Damon Chaplin commit at pdx.freedesktop.org
Fri Apr 4 04:04:15 PDT 2008


Committed by: damon

Update of /cvs/cairo/goocanvas/docs
In directory kemper:/tmp/cvs-serv13771/docs

Modified Files:
	Makefile.am creating-items.xml goocanvas-docs.sgml 
	model-view-canvas.xml simple-canvas.xml wysiwyg.xml 
Added Files:
	architecture.xml coordinates.xml 
Log Message:
2008-04-04  Damon Chaplin  <damon at gnome.org>

	    * docs/coordinates.xml: 
	    * docs/architecture.xml: new sections.

	    * docs/creating-items.xml: rewritten.

	    * src/goocanvasitemmodel.c (goo_canvas_item_model_set_parent): 
	    * src/goocanvasitem.c (goo_canvas_item_set_parent): note in the docs
	    that the "parent" property can be used to set the parent, but that
	    these functions are only for implementing new items (a bit confusing).

	    * src/goocanvasitem.c (goo_canvas_item_is_visible): fixed a bug
	    where if the item doesn't support the method it would just return
	    TRUE, but it should also check the ancestors are visible.

	    * src/goocanvasitemsimple.c (goo_canvas_item_simple_set_property)
	    (goo_canvas_item_model_simple_set_property): use the _remove()
	    functions instead of the find_child()/remove_child() code.



Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/goocanvas/docs/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am	27 Mar 2008 13:00:49 -0000	1.5
+++ Makefile.am	4 Apr 2008 11:08:21 -0000	1.6
@@ -61,6 +61,8 @@
 	simple-canvas.xml			\
 	model-view-canvas.xml			\
 	wysiwyg.xml				\
+	architecture.xml			\
+	coordinates.xml				\
 	creating-items.xml
 
 # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).

--- NEW FILE: architecture.xml ---
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="goocanvas-architecture">
  <refmeta>
    <refentrytitle>Underlying Architecture</refentrytitle>
    <manvolnum>3</manvolnum>
    <refmiscinfo>GOOCANVAS Library</refmiscinfo>
  </refmeta>

  <refnamediv>
    <refname>Underlying Architecture</refname>
    <refpurpose>how the canvas fits together.</refpurpose>
  </refnamediv>

  <refsect1 id="architecture">
    <title>Underlying Architecture</title>

    <refsect2 id="widget">
      <title>The GooCanvas Widget</title>
      <para>
	#GooCanvas is a #GtkWidget (it is actually a subclass of
	#GtkContainer), and so can be placed in an interface just like
	any normal widget. Usually a #GooCanvas widget would be placed inside
	a #GtkScrolledWindow in order to enable scrolling of the canvas.
      </para>
      <para>
	The size of the canvas can be set explicitly using
	goo_canvas_set_bounds(), or if the #GooCanvas:automatic-bounds
	property is set to %TRUE the bounds will be automatically calculated
	to include all of the canvas items. The units used in the canvas can
	be set with the #GooCanvas:units property. The canvas units can be
	pixels, points, inches or millimeters and apply to the canvas and
	all items.
      </para>
    </refsect2>

    <refsect2 id="simple-structure">
      <title>The Structure of the Simple Canvas</title>
      <para>
	The simple canvas consists of a hierarchy of canvas items.
	The root item is automatically created by the canvas and can be
	accessed using goo_canvas_get_root_item(). New items and groups can
	then be created and added to the root item.
      </para>
      <para>
	Each item in the canvas keeps a #GooCanvasBounds structure which
	stores the bounding rectangle of the item and all of its descendants.
	This makes it easy to find out which items in the canvas need repainting
	or which item the mouse is over. (The bounds are stored in the device
	coordinate space, which is the coordinate space of the entire canvas,
	after any item transformation matrices have been applied.)
      </para>
    </refsect2>

    <refsect2 id="model-view-structure">
      <title>The Structure of the Model/View Canvas</title>
      <para>
	The model/view canvas consists of a hierarchy of item models, and an
	identical hierarchy of canvas items, with each canvas item
	corresponding to one item model.
      </para>
      <para>
	The hierarchy of item models can be used in several #GooCanvas
	widgets, to allow multiple views of the same model.
	Though different canvas items will be used in each #GooCanvas.
      </para>
      <para>
	The root item model is set with goo_canvas_set_root_item_model().
	The canvas will automatically create canvas items to display
	the hierarchy of item models, and will automatically add and
	remove canvas items as the item model hierarchy is changed.
      </para>
    </refsect2>

    <refsect2 id="updates">
      <title>The Update Procedure</title>
      <para>
	When items are added to the canvas or their properties are changed
	they may need to recalculate their bounds. To do this they set an
	internal flag such as @need_update, and make a call to
	goo_canvas_item_request_update().
      </para>
      <para>
	#GooCanvas handles all the update requests at once, to avoids multiple
	redraws of the same parts of the canvas. To do this it installs
	an idle handler, goo_canvas_idle_handler(), which is called as soon
	as the application is idle (and before any part of the canvas is
	redrawn). 
      </para>
      <para>
	The idle handler calls goo_canvas_item_update() on the root item,
	which recursively calls goo_canvas_item_update() on any items as
	necessary, recalculating their bounds and requesting redraws as
	appropriate.
      </para>
      <para>
	If a container item (e.g. #GooCanvasGroup) is changed it needs to
	ensure that all descendants recalculate their bounds so it
	calls goo_canvas_item_update() for all of its children with the
	@entire_tree argument set to %TRUE.
      </para>
    </refsect2>

    <refsect2 id="simple-updates">
      <title>How Changes to Items are Handled</title>
      <para>
	When an item is changed (e.g. if the #GooCanvasRect:x property of
	a #GooCanvasRect is changed), the item calls
	goo_canvas_item_simple_changed() with a flag indicating if the
	bounds of the item need	to be recalculated.
      </para>
      <para>
	If the bounds don't need to be recalculated, then
	goo_canvas_request_redraw() is called to simply request that the
	item is redrawn. This results in a call to gdk_window_invalidate_rect()
	and the redraw proceeds just like a normal #GtkWidget.
      </para>
      <para>
	However, if the bounds do need to be recalculated then
	goo_canvas_item_request_update() is called to request that the item
	be updated the next time the canvas performs an update.
      </para>
    </refsect2>

    <refsect2 id="model-view-updates">
      <title>How Changes are Handled in the Model/View Canvas</title>
      <para>
	In the Model/View canvas it is the underlying item models which are
	initially changed. The item models emit "changed" signals which the
	items respond to. For the standard canvas items the
	goo_canvas_item_model_simple_changed() signal handler is called,
	which calls goo_canvas_item_simple_changed() and the
	procedure continues as in the simple canvas case above.
      </para>
    </refsect2>

  </refsect1>
</refentry>

--- NEW FILE: coordinates.xml ---
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="goocanvas-coordinates">
  <refmeta>
    <refentrytitle>Coordinate Spaces</refentrytitle>
    <manvolnum>3</manvolnum>
    <refmiscinfo>GOOCANVAS Library</refmiscinfo>
  </refmeta>

  <refnamediv>
    <refname>Coordinate Spaces</refname>
    <refpurpose>how coordinates are used.</refpurpose>
  </refnamediv>

  <refsect1 id="coordinates">
    <title>Coordinate Spaces</title>
    <para>
      Items in the canvas typically have a number of properties specifying
      their location and size. For example the #GooCanvasRect item has
      #GooCanvasRect:x, #GooCanvasRect:y, #GooCanvasRect:width and
      #GooCanvasRect:height properties.
    </para>
    <para>
      However, items can also have a transformation matrix (e.g. the
      #GooCanvasItem:transform property).
      Transformation matrices modify the item's coordinate space in some
      way. Modifications include translation (moving the origin), rotation,
      scaling, and skewing, or combinations of these. Thus the final
      position of the item on the canvas can be altered dramatically.
    </para>
    <para>
      The simple animation features in #GooCanvas are accomplished by
      modifying the item's transformation matrix over time.
      (See goo_canvas_item_animate().)
    </para>
    <para>
      Since items are in a hierarchy it is possible to move or rotate an
      entire group of items by simply changing the transformation matrix
      of the group containing them.
    </para>
    <para>
      The coordinate space used within the item itself (e.g. where the
      #GooCanvasRect:x and #GooCanvasRect:y properties of a #GooCanvasRect
      are specified)
      is referred to as "Item Space". The coordinate space used by
      the entire canvas is referred to as "Device Space". "Item Space"
      and "Device Space" may or may not be the same, depending on whether
      the item or any of its ancestors have a transformation matrix set.
      (Note that the entire canvas may also be scrolled and/or zoomed,
      which means that there may be additional transformations above
      "Device Space".)
    </para>
    <para>
      Functions are provided to convert between coordinate spaces,
      e.g. goo_canvas_convert_to_item_space() and
      goo_canvas_convert_from_item_space() convert device space coordinates
      to item space and vice versa.
    </para>
  </refsect1>
</refentry>

Index: creating-items.xml
===================================================================
RCS file: /cvs/cairo/goocanvas/docs/creating-items.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- creating-items.xml	6 Mar 2007 13:21:26 -0000	1.4
+++ creating-items.xml	4 Apr 2008 11:08:21 -0000	1.5
@@ -13,150 +13,103 @@
     <refpurpose>how to create new canvas items.</refpurpose>
   </refnamediv>
 
-  <refsect1 id="new-items-overview">
+  <refsect1>
     <title>How to Create New Canvas Items</title>
     <para>
-    Here's an example of how to create a new simple canvas item. (Note that
-    this item doesn't have a model-view split.)
+    There are 3 ways to create new canvas items, listed here in increasing
+    order of complexity:
+    <itemizedlist>
+    <listitem><para>
+	<link linkend="creating-simple-subclass">
+	Creating a simple subclass of GooCanvasItemSimple.</link>
+    </para></listitem><listitem><para>
+	<link linkend="creating-regular-subclass">
+	Creating a regular subclass of GooCanvasItemSimple.</link>
+    </para></listitem><listitem><para>
+	<link linkend="implementing-interface">
+	Implementing the GooCanvasItem interface.</link>
+    </para></listitem>
+    </itemizedlist>
+    These will be discussed in turn below. (It is also possible to create
+    new container items by subclassing #GooCanvasGroup, but that is not
+    covered here.)
     </para>
     <para>
-    Here's the header file - a fairly standard GObject header file.
-    Our item derives from #GooCanvasItemSimple and just has its own
-    x, y, width and height variables:
+      The final part of this section covers
+      <link linkend="creating-models">creating item models</link>.
     </para>
 
-<informalexample><programlisting>
-  /&ast;
-   * GooCanvas Demo. Copyright (C) 2006 Damon Chaplin.
-   * Released under the GNU LGPL license. See COPYING for details.
-   *
-   * demo-item.c - a simple demo item.
-   &ast;/
-  &num;ifndef __GOO_DEMO_ITEM_H__
-  &num;define __GOO_DEMO_ITEM_H__
-  
-  &num;include &lt;gtk/gtk.h&gt;
-  &num;include "goocanvasitemsimple.h"
-  
-  G_BEGIN_DECLS
-  
-  
-  &num;define GOO_TYPE_DEMO_ITEM            (goo_demo_item_get_type&nbsp;())
-  &num;define GOO_DEMO_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOO_TYPE_DEMO_ITEM, GooDemoItem))
-  &num;define GOO_DEMO_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GOO_TYPE_DEMO_ITEM, GooDemoItemClass))
-  &num;define GOO_IS_DEMO_ITEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOO_TYPE_DEMO_ITEM))
-  &num;define GOO_IS_DEMO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOO_TYPE_DEMO_ITEM))
-  &num;define GOO_DEMO_ITEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GOO_TYPE_DEMO_ITEM, GooDemoItemClass))
-  
-  
-  typedef struct _GooDemoItem       GooDemoItem;
-  typedef struct _GooDemoItemClass  GooDemoItemClass;
-  
-  struct _GooDemoItem
-  {
-    GooCanvasItemSimple parent_object;
-  
-    gdouble x, y, width, height;
-  };
-  
-  struct _GooDemoItemClass
-  {
-    GooCanvasItemSimpleClass parent_class;
-  };
-  
-  
-  GType               goo_demo_item_get_type  (void) G_GNUC_CONST;
-  
-  GooCanvasItem*      goo_demo_item_new       (GooCanvasItem      *parent,
-                                               gdouble             x,
-                                               gdouble             y,
-                                               gdouble             width,
-                                               gdouble             height,
-                                               ...);
-  
-  
-  G_END_DECLS
-  
-  &num;endif /&ast; __GOO_DEMO_ITEM_H__ &ast;/
- </programlisting></informalexample>
-
-<para>
-And here's the source file:
-</para>
-
-<informalexample><programlisting>
-  /&ast;
-   * GooCanvas Demo. Copyright (C) 2006 Damon Chaplin.
-   * Released under the GNU LGPL license. See COPYING for details.
-   *
-   * demo-item.c - a simple demo item.
-   &ast;/
-  &num;include &lt;config.h&gt;
-  &num;include "goocanvas.h"
-  &num;include "demo-item.h"
-  
-  
-  /&ast; Use the GLib convenience macro to define the type. GooDemoItem is the
-     class struct, goo_demo_item is the function prefix, and our class is a
-     subclass of GOO_TYPE_CANVAS_ITEM_SIMPLE. &ast;/
-  G_DEFINE_TYPE (GooDemoItem, goo_demo_item, GOO_TYPE_CANVAS_ITEM_SIMPLE)
-  
-  
-  /&ast; The standard object initialization function. &ast;/
+    <refsect2 id="creating-simple-subclass">
+      <title>Creating a Simple Subclass of GooCanvasItemSimple</title>
+      <para>
+	For items that consist of a simple graphic element such
+	as a line, rectangle or circle, it is possible to create a subclass
+	of #GooCanvasItemSimple and override just one method,
+	simple_create_path(). (This method is used for the #GooCanvasEllipse
+	and #GooCanvasPath items.)
+      </para>
+      <para>
+	The simple_create_path() method should create a path using the given
+	cairo context. The path will be drawn using the stroke, fill and
+	other painting properties from #GooCanvasItemSimple.
+      </para>
+      <para>
+	This example shows the simple_create_path() method for a simple
+	rectangular item, MyItem:
+	<informalexample><programlisting>
   static void
-  goo_demo_item_init (GooDemoItem *demo_item)
-  {
-    demo_item-&gt;x = 0.0;
-    demo_item-&gt;y = 0.0;
-    demo_item-&gt;width = 0.0;
-    demo_item-&gt;height = 0.0;
-  }
-  
-  
-  /&ast; The convenience function to create new items. This should start with a 
-     parent argument and end with a variable list of object properties to fit
-     in with the standard canvas items. &ast;/
-  GooCanvasItem*
-  goo_demo_item_new (GooCanvasItem      *parent,
-                     gdouble             x,
-                     gdouble             y,
-                     gdouble             width,
-                     gdouble             height,
-                     ...)
+  my_item_simple_create_path (GooCanvasItemSimple *simple,
+                              cairo_t             *cr)
   {
-    GooCanvasItem *item;
-    GooDemoItem *demo_item;
-    const char *first_property;
-    va_list var_args;
-  
-    item = g_object_new (GOO_TYPE_DEMO_ITEM, NULL);
-  
-    demo_item = (GooDemoItem*) item;
-    demo_item-&gt;x = x;
-    demo_item-&gt;y = y;
-    demo_item-&gt;width = width;
-    demo_item-&gt;height = height;
-  
-    va_start (var_args, height);
-    first_property = va_arg (var_args, char*);
-    if (first_property)
-      g_object_set_valist ((GObject*) item, first_property, var_args);
-    va_end (var_args);
-  
-    if (parent)
-      {
-        goo_canvas_item_add_child (parent, item, -1);
-        g_object_unref (item);
-      }
-  
-    return item;
+    MyItem *item = (MyItem*) simple;
+
+    cairo_rectangle (cr, item->x, item->y, item->width, item->height);
   }
-  
-  
-  /&ast; The update method. This is called when the canvas is initially shown and
-     also whenever the object is updated and needs to change its size and/or
-     shape. It should calculate its new bounds in its own coordinate space,
-     storing them in simple-&gt;bounds. &ast;/
+	</programlisting></informalexample>
+      </para>
+      <para>
+	Whenever the item is changed in some way it should call
+	goo_canvas_item_simple_changed(), passing a boolean value indicating
+	whether the item's bounds need to be recalculated or if it only needs
+	to be repainted. The #GooCanvasItemSimple code will take care of
+	updating the item and repainting the appropriate parts of the canvas.
+      </para>
+    </refsect2>
+
+    <refsect2 id="creating-regular-subclass">
+      <title>Creating a Regular Subclass of GooCanvasItemSimple</title>
+      <para>
+	Most items will need more than a simple line or rectangle, so they
+	will need to create a subclass of #GooCanvasItemSimple and override
+	three methods, simple_update(), simple_paint() and simple_is_item_at().
+      </para>
+      <para>
+	The simple_update() method should compute the bounds of the item, in the
+	item's coordinate space, and place them in the bounds member of
+	#GooCanvasItemSimple-struct. Note that the cairo context passed to
+	this function may have transformations applied to it, so
+	cairo_identity_matrix() should be called before using it.
+      </para>
+      <para>
+	The simple_paint() method should paint the item using the given cairo
+	context. To use the stroke and fill properties from #GooCanvasItemSimple
+	to paint parts of the item call goo_canvas_style_set_stroke_options()
+	and goo_canvas_style_set_fill_options() before calling cairo_stroke()
+	and cairo_fill(). (The item's style can be found in
+	GOO_CANVAS_ITEM_SIMPLE (item)->simple_data->style).
+      </para>
+      <para>
+	The simple_is_item_at() method should return %TRUE if the
+	given coordinate (in the item's coordinate space) is inside the item.
+	(The is_pointer_event argument can be ignored for most purposes since
+	the #GooCanvasItemSimple code will take care of it.)
+      </para>
+      <para>
+	This example code shows the simple_update(), simple_paint() and
+	simple_is_item_at() methods for a rectangular item (the complete
+	item's source code can be found in the GooCanvas demo directory, in
+	demo-item.h and demo-item.c):
+	<informalexample><programlisting>
   static void
   goo_demo_item_update  (GooCanvasItemSimple *simple,
                          cairo_t             *cr)
@@ -171,8 +124,6 @@
   }
   
   
-  /&ast; The paint method. This should draw the item on the given cairo_t, using
-     the item's own coordinate space. &ast;/
   static void
   goo_demo_item_paint (GooCanvasItemSimple   *simple,
                        cairo_t               *cr,
@@ -191,9 +142,6 @@
   }
   
   
-  /&ast; Hit detection. This should check if the given coordinate (in the item's
-     coordinate space) is within the item. If it is it should return TRUE,
-     otherwise it should return FALSE. &ast;/
   static gboolean
   goo_demo_item_is_item_at (GooCanvasItemSimple *simple,
                             gdouble              x,
@@ -209,22 +157,158 @@
   
     return TRUE;
   }
-  
-  
-  /&ast; The class initialization function. Here we set the class' update(), paint()
-     and is_item_at() methods. &ast;/
-  static void
-  goo_demo_item_class_init (GooDemoItemClass *klass)
-  {
-    GooCanvasItemSimpleClass *simple_class = (GooCanvasItemSimpleClass*) klass;
-  
-    simple_class-&gt;update        = goo_demo_item_update;
-    simple_class-&gt;paint         = goo_demo_item_paint;
-    simple_class-&gt;is_item_at    = goo_demo_item_is_item_at;
-  }
-  
-  
- </programlisting></informalexample>
+	</programlisting></informalexample>
+      </para>
+      <para>
+	As with the simple #GooCanvasItemSimple subclass, the item should
+	call goo_canvas_item_simple_changed() whenever it is changed, to
+	ensure that the item's bounds are recomputed and it is repainted
+	if necessary.
+      </para>
+    </refsect2>
+
+    <refsect2 id="implementing-interface">
+      <title>Implementing the GooCanvasItem Interface</title>
+      <para>
+	The most complicated way to create new canvas items is to implement
+	the #GooCanvasItem interface directly. This should not be needed in
+	most cases, but may be desired if the developer wants to avoid the
+	memory and processor overheads associated with the #GooCanvasItemSimple
+	class, or if the developer wants to turn an existing application object
+	into a canvas item.
+      </para>
+
+      <para>
+	At a minimum the canvas item must implement these 6 methods:
+	<itemizedlist>
+	  <listitem><para>
+	      get_parent() - the item's parent should be returned.
+	  </para></listitem><listitem><para>
+	      set_parent() - the item's parent should be stored (though it
+	      should not add a reference to the parent).
+	  </para></listitem><listitem><para>
+	      get_bounds() - returns the bounds of the item, in device space.
+	      The item should ensure that the bounds are up-to-date before
+	      returning them, calling goo_canvas_item_ensure_updated() if
+	      necessary.
+	  </para></listitem><listitem><para>
+	      update() - if the item has been changed since the last update,
+	      or if the entire_tree flag is %TRUE, the item's bounds should
+	      be recomputed (in device space). It should also request a redraw
+	      of the old bounds and the new bounds, so the display is updated
+	      appropriately. The new bounds should be returned in the bounds
+	      argument.
+	  </para></listitem><listitem><para>
+	      paint() - if the item's bounds intersect the given bounds then
+	      the item should be painted on the given cairo context.
+	      The scale parameter is only used to check if the item should be
+	      visible, according to the item's #GooCanvasItem:visibility and
+	      #GooCanvasItem:visibility-threshold property settings.
+	  </para></listitem><listitem><para>
+	      get_items_at() - if the given point is inside the item then
+	      a pointer to the item should be added to the start of the list
+	      of found items. The list is then returned.
+	  </para></listitem>
+	</itemizedlist>
+      </para>
+
+      <para>
+	The canvas item must also implement the
+	#GooCanvasItem:parent, #GooCanvasItem:title,
+	#GooCanvasItem:description,
+	#GooCanvasItem:visibility, #GooCanvasItem:visibility-threshold,
+	#GooCanvasItem:transform and #GooCanvasItem:pointer-events properties.
+	(The last 4 properties can simply be ignored if the application
+	doesn't intend to use them.)
+      </para>
+
+      <para>
+	If the canvas item will be used within a container that does item
+	layout, such as #GooCanvasTable, it must implement the first two
+	methods here at least:
+	<itemizedlist>
+	  <listitem><para>
+	      get_requested_area() - returns the requested area of the item,
+	      in the parent's coordinate space.
+	  </para></listitem><listitem><para>
+	      allocate_area() - allocates the item's area, in the parent's
+	      coordinate space.
+	  </para></listitem><listitem><para>
+	      get_requested_height() - returns the requested height of the
+	      item, given a particular allocated width, in the parent's
+	      coordinate space. (This only needed for items that change height
+	      as their width is changed, such as text items.)
+	  </para></listitem>
+	</itemizedlist>
+      </para>
+
+      <para>
+	If the canvas item supports a transformation matrix it must implement:
+	<itemizedlist>
+	  <listitem><para>
+	      get_transform() - returns the item's transformation matrix.
+	  </para></listitem><listitem><para>
+	      set_transform() - sets the item's transformation matrix.
+	  </para></listitem>
+	</itemizedlist>
+      </para>
+
+      <para>
+	If the canvas item supports a #GooCanvasStyle setting, it must
+	implement:
+	<itemizedlist>
+	  <listitem><para>
+	      get_style() - returns the item's style.
+	  </para></listitem><listitem><para>
+	      set_style() - sets the item's style.
+	  </para></listitem>
+	</itemizedlist>
+      </para>
+
+      <para>
+	Since #GooCanvasItemSimple implements most of the above methods and
+	properties its source code is a good place to look for help.
+      </para>
+    </refsect2>
+
+    <refsect2 id="creating-item-models">
+      <title>Creating Item Models</title>
+      <para>
+	As with creating canvas items, to create item models it
+	is possible to subclass #GooCanvasItemModelSimple or to
+	implement the #GooCanvasItemModel interface directly.
+      </para>
+      <para>
+	Subclassing #GooCanvasItemModelSimple is very easy, since only one
+	method from the #GooCanvasItemModel interface must be implemented -
+	create_item(). This should return a new canvas item for viewing the
+	item model in a canvas. (It may be called multiple times if multiple
+	canvases are viewing the same canvas model.)
+      </para>
+      <para>
+	The #GooCanvasItemModelSimple subclass should emit the "changed"
+	signal whenever it has changed, with a boolean flag indicating if
+	the bounds need to be recomputed. The canvas items will connect to
+	this signal and request an update or a redraw as appropriate.
+      </para>
+      <para>
+	To implement the #GooCanvasItemModel interface directly, the class
+	must implement the get_parent(), set_parent() and create_item()
+	methods. It may also implement get_transform(), set_transform(),
+	get_style() and set_style() methods if desired.
+      </para>
+      <para>
+	The class must also implement the
+	#GooCanvasItemModel:parent, #GooCanvasItemModel:title,
+	#GooCanvasItemModel:description, #GooCanvasItemModel:can-focus,
+	#GooCanvasItemModel:visibility,
+	#GooCanvasItemModel:visibility-threshold,
+	#GooCanvasItemModel:transform and #GooCanvasItemModel:pointer-events
+	properties.
+	(The last 4 properties can simply be ignored if the application
+	doesn't intend to use them.)
+      </para>
+    </refsect2>
 
   </refsect1>
 </refentry>

Index: goocanvas-docs.sgml
===================================================================
RCS file: /cvs/cairo/goocanvas/docs/goocanvas-docs.sgml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- goocanvas-docs.sgml	27 Mar 2008 13:00:49 -0000	1.8
+++ goocanvas-docs.sgml	4 Apr 2008 11:08:21 -0000	1.9
@@ -11,8 +11,10 @@
     <xi:include href="xml/overview.xml"/>
     <xi:include href="xml/simple-canvas.xml"/>
     <xi:include href="xml/model-view-canvas.xml"/>
-    <xi:include href="xml/wysiwyg.xml"/>
+    <xi:include href="xml/architecture.xml"/>
+    <xi:include href="xml/coordinates.xml"/>
     <xi:include href="xml/creating-items.xml"/>
+    <xi:include href="xml/wysiwyg.xml"/>
   </chapter>
 
   <chapter>

Index: model-view-canvas.xml
===================================================================
RCS file: /cvs/cairo/goocanvas/docs/model-view-canvas.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- model-view-canvas.xml	9 Feb 2007 13:41:03 -0000	1.2
+++ model-view-canvas.xml	4 Apr 2008 11:08:22 -0000	1.3
@@ -3,13 +3,13 @@
                "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
 <refentry id="goocanvas-model-view-canvas">
   <refmeta>
-    <refentrytitle>The Model/View Canvas</refentrytitle>
+    <refentrytitle>Model/View Canvas Example</refentrytitle>
     <manvolnum>3</manvolnum>
     <refmiscinfo>GOOCANVAS Library</refmiscinfo>
   </refmeta>
 
   <refnamediv>
-    <refname>The Model/View Canvas</refname>
+    <refname>Model/View Canvas Example</refname>
     <refpurpose>how to create a model/view canvas.</refpurpose>
   </refnamediv>
 

Index: simple-canvas.xml
===================================================================
RCS file: /cvs/cairo/goocanvas/docs/simple-canvas.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- simple-canvas.xml	9 Feb 2007 13:41:03 -0000	1.2
+++ simple-canvas.xml	4 Apr 2008 11:08:22 -0000	1.3
@@ -3,13 +3,13 @@
                "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
 <refentry id="goocanvas-simple-canvas">
   <refmeta>
-    <refentrytitle>The Simple Canvas</refentrytitle>
+    <refentrytitle>Simple Canvas Example</refentrytitle>
     <manvolnum>3</manvolnum>
     <refmiscinfo>GOOCANVAS Library</refmiscinfo>
   </refmeta>
 
   <refnamediv>
-    <refname>The Simple Canvas</refname>
+    <refname>Simple Canvas Example</refname>
     <refpurpose>how to create a simple canvas.</refpurpose>
   </refnamediv>
 

Index: wysiwyg.xml
===================================================================
RCS file: /cvs/cairo/goocanvas/docs/wysiwyg.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- wysiwyg.xml	27 Mar 2008 13:00:49 -0000	1.1
+++ wysiwyg.xml	4 Apr 2008 11:08:22 -0000	1.2
@@ -21,7 +21,7 @@
       <para>
     The GooCanvas #GooCanvas:resolution-x and #GooCanvas:resolution-y
     properties must be set correctly. They both default to 96dpi, which
-    corresponds with a typical monitor. To get a more accurate figure you
+    corresponds to a typical monitor. To get a more accurate figure you
     might be able to use gdk_screen_get_resolution(), but this isn't always
     guaranteed to be correct. If accuracy is very important a method should
     be provided for the user to calibrate the screen.



More information about the cairo-commit mailing list