1 /* gEDA - GNU Electronic Design Automation
2 * gattrib -- gEDA component and net attribute manipulation using spreadsheet.
3 * Copyright (C) 2003 Stuart D. Brorson.
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., 59 Temple Place, Suite 330, Boston, MA 02111 USA
21 /* ----------- SDB note about philosophy behind globals -------------- *
22 * I made the "TOPLEVEL project" and all the GTK window stuff into
23 * global variables. I know that this is supposedly bad programming form.
24 * However, here are some observations:
25 * -- I wanted to use gEDA's TOPLEVEL structure as much as possible, at
26 * least to hold info about the design's netlist & components.
27 * The TOPLEVEL strucuture is architected to hold info about gschem's
28 * window also. HOwever, gschem's windows are architected differently
29 * than mine in gattrib. This is because my windowing system does
30 * completely different things, and also uses the GtkSheet widget, which
31 * is architected completely differently from TOPLEVEL.
32 * -- Since I couldn't easily or naturally cram my windowing scheme into
33 * TOPLEVEL (or so I think), I decided to use a separate set of windows
34 * from those defined under TOPLEVEL for my application.
35 * -- The problem arises when using callbacks. Callbacks from GTK allow
36 * only one argument to be passed. Given the way I set up the menu bar,
37 * I didn't have easy acces to the information inside both the GtkSHeet
38 * objects *and* the TOPLEVEL stuff while only having one callback
39 * argument. This makes it hard to have access to e.g. a GtkSheet window
40 * and a list of files (in TOPLEVEL) simultaneously.
41 * -- Therefore, I decided to make both the window stuff and TOPLEVEL
43 * -- Similarly, because I couldn't cram the SHEET_DATA struct into any
44 * hook in TOPLEVEL, I just made it a global also.
45 * -- Finally, in my defense, in gschem and gnetlist, (TOPLEVEL *w_current
46 * or pr_current) is passed to almost every function. Since it
47 * is just a pointer to a huge struct of stuff, manipulating
48 * the stuff in the struct has a global
49 * effect. That is, manipulating w_current (or pr_current) has side
50 * effects, so it is basically a global anyway. The real problem with
51 * globals occurs when you have a global variable caled "i" or "temp"
52 * which conflicts with a global in a module written by somebody else.
53 * Since pr_current is a very uncommon name, this should not be a
54 * problem here. Therefore, I decided
55 * to make life easy for myself dealing with callbacks by making both
56 * the windows and TOPLEVEL global variables.
57 * If there is a better way to solve this problem, I'd like to hear it.
58 * ------------------------------------------------------------------ */
64 /*------------------------------------------------------------------
65 * pr_current -- the main data structure from gEDA. I made it a
66 * global since it was treated that way anyway. It is defined in
68 *------------------------------------------------------------------*/
71 /*------------------------------------------------------------------
72 * first_page -- this will eventually get folded into the TOPLEVEL
74 *------------------------------------------------------------------*/
75 int first_page
; /* set to zero after first page is read in. */
77 /*------------------------------------------------------------------
78 * (SHEET_DATA *sheet_head) -- my own data structure which I made
79 * a global because it was easier to deal with when handing
80 * callbacks. It is defined in structs.h
81 *------------------------------------------------------------------*/
82 SHEET_DATA
*sheet_head
;
84 /*------------------------------------------------------------------
85 * GTKsheet includes: stuff for dealing with windows.
86 *------------------------------------------------------------------*/
87 #define DEFAULT_PRECISION 2
88 #define DEFAULT_SPACE 8
89 #define NUM_SHEETS 3 /* Components, Nets, and Pins */
91 GtkWidget
*window
; /* Main window */
92 GtkWidget
*main_vbox
; /* Container which vertically aligns children */
93 GtkWidget
*menu_bar
; /* Menu bar (holding file, edit, etc . . . */
96 GtkSheet
**sheets
; /* These are the spreadsheet widgets themselves */
98 GtkWidget
**scrolled_windows
;
99 GtkWidget
*show_hide_box
;
100 GtkWidget
*status_box
;
103 GtkWidget
*fgcolorcombo
;
104 GtkWidget
*bgcolorcombo
;
105 GtkWidget
*bordercombo
;
108 GtkWidget
*bg_pixmap
;
109 GtkWidget
*fg_pixmap
;
111 GtkWidget
*left_button
;
112 GtkWidget
*center_button
;
113 GtkWidget
*right_button
;
115 GtkWidget
*bullet
[10];
121 GtkWidget
*font_combo
;
122 GtkWidget
*toggle_combo
;
124 /*------------------------------------------------------------------
125 * This stuff copied over from gschem
126 *------------------------------------------------------------------*/
128 extern GdkColormap
*colormap
;
129 extern GdkVisual
*visual
;
132 extern GdkColor white
;
133 extern GdkColor black
;
135 extern GdkColor green
;
136 extern GdkColor blue
;
137 extern GdkColor cyan
;
138 extern GdkColor yellow
;
139 extern GdkColor grey
;
140 extern GdkColor grey90
;
141 extern GdkColor darkgreen
;
142 extern GdkColor darkred
;
143 extern GdkColor darkyellow
;
144 extern GdkColor darkcyan
;
145 extern GdkColor darkblue
;
146 extern GdkColor darkgrey
;
148 extern char *rc_filename
;
150 extern int logfile_fd
;
151 extern int do_logging
;
152 extern int logging_dest
;
154 /* Internationalization */
157 /* gattrib specific stuff */
158 extern char *guile_proc
; /* Needed for read-in of rc files */
160 /* command line switch settings */
161 extern int verbose_mode
;
162 extern int quiet_mode
;