Sha256: 2700224ee09025aeb5576046bfa62c6a8a1403b7ac41e963b62986ea8c260efb

Contents?: true

Size: 1.88 KB

Versions: 13

Compression:

Stored size: 1.88 KB

Contents

#include "reflex/ruby/event.h"


#include "reflex/ruby/view.h"
#include "defs.h"


RUCY_DEFINE_VALUE_FROM_TO(Reflex::FocusEvent)

#define THIS  to<Reflex::FocusEvent*>(self)

#define CHECK RUCY_CHECK_OBJ(Reflex::FocusEvent, self)


static
VALUE alloc(VALUE klass)
{
	return new_type<Reflex::FocusEvent>(klass);
}

static
VALUE initialize(VALUE self, VALUE action, VALUE current, VALUE last)
{
	CHECK;

	*THIS = Reflex::FocusEvent(
		(Reflex::FocusEvent::Action) to<uint>(action),
		to<Reflex::View*>(current),
		to<Reflex::View*>(last));

	return rb_call_super(0, NULL);
}

static
VALUE initialize_copy(VALUE self, VALUE obj)
{
	CHECK;
	*THIS = to<Reflex::FocusEvent&>(obj).dup();
	return self;
}

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

static
VALUE get_current(VALUE self)
{
	CHECK;
	return THIS->current() ? value(THIS->current()) : nil();
}

static
VALUE get_last(VALUE self)
{
	CHECK;
	return THIS->last() ? value(THIS->last()) : nil();
}


static Class cFocusEvent;

void
Init_reflex_focus_event ()
{
	Module mReflex = rb_define_module("Reflex");

	cFocusEvent = mReflex.define_class("FocusEvent", Reflex::event_class());
	rb_define_alloc_func(cFocusEvent, alloc);
	rb_define_private_method(cFocusEvent, "initialize", RUBY_METHOD_FUNC(initialize), 3);
	rb_define_private_method(cFocusEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
	rb_define_method(cFocusEvent, "action", RUBY_METHOD_FUNC(get_action), 0);
	rb_define_method(cFocusEvent, "current", RUBY_METHOD_FUNC(get_current), 0);
	rb_define_method(cFocusEvent, "last", RUBY_METHOD_FUNC(get_last), 0);

	cFocusEvent.define_const("ACTION_NONE", Reflex::FocusEvent::ACTION_NONE);
	cFocusEvent.define_const("FOCUS",       Reflex::FocusEvent::FOCUS);
	cFocusEvent.define_const("BLUR",        Reflex::FocusEvent::BLUR);
}


namespace Reflex
{


	Class
	focus_event_class ()
	{
		return cFocusEvent;
	}


}// Reflex

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
reflexion-0.2.1 .doc/ext/reflex/focus_event.cpp
reflexion-0.2 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.57 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.56 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.55 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.54 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.53 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.52 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.51 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.50 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.49 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.48 .doc/ext/reflex/focus_event.cpp
reflexion-0.1.47 .doc/ext/reflex/focus_event.cpp