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 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
;
67 * Event and Notify proc declarations
69 static int props_define_notify_proc(void *data
);
71 void create_props_frame(Widget but
, void *data
)
75 if (props_frame
== NULL
) {
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
,
88 "Button press", FOCUS_CLICK
,
90 "Follows mouse", FOCUS_FOLLOWS
,
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");
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
);
121 void update_props_items(void)
127 GUI
*gui
= gapp
->gui
;
128 ToggleButtonSetState(noask_item
, gui
->noask
);
130 if (gui
->focus_policy
== FOCUS_SET
) {
132 } else if (gui
->focus_policy
== FOCUS_CLICK
) {
134 } else if (gui
->focus_policy
== FOCUS_FOLLOWS
) {
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
);
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
)) {
162 gui
->focus_policy
= FOCUS_CLICK
;
165 gui
->focus_policy
= FOCUS_SET
;
168 gui
->focus_policy
= FOCUS_FOLLOWS
;
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
);
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
;