Some menu shuffling.
[grace.git] / src / miscwin.c
blobe9060ecd4893607c7d9c4f1746e7a287d1f8e520
1 /*
2 * Grace - GRaphing, Advanced Computation and Exploration of data
3 *
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
5 *
6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7 * Copyright (c) 1996-2002 Grace Development Team
8 *
9 * Maintained by Evgeny Stambulchik
12 * All Rights Reserved
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * Misc properties
35 #include <config.h>
37 #include <stdio.h>
38 #include <stdlib.h>
40 #include "globals.h"
41 #include "utils.h"
42 #include "core_utils.h"
43 #include "motifinc.h"
44 #include "protos.h"
46 extern int cursortype;
48 #if defined WITH_XMHTML || defined WITH_LIBHELP
49 extern int force_external_viewer;
50 #endif
52 static Widget props_frame;
55 * Panel item declarations
57 #ifdef DEBUG
58 static SpinStructure *debug_item;
59 #endif
60 static Widget noask_item;
62 static OptionStructure *graph_focus_choice_item;
63 static Widget graph_drawfocus_choice_item;
65 static Widget autoredraw_type_item;
66 static Widget cursor_type_item;
67 static SpinStructure *max_path_item;
68 static Widget safe_mode_item;
69 static Widget scrollper_item;
70 static Widget shexper_item;
72 #if defined WITH_XMHTML || defined WITH_LIBHELP
73 static Widget force_external_viewer_item;
74 #endif
77 * Event and Notify proc declarations
79 static int props_define_notify_proc(void *data);
81 void create_props_frame(Widget but, void *data)
83 set_wait_cursor();
85 if (props_frame == NULL) {
86 Widget fr, rc1;
88 props_frame = CreateDialogForm(app_shell, "Preferences");
90 fr = CreateFrame(props_frame, "Responsiveness");
91 AddDialogFormChild(props_frame, fr);
92 rc1 = CreateVContainer(fr);
94 #ifdef DEBUG
95 debug_item = CreateSpinChoice(rc1,
96 "Debug level:", 1, SPIN_TYPE_INT, 0.0, 8.0, 1.0);
97 #endif
98 noask_item = CreateToggleButton(rc1, "Don't ask questions");
100 graph_focus_choice_item = CreateOptionChoiceVA(rc1,
101 "Graph focus switch",
102 "Button press", FOCUS_CLICK,
103 "As set", FOCUS_SET,
104 "Follows mouse", FOCUS_FOLLOWS,
105 NULL);
107 graph_drawfocus_choice_item =
108 CreateToggleButton(rc1, "Display focus markers");
109 autoredraw_type_item = CreateToggleButton(rc1, "Auto redraw");
110 cursor_type_item = CreateToggleButton(rc1, "Crosshair cursor");
111 #if defined WITH_XMHTML || defined WITH_LIBHELP
112 force_external_viewer_item = CreateToggleButton(rc1,
113 "Use external help viewer for local documents");
114 #endif
115 fr = CreateFrame(props_frame, "Restrictions");
116 AddDialogFormChild(props_frame, fr);
117 rc1 = CreateVContainer(fr);
118 max_path_item = CreateSpinChoice(rc1,
119 "Max drawing path length:", 6, SPIN_TYPE_INT, 0.0, 1.0e6, 1000);
120 safe_mode_item = CreateToggleButton(rc1, "Run in safe mode");
122 fr = CreateFrame(props_frame, "Scroll/zoom");
123 rc1 = CreateVContainer(fr);
124 scrollper_item = CreateScale(rc1, "Scroll %", 0, 200, 20);
125 shexper_item = CreateScale(rc1, "Zoom %", 0, 200, 20);
127 CreateAACDialog(props_frame, fr, props_define_notify_proc, NULL);
130 update_props_items();
132 RaiseWindow(GetParent(props_frame));
133 unset_wait_cursor();
136 void update_props_items(void)
138 int itest = 0;
139 int iv;
141 if (props_frame) {
142 GUI *gui = grace->gui;
143 #ifdef DEBUG
144 if (get_debuglevel(grace) > 8) {
145 errwin("Debug level > 8, resetting to 0");
146 set_debuglevel(grace, 0);
148 SetSpinChoice(debug_item, (double) get_debuglevel(grace));
149 #endif
150 SetToggleButtonState(noask_item, gui->noask);
152 if (gui->focus_policy == FOCUS_SET) {
153 itest = 1;
154 } else if (gui->focus_policy == FOCUS_CLICK) {
155 itest = 0;
156 } else if (gui->focus_policy == FOCUS_FOLLOWS) {
157 itest = 2;
159 SetOptionChoice(graph_focus_choice_item, itest);
160 SetToggleButtonState(graph_drawfocus_choice_item, gui->draw_focus_flag);
162 SetToggleButtonState(autoredraw_type_item, gui->auto_redraw);
163 SetToggleButtonState(cursor_type_item, cursortype);
164 #if defined WITH_XMHTML || defined WITH_LIBHELP
165 SetToggleButtonState(force_external_viewer_item, force_external_viewer);
166 #endif
167 SetSpinChoice(max_path_item,
168 (double) get_max_path_limit(grace->rt->canvas));
169 SetToggleButtonState(safe_mode_item, grace->rt->safe_mode);
170 iv = (int) rint(100*grace->rt->scrollper);
171 SetScaleValue(scrollper_item, iv);
172 iv = (int) rint(100*grace->rt->shexper);
173 SetScaleValue(shexper_item, iv);
177 static int props_define_notify_proc(void *data)
179 GUI *gui = grace->gui;
181 #ifdef DEBUG
182 set_debuglevel(grace, (int) GetSpinChoice(debug_item));
183 #endif
184 gui->noask = GetToggleButtonState(noask_item);
186 switch (GetOptionChoice(graph_focus_choice_item)) {
187 case 0:
188 gui->focus_policy = FOCUS_CLICK;
189 break;
190 case 1:
191 gui->focus_policy = FOCUS_SET;
192 break;
193 case 2:
194 gui->focus_policy = FOCUS_FOLLOWS;
195 break;
197 gui->draw_focus_flag = GetToggleButtonState(graph_drawfocus_choice_item);
199 gui->auto_redraw = GetToggleButtonState(autoredraw_type_item);
200 cursortype = GetToggleButtonState(cursor_type_item);
201 #if defined WITH_XMHTML || defined WITH_LIBHELP
202 force_external_viewer = GetToggleButtonState(force_external_viewer_item);
203 #endif
204 set_max_path_limit(grace->rt->canvas, (int) GetSpinChoice(max_path_item));
205 grace->rt->safe_mode = GetToggleButtonState(safe_mode_item);
206 grace->rt->scrollper = (double) GetScaleValue(scrollper_item)/100.0;
207 grace->rt->shexper = (double) GetScaleValue(shexper_item)/100.0;
209 xdrawgraph(grace->project, FALSE);
211 return RETURN_SUCCESS;