2 * $Id: rb_gl_x11.c 100 2004-08-27 09:31:26Z tilman $
4 * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <Ecore_Evas.h>
26 #include "../ecore/rb_ecore.h"
27 #include "../ecore_x/rb_window.h"
28 #include "rb_ecore_evas_main.h"
29 #include "rb_ecore_evas.h"
37 static void c_mark (RbEcoreEvasGlX11 *ee)
39 c_ecore_evas_mark (&ee->ee);
41 if (!NIL_P (ee->parent_window))
42 rb_gc_mark (ee->parent_window);
44 if (!NIL_P (ee->window))
45 rb_gc_mark (ee->window);
48 static void c_free (RbEcoreEvasGlX11 *ee)
50 c_ecore_evas_free (&ee->ee, false);
57 * Ecore::Evas::GlX11.new([display, parent, x, y, w, h]) => glx11
59 * Creates an Ecore::Evas::GlX11 object.
61 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
63 VALUE self, disp, parent, geom[4];
64 RbEcoreEvasGlX11 *ee = NULL;
67 int i, igeom[4] = {0, 0, 0, 0};
69 self = Data_Make_Struct (klass, RbEcoreEvasGlX11,
72 rb_scan_args (argc, argv, "06", &disp, &parent,
73 &geom[0], &geom[1], &geom[2], &geom[3]);
76 Check_Type (disp, T_STRING);
77 cdisp = StringValuePtr (disp);
80 if (!NIL_P (parent)) {
81 CHECK_CLASS (parent, cWindow);
82 Data_Get_Struct (parent, RbWindow, win);
85 for (i = 0; i < 4; i++)
86 if (!NIL_P (geom[i])) {
87 Check_Type (geom[i], T_FIXNUM);
88 igeom[i] = FIX2INT (geom[i]);
94 ee->ee.real = ecore_evas_gl_x11_new (cdisp,
98 ee->parent_window = parent;
101 rb_obj_call_init (self, 0, NULL);
108 * glx11.window => window
110 * Returns the <code>Ecore::X::Window</code> object for <i>glx11</i>.
112 static VALUE c_window_get (VALUE self)
116 GET_OBJ (self, RbEcoreEvasGlX11, ee);
118 if (NIL_P (ee->window)) {
119 w = ecore_evas_gl_x11_window_get (ee->ee.real);
120 ee->window = TO_ECORE_X_WINDOW (self, w);
126 void Init_GlX11 (void)
130 rb_require ("ecore_x");
132 c = rb_define_class_under (mEvas, "GlX11", cEcoreEvas);
134 rb_define_singleton_method (c, "new", c_new, -1);
135 rb_define_method (c, "window", c_window_get, 0);