Updated copyright text/header in most source files.
[geda-gaf/peter-b.git] / gattrib / include / globals.h
blobc1ffd6c394239284a6804b0be12e5f8992765342
1 /* gEDA - GPL Electronic Design Automation
2 * gattrib -- gEDA component and net attribute manipulation using spreadsheet.
3 * Copyright (C) 2003-2010 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 /*!
22 * \file
23 * \brief Global variable declarations
25 * \section sdb_note SDB note about philosophy behind globals
27 * I made the "TOPLEVEL project" and all the GTK window stuff into
28 * global variables. I know that this is supposedly bad programming form.
29 * However, here are some observations:
30 * - I wanted to use gEDA's TOPLEVEL structure as much as possible, at
31 * least to hold info about the design's netlist & components.
32 * The TOPLEVEL strucuture is architected to hold info about gschem's
33 * window also. HOwever, gschem's windows are architected differently
34 * than mine in gattrib. This is because my windowing system does
35 * completely different things, and also uses the GtkSheet widget, which
36 * is architected completely differently from TOPLEVEL.
37 * - Since I couldn't easily or naturally cram my windowing scheme into
38 * TOPLEVEL (or so I think), I decided to use a separate set of windows
39 * from those defined under TOPLEVEL for my application.
40 * - The problem arises when using callbacks. Callbacks from GTK allow
41 * only one argument to be passed. Given the way I set up the menu bar,
42 * I didn't have easy acces to the information inside both the GtkSHeet
43 * objects *and* the TOPLEVEL stuff while only having one callback
44 * argument. This makes it hard to have access to e.g. a GtkSheet window
45 * and a list of files (in TOPLEVEL) simultaneously.
46 * - Therefore, I decided to make both the window stuff and TOPLEVEL
47 * globals.
48 * - Similarly, because I couldn't cram the SHEET_DATA struct into any
49 * hook in TOPLEVEL, I just made it a global also.
50 * - Finally, in my defense, in gschem and gnetlist, (TOPLEVEL *w_current
51 * or pr_current) is passed to almost every function. Since it
52 * is just a pointer to a huge struct of stuff, manipulating
53 * the stuff in the struct has a global
54 * effect. That is, manipulating w_current (or pr_current) has side
55 * effects, so it is basically a global anyway. The real problem with
56 * globals occurs when you have a global variable caled "i" or "temp"
57 * which conflicts with a global in a module written by somebody else.
58 * Since pr_current is a very uncommon name, this should not be a
59 * problem here. Therefore, I decided
60 * to make life easy for myself dealing with callbacks by making both
61 * the windows and TOPLEVEL global variables.
63 * If there is a better way to solve this problem, I'd like to hear it.
66 /* ------------------------------------------------------------------ */
68 #ifndef __GLOBALS__
69 #define __GLOBALS__
72 /*------------------------------------------------------------------*/
73 /*!
74 * The main data structure from gEDA. I made it a
75 * global since it was treated that way anyway. It is defined in
76 * structs.h
78 /*------------------------------------------------------------------*/
79 TOPLEVEL *pr_current;
81 /*------------------------------------------------------------------*/
82 /*!
83 * My own data structure which I made
84 * a global because it was easier to deal with when handing
85 * callbacks. It is defined in structs.h
87 /*------------------------------------------------------------------*/
88 SHEET_DATA *sheet_head;
90 /*------------------------------------------------------------------
91 * GTKsheet includes: stuff for dealing with windows.
92 *------------------------------------------------------------------*/
93 #define DEFAULT_PRECISION 2
94 #define DEFAULT_SPACE 8
95 #define NUM_SHEETS 3 /* Components, Nets, and Pins */
97 GtkWidget *window; /* Main window */
98 GtkWidget *notebook;
100 GtkSheet **sheets; /* These are the spreadsheet widgets themselves */
102 GtkWidget **scrolled_windows;
103 GtkWidget *entry;
104 GtkWidget *location;
105 GtkWidget *left_button;
106 GtkWidget *center_button;
107 GtkWidget *right_button;
108 GtkWidget *label;
110 /* command line switch settings */
111 extern int verbose_mode;
112 extern int quiet_mode;
114 /* Used to identify colors */
115 #define BLACK 0
116 #define WHITE 1
117 #define RED 2
118 #define GREEN 3
119 #define BLUE 4
120 #define YELLOW 5
121 #define CYAN 6
122 #define GREY 7
124 #endif