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

/*
Copyright (C) 2012 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-object.h>
#include <glib.h>
#include <float.h>
#include <math.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_GLYPH_CANVAS_0_PROPERTY,
	BIRD_FONT_GLYPH_CANVAS_NUM_PROPERTIES
};
static GParamSpec* bird_font_glyph_canvas_properties[BIRD_FONT_GLYPH_CANVAS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	BIRD_FONT_GLYPH_CANVAS_SIGNAL_REDRAW_AREA_SIGNAL,
	BIRD_FONT_GLYPH_CANVAS_NUM_SIGNALS
};
static guint bird_font_glyph_canvas_signals[BIRD_FONT_GLYPH_CANVAS_NUM_SIGNALS] = {0};

static gpointer bird_font_glyph_canvas_parent_class = NULL;
BirdFontFontDisplay* bird_font_glyph_canvas_current_display = NULL;
BirdFontWidgetAllocation* bird_font_glyph_canvas_allocation = NULL;

static void ___lambda9_ (BirdFontGlyphCanvas* self,
                  gdouble x,
                  gdouble y,
                  gdouble w,
                  gdouble h);
static void ____lambda9__bird_font_font_display_redraw_area (BirdFontFontDisplay* _sender,
                                                      gdouble x,
                                                      gdouble y,
                                                      gdouble w,
                                                      gdouble h,
                                                      gpointer self);
static void g_cclosure_user_marshal_VOID__INT_INT_INT_INT (GClosure * closure,
                                                    GValue * return_value,
                                                    guint n_param_values,
                                                    const GValue * param_values,
                                                    gpointer invocation_hint,
                                                    gpointer marshal_data);
static void bird_font_glyph_canvas_finalize (GObject * obj);
static GType bird_font_glyph_canvas_get_type_once (void);

BirdFontGlyphCanvas*
bird_font_glyph_canvas_construct (GType object_type)
{
	BirdFontGlyphCanvas * self = NULL;
	BirdFontWidgetAllocation* _tmp0_;
	self = (BirdFontGlyphCanvas*) g_object_new (object_type, NULL);
	_tmp0_ = bird_font_widget_allocation_new ();
	_g_object_unref0 (bird_font_glyph_canvas_allocation);
	bird_font_glyph_canvas_allocation = _tmp0_;
	return self;
}

BirdFontGlyphCanvas*
bird_font_glyph_canvas_new (void)
{
	return bird_font_glyph_canvas_construct (BIRD_FONT_TYPE_GLYPH_CANVAS);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

BirdFontWidgetAllocation*
bird_font_glyph_canvas_get_allocation (void)
{
	BirdFontWidgetAllocation* _tmp0_;
	BirdFontWidgetAllocation* _tmp1_;
	BirdFontWidgetAllocation* result;
	_tmp0_ = bird_font_glyph_canvas_allocation;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
bird_font_glyph_canvas_set_allocation (BirdFontWidgetAllocation* w)
{
	BirdFontWidgetAllocation* _tmp0_;
	g_return_if_fail (w != NULL);
	_tmp0_ = bird_font_widget_allocation_copy (w);
	_g_object_unref0 (bird_font_glyph_canvas_allocation);
	bird_font_glyph_canvas_allocation = _tmp0_;
}

void
bird_font_glyph_canvas_key_release (BirdFontGlyphCanvas* self,
                                    guint e)
{
	BirdFontFontDisplay* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = bird_font_glyph_canvas_current_display;
	bird_font_font_display_key_release (_tmp0_, e);
}

void
bird_font_glyph_canvas_key_press (BirdFontGlyphCanvas* self,
                                  guint e)
{
	BirdFontFontDisplay* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = bird_font_glyph_canvas_current_display;
	bird_font_font_display_key_press (_tmp0_, e);
}

void
bird_font_glyph_canvas_set_display (BirdFontFontDisplay* fd)
{
	BirdFontFontDisplay* _tmp0_;
	g_return_if_fail (fd != NULL);
	_tmp0_ = _g_object_ref0 (fd);
	_g_object_unref0 (bird_font_glyph_canvas_current_display);
	bird_font_glyph_canvas_current_display = _tmp0_;
}

static void
___lambda9_ (BirdFontGlyphCanvas* self,
             gdouble x,
             gdouble y,
             gdouble w,
             gdouble h)
{
	g_signal_emit (self, bird_font_glyph_canvas_signals[BIRD_FONT_GLYPH_CANVAS_SIGNAL_REDRAW_AREA_SIGNAL], 0, (gint) x, (gint) y, (gint) w, (gint) h);
}

static void
____lambda9__bird_font_font_display_redraw_area (BirdFontFontDisplay* _sender,
                                                 gdouble x,
                                                 gdouble y,
                                                 gdouble w,
                                                 gdouble h,
                                                 gpointer self)
{
	___lambda9_ ((BirdFontGlyphCanvas*) self, x, y, w, h);
}

void
bird_font_glyph_canvas_set_current_glyph_collection (BirdFontGlyphCanvas* self,
                                                     BirdFontGlyphCollection* gc,
                                                     gboolean signal_selected)
{
	BirdFontGlyph* g = NULL;
	BirdFontGlyph* _tmp0_;
	BirdFontGlyphCollection* _tmp1_;
	BirdFontGlyph* _tmp2_;
	BirdFontWidgetAllocation* _tmp3_;
	BirdFontFontDisplay* _tmp4_;
	BirdFontNativeWindow* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gc != NULL);
	_tmp0_ = bird_font_glyph_collection_get_current (gc);
	g = _tmp0_;
	_tmp1_ = _g_object_ref0 (gc);
	_g_object_unref0 (bird_font_bird_font_current_glyph_collection);
	bird_font_bird_font_current_glyph_collection = _tmp1_;
	_tmp2_ = g;
	_tmp3_ = bird_font_glyph_canvas_allocation;
	bird_font_glyph_resized (_tmp2_, _tmp3_);
	_tmp4_ = bird_font_glyph_canvas_current_display;
	if (!bird_font_is_null (_tmp4_)) {
		BirdFontFontDisplay* _tmp6_;
		if (signal_selected) {
			BirdFontFontDisplay* _tmp5_;
			_tmp5_ = bird_font_glyph_canvas_current_display;
			bird_font_font_display_selected_canvas (_tmp5_);
			bird_font_font_display_dirty_scrollbar = TRUE;
		}
		_tmp6_ = bird_font_glyph_canvas_current_display;
		g_signal_connect_object (_tmp6_, "redraw-area", (GCallback) ____lambda9__bird_font_font_display_redraw_area, self, 0);
		bird_font_glyph_canvas_redraw ();
	}
	_tmp7_ = bird_font_main_window_native_window;
	if (!bird_font_is_null (_tmp7_)) {
		BirdFontNativeWindow* _tmp8_;
		_tmp8_ = bird_font_main_window_native_window;
		bird_font_native_window_update_window_size (_tmp8_);
	}
	_g_object_unref0 (g);
}

BirdFontGlyph*
bird_font_glyph_canvas_get_current_glyph (void)
{
	BirdFontGlyph* _tmp0_;
	BirdFontGlyph* result;
	_tmp0_ = bird_font_main_window_get_current_glyph ();
	result = _tmp0_;
	return result;
}

BirdFontFontDisplay*
bird_font_glyph_canvas_get_current_display (BirdFontGlyphCanvas* self)
{
	BirdFontFontDisplay* _tmp0_;
	BirdFontFontDisplay* _tmp1_;
	BirdFontFontDisplay* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = bird_font_glyph_canvas_current_display;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
bird_font_glyph_canvas_redraw_area (BirdFontGlyphCanvas* self,
                                    gint x,
                                    gint y,
                                    gint w,
                                    gint h)
{
	g_return_if_fail (self != NULL);
	if (bird_font_menu_tab_has_suppress_event ()) {
		g_warning ("GlyphCanvas.vala:85: Do not call redraw from background thread.");
	} else {
		BirdFontScrollbar* _tmp0_;
		_tmp0_ = bird_font_main_window_scrollbar;
		g_signal_emit (self, bird_font_glyph_canvas_signals[BIRD_FONT_GLYPH_CANVAS_SIGNAL_REDRAW_AREA_SIGNAL], 0, x, y, w + ((gint) _tmp0_->width), h);
	}
}

void
bird_font_glyph_canvas_redraw (void)
{
	BirdFontGlyphCanvas* c = NULL;
	BirdFontGlyphCanvas* _tmp0_;
	gboolean _tmp1_ = FALSE;
	BirdFontGlyphCanvas* _tmp2_;
	_tmp0_ = bird_font_main_window_get_glyph_canvas ();
	c = _tmp0_;
	_tmp2_ = c;
	if (!bird_font_is_null (_tmp2_)) {
		BirdFontScrollbar* _tmp3_;
		_tmp3_ = bird_font_main_window_scrollbar;
		_tmp1_ = !bird_font_is_null (_tmp3_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gint w = 0;
		BirdFontWidgetAllocation* _tmp4_;
		BirdFontScrollbar* _tmp5_;
		BirdFontGlyphCanvas* _tmp6_;
		BirdFontWidgetAllocation* _tmp7_;
		_tmp4_ = bird_font_glyph_canvas_allocation;
		_tmp5_ = bird_font_main_window_scrollbar;
		w = (gint) (_tmp4_->width + _tmp5_->width);
		_tmp6_ = c;
		_tmp7_ = bird_font_glyph_canvas_allocation;
		bird_font_glyph_canvas_redraw_area (_tmp6_, 0, 0, w, _tmp7_->height);
	}
	_g_object_unref0 (c);
}

static void
g_cclosure_user_marshal_VOID__INT_INT_INT_INT (GClosure * closure,
                                               GValue * return_value,
                                               guint n_param_values,
                                               const GValue * param_values,
                                               gpointer invocation_hint,
                                               gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__INT_INT_INT_INT) (gpointer data1, gint arg_1, gint arg_2, gint arg_3, gint arg_4, gpointer data2);
	register GMarshalFunc_VOID__INT_INT_INT_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 5);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_INT_INT_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_int (param_values + 2), g_value_get_int (param_values + 3), g_value_get_int (param_values + 4), data2);
}

static void
bird_font_glyph_canvas_class_init (BirdFontGlyphCanvasClass * klass,
                                   gpointer klass_data)
{
	bird_font_glyph_canvas_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_glyph_canvas_finalize;
	bird_font_glyph_canvas_signals[BIRD_FONT_GLYPH_CANVAS_SIGNAL_REDRAW_AREA_SIGNAL] = g_signal_new ("signal-redraw-area", BIRD_FONT_TYPE_GLYPH_CANVAS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT_INT_INT, G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
}

static void
bird_font_glyph_canvas_instance_init (BirdFontGlyphCanvas * self,
                                      gpointer klass)
{
}

static void
bird_font_glyph_canvas_finalize (GObject * obj)
{
	BirdFontGlyphCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_GLYPH_CANVAS, BirdFontGlyphCanvas);
	G_OBJECT_CLASS (bird_font_glyph_canvas_parent_class)->finalize (obj);
}

static GType
bird_font_glyph_canvas_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontGlyphCanvasClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_glyph_canvas_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontGlyphCanvas), 0, (GInstanceInitFunc) bird_font_glyph_canvas_instance_init, NULL };
	GType bird_font_glyph_canvas_type_id;
	bird_font_glyph_canvas_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontGlyphCanvas", &g_define_type_info, 0);
	return bird_font_glyph_canvas_type_id;
}

GType
bird_font_glyph_canvas_get_type (void)
{
	static volatile gsize bird_font_glyph_canvas_type_id__once = 0;
	if (g_once_init_enter (&bird_font_glyph_canvas_type_id__once)) {
		GType bird_font_glyph_canvas_type_id;
		bird_font_glyph_canvas_type_id = bird_font_glyph_canvas_get_type_once ();
		g_once_init_leave (&bird_font_glyph_canvas_type_id__once, bird_font_glyph_canvas_type_id);
	}
	return bird_font_glyph_canvas_type_id__once;
}

