Renamed functions
[grace.git] / src / miscwin.c
blob5e3c720ae8329fa2d8feaaee02b48cbb8b3cdfa8
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 "xprotos.h"
46 static Widget props_frame;
49 * Panel item declarations
51 static Widget noask_item;
53 static OptionStructure *graph_focus_choice_item;
54 static Widget graph_drawfocus_choice_item;
56 static Widget cursor_type_item;
57 static SpinStructure *max_path_item;
58 static Widget safe_mode_item;
59 static Widget scrollper_item;
60 static Widget shexper_item;
62 #if defined WITH_XMHTML
63 static Widget force_external_viewer_item;
64 #endif
67 * Event and Notify proc declarations
69 static int props_define_notify_proc(void *data);
71 void create_props_frame(Widget but, void *data)
73 set_wait_cursor();
75 if (props_frame == NULL) {
76 Widget fr, rc1;
78 props_frame = CreateDialog(app_shell, "Preferences");
80 fr = CreateFrame(props_frame, "Responsiveness");
81 FormAddVChild(props_frame, fr);
82 rc1 = CreateVContainer(fr);
84 noask_item = CreateToggleButton(rc1, "Don't ask questions");
86 graph_focus_choice_item = CreateOptionChoiceVA(rc1,
87 "Graph focus switch",
88 "Button press", FOCUS_CLICK,
89 "As set", FOCUS_SET,
90 "Follows mouse", FOCUS_FOLLOWS,
91 NULL);
93 graph_drawfocus_choice_item =
94 CreateToggleButton(rc1, "Display focus markers");
95 cursor_type_item = CreateToggleButton(rc1, "Crosshair cursor");
96 #if defined WITH_XMHTML
97 force_external_viewer_item = CreateToggleButton(rc1,
98 "Use external help viewer for local documents");
99 #endif
100 fr = CreateFrame(props_frame, "Restrictions");
101 FormAddVChild(props_frame, fr);
102 rc1 = CreateVContainer(fr);
103 max_path_item = CreateSpinChoice(rc1,
104 "Max drawing path length:", 6, SPIN_TYPE_INT, 0.0, 1.0e6, 1000);
105 safe_mode_item = CreateToggleButton(rc1, "Run in safe mode");
107 fr = CreateFrame(props_frame, "Scroll/zoom");
108 rc1 = CreateVContainer(fr);
109 scrollper_item = CreateScale(rc1, "Scroll %", 0, 200, 20);
110 shexper_item = CreateScale(rc1, "Zoom %", 0, 200, 20);
112 CreateAACDialog(props_frame, fr, props_define_notify_proc, NULL);
115 update_props_items();
117 DialogRaise(props_frame);
118 unset_wait_cursor();
121 void update_props_items(void)
123 int itest = 0;
124 int iv;
126 if (props_frame) {
127 GUI *gui = gapp->gui;
128 ToggleButtonSetState(noask_item, gui->noask);
130 if (gui->focus_policy == FOCUS_SET) {
131 itest = 1;
132 } else if (gui->focus_policy == FOCUS_CLICK) {
133 itest = 0;
134 } else if (gui->focus_policy == FOCUS_FOLLOWS) {
135 itest = 2;
137 SetOptionChoice(graph_focus_choice_item, itest);
138 ToggleButtonSetState(graph_drawfocus_choice_item, gui->draw_focus_flag);
140 ToggleButtonSetState(cursor_type_item, gui->crosshair_cursor);
141 #if defined WITH_XMHTML
142 ToggleButtonSetState(force_external_viewer_item, gui->force_external_viewer);
143 #endif
144 SpinChoiceSetValue(max_path_item,
145 (double) get_max_path_limit(grace_get_canvas(gapp->grace)));
146 ToggleButtonSetState(safe_mode_item, gapp->rt->safe_mode);
147 iv = (int) rint(100*gapp->rt->scrollper);
148 ScaleSetValue(scrollper_item, iv);
149 iv = (int) rint(100*gapp->rt->shexper);
150 ScaleSetValue(shexper_item, iv);
154 static int props_define_notify_proc(void *data)
156 GUI *gui = gapp->gui;
158 gui->noask = ToggleButtonGetState(noask_item);
160 switch (GetOptionChoice(graph_focus_choice_item)) {
161 case 0:
162 gui->focus_policy = FOCUS_CLICK;
163 break;
164 case 1:
165 gui->focus_policy = FOCUS_SET;
166 break;
167 case 2:
168 gui->focus_policy = FOCUS_FOLLOWS;
169 break;
171 gui->draw_focus_flag = ToggleButtonGetState(graph_drawfocus_choice_item);
173 gui->crosshair_cursor = ToggleButtonGetState(cursor_type_item);
174 #if defined WITH_XMHTML
175 gui->force_external_viewer = ToggleButtonGetState(force_external_viewer_item);
176 #endif
177 set_max_path_limit(grace_get_canvas(gapp->grace), (int) SpinChoiceGetValue(max_path_item));
178 gapp->rt->safe_mode = ToggleButtonGetState(safe_mode_item);
179 gapp->rt->scrollper = (double) ScaleGetValue(scrollper_item)/100.0;
180 gapp->rt->shexper = (double) ScaleGetValue(shexper_item)/100.0;
182 xdrawgraph(gapp->gp);
184 return RETURN_SUCCESS;