2 * Grace - GRaphing, Advanced Computation and Exploration of data
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7 * Copyright (c) 1996-2002 Grace Development Team
9 * Maintained by Evgeny Stambulchik
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.
42 #include "core_utils.h"
46 extern int cursortype
;
48 #if defined WITH_XMHTML || defined WITH_LIBHELP
49 extern int force_external_viewer
;
52 static Widget props_frame
;
55 * Panel item declarations
58 static SpinStructure
*debug_item
;
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
;
77 * Event and Notify proc declarations
79 static int props_define_notify_proc(void *data
);
81 void create_props_frame(Widget but
, void *data
)
85 if (props_frame
== NULL
) {
88 props_frame
= CreateDialogForm(app_shell
, "Preferences");
90 fr
= CreateFrame(props_frame
, "Responsiveness");
91 AddDialogFormChild(props_frame
, fr
);
92 rc1
= CreateVContainer(fr
);
95 debug_item
= CreateSpinChoice(rc1
,
96 "Debug level:", 1, SPIN_TYPE_INT
, 0.0, 8.0, 1.0);
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
,
104 "Follows mouse", FOCUS_FOLLOWS
,
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");
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
));
136 void update_props_items(void)
142 GUI
*gui
= grace
->gui
;
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
));
150 SetToggleButtonState(noask_item
, gui
->noask
);
152 if (gui
->focus_policy
== FOCUS_SET
) {
154 } else if (gui
->focus_policy
== FOCUS_CLICK
) {
156 } else if (gui
->focus_policy
== FOCUS_FOLLOWS
) {
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
);
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
;
182 set_debuglevel(grace
, (int) GetSpinChoice(debug_item
));
184 gui
->noask
= GetToggleButtonState(noask_item
);
186 switch (GetOptionChoice(graph_focus_choice_item
)) {
188 gui
->focus_policy
= FOCUS_CLICK
;
191 gui
->focus_policy
= FOCUS_SET
;
194 gui
->focus_policy
= FOCUS_FOLLOWS
;
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
);
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
;