Removed RCS-style IDs.
[ruby-evas.git] / src / rb_polygon.c
1 /*
2  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <ruby.h>
20
21 #include <Evas.h>
22
23 #include "rb_evas_main.h"
24 #include "rb_evas.h"
25 #include "rb_evas_object.h"
26
27 /*
28  * call-seq:
29  *  Evas::Polygon.new(evas) => polygon
30  *
31  * Creates an new Evas::Polygon object.
32  */
33 static VALUE c_init (VALUE self, VALUE evas)
34 {
35         CHECK_CLASS (evas, cEvas);
36         GET_OBJ (evas, RbEvas, e);
37         GET_OBJ (self, RbEvasObject, poly);
38
39         poly->real = evas_object_polygon_add (e->real);
40
41         rb_call_super (1, &evas);
42
43         return self;
44 }
45
46 /*
47  * call-seq:
48  *  polygon.add_point(x, y) => nil
49  *
50  * Adds a point to <i>polygon</i>.
51  */
52 static VALUE c_add_point (VALUE self, VALUE x, VALUE y)
53 {
54         GET_OBJ (self, RbEvasObject, e);
55
56         Check_Type (x, T_FIXNUM);
57         Check_Type (y, T_FIXNUM);
58
59         evas_object_polygon_point_add (e->real, FIX2INT (x), FIX2INT (y));
60
61         return Qnil;
62 }
63
64 /*
65  * call-seq:
66  *  polygon.clear_points => nil
67  *
68  * Clears the points of <i>polygon</i>.
69  */
70 static VALUE c_clear_points (VALUE self)
71 {
72         GET_OBJ (self, RbEvasObject, e);
73
74         evas_object_polygon_points_clear (e->real);
75
76         return Qnil;
77 }
78
79 void Init_Polygon (void)
80 {
81         VALUE c = rb_define_class_under (mEvas, "Polygon", cEvasObject);
82
83         rb_define_method (c, "initialize", c_init, 1);
84         rb_define_method (c, "add_point", c_add_point, 2);
85         rb_define_method (c, "clear_points", c_clear_points, 0);
86 }