Drop unused context argument.
[geda-gaf/berndj.git] / gschem / src / o_buffer.c
blob7d1f786ebaaf1560e87fb22a00e77ac752c3fc7b
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 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
20 #include <config.h>
21 #include <stdio.h>
23 #include "gschem.h"
25 #ifdef HAVE_LIBDMALLOC
26 #include <dmalloc.h>
27 #endif
29 /*! \todo Finish function documentation!!!
30 * \brief
31 * \par Function Description
34 void o_buffer_copy(GSCHEM_TOPLEVEL *w_current, int buf_num)
36 TOPLEVEL *toplevel = w_current->toplevel;
37 GList *s_current = NULL;
39 if (buf_num < 0 || buf_num > MAX_BUFFERS) {
40 fprintf(stderr, _("Got an invalid buffer_number [o_buffer_copy]\n"));
41 return;
44 s_current = geda_list_get_glist( toplevel->page_current->selection_list );
46 if (object_buffer[buf_num] != NULL) {
47 s_delete_object_glist(toplevel, object_buffer[buf_num]);
48 object_buffer[buf_num] = NULL;
51 toplevel->ADDING_SEL = 1;
52 object_buffer[buf_num] =
53 o_glist_copy_all_to_glist(toplevel, s_current,
54 object_buffer[buf_num], SELECTION_FLAG);
55 toplevel->ADDING_SEL = 0;
58 /*! \todo Finish function documentation!!!
59 * \brief
60 * \par Function Description
63 void o_buffer_cut(GSCHEM_TOPLEVEL *w_current, int buf_num)
65 TOPLEVEL *toplevel = w_current->toplevel;
66 GList *s_current = NULL;
68 if (buf_num < 0 || buf_num > MAX_BUFFERS) {
69 fprintf(stderr, _("Got an invalid buffer_number [o_buffer_cut]\n"));
70 return;
73 s_current = geda_list_get_glist( toplevel->page_current->selection_list );
75 if (object_buffer[buf_num] != NULL) {
76 s_delete_object_glist(toplevel, object_buffer[buf_num]);
77 object_buffer[buf_num] = NULL;
80 toplevel->ADDING_SEL = 1;
81 object_buffer[buf_num] =
82 o_glist_copy_all_to_glist(toplevel, s_current,
83 object_buffer[buf_num], SELECTION_FLAG);
84 toplevel->ADDING_SEL = 0;
85 o_delete_selected(w_current);
88 /*! \todo Finish function documentation!!!
89 * \brief
90 * \par Function Description
93 void o_buffer_paste_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
94 int buf_num)
96 TOPLEVEL *toplevel = w_current->toplevel;
97 int rleft, rtop, rbottom, rright;
98 int x, y;
100 if (buf_num < 0 || buf_num > MAX_BUFFERS) {
101 fprintf(stderr, _("Got an invalid buffer_number [o_buffer_paste_start]\n"));
102 return;
105 w_current->last_drawb_mode = LAST_DRAWB_MODE_NONE;
107 /* remove the old place list if it exists */
108 s_delete_object_glist(toplevel, toplevel->page_current->place_list);
109 toplevel->page_current->place_list = NULL;
111 toplevel->ADDING_SEL = 1;
112 toplevel->page_current->place_list =
113 o_glist_copy_all_to_glist(toplevel, object_buffer[buf_num],
114 toplevel->page_current->place_list,
115 SELECTION_FLAG);
117 if (!world_get_object_glist_bounds(toplevel->page_current->place_list,
118 &rleft, &rtop,
119 &rright, &rbottom)) {
120 /* If the place buffer doesn't have any objects
121 * to define its any bounds, we drop out here */
122 return;
125 /* Place the objects into the buffer at the mouse origin, (w_x, w_y). */
127 w_current->first_wx = w_x;
128 w_current->first_wy = w_y;
130 /* snap x and y to the grid, pointed out by Martin Benes */
131 x = snap_grid(toplevel, rleft);
132 y = snap_grid(toplevel, rtop);
134 o_glist_translate_world(w_x - x, w_y - y,
135 toplevel->page_current->place_list);
136 toplevel->ADDING_SEL = 0;
138 w_current->inside_action = 1;
139 i_set_state(w_current, ENDPASTE);
140 o_place_start (w_current, w_x, w_y);
144 /*! \todo Finish function documentation!!!
145 * \brief
146 * \par Function Description
149 void o_buffer_init(void)
151 int i;
153 for (i = 0 ; i < MAX_BUFFERS; i++) {
154 object_buffer[i] = NULL;
158 /*! \todo Finish function documentation!!!
159 * \brief
160 * \par Function Description
163 void o_buffer_free(GSCHEM_TOPLEVEL *w_current)
165 TOPLEVEL *toplevel = w_current->toplevel;
166 int i;
168 for (i = 0 ; i < MAX_BUFFERS; i++) {
169 if (object_buffer[i]) {
170 s_delete_object_glist(toplevel, object_buffer[i]);
171 object_buffer[i] = NULL;