projects
/
ruby-evas.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed a segfault in Text#set_font.
[ruby-evas.git]
/
src
/
rb_text.c
diff --git
a/src/rb_text.c
b/src/rb_text.c
index 4224e9883180b4ea2a59a0d03322692a2b94f342..431e8edfbb848107e8067b4595cf2b1804c810a5 100644
(file)
--- a/
src/rb_text.c
+++ b/
src/rb_text.c
@@
-1,5
+1,5
@@
/*
/*
- * $Id: rb_text.c
38 2004-07-25 11:27:25
Z tilman $
+ * $Id: rb_text.c
143 2004-11-26 21:39:08
Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
@@
-26,17
+26,28
@@
#include "rb_evas.h"
#include "rb_evas_object.h"
#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];
static VALUE c_new (VALUE klass, VALUE evas)
{
VALUE self, argv[1];
-
Evas_Object **rec
t;
+
RbEvasObject *tex
t;
CHECK_CLASS (evas, cEvas);
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, rec
t);
-
*rect = evas_object_text_add (*e
);
+ self = Data_Make_Struct (klass,
RbEvasObject
, c_evas_object_mark,
+ c_
free, tex
t);
+
text->real = evas_object_text_add (e->real
);
argv[0] = evas;
rb_obj_call_init (self, 1, argv);
argv[0] = evas;
rb_obj_call_init (self, 1, argv);
@@
-44,74
+55,115
@@
static VALUE c_new (VALUE klass, VALUE evas)
return self;
}
return self;
}
+/*
+ * call-seq:
+ * text.font_source => string or nil
+ *
+ * Returns the font source of <i>text</i>.
+ */
static VALUE c_font_source_get (VALUE self)
{
const char *tmp;
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);
}
return Qnil;
else
return rb_str_new2 (tmp);
}
+/*
+ * call-seq:
+ * text.font_source(source)
+ *
+ * Sets the font source of <i>text</i>.
+ */
static VALUE c_font_source_set (VALUE self, VALUE val)
{
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);
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;
}
return Qnil;
}
+/*
+ * call-seq:
+ * text.get_font => array
+ *
+ * Returns the font name and font size of <i>text</i>.
+ *
+ * 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;
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));
}
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 <i>text</i>.
+ *
+ * text.set_font("vera", 10) #=> nil
+ */
static VALUE c_set_font (VALUE self, VALUE font, VALUE size)
{
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_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;
}
FIX2INT (size));
return Qnil;
}
+/*
+ * call-seq:
+ * text.text => string
+ *
+ * Returns the text of <i>text</i>.
+ */
static VALUE c_text_get (VALUE self)
{
const char *tmp;
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);
}
return Qnil;
else
return rb_str_new2 (tmp);
}
+/*
+ * call-seq:
+ * text.text(string)
+ *
+ * Sets the text of <i>text</i>.
+ */
static VALUE c_text_set (VALUE self, VALUE val)
{
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);
Check_Type (val, T_STRING);
- evas_object_text_text_set (
*e
, StringValuePtr (val));
+ evas_object_text_text_set (
e->real
, StringValuePtr (val));
return Qnil;
}
return Qnil;
}