2 * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <Ecore_Evas.h>
24 #include "../ecore/rb_ecore.h"
25 #include "../ecore_x/rb_window.h"
26 #include "rb_ecore_evas_main.h"
27 #include "rb_ecore_evas.h"
33 } RbEcoreEvasSoftwareX11;
35 static void c_mark (RbEcoreEvasSoftwareX11 *ee)
37 c_ecore_evas_mark (&ee->ee);
39 if (!NIL_P (ee->parent_window))
40 rb_gc_mark (ee->parent_window);
42 if (!NIL_P (ee->window))
43 rb_gc_mark (ee->window);
46 static void c_free (RbEcoreEvasSoftwareX11 *ee)
48 c_ecore_evas_free (&ee->ee, false);
53 static VALUE c_alloc (VALUE klass)
55 RbEcoreEvasSoftwareX11 *ee = NULL;
60 return Data_Make_Struct (klass, RbEcoreEvasSoftwareX11,
66 * Ecore::Evas::SoftwareX11.new([display, parent, x, y, w, h]) => swx11
68 * Creates an Ecore::Evas::SoftwareX11 object.
70 static VALUE c_init (int argc, VALUE *argv, VALUE self)
72 VALUE disp, parent, geom[4];
75 int i, igeom[4] = {0, 0, 0, 0};
77 GET_OBJ (self, RbEcoreEvasSoftwareX11, ee);
79 rb_scan_args (argc, argv, "06", &disp, &parent,
80 &geom[0], &geom[1], &geom[2], &geom[3]);
83 Check_Type (disp, T_STRING);
84 cdisp = StringValuePtr (disp);
87 if (!NIL_P (parent)) {
88 CHECK_CLASS (parent, cWindow);
89 Data_Get_Struct (parent, RbWindow, win);
92 for (i = 0; i < 4; i++)
93 if (!NIL_P (geom[i])) {
94 Check_Type (geom[i], T_FIXNUM);
95 igeom[i] = FIX2INT (geom[i]);
98 ee->ee.real = ecore_evas_software_x11_new (cdisp,
102 ee->parent_window = parent;
105 rb_call_super (argc, argv);
112 * swx11.window => window
114 * Returns the <code>Ecore::X::Window</code> object for <i>swx11</i>.
116 static VALUE c_window_get (VALUE self)
120 GET_OBJ (self, RbEcoreEvasSoftwareX11, ee);
122 if (NIL_P (ee->window)) {
123 w = ecore_evas_software_x11_window_get (ee->ee.real);
124 ee->window = TO_ECORE_X_WINDOW (self, w);
130 void Init_SoftwareX11 (void)
134 c = rb_define_class_under (mEvas, "SoftwareX11", cEcoreEvas);
136 rb_define_alloc_func (c, c_alloc);
137 rb_define_method (c, "initialize", c_init, -1);
138 rb_define_method (c, "window", c_window_get, 0);