gdk3 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,305 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2004 Ruby-GNOME2 Project Team
|
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
|
+
#include "rbgdk3private.h"
|
26
|
+
|
27
|
+
#define RG_TARGET_NAMESPACE mProperty
|
28
|
+
|
29
|
+
/* deprecated
|
30
|
+
static VALUE
|
31
|
+
rg_s_text_property_to_text_list(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
32
|
+
{
|
33
|
+
gint num, i;
|
34
|
+
gchar** list;
|
35
|
+
VALUE ret = Qnil;
|
36
|
+
|
37
|
+
if (argc == 3) {
|
38
|
+
VALUE encoding, format, text;
|
39
|
+
rb_scan_args(argc, argv, "30", &encoding, &format, &text);
|
40
|
+
StringValue(text);
|
41
|
+
|
42
|
+
num = gdk_text_property_to_text_list(RVAL2ATOM(encoding),
|
43
|
+
NUM2INT(format),
|
44
|
+
(const guchar*)RVAL2CSTR(text),
|
45
|
+
RSTRING_LEN(text), &list);
|
46
|
+
} else {
|
47
|
+
VALUE display, encoding, format, text;
|
48
|
+
rb_scan_args(argc, argv, "40", &display, &encoding, &format, &text);
|
49
|
+
StringValue(text);
|
50
|
+
|
51
|
+
num = gdk_text_property_to_text_list_for_display(RVAL2GDKDISPLAYOBJECT(display),
|
52
|
+
RVAL2ATOM(encoding),
|
53
|
+
NUM2INT(format),
|
54
|
+
(const guchar*)RVAL2CSTR(text),
|
55
|
+
RSTRING_LEN(text),
|
56
|
+
&list);
|
57
|
+
}
|
58
|
+
|
59
|
+
ret = rb_ary_new2(num);
|
60
|
+
for (i =0; i < num; i++){
|
61
|
+
rb_ary_push(ret, CSTR2RVAL(list[i]));
|
62
|
+
}
|
63
|
+
gdk_free_text_list(list);
|
64
|
+
return ret;
|
65
|
+
}
|
66
|
+
*/
|
67
|
+
|
68
|
+
/* TODO
|
69
|
+
static VALUE
|
70
|
+
rg_s_text_property_to_utf8_list(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
71
|
+
{
|
72
|
+
gint num, i;
|
73
|
+
gchar** list;
|
74
|
+
VALUE ret = Qnil;
|
75
|
+
|
76
|
+
if (argc == 3) {
|
77
|
+
VALUE encoding, format, text;
|
78
|
+
rb_scan_args(argc, argv, "30", &encoding, &format, &text);
|
79
|
+
StringValue(text);
|
80
|
+
|
81
|
+
num = gdk_text_property_to_utf8_list(RVAL2ATOM(encoding),
|
82
|
+
NUM2INT(format),
|
83
|
+
(const guchar*)RVAL2CSTR(text),
|
84
|
+
RSTRING_LEN(text), &list);
|
85
|
+
} else {
|
86
|
+
VALUE display, encoding, format, text;
|
87
|
+
rb_scan_args(argc, argv, "40", &display, &encoding, &format, &text);
|
88
|
+
StringValue(text);
|
89
|
+
|
90
|
+
num = gdk_text_property_to_utf8_list_for_display(RVAL2GDKDISPLAYOBJECT(display),
|
91
|
+
RVAL2ATOM(encoding),
|
92
|
+
NUM2INT(format),
|
93
|
+
(const guchar*)RVAL2CSTR(text),
|
94
|
+
RSTRING_LEN(text),
|
95
|
+
&list);
|
96
|
+
}
|
97
|
+
|
98
|
+
ret = rb_ary_new2(num);
|
99
|
+
for (i =0; i < num; i++){
|
100
|
+
rb_ary_push(ret, CSTR2RVAL(list[i]));
|
101
|
+
}
|
102
|
+
g_strfreev(list);
|
103
|
+
return ret;
|
104
|
+
}
|
105
|
+
*/
|
106
|
+
|
107
|
+
/* deprecated
|
108
|
+
static VALUE
|
109
|
+
rg_s_string_to_compound_text(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
110
|
+
{
|
111
|
+
gint num;
|
112
|
+
GdkAtom encoding;
|
113
|
+
gint format;
|
114
|
+
guchar *ctext;
|
115
|
+
gint length;
|
116
|
+
|
117
|
+
if (argc == 1) {
|
118
|
+
VALUE str;
|
119
|
+
rb_scan_args(argc, argv, "10", &str);
|
120
|
+
num = gdk_string_to_compound_text(RVAL2CSTR(str),
|
121
|
+
&encoding, &format,
|
122
|
+
&ctext, &length);
|
123
|
+
} else {
|
124
|
+
VALUE display, str;
|
125
|
+
|
126
|
+
rb_scan_args(argc, argv, "20", &display, &str);
|
127
|
+
num = gdk_string_to_compound_text_for_display(RVAL2GDKDISPLAYOBJECT(display),
|
128
|
+
RVAL2CSTR(str),
|
129
|
+
&encoding, &format,
|
130
|
+
&ctext, &length);
|
131
|
+
}
|
132
|
+
|
133
|
+
if (num == 0){
|
134
|
+
VALUE ret = CSTR2RVAL((const char*)ctext);
|
135
|
+
gdk_free_compound_text(ctext);
|
136
|
+
return rb_ary_new3(3, GDKATOM2RVAL(encoding),
|
137
|
+
INT2NUM(format), ret);
|
138
|
+
} else {
|
139
|
+
rb_raise(rb_eRuntimeError, "failed to converts a string %d\n", num);
|
140
|
+
}
|
141
|
+
return Qnil;
|
142
|
+
}
|
143
|
+
*/
|
144
|
+
|
145
|
+
static VALUE
|
146
|
+
rg_s_utf8_to_string_target(G_GNUC_UNUSED VALUE self, VALUE str)
|
147
|
+
{
|
148
|
+
return CSTR2RVAL((const char*)gdk_utf8_to_string_target(RVAL2CSTR(str)));
|
149
|
+
}
|
150
|
+
|
151
|
+
/* deprecated
|
152
|
+
static VALUE
|
153
|
+
rg_s_utf8_to_compound_text(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
154
|
+
{
|
155
|
+
GdkAtom encoding;
|
156
|
+
gint format;
|
157
|
+
guchar *ctext;
|
158
|
+
gint length;
|
159
|
+
gint ret;
|
160
|
+
|
161
|
+
if (argc == 1) {
|
162
|
+
VALUE str;
|
163
|
+
rb_scan_args(argc, argv, "10", &str);
|
164
|
+
|
165
|
+
ret = gdk_utf8_to_compound_text(RVAL2CSTR(str),
|
166
|
+
&encoding, &format,
|
167
|
+
&ctext, &length);
|
168
|
+
} else {
|
169
|
+
VALUE display, str;
|
170
|
+
|
171
|
+
rb_scan_args(argc, argv, "20", &display, &str);
|
172
|
+
ret = gdk_utf8_to_compound_text_for_display(RVAL2GDKDISPLAYOBJECT(display),
|
173
|
+
RVAL2CSTR(str),
|
174
|
+
&encoding, &format,
|
175
|
+
&ctext, &length);
|
176
|
+
}
|
177
|
+
|
178
|
+
if (ret){
|
179
|
+
VALUE val = CSTR2RVAL((const char*)ctext);
|
180
|
+
gdk_free_compound_text(ctext);
|
181
|
+
return rb_ary_new3(3, GDKATOM2RVAL(encoding),
|
182
|
+
INT2NUM(format), val);
|
183
|
+
} else {
|
184
|
+
rb_raise(rb_eRuntimeError, "failed to converts a string %d\n", ret);
|
185
|
+
}
|
186
|
+
return Qnil;
|
187
|
+
}
|
188
|
+
*/
|
189
|
+
|
190
|
+
/* TODO
|
191
|
+
static VALUE
|
192
|
+
rg_s_change(int argc, VALUE *argv, VALUE self)
|
193
|
+
{
|
194
|
+
int fmt, len;
|
195
|
+
void* dat;
|
196
|
+
GdkAtom ntype;
|
197
|
+
VALUE win, property, type, size= Qnil, mode, src;
|
198
|
+
|
199
|
+
if(6 == argc)
|
200
|
+
rb_scan_args(argc, argv, "60", &win, &property, &type, &size, &mode, &src);
|
201
|
+
else
|
202
|
+
rb_scan_args(argc, argv, "50", &win, &property, &type, &mode, &src);
|
203
|
+
|
204
|
+
rbgtk_atom2selectiondata(type, size, src, &ntype, &dat, &fmt, &len);
|
205
|
+
|
206
|
+
gdk_property_change(RVAL2GDKWINDOW(win), RVAL2ATOM(property),
|
207
|
+
ntype, fmt, RVAL2GDKPROPMODE(mode), dat, len);
|
208
|
+
|
209
|
+
rbgtk_atom2selectiondata_free(ntype, dat);
|
210
|
+
|
211
|
+
return self;
|
212
|
+
}
|
213
|
+
*/
|
214
|
+
|
215
|
+
static VALUE
|
216
|
+
rg_s_get(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
217
|
+
{
|
218
|
+
/* for argument processing */
|
219
|
+
GdkAtom rtype;
|
220
|
+
gint rfmt, rlen;
|
221
|
+
guchar* rdat;
|
222
|
+
VALUE win, property, type, offset=INT2FIX(0), length=INT2FIX(9999), delete;
|
223
|
+
|
224
|
+
/* for inner processing */
|
225
|
+
gint i;
|
226
|
+
size_t j;
|
227
|
+
VALUE ret = 0;
|
228
|
+
|
229
|
+
if(6 == argc)
|
230
|
+
rb_scan_args(argc, argv, "60", &win, &property, &type, &offset, &length, &delete);
|
231
|
+
else
|
232
|
+
rb_scan_args(argc, argv, "40", &win, &property, &type, &delete);
|
233
|
+
|
234
|
+
if(gdk_property_get(RVAL2GDKWINDOW(win), RVAL2ATOM(property), RVAL2ATOM(type),
|
235
|
+
NUM2INT(offset), NUM2INT(length),
|
236
|
+
RVAL2CBOOL(delete), &rtype, &rfmt, &rlen, &rdat) == FALSE){
|
237
|
+
return Qnil;
|
238
|
+
}
|
239
|
+
|
240
|
+
switch(rfmt){
|
241
|
+
case 8:
|
242
|
+
default:
|
243
|
+
ret = RBG_STRING_SET_UTF8_ENCODING(rb_str_new((const char*)rdat, rlen));
|
244
|
+
break;
|
245
|
+
|
246
|
+
case 16:
|
247
|
+
ret = rb_ary_new();
|
248
|
+
|
249
|
+
for( i = 0; i < rlen; i++){
|
250
|
+
rb_ary_push(ret, rb_Integer(((unsigned short*)rdat)[i]));
|
251
|
+
}
|
252
|
+
break;
|
253
|
+
|
254
|
+
case 32:
|
255
|
+
ret = rb_ary_new();
|
256
|
+
|
257
|
+
if(rtype != GDK_SELECTION_TYPE_ATOM){
|
258
|
+
for(j = 0; j < (rlen/sizeof(unsigned long)); j++){
|
259
|
+
rb_ary_push(ret, INT2FIX(((unsigned long*)rdat)[j]));
|
260
|
+
}
|
261
|
+
} else {
|
262
|
+
for(j = 0; j < (rlen/sizeof(unsigned long)); j++){
|
263
|
+
rb_ary_push(ret, GDKATOM2RVAL((GdkAtom)((unsigned long*)rdat)[j]));
|
264
|
+
}
|
265
|
+
}
|
266
|
+
break;
|
267
|
+
}
|
268
|
+
|
269
|
+
return rb_ary_new3(3, GDKATOM2RVAL(rtype),
|
270
|
+
ret, INT2NUM(rlen));
|
271
|
+
}
|
272
|
+
|
273
|
+
static VALUE
|
274
|
+
rg_s_delete(VALUE self, VALUE win, VALUE property)
|
275
|
+
{
|
276
|
+
gdk_property_delete(RVAL2GDKWINDOW(win), RVAL2ATOM(property));
|
277
|
+
return self;
|
278
|
+
}
|
279
|
+
|
280
|
+
void
|
281
|
+
Init_gdk_property(VALUE mGdk)
|
282
|
+
{
|
283
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Property");
|
284
|
+
|
285
|
+
/* deprecated
|
286
|
+
RG_DEF_SMETHOD(text_property_to_text_list, -1);
|
287
|
+
*/
|
288
|
+
/* TODO
|
289
|
+
RG_DEF_SMETHOD(text_property_to_utf8_list, -1);
|
290
|
+
*/
|
291
|
+
/* deprecated
|
292
|
+
RG_DEF_SMETHOD(string_to_compound_text, -1);
|
293
|
+
*/
|
294
|
+
RG_DEF_SMETHOD(utf8_to_string_target, 1);
|
295
|
+
/* deprecated
|
296
|
+
RG_DEF_SMETHOD(utf8_to_compound_text, -1);
|
297
|
+
*/
|
298
|
+
/* TODO
|
299
|
+
RG_DEF_SMETHOD(change, -1);
|
300
|
+
*/
|
301
|
+
RG_DEF_SMETHOD(get, -1);
|
302
|
+
RG_DEF_SMETHOD(delete, 2);
|
303
|
+
|
304
|
+
G_DEF_CLASS(GDK_TYPE_PROP_MODE, "PropMode", RG_TARGET_NAMESPACE);
|
305
|
+
}
|
@@ -0,0 +1,140 @@
|
|
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
|
+
* 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
|
+
#include "rbgdk3private.h"
|
26
|
+
|
27
|
+
#define RG_TARGET_NAMESPACE cRectangle
|
28
|
+
#define _SELF(r) (RVAL2GDKRECTANGLE(r))
|
29
|
+
|
30
|
+
static VALUE
|
31
|
+
rg_initialize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
|
32
|
+
{
|
33
|
+
GdkRectangle new;
|
34
|
+
|
35
|
+
new.x = NUM2INT(x);
|
36
|
+
new.y = NUM2INT(y);
|
37
|
+
new.width = NUM2INT(width);
|
38
|
+
new.height = NUM2INT(height);
|
39
|
+
|
40
|
+
G_INITIALIZE(self, &new);
|
41
|
+
return Qnil;
|
42
|
+
}
|
43
|
+
|
44
|
+
static VALUE
|
45
|
+
rg_intersect(VALUE self, VALUE other)
|
46
|
+
{
|
47
|
+
GdkRectangle dest;
|
48
|
+
gboolean ret = gdk_rectangle_intersect(_SELF(self), _SELF(other), &dest);
|
49
|
+
return ret ? GDKRECTANGLE2RVAL(&dest) : Qnil;
|
50
|
+
}
|
51
|
+
|
52
|
+
static VALUE
|
53
|
+
rg_union(VALUE self, VALUE other)
|
54
|
+
{
|
55
|
+
GdkRectangle dest;
|
56
|
+
gdk_rectangle_union(_SELF(self), _SELF(other), &dest);
|
57
|
+
return GDKRECTANGLE2RVAL(&dest);
|
58
|
+
}
|
59
|
+
|
60
|
+
/* Struct accessors */
|
61
|
+
static VALUE
|
62
|
+
rg_x(VALUE self)
|
63
|
+
{
|
64
|
+
return INT2NUM(_SELF(self)->x);
|
65
|
+
}
|
66
|
+
|
67
|
+
static VALUE
|
68
|
+
rg_y(VALUE self)
|
69
|
+
{
|
70
|
+
return INT2NUM(_SELF(self)->y);
|
71
|
+
}
|
72
|
+
|
73
|
+
static VALUE
|
74
|
+
rg_width(VALUE self)
|
75
|
+
{
|
76
|
+
return INT2NUM(_SELF(self)->width);
|
77
|
+
}
|
78
|
+
|
79
|
+
static VALUE
|
80
|
+
rg_height(VALUE self)
|
81
|
+
{
|
82
|
+
return INT2NUM(_SELF(self)->height);
|
83
|
+
}
|
84
|
+
|
85
|
+
static VALUE
|
86
|
+
rg_set_x(VALUE self, VALUE x)
|
87
|
+
{
|
88
|
+
_SELF(self)->x = NUM2INT(x);
|
89
|
+
return self;
|
90
|
+
}
|
91
|
+
|
92
|
+
static VALUE
|
93
|
+
rg_set_y(VALUE self, VALUE y)
|
94
|
+
{
|
95
|
+
_SELF(self)->y = NUM2INT(y);
|
96
|
+
return self;
|
97
|
+
}
|
98
|
+
|
99
|
+
static VALUE
|
100
|
+
rg_set_width(VALUE self, VALUE width)
|
101
|
+
{
|
102
|
+
_SELF(self)->width = NUM2INT(width);
|
103
|
+
return self;
|
104
|
+
}
|
105
|
+
|
106
|
+
static VALUE
|
107
|
+
rg_set_height(VALUE self, VALUE height)
|
108
|
+
{
|
109
|
+
_SELF(self)->height = NUM2INT(height);
|
110
|
+
return self;
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
rg_to_a(VALUE self)
|
115
|
+
{
|
116
|
+
GdkRectangle* a = _SELF(self);
|
117
|
+
return rb_ary_new3(4, INT2FIX(a->x), INT2FIX(a->y),
|
118
|
+
INT2FIX(a->width), INT2FIX(a->height));
|
119
|
+
}
|
120
|
+
|
121
|
+
void
|
122
|
+
Init_gdk_rectangle(VALUE mGdk)
|
123
|
+
{
|
124
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_RECTANGLE, "Rectangle", mGdk);
|
125
|
+
|
126
|
+
RG_DEF_METHOD(initialize, 4);
|
127
|
+
RG_DEF_METHOD(intersect, 1);
|
128
|
+
RG_DEF_ALIAS("&", "intersect");
|
129
|
+
RG_DEF_METHOD(union, 1);
|
130
|
+
RG_DEF_ALIAS("|", "union");
|
131
|
+
RG_DEF_METHOD(x, 0);
|
132
|
+
RG_DEF_METHOD(y, 0);
|
133
|
+
RG_DEF_METHOD(width, 0);
|
134
|
+
RG_DEF_METHOD(height, 0);
|
135
|
+
RG_DEF_METHOD(set_x, 1);
|
136
|
+
RG_DEF_METHOD(set_y, 1);
|
137
|
+
RG_DEF_METHOD(set_width, 1);
|
138
|
+
RG_DEF_METHOD(set_height, 1);
|
139
|
+
RG_DEF_METHOD(to_a, 0);
|
140
|
+
}
|
data/ext/gdk3/rbgdkrgb.c
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
|
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
|
+
|
28
|
+
#define RG_TARGET_NAMESPACE mRGB
|
29
|
+
#define RVAL2DRAW(s) RVAL2GDKDRAWABLE(s)
|
30
|
+
|
31
|
+
static VALUE
|
32
|
+
rg_s_draw_rgb_image(int argc, VALUE *argv, VALUE self)
|
33
|
+
{
|
34
|
+
VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
|
35
|
+
|
36
|
+
rb_scan_args(argc, argv, "92", &win, &gc, &x, &y, &w, &h, &dither,
|
37
|
+
&buf, &rowstride, &xdith, &ydith);
|
38
|
+
|
39
|
+
if (argc == 9){
|
40
|
+
gdk_draw_rgb_image(RVAL2DRAW(win), RVAL2GDKGC(gc),
|
41
|
+
NUM2INT(x), NUM2INT(y),
|
42
|
+
NUM2INT(w), NUM2INT(h),
|
43
|
+
RVAL2GDKRGBDITHER(dither),
|
44
|
+
(guchar*)RVAL2CSTR(buf),
|
45
|
+
NUM2INT(rowstride));
|
46
|
+
} else {
|
47
|
+
gdk_draw_rgb_image_dithalign(RVAL2DRAW(win), RVAL2GDKGC(gc),
|
48
|
+
NUM2INT(x), NUM2INT(y),
|
49
|
+
NUM2INT(w), NUM2INT(h),
|
50
|
+
RVAL2GDKRGBDITHER(dither),
|
51
|
+
(guchar*)RVAL2CSTR(buf),
|
52
|
+
NUM2INT(rowstride),
|
53
|
+
NUM2INT(xdith), NUM2INT(ydith));
|
54
|
+
}
|
55
|
+
|
56
|
+
return self;
|
57
|
+
}
|
58
|
+
|
59
|
+
static VALUE
|
60
|
+
rg_s_draw_indexed_image(VALUE self, VALUE win, VALUE rbgc, VALUE rbx, VALUE rby,
|
61
|
+
VALUE rbwidth, VALUE rbheight, VALUE rbdither,
|
62
|
+
VALUE rbbuf, VALUE rbrowstride, VALUE rbcolors)
|
63
|
+
{
|
64
|
+
GdkDrawable *drawable = RVAL2DRAW(win);
|
65
|
+
GdkGC *gc = RVAL2GDKGC(rbgc);
|
66
|
+
gint x = NUM2INT(rbx);
|
67
|
+
gint y = NUM2INT(rby);
|
68
|
+
gint width = NUM2INT(rbwidth);
|
69
|
+
gint height = NUM2INT(rbheight);
|
70
|
+
GdkRgbDither dither = RVAL2GDKRGBDITHER(rbdither);
|
71
|
+
const guchar *buf = (const guchar *)RVAL2CSTR(rbbuf);
|
72
|
+
gint rowstride = NUM2INT(rbrowstride);
|
73
|
+
long n;
|
74
|
+
guint32 *colors = RVAL2GUINT32S(rbcolors, n);
|
75
|
+
GdkRgbCmap *cmap;
|
76
|
+
|
77
|
+
if (n < 0 || n > 255) {
|
78
|
+
g_free(colors);
|
79
|
+
|
80
|
+
rb_raise(rb_eArgError, "colors: out of range (0 - 255)");
|
81
|
+
}
|
82
|
+
|
83
|
+
cmap = gdk_rgb_cmap_new(colors, n);
|
84
|
+
|
85
|
+
g_free(colors);
|
86
|
+
|
87
|
+
gdk_draw_indexed_image(drawable, gc, x, y, width, height, dither, buf, rowstride, cmap);
|
88
|
+
|
89
|
+
gdk_rgb_cmap_free(cmap);
|
90
|
+
|
91
|
+
return self;
|
92
|
+
}
|
93
|
+
|
94
|
+
static VALUE
|
95
|
+
rg_s_draw_gray_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w, VALUE h, VALUE dither, VALUE buf, VALUE rowstride)
|
96
|
+
{
|
97
|
+
gdk_draw_gray_image(RVAL2DRAW(win), RVAL2GDKGC(gc),
|
98
|
+
NUM2INT(x), NUM2INT(y),
|
99
|
+
NUM2INT(w), NUM2INT(h),
|
100
|
+
RVAL2GDKRGBDITHER(dither),
|
101
|
+
(guchar*)RVAL2CSTR(buf),
|
102
|
+
NUM2INT(rowstride));
|
103
|
+
return self;
|
104
|
+
}
|
105
|
+
|
106
|
+
static VALUE
|
107
|
+
rg_s_draw_rgb_32_image(int argc, VALUE *argv, VALUE self)
|
108
|
+
{
|
109
|
+
VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
|
110
|
+
|
111
|
+
rb_scan_args(argc, argv, "92", &win, &gc, &x, &y, &w, &h, &dither,
|
112
|
+
&buf, &rowstride, &xdith, &ydith);
|
113
|
+
|
114
|
+
if (argc == 9){
|
115
|
+
gdk_draw_rgb_32_image(RVAL2DRAW(win), RVAL2GDKGC(gc),
|
116
|
+
NUM2INT(x), NUM2INT(y),
|
117
|
+
NUM2INT(w), NUM2INT(h),
|
118
|
+
RVAL2GDKRGBDITHER(dither),
|
119
|
+
(guchar*)RVAL2CSTR(buf),
|
120
|
+
NUM2INT(rowstride));
|
121
|
+
} else {
|
122
|
+
gdk_draw_rgb_32_image_dithalign(RVAL2DRAW(win), RVAL2GDKGC(gc),
|
123
|
+
NUM2INT(x), NUM2INT(y),
|
124
|
+
NUM2INT(w), NUM2INT(h),
|
125
|
+
RVAL2GDKRGBDITHER(dither),
|
126
|
+
(guchar*)RVAL2CSTR(buf),
|
127
|
+
NUM2INT(rowstride), NUM2INT(xdith), NUM2INT(ydith));
|
128
|
+
}
|
129
|
+
return self;
|
130
|
+
}
|
131
|
+
|
132
|
+
static VALUE
|
133
|
+
rg_s_find_color(VALUE self, VALUE colormap, VALUE color)
|
134
|
+
{
|
135
|
+
gdk_rgb_find_color(RVAL2GDKCOLORMAP(colormap),
|
136
|
+
RVAL2GDKCOLOR(color));
|
137
|
+
return self;
|
138
|
+
}
|
139
|
+
|
140
|
+
static VALUE
|
141
|
+
rg_s_set_install(VALUE self, VALUE install)
|
142
|
+
{
|
143
|
+
gdk_rgb_set_install(RVAL2CBOOL(install));
|
144
|
+
return self;
|
145
|
+
}
|
146
|
+
|
147
|
+
static VALUE
|
148
|
+
rg_s_set_min_colors(VALUE self, VALUE min_colors)
|
149
|
+
{
|
150
|
+
gdk_rgb_set_min_colors(NUM2INT(min_colors));
|
151
|
+
return self;
|
152
|
+
}
|
153
|
+
|
154
|
+
static VALUE
|
155
|
+
rg_s_visual(G_GNUC_UNUSED VALUE self)
|
156
|
+
{
|
157
|
+
return GOBJ2RVAL(gdk_rgb_get_visual());
|
158
|
+
}
|
159
|
+
|
160
|
+
static VALUE
|
161
|
+
rg_s_colormap(G_GNUC_UNUSED VALUE self)
|
162
|
+
{
|
163
|
+
return GOBJ2RVAL(gdk_rgb_get_colormap());
|
164
|
+
}
|
165
|
+
|
166
|
+
static VALUE
|
167
|
+
rg_s_ditherable_p(G_GNUC_UNUSED VALUE self)
|
168
|
+
{
|
169
|
+
return CBOOL2RVAL(gdk_rgb_ditherable());
|
170
|
+
}
|
171
|
+
|
172
|
+
static VALUE
|
173
|
+
rg_s_set_verbose(VALUE self, VALUE verbose)
|
174
|
+
{
|
175
|
+
gdk_rgb_set_verbose(RVAL2CBOOL(verbose));
|
176
|
+
return self;
|
177
|
+
}
|
178
|
+
|
179
|
+
void
|
180
|
+
Init_gdk_rgb(VALUE mGdk)
|
181
|
+
{
|
182
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "RGB");
|
183
|
+
|
184
|
+
RG_DEF_SMETHOD(draw_rgb_image, -1);
|
185
|
+
RG_DEF_SMETHOD(draw_indexed_image, 10);
|
186
|
+
RG_DEF_SMETHOD(draw_gray_image, 9);
|
187
|
+
RG_DEF_SMETHOD(draw_rgb_32_image, -1);
|
188
|
+
RG_DEF_SMETHOD(find_color, 2);
|
189
|
+
RG_DEF_SMETHOD(set_install, 1);
|
190
|
+
RG_DEF_SMETHOD(set_min_colors, 0);
|
191
|
+
RG_DEF_SMETHOD(visual, 0);
|
192
|
+
RG_DEF_SMETHOD(colormap, 0);
|
193
|
+
RG_DEF_SMETHOD_P(ditherable, 0);
|
194
|
+
RG_DEF_SMETHOD(set_verbose, 1);
|
195
|
+
|
196
|
+
G_DEF_CLASS(GDK_TYPE_RGB_DITHER, "Dither", RG_TARGET_NAMESPACE);
|
197
|
+
}
|
198
|
+
*/
|
199
|
+
|