示例#1
0
文件: wire.c 项目: neuroidss/oregano
static void wire_class_init (WireClass *klass)
{
    GObjectClass *object_class;
    ItemDataClass *item_data_class;

    parent_class = g_type_class_peek (TYPE_ITEM_DATA);
    item_data_class = ITEM_DATA_CLASS (klass);
    object_class = G_OBJECT_CLASS (klass);

    object_class->dispose = wire_dispose;
    object_class->finalize = wire_finalize;

    wire_signals[ARG_DELETE] =
        g_signal_new ("delete", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST,
                      G_STRUCT_OFFSET (WireClass, delete), NULL, NULL,
                      g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);

    item_data_class->clone = wire_clone;
    item_data_class->copy = wire_copy;
    item_data_class->rotate = wire_rotate;
    item_data_class->flip = wire_flip;
    item_data_class->unreg = wire_unregister;
    item_data_class->reg = wire_register;
    item_data_class->has_properties = wire_has_properties;
    item_data_class->print = wire_print;
    item_data_class->changed = wire_changed;
}
示例#2
0
void
clipboard_add_object (GObject *item)
{
    ItemDataClass *id_class;
    ItemData *item_data, *clone;
    ClipboardData *cb_data;

    g_return_if_fail (item != NULL);

    item_data = sheet_item_get_data (SHEET_ITEM (item));
    g_return_if_fail (item_data != NULL);

    id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (item_data));
    if (id_class->clone == NULL)
        return;

    // Duplicate the data for the object and add to the clipboard.
    clone = id_class->clone (item_data);

    cb_data = g_new0 (ClipboardData, 1);
    cb_data->item_data = clone;
    cb_data->item_class = SHEET_ITEM_CLASS (G_OBJECT_GET_CLASS (item));

    oregano.clipboard = g_slist_prepend (oregano.clipboard, cb_data);
}
示例#3
0
static void part_class_init (PartClass *klass)
{
	GObjectClass *object_class;
	ItemDataClass *item_data_class;

	parent_class = g_type_class_peek (TYPE_ITEM_DATA);

	object_class = G_OBJECT_CLASS (klass);
	item_data_class = ITEM_DATA_CLASS (klass);

	object_class->set_property = part_set_gproperty;
	object_class->get_property = part_get_gproperty;
	object_class->dispose = part_dispose;
	object_class->finalize = part_finalize;

	g_object_class_install_property (
	    object_class, ARG_PROPERTIES,
	    g_param_spec_pointer ("properties", "properties", "the properties", G_PARAM_READWRITE));
	g_object_class_install_property (
	    object_class, ARG_LABELS,
	    g_param_spec_pointer ("labels", "labels", "the labels", G_PARAM_READWRITE));

	item_data_class->clone = part_clone;
	item_data_class->copy = part_copy;
	item_data_class->rotate = part_rotate;
	item_data_class->flip = part_flip;
	item_data_class->unreg = part_unregister;
	item_data_class->reg = part_register;
	item_data_class->changed = part_changed;

	item_data_class->get_refdes_prefix = part_get_refdes_prefix;
	item_data_class->set_property = part_set_property;
	item_data_class->has_properties = part_has_properties;
	item_data_class->print = part_print;
}
示例#4
0
void item_data_unregister (ItemData *data)
{
	ItemDataClass *id_class;

	g_return_if_fail (data != NULL);
	g_return_if_fail (IS_ITEM_DATA (data));

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->unreg) {
		id_class->unreg (data);
	}
}
示例#5
0
void item_data_rotate (ItemData *data, int angle, Coords *center)
{
	ItemDataClass *id_class;

	g_return_if_fail (data != NULL);
	g_return_if_fail (IS_ITEM_DATA (data));

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->rotate) {
		id_class->rotate (data, angle, center);
	}
}
示例#6
0
void item_data_flip (ItemData *data, IDFlip direction, Coords *center)
{
	ItemDataClass *id_class;

	g_return_if_fail (data != NULL);
	g_return_if_fail (IS_ITEM_DATA (data));

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->flip) {
		id_class->flip (data, direction, center);
	}
}
示例#7
0
/**
 * \brief changed, forcefully emits a changed signal to recalculate the morph
 *matrix
 *
 * @param data determines which item to refresh
 *
 * \note this function does _not_ request a redraw
 */
void item_data_changed (ItemData *data)
{
	ItemDataClass *id_class;

	g_return_if_fail (data != NULL);
	g_return_if_fail (IS_ITEM_DATA (data));

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->changed == NULL)
		return;

	return id_class->changed (data);
}
示例#8
0
void item_data_print (ItemData *data, cairo_t *cr, SchematicPrintContext *ctx)
{
	ItemDataClass *id_class;

	g_return_if_fail (data != NULL);
	g_return_if_fail (IS_ITEM_DATA (data));
	g_return_if_fail (cr != NULL);

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->print) {
		id_class->print (data, cr, ctx);
	}
}
示例#9
0
gboolean item_data_has_properties (ItemData *data)
{
	ItemDataClass *id_class;

	g_return_val_if_fail (data != NULL, FALSE);
	g_return_val_if_fail (IS_ITEM_DATA (data), FALSE);

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->has_properties) {
		return id_class->has_properties (data);
	}
	return FALSE;
}
示例#10
0
void item_data_set_property (ItemData *data, char *property, char *value)
{
	ItemDataClass *id_class;

	g_return_if_fail (data != NULL);
	g_return_if_fail (IS_ITEM_DATA (data));

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->set_property) {
		id_class->set_property (data, property, value);
		return;
	}
}
示例#11
0
gboolean item_data_register (ItemData *data)
{
	ItemDataClass *id_class;

	g_return_val_if_fail (data != NULL, FALSE);
	g_return_val_if_fail (IS_ITEM_DATA (data), FALSE);

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->reg) {
		return id_class->reg (data);
	}
	return FALSE;
}
示例#12
0
ItemData *item_data_clone (ItemData *src)
{
	ItemDataClass *id_class;

	g_return_val_if_fail (src != NULL, NULL);
	g_return_val_if_fail (IS_ITEM_DATA (src), NULL);

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (src));
	if (id_class->clone == NULL)
		return NULL;

	return id_class->clone (src);
}
示例#13
0
char *item_data_get_refdes_prefix (ItemData *data)
{
	ItemDataClass *id_class;

	g_return_val_if_fail (data != NULL, NULL);
	g_return_val_if_fail (IS_ITEM_DATA (data), NULL);

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (data));
	if (id_class->get_refdes_prefix) {
		return id_class->get_refdes_prefix (data);
	}

	return NULL;
}
示例#14
0
文件: wire.c 项目: neuroidss/oregano
static ItemData *wire_clone (ItemData *src)
{
    Wire *new_wire;
    ItemDataClass *id_class;

    g_return_val_if_fail (src != NULL, NULL);
    g_return_val_if_fail (IS_WIRE (src), NULL);

    id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (src));
    if (id_class->copy == NULL)
        return NULL;

    new_wire = g_object_new (TYPE_WIRE, NULL);
    id_class->copy (ITEM_DATA (new_wire), src);

    return ITEM_DATA (new_wire);
}
示例#15
0
文件: textbox.c 项目: Miuler/oregano
static ItemData *
textbox_clone (ItemData *src)
{
	Textbox *src_textbox, *new_textbox;
	ItemDataClass *id_class;

	g_return_val_if_fail (src != NULL, NULL);
	g_return_val_if_fail (IS_TEXTBOX (src), NULL);

	id_class = ITEM_DATA_CLASS(G_OBJECT_GET_CLASS(src));
	if (id_class->copy == NULL)
		return NULL;

	src_textbox = TEXTBOX(src);
	new_textbox = TEXTBOX(g_object_new(TYPE_TEXTBOX, NULL));
	id_class->copy (ITEM_DATA (new_textbox), src);

	return ITEM_DATA (new_textbox);
}
示例#16
0
static ItemData *part_clone (ItemData *src)
{
	Part *src_part, *new_part;
	ItemDataClass *id_class;

	g_return_val_if_fail (src != NULL, NULL);
	g_return_val_if_fail (IS_PART (src), NULL);

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (src));
	if (id_class->copy == NULL)
		return NULL;

	src_part = PART (src);
	new_part = g_object_new (TYPE_PART, NULL);
	new_part->priv->pins = g_new0 (Pin, src_part->priv->num_pins);
	id_class->copy (ITEM_DATA (new_part), src);

	return ITEM_DATA (new_part);
}
示例#17
0
文件: textbox.c 项目: Miuler/oregano
static void
textbox_class_init (TextboxClass *klass)
{
	GObjectClass *object_class;
	ItemDataClass *item_data_class;

	parent_class = g_type_class_peek(TYPE_ITEM_DATA);
	item_data_class = ITEM_DATA_CLASS(klass);
	object_class = G_OBJECT_CLASS(klass);

	textbox_signals[TEXT_CHANGED] =
		g_signal_new ("text_changed",
			G_TYPE_FROM_CLASS(object_class),
			G_SIGNAL_RUN_FIRST,
			0,
			NULL,
			NULL,
			g_cclosure_marshal_VOID__STRING,
			G_TYPE_NONE, 1, G_TYPE_STRING);

	textbox_signals[FONT_CHANGED] =
		g_signal_new ("font_changed",
			G_TYPE_FROM_CLASS(object_class),
			G_SIGNAL_RUN_FIRST,
			0,
			NULL,
			NULL,
			g_cclosure_marshal_VOID__STRING,
			G_TYPE_NONE, 1, G_TYPE_STRING);

	object_class->finalize= textbox_finalize;
	object_class->dispose = textbox_dispose;

	item_data_class->clone = textbox_clone;
	item_data_class->copy = textbox_copy;
	item_data_class->rotate = textbox_rotate;
	item_data_class->flip = textbox_flip;
	item_data_class->unreg = textbox_unregister;
	item_data_class->reg = textbox_register;
	item_data_class->has_properties = textbox_has_properties;
	item_data_class->print = textbox_print;
}
示例#18
0
void sheet_item_paste (Sheet *sheet, ClipboardData *data)
{
	SheetItemClass *item_class;
	ItemDataClass *id_class;
	ItemData *item_data, *clone;

	g_return_if_fail (sheet != NULL);
	g_return_if_fail (IS_SHEET (sheet));
	g_return_if_fail (data != NULL);

	item_data = ITEM_DATA (clipboard_data_get_item_data (data));

	id_class = ITEM_DATA_CLASS (G_OBJECT_GET_CLASS (item_data));
	if (id_class->clone == NULL)
		return;

	// Duplicate the data for the item and paste the item on the sheet.
	item_class = SHEET_ITEM_CLASS (clipboard_data_get_item_class (data));
	if (item_class->paste) {
		clone = id_class->clone (item_data);
		item_class->paste (sheet, clone);
	}
}