/*! \todo Finish function documentation!!! * \brief * \par Function Description * * \note * The object passed in should be the REAL object, NOT any copy in any * selection list */ void o_text_change(GschemToplevel *w_current, OBJECT *object, char *string, int visibility, int show) { GschemPageView *page_view = gschem_toplevel_get_current_page_view (w_current); TOPLEVEL *toplevel = gschem_page_view_get_toplevel (page_view); PAGE *page = gschem_page_view_get_page (page_view); g_return_if_fail (toplevel != NULL); g_return_if_fail (page != NULL); if (object == NULL) { return; } if (object->type != OBJ_TEXT) { return; } o_text_set_string (toplevel, object, string); o_set_visibility (toplevel, object, visibility); object->show_name_value = show; o_text_recreate(toplevel, object); /* handle slot= attribute, it's a special case */ if (object->attached_to != NULL && g_ascii_strncasecmp (string, "slot=", 5) == 0) { o_slot_end (w_current, object->attached_to, string); } gschem_toplevel_page_content_changed (w_current, page); }
/*! \brief Complete the text edit * * \par Function Description * This function completes the text edit by setting all the selected text * objects to the desired values. * * \param [in] w_current The topleval gschem struct. * \param [in] string The text to set the selected text objects to. If this * string is NULL or has zero length, then this function * leaves the text unchanged. * \param [in] color The color to set the selected text to. If the color * is less than zero, then this function leaves the color * unchanged. * \param [in] align The text alignment to set the selected text to. If * the alignment is less than zero, this function leaves * the alignment unchanged. * \param [in] rotate The rotation angle to set the selected text to. If * the rotation angle is less than zero, this function * leaves the rotation angle unchanged. * \param [in] size The size to set all the selected text to. If the * size is less than or equal to zero, this function * leaves the size unchanged. */ void o_text_edit_end(GschemToplevel *w_current, char *string, int color, int align, int rotate, int size) { GschemPageView *page_view = gschem_toplevel_get_current_page_view (w_current); TOPLEVEL *toplevel = gschem_page_view_get_toplevel (page_view); PAGE *page = gschem_page_view_get_page (page_view); OBJECT *object; GList *s_current; char *textstr = string; g_return_if_fail (toplevel != NULL); g_return_if_fail (page != NULL); if ((textstr != NULL) && (g_utf8_strlen(textstr, -1) == 0)) { textstr = NULL; } /* skip over head */ s_current = geda_list_get_glist (page->selection_list); while(s_current != NULL) { object = (OBJECT *) s_current->data; if (object) { if (object->type == OBJ_TEXT) { if (size > 0) { object->text->size = size; } if (align >= 0) { object->text->alignment = align; } if (color >= 0) { object->color = color; } if (rotate >= 0) { object->text->angle = rotate; } if (textstr != NULL) { o_text_set_string (toplevel, object, textstr); /* handle slot= attribute, it's a special case */ if (object->attached_to != NULL && g_ascii_strncasecmp (textstr, "slot=", 5) == 0) { o_slot_end (w_current, object->attached_to, textstr); } } o_text_recreate(toplevel, object); } } s_current = g_list_next(s_current); } gschem_toplevel_page_content_changed (w_current, page); o_undo_savestate(w_current, page, UNDO_ALL); }
/*! \brief response function for the slot edit dialog * \par Function Description * The function takes the dialog entry and applies the new slot to the * symbol. */ void slot_edit_dialog_response(GtkWidget *widget, gint response, GschemToplevel *w_current) { GtkWidget *textentry; char *slot_string; int len; gchar *string = NULL; switch (response) { case GTK_RESPONSE_REJECT: case GTK_RESPONSE_DELETE_EVENT: /* void */ break; case GTK_RESPONSE_ACCEPT: textentry = GTK_WIDGET (g_object_get_data (G_OBJECT (w_current->sewindow), "textentry")); string = (gchar*) gtk_entry_get_text(GTK_ENTRY(textentry)); len = strlen(string); if (len != 0) { slot_string = g_strdup_printf ("slot=%s", string); o_slot_end (w_current, o_select_return_first_object (w_current), slot_string); g_free (slot_string); } break; default: printf("slot_edit_dialog_response(): strange signal %1$d\n",response); } i_set_state(w_current, SELECT); gtk_widget_destroy(w_current->sewindow); w_current->sewindow = NULL; }
/*! \brief Changes the number <B>OBJECT</B> element. Changes the slot attribute. * \par Function Description * This function updates the text content of the <B>o_current</B> object. * If the <B>slot</B> value is not zero. It updates the slot attribut of the * complex element that is also the parent object of the o_current element. */ void autonumber_apply_new_text(AUTONUMBER_TEXT * autotext, OBJECT *o_current, gint number, gint slot) { char *str; if (slot != 0) { /* update the slot on the owning object */ str = g_strdup_printf ("slot=%d", slot); o_slot_end (autotext->w_current, o_current->attached_to, str); g_free (str); } /* replace old text */ str = g_strdup_printf("%s%d", autotext->current_searchtext, number); o_text_set_string (autotext->w_current->toplevel, o_current, str); g_free (str); gschem_toplevel_page_content_changed (autotext->w_current, autotext->w_current->toplevel->page_current); }
/* text item */ OBJECT *o_attrib_add_attrib(GschemToplevel *w_current, const char *text_string, int visibility, int show_name_value, OBJECT *object) { TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current); OBJECT *new_obj; int world_x = - 1, world_y = -1; int align = LOWER_LEFT; int angle = 0; int color; int left, right, top, bottom; OBJECT *o_current; color = DETACHED_ATTRIBUTE_COLOR; o_current = object; /* creating a toplevel or unattached attribute */ if (o_current) { /* get coordinates of where to place the text object */ switch(o_current->type) { case(OBJ_COMPLEX): case(OBJ_PLACEHOLDER): world_x = o_current->complex->x; world_y = o_current->complex->y; align = LOWER_LEFT; angle = 0; color = ATTRIBUTE_COLOR; break; case(OBJ_ARC): world_x = o_current->arc->x; world_y = o_current->arc->y; align = LOWER_LEFT; angle = 0; color = ATTRIBUTE_COLOR; break; case(OBJ_CIRCLE): world_x = o_current->circle->center_x; world_y = o_current->circle->center_y; align = LOWER_LEFT; angle = 0; color = ATTRIBUTE_COLOR; break; case(OBJ_BOX): world_x = o_current->box->upper_x; world_y = o_current->box->upper_y; align = LOWER_LEFT; angle = 0; color = ATTRIBUTE_COLOR; break; case(OBJ_LINE): case(OBJ_NET): case(OBJ_PIN): case(OBJ_BUS): { int dx = o_current->line->x[1] - o_current->line->x[0]; int dy = o_current->line->y[1] - o_current->line->y[0]; if (dy == 0) { if (dx > 0) { world_x = o_current->line->x[0] + SPACING_FROM_END; world_y = o_current->line->y[0] + SPACING_PERPENDICULAR; align = LOWER_LEFT; angle = 0; } else { world_x = o_current->line->x[0] - SPACING_FROM_END; world_y = o_current->line->y[0] + SPACING_PERPENDICULAR; align = LOWER_RIGHT; angle = 0; } } else if (dx == 0) { if (dy > 0) { world_x = o_current->line->x[0] - SPACING_PERPENDICULAR; world_y = o_current->line->y[0] + SPACING_FROM_END; align = LOWER_LEFT; angle = 90; } else { world_x = o_current->line->x[0] - SPACING_PERPENDICULAR; world_y = o_current->line->y[0] - SPACING_FROM_END; align = LOWER_RIGHT; angle = 90; } } else { world_x = o_current->line->x[0]; world_y = o_current->line->y[0]; align = LOWER_LEFT; angle = 0; } color = ATTRIBUTE_COLOR; } break; case(OBJ_TEXT): world_x = o_current->text->x; world_y = o_current->text->y; color = DETACHED_ATTRIBUTE_COLOR; align = LOWER_LEFT; angle = 0; o_current = NULL; break; } } else { world_get_object_glist_bounds (toplevel, s_page_objects (toplevel->page_current), &left, &top, &right, &bottom); /* this really is the lower left hand corner */ world_x = left; world_y = top; /* printf("%d %d\n", world_x, world_y); */ align = LOWER_LEFT; angle = 0; color = DETACHED_ATTRIBUTE_COLOR; } /* first create text item */ new_obj = o_text_new(toplevel, color, world_x, world_y, align, angle, text_string, w_current->text_size, /* current text size */ visibility, show_name_value); s_page_append (toplevel, toplevel->page_current, new_obj); /* now attach the attribute to the object (if o_current is not NULL) */ /* remember that o_current contains the object to get the attribute */ if (o_current) { o_attrib_attach (toplevel, new_obj, o_current, FALSE); } o_selection_add (toplevel, toplevel->page_current->selection_list, new_obj); /* handle slot= attribute, it's a special case */ if (o_current != NULL && g_ascii_strncasecmp (text_string, "slot=", 5) == 0) { o_slot_end (w_current, o_current, text_string); } /* Call add-objects-hook. */ g_run_hook_object (w_current, "%add-objects-hook", new_obj); g_run_hook_object (w_current, "%select-objects-hook", new_obj); gschem_toplevel_page_content_changed (w_current, toplevel->page_current); return new_obj; }