gdk3 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +53 -0
- data/ext/gdk3/depend +11 -0
- data/ext/gdk3/extconf.rb +127 -0
- data/ext/gdk3/gdk3.def +12 -0
- data/ext/gdk3/init.c +35 -0
- data/ext/gdk3/rbgdk.c +540 -0
- data/ext/gdk3/rbgdk3.h +71 -0
- data/ext/gdk3/rbgdk3conversions.h +118 -0
- data/ext/gdk3/rbgdk3private.h +93 -0
- data/ext/gdk3/rbgdkatom.c +122 -0
- data/ext/gdk3/rbgdkcairo.c +95 -0
- data/ext/gdk3/rbgdkcolor.c +137 -0
- data/ext/gdk3/rbgdkconst.c +33 -0
- data/ext/gdk3/rbgdkcursor.c +99 -0
- data/ext/gdk3/rbgdkdevice.c +197 -0
- data/ext/gdk3/rbgdkdisplay.c +482 -0
- data/ext/gdk3/rbgdkdisplaymanager.c +55 -0
- data/ext/gdk3/rbgdkdragcontext.c +191 -0
- data/ext/gdk3/rbgdkdraw.c +520 -0
- data/ext/gdk3/rbgdkevent.c +926 -0
- data/ext/gdk3/rbgdkgeometry.c +252 -0
- data/ext/gdk3/rbgdkkeymap.c +151 -0
- data/ext/gdk3/rbgdkkeyval.c +108 -0
- data/ext/gdk3/rbgdkpango.c +197 -0
- data/ext/gdk3/rbgdkpangorenderer.c +144 -0
- data/ext/gdk3/rbgdkpixbuf.c +176 -0
- data/ext/gdk3/rbgdkproperty.c +305 -0
- data/ext/gdk3/rbgdkrectangle.c +140 -0
- data/ext/gdk3/rbgdkrgb.c +199 -0
- data/ext/gdk3/rbgdkrgba.c +142 -0
- data/ext/gdk3/rbgdkscreen.c +443 -0
- data/ext/gdk3/rbgdkselection.c +146 -0
- data/ext/gdk3/rbgdkthreads.c +77 -0
- data/ext/gdk3/rbgdktimecoord.c +133 -0
- data/ext/gdk3/rbgdkvisual.c +251 -0
- data/ext/gdk3/rbgdkwindow.c +1044 -0
- data/ext/gdk3/rbgdkwindowattr.c +191 -0
- data/ext/gdk3/rbgdkx11.c +102 -0
- data/ext/gdk3/rbgdkx11x11window.c +66 -0
- data/extconf.rb +49 -0
- data/lib/gdk3.rb +3 -0
- data/lib/gdk3/base.rb +50 -0
- data/lib/gdk3/deprecated.rb +152 -0
- metadata +156 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2006 Ruby-GNOME2 Project Team
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 of the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbgdk3private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE cDisplayManager
|
25
|
+
#define _SELF(obj) RVAL2GDKDISPLAYMANAGER(obj)
|
26
|
+
|
27
|
+
static VALUE
|
28
|
+
rg_s_get(G_GNUC_UNUSED VALUE self)
|
29
|
+
{
|
30
|
+
return GOBJ2RVAL(gdk_display_manager_get());
|
31
|
+
}
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
rg_displays(VALUE self)
|
35
|
+
{
|
36
|
+
return GOBJGSLIST2RVAL_FREE(gdk_display_manager_list_displays(_SELF(self)),
|
37
|
+
g_slist_free, NULL);
|
38
|
+
}
|
39
|
+
|
40
|
+
/* Move to Gdk::Display.
|
41
|
+
static VALUE
|
42
|
+
gdkdisplaymanager_get_core_pointer(VALUE self)
|
43
|
+
{
|
44
|
+
return GOBJ2RVAL(gdk_display_get_core_pointer(_SELF(self)));
|
45
|
+
}
|
46
|
+
*/
|
47
|
+
|
48
|
+
void
|
49
|
+
Init_gdk_display_manager(VALUE mGdk)
|
50
|
+
{
|
51
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DISPLAY_MANAGER, "DisplayManager", mGdk);
|
52
|
+
|
53
|
+
RG_DEF_SMETHOD(get, 0);
|
54
|
+
RG_DEF_METHOD(displays, 0);
|
55
|
+
}
|
@@ -0,0 +1,191 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002,2003 Masao Mutoh
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 of the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbgdk3private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE cDragContext
|
25
|
+
#define _SELF(self) (RVAL2GDKDRAGCONTEXT(self))
|
26
|
+
|
27
|
+
static VALUE
|
28
|
+
rg_protocol(VALUE self)
|
29
|
+
{
|
30
|
+
return GDKDRAGPROTOCOL2RVAL(gdk_drag_context_get_protocol(_SELF(self)));
|
31
|
+
}
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
rg_source_window(VALUE self)
|
35
|
+
{
|
36
|
+
return GOBJ2RVAL(gdk_drag_context_get_source_window(_SELF(self)));
|
37
|
+
}
|
38
|
+
|
39
|
+
static VALUE
|
40
|
+
rg_dest_window(VALUE self)
|
41
|
+
{
|
42
|
+
return GOBJ2RVAL(gdk_drag_context_get_dest_window(_SELF(self)));
|
43
|
+
}
|
44
|
+
|
45
|
+
static VALUE
|
46
|
+
rg_targets(VALUE self)
|
47
|
+
{
|
48
|
+
GList *list, *cur;
|
49
|
+
VALUE ary = rb_ary_new();
|
50
|
+
|
51
|
+
list = gdk_drag_context_list_targets(_SELF(self));
|
52
|
+
for (cur = list; cur != NULL; cur = cur->next) {
|
53
|
+
rb_ary_push(ary, GDKATOM2RVAL((GdkAtom)cur->data));
|
54
|
+
}
|
55
|
+
return ary;
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
rg_actions(VALUE self)
|
60
|
+
{
|
61
|
+
return GDKDRAGACTION2RVAL(gdk_drag_context_get_actions(_SELF(self)));
|
62
|
+
}
|
63
|
+
|
64
|
+
static VALUE
|
65
|
+
rg_suggested_action(VALUE self)
|
66
|
+
{
|
67
|
+
return GDKDRAGACTION2RVAL(gdk_drag_context_get_suggested_action(_SELF(self)));
|
68
|
+
}
|
69
|
+
|
70
|
+
static VALUE
|
71
|
+
rg_selected_action(VALUE self)
|
72
|
+
{
|
73
|
+
return GDKDRAGACTION2RVAL(gdk_drag_context_get_selected_action(_SELF(self)));
|
74
|
+
}
|
75
|
+
|
76
|
+
static VALUE
|
77
|
+
rg_selection(VALUE self)
|
78
|
+
{
|
79
|
+
return GDKATOM2RVAL(gdk_drag_get_selection(_SELF(self)));
|
80
|
+
}
|
81
|
+
|
82
|
+
static VALUE
|
83
|
+
rg_drag_abort(VALUE self, VALUE time)
|
84
|
+
{
|
85
|
+
gdk_drag_abort(_SELF(self), NUM2UINT(time));
|
86
|
+
return self;
|
87
|
+
}
|
88
|
+
|
89
|
+
static VALUE
|
90
|
+
rg_drop_reply(VALUE self, VALUE ok, VALUE time)
|
91
|
+
{
|
92
|
+
gdk_drop_reply(_SELF(self), RVAL2CBOOL(ok), NUM2UINT(time));
|
93
|
+
return self;
|
94
|
+
}
|
95
|
+
|
96
|
+
static VALUE
|
97
|
+
rg_drag_drop(VALUE self, VALUE time)
|
98
|
+
{
|
99
|
+
gdk_drag_drop(_SELF(self), NUM2UINT(time));
|
100
|
+
return self;
|
101
|
+
}
|
102
|
+
|
103
|
+
static VALUE
|
104
|
+
rg_find_window(int argc, VALUE *argv, VALUE self)
|
105
|
+
{
|
106
|
+
VALUE drag_window, x_root, y_root;
|
107
|
+
GdkWindow *dest_window;
|
108
|
+
GdkDragProtocol prot;
|
109
|
+
|
110
|
+
if (argc == 3) {
|
111
|
+
/* deprecated
|
112
|
+
rb_scan_args(argc, argv, "30", &drag_window, &x_root, &y_root);
|
113
|
+
gdk_drag_find_window(_SELF(self),
|
114
|
+
RVAL2GDKWINDOW(drag_window),
|
115
|
+
NUM2INT(x_root), NUM2INT(y_root),
|
116
|
+
&dest_window, &prot);
|
117
|
+
*/
|
118
|
+
} else {
|
119
|
+
VALUE screen;
|
120
|
+
rb_scan_args(argc, argv, "40", &drag_window, &screen, &x_root, &y_root);
|
121
|
+
gdk_drag_find_window_for_screen(_SELF(self),
|
122
|
+
RVAL2GDKWINDOW(drag_window),
|
123
|
+
RVAL2GDKSCREEN(screen),
|
124
|
+
NUM2INT(x_root), NUM2INT(y_root),
|
125
|
+
&dest_window, &prot);
|
126
|
+
}
|
127
|
+
|
128
|
+
return rb_ary_new3(2, GOBJ2RVAL(dest_window),
|
129
|
+
GDKDRAGPROTOCOL2RVAL(prot));
|
130
|
+
}
|
131
|
+
|
132
|
+
static VALUE
|
133
|
+
rg_drag_motion(VALUE self, VALUE dest_window, VALUE protocol, VALUE x_root, VALUE y_root, VALUE suggested_action, VALUE possible_actions, VALUE time)
|
134
|
+
{
|
135
|
+
gboolean ret = gdk_drag_motion(_SELF(self),
|
136
|
+
RVAL2GDKWINDOW(dest_window),
|
137
|
+
RVAL2GDKDRAGPROTOCOL(protocol),
|
138
|
+
NUM2INT(x_root), NUM2INT(y_root),
|
139
|
+
RVAL2GDKDRAGACTION(suggested_action),
|
140
|
+
RVAL2GDKDRAGACTION(possible_actions),
|
141
|
+
NUM2UINT(time));
|
142
|
+
return CBOOL2RVAL(ret);
|
143
|
+
}
|
144
|
+
|
145
|
+
static VALUE
|
146
|
+
rg_drop_finish(VALUE self, VALUE success, VALUE time)
|
147
|
+
{
|
148
|
+
gdk_drop_finish(_SELF(self), RVAL2CBOOL(success), NUM2UINT(time));
|
149
|
+
return self;
|
150
|
+
}
|
151
|
+
|
152
|
+
static VALUE
|
153
|
+
rg_drag_status(VALUE self, VALUE action, VALUE time)
|
154
|
+
{
|
155
|
+
gdk_drag_status(_SELF(self),
|
156
|
+
RVAL2GDKDRAGACTION(action), NUM2UINT(time));
|
157
|
+
return self;
|
158
|
+
}
|
159
|
+
|
160
|
+
static VALUE
|
161
|
+
rg_drag_drop_succeeded_p(VALUE self)
|
162
|
+
{
|
163
|
+
return CBOOL2RVAL(gdk_drag_drop_succeeded(_SELF(self)));
|
164
|
+
}
|
165
|
+
|
166
|
+
void
|
167
|
+
Init_gdk_dragcontext(VALUE mGdk)
|
168
|
+
{
|
169
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DRAG_CONTEXT, "DragContext", mGdk);
|
170
|
+
|
171
|
+
RG_DEF_METHOD(protocol, 0);
|
172
|
+
RG_DEF_METHOD(source_window, 0);
|
173
|
+
RG_DEF_METHOD(dest_window, 0);
|
174
|
+
RG_DEF_METHOD(targets, 0);
|
175
|
+
RG_DEF_METHOD(actions, 0);
|
176
|
+
RG_DEF_METHOD(suggested_action, 0);
|
177
|
+
RG_DEF_METHOD(selected_action, 0);
|
178
|
+
|
179
|
+
RG_DEF_METHOD(selection, 0);
|
180
|
+
RG_DEF_METHOD(drag_abort, 1);
|
181
|
+
RG_DEF_METHOD(drop_reply, 2);
|
182
|
+
RG_DEF_METHOD(drag_drop, 1);
|
183
|
+
RG_DEF_METHOD(find_window, 4);
|
184
|
+
RG_DEF_METHOD(drag_motion, 7);
|
185
|
+
RG_DEF_METHOD(drop_finish, 2);
|
186
|
+
RG_DEF_METHOD(drag_status, 2);
|
187
|
+
RG_DEF_METHOD_P(drag_drop_succeeded, 0);
|
188
|
+
|
189
|
+
G_DEF_CLASS(GDK_TYPE_DRAG_PROTOCOL, "Protocol", RG_TARGET_NAMESPACE);
|
190
|
+
G_DEF_CLASS(GDK_TYPE_DRAG_ACTION, "Action", RG_TARGET_NAMESPACE);
|
191
|
+
}
|
@@ -0,0 +1,520 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2005 Masao Mutoh
|
5
|
+
* Copyright (C) 1998-2000 Yukihiro Matsumoto,
|
6
|
+
* Daisuke Kanda,
|
7
|
+
* Hiroshi Igarashi
|
8
|
+
*
|
9
|
+
* This library is free software; you can redistribute it and/or
|
10
|
+
* modify it under the terms of the GNU Lesser General Public
|
11
|
+
* License as published by the Free Software Foundation; either
|
12
|
+
* version 2.1 of the License, or (at your option) any later version.
|
13
|
+
*
|
14
|
+
* This library is distributed in the hope that it will be useful,
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
* Lesser General Public License for more details.
|
18
|
+
*
|
19
|
+
* You should have received a copy of the GNU Lesser General Public
|
20
|
+
* License along with this library; if not, write to the Free Software
|
21
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
22
|
+
* MA 02110-1301 USA
|
23
|
+
*/
|
24
|
+
|
25
|
+
/* deprecated
|
26
|
+
#include "rbgdk3private.h"
|
27
|
+
#include "rbpango.h"
|
28
|
+
#ifdef GDK_WINDOWING_X11
|
29
|
+
#include <gdk/gdkx.h>
|
30
|
+
#endif
|
31
|
+
#ifdef HAVE_RB_CAIRO_H
|
32
|
+
#include <rb_cairo.h>
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#define RG_TARGET_NAMESPACE cDrawable
|
36
|
+
#define _SELF(s) RVAL2GDKDRAWABLE(s)
|
37
|
+
|
38
|
+
static VALUE
|
39
|
+
rg_visual(VALUE self)
|
40
|
+
{
|
41
|
+
return GOBJ2RVAL(_SELF(self));
|
42
|
+
}
|
43
|
+
|
44
|
+
static VALUE
|
45
|
+
rg_set_colormap(VALUE self, VALUE colormap)
|
46
|
+
{
|
47
|
+
VALUE old_colormap;
|
48
|
+
|
49
|
+
old_colormap = GOBJ2RVAL(gdk_drawable_get_colormap(_SELF(self)));
|
50
|
+
G_CHILD_REMOVE(self, old_colormap);
|
51
|
+
|
52
|
+
G_CHILD_ADD(self, colormap);
|
53
|
+
gdk_drawable_set_colormap(_SELF(self), RVAL2GDKCOLORMAP(colormap));
|
54
|
+
return self;
|
55
|
+
}
|
56
|
+
|
57
|
+
static VALUE
|
58
|
+
rg_colormap(VALUE self)
|
59
|
+
{
|
60
|
+
VALUE rb_colormap;
|
61
|
+
|
62
|
+
rb_colormap = GOBJ2RVAL(gdk_drawable_get_colormap(_SELF(self)));
|
63
|
+
G_CHILD_ADD(self, rb_colormap);
|
64
|
+
return rb_colormap;
|
65
|
+
}
|
66
|
+
|
67
|
+
static VALUE
|
68
|
+
rg_depth(VALUE self)
|
69
|
+
{
|
70
|
+
return INT2NUM(gdk_drawable_get_depth(_SELF(self)));
|
71
|
+
}
|
72
|
+
|
73
|
+
static VALUE
|
74
|
+
rg_size(VALUE self)
|
75
|
+
{
|
76
|
+
gint width, height;
|
77
|
+
gdk_drawable_get_size(_SELF(self), &width, &height);
|
78
|
+
return rb_ary_new3(2, INT2NUM(width), INT2NUM(height));
|
79
|
+
}
|
80
|
+
|
81
|
+
static VALUE
|
82
|
+
rg_clip_region(VALUE self)
|
83
|
+
{
|
84
|
+
return GDKREGION2RVAL(gdk_drawable_get_clip_region(_SELF(self)));
|
85
|
+
}
|
86
|
+
|
87
|
+
static VALUE
|
88
|
+
rg_visible_region(VALUE self)
|
89
|
+
{
|
90
|
+
return GDKREGION2RVAL(gdk_drawable_get_visible_region(_SELF(self)));
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE
|
94
|
+
rg_draw_point(VALUE self, VALUE gc, VALUE x, VALUE y)
|
95
|
+
{
|
96
|
+
gdk_draw_point(_SELF(self), RVAL2GDKGC(gc),
|
97
|
+
NUM2INT(x), NUM2INT(y));
|
98
|
+
return self;
|
99
|
+
}
|
100
|
+
|
101
|
+
static VALUE
|
102
|
+
rg_draw_points(VALUE self, VALUE rbgc, VALUE rbpoints)
|
103
|
+
{
|
104
|
+
GdkDrawable *drawable = _SELF(self);
|
105
|
+
GdkGC *gc = RVAL2GDKGC(rbgc);
|
106
|
+
long n;
|
107
|
+
GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n);
|
108
|
+
|
109
|
+
gdk_draw_points(drawable, gc, points, n);
|
110
|
+
|
111
|
+
g_free(points);
|
112
|
+
|
113
|
+
return self;
|
114
|
+
}
|
115
|
+
|
116
|
+
static VALUE
|
117
|
+
rg_draw_line(VALUE self, VALUE gc, VALUE x1, VALUE y1, VALUE x2, VALUE y2)
|
118
|
+
{
|
119
|
+
gdk_draw_line(_SELF(self), RVAL2GDKGC(gc),
|
120
|
+
NUM2INT(x1), NUM2INT(y1),
|
121
|
+
NUM2INT(x2), NUM2INT(y2));
|
122
|
+
return self;
|
123
|
+
}
|
124
|
+
|
125
|
+
static VALUE
|
126
|
+
rg_draw_lines(VALUE self, VALUE rbgc, VALUE rbpoints)
|
127
|
+
{
|
128
|
+
GdkDrawable *drawable = _SELF(self);
|
129
|
+
GdkGC *gc = RVAL2GDKGC(rbgc);
|
130
|
+
long n;
|
131
|
+
GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n);
|
132
|
+
|
133
|
+
gdk_draw_lines(drawable, gc, points, n);
|
134
|
+
|
135
|
+
g_free(points);
|
136
|
+
|
137
|
+
return self;
|
138
|
+
}
|
139
|
+
|
140
|
+
static VALUE
|
141
|
+
rg_draw_pixbuf(VALUE self, VALUE gc, VALUE pixbuf, VALUE src_x, VALUE src_y, VALUE dest_x, VALUE dest_y, VALUE width, VALUE height, VALUE dither, VALUE x_dither, VALUE y_dither)
|
142
|
+
{
|
143
|
+
gdk_draw_pixbuf(_SELF(self),
|
144
|
+
RVAL2GDKGC(gc),
|
145
|
+
RVAL2GDKPIXBUF(pixbuf),
|
146
|
+
NUM2INT(src_x), NUM2INT(src_y),
|
147
|
+
NUM2INT(dest_x), NUM2INT(dest_y),
|
148
|
+
NUM2INT(width), NUM2INT(height),
|
149
|
+
RVAL2GDKRGBDITHER(dither),
|
150
|
+
NUM2INT(x_dither), NUM2INT(y_dither));
|
151
|
+
return self;
|
152
|
+
}
|
153
|
+
|
154
|
+
struct rbgdk_rval2gdksegments_args {
|
155
|
+
VALUE ary;
|
156
|
+
long n;
|
157
|
+
GdkSegment *result;
|
158
|
+
};
|
159
|
+
|
160
|
+
static VALUE
|
161
|
+
rbgdk_rval2gdksegments_body(VALUE value)
|
162
|
+
{
|
163
|
+
long i;
|
164
|
+
struct rbgdk_rval2gdksegments_args *args = (struct rbgdk_rval2gdksegments_args *)value;
|
165
|
+
|
166
|
+
for (i = 0; i < args->n; i++) {
|
167
|
+
VALUE segments = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]);
|
168
|
+
|
169
|
+
if (RARRAY_LEN(segments) != 2)
|
170
|
+
rb_raise(rb_eArgError, "segment %ld should be array of size 4", i);
|
171
|
+
|
172
|
+
args->result[i].x1 = NUM2INT(RARRAY_PTR(segments)[0]);
|
173
|
+
args->result[i].y1 = NUM2INT(RARRAY_PTR(segments)[1]);
|
174
|
+
args->result[i].x2 = NUM2INT(RARRAY_PTR(segments)[2]);
|
175
|
+
args->result[i].y2 = NUM2INT(RARRAY_PTR(segments)[3]);
|
176
|
+
}
|
177
|
+
|
178
|
+
return Qnil;
|
179
|
+
}
|
180
|
+
|
181
|
+
static G_GNUC_NORETURN VALUE
|
182
|
+
rbgdk_rval2gdksegments_rescue(VALUE value)
|
183
|
+
{
|
184
|
+
g_free(((struct rbgdk_rval2gdksegments_args *)value)->result);
|
185
|
+
|
186
|
+
rb_exc_raise(rb_errinfo());
|
187
|
+
}
|
188
|
+
|
189
|
+
static GdkSegment *
|
190
|
+
rbgdk_rval2gdksegments(VALUE value, long *n)
|
191
|
+
{
|
192
|
+
struct rbgdk_rval2gdksegments_args args;
|
193
|
+
|
194
|
+
args.ary = rb_ary_to_ary(value);
|
195
|
+
args.n = RARRAY_LEN(args.ary);
|
196
|
+
args.result = g_new(GdkSegment, args.n + 1);
|
197
|
+
|
198
|
+
rb_rescue(rbgdk_rval2gdksegments_body, (VALUE)&args,
|
199
|
+
rbgdk_rval2gdksegments_rescue, (VALUE)&args);
|
200
|
+
|
201
|
+
if (n != NULL)
|
202
|
+
*n = args.n;
|
203
|
+
|
204
|
+
return args.result;
|
205
|
+
}
|
206
|
+
|
207
|
+
#define RVAL2GDKSEGMENTS(value, n) rbgdk_rval2gdksegments(value, n)
|
208
|
+
|
209
|
+
static VALUE
|
210
|
+
rg_draw_segments(VALUE self, VALUE rbgc, VALUE rbsegments)
|
211
|
+
{
|
212
|
+
GdkDrawable *drawable = _SELF(self);
|
213
|
+
GdkGC *gc = RVAL2GDKGC(rbgc);
|
214
|
+
long n;
|
215
|
+
GdkSegment *segments = RVAL2GDKSEGMENTS(rbsegments, &n);
|
216
|
+
|
217
|
+
gdk_draw_segments(drawable, gc, segments, n);
|
218
|
+
|
219
|
+
g_free(segments);
|
220
|
+
|
221
|
+
return self;
|
222
|
+
}
|
223
|
+
|
224
|
+
static VALUE
|
225
|
+
rg_draw_rectangle(VALUE self, VALUE gc, VALUE filled, VALUE x, VALUE y, VALUE w, VALUE h)
|
226
|
+
{
|
227
|
+
gdk_draw_rectangle(_SELF(self), RVAL2GDKGC(gc),
|
228
|
+
RVAL2CBOOL(filled),
|
229
|
+
NUM2INT(x), NUM2INT(y),
|
230
|
+
NUM2INT(w), NUM2INT(h));
|
231
|
+
return self;
|
232
|
+
}
|
233
|
+
|
234
|
+
static VALUE
|
235
|
+
rg_draw_arc(VALUE self, VALUE gc, VALUE filled, VALUE x, VALUE y, VALUE w, VALUE h, VALUE a1, VALUE a2)
|
236
|
+
{
|
237
|
+
gdk_draw_arc(_SELF(self), RVAL2GDKGC(gc),
|
238
|
+
RVAL2CBOOL(filled),
|
239
|
+
NUM2INT(x), NUM2INT(y),
|
240
|
+
NUM2INT(w), NUM2INT(h),
|
241
|
+
NUM2INT(a1), NUM2INT(a2));
|
242
|
+
return self;
|
243
|
+
}
|
244
|
+
|
245
|
+
static VALUE
|
246
|
+
rg_draw_polygon(VALUE self, VALUE rbgc, VALUE rbfilled, VALUE rbpoints)
|
247
|
+
{
|
248
|
+
GdkDrawable *drawable = _SELF(self);
|
249
|
+
GdkGC *gc = RVAL2GDKGC(rbgc);
|
250
|
+
gboolean filled = RVAL2CBOOL(rbfilled);
|
251
|
+
long n;
|
252
|
+
GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n);
|
253
|
+
|
254
|
+
gdk_draw_polygon(drawable, gc, filled, points, n);
|
255
|
+
|
256
|
+
g_free(points);
|
257
|
+
|
258
|
+
return self;
|
259
|
+
}
|
260
|
+
|
261
|
+
struct rbgdk_rval2gdktrapezoids_args {
|
262
|
+
VALUE ary;
|
263
|
+
long n;
|
264
|
+
GdkTrapezoid *result;
|
265
|
+
};
|
266
|
+
|
267
|
+
static VALUE
|
268
|
+
rbgdk_rval2gdktrapezoids_body(VALUE value)
|
269
|
+
{
|
270
|
+
long i;
|
271
|
+
struct rbgdk_rval2gdktrapezoids_args *args = (struct rbgdk_rval2gdktrapezoids_args *)value;
|
272
|
+
|
273
|
+
for (i = 0; i < args->n; i++) {
|
274
|
+
VALUE trapezoids = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]);
|
275
|
+
|
276
|
+
if (RARRAY_LEN(trapezoids) != 6)
|
277
|
+
rb_raise(rb_eArgError, "trapezoid %ld should be array of size 6", i);
|
278
|
+
|
279
|
+
args->result[i].y1 = NUM2DBL(RARRAY_PTR(trapezoids)[0]);
|
280
|
+
args->result[i].x11 = NUM2DBL(RARRAY_PTR(trapezoids)[1]);
|
281
|
+
args->result[i].x21 = NUM2DBL(RARRAY_PTR(trapezoids)[2]);
|
282
|
+
args->result[i].y2 = NUM2DBL(RARRAY_PTR(trapezoids)[3]);
|
283
|
+
args->result[i].x12 = NUM2DBL(RARRAY_PTR(trapezoids)[4]);
|
284
|
+
args->result[i].x22 = NUM2DBL(RARRAY_PTR(trapezoids)[5]);
|
285
|
+
}
|
286
|
+
|
287
|
+
return Qnil;
|
288
|
+
}
|
289
|
+
|
290
|
+
static G_GNUC_NORETURN VALUE
|
291
|
+
rbgdk_rval2gdktrapezoids_rescue(VALUE value)
|
292
|
+
{
|
293
|
+
g_free(((struct rbgdk_rval2gdktrapezoids_args *)value)->result);
|
294
|
+
|
295
|
+
rb_exc_raise(rb_errinfo());
|
296
|
+
}
|
297
|
+
|
298
|
+
static GdkTrapezoid *
|
299
|
+
rbgdk_rval2gdktrapezoids(VALUE value, long *n)
|
300
|
+
{
|
301
|
+
struct rbgdk_rval2gdktrapezoids_args args;
|
302
|
+
|
303
|
+
args.ary = rb_ary_to_ary(value);
|
304
|
+
args.n = RARRAY_LEN(args.ary);
|
305
|
+
args.result = g_new(GdkTrapezoid, args.n + 1);
|
306
|
+
|
307
|
+
rb_rescue(rbgdk_rval2gdktrapezoids_body, (VALUE)&args,
|
308
|
+
rbgdk_rval2gdktrapezoids_rescue, (VALUE)&args);
|
309
|
+
|
310
|
+
if (n != NULL)
|
311
|
+
*n = args.n;
|
312
|
+
|
313
|
+
return args.result;
|
314
|
+
}
|
315
|
+
|
316
|
+
#define RVAL2GDKTRAPEZOIDS(value, n) rbgdk_rval2gdktrapezoids(value, n)
|
317
|
+
|
318
|
+
static VALUE
|
319
|
+
rg_draw_trapezoids(VALUE self, VALUE rbgc, VALUE rbtrapezoids)
|
320
|
+
{
|
321
|
+
GdkDrawable *drawable = _SELF(self);
|
322
|
+
GdkGC *gc = RVAL2GDKGC(rbgc);
|
323
|
+
long n;
|
324
|
+
GdkTrapezoid *trapezoids = RVAL2GDKTRAPEZOIDS(rbtrapezoids, &n);
|
325
|
+
|
326
|
+
gdk_draw_trapezoids(drawable, gc, trapezoids, n);
|
327
|
+
|
328
|
+
g_free(trapezoids);
|
329
|
+
|
330
|
+
return self;
|
331
|
+
}
|
332
|
+
|
333
|
+
static VALUE
|
334
|
+
rg_draw_glyphs(VALUE self, VALUE gc, VALUE font, VALUE x, VALUE y, VALUE glyphs)
|
335
|
+
{
|
336
|
+
gdk_draw_glyphs(_SELF(self), RVAL2GDKGC(gc), RVAL2PANGOFONT(font),
|
337
|
+
NUM2INT(x), NUM2INT(y),
|
338
|
+
RVAL2PANGOGLYPHSTRING(glyphs));
|
339
|
+
return self;
|
340
|
+
}
|
341
|
+
|
342
|
+
static VALUE
|
343
|
+
rg_draw_glyphs_transformed(VALUE self, VALUE gc, VALUE matrix, VALUE font, VALUE x, VALUE y, VALUE glyphs)
|
344
|
+
{
|
345
|
+
gdk_draw_glyphs_transformed(_SELF(self), RVAL2GDKGC(gc),
|
346
|
+
NIL_P(matrix) ? (PangoMatrix*)NULL : RVAL2PANGOMATRIX(matrix),
|
347
|
+
RVAL2PANGOFONT(font),
|
348
|
+
NUM2INT(x), NUM2INT(y),
|
349
|
+
RVAL2PANGOGLYPHSTRING(glyphs));
|
350
|
+
return self;
|
351
|
+
}
|
352
|
+
|
353
|
+
static VALUE
|
354
|
+
rg_draw_layout_line(int argc, VALUE *argv, VALUE self)
|
355
|
+
{
|
356
|
+
VALUE gc, x, y, line, fg, bg;
|
357
|
+
|
358
|
+
rb_scan_args(argc, argv, "42", &gc, &x, &y, &line, &fg, &bg);
|
359
|
+
|
360
|
+
gdk_draw_layout_line_with_colors(_SELF(self), RVAL2GDKGC(gc),
|
361
|
+
NUM2INT(x), NUM2INT(y),
|
362
|
+
RVAL2PANGOLAYOUTLINE(line),
|
363
|
+
RVAL2GDKCOLOR(fg),
|
364
|
+
RVAL2GDKCOLOR(bg));
|
365
|
+
|
366
|
+
return self;
|
367
|
+
}
|
368
|
+
|
369
|
+
static VALUE
|
370
|
+
rg_draw_layout(int argc, VALUE *argv, VALUE self)
|
371
|
+
{
|
372
|
+
VALUE gc, x, y, layout, fg, bg;
|
373
|
+
|
374
|
+
rb_scan_args(argc, argv, "42", &gc, &x, &y, &layout, &fg, &bg);
|
375
|
+
|
376
|
+
gdk_draw_layout_with_colors(_SELF(self), RVAL2GDKGC(gc),
|
377
|
+
NUM2INT(x), NUM2INT(y), RVAL2PANGOLAYOUT(layout),
|
378
|
+
RVAL2GDKCOLOR(fg),
|
379
|
+
RVAL2GDKCOLOR(bg));
|
380
|
+
|
381
|
+
return self;
|
382
|
+
}
|
383
|
+
|
384
|
+
static VALUE
|
385
|
+
rg_draw_drawable(VALUE self, VALUE gc, VALUE src, VALUE xsrc, VALUE ysrc, VALUE xdst, VALUE ydst, VALUE w, VALUE h)
|
386
|
+
{
|
387
|
+
gdk_draw_drawable(_SELF(self), RVAL2GDKGC(gc), _SELF(src),
|
388
|
+
NUM2INT(xsrc), NUM2INT(ysrc),
|
389
|
+
NUM2INT(xdst), NUM2INT(ydst),
|
390
|
+
NUM2INT(w), NUM2INT(h));
|
391
|
+
return self;
|
392
|
+
}
|
393
|
+
|
394
|
+
static VALUE
|
395
|
+
rg_draw_image(VALUE self, VALUE gc, VALUE image, VALUE xsrc, VALUE ysrc, VALUE xdst, VALUE ydst, VALUE w, VALUE h)
|
396
|
+
{
|
397
|
+
gdk_draw_image(_SELF(self), RVAL2GDKGC(gc),
|
398
|
+
RVAL2GDKIMAGE(image),
|
399
|
+
NUM2INT(xsrc), NUM2INT(ysrc),
|
400
|
+
NUM2INT(xdst), NUM2INT(ydst),
|
401
|
+
NUM2INT(w), NUM2INT(h));
|
402
|
+
return self;
|
403
|
+
}
|
404
|
+
|
405
|
+
static VALUE
|
406
|
+
rg_get_image(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
|
407
|
+
{
|
408
|
+
return GOBJ2RVAL(gdk_drawable_get_image(_SELF(self),
|
409
|
+
NUM2INT(x), NUM2INT(y),
|
410
|
+
NUM2INT(w), NUM2INT(h)));
|
411
|
+
}
|
412
|
+
|
413
|
+
static VALUE
|
414
|
+
rg_copy_to_image(VALUE self, VALUE image, VALUE xsrc, VALUE ysrc, VALUE xdst, VALUE ydst, VALUE w, VALUE h)
|
415
|
+
{
|
416
|
+
return GOBJ2RVAL(gdk_drawable_copy_to_image(_SELF(self),
|
417
|
+
RVAL2GDKIMAGE(image),
|
418
|
+
NUM2INT(xsrc), NUM2INT(ysrc),
|
419
|
+
NUM2INT(xdst), NUM2INT(ydst),
|
420
|
+
NUM2INT(w), NUM2INT(h)));
|
421
|
+
}
|
422
|
+
|
423
|
+
#ifdef GDK_WINDOWING_X11
|
424
|
+
static VALUE
|
425
|
+
rg_xid(VALUE self)
|
426
|
+
{
|
427
|
+
return ULONG2NUM(GDK_DRAWABLE_XID(_SELF(self)));
|
428
|
+
}
|
429
|
+
#endif
|
430
|
+
|
431
|
+
#ifdef GDK_WINDOWING_WIN32
|
432
|
+
static VALUE
|
433
|
+
rg_handle(VALUE self)
|
434
|
+
{
|
435
|
+
HGDIOBJ handle;
|
436
|
+
handle = gdk_win32_drawable_get_handle(_SELF(self));
|
437
|
+
return ULONG2NUM(GPOINTER_TO_UINT(handle));
|
438
|
+
}
|
439
|
+
#endif
|
440
|
+
|
441
|
+
static VALUE
|
442
|
+
rg_display(VALUE self)
|
443
|
+
{
|
444
|
+
return GOBJ2RVAL(gdk_drawable_get_display(_SELF(self)));
|
445
|
+
}
|
446
|
+
|
447
|
+
static VALUE
|
448
|
+
rg_screen(VALUE self)
|
449
|
+
{
|
450
|
+
return GOBJ2RVAL(gdk_drawable_get_screen(_SELF(self)));
|
451
|
+
}
|
452
|
+
|
453
|
+
#ifdef HAVE_RB_CAIRO_H
|
454
|
+
static VALUE
|
455
|
+
rg_create_cairo_context(VALUE self)
|
456
|
+
{
|
457
|
+
VALUE rb_cr;
|
458
|
+
cairo_t *cr;
|
459
|
+
cr = gdk_cairo_create(_SELF(self));
|
460
|
+
rb_cairo_check_status(cairo_status(cr));
|
461
|
+
rb_cr = CRCONTEXT2RVAL(cr);
|
462
|
+
cairo_destroy (cr);
|
463
|
+
return rb_cr;
|
464
|
+
}
|
465
|
+
#endif
|
466
|
+
|
467
|
+
void
|
468
|
+
Init_gdk_draw(VALUE mGdk)
|
469
|
+
{
|
470
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DRAWABLE, "Drawable", mGdk);
|
471
|
+
|
472
|
+
RG_DEF_METHOD(visual, 0);
|
473
|
+
RG_DEF_METHOD(set_colormap, 1);
|
474
|
+
RG_DEF_METHOD(colormap, 0);
|
475
|
+
RG_DEF_METHOD(depth, 0);
|
476
|
+
RG_DEF_METHOD(size, 0);
|
477
|
+
RG_DEF_METHOD(clip_region, 0);
|
478
|
+
RG_DEF_METHOD(visible_region, 0);
|
479
|
+
RG_DEF_METHOD(draw_point, 3);
|
480
|
+
RG_DEF_METHOD(draw_points, 2);
|
481
|
+
RG_DEF_METHOD(draw_line, 5);
|
482
|
+
RG_DEF_METHOD(draw_lines, 2);
|
483
|
+
RG_DEF_METHOD(draw_pixbuf, 11);
|
484
|
+
RG_DEF_METHOD(draw_segments, 2);
|
485
|
+
RG_DEF_METHOD(draw_rectangle, 6);
|
486
|
+
RG_DEF_METHOD(draw_arc, 8);
|
487
|
+
RG_DEF_METHOD(draw_polygon, 3);
|
488
|
+
RG_DEF_METHOD(draw_trapezoids, 2);
|
489
|
+
RG_DEF_METHOD(draw_glyphs, 5);
|
490
|
+
RG_DEF_METHOD(draw_glyphs_transformed, 6);
|
491
|
+
RG_DEF_METHOD(draw_layout_line, -1);
|
492
|
+
RG_DEF_METHOD(draw_layout, -1);
|
493
|
+
RG_DEF_METHOD(draw_drawable, 8);
|
494
|
+
RG_DEF_METHOD(draw_image, 8);
|
495
|
+
RG_DEF_METHOD(get_image, 4);
|
496
|
+
RG_DEF_METHOD(copy_to_image, 7);
|
497
|
+
|
498
|
+
#ifdef GDK_WINDOWING_X11
|
499
|
+
RG_DEF_METHOD(xid, 0);
|
500
|
+
#endif
|
501
|
+
#ifdef GDK_WINDOWING_WIN32
|
502
|
+
RG_DEF_METHOD(handle, 0);
|
503
|
+
#endif
|
504
|
+
RG_DEF_METHOD(display, 0);
|
505
|
+
RG_DEF_METHOD(screen, 0);
|
506
|
+
|
507
|
+
#ifdef HAVE_RB_CAIRO_H
|
508
|
+
RG_DEF_METHOD(create_cairo_context, 0);
|
509
|
+
#endif
|
510
|
+
|
511
|
+
#ifdef GDK_WINDOWING_X11
|
512
|
+
G_DEF_CLASS3("GdkDrawableImplX11", "DrawableImplX11", mGdk);
|
513
|
+
#elif defined(GDK_WINDOWING_WIN32)
|
514
|
+
G_DEF_CLASS3("GdkDrawableImplWin32", "DrawableImplWin32", mGdk);
|
515
|
+
#elif defined(GDK_WINDOWING_FB)
|
516
|
+
G_DEF_CLASS3("GdkDrawableFB", "DrawableFB", mGdk);
|
517
|
+
#endif
|
518
|
+
}
|
519
|
+
*/
|
520
|
+
|