goocanvas 0.90.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/ChangeLog +87 -0
  2. data/README +37 -0
  3. data/Rakefile +14 -0
  4. data/ext/goocanvas/depend +5 -0
  5. data/ext/goocanvas/extconf.rb +66 -0
  6. data/ext/goocanvas/goocanvas.def +2 -0
  7. data/ext/goocanvas/rbgoocairo.c +74 -0
  8. data/ext/goocanvas/rbgoocanvas.c +236 -0
  9. data/ext/goocanvas/rbgoocanvas.h +66 -0
  10. data/ext/goocanvas/rbgoocanvasellipse.c +50 -0
  11. data/ext/goocanvas/rbgoocanvasgroup.c +41 -0
  12. data/ext/goocanvas/rbgoocanvasimage.c +45 -0
  13. data/ext/goocanvas/rbgoocanvasitem.c +358 -0
  14. data/ext/goocanvas/rbgoocanvaspolyline.c +102 -0
  15. data/ext/goocanvas/rbgoocanvasrect.c +47 -0
  16. data/ext/goocanvas/rbgoocanvasstyle.c +61 -0
  17. data/ext/goocanvas/rbgoocanvastable.c +41 -0
  18. data/ext/goocanvas/rbgoocanvastext.c +58 -0
  19. data/ext/goocanvas/rbgoocanvaswidget.c +48 -0
  20. data/ext/goocanvas/rbgooutils.c +44 -0
  21. data/extconf.rb +49 -0
  22. data/lib/1.8/goocanvas.so +0 -0
  23. data/lib/1.9/goocanvas.so +0 -0
  24. data/lib/goocanvas.rb +145 -0
  25. data/sample/demo-arrowhead.rb +315 -0
  26. data/sample/demo-fifteen.rb +218 -0
  27. data/sample/demo-primitives.rb +720 -0
  28. data/sample/demo.rb +84 -0
  29. data/sample/flower.png +0 -0
  30. data/sample/scalability-demo.rb +130 -0
  31. data/sample/simple-demo.rb +35 -0
  32. data/sample/table-demo.rb +137 -0
  33. data/sample/toroid.png +0 -0
  34. data/sample/units-demo.rb +80 -0
  35. data/sample/widgets-demo.rb +197 -0
  36. data/vendor/local/bin/libgoocanvas-3.dll +0 -0
  37. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvas.h +334 -0
  38. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasatk.h +22 -0
  39. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasellipse.h +120 -0
  40. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasenumtypes.h +33 -0
  41. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasgrid.h +153 -0
  42. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasgroup.h +109 -0
  43. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasimage.h +121 -0
  44. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasitem.h +479 -0
  45. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasitemmodel.h +275 -0
  46. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasitemsimple.h +247 -0
  47. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasmarshal.h +61 -0
  48. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvaspath.h +116 -0
  49. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvaspolyline.h +176 -0
  50. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasprivate.h +59 -0
  51. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasrect.h +121 -0
  52. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasstyle.h +110 -0
  53. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvastable.h +139 -0
  54. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvastext.h +133 -0
  55. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasutils.h +333 -0
  56. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvaswidget.h +66 -0
  57. data/vendor/local/include/goocanvas-1.0.0/goocanvas/stamp-goocanvasmarshal.h +1 -0
  58. data/vendor/local/lib/libgoocanvas.a +0 -0
  59. data/vendor/local/lib/libgoocanvas.dll.a +0 -0
  60. data/vendor/local/lib/pkgconfig/goocanvas.pc +13 -0
  61. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvas.html +1982 -0
  62. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasEllipse.html +269 -0
  63. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasEllipseModel.html +274 -0
  64. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGrid.html +469 -0
  65. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGridModel.html +476 -0
  66. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGroup.html +183 -0
  67. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGroupModel.html +184 -0
  68. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasImage.html +247 -0
  69. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasImageModel.html +252 -0
  70. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItem.html +3014 -0
  71. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItemModel.html +1764 -0
  72. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItemModelSimple.html +298 -0
  73. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItemSimple.html +809 -0
  74. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPath.html +279 -0
  75. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPathModel.html +280 -0
  76. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPolyline.html +369 -0
  77. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPolylineModel.html +375 -0
  78. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasRect.html +247 -0
  79. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasRectModel.html +252 -0
  80. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasStyle.html +489 -0
  81. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasTable.html +452 -0
  82. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasTableModel.html +452 -0
  83. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasText.html +324 -0
  84. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasTextModel.html +287 -0
  85. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasWidget.html +266 -0
  86. data/vendor/local/share/gtk-doc/html/goocanvas/ch01.html +53 -0
  87. data/vendor/local/share/gtk-doc/html/goocanvas/ch02.html +50 -0
  88. data/vendor/local/share/gtk-doc/html/goocanvas/ch03.html +62 -0
  89. data/vendor/local/share/gtk-doc/html/goocanvas/ch04.html +60 -0
  90. data/vendor/local/share/gtk-doc/html/goocanvas/ch05.html +33 -0
  91. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-GooCanvas-Types.html +815 -0
  92. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-architecture.html +157 -0
  93. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-coordinates.html +106 -0
  94. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-creating-items.html +420 -0
  95. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-model-view-canvas.html +246 -0
  96. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-overview.html +106 -0
  97. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-simple-canvas.html +238 -0
  98. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-wysiwyg.html +84 -0
  99. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas.devhelp +608 -0
  100. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas.devhelp2 +639 -0
  101. data/vendor/local/share/gtk-doc/html/goocanvas/home.png +0 -0
  102. data/vendor/local/share/gtk-doc/html/goocanvas/index.html +138 -0
  103. data/vendor/local/share/gtk-doc/html/goocanvas/index.sgml +814 -0
  104. data/vendor/local/share/gtk-doc/html/goocanvas/left.png +0 -0
  105. data/vendor/local/share/gtk-doc/html/goocanvas/right.png +0 -0
  106. data/vendor/local/share/gtk-doc/html/goocanvas/style.css +257 -0
  107. data/vendor/local/share/gtk-doc/html/goocanvas/up.png +0 -0
  108. data/vendor/local/share/gtk-doc/tmpl/goocanvas/dummy.sgml +0 -0
  109. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvas-unused.sgml +0 -0
  110. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvas.sgml +536 -0
  111. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasellipse.sgml +82 -0
  112. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasellipsemodel.sgml +82 -0
  113. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgrid.sgml +176 -0
  114. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgridmodel.sgml +176 -0
  115. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgroup.sgml +58 -0
  116. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgroupmodel.sgml +58 -0
  117. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasimage.sgml +81 -0
  118. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasimagemodel.sgml +81 -0
  119. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitem.sgml +773 -0
  120. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitemmodel.sgml +490 -0
  121. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitemmodelsimple.sgml +135 -0
  122. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitemsimple.sgml +254 -0
  123. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspath.sgml +64 -0
  124. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspathmodel.sgml +64 -0
  125. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspolyline.sgml +109 -0
  126. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspolylinemodel.sgml +109 -0
  127. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasrect.sgml +72 -0
  128. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasrectmodel.sgml +72 -0
  129. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasstyle.sgml +186 -0
  130. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastable.sgml +158 -0
  131. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastablemodel.sgml +158 -0
  132. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastext.sgml +103 -0
  133. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastextmodel.sgml +93 -0
  134. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasutils.sgml +241 -0
  135. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaswidget.sgml +73 -0
  136. metadata +218 -0
@@ -0,0 +1,420 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>Creating New Items</title>
6
+ <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7
+ <link rel="home" href="index.html" title="GooCanvas Reference Manual">
8
+ <link rel="up" href="ch01.html" title="Introduction">
9
+ <link rel="prev" href="goocanvas-coordinates.html" title="Coordinate Spaces and Limits">
10
+ <link rel="next" href="goocanvas-wysiwyg.html" title="WYSIWYG Printing">
11
+ <meta name="generator" content="GTK-Doc V1.14 (XML mode)">
12
+ <link rel="stylesheet" href="style.css" type="text/css">
13
+ </head>
14
+ <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15
+ <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16
+ <td><a accesskey="p" href="goocanvas-coordinates.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17
+ <td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18
+ <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19
+ <th width="100%" align="center">GooCanvas Reference Manual</th>
20
+ <td><a accesskey="n" href="goocanvas-wysiwyg.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
21
+ </tr></table>
22
+ <div class="refentry" title="Creating New Items">
23
+ <a name="goocanvas-creating-items"></a><div class="titlepage"></div>
24
+ <div class="refnamediv"><table width="100%"><tr>
25
+ <td valign="top">
26
+ <h2><span class="refentrytitle">Creating New Items</span></h2>
27
+ <p>Creating New Items — how to create new canvas items.</p>
28
+ </td>
29
+ <td valign="top" align="right"></td>
30
+ </tr></table></div>
31
+ <div class="refsect1" title="How to Create New Canvas Items">
32
+ <a name="id2863322"></a><h2>How to Create New Canvas Items</h2>
33
+ <p>
34
+ There are 3 ways to create new canvas items, listed here in increasing
35
+ order of complexity:
36
+ </p>
37
+ <div class="itemizedlist"><ul class="itemizedlist" type="disc">
38
+ <li class="listitem"><p>
39
+ <a class="link" href="goocanvas-creating-items.html#creating-simple-subclass" title="Creating a Simple Subclass of GooCanvasItemSimple">
40
+ Creating a simple subclass of GooCanvasItemSimple.</a>
41
+ </p></li>
42
+ <li class="listitem"><p>
43
+ <a class="link" href="goocanvas-creating-items.html#creating-regular-subclass" title="Creating a Regular Subclass of GooCanvasItemSimple">
44
+ Creating a regular subclass of GooCanvasItemSimple.</a>
45
+ </p></li>
46
+ <li class="listitem"><p>
47
+ <a class="link" href="goocanvas-creating-items.html#implementing-interface" title="Implementing the GooCanvasItem Interface">
48
+ Implementing the GooCanvasItem interface.</a>
49
+ </p></li>
50
+ </ul></div>
51
+ <p>
52
+ These will be discussed in turn below. (It is also possible to create
53
+ new container items by subclassing <a class="link" href="GooCanvasGroup.html" title="GooCanvasGroup"><span class="type">GooCanvasGroup</span></a>, but that is not
54
+ covered here.)
55
+ </p>
56
+ <p>
57
+ The final part of this section covers
58
+ creating item models.
59
+ </p>
60
+ <div class="refsect2" title="Creating a Simple Subclass of GooCanvasItemSimple">
61
+ <a name="creating-simple-subclass"></a><h3>Creating a Simple Subclass of GooCanvasItemSimple</h3>
62
+ <p>
63
+ For items that consist of a simple graphic element such
64
+ as a line, rectangle or circle, it is possible to create a subclass
65
+ of <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a> and override just one method,
66
+ <code class="function">simple_create_path()</code>. (This method is used for the <a class="link" href="GooCanvasEllipse.html" title="GooCanvasEllipse"><span class="type">GooCanvasEllipse</span></a>
67
+ and <a class="link" href="GooCanvasPath.html" title="GooCanvasPath"><span class="type">GooCanvasPath</span></a> items.)
68
+ </p>
69
+ <p>
70
+ The <code class="function">simple_create_path()</code> method should create a path using the given
71
+ cairo context. The path will be drawn using the stroke, fill and
72
+ other painting properties from <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a>.
73
+ </p>
74
+ <p>
75
+ This example shows the <code class="function">simple_create_path()</code> method for a simple
76
+ rectangular item, MyItem:
77
+ </p>
78
+ <div class="informalexample">
79
+ <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
80
+ <tbody>
81
+ <tr>
82
+ <td class="listing_lines" align="right"><pre>1
83
+ 2
84
+ 3
85
+ 4
86
+ 5
87
+ 6
88
+ 7
89
+ 8</pre></td>
90
+ <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
91
+ <span class="function">my_item_simple_create_path</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="GooCanvasItemSimple.html">GooCanvasItemSimple</a> </span><span class="symbol">*</span><span class="normal">simple</span><span class="symbol">,</span>
92
+ <span class="normal"> <a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-t">cairo_t</a> </span><span class="symbol">*</span><span class="normal">cr</span><span class="symbol">)</span>
93
+ <span class="cbracket">{</span>
94
+ <span class="normal"> MyItem </span><span class="symbol">*</span><span class="normal">item </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">MyItem</span><span class="symbol">*)</span><span class="normal"> simple</span><span class="symbol">;</span>
95
+
96
+ <span class="normal"> </span><span class="function"><a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-Paths.html#cairo-rectangle">cairo_rectangle</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">cr</span><span class="symbol">,</span><span class="normal"> item</span><span class="symbol">-&gt;</span><span class="normal">x</span><span class="symbol">,</span><span class="normal"> item</span><span class="symbol">-&gt;</span><span class="normal">y</span><span class="symbol">,</span><span class="normal"> item</span><span class="symbol">-&gt;</span><span class="normal">width</span><span class="symbol">,</span><span class="normal"> item</span><span class="symbol">-&gt;</span><span class="normal">height</span><span class="symbol">);</span>
97
+ <span class="cbracket">}</span></pre></td>
98
+ </tr>
99
+ </tbody>
100
+ </table>
101
+ </div>
102
+
103
+ <p>
104
+ </p>
105
+ <p>
106
+ Whenever the item is changed in some way it should call
107
+ <a class="link" href="GooCanvasItemSimple.html#goo-canvas-item-simple-changed" title="goo_canvas_item_simple_changed ()"><code class="function">goo_canvas_item_simple_changed()</code></a>, passing a boolean value indicating
108
+ whether the item's bounds need to be recalculated or if it only needs
109
+ to be repainted. The <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a> code will take care of
110
+ updating the item and repainting the appropriate parts of the canvas.
111
+ </p>
112
+ </div>
113
+ <hr>
114
+ <div class="refsect2" title="Creating a Regular Subclass of GooCanvasItemSimple">
115
+ <a name="creating-regular-subclass"></a><h3>Creating a Regular Subclass of GooCanvasItemSimple</h3>
116
+ <p>
117
+ Most items will need more than a simple line or rectangle, so they
118
+ will need to create a subclass of <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a> and override
119
+ three methods, <code class="function">simple_update()</code>, <code class="function">simple_paint()</code> and <code class="function">simple_is_item_at()</code>.
120
+ </p>
121
+ <p>
122
+ The <code class="function">simple_update()</code> method should compute the bounds of the item, in the
123
+ item's coordinate space, and place them in the bounds member of
124
+ <a class="link" href="GooCanvasItemSimple.html#GooCanvasItemSimple-struct" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a>. Note that the cairo context passed to
125
+ this function may have transformations applied to it, so
126
+ <a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-Transformations.html#cairo-identity-matrix"><code class="function">cairo_identity_matrix()</code></a> should be called before using it.
127
+ </p>
128
+ <p>
129
+ The <code class="function">simple_paint()</code> method should paint the item using the given cairo
130
+ context. To use the stroke and fill properties from <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a>
131
+ to paint parts of the item call <a class="link" href="GooCanvasStyle.html#goo-canvas-style-set-stroke-options" title="goo_canvas_style_set_stroke_options ()"><code class="function">goo_canvas_style_set_stroke_options()</code></a>
132
+ and <a class="link" href="GooCanvasStyle.html#goo-canvas-style-set-fill-options" title="goo_canvas_style_set_fill_options ()"><code class="function">goo_canvas_style_set_fill_options()</code></a> before calling <a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-stroke"><code class="function">cairo_stroke()</code></a>
133
+ and <a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-fill"><code class="function">cairo_fill()</code></a>. (The item's style can be found in
134
+ GOO_CANVAS_ITEM_SIMPLE (item)-&gt;simple_data-&gt;style).
135
+ </p>
136
+ <p>
137
+ The <code class="function">simple_is_item_at()</code> method should return <code class="literal">TRUE</code> if the
138
+ given coordinate (in the item's coordinate space) is inside the item.
139
+ (The is_pointer_event argument can be ignored for most purposes since
140
+ the <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a> code will take care of it.)
141
+ </p>
142
+ <p>
143
+ This example code shows the <code class="function">simple_update()</code>, <code class="function">simple_paint()</code> and
144
+ <code class="function">simple_is_item_at()</code> methods for a rectangular item (the complete
145
+ item's source code can be found in the GooCanvas demo directory, in
146
+ demo-item.h and demo-item.c):
147
+ </p>
148
+ <div class="informalexample">
149
+ <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
150
+ <tbody>
151
+ <tr>
152
+ <td class="listing_lines" align="right"><pre>1
153
+ 2
154
+ 3
155
+ 4
156
+ 5
157
+ 6
158
+ 7
159
+ 8
160
+ 9
161
+ 10
162
+ 11
163
+ 12
164
+ 13
165
+ 14
166
+ 15
167
+ 16
168
+ 17
169
+ 18
170
+ 19
171
+ 20
172
+ 21
173
+ 22
174
+ 23
175
+ 24
176
+ 25
177
+ 26
178
+ 27
179
+ 28
180
+ 29
181
+ 30
182
+ 31
183
+ 32
184
+ 33
185
+ 34
186
+ 35
187
+ 36
188
+ 37
189
+ 38
190
+ 39
191
+ 40
192
+ 41
193
+ 42
194
+ 43
195
+ 44
196
+ 45
197
+ 46
198
+ 47</pre></td>
199
+ <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
200
+ <span class="function">goo_demo_item_update</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="GooCanvasItemSimple.html">GooCanvasItemSimple</a> </span><span class="symbol">*</span><span class="normal">simple</span><span class="symbol">,</span>
201
+ <span class="normal"> <a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-t">cairo_t</a> </span><span class="symbol">*</span><span class="normal">cr</span><span class="symbol">)</span>
202
+ <span class="cbracket">{</span>
203
+ <span class="normal"> GooDemoItem </span><span class="symbol">*</span><span class="normal">demo_item </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">GooDemoItem</span><span class="symbol">*)</span><span class="normal"> simple</span><span class="symbol">;</span>
204
+
205
+ <span class="normal"> </span><span class="comment">/* Compute the new bounds. */</span>
206
+ <span class="normal"> simple</span><span class="symbol">-&gt;</span><span class="normal">bounds</span><span class="symbol">.</span><span class="normal">x1 </span><span class="symbol">=</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x</span><span class="symbol">;</span>
207
+ <span class="normal"> simple</span><span class="symbol">-&gt;</span><span class="normal">bounds</span><span class="symbol">.</span><span class="normal">y1 </span><span class="symbol">=</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y</span><span class="symbol">;</span>
208
+ <span class="normal"> simple</span><span class="symbol">-&gt;</span><span class="normal">bounds</span><span class="symbol">.</span><span class="normal">x2 </span><span class="symbol">=</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">width</span><span class="symbol">;</span>
209
+ <span class="normal"> simple</span><span class="symbol">-&gt;</span><span class="normal">bounds</span><span class="symbol">.</span><span class="normal">y2 </span><span class="symbol">=</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">height</span><span class="symbol">;</span>
210
+ <span class="cbracket">}</span>
211
+
212
+
213
+ <span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
214
+ <span class="function">goo_demo_item_paint</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="GooCanvasItemSimple.html">GooCanvasItemSimple</a> </span><span class="symbol">*</span><span class="normal">simple</span><span class="symbol">,</span>
215
+ <span class="normal"> <a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-t">cairo_t</a> </span><span class="symbol">*</span><span class="normal">cr</span><span class="symbol">,</span>
216
+ <span class="normal"> </span><span class="keyword">const</span><span class="normal"> <a href="goocanvas-GooCanvas-Types.html#GooCanvasBounds">GooCanvasBounds</a> </span><span class="symbol">*</span><span class="normal">bounds</span><span class="symbol">)</span>
217
+ <span class="cbracket">{</span>
218
+ <span class="normal"> GooDemoItem </span><span class="symbol">*</span><span class="normal">demo_item </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">GooDemoItem</span><span class="symbol">*)</span><span class="normal"> simple</span><span class="symbol">;</span>
219
+
220
+ <span class="normal"> </span><span class="function"><a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-Paths.html#cairo-move-to">cairo_move_to</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">cr</span><span class="symbol">,</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x</span><span class="symbol">,</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y</span><span class="symbol">);</span>
221
+ <span class="normal"> </span><span class="function"><a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-Paths.html#cairo-line-to">cairo_line_to</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">cr</span><span class="symbol">,</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x</span><span class="symbol">,</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">height</span><span class="symbol">);</span>
222
+ <span class="normal"> </span><span class="function"><a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-Paths.html#cairo-line-to">cairo_line_to</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">cr</span><span class="symbol">,</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">width</span><span class="symbol">,</span>
223
+ <span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">height</span><span class="symbol">);</span>
224
+ <span class="normal"> </span><span class="function"><a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-Paths.html#cairo-line-to">cairo_line_to</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">cr</span><span class="symbol">,</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">width</span><span class="symbol">,</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y</span><span class="symbol">);</span>
225
+ <span class="normal"> </span><span class="function"><a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-Paths.html#cairo-close-path">cairo_close_path</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">cr</span><span class="symbol">);</span>
226
+ <span class="normal"> </span><span class="function"><a href="GooCanvasStyle.html#goo-canvas-style-set-fill-options">goo_canvas_style_set_fill_options</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">simple</span><span class="symbol">-&gt;</span><span class="normal">simple_data</span><span class="symbol">-&gt;</span><span class="normal">style</span><span class="symbol">,</span><span class="normal"> cr</span><span class="symbol">);</span>
227
+ <span class="normal"> </span><span class="function"><a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-fill">cairo_fill</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">cr</span><span class="symbol">);</span>
228
+ <span class="cbracket">}</span>
229
+
230
+
231
+ <span class="keyword">static</span><span class="normal"> gboolean</span>
232
+ <span class="function">goo_demo_item_is_item_at</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="GooCanvasItemSimple.html">GooCanvasItemSimple</a> </span><span class="symbol">*</span><span class="normal">simple</span><span class="symbol">,</span>
233
+ <span class="normal"> gdouble x</span><span class="symbol">,</span>
234
+ <span class="normal"> gdouble y</span><span class="symbol">,</span>
235
+ <span class="normal"> <a href="/home/damon/gnome/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-t">cairo_t</a> </span><span class="symbol">*</span><span class="normal">cr</span><span class="symbol">,</span>
236
+ <span class="normal"> gboolean is_pointer_event</span><span class="symbol">)</span>
237
+ <span class="cbracket">{</span>
238
+ <span class="normal"> GooDemoItem </span><span class="symbol">*</span><span class="normal">demo_item </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">GooDemoItem</span><span class="symbol">*)</span><span class="normal"> simple</span><span class="symbol">;</span>
239
+
240
+ <span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">x </span><span class="symbol">&lt;</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x </span><span class="symbol">||</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">x </span><span class="symbol">&gt;</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">x </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">width</span><span class="symbol">)</span>
241
+ <span class="normal"> </span><span class="symbol">||</span><span class="normal"> y </span><span class="symbol">&lt;</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y </span><span class="symbol">||</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">y </span><span class="symbol">&gt;</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">y </span><span class="symbol">+</span><span class="normal"> demo_item</span><span class="symbol">-&gt;</span><span class="normal">height</span><span class="symbol">))</span>
242
+ <span class="normal"> </span><span class="keyword">return</span><span class="normal"> FALSE</span><span class="symbol">;</span>
243
+
244
+ <span class="normal"> </span><span class="keyword">return</span><span class="normal"> TRUE</span><span class="symbol">;</span>
245
+ <span class="cbracket">}</span></pre></td>
246
+ </tr>
247
+ </tbody>
248
+ </table>
249
+ </div>
250
+
251
+ <p>
252
+ </p>
253
+ <p>
254
+ As with the simple <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a> subclass, the item should
255
+ call <a class="link" href="GooCanvasItemSimple.html#goo-canvas-item-simple-changed" title="goo_canvas_item_simple_changed ()"><code class="function">goo_canvas_item_simple_changed()</code></a> whenever it is changed, to
256
+ ensure that the item's bounds are recomputed and it is repainted
257
+ if necessary.
258
+ </p>
259
+ </div>
260
+ <hr>
261
+ <div class="refsect2" title="Implementing the GooCanvasItem Interface">
262
+ <a name="implementing-interface"></a><h3>Implementing the GooCanvasItem Interface</h3>
263
+ <p>
264
+ The most complicated way to create new canvas items is to implement
265
+ the <a class="link" href="GooCanvasItem.html" title="GooCanvasItem"><span class="type">GooCanvasItem</span></a> interface directly. This should not be needed in
266
+ most cases, but may be desired if the developer wants to avoid the
267
+ memory and processor overheads associated with the <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a>
268
+ class, or if the developer wants to turn an existing application object
269
+ into a canvas item.
270
+ </p>
271
+ <p>
272
+ At a minimum the canvas item must implement these 6 methods:
273
+ </p>
274
+ <div class="itemizedlist"><ul class="itemizedlist" type="disc">
275
+ <li class="listitem"><p>
276
+ <code class="function">get_parent()</code> - the item's parent should be returned.
277
+ </p></li>
278
+ <li class="listitem"><p>
279
+ <code class="function">set_parent()</code> - the item's parent should be stored (though it
280
+ should not add a reference to the parent).
281
+ </p></li>
282
+ <li class="listitem"><p>
283
+ <code class="function">get_bounds()</code> - returns the bounds of the item, in canvas space.
284
+ The item should ensure that the bounds are up-to-date before
285
+ returning them, calling <a class="link" href="GooCanvasItem.html#goo-canvas-item-ensure-updated" title="goo_canvas_item_ensure_updated ()"><code class="function">goo_canvas_item_ensure_updated()</code></a> if
286
+ necessary.
287
+ </p></li>
288
+ <li class="listitem"><p>
289
+ <code class="function">update()</code> - if the item has been changed since the last update,
290
+ or if the entire_tree flag is <code class="literal">TRUE</code>, the item's bounds should
291
+ be recomputed (in canvas space). It should also request a redraw
292
+ of the old bounds and the new bounds, so the display is updated
293
+ appropriately. The new bounds should be returned in the bounds
294
+ argument.
295
+ </p></li>
296
+ <li class="listitem"><p>
297
+ <code class="function">paint()</code> - if the item's bounds intersect the given bounds then
298
+ the item should be painted on the given cairo context.
299
+ The scale parameter is only used to check if the item should be
300
+ visible, according to the item's <a class="link" href="GooCanvasItem.html#GooCanvasItem--visibility" title='The "visibility" property'><span class="type">"visibility"</span></a> and
301
+ <a class="link" href="GooCanvasItem.html#GooCanvasItem--visibility-threshold" title='The "visibility-threshold" property'><span class="type">"visibility-threshold"</span></a> property settings.
302
+ </p></li>
303
+ <li class="listitem"><p>
304
+ <code class="function">get_items_at()</code> - if the given point is inside the item then
305
+ a pointer to the item should be added to the start of the list
306
+ of found items. The list is then returned.
307
+ </p></li>
308
+ </ul></div>
309
+ <p>
310
+ </p>
311
+ <p>
312
+ The canvas item must also implement the
313
+ <a class="link" href="GooCanvasItem.html#GooCanvasItem--parent" title='The "parent" property'><span class="type">"parent"</span></a>, <a class="link" href="GooCanvasItem.html#GooCanvasItem--title" title='The "title" property'><span class="type">"title"</span></a>,
314
+ <a class="link" href="GooCanvasItem.html#GooCanvasItem--description" title='The "description" property'><span class="type">"description"</span></a>,
315
+ <a class="link" href="GooCanvasItem.html#GooCanvasItem--visibility" title='The "visibility" property'><span class="type">"visibility"</span></a>, <a class="link" href="GooCanvasItem.html#GooCanvasItem--visibility-threshold" title='The "visibility-threshold" property'><span class="type">"visibility-threshold"</span></a>,
316
+ <a class="link" href="GooCanvasItem.html#GooCanvasItem--transform" title='The "transform" property'><span class="type">"transform"</span></a> and <a class="link" href="GooCanvasItem.html#GooCanvasItem--pointer-events" title='The "pointer-events" property'><span class="type">"pointer-events"</span></a> properties.
317
+ (The last 4 properties can simply be ignored if the application
318
+ doesn't intend to use them.)
319
+ </p>
320
+ <p>
321
+ If the canvas item will be used within a container that does item
322
+ layout, such as <a class="link" href="GooCanvasTable.html" title="GooCanvasTable"><span class="type">GooCanvasTable</span></a>, it must implement the first two
323
+ methods here at least:
324
+ </p>
325
+ <div class="itemizedlist"><ul class="itemizedlist" type="disc">
326
+ <li class="listitem"><p>
327
+ <code class="function">get_requested_area()</code> - returns the requested area of the item,
328
+ in the parent's coordinate space.
329
+ </p></li>
330
+ <li class="listitem"><p>
331
+ <code class="function">allocate_area()</code> - allocates the item's area, in the parent's
332
+ coordinate space.
333
+ </p></li>
334
+ <li class="listitem"><p>
335
+ <code class="function">get_requested_height()</code> - returns the requested height of the
336
+ item, given a particular allocated width, in the parent's
337
+ coordinate space. (This only needed for items that change height
338
+ as their width is changed, such as text items.)
339
+ </p></li>
340
+ </ul></div>
341
+ <p>
342
+ </p>
343
+ <p>
344
+ If the canvas item supports a transformation matrix it must implement:
345
+ </p>
346
+ <div class="itemizedlist"><ul class="itemizedlist" type="disc">
347
+ <li class="listitem"><p>
348
+ <code class="function">get_transform()</code> - returns the item's transformation matrix.
349
+ </p></li>
350
+ <li class="listitem"><p>
351
+ <code class="function">set_transform()</code> - sets the item's transformation matrix.
352
+ </p></li>
353
+ </ul></div>
354
+ <p>
355
+ </p>
356
+ <p>
357
+ If the canvas item supports a <a class="link" href="GooCanvasStyle.html" title="GooCanvasStyle"><span class="type">GooCanvasStyle</span></a> setting, it must
358
+ implement:
359
+ </p>
360
+ <div class="itemizedlist"><ul class="itemizedlist" type="disc">
361
+ <li class="listitem"><p>
362
+ <code class="function">get_style()</code> - returns the item's style.
363
+ </p></li>
364
+ <li class="listitem"><p>
365
+ <code class="function">set_style()</code> - sets the item's style.
366
+ </p></li>
367
+ </ul></div>
368
+ <p>
369
+ </p>
370
+ <p>
371
+ Since <a class="link" href="GooCanvasItemSimple.html" title="GooCanvasItemSimple"><span class="type">GooCanvasItemSimple</span></a> implements most of the above methods and
372
+ properties its source code is a good place to look for help.
373
+ </p>
374
+ </div>
375
+ <hr>
376
+ <div class="refsect2" title="Creating Item Models">
377
+ <a name="creating-item-models"></a><h3>Creating Item Models</h3>
378
+ <p>
379
+ As with creating canvas items, to create item models it
380
+ is possible to subclass <a class="link" href="GooCanvasItemModelSimple.html" title="GooCanvasItemModelSimple"><span class="type">GooCanvasItemModelSimple</span></a> or to
381
+ implement the <a class="link" href="GooCanvasItemModel.html" title="GooCanvasItemModel"><span class="type">GooCanvasItemModel</span></a> interface directly.
382
+ </p>
383
+ <p>
384
+ Subclassing <a class="link" href="GooCanvasItemModelSimple.html" title="GooCanvasItemModelSimple"><span class="type">GooCanvasItemModelSimple</span></a> is very easy, since only one
385
+ method from the <a class="link" href="GooCanvasItemModel.html" title="GooCanvasItemModel"><span class="type">GooCanvasItemModel</span></a> interface must be implemented -
386
+ <code class="function">create_item()</code>. This should return a new canvas item for viewing the
387
+ item model in a canvas. (It may be called multiple times if multiple
388
+ canvases are viewing the same canvas model.)
389
+ </p>
390
+ <p>
391
+ The <a class="link" href="GooCanvasItemModelSimple.html" title="GooCanvasItemModelSimple"><span class="type">GooCanvasItemModelSimple</span></a> subclass should emit the "changed"
392
+ signal whenever it has changed, with a boolean flag indicating if
393
+ the bounds need to be recomputed. The canvas items will connect to
394
+ this signal and request an update or a redraw as appropriate.
395
+ </p>
396
+ <p>
397
+ To implement the <a class="link" href="GooCanvasItemModel.html" title="GooCanvasItemModel"><span class="type">GooCanvasItemModel</span></a> interface directly, the class
398
+ must implement the <code class="function">get_parent()</code>, <code class="function">set_parent()</code> and <code class="function">create_item()</code>
399
+ methods. It may also implement <code class="function">get_transform()</code>, <code class="function">set_transform()</code>,
400
+ <code class="function">get_style()</code> and <code class="function">set_style()</code> methods if desired.
401
+ </p>
402
+ <p>
403
+ The class must also implement the
404
+ <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--parent" title='The "parent" property'><span class="type">"parent"</span></a>, <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--title" title='The "title" property'><span class="type">"title"</span></a>,
405
+ <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--description" title='The "description" property'><span class="type">"description"</span></a>, <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--can-focus" title='The "can-focus" property'><span class="type">"can-focus"</span></a>,
406
+ <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--visibility" title='The "visibility" property'><span class="type">"visibility"</span></a>,
407
+ <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--visibility-threshold" title='The "visibility-threshold" property'><span class="type">"visibility-threshold"</span></a>,
408
+ <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--transform" title='The "transform" property'><span class="type">"transform"</span></a> and <a class="link" href="GooCanvasItemModel.html#GooCanvasItemModel--pointer-events" title='The "pointer-events" property'><span class="type">"pointer-events"</span></a>
409
+ properties.
410
+ (The last 4 properties can simply be ignored if the application
411
+ doesn't intend to use them.)
412
+ </p>
413
+ </div>
414
+ </div>
415
+ </div>
416
+ <div class="footer">
417
+ <hr>
418
+ Generated by GTK-Doc V1.14</div>
419
+ </body>
420
+ </html>