1
/* gEDA - GPL Electronic Design Automation
2
* gsymcheck - gEDA Symbol Check
3
* Copyright (C) 1998-2000 Ales V. Hvezda
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
#include <libgeda/libgeda.h>
26
#include "../include/papersizes.h"
27
#include "../include/prototype.h"
30
/* global_wid always increments, it needs to be unique per gsymcheck run */
31
static int num_projects=0;
32
static int global_wid=0;
34
/* head pointer to window structure, this points to all the windows that
36
static TOPLEVEL *project_head=NULL;
37
static TOPLEVEL *project_tail=NULL;
39
/* add to the end of the list */
41
s_project_add(TOPLEVEL *w_head, TOPLEVEL *pr_current)
44
pr_current->prev = NULL;
45
pr_current->next = NULL;
48
pr_current->prev = w_head;
49
pr_current->next = NULL;
50
w_head->next = pr_current;
58
project_tail = project_head = (TOPLEVEL *) malloc(sizeof(TOPLEVEL));
59
project_head->wid = -1;
68
/* deletes specified window from w_head list */
69
/* doesn't do the actual destroy though */
71
s_project_delete(TOPLEVEL *w_head, TOPLEVEL *pr_current)
74
if (w_head == NULL || pr_current == NULL) {
75
/* error condition hack */
80
pr_current->next->prev = pr_current->prev;
83
pr_current->prev->next = pr_current->next;
85
s_page_free_all(pr_current, pr_current->page_tail);
90
s_project_setup_world(TOPLEVEL *pr_current)
92
pr_current->init_left = 0;
93
pr_current->init_top = 0;
94
/* init_right and _bottom are set before this function is called */
95
pr_current->min_zoom = 0;
96
pr_current->max_zoom = 8;
99
/* part of page mechanism addition commented out
100
pr_current->zoom_factor = 0;
105
s_project_setup_rest(TOPLEVEL *pr_current)
107
pr_current->num_untitled=0;
109
pr_current->start_x=-1;
110
pr_current->start_y=-1;
111
pr_current->save_x=-1;
112
pr_current->save_y=-1;
113
pr_current->last_x=-1;
114
pr_current->last_y=-1;
115
pr_current->loc_x=-1;
116
pr_current->loc_y=-1;
117
pr_current->distance=-1;
118
pr_current->event_state=-1;
119
pr_current->inside_action=0;
123
pr_current->current_attribute=NULL;
124
pr_current->current_visible=-1; /* not sure on these */
125
pr_current->current_show=-1;
127
pr_current->internal_basename=NULL;
128
pr_current->internal_clib=NULL;
130
pr_current->series_name = NULL;
131
pr_current->untitled_name = NULL;
132
pr_current->font_directory = NULL;
133
pr_current->scheme_directory = NULL;
135
/* part of page mechanism addition commented out
136
pr_current->zoom_factor=0;
138
pr_current->override_color=-1;
139
pr_current->inside_redraw=0;
142
/* Don't init these to zero here... once we are done with all init
143
* will these be inited to zero
144
* pr_current->DONT_DRAW_CONN=0;
145
* pr_current->DONT_RESIZE=0;
146
* pr_current->DONT_EXPOSE=0;
147
* pr_current->DONT_RECALC=0;
150
pr_current->FORCE_CONN_UPDATE=0;
151
pr_current->ADDING_SEL=0;
152
pr_current->REMOVING_SEL=0;
154
pr_current->drawbounding_action_mode=FREE;
155
pr_current->last_drawb_mode = -1;
156
pr_current->CONTROLKEY=0;
157
pr_current->SHIFTKEY=0;
158
pr_current->last_callback=NULL;
160
pr_current->cswindow = NULL;
161
pr_current->aswindow = NULL;
162
pr_current->fowindow = NULL;
163
pr_current->fswindow = NULL;
165
pr_current->tiwindow = NULL;
166
pr_current->tewindow = NULL;
167
pr_current->exwindow = NULL;
168
pr_current->aawindow = NULL;
169
pr_current->trwindow = NULL;
170
pr_current->tswindow = NULL;
171
pr_current->pswindow = NULL;
172
pr_current->pwindow = NULL;
173
pr_current->abwindow = NULL;
174
pr_current->hkwindow = NULL;
175
pr_current->cowindow = NULL;
177
pr_current->coord_world = NULL;
178
pr_current->coord_screen = NULL;
179
/* pr_current->preview = NULL;experimental widget */
181
pr_current->width = 1;
182
pr_current->height = 1;
183
pr_current->snap_size = 100;
185
/* The following is an attempt at getting (deterministic) defaults */
186
/* for the following variables */
187
pr_current->attribute_promotion = FALSE;
188
pr_current->promote_invisible = FALSE;
189
pr_current->keep_invisible = FALSE;
194
s_project_create_new(void)
196
TOPLEVEL *pr_current=NULL;
198
/* allocate new window structure */
199
pr_current = (TOPLEVEL *) malloc(sizeof(TOPLEVEL));
201
pr_current->wid = global_wid;
203
/* make sure none of these events happen till we are done */
205
pr_current->DONT_DRAW_CONN=1;
206
pr_current->DONT_RESIZE=1;
207
pr_current->DONT_EXPOSE=1;
208
pr_current->DONT_RECALC=1;
211
/* the default coord sizes */
212
/* real ones set in rc file */
213
pr_current->init_right = WIDTH_C;
214
pr_current->init_bottom = HEIGHT_C;
217
#if 0 /* X related stuff */
218
pr_current->display_height = gdk_screen_height();
219
pr_current->display_width = gdk_screen_width();
222
s_project_setup_world(pr_current);
224
#if 0 /* X related stuff */
225
/* do X fill in first */
226
s_project_create_main(pr_current);
229
/* do other var fill in */
230
s_project_setup_rest(pr_current);
232
/* do default interface variables */
234
i_vars_setdefault(pr_current);
237
/* Put head node on page list... be sure to free this somewhere hack */
238
s_page_add_head(pr_current);
240
/* Now create a blank page */
241
pr_current->page_tail = s_page_add(pr_current,
242
pr_current->page_tail,
244
/* this is correct */
246
s_page_setup(pr_current->page_tail);
248
/* setup page_current link */
249
pr_current->page_current = pr_current->page_tail;
251
/* Special case init */
252
/* move this elsewhere eventually */
253
/* pr_current->page_current->object_parent=NULL; not this one */
255
pr_current->page_current->object_lastplace=NULL;
256
pr_current->page_current->object_selected=NULL;
258
set_window(pr_current, pr_current->init_left, pr_current->init_right,
259
pr_current->init_top, pr_current->init_bottom);
261
#if 0 /* X related stuff */
262
/* now update the scrollbars */
263
x_hscrollbar_update(pr_current);
264
x_vscrollbar_update(pr_current);
270
project_tail = s_project_add(project_tail, pr_current);
273
i_vars_setdefault(pr_current);
276
/* no longer doing the old rc files */
277
/* f_rc_parse(pr_current);*/
279
g_rc_parse(pr_current);
281
/* renable the events */
282
pr_current->DONT_DRAW_CONN=0;
283
pr_current->DONT_RESIZE=0;
284
pr_current->DONT_EXPOSE=0;
285
pr_current->DONT_RECALC=0;
290
/* stays the same ???????????? */
292
s_project_close(TOPLEVEL *pr_current)
295
/* make sure project_tail stays correct and doesn't dangle */
296
/* project_head can't dangle since it has a head node, which is */
297
/* NEVER deallocated (only at the very end) */
298
if (project_tail == pr_current) {
299
project_tail = pr_current->prev;
303
if (pr_current->series_name) {
304
free(pr_current->series_name);
307
if (pr_current->untitled_name) {
308
free(pr_current->untitled_name);
311
if (pr_current->font_directory) {
312
free(pr_current->font_directory);
315
if (pr_current->scheme_directory) {
316
free(pr_current->scheme_directory);
319
/* close the log file */
323
/* if you close a window, then you free the font set... */
324
/* this is probably a bad idea... */
325
o_text_freeallfonts(pr_current);
327
s_project_delete(project_head, pr_current);
329
num_projects = num_projects - 1;
333
/* just closed last window, so quit */
334
if (num_projects == 0) {
340
s_project_close_all()
342
TOPLEVEL *pr_current;
345
pr_current = project_tail;
347
/* loop over all windows to close */
348
/* going backwards */
349
/* wid == -1 is the head and we are done. */
350
while(pr_current != NULL && pr_current->wid != -1) {
351
w_prev = pr_current->prev;
352
s_project_close(pr_current);
356
/* now free the head */
357
/* only if all the windows are gone */
359
if (project_head->next == NULL && num_projects == 0) {
360
s_project_free_head();
365
s_project_get_ptr(int wid)
367
TOPLEVEL *pr_current;
369
pr_current = project_head;
371
while(pr_current != NULL) {
372
if (pr_current->wid == wid) {
376
pr_current = pr_current->next;