gtk2 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6664 -0
- data/README +33 -0
- data/Rakefile +71 -0
- data/extconf.rb +116 -0
- data/src/global.h +33 -0
- data/src/init.c +39 -0
- data/src/lib/gtk2.rb +13 -0
- data/src/lib/gtk2/base.rb +95 -0
- data/src/makeinits.rb +57 -0
- data/src/makekeysyms.rb +5 -0
- data/src/rbgdk.c +395 -0
- data/src/rbgdk.h +50 -0
- data/src/rbgdkatom.c +122 -0
- data/src/rbgdkcairo.c +100 -0
- data/src/rbgdkcolor.c +151 -0
- data/src/rbgdkcolormap.c +142 -0
- data/src/rbgdkconst.c +29 -0
- data/src/rbgdkconversions.h +18 -0
- data/src/rbgdkcursor.c +115 -0
- data/src/rbgdkdevice.c +235 -0
- data/src/rbgdkdisplay.c +634 -0
- data/src/rbgdkdisplaymanager.c +50 -0
- data/src/rbgdkdragcontext.c +280 -0
- data/src/rbgdkdraw.c +487 -0
- data/src/rbgdkevent.c +1020 -0
- data/src/rbgdkgc.c +456 -0
- data/src/rbgdkgeometry.c +272 -0
- data/src/rbgdkimage.c +155 -0
- data/src/rbgdkinput.c +70 -0
- data/src/rbgdkkeymap.c +153 -0
- data/src/rbgdkkeysyms.h +2174 -0
- data/src/rbgdkkeyval.c +105 -0
- data/src/rbgdkpango.c +171 -0
- data/src/rbgdkpangorenderer.c +132 -0
- data/src/rbgdkpixbuf.c +178 -0
- data/src/rbgdkpixmap.c +255 -0
- data/src/rbgdkproperty.c +342 -0
- data/src/rbgdkrectangle.c +146 -0
- data/src/rbgdkregion.c +242 -0
- data/src/rbgdkrgb.c +197 -0
- data/src/rbgdkscreen.c +535 -0
- data/src/rbgdkselection.c +161 -0
- data/src/rbgdkthreads.c +68 -0
- data/src/rbgdktimecoord.c +118 -0
- data/src/rbgdkvisual.c +273 -0
- data/src/rbgdkwindow.c +1302 -0
- data/src/rbgdkwindowattr.c +213 -0
- data/src/rbgdkx11.c +256 -0
- data/src/rbgtk.c +93 -0
- data/src/rbgtk.h +121 -0
- data/src/rbgtkaboutdialog.c +195 -0
- data/src/rbgtkaccelerator.c +78 -0
- data/src/rbgtkaccelgroup.c +216 -0
- data/src/rbgtkaccelgroupentry.c +85 -0
- data/src/rbgtkaccelkey.c +116 -0
- data/src/rbgtkaccellabel.c +46 -0
- data/src/rbgtkaccelmap.c +162 -0
- data/src/rbgtkaccessible.c +29 -0
- data/src/rbgtkaction.c +277 -0
- data/src/rbgtkactiongroup.c +377 -0
- data/src/rbgtkadjustment.c +153 -0
- data/src/rbgtkalignment.c +71 -0
- data/src/rbgtkallocation.c +171 -0
- data/src/rbgtkarrow.c +47 -0
- data/src/rbgtkaspectframe.c +46 -0
- data/src/rbgtkassistant.c +230 -0
- data/src/rbgtkbbox.c +47 -0
- data/src/rbgtkbin.c +31 -0
- data/src/rbgtkbindingset.c +192 -0
- data/src/rbgtkborder.c +80 -0
- data/src/rbgtkbox.c +142 -0
- data/src/rbgtkbuildable.c +115 -0
- data/src/rbgtkbuilder.c +154 -0
- data/src/rbgtkbutton.c +151 -0
- data/src/rbgtkcalendar.c +159 -0
- data/src/rbgtkcelleditable.c +49 -0
- data/src/rbgtkcelllayout.c +144 -0
- data/src/rbgtkcellrenderer.c +139 -0
- data/src/rbgtkcellrendereraccel.c +42 -0
- data/src/rbgtkcellrenderercombo.c +37 -0
- data/src/rbgtkcellrendererpixbuf.c +33 -0
- data/src/rbgtkcellrendererprogress.c +37 -0
- data/src/rbgtkcellrendererspin.c +38 -0
- data/src/rbgtkcellrenderertext.c +45 -0
- data/src/rbgtkcellrenderertoggle.c +32 -0
- data/src/rbgtkcellview.c +134 -0
- data/src/rbgtkcheckbutton.c +55 -0
- data/src/rbgtkcheckmenuitem.c +56 -0
- data/src/rbgtkclipboard.c +473 -0
- data/src/rbgtkcolorbutton.c +63 -0
- data/src/rbgtkcolorsel.c +175 -0
- data/src/rbgtkcolorselectiondialog.c +72 -0
- data/src/rbgtkcombo.c +117 -0
- data/src/rbgtkcombobox.c +240 -0
- data/src/rbgtkcomboboxentry.c +60 -0
- data/src/rbgtkconst.c +163 -0
- data/src/rbgtkcontainer.c +776 -0
- data/src/rbgtkconversions.h +26 -0
- data/src/rbgtkcurve.c +105 -0
- data/src/rbgtkdialog.c +244 -0
- data/src/rbgtkdrag.c +436 -0
- data/src/rbgtkdrawingarea.c +31 -0
- data/src/rbgtkeditable.c +152 -0
- data/src/rbgtkentry.c +161 -0
- data/src/rbgtkentrycompletion.c +167 -0
- data/src/rbgtkeventbox.c +31 -0
- data/src/rbgtkexpander.c +67 -0
- data/src/rbgtkfilechooser.c +403 -0
- data/src/rbgtkfilechooserbutton.c +72 -0
- data/src/rbgtkfilechooserdialog.c +58 -0
- data/src/rbgtkfilechooserwidget.c +50 -0
- data/src/rbgtkfilefilter.c +139 -0
- data/src/rbgtkfilesel.c +155 -0
- data/src/rbgtkfixed.c +72 -0
- data/src/rbgtkfontbutton.c +69 -0
- data/src/rbgtkfontselection.c +30 -0
- data/src/rbgtkfontselectiondialog.c +106 -0
- data/src/rbgtkframe.c +64 -0
- data/src/rbgtkgamma.c +47 -0
- data/src/rbgtkhandlebox.c +42 -0
- data/src/rbgtkhbbox.c +31 -0
- data/src/rbgtkhbox.c +38 -0
- data/src/rbgtkhpaned.c +31 -0
- data/src/rbgtkhruler.c +31 -0
- data/src/rbgtkhscale.c +45 -0
- data/src/rbgtkhscrollbar.c +38 -0
- data/src/rbgtkhseparator.c +30 -0
- data/src/rbgtkiconfactory.c +80 -0
- data/src/rbgtkiconinfo.c +118 -0
- data/src/rbgtkiconset.c +87 -0
- data/src/rbgtkiconsize.c +90 -0
- data/src/rbgtkiconsource.c +176 -0
- data/src/rbgtkicontheme.c +309 -0
- data/src/rbgtkiconview.c +351 -0
- data/src/rbgtkimage.c +152 -0
- data/src/rbgtkimagemenuitem.c +52 -0
- data/src/rbgtkimcontext.c +134 -0
- data/src/rbgtkimcontextsimple.c +48 -0
- data/src/rbgtkimmulticontext.c +38 -0
- data/src/rbgtkinits.c +473 -0
- data/src/rbgtkinputdialog.c +30 -0
- data/src/rbgtkinvisible.c +68 -0
- data/src/rbgtkitem.c +51 -0
- data/src/rbgtkitemfactory.c +312 -0
- data/src/rbgtklabel.c +168 -0
- data/src/rbgtklayout.c +91 -0
- data/src/rbgtklinkbutton.c +68 -0
- data/src/rbgtkliststore.c +412 -0
- data/src/rbgtkmacros.h +26 -0
- data/src/rbgtkmain.c +532 -0
- data/src/rbgtkmenu.c +272 -0
- data/src/rbgtkmenubar.c +48 -0
- data/src/rbgtkmenuitem.c +171 -0
- data/src/rbgtkmenushell.c +128 -0
- data/src/rbgtkmenutoolbutton.c +74 -0
- data/src/rbgtkmessagedialog.c +102 -0
- data/src/rbgtkmisc.c +63 -0
- data/src/rbgtknotebook.c +484 -0
- data/src/rbgtkobject.c +186 -0
- data/src/rbgtkoptionmenu.c +65 -0
- data/src/rbgtkpagesetup.c +196 -0
- data/src/rbgtkpagesetupunixdialog.c +80 -0
- data/src/rbgtkpaned.c +114 -0
- data/src/rbgtkpapersize.c +186 -0
- data/src/rbgtkplug.c +84 -0
- data/src/rbgtkprintcontext.c +124 -0
- data/src/rbgtkprinter.c +155 -0
- data/src/rbgtkprintjob.c +151 -0
- data/src/rbgtkprintoperation.c +152 -0
- data/src/rbgtkprintoperationpreview.c +54 -0
- data/src/rbgtkprintsettings.c +794 -0
- data/src/rbgtkprintunixdialog.c +98 -0
- data/src/rbgtkprogress.c +21 -0
- data/src/rbgtkprogressbar.c +72 -0
- data/src/rbgtkradioaction.c +102 -0
- data/src/rbgtkradiobutton.c +83 -0
- data/src/rbgtkradiomenuitem.c +115 -0
- data/src/rbgtkradiotoolbutton.c +99 -0
- data/src/rbgtkrange.c +98 -0
- data/src/rbgtkrc.c +228 -0
- data/src/rbgtkrcstyle.c +184 -0
- data/src/rbgtkrecentaction.c +52 -0
- data/src/rbgtkrecentchooser.c +276 -0
- data/src/rbgtkrecentchooserdialog.c +59 -0
- data/src/rbgtkrecentchoosermenu.c +55 -0
- data/src/rbgtkrecentchooserwidget.c +45 -0
- data/src/rbgtkrecentdata.c +152 -0
- data/src/rbgtkrecentfilter.c +180 -0
- data/src/rbgtkrecentfilterinfo.c +197 -0
- data/src/rbgtkrecentinfo.c +232 -0
- data/src/rbgtkrecentmanager.c +164 -0
- data/src/rbgtkruler.c +82 -0
- data/src/rbgtkscale.c +47 -0
- data/src/rbgtkscalebutton.c +115 -0
- data/src/rbgtkscrollbar.c +21 -0
- data/src/rbgtkscrolledwindow.c +160 -0
- data/src/rbgtkselection.c +171 -0
- data/src/rbgtkselectiondata.c +333 -0
- data/src/rbgtkseparator.c +21 -0
- data/src/rbgtkseparatormenuitem.c +28 -0
- data/src/rbgtkseparatortoolitem.c +40 -0
- data/src/rbgtksettings.c +225 -0
- data/src/rbgtksizegroup.c +74 -0
- data/src/rbgtksocket.c +72 -0
- data/src/rbgtkspinbutton.c +138 -0
- data/src/rbgtkstatusbar.c +90 -0
- data/src/rbgtkstatusicon.c +120 -0
- data/src/rbgtkstock.c +264 -0
- data/src/rbgtkstyle.c +722 -0
- data/src/rbgtktable.c +190 -0
- data/src/rbgtktargetlist.c +148 -0
- data/src/rbgtktearoffmenuitem.c +30 -0
- data/src/rbgtktextappearance.c +173 -0
- data/src/rbgtktextattributes.c +209 -0
- data/src/rbgtktextbuffer.c +993 -0
- data/src/rbgtktextchild.c +49 -0
- data/src/rbgtktextiter.c +553 -0
- data/src/rbgtktextmark.c +87 -0
- data/src/rbgtktexttag.c +66 -0
- data/src/rbgtktexttagtable.c +94 -0
- data/src/rbgtktextview.c +351 -0
- data/src/rbgtktoggleaction.c +76 -0
- data/src/rbgtktogglebutton.c +84 -0
- data/src/rbgtktoggletoolbutton.c +70 -0
- data/src/rbgtktoolbar.c +373 -0
- data/src/rbgtktoolbutton.c +75 -0
- data/src/rbgtktoolitem.c +184 -0
- data/src/rbgtktooltip.c +76 -0
- data/src/rbgtktooltips.c +107 -0
- data/src/rbgtktreedragdest.c +19 -0
- data/src/rbgtktreedragsource.c +19 -0
- data/src/rbgtktreeiter.c +259 -0
- data/src/rbgtktreemodel.c +256 -0
- data/src/rbgtktreemodelfilter.c +214 -0
- data/src/rbgtktreemodelsort.c +113 -0
- data/src/rbgtktreepath.c +195 -0
- data/src/rbgtktreerowreference.c +168 -0
- data/src/rbgtktreeselection.c +235 -0
- data/src/rbgtktreesortable.c +127 -0
- data/src/rbgtktreestore.c +379 -0
- data/src/rbgtktreeview.c +881 -0
- data/src/rbgtktreeviewcolumn.c +331 -0
- data/src/rbgtkuimanager.c +210 -0
- data/src/rbgtkvbbox.c +31 -0
- data/src/rbgtkvbox.c +38 -0
- data/src/rbgtkviewport.c +33 -0
- data/src/rbgtkvolumebutton.c +36 -0
- data/src/rbgtkvpaned.c +31 -0
- data/src/rbgtkvruler.c +30 -0
- data/src/rbgtkvscale.c +45 -0
- data/src/rbgtkvscrollbar.c +38 -0
- data/src/rbgtkvseparator.c +30 -0
- data/src/rbgtkwidget.c +1414 -0
- data/src/rbgtkwindow.c +822 -0
- data/src/rbgtkwindowgroup.c +48 -0
- data/test/gtk-test-utils.rb +15 -0
- data/test/run-test.rb +30 -0
- data/test/test_gc.rb +25 -0
- data/test/test_gdk.rb +18 -0
- data/test/test_gdk_color.rb +10 -0
- data/test/test_gdk_display.rb +37 -0
- data/test/test_gdk_event.rb +11 -0
- data/test/test_gdk_gc.rb +7 -0
- data/test/test_gdk_keymap.rb +8 -0
- data/test/test_gdk_pango.rb +9 -0
- data/test/test_gdk_selection_data.rb +17 -0
- data/test/test_gdk_window.rb +29 -0
- data/test/test_gdk_window_attribute.rb +9 -0
- data/test/test_gtk_about_dialog.rb +14 -0
- data/test/test_gtk_buildable.rb +66 -0
- data/test/test_gtk_builder.rb +188 -0
- data/test/test_gtk_entry.rb +18 -0
- data/test/test_gtk_icon_theme.rb +30 -0
- data/test/test_gtk_image.rb +8 -0
- data/test/test_gtk_list_store.rb +65 -0
- data/test/test_gtk_menu_item.rb +13 -0
- data/test/test_gtk_rc_style.rb +14 -0
- data/test/test_gtk_tree_path.rb +20 -0
- data/test/test_gtk_unix_print.rb +14 -0
- data/test/test_gtk_widget.rb +32 -0
- 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
|
+
}
|
data/src/rbgdkregion.c
ADDED
@@ -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
|
+
}
|
data/src/rbgdkrgb.c
ADDED
@@ -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
|
+
}
|