/* Widget.c generated by valac 0.56.17, the Vala compiler
 * generated from Widget.vala, do not modify */

/*
Copyright (C) 2014 Johan Mattsson

This library is free software; you can redistribute it and/or modify 
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either version 3 of the 
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <glib.h>
#include <float.h>
#include <math.h>
#include <cairo-gobject.h>
#include <glib-object.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	BIRD_FONT_WIDGET_0_PROPERTY,
	BIRD_FONT_WIDGET_NUM_PROPERTIES
};
static GParamSpec* bird_font_widget_properties[BIRD_FONT_WIDGET_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer bird_font_widget_parent_class = NULL;

static gdouble bird_font_widget_real_get_height (BirdFontWidget* self);
static gdouble bird_font_widget_real_get_width (BirdFontWidget* self);
static void bird_font_widget_real_draw (BirdFontWidget* self,
                                 cairo_t* cr);
static void bird_font_widget_real_layout (BirdFontWidget* self);
static void bird_font_widget_real_key_press (BirdFontWidget* self,
                                      guint keyval);
static void bird_font_widget_real_focus (BirdFontWidget* self,
                                  gboolean enter);
static void bird_font_widget_real_button_press (BirdFontWidget* self,
                                         guint button,
                                         gdouble x,
                                         gdouble y);
static void bird_font_widget_real_button_release (BirdFontWidget* self,
                                           guint button,
                                           gdouble x,
                                           gdouble y);
static void bird_font_widget_real_double_click (BirdFontWidget* self,
                                         guint button,
                                         gdouble x,
                                         gdouble y);
static gboolean bird_font_widget_real_motion (BirdFontWidget* self,
                                       gdouble x,
                                       gdouble y);
static void bird_font_widget_finalize (GObject * obj);
static GType bird_font_widget_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gdouble
bird_font_widget_real_get_height (BirdFontWidget* self)
{
	gdouble _tmp0_ = 0.0;
	g_critical ("Type `%s' does not implement abstract method `bird_font_widget_get_height'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gdouble
bird_font_widget_get_height (BirdFontWidget* self)
{
	BirdFontWidgetClass* _klass_;
	g_return_val_if_fail (self != NULL, 0.0);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->get_height) {
		return _klass_->get_height (self);
	}
	return -1.0;
}

static gdouble
bird_font_widget_real_get_width (BirdFontWidget* self)
{
	gdouble _tmp0_ = 0.0;
	g_critical ("Type `%s' does not implement abstract method `bird_font_widget_get_width'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gdouble
bird_font_widget_get_width (BirdFontWidget* self)
{
	BirdFontWidgetClass* _klass_;
	g_return_val_if_fail (self != NULL, 0.0);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->get_width) {
		return _klass_->get_width (self);
	}
	return -1.0;
}

static void
bird_font_widget_real_draw (BirdFontWidget* self,
                            cairo_t* cr)
{
	g_critical ("Type `%s' does not implement abstract method `bird_font_widget_draw'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
bird_font_widget_draw (BirdFontWidget* self,
                       cairo_t* cr)
{
	BirdFontWidgetClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->draw) {
		_klass_->draw (self, cr);
	}
}

void
bird_font_widget_draw_rounded_rectangle (cairo_t* cr,
                                         gdouble x,
                                         gdouble y,
                                         gdouble w,
                                         gdouble h,
                                         gdouble radius)
{
	g_return_if_fail (cr != NULL);
	cairo_move_to (cr, x, y + radius);
	cairo_arc (cr, x + radius, y + radius, radius, 2 * (G_PI / 2), 3 * (G_PI / 2));
	cairo_line_to (cr, (x + w) - radius, y);
	cairo_arc (cr, (x + w) - radius, y + radius, radius, 3 * (G_PI / 2), 4 * (G_PI / 2));
	cairo_line_to (cr, x + w, y + h);
	cairo_arc (cr, (x + w) - radius, y + h, radius, 4 * (G_PI / 2), 5 * (G_PI / 2));
	cairo_line_to (cr, x + radius, (y + h) + radius);
	cairo_arc (cr, x + radius, y + h, radius, 5 * (G_PI / 2), 6 * (G_PI / 2));
	cairo_line_to (cr, x, y + radius);
	cairo_close_path (cr);
}

static void
bird_font_widget_real_layout (BirdFontWidget* self)
{
}

void
bird_font_widget_layout (BirdFontWidget* self)
{
	BirdFontWidgetClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->layout) {
		_klass_->layout (self);
	}
}

gboolean
bird_font_widget_is_over (BirdFontWidget* self,
                          gdouble x,
                          gdouble y)
{
	gboolean _tmp0_ = FALSE;
	gdouble _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = x;
	if ((self->widget_x <= _tmp1_) && (_tmp1_ <= (self->widget_x + bird_font_widget_get_width (self)))) {
		gdouble _tmp2_;
		_tmp2_ = y;
		_tmp0_ = (self->widget_y <= _tmp2_) && (_tmp2_ <= (self->widget_y + bird_font_widget_get_height (self)));
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

gboolean
bird_font_widget_is_on_screen (BirdFontWidget* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gdouble _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp2_ = (gdouble) 0;
	if ((self->widget_y <= _tmp2_) && (_tmp2_ <= (self->widget_y + bird_font_widget_get_height (self)))) {
		_tmp1_ = TRUE;
	} else {
		BirdFontWidgetAllocation* _tmp3_;
		gdouble _tmp4_;
		_tmp3_ = self->allocation;
		_tmp4_ = (gdouble) _tmp3_->height;
		_tmp1_ = (self->widget_y <= _tmp4_) && (_tmp4_ <= (self->widget_y + bird_font_widget_get_height (self)));
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		BirdFontWidgetAllocation* _tmp5_;
		gdouble _tmp6_;
		_tmp5_ = self->allocation;
		_tmp6_ = self->widget_y;
		_tmp0_ = (((gdouble) 0) <= _tmp6_) && (_tmp6_ <= ((gdouble) _tmp5_->height));
	}
	result = _tmp0_;
	return result;
}

static void
bird_font_widget_real_key_press (BirdFontWidget* self,
                                 guint keyval)
{
}

void
bird_font_widget_key_press (BirdFontWidget* self,
                            guint keyval)
{
	BirdFontWidgetClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->key_press) {
		_klass_->key_press (self, keyval);
	}
}

static void
bird_font_widget_real_focus (BirdFontWidget* self,
                             gboolean enter)
{
}

void
bird_font_widget_focus (BirdFontWidget* self,
                        gboolean enter)
{
	BirdFontWidgetClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->focus) {
		_klass_->focus (self, enter);
	}
}

static void
bird_font_widget_real_button_press (BirdFontWidget* self,
                                    guint button,
                                    gdouble x,
                                    gdouble y)
{
}

void
bird_font_widget_button_press (BirdFontWidget* self,
                               guint button,
                               gdouble x,
                               gdouble y)
{
	BirdFontWidgetClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->button_press) {
		_klass_->button_press (self, button, x, y);
	}
}

static void
bird_font_widget_real_button_release (BirdFontWidget* self,
                                      guint button,
                                      gdouble x,
                                      gdouble y)
{
}

void
bird_font_widget_button_release (BirdFontWidget* self,
                                 guint button,
                                 gdouble x,
                                 gdouble y)
{
	BirdFontWidgetClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->button_release) {
		_klass_->button_release (self, button, x, y);
	}
}

static void
bird_font_widget_real_double_click (BirdFontWidget* self,
                                    guint button,
                                    gdouble x,
                                    gdouble y)
{
}

void
bird_font_widget_double_click (BirdFontWidget* self,
                               guint button,
                               gdouble x,
                               gdouble y)
{
	BirdFontWidgetClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->double_click) {
		_klass_->double_click (self, button, x, y);
	}
}

static gboolean
bird_font_widget_real_motion (BirdFontWidget* self,
                              gdouble x,
                              gdouble y)
{
	gboolean result;
	result = FALSE;
	return result;
}

gboolean
bird_font_widget_motion (BirdFontWidget* self,
                         gdouble x,
                         gdouble y)
{
	BirdFontWidgetClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = BIRD_FONT_WIDGET_GET_CLASS (self);
	if (_klass_->motion) {
		return _klass_->motion (self, x, y);
	}
	return FALSE;
}

BirdFontWidget*
bird_font_widget_construct (GType object_type)
{
	BirdFontWidget * self = NULL;
	self = (BirdFontWidget*) g_object_new (object_type, NULL);
	return self;
}

static void
bird_font_widget_class_init (BirdFontWidgetClass * klass,
                             gpointer klass_data)
{
	bird_font_widget_parent_class = g_type_class_peek_parent (klass);
	((BirdFontWidgetClass *) klass)->get_height = (gdouble (*) (BirdFontWidget*)) bird_font_widget_real_get_height;
	((BirdFontWidgetClass *) klass)->get_width = (gdouble (*) (BirdFontWidget*)) bird_font_widget_real_get_width;
	((BirdFontWidgetClass *) klass)->draw = (void (*) (BirdFontWidget*, cairo_t*)) bird_font_widget_real_draw;
	((BirdFontWidgetClass *) klass)->layout = (void (*) (BirdFontWidget*)) bird_font_widget_real_layout;
	((BirdFontWidgetClass *) klass)->key_press = (void (*) (BirdFontWidget*, guint)) bird_font_widget_real_key_press;
	((BirdFontWidgetClass *) klass)->focus = (void (*) (BirdFontWidget*, gboolean)) bird_font_widget_real_focus;
	((BirdFontWidgetClass *) klass)->button_press = (void (*) (BirdFontWidget*, guint, gdouble, gdouble)) bird_font_widget_real_button_press;
	((BirdFontWidgetClass *) klass)->button_release = (void (*) (BirdFontWidget*, guint, gdouble, gdouble)) bird_font_widget_real_button_release;
	((BirdFontWidgetClass *) klass)->double_click = (void (*) (BirdFontWidget*, guint, gdouble, gdouble)) bird_font_widget_real_double_click;
	((BirdFontWidgetClass *) klass)->motion = (gboolean (*) (BirdFontWidget*, gdouble, gdouble)) bird_font_widget_real_motion;
	G_OBJECT_CLASS (klass)->finalize = bird_font_widget_finalize;
}

static void
bird_font_widget_instance_init (BirdFontWidget * self,
                                gpointer klass)
{
	BirdFontWidgetAllocation* _tmp0_;
	self->margin_bottom = (gdouble) 0;
	self->widget_x = (gdouble) 0;
	self->widget_y = (gdouble) 0;
	_tmp0_ = bird_font_widget_allocation_new ();
	self->allocation = _tmp0_;
}

static void
bird_font_widget_finalize (GObject * obj)
{
	BirdFontWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_WIDGET, BirdFontWidget);
	_g_object_unref0 (self->allocation);
	G_OBJECT_CLASS (bird_font_widget_parent_class)->finalize (obj);
}

static GType
bird_font_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontWidget), 0, (GInstanceInitFunc) bird_font_widget_instance_init, NULL };
	GType bird_font_widget_type_id;
	bird_font_widget_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontWidget", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return bird_font_widget_type_id;
}

GType
bird_font_widget_get_type (void)
{
	static volatile gsize bird_font_widget_type_id__once = 0;
	if (g_once_init_enter (&bird_font_widget_type_id__once)) {
		GType bird_font_widget_type_id;
		bird_font_widget_type_id = bird_font_widget_get_type_once ();
		g_once_init_leave (&bird_font_widget_type_id__once, bird_font_widget_type_id);
	}
	return bird_font_widget_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

