/* Headline.c generated by valac 0.56.17, the Vala compiler
 * generated from Headline.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-object.h>
#include <cairo-gobject.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <stdlib.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

#define BIRD_FONT_TYPE_HEADLINE (bird_font_headline_get_type ())
#define BIRD_FONT_HEADLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_HEADLINE, BirdFontHeadline))
#define BIRD_FONT_HEADLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_HEADLINE, BirdFontHeadlineClass))
#define BIRD_FONT_IS_HEADLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_HEADLINE))
#define BIRD_FONT_IS_HEADLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_HEADLINE))
#define BIRD_FONT_HEADLINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_HEADLINE, BirdFontHeadlineClass))

typedef struct _BirdFontHeadline BirdFontHeadline;
typedef struct _BirdFontHeadlineClass BirdFontHeadlineClass;
typedef struct _BirdFontHeadlinePrivate BirdFontHeadlinePrivate;
enum  {
	BIRD_FONT_HEADLINE_0_PROPERTY,
	BIRD_FONT_HEADLINE_NUM_PROPERTIES
};
static GParamSpec* bird_font_headline_properties[BIRD_FONT_HEADLINE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BirdFontHeadline {
	BirdFontWidget parent_instance;
	BirdFontHeadlinePrivate * priv;
};

struct _BirdFontHeadlineClass {
	BirdFontWidgetClass parent_class;
};

struct _BirdFontHeadlinePrivate {
	BirdFontText* label;
};

static gint BirdFontHeadline_private_offset;
static gpointer bird_font_headline_parent_class = NULL;

VALA_EXTERN GType bird_font_headline_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BirdFontHeadline* bird_font_headline_new (const gchar* text);
VALA_EXTERN BirdFontHeadline* bird_font_headline_construct (GType object_type,
                                                const gchar* text);
static void bird_font_headline_real_draw (BirdFontWidget* base,
                                   cairo_t* cr);
static gdouble bird_font_headline_real_get_height (BirdFontWidget* base);
static gdouble bird_font_headline_real_get_width (BirdFontWidget* base);
static void bird_font_headline_finalize (GObject * obj);
static GType bird_font_headline_get_type_once (void);

static inline gpointer
bird_font_headline_get_instance_private (BirdFontHeadline* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontHeadline_private_offset);
}

BirdFontHeadline*
bird_font_headline_construct (GType object_type,
                              const gchar* text)
{
	BirdFontHeadline * self = NULL;
	BirdFontText* _tmp0_;
	BirdFontText* _tmp1_;
	g_return_val_if_fail (text != NULL, NULL);
	self = (BirdFontHeadline*) bird_font_widget_construct (object_type);
	_tmp0_ = bird_font_text_new ("", (gdouble) 17, (gdouble) 0);
	_g_object_unref0 (self->priv->label);
	self->priv->label = _tmp0_;
	_tmp1_ = self->priv->label;
	bird_font_text_set_text (_tmp1_, text);
	return self;
}

BirdFontHeadline*
bird_font_headline_new (const gchar* text)
{
	return bird_font_headline_construct (BIRD_FONT_TYPE_HEADLINE, text);
}

static void
bird_font_headline_real_draw (BirdFontWidget* base,
                              cairo_t* cr)
{
	BirdFontHeadline * self;
	BirdFontWidgetAllocation* _tmp0_;
	BirdFontText* _tmp1_;
	BirdFontText* _tmp2_;
	BirdFontText* _tmp3_;
	self = (BirdFontHeadline*) base;
	g_return_if_fail (cr != NULL);
	cairo_save (cr);
	bird_font_theme_color (cr, "Headline Background");
	_tmp0_ = ((BirdFontWidget*) self)->allocation;
	cairo_rectangle (cr, (gdouble) 0, ((BirdFontWidget*) self)->widget_y, (gdouble) _tmp0_->width, (gdouble) 40);
	cairo_fill (cr);
	cairo_restore (cr);
	cairo_save (cr);
	_tmp1_ = self->priv->label;
	bird_font_text_set_source_rgba (_tmp1_, (gdouble) 1, (gdouble) 1, (gdouble) 1, (gdouble) 1);
	_tmp2_ = self->priv->label;
	bird_font_text_set_font_size (_tmp2_, (gdouble) 20);
	_tmp3_ = self->priv->label;
	bird_font_text_draw_at_baseline (_tmp3_, cr, (gdouble) 21, ((BirdFontWidget*) self)->widget_y + 25, "");
	cairo_restore (cr);
}

static gdouble
bird_font_headline_real_get_height (BirdFontWidget* base)
{
	BirdFontHeadline * self;
	gdouble result;
	self = (BirdFontHeadline*) base;
	result = (gdouble) 40;
	return result;
}

static gdouble
bird_font_headline_real_get_width (BirdFontWidget* base)
{
	BirdFontHeadline * self;
	BirdFontWidgetAllocation* _tmp0_;
	gdouble result;
	self = (BirdFontHeadline*) base;
	_tmp0_ = ((BirdFontWidget*) self)->allocation;
	result = (gdouble) _tmp0_->width;
	return result;
}

static void
bird_font_headline_class_init (BirdFontHeadlineClass * klass,
                               gpointer klass_data)
{
	bird_font_headline_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontHeadline_private_offset);
	((BirdFontWidgetClass *) klass)->draw = (void (*) (BirdFontWidget*, cairo_t*)) bird_font_headline_real_draw;
	((BirdFontWidgetClass *) klass)->get_height = (gdouble (*) (BirdFontWidget*)) bird_font_headline_real_get_height;
	((BirdFontWidgetClass *) klass)->get_width = (gdouble (*) (BirdFontWidget*)) bird_font_headline_real_get_width;
	G_OBJECT_CLASS (klass)->finalize = bird_font_headline_finalize;
}

static void
bird_font_headline_instance_init (BirdFontHeadline * self,
                                  gpointer klass)
{
	self->priv = bird_font_headline_get_instance_private (self);
}

static void
bird_font_headline_finalize (GObject * obj)
{
	BirdFontHeadline * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_HEADLINE, BirdFontHeadline);
	_g_object_unref0 (self->priv->label);
	G_OBJECT_CLASS (bird_font_headline_parent_class)->finalize (obj);
}

static GType
bird_font_headline_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontHeadlineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_headline_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontHeadline), 0, (GInstanceInitFunc) bird_font_headline_instance_init, NULL };
	GType bird_font_headline_type_id;
	bird_font_headline_type_id = g_type_register_static (BIRD_FONT_TYPE_WIDGET, "BirdFontHeadline", &g_define_type_info, 0);
	BirdFontHeadline_private_offset = g_type_add_instance_private (bird_font_headline_type_id, sizeof (BirdFontHeadlinePrivate));
	return bird_font_headline_type_id;
}

GType
bird_font_headline_get_type (void)
{
	static volatile gsize bird_font_headline_type_id__once = 0;
	if (g_once_init_enter (&bird_font_headline_type_id__once)) {
		GType bird_font_headline_type_id;
		bird_font_headline_type_id = bird_font_headline_get_type_once ();
		g_once_init_leave (&bird_font_headline_type_id__once, bird_font_headline_type_id);
	}
	return bird_font_headline_type_id__once;
}

