Sha256: f67711e016a971dc475e21438bec226267d54a8e091b36f07b7f7cc13c594188

Contents?: true

Size: 1.75 KB

Versions: 5

Compression:

Stored size: 1.75 KB

Contents

#include "rays/ruby/font.h"


#include <rucy.h>
#include "defs.h"


using namespace Rucy;

using Rays::coord;


RUCY_DEFINE_VALUE_FROM_TO(Rays::Font)

#define THIS  to<Rays::Font*>(self)

#define CHECK RUCY_CHECK_OBJECT(Rays::Font, self)


static
VALUE alloc(VALUE klass)
{
	return new_type<Rays::Font>(klass);
}

static
VALUE initialize(VALUE self)
{
	RUCY_CHECK_OBJ(Rays::Font, self);
	check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);

	const char* name = (argc >= 1) ? argv[0].c_str()    : NULL;
	float size       = (argc >= 2) ? to<float>(argv[1]) : 0;
	*THIS = Rays::Font(name, size);

	return self;
}

static
VALUE initialize_copy(VALUE self, VALUE obj)
{
	RUCY_CHECK_OBJ(Rays::Font, self);

	*THIS = to<Rays::Font&>(obj).copy();
	return self;
}

static
VALUE name(VALUE self)
{
	CHECK;
	return value(THIS->name().c_str());
}

static
VALUE size(VALUE self)
{
	CHECK;
	return value(THIS->size());
}

static
VALUE width(VALUE self, VALUE str)
{
	CHECK;
	return value(THIS->get_width(str.c_str()));
}

static
VALUE height(VALUE self)
{
	CHECK;
	return value(THIS->get_height());
}


static Class cFont;

void
Init_font ()
{
	Module mRays = rb_define_module("Rays");

	cFont = rb_define_class_under(mRays, "Font", rb_cObject);
	rb_define_alloc_func(cFont, alloc);
	rb_define_private_method(cFont, "initialize", RUBY_METHOD_FUNC(initialize), -1);
	rb_define_private_method(cFont, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
	rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name), 0);
	rb_define_method(cFont, "size", RUBY_METHOD_FUNC(size), 0);
	rb_define_method(cFont, "width", RUBY_METHOD_FUNC(width), 1);
	rb_define_method(cFont, "height", RUBY_METHOD_FUNC(height), 0);
}


namespace Rays
{


	Class
	font_class ()
	{
		return cFont;
	}


}// Rays

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rays-0.1.12 .doc/ext/rays/font.cpp
rays-0.1.11 .doc/ext/rays/font.cpp
rays-0.1.10 .doc/ext/rays/font.cpp
rays-0.1.9 .doc/ext/rays/font.cpp
rays-0.1.8 .doc/ext/rays/font.cpp