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)
5 *
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.
10 *
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.
15 *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 #include <config.h>
21 #include <stdio.h>
22
23 #include "gschem.h"
24
25 #ifdef HAVE_LIBDMALLOC
26 #include <dmalloc.h>
27 #endif
28
29 /*! \def INIT_STR(w, name, str) */
30 #define INIT_STR(w, name, str) { \
31 g_free((w)->name); \
32 (w)->name = g_strdup(((default_ ## name) != NULL) ? \
33 (default_ ## name) : (str)); \
34 }
35
36 /* Absolute default used when default_... strings are NULL */
37 #define DEFAULT_PRINT_COMMAND "lpr"
38
39 int default_text_size = 10;
40 int default_text_caps = LOWER;
41 int default_attribute_color = ATTRIBUTE_COLOR;
42 int default_detachattr_color = DETACHED_ATTRIBUTE_COLOR;
43 int default_net_endpoint_color = NET_ENDPOINT_COLOR;
44 int default_junction_color = JUNCTION_COLOR;
45 int default_override_net_color = -1;
46 int default_override_bus_color = -1;
47 int default_override_pin_color = -1;
48 int default_net_endpoint_mode = FILLEDBOX;
49 int default_net_midpoint_mode = FILLED;
50 int default_net_direction_mode = TRUE;
51 int default_net_selection_mode = 0;
52 int default_pin_style = THICK;
53 int default_net_style = THICK;
54 int default_bus_style = THICK;
55 int default_line_style = THICK;
56 int default_background_color = BACKGROUND_COLOR;
57 int default_actionfeedback_mode = OUTLINE;
58 int default_zoom_with_pan = TRUE;
59 int default_object_clipping = TRUE;
60 int default_do_logging = TRUE;
61 int default_logging_dest = LOG_WINDOW;
62 int default_embed_complex = FALSE;
63 int default_include_complex = FALSE;
64 int default_snap_size = 100;
65
66 int default_paper_width = 11000; /* letter size */
67 int default_paper_height = 85000;
68 int default_scrollbars_flag = TRUE;
69 char *default_print_command = NULL;
70 int default_print_orientation = LANDSCAPE;
71 int default_image_color = FALSE;
72 int default_image_width = 800;
73 int default_image_height = 600;
74 int default_print_color = FALSE;
75 int default_print_color_background = OUTPUT_BACKGROUND_COLOR;
76 int default_print_output_type = EXTENTS;
77 int default_print_output_capstyle = SQUARE_CAP;
78 int default_log_window = MAP_ON_STARTUP;
79 int default_log_window_type = DECORATED;
80 int default_third_button = POPUP_ENABLED;
81 #ifdef HAVE_LIBSTROKE
82 int default_middle_button = STROKE;
83 #else
84 int default_middle_button = REPEAT;
85 #endif
86 int default_scroll_wheel = SCROLL_WHEEL_CLASSIC;
87 int default_net_consolidate = TRUE;
88 int default_file_preview = FALSE;
89 int default_enforce_hierarchy = TRUE;
90 int default_text_origin_marker = TRUE;
91 int default_fast_mousepan = TRUE;
92 int default_raise_dialog_boxes = FALSE;
93 int default_continue_component_place = TRUE;
94 GList *default_component_select_attrlist = NULL;
95 int default_undo_levels = 20;
96 int default_undo_control = TRUE;
97 int default_undo_type = UNDO_DISK;
98 int default_undo_panzoom = FALSE;
99 int default_draw_grips = TRUE;
100 int default_netconn_rubberband = FALSE;
101 int default_magnetic_net_mode = TRUE;
102 int default_sort_component_library = FALSE;
103 int default_warp_cursor = TRUE;
104 int default_toolbars = TRUE;
105 int default_handleboxes = TRUE;
106 int default_setpagedevice_orientation = FALSE;
107 int default_setpagedevice_pagesize = FALSE;
108 int default_bus_ripper_size = 200;
109 int default_bus_ripper_type = COMP_BUS_RIPPER;
110 int default_bus_ripper_rotation = NON_SYMMETRIC;
111 int default_force_boundingbox = FALSE;
112 int default_dots_grid_dot_size = 1;
113 int default_dots_grid_mode = DOTS_GRID_VARIABLE_MODE;
114 int default_dots_grid_fixed_threshold = 10;
115 int default_mesh_grid_display_threshold = 3;
116 int default_add_attribute_offset = 50;
117
118 int default_auto_save_interval = 120;
119
120 int default_width = 800; /* these variables are used in x_window.c */
121 int default_height = 600;
122
123 /* default zoom_factor at which text is displayed completely */
124 int default_text_display_zoomfactor = 30;
125
126 int default_text_feedback = ONLY_WHEN_READABLE;
127 int default_mousepan_gain = 5;
128 int default_keyboardpan_gain = 20;
129 int default_select_slack_pixels = 4;
130 int default_zoom_gain = 20;
131 int default_scrollpan_steps = 8;
132
133 /*! \todo Finish function documentation!!!
134 * \brief
135 * \par Function Description
136 *
137 */
i_vars_set(GSCHEM_TOPLEVEL * w_current)138 void i_vars_set(GSCHEM_TOPLEVEL *w_current)
139 {
140 TOPLEVEL *toplevel = w_current->toplevel;
141 i_vars_libgeda_set(toplevel);
142
143 /* this will be false if logging cannot be enabled */
144 if (do_logging != FALSE) {
145 do_logging = default_do_logging;
146 }
147
148 logging_dest = default_logging_dest;
149
150 w_current->text_size = default_text_size;
151 w_current->text_caps = default_text_caps;
152
153 toplevel->background_color = default_background_color;
154
155 toplevel->net_style = default_net_style;
156 w_current->net_endpoint_mode = default_net_endpoint_mode;
157 w_current->net_midpoint_mode = default_net_midpoint_mode;
158 w_current->net_direction_mode = default_net_direction_mode;
159 w_current->net_selection_mode = default_net_selection_mode;
160
161 toplevel->override_net_color = default_override_net_color;
162
163 toplevel->bus_style = default_bus_style;
164 toplevel->override_bus_color = default_override_bus_color;
165
166 toplevel->pin_style = default_pin_style;
167 toplevel->override_pin_color = default_override_pin_color;
168
169 toplevel->line_style = default_line_style;
170
171 w_current->zoom_with_pan = default_zoom_with_pan;
172 w_current->actionfeedback_mode = default_actionfeedback_mode;
173 w_current->text_display_zoomfactor = default_text_display_zoomfactor;
174 w_current->text_feedback = default_text_feedback;
175 w_current->scrollbars_flag = default_scrollbars_flag;
176
177 toplevel->object_clipping = default_object_clipping;
178 w_current->embed_complex = default_embed_complex;
179 w_current->include_complex = default_include_complex;
180 w_current->snap_size = default_snap_size;
181 w_current->log_window = default_log_window;
182 w_current->log_window_type = default_log_window_type;
183
184 INIT_STR(w_current, print_command, DEFAULT_PRINT_COMMAND);
185
186 toplevel->print_output_type = default_print_output_type;
187 toplevel->print_output_capstyle = default_print_output_capstyle;
188 toplevel->print_orientation = default_print_orientation;
189 toplevel->print_color = default_print_color;
190 toplevel->print_color_background = default_print_color_background;
191 toplevel->setpagedevice_orientation = default_setpagedevice_orientation;
192 toplevel->setpagedevice_pagesize = default_setpagedevice_pagesize;
193
194 toplevel->image_color = default_image_color;
195 w_current->image_width = default_image_width;
196 w_current->image_height = default_image_height;
197 w_current->third_button = default_third_button;
198 w_current->middle_button = default_middle_button;
199 w_current->scroll_wheel = default_scroll_wheel;
200 toplevel->net_consolidate = default_net_consolidate;
201 w_current->file_preview = default_file_preview;
202 w_current->enforce_hierarchy = default_enforce_hierarchy;
203 w_current->text_origin_marker = default_text_origin_marker;
204 w_current->fast_mousepan = default_fast_mousepan;
205 w_current->raise_dialog_boxes = default_raise_dialog_boxes;
206 w_current->continue_component_place = default_continue_component_place;
207 w_current->component_select_attrlist = default_component_select_attrlist;
208 w_current->undo_levels = default_undo_levels;
209 w_current->undo_control = default_undo_control;
210 w_current->undo_type = default_undo_type;
211 w_current->undo_panzoom = default_undo_panzoom;
212
213 w_current->draw_grips = default_draw_grips;
214 w_current->netconn_rubberband = default_netconn_rubberband;
215 w_current->magneticnet_mode = default_magnetic_net_mode;
216 w_current->sort_component_library = default_sort_component_library;
217 w_current->warp_cursor = default_warp_cursor;
218 w_current->toolbars = default_toolbars;
219 w_current->handleboxes = default_handleboxes;
220
221 toplevel->paper_width = default_paper_width;
222 toplevel->paper_height = default_paper_height;
223
224 w_current->bus_ripper_size = default_bus_ripper_size;
225 w_current->bus_ripper_type = default_bus_ripper_type;
226 w_current->bus_ripper_rotation = default_bus_ripper_rotation;
227
228 toplevel->force_boundingbox = default_force_boundingbox;
229
230 w_current->dots_grid_dot_size = default_dots_grid_dot_size;
231 w_current->dots_grid_mode = default_dots_grid_mode;
232 w_current->dots_grid_fixed_threshold = default_dots_grid_fixed_threshold;
233 w_current->mesh_grid_display_threshold = default_mesh_grid_display_threshold;
234
235 w_current->add_attribute_offset = default_add_attribute_offset;
236
237 w_current->mousepan_gain = default_mousepan_gain;
238 w_current->keyboardpan_gain = default_keyboardpan_gain;
239
240 w_current->select_slack_pixels = default_select_slack_pixels;
241 w_current->zoom_gain = default_zoom_gain;
242 w_current->scrollpan_steps = default_scrollpan_steps;
243
244 toplevel->auto_save_interval = default_auto_save_interval;
245 }
246
247
248 /*! \brief Free default names
249 * \par Function Description
250 * This function will free all of the default variables for gschem.
251 *
252 */
i_vars_freenames()253 void i_vars_freenames()
254 {
255 g_free(default_print_command);
256 }
257