Removed RCS-style IDs.
[ruby-evas.git] / src / rb_gradient.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::Gradient.new(evas) => gradient
30  *
31  * Creates an Evas::Gradient 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, grad);
38
39         grad->real = evas_object_gradient_add (e->real);
40
41         rb_call_super (1, &evas);
42
43         return self;
44 }
45
46 /*
47  * call-seq:
48  *  gradient.add_color(r, g, b, a, distance) => nil
49  *
50  * Adds a color to <i>gradient</i>.
51  */
52 static VALUE c_add_color (VALUE self, VALUE r, VALUE g, VALUE b,
53                           VALUE a, VALUE distance)
54 {
55         GET_OBJ (self, RbEvasObject, e);
56
57         Check_Type (r, T_FIXNUM);
58         Check_Type (g, T_FIXNUM);
59         Check_Type (b, T_FIXNUM);
60         Check_Type (a, T_FIXNUM);
61         Check_Type (distance, T_FIXNUM);
62
63         evas_object_gradient_color_add (e->real, FIX2INT (r), FIX2INT (g),
64                                         FIX2INT (b), FIX2INT (a),
65                                         FIX2INT (distance));
66
67         return Qnil;
68 }
69
70 /*
71  * call-seq:
72  *  gradient.clear_colors => nil
73  *
74  * Clears the colors of <i>gradient</i>.
75  */
76 static VALUE c_clear_colors (VALUE self)
77 {
78         GET_OBJ (self, RbEvasObject, e);
79
80         evas_object_gradient_colors_clear (e->real);
81
82         return Qnil;
83 }
84
85 /*
86  * call-seq:
87  *  gradient.angle => fixnum
88  *
89  * Returns the angle of <i>gradient</i>.
90  */
91 static VALUE c_angle_get (VALUE self)
92 {
93         GET_OBJ (self, RbEvasObject, e);
94
95         return INT2FIX (evas_object_gradient_angle_get (e->real));
96 }
97
98 /*
99  * call-seq:
100  *  gradient.angle(fixnum)
101  *
102  * Sets the angle of <i>gradient</i>.
103  */
104 static VALUE c_angle_set (VALUE self, VALUE val)
105 {
106         GET_OBJ (self, RbEvasObject, e);
107
108         Check_Type (val, T_FIXNUM);
109
110         evas_object_gradient_angle_set (e->real, FIX2INT (val));
111
112         return Qnil;
113 }
114
115 void Init_Gradient (void)
116 {
117         VALUE c = rb_define_class_under (mEvas, "Gradient", cEvasObject);
118
119         rb_define_method (c, "initialize", c_init, 1);
120         rb_define_method (c, "add_color", c_add_color, 5);
121         rb_define_method (c, "clear_colors", c_clear_colors, 0);
122         rb_define_method (c, "angle", c_angle_get, 0);
123         rb_define_method (c, "angle=", c_angle_set, 1);
124 }