gtk2 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. data/ChangeLog +6664 -0
  2. data/README +33 -0
  3. data/Rakefile +71 -0
  4. data/extconf.rb +116 -0
  5. data/src/global.h +33 -0
  6. data/src/init.c +39 -0
  7. data/src/lib/gtk2.rb +13 -0
  8. data/src/lib/gtk2/base.rb +95 -0
  9. data/src/makeinits.rb +57 -0
  10. data/src/makekeysyms.rb +5 -0
  11. data/src/rbgdk.c +395 -0
  12. data/src/rbgdk.h +50 -0
  13. data/src/rbgdkatom.c +122 -0
  14. data/src/rbgdkcairo.c +100 -0
  15. data/src/rbgdkcolor.c +151 -0
  16. data/src/rbgdkcolormap.c +142 -0
  17. data/src/rbgdkconst.c +29 -0
  18. data/src/rbgdkconversions.h +18 -0
  19. data/src/rbgdkcursor.c +115 -0
  20. data/src/rbgdkdevice.c +235 -0
  21. data/src/rbgdkdisplay.c +634 -0
  22. data/src/rbgdkdisplaymanager.c +50 -0
  23. data/src/rbgdkdragcontext.c +280 -0
  24. data/src/rbgdkdraw.c +487 -0
  25. data/src/rbgdkevent.c +1020 -0
  26. data/src/rbgdkgc.c +456 -0
  27. data/src/rbgdkgeometry.c +272 -0
  28. data/src/rbgdkimage.c +155 -0
  29. data/src/rbgdkinput.c +70 -0
  30. data/src/rbgdkkeymap.c +153 -0
  31. data/src/rbgdkkeysyms.h +2174 -0
  32. data/src/rbgdkkeyval.c +105 -0
  33. data/src/rbgdkpango.c +171 -0
  34. data/src/rbgdkpangorenderer.c +132 -0
  35. data/src/rbgdkpixbuf.c +178 -0
  36. data/src/rbgdkpixmap.c +255 -0
  37. data/src/rbgdkproperty.c +342 -0
  38. data/src/rbgdkrectangle.c +146 -0
  39. data/src/rbgdkregion.c +242 -0
  40. data/src/rbgdkrgb.c +197 -0
  41. data/src/rbgdkscreen.c +535 -0
  42. data/src/rbgdkselection.c +161 -0
  43. data/src/rbgdkthreads.c +68 -0
  44. data/src/rbgdktimecoord.c +118 -0
  45. data/src/rbgdkvisual.c +273 -0
  46. data/src/rbgdkwindow.c +1302 -0
  47. data/src/rbgdkwindowattr.c +213 -0
  48. data/src/rbgdkx11.c +256 -0
  49. data/src/rbgtk.c +93 -0
  50. data/src/rbgtk.h +121 -0
  51. data/src/rbgtkaboutdialog.c +195 -0
  52. data/src/rbgtkaccelerator.c +78 -0
  53. data/src/rbgtkaccelgroup.c +216 -0
  54. data/src/rbgtkaccelgroupentry.c +85 -0
  55. data/src/rbgtkaccelkey.c +116 -0
  56. data/src/rbgtkaccellabel.c +46 -0
  57. data/src/rbgtkaccelmap.c +162 -0
  58. data/src/rbgtkaccessible.c +29 -0
  59. data/src/rbgtkaction.c +277 -0
  60. data/src/rbgtkactiongroup.c +377 -0
  61. data/src/rbgtkadjustment.c +153 -0
  62. data/src/rbgtkalignment.c +71 -0
  63. data/src/rbgtkallocation.c +171 -0
  64. data/src/rbgtkarrow.c +47 -0
  65. data/src/rbgtkaspectframe.c +46 -0
  66. data/src/rbgtkassistant.c +230 -0
  67. data/src/rbgtkbbox.c +47 -0
  68. data/src/rbgtkbin.c +31 -0
  69. data/src/rbgtkbindingset.c +192 -0
  70. data/src/rbgtkborder.c +80 -0
  71. data/src/rbgtkbox.c +142 -0
  72. data/src/rbgtkbuildable.c +115 -0
  73. data/src/rbgtkbuilder.c +154 -0
  74. data/src/rbgtkbutton.c +151 -0
  75. data/src/rbgtkcalendar.c +159 -0
  76. data/src/rbgtkcelleditable.c +49 -0
  77. data/src/rbgtkcelllayout.c +144 -0
  78. data/src/rbgtkcellrenderer.c +139 -0
  79. data/src/rbgtkcellrendereraccel.c +42 -0
  80. data/src/rbgtkcellrenderercombo.c +37 -0
  81. data/src/rbgtkcellrendererpixbuf.c +33 -0
  82. data/src/rbgtkcellrendererprogress.c +37 -0
  83. data/src/rbgtkcellrendererspin.c +38 -0
  84. data/src/rbgtkcellrenderertext.c +45 -0
  85. data/src/rbgtkcellrenderertoggle.c +32 -0
  86. data/src/rbgtkcellview.c +134 -0
  87. data/src/rbgtkcheckbutton.c +55 -0
  88. data/src/rbgtkcheckmenuitem.c +56 -0
  89. data/src/rbgtkclipboard.c +473 -0
  90. data/src/rbgtkcolorbutton.c +63 -0
  91. data/src/rbgtkcolorsel.c +175 -0
  92. data/src/rbgtkcolorselectiondialog.c +72 -0
  93. data/src/rbgtkcombo.c +117 -0
  94. data/src/rbgtkcombobox.c +240 -0
  95. data/src/rbgtkcomboboxentry.c +60 -0
  96. data/src/rbgtkconst.c +163 -0
  97. data/src/rbgtkcontainer.c +776 -0
  98. data/src/rbgtkconversions.h +26 -0
  99. data/src/rbgtkcurve.c +105 -0
  100. data/src/rbgtkdialog.c +244 -0
  101. data/src/rbgtkdrag.c +436 -0
  102. data/src/rbgtkdrawingarea.c +31 -0
  103. data/src/rbgtkeditable.c +152 -0
  104. data/src/rbgtkentry.c +161 -0
  105. data/src/rbgtkentrycompletion.c +167 -0
  106. data/src/rbgtkeventbox.c +31 -0
  107. data/src/rbgtkexpander.c +67 -0
  108. data/src/rbgtkfilechooser.c +403 -0
  109. data/src/rbgtkfilechooserbutton.c +72 -0
  110. data/src/rbgtkfilechooserdialog.c +58 -0
  111. data/src/rbgtkfilechooserwidget.c +50 -0
  112. data/src/rbgtkfilefilter.c +139 -0
  113. data/src/rbgtkfilesel.c +155 -0
  114. data/src/rbgtkfixed.c +72 -0
  115. data/src/rbgtkfontbutton.c +69 -0
  116. data/src/rbgtkfontselection.c +30 -0
  117. data/src/rbgtkfontselectiondialog.c +106 -0
  118. data/src/rbgtkframe.c +64 -0
  119. data/src/rbgtkgamma.c +47 -0
  120. data/src/rbgtkhandlebox.c +42 -0
  121. data/src/rbgtkhbbox.c +31 -0
  122. data/src/rbgtkhbox.c +38 -0
  123. data/src/rbgtkhpaned.c +31 -0
  124. data/src/rbgtkhruler.c +31 -0
  125. data/src/rbgtkhscale.c +45 -0
  126. data/src/rbgtkhscrollbar.c +38 -0
  127. data/src/rbgtkhseparator.c +30 -0
  128. data/src/rbgtkiconfactory.c +80 -0
  129. data/src/rbgtkiconinfo.c +118 -0
  130. data/src/rbgtkiconset.c +87 -0
  131. data/src/rbgtkiconsize.c +90 -0
  132. data/src/rbgtkiconsource.c +176 -0
  133. data/src/rbgtkicontheme.c +309 -0
  134. data/src/rbgtkiconview.c +351 -0
  135. data/src/rbgtkimage.c +152 -0
  136. data/src/rbgtkimagemenuitem.c +52 -0
  137. data/src/rbgtkimcontext.c +134 -0
  138. data/src/rbgtkimcontextsimple.c +48 -0
  139. data/src/rbgtkimmulticontext.c +38 -0
  140. data/src/rbgtkinits.c +473 -0
  141. data/src/rbgtkinputdialog.c +30 -0
  142. data/src/rbgtkinvisible.c +68 -0
  143. data/src/rbgtkitem.c +51 -0
  144. data/src/rbgtkitemfactory.c +312 -0
  145. data/src/rbgtklabel.c +168 -0
  146. data/src/rbgtklayout.c +91 -0
  147. data/src/rbgtklinkbutton.c +68 -0
  148. data/src/rbgtkliststore.c +412 -0
  149. data/src/rbgtkmacros.h +26 -0
  150. data/src/rbgtkmain.c +532 -0
  151. data/src/rbgtkmenu.c +272 -0
  152. data/src/rbgtkmenubar.c +48 -0
  153. data/src/rbgtkmenuitem.c +171 -0
  154. data/src/rbgtkmenushell.c +128 -0
  155. data/src/rbgtkmenutoolbutton.c +74 -0
  156. data/src/rbgtkmessagedialog.c +102 -0
  157. data/src/rbgtkmisc.c +63 -0
  158. data/src/rbgtknotebook.c +484 -0
  159. data/src/rbgtkobject.c +186 -0
  160. data/src/rbgtkoptionmenu.c +65 -0
  161. data/src/rbgtkpagesetup.c +196 -0
  162. data/src/rbgtkpagesetupunixdialog.c +80 -0
  163. data/src/rbgtkpaned.c +114 -0
  164. data/src/rbgtkpapersize.c +186 -0
  165. data/src/rbgtkplug.c +84 -0
  166. data/src/rbgtkprintcontext.c +124 -0
  167. data/src/rbgtkprinter.c +155 -0
  168. data/src/rbgtkprintjob.c +151 -0
  169. data/src/rbgtkprintoperation.c +152 -0
  170. data/src/rbgtkprintoperationpreview.c +54 -0
  171. data/src/rbgtkprintsettings.c +794 -0
  172. data/src/rbgtkprintunixdialog.c +98 -0
  173. data/src/rbgtkprogress.c +21 -0
  174. data/src/rbgtkprogressbar.c +72 -0
  175. data/src/rbgtkradioaction.c +102 -0
  176. data/src/rbgtkradiobutton.c +83 -0
  177. data/src/rbgtkradiomenuitem.c +115 -0
  178. data/src/rbgtkradiotoolbutton.c +99 -0
  179. data/src/rbgtkrange.c +98 -0
  180. data/src/rbgtkrc.c +228 -0
  181. data/src/rbgtkrcstyle.c +184 -0
  182. data/src/rbgtkrecentaction.c +52 -0
  183. data/src/rbgtkrecentchooser.c +276 -0
  184. data/src/rbgtkrecentchooserdialog.c +59 -0
  185. data/src/rbgtkrecentchoosermenu.c +55 -0
  186. data/src/rbgtkrecentchooserwidget.c +45 -0
  187. data/src/rbgtkrecentdata.c +152 -0
  188. data/src/rbgtkrecentfilter.c +180 -0
  189. data/src/rbgtkrecentfilterinfo.c +197 -0
  190. data/src/rbgtkrecentinfo.c +232 -0
  191. data/src/rbgtkrecentmanager.c +164 -0
  192. data/src/rbgtkruler.c +82 -0
  193. data/src/rbgtkscale.c +47 -0
  194. data/src/rbgtkscalebutton.c +115 -0
  195. data/src/rbgtkscrollbar.c +21 -0
  196. data/src/rbgtkscrolledwindow.c +160 -0
  197. data/src/rbgtkselection.c +171 -0
  198. data/src/rbgtkselectiondata.c +333 -0
  199. data/src/rbgtkseparator.c +21 -0
  200. data/src/rbgtkseparatormenuitem.c +28 -0
  201. data/src/rbgtkseparatortoolitem.c +40 -0
  202. data/src/rbgtksettings.c +225 -0
  203. data/src/rbgtksizegroup.c +74 -0
  204. data/src/rbgtksocket.c +72 -0
  205. data/src/rbgtkspinbutton.c +138 -0
  206. data/src/rbgtkstatusbar.c +90 -0
  207. data/src/rbgtkstatusicon.c +120 -0
  208. data/src/rbgtkstock.c +264 -0
  209. data/src/rbgtkstyle.c +722 -0
  210. data/src/rbgtktable.c +190 -0
  211. data/src/rbgtktargetlist.c +148 -0
  212. data/src/rbgtktearoffmenuitem.c +30 -0
  213. data/src/rbgtktextappearance.c +173 -0
  214. data/src/rbgtktextattributes.c +209 -0
  215. data/src/rbgtktextbuffer.c +993 -0
  216. data/src/rbgtktextchild.c +49 -0
  217. data/src/rbgtktextiter.c +553 -0
  218. data/src/rbgtktextmark.c +87 -0
  219. data/src/rbgtktexttag.c +66 -0
  220. data/src/rbgtktexttagtable.c +94 -0
  221. data/src/rbgtktextview.c +351 -0
  222. data/src/rbgtktoggleaction.c +76 -0
  223. data/src/rbgtktogglebutton.c +84 -0
  224. data/src/rbgtktoggletoolbutton.c +70 -0
  225. data/src/rbgtktoolbar.c +373 -0
  226. data/src/rbgtktoolbutton.c +75 -0
  227. data/src/rbgtktoolitem.c +184 -0
  228. data/src/rbgtktooltip.c +76 -0
  229. data/src/rbgtktooltips.c +107 -0
  230. data/src/rbgtktreedragdest.c +19 -0
  231. data/src/rbgtktreedragsource.c +19 -0
  232. data/src/rbgtktreeiter.c +259 -0
  233. data/src/rbgtktreemodel.c +256 -0
  234. data/src/rbgtktreemodelfilter.c +214 -0
  235. data/src/rbgtktreemodelsort.c +113 -0
  236. data/src/rbgtktreepath.c +195 -0
  237. data/src/rbgtktreerowreference.c +168 -0
  238. data/src/rbgtktreeselection.c +235 -0
  239. data/src/rbgtktreesortable.c +127 -0
  240. data/src/rbgtktreestore.c +379 -0
  241. data/src/rbgtktreeview.c +881 -0
  242. data/src/rbgtktreeviewcolumn.c +331 -0
  243. data/src/rbgtkuimanager.c +210 -0
  244. data/src/rbgtkvbbox.c +31 -0
  245. data/src/rbgtkvbox.c +38 -0
  246. data/src/rbgtkviewport.c +33 -0
  247. data/src/rbgtkvolumebutton.c +36 -0
  248. data/src/rbgtkvpaned.c +31 -0
  249. data/src/rbgtkvruler.c +30 -0
  250. data/src/rbgtkvscale.c +45 -0
  251. data/src/rbgtkvscrollbar.c +38 -0
  252. data/src/rbgtkvseparator.c +30 -0
  253. data/src/rbgtkwidget.c +1414 -0
  254. data/src/rbgtkwindow.c +822 -0
  255. data/src/rbgtkwindowgroup.c +48 -0
  256. data/test/gtk-test-utils.rb +15 -0
  257. data/test/run-test.rb +30 -0
  258. data/test/test_gc.rb +25 -0
  259. data/test/test_gdk.rb +18 -0
  260. data/test/test_gdk_color.rb +10 -0
  261. data/test/test_gdk_display.rb +37 -0
  262. data/test/test_gdk_event.rb +11 -0
  263. data/test/test_gdk_gc.rb +7 -0
  264. data/test/test_gdk_keymap.rb +8 -0
  265. data/test/test_gdk_pango.rb +9 -0
  266. data/test/test_gdk_selection_data.rb +17 -0
  267. data/test/test_gdk_window.rb +29 -0
  268. data/test/test_gdk_window_attribute.rb +9 -0
  269. data/test/test_gtk_about_dialog.rb +14 -0
  270. data/test/test_gtk_buildable.rb +66 -0
  271. data/test/test_gtk_builder.rb +188 -0
  272. data/test/test_gtk_entry.rb +18 -0
  273. data/test/test_gtk_icon_theme.rb +30 -0
  274. data/test/test_gtk_image.rb +8 -0
  275. data/test/test_gtk_list_store.rb +65 -0
  276. data/test/test_gtk_menu_item.rb +13 -0
  277. data/test/test_gtk_rc_style.rb +14 -0
  278. data/test/test_gtk_tree_path.rb +20 -0
  279. data/test/test_gtk_unix_print.rb +14 -0
  280. data/test/test_gtk_widget.rb +32 -0
  281. metadata +393 -0
@@ -0,0 +1,146 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkrectangle.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2003/01/12 18:09:10 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+
11
+ This file is derived from rbgdkregion.c.
12
+ rbgdkregion.c -
13
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
14
+ Daisuke Kanda,
15
+ Hiroshi Igarashi
16
+ ************************************************/
17
+
18
+ #include "global.h"
19
+
20
+ #define _SELF(r) ((GdkRectangle*)RVAL2BOXED(r, GDK_TYPE_RECTANGLE))
21
+
22
+ static VALUE
23
+ gdkrect_initialize(self, x, y, width, height)
24
+ VALUE self, x, y, width, height;
25
+ {
26
+ GdkRectangle new;
27
+
28
+ new.x = NUM2INT(x);
29
+ new.y = NUM2INT(y);
30
+ new.width = NUM2INT(width);
31
+ new.height = NUM2INT(height);
32
+
33
+ G_INITIALIZE(self, &new);
34
+ return Qnil;
35
+ }
36
+
37
+ static VALUE
38
+ gdkrect_intersect(self, other)
39
+ VALUE self, other;
40
+ {
41
+ GdkRectangle dest;
42
+ gboolean ret = gdk_rectangle_intersect(_SELF(self), _SELF(other), &dest);
43
+ return ret ? BOXED2RVAL(&dest, GDK_TYPE_RECTANGLE) : Qnil;
44
+ }
45
+
46
+ static VALUE
47
+ gdkrect_union(self, other)
48
+ VALUE self, other;
49
+ {
50
+ GdkRectangle dest;
51
+ gdk_rectangle_union(_SELF(self), _SELF(other), &dest);
52
+ return BOXED2RVAL(&dest, GDK_TYPE_RECTANGLE);
53
+ }
54
+
55
+ /* Struct accessors */
56
+ static VALUE
57
+ gdkrect_x(self)
58
+ VALUE self;
59
+ {
60
+ return INT2NUM(_SELF(self)->x);
61
+ }
62
+
63
+ static VALUE
64
+ gdkrect_y(self)
65
+ VALUE self;
66
+ {
67
+ return INT2NUM(_SELF(self)->y);
68
+ }
69
+
70
+ static VALUE
71
+ gdkrect_w(self)
72
+ VALUE self;
73
+ {
74
+ return INT2NUM(_SELF(self)->width);
75
+ }
76
+
77
+ static VALUE
78
+ gdkrect_h(self)
79
+ VALUE self;
80
+ {
81
+ return INT2NUM(_SELF(self)->height);
82
+ }
83
+
84
+ static VALUE
85
+ gdkrect_set_x(self, x)
86
+ VALUE self, x;
87
+ {
88
+ _SELF(self)->x = NUM2INT(x);
89
+ return self;
90
+ }
91
+
92
+ static VALUE
93
+ gdkrect_set_y(self, y)
94
+ VALUE self, y;
95
+ {
96
+ _SELF(self)->y = NUM2INT(y);
97
+ return self;
98
+ }
99
+
100
+ static VALUE
101
+ gdkrect_set_w(self, width)
102
+ VALUE self, width;
103
+ {
104
+ _SELF(self)->width = NUM2INT(width);
105
+ return self;
106
+ }
107
+
108
+ static VALUE
109
+ gdkrect_set_h(self, height)
110
+ VALUE self, height;
111
+ {
112
+ _SELF(self)->height = NUM2INT(height);
113
+ return self;
114
+ }
115
+
116
+ static VALUE
117
+ gdkrect_to_a(self)
118
+ VALUE self;
119
+ {
120
+ GdkRectangle* a = _SELF(self);
121
+ return rb_ary_new3(4, INT2FIX(a->x), INT2FIX(a->y),
122
+ INT2FIX(a->width), INT2FIX(a->height));
123
+ }
124
+
125
+ void
126
+ Init_gtk_gdk_rectangle()
127
+ {
128
+ VALUE gdkRectangle = G_DEF_CLASS(GDK_TYPE_RECTANGLE, "Rectangle", mGdk);
129
+
130
+ rb_define_method(gdkRectangle, "initialize", gdkrect_initialize, 4);
131
+ rb_define_method(gdkRectangle, "intersect", gdkrect_intersect, 1);
132
+ rb_define_alias(gdkRectangle, "&", "intersect");
133
+ rb_define_method(gdkRectangle, "union", gdkrect_union, 1);
134
+ rb_define_alias(gdkRectangle, "|", "union");
135
+ rb_define_method(gdkRectangle, "x", gdkrect_x, 0);
136
+ rb_define_method(gdkRectangle, "y", gdkrect_y, 0);
137
+ rb_define_method(gdkRectangle, "width", gdkrect_w, 0);
138
+ rb_define_method(gdkRectangle, "height", gdkrect_h, 0);
139
+ rb_define_method(gdkRectangle, "set_x", gdkrect_set_x, 1);
140
+ rb_define_method(gdkRectangle, "set_y", gdkrect_set_y, 1);
141
+ rb_define_method(gdkRectangle, "set_width", gdkrect_set_w, 1);
142
+ rb_define_method(gdkRectangle, "set_height", gdkrect_set_h, 1);
143
+ rb_define_method(gdkRectangle, "to_a", gdkrect_to_a, 0);
144
+
145
+ G_DEF_SETTERS(gdkRectangle);
146
+ }
@@ -0,0 +1,242 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkregion.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:31 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
+ Daisuke Kanda,
12
+ Hiroshi Igarashi
13
+ ************************************************/
14
+ #include "global.h"
15
+
16
+ #define _SELF(r) ((GdkRegion*)RVAL2BOXED(r, GDK_TYPE_REGION))
17
+
18
+ /**********************************/
19
+ GType
20
+ gdk_region_get_type(void)
21
+ {
22
+ static GType our_type = 0;
23
+
24
+ if (our_type == 0)
25
+ our_type = g_boxed_type_register_static ("GdkRegion",
26
+ (GBoxedCopyFunc)gdk_region_copy,
27
+ (GBoxedFreeFunc)gdk_region_destroy);
28
+ return our_type;
29
+ }
30
+ /**********************************/
31
+ static VALUE
32
+ gdkregion_initialize(argc, argv, self)
33
+ int argc;
34
+ VALUE *argv;
35
+ VALUE self;
36
+ {
37
+ VALUE points_or_rectangle, fill_rule;
38
+ GdkRegion* region;
39
+ GdkPoint *gpoints;
40
+ int i;
41
+
42
+ rb_scan_args(argc, argv, "02", &points_or_rectangle, &fill_rule);
43
+ if (NIL_P(points_or_rectangle)){
44
+ region = gdk_region_new();
45
+ } else if (TYPE(points_or_rectangle) == T_ARRAY){
46
+ gpoints = ALLOCA_N(GdkPoint, RARRAY_LEN(points_or_rectangle));
47
+
48
+ for (i = 0; i < RARRAY_LEN(points_or_rectangle); i++) {
49
+ Check_Type(RARRAY_PTR(points_or_rectangle)[i], T_ARRAY);
50
+ if (RARRAY_LEN(RARRAY_PTR(points_or_rectangle)[i]) < 2) {
51
+ rb_raise(rb_eArgError, "point %d should be array of size 2", i);
52
+ }
53
+ gpoints[i].x = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[0]);
54
+ gpoints[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[1]);
55
+ }
56
+ region = gdk_region_polygon(gpoints, RARRAY_LEN(points_or_rectangle),
57
+ RVAL2GENUM(fill_rule, GDK_TYPE_FILL_RULE));
58
+ } else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE){
59
+ region = gdk_region_rectangle((GdkRectangle*)RVAL2BOXED(points_or_rectangle,
60
+ GDK_TYPE_RECTANGLE));
61
+ } else {
62
+ rb_raise(rb_eArgError,
63
+ "invalid argument %s (expect array of Gdk::Point or Gdk::Rectangle, nil)",
64
+ rb_class2name(CLASS_OF(points_or_rectangle)));
65
+ }
66
+
67
+ G_INITIALIZE(self, region);
68
+ return Qnil;
69
+ }
70
+
71
+ static VALUE
72
+ gdkregion_get_rectangles(self)
73
+ VALUE self;
74
+ {
75
+ GdkRectangle* rectangles;
76
+ gint n_rect, i;
77
+ VALUE ary;
78
+
79
+ gdk_region_get_rectangles(_SELF(self), &rectangles, &n_rect);
80
+ ary = rb_ary_new2(n_rect);
81
+ for (i = 0; i < n_rect; i++) {
82
+ rb_ary_push(ary, BOXED2RVAL(&rectangles[i], GDK_TYPE_RECTANGLE));
83
+ }
84
+ g_free(rectangles);
85
+ return ary;
86
+ }
87
+
88
+ static void
89
+ gdkregion_span_func(span, func)
90
+ GdkSpan* span;
91
+ gpointer func;
92
+ {
93
+ rb_funcall((VALUE)func, id_call, 3,
94
+ INT2NUM(span->x), INT2NUM(span->y), INT2NUM(span->width));
95
+ }
96
+
97
+ static VALUE
98
+ gdkregion_spans_intersect_foreach(self, spans, sorted)
99
+ VALUE self, spans, sorted;
100
+ {
101
+ int i;
102
+ GdkSpan* gspans = ALLOCA_N(GdkSpan, RARRAY_LEN(spans));
103
+ volatile VALUE func = rb_block_proc();
104
+
105
+ G_RELATIVE(self, func);
106
+ for (i = 0; i < RARRAY_LEN(spans); i++) {
107
+ gspans[i].x = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[0]);
108
+ gspans[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[1]);
109
+ gspans[i].width = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[2]);
110
+ }
111
+ gdk_region_spans_intersect_foreach(_SELF(self),
112
+ gspans, RARRAY_LEN(spans), RVAL2CBOOL(sorted),
113
+ (GdkSpanFunc)gdkregion_span_func, (gpointer)func);
114
+ return self;
115
+ }
116
+
117
+ static VALUE
118
+ gdkregion_get_clipbox(self)
119
+ VALUE self;
120
+ {
121
+ GdkRectangle rect;
122
+ gdk_region_get_clipbox(_SELF(self), &rect);
123
+ return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE);
124
+ }
125
+
126
+ static VALUE
127
+ gdkregion_empty(self)
128
+ VALUE self;
129
+ {
130
+ return CBOOL2RVAL(gdk_region_empty(_SELF(self)));
131
+ }
132
+
133
+ static VALUE
134
+ gdkregion_equal(self, obj)
135
+ VALUE self, obj;
136
+ {
137
+ if (!rb_obj_is_instance_of(obj, GTYPE2CLASS(GDK_TYPE_REGION))) {
138
+ return Qnil;
139
+ }
140
+ return CBOOL2RVAL(gdk_region_equal(_SELF(self), _SELF(obj)));
141
+ }
142
+
143
+ static VALUE
144
+ gdkregion_point_in(self, x, y)
145
+ VALUE self, x, y;
146
+ {
147
+ return CBOOL2RVAL(gdk_region_point_in(_SELF(self), NUM2INT(x),
148
+ NUM2INT(y)));
149
+ }
150
+
151
+ static VALUE
152
+ gdkregion_rect_in(self, rect)
153
+ VALUE self, rect;
154
+ {
155
+ return GENUM2RVAL(gdk_region_rect_in(
156
+ _SELF(self),
157
+ (GdkRectangle*)RVAL2BOXED(rect, GDK_TYPE_RECTANGLE)),
158
+ GDK_TYPE_OVERLAP_TYPE);
159
+ }
160
+
161
+ static VALUE
162
+ gdkregion_offset(self, dx, dy)
163
+ VALUE self, dx, dy;
164
+ {
165
+ gdk_region_offset(_SELF(self), NUM2INT(dx), NUM2INT(dy));
166
+ return self;
167
+ }
168
+
169
+ static VALUE
170
+ gdkregion_shrink(self, dx, dy)
171
+ VALUE self, dx, dy;
172
+ {
173
+ gdk_region_shrink(_SELF(self), NUM2INT(dx), NUM2INT(dy));
174
+ return self;
175
+ }
176
+
177
+ static VALUE
178
+ gdkregion_intersect(self, region)
179
+ VALUE self, region;
180
+ {
181
+ gdk_region_intersect(_SELF(self), _SELF(region));
182
+ return self;
183
+ }
184
+
185
+ static VALUE
186
+ gdkregion_union(self, other)
187
+ VALUE self, other;
188
+ {
189
+ if (RVAL2GTYPE(other) == GDK_TYPE_RECTANGLE){
190
+ gdk_region_union_with_rect(_SELF(self),
191
+ (GdkRectangle*)RVAL2BOXED(other, GDK_TYPE_RECTANGLE));
192
+ } else {
193
+ gdk_region_union(_SELF(self), _SELF(other));
194
+ }
195
+ return self;
196
+ }
197
+
198
+ static VALUE
199
+ gdkregion_subtract(self, region)
200
+ VALUE self, region;
201
+ {
202
+ gdk_region_subtract(_SELF(self), _SELF(region));
203
+ return self;
204
+ }
205
+
206
+ static VALUE
207
+ gdkregion_xor(self, region)
208
+ VALUE self, region;
209
+ {
210
+ gdk_region_xor(_SELF(self), _SELF(region));
211
+ return self;
212
+ }
213
+
214
+
215
+ void
216
+ Init_gtk_gdk_region()
217
+ {
218
+ VALUE gdkRegion = G_DEF_CLASS(GDK_TYPE_REGION, "Region", mGdk);
219
+
220
+ rb_define_method(gdkRegion, "initialize", gdkregion_initialize, -1);
221
+ rb_define_method(gdkRegion, "rectangles", gdkregion_get_rectangles, 0);
222
+ rb_define_method(gdkRegion, "spans_intersect_each", gdkregion_spans_intersect_foreach, 2);
223
+ rb_define_method(gdkRegion, "clipbox", gdkregion_get_clipbox, 0);
224
+ rb_define_method(gdkRegion, "empty?", gdkregion_empty, 0);
225
+ rb_define_method(gdkRegion, "==", gdkregion_equal, 1);
226
+ rb_define_method(gdkRegion, "point_in?", gdkregion_point_in, 2);
227
+ rb_define_method(gdkRegion, "rect_in", gdkregion_rect_in, 1);
228
+ rb_define_method(gdkRegion, "offset", gdkregion_offset, 2);
229
+ rb_define_method(gdkRegion, "shrink", gdkregion_shrink, 2);
230
+ rb_define_method(gdkRegion, "intersect", gdkregion_intersect, 1);
231
+ rb_define_method(gdkRegion, "union", gdkregion_union, 1);
232
+ rb_define_method(gdkRegion, "subtract", gdkregion_subtract, 1);
233
+ rb_define_method(gdkRegion, "xor", gdkregion_xor, 1);
234
+
235
+ /* GdkOverlapType */
236
+ G_DEF_CLASS(GDK_TYPE_OVERLAP_TYPE, "OverlapType", gdkRegion);
237
+ G_DEF_CONSTANTS(gdkRegion, GDK_TYPE_OVERLAP_TYPE, "GDK_");
238
+
239
+ /* GdkFillRule */
240
+ G_DEF_CLASS(GDK_TYPE_FILL_RULE, "FillRule", gdkRegion);
241
+ G_DEF_CONSTANTS(gdkRegion, GDK_TYPE_FILL_RULE, "GDK_");
242
+ }
@@ -0,0 +1,197 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkrgb.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:31 $
8
+
9
+ Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
10
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
+ Daisuke Kanda,
12
+ Hiroshi Igarashi
13
+ ************************************************/
14
+
15
+ #include "global.h"
16
+
17
+ #define RVAL2DRAW(s) GDK_DRAWABLE(RVAL2GOBJ(s))
18
+
19
+
20
+ static VALUE
21
+ rgb_draw_rgb_image(argc, argv, self)
22
+ int argc;
23
+ VALUE* argv;
24
+ VALUE self;
25
+ {
26
+ VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
27
+
28
+ rb_scan_args(argc, argv, "92", &win, &gc, &x, &y, &w, &h, &dither,
29
+ &buf, &rowstride, &xdith, &ydith);
30
+
31
+ if (argc == 9){
32
+ gdk_draw_rgb_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
33
+ NUM2INT(x), NUM2INT(y),
34
+ NUM2INT(w), NUM2INT(h),
35
+ RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
36
+ (guchar*)RVAL2CSTR(buf),
37
+ NUM2INT(rowstride));
38
+ } else {
39
+ gdk_draw_rgb_image_dithalign(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
40
+ NUM2INT(x), NUM2INT(y),
41
+ NUM2INT(w), NUM2INT(h),
42
+ RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
43
+ (guchar*)RVAL2CSTR(buf),
44
+ NUM2INT(rowstride),
45
+ NUM2INT(xdith), NUM2INT(ydith));
46
+ }
47
+
48
+ return self;
49
+ }
50
+
51
+ static VALUE
52
+ rgb_draw_indexed_image(self, win, gc, x, y, w, h, dither, buf, rowstride, colors)
53
+ VALUE self, win, gc, x, y, w, h, dither, buf, rowstride, colors;
54
+ {
55
+ GdkRgbCmap* cmap;
56
+ guint32* gcolors;
57
+ gint i, n_colors;
58
+
59
+ n_colors = RARRAY_LEN(colors);
60
+
61
+ if (n_colors > 255)
62
+ rb_raise(rb_eArgError, "colors: out of range (0 - 255)");
63
+
64
+ gcolors = g_new(guint32, n_colors);
65
+ for (i = 0; i < n_colors; i++) {
66
+ gcolors[i] = NUM2UINT(RARRAY_PTR(colors)[i]);
67
+ }
68
+
69
+ cmap = gdk_rgb_cmap_new(gcolors, n_colors);
70
+
71
+ gdk_draw_indexed_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
72
+ NUM2INT(x), NUM2INT(y),
73
+ NUM2INT(w), NUM2INT(h),
74
+ RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
75
+ (guchar*)RVAL2CSTR(buf),
76
+ NUM2INT(rowstride), cmap);
77
+ gdk_rgb_cmap_free(cmap);
78
+ return self;
79
+ }
80
+
81
+ static VALUE
82
+ rgb_draw_gray_image(self, win, gc, x, y, w, h, dither, buf, rowstride)
83
+ VALUE self, win, gc, x, y, w, h, dither, buf, rowstride;
84
+ {
85
+ gdk_draw_gray_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
86
+ NUM2INT(x), NUM2INT(y),
87
+ NUM2INT(w), NUM2INT(h),
88
+ RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
89
+ (guchar*)RVAL2CSTR(buf),
90
+ NUM2INT(rowstride));
91
+ return self;
92
+ }
93
+
94
+ static VALUE
95
+ rgb_draw_rgb_32_image(argc, argv, self)
96
+ int argc;
97
+ VALUE* argv;
98
+ VALUE self;
99
+ {
100
+ VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
101
+
102
+ rb_scan_args(argc, argv, "92", &win, &gc, &x, &y, &w, &h, &dither,
103
+ &buf, &rowstride, &xdith, &ydith);
104
+
105
+ if (argc == 9){
106
+ gdk_draw_rgb_32_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
107
+ NUM2INT(x), NUM2INT(y),
108
+ NUM2INT(w), NUM2INT(h),
109
+ RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
110
+ (guchar*)RVAL2CSTR(buf),
111
+ NUM2INT(rowstride));
112
+ } else {
113
+ gdk_draw_rgb_32_image_dithalign(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
114
+ NUM2INT(x), NUM2INT(y),
115
+ NUM2INT(w), NUM2INT(h),
116
+ RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
117
+ (guchar*)RVAL2CSTR(buf),
118
+ NUM2INT(rowstride), NUM2INT(xdith), NUM2INT(ydith));
119
+ }
120
+ return self;
121
+ }
122
+
123
+ static VALUE
124
+ rgb_find_color(self, colormap, color)
125
+ VALUE self, colormap, color;
126
+ {
127
+ gdk_rgb_find_color(GDK_COLORMAP(RVAL2GOBJ(colormap)),
128
+ RVAL2GDKCOLOR(color));
129
+ return self;
130
+ }
131
+
132
+ static VALUE
133
+ rgb_set_install(self, install)
134
+ VALUE self, install;
135
+ {
136
+ gdk_rgb_set_install(RVAL2CBOOL(install));
137
+ return self;
138
+ }
139
+
140
+ static VALUE
141
+ rgb_set_min_colors(self, min_colors)
142
+ VALUE self, min_colors;
143
+ {
144
+ gdk_rgb_set_min_colors(NUM2INT(min_colors));
145
+ return self;
146
+ }
147
+
148
+ static VALUE
149
+ rgb_get_visual(self)
150
+ VALUE self;
151
+ {
152
+ return GOBJ2RVAL(gdk_rgb_get_visual());
153
+ }
154
+
155
+ static VALUE
156
+ rgb_get_cmap(self)
157
+ VALUE self;
158
+ {
159
+ return GOBJ2RVAL(gdk_rgb_get_colormap());
160
+ }
161
+
162
+ static VALUE
163
+ rgb_ditherable(self)
164
+ VALUE self;
165
+ {
166
+ return CBOOL2RVAL(gdk_rgb_ditherable());
167
+ }
168
+
169
+ static VALUE
170
+ rgb_set_verbose(self, verbose)
171
+ VALUE self, verbose;
172
+ {
173
+ gdk_rgb_set_verbose(RVAL2CBOOL(verbose));
174
+ return self;
175
+ }
176
+
177
+ void
178
+ Init_gtk_gdk_rgb()
179
+ {
180
+ VALUE mGdkRgb = rb_define_module_under(mGdk, "RGB");
181
+
182
+ rb_define_module_function(mGdkRgb, "draw_rgb_image", rgb_draw_rgb_image, -1);
183
+ rb_define_module_function(mGdkRgb, "draw_indexed_image", rgb_draw_indexed_image, 10);
184
+ rb_define_module_function(mGdkRgb, "draw_gray_image", rgb_draw_gray_image, 9);
185
+ rb_define_module_function(mGdkRgb, "draw_rgb_32_image", rgb_draw_rgb_32_image, -1);
186
+ rb_define_module_function(mGdkRgb, "find_color", rgb_find_color, 2);
187
+ rb_define_module_function(mGdkRgb, "set_install", rgb_set_install, 1);
188
+ rb_define_module_function(mGdkRgb, "set_min_colors", rgb_set_min_colors, 0);
189
+ rb_define_module_function(mGdkRgb, "visual", rgb_get_visual, 0);
190
+ rb_define_module_function(mGdkRgb, "colormap", rgb_get_cmap, 0);
191
+ rb_define_module_function(mGdkRgb, "ditherable?", rgb_ditherable, 0);
192
+ rb_define_module_function(mGdkRgb, "set_verbose", rgb_set_verbose, 1);
193
+
194
+ /* GdkRgbDither */
195
+ G_DEF_CLASS(GDK_TYPE_RGB_DITHER, "Dither", mGdkRgb);
196
+ G_DEF_CONSTANTS(mGdkRgb, GDK_TYPE_RGB_DITHER, "GDK_RGB_");
197
+ }