2 * $Id: rb_text.c 354 2006-02-10 18:14:08Z tilman $
4 * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
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
25 #include "rb_evas_main.h"
27 #include "rb_evas_object.h"
31 * Evas::Text.new(evas) => text
33 * Creates an Evas::Text object.
35 static VALUE c_init (VALUE self, VALUE evas)
37 CHECK_CLASS (evas, cEvas);
38 GET_OBJ (evas, RbEvas, e);
39 GET_OBJ (self, RbEvasObject, text);
41 text->real = evas_object_text_add (e->real);
43 rb_call_super (1, &evas);
50 * text.font_source => string or nil
52 * Returns the font source of <i>text</i>.
54 static VALUE c_font_source_get (VALUE self)
58 GET_OBJ (self, RbEvasObject, e);
60 if (!(tmp = evas_object_text_font_source_get (e->real)))
63 return rb_str_new2 (tmp);
68 * text.font_source(source)
70 * Sets the font source of <i>text</i>.
72 static VALUE c_font_source_set (VALUE self, VALUE val)
74 GET_OBJ (self, RbEvasObject, e);
76 Check_Type (val, T_STRING);
78 evas_object_text_font_source_set (e->real, StringValuePtr (val));
85 * text.get_font => array
87 * Returns the font name and font size of <i>text</i>.
89 * text.set_font("vera", 10) #=> nil
90 * text_get_font #=> ["vera", 10]
92 static VALUE c_get_font (VALUE self)
95 Evas_Font_Size size = 0;
97 GET_OBJ (self, RbEvasObject, e);
99 evas_object_text_font_get (e->real, &font, &size);
101 return rb_ary_new3 (2, font ? rb_str_new2 (font) : Qnil,
107 * text.set_font(font, size) => nil
109 * Sets the font name and font size of <i>text</i>.
111 * text.set_font("vera", 10) #=> nil
113 static VALUE c_set_font (VALUE self, VALUE font, VALUE size)
115 GET_OBJ (self, RbEvasObject, e);
117 Check_Type (font, T_STRING);
118 Check_Type (size, T_FIXNUM);
120 evas_object_text_font_set (e->real, StringValuePtr (font),
128 * text.text => string
130 * Returns the text of <i>text</i>.
132 static VALUE c_text_get (VALUE self)
136 GET_OBJ (self, RbEvasObject, e);
138 if (!(tmp = evas_object_text_text_get (e->real)))
141 return rb_str_new2 (tmp);
148 * Sets the text of <i>text</i>.
150 static VALUE c_text_set (VALUE self, VALUE val)
152 GET_OBJ (self, RbEvasObject, e);
154 Check_Type (val, T_STRING);
156 evas_object_text_text_set (e->real, StringValuePtr (val));
161 void Init_Text (void)
163 VALUE c = rb_define_class_under (mEvas, "Text", cEvasObject);
165 rb_define_method (c, "initialize", c_init, 1);
166 rb_define_method (c, "font_source", c_font_source_get, 0);
167 rb_define_method (c, "font_source=", c_font_source_set, 1);
168 rb_define_method (c, "get_font", c_get_font, 0);
169 rb_define_method (c, "set_font", c_set_font, 2);
170 rb_define_method (c, "text", c_text_get, 0);
171 rb_define_method (c, "text=", c_text_set, 1);