X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Frb_text.c;h=431e8edfbb848107e8067b4595cf2b1804c810a5;hb=7ddd864c94652d62b94a7501fb825fd4cba4d5c0;hp=4224e9883180b4ea2a59a0d03322692a2b94f342;hpb=48ce7740aa5b73b1f58fbde3180f5f56d9022fcf;p=ruby-evas.git
diff --git a/src/rb_text.c b/src/rb_text.c
index 4224e98..431e8ed 100644
--- a/src/rb_text.c
+++ b/src/rb_text.c
@@ -1,5 +1,5 @@
/*
- * $Id: rb_text.c 38 2004-07-25 11:27:25Z tilman $
+ * $Id: rb_text.c 143 2004-11-26 21:39:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
@@ -26,17 +26,28 @@
#include "rb_evas.h"
#include "rb_evas_object.h"
+static void c_free (RbEvasObject *e)
+{
+ c_evas_object_free (e, true);
+}
+
+/*
+ * call-seq:
+ * Evas::Text.new(evas) => text
+ *
+ * Creates an Evas::Text object.
+ */
static VALUE c_new (VALUE klass, VALUE evas)
{
VALUE self, argv[1];
- Evas_Object **rect;
+ RbEvasObject *text;
CHECK_CLASS (evas, cEvas);
- GET_OBJ (evas, Evas *, e);
+ GET_OBJ (evas, RbEvas, e);
- self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
- c_evas_object_free, rect);
- *rect = evas_object_text_add (*e);
+ self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
+ c_free, text);
+ text->real = evas_object_text_add (e->real);
argv[0] = evas;
rb_obj_call_init (self, 1, argv);
@@ -44,74 +55,115 @@ static VALUE c_new (VALUE klass, VALUE evas)
return self;
}
+/*
+ * call-seq:
+ * text.font_source => string or nil
+ *
+ * Returns the font source of text.
+ */
static VALUE c_font_source_get (VALUE self)
{
const char *tmp;
- GET_OBJ (self, Evas_Object *, e);
+ GET_OBJ (self, RbEvasObject, e);
- if (!(tmp = evas_object_text_font_source_get (*e)))
+ if (!(tmp = evas_object_text_font_source_get (e->real)))
return Qnil;
else
return rb_str_new2 (tmp);
}
+/*
+ * call-seq:
+ * text.font_source(source)
+ *
+ * Sets the font source of text.
+ */
static VALUE c_font_source_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object *, e);
+ GET_OBJ (self, RbEvasObject, e);
Check_Type (val, T_STRING);
- evas_object_text_font_source_set (*e, StringValuePtr (val));
+ evas_object_text_font_source_set (e->real, StringValuePtr (val));
return Qnil;
}
+/*
+ * call-seq:
+ * text.get_font => array
+ *
+ * Returns the font name and font size of text.
+ *
+ * text.set_font("vera", 10) #=> nil
+ * text_get_font #=> ["vera", 10]
+ */
static VALUE c_get_font (VALUE self)
{
char *font = NULL;
Evas_Font_Size size = 0;
- GET_OBJ (self, Evas_Object *, e);
+ GET_OBJ (self, RbEvasObject, e);
- evas_object_text_font_get (*e, &font, &size);
+ evas_object_text_font_get (e->real, &font, &size);
return rb_ary_new3 (2, font ? rb_str_new2 (font) : Qnil,
INT2FIX (size));
}
+/*
+ * call-seq:
+ * text.set_font(font, size) => nil
+ *
+ * Sets the font name and font size of text.
+ *
+ * text.set_font("vera", 10) #=> nil
+ */
static VALUE c_set_font (VALUE self, VALUE font, VALUE size)
{
- GET_OBJ (self, Evas_Object *, e);
+ GET_OBJ (self, RbEvasObject, e);
Check_Type (font, T_STRING);
- Check_Type (font, T_FIXNUM);
+ Check_Type (size, T_FIXNUM);
- evas_object_text_font_set (*e, StringValuePtr (font),
+ evas_object_text_font_set (e->real, StringValuePtr (font),
FIX2INT (size));
return Qnil;
}
+/*
+ * call-seq:
+ * text.text => string
+ *
+ * Returns the text of text.
+ */
static VALUE c_text_get (VALUE self)
{
const char *tmp;
- GET_OBJ (self, Evas_Object *, e);
+ GET_OBJ (self, RbEvasObject, e);
- if (!(tmp = evas_object_text_text_get (*e)))
+ if (!(tmp = evas_object_text_text_get (e->real)))
return Qnil;
else
return rb_str_new2 (tmp);
}
+/*
+ * call-seq:
+ * text.text(string)
+ *
+ * Sets the text of text.
+ */
static VALUE c_text_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object *, e);
+ GET_OBJ (self, RbEvasObject, e);
Check_Type (val, T_STRING);
- evas_object_text_text_set (*e, StringValuePtr (val));
+ evas_object_text_text_set (e->real, StringValuePtr (val));
return Qnil;
}