1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
29 #ifdef HAVE_LIBDMALLOC
33 #define MAX_SLOT_SIZE 10
35 /*! \todo Finish function documentation!!!
36 * \brief Change slot of selected component
37 * \par Function Description
40 void o_slot_start (GSCHEM_TOPLEVEL
*w_current
, OBJECT
*object
)
44 /* single object for now */
45 if (object
->type
!= OBJ_COMPLEX
)
48 slot_value
= o_attrib_search_object_attribs_by_name (object
, "slot", 0);
50 if (slot_value
== NULL
) {
51 /* we didn't find a slot=? attribute, make something up */
52 /* for now.. this is an error condition */
53 slot_value
= g_strdup ("1");
56 slot_edit_dialog (w_current
, slot_value
);
60 /*! \todo Finish function documentation!!!
62 * \par Function Description
65 void o_slot_end(GSCHEM_TOPLEVEL
*w_current
, OBJECT
*object
, const char *string
)
67 TOPLEVEL
*toplevel
= w_current
->toplevel
;
77 g_return_if_fail (object
!= NULL
);
79 status
= o_attrib_string_get_name_value (string
, NULL
, &value
);
81 s_log_message (_("Slot attribute malformed\n"));
86 o_attrib_search_object_attribs_by_name (object
, "numslots", 0);
88 if (!numslots_value
) {
89 s_log_message (_("numslots attribute missing\n"));
90 s_log_message (_("Slotting not allowed for this component\n"));
95 numslots
= atoi (numslots_value
);
96 g_free (numslots_value
);
98 new_slot_number
= atoi (value
);
101 printf ("numslots = %d\n", numslots
);
104 if (new_slot_number
> numslots
|| new_slot_number
<=0 ) {
105 s_log_message (_("New slot number out of range\n"));
110 /* first see if slot attribute already exists outside
112 slot_value
= s_slot_search_slot (object
, &o_slot
);
115 if (o_slot
!= NULL
&& !o_attrib_is_inherited (o_slot
)) {
116 o_text_set_string (toplevel
, o_slot
, string
);
118 if (o_slot
->visibility
== VISIBLE
||
119 (o_slot
->visibility
== INVISIBLE
&& toplevel
->show_hidden_text
)) {
120 o_invalidate (w_current
, o_slot
);
123 o_text_recreate (toplevel
, o_slot
);
125 /* this doesn't deal with the selection list
127 if (o_slot
->visibility
== VISIBLE
||
128 (o_slot
->visibility
== INVISIBLE
&& toplevel
->show_hidden_text
)) {
129 o_invalidate (w_current
, o_slot
);
133 /* here you need to do the add the slot
134 attribute since it doesn't exist */
135 new_obj
= o_text_new (toplevel
, OBJ_TEXT
, ATTRIBUTE_COLOR
,
136 object
->complex->x
, object
->complex->y
,
137 LOWER_LEFT
, 0, /* zero is angle */
138 string
, 10, INVISIBLE
, SHOW_NAME_VALUE
);
139 s_page_append (toplevel
, toplevel
->page_current
, new_obj
);
141 /* manually attach attribute */
142 o_attrib_attach (toplevel
, new_obj
, object
, FALSE
);
145 o_invalidate (w_current
, object
);
146 s_slot_update_object (toplevel
, object
);
148 o_invalidate (w_current
,object
);
150 toplevel
->page_current
->CHANGED
= 1;