1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
/* xsiviewwin - XLISP interface to IVIEW dynamic graphics package. */
/* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney */
/* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz */
/* You may give out copies of this software; for conditions see the */
/* file COPYING included with this distribution. */
#include "xlisp.h"
#include "xlstat.h"
#define IVIEW_WINDOW_TITLE "Graph Window"
#ifdef MACINTOSH
#define IVIEW_WINDOW_LEFT 10
#define IVIEW_WINDOW_TOP 20
#define IVIEW_WINDOW_WIDTH 250
#define IVIEW_WINDOW_HEIGHT 250
#else
#ifdef _Windows
#define IVIEW_WINDOW_LEFT 0
#define IVIEW_WINDOW_TOP 0
#define IVIEW_WINDOW_WIDTH 250
#define IVIEW_WINDOW_HEIGHT 250
#define IVIEW_WINDOW_LEFT 50
#else
#define IVIEW_WINDOW_LEFT 50
#ifdef AMIGA
#define IVIEW_WINDOW_TOP 0
#else
#define IVIEW_WINDOW_TOP 50
#endif /* AMIGA */
#define IVIEW_WINDOW_WIDTH 400
#define IVIEW_WINDOW_HEIGHT 400
#endif /* _Windows */
#endif /* MACINTOSH */
/* external variables */
extern LVAL s_true;
extern LVAL sk_allocate, sk_dispose, sk_resize, sk_redraw, sk_do_idle,
sk_do_click, sk_do_motion, sk_do_key, sk_install, sk_remove, s_title,
s_go_away, s_menu, s_hardware_address, s_black_on_white, s_has_h_scroll,
s_has_v_scroll, s_internals, sk_show, sk_show_window;
extern LVAL s_in_callback;
/**************************************************************************/
/** **/
/** Window Creation Functions **/
/** **/
/**************************************************************************/
/* :ISNEW message for IVIEW-WINDOW-CLASS */
LVAL iview_window_isnew(V)
{
LVAL object = xlgaobject();
int show = xsboolkey(sk_show, TRUE);
object_isnew(object);
initialize_graph_window(object);
if (show) send_message(object, sk_allocate);
return(object);
}
/* :ALLOCATE message for IVIEW-WINDOW-CLASS */
LVAL iview_window_allocate(V)
{
LVAL object;
IVIEW_WINDOW w;
object = xlgaobject();
w = IViewWindowNew(object, TRUE);
/* use StShowWindow to show (map) window but NOT send :resize or :redraw */
if (xsboolkey(sk_show, TRUE)) StShowWindow(w);
return(object);
}
VOID StGWGetAllocInfo P7C(LVAL, object, char **, title,
int *, left, int *, top, int *, width, int *, height, int *, goAway)
{
LVAL window_title;
if (slot_value(object, s_hardware_address) != NIL)
send_message(object, sk_dispose);
window_title = slot_value(object, s_title);
if (!stringp(window_title)) {
window_title = cvstring(IVIEW_WINDOW_TITLE);
set_slot_value(object, s_title, window_title);
}
*title = (char *) getstring(window_title);
*left = IVIEW_WINDOW_LEFT;
*top = IVIEW_WINDOW_TOP;
*width = IVIEW_WINDOW_WIDTH;
*height = IVIEW_WINDOW_HEIGHT;
get_window_bounds(object, left, top, width, height);
*goAway = slot_value(object, s_go_away) != NIL;
}
VOID StGWObDoClobber P1C(LVAL, object)
{
standard_hardware_clobber(object);
}
VOID StGWObResize P1C(LVAL, object)
{
send_callback_message(object, sk_resize);
}
VOID StGWObRedraw P1C(LVAL, object)
{
send_callback_message(object, sk_redraw);
}
/* idle action. incall is used to detect longjmp's on errors and to */
/* turn off idle calling if the call is generating an error. */
VOID StGWObDoIdle P1C(LVAL, object)
{
static int incall = FALSE;
if (incall) {
StGWSetIdleOn(StGWObWinInfo(object), FALSE);
incall = FALSE;
return;
}
else {
incall = TRUE;
send_callback_message(object, sk_do_idle);
incall = FALSE;
}
}
VOID StGWObDoMouse P5C(LVAL, object, int, x, int, y, MouseEventType, type, MouseClickModifier, mods)
{
LVAL Lx, Ly, argv[6], olddenv;
int extend, option;
xlstkcheck(2);
xlsave(Lx);
xlsave(Ly);
argv[0] = object;
argv[2] = Lx = cvfixnum((FIXTYPE) x);
argv[3] = Ly = cvfixnum((FIXTYPE) y);
olddenv = xldenv;
xldbind(s_in_callback, s_true);
if (type == MouseClick) {
extend = ((int) mods) % 2;
option = ((int) mods) / 2;
argv[1] = sk_do_click;
argv[4] = (extend) ? s_true : NIL;
argv[5] = (option) ? s_true : NIL;
xscallsubrvec(xmsend, 6, argv);
}
else {
argv[1] = sk_do_motion;
xscallsubrvec(xmsend, 4, argv);
}
xlpopn(2);
xlunbind(olddenv);
}
VOID StGWObDoKey P4C(LVAL, object, int, key, int, shift, int, opt)
{
LVAL argv[5], ch, olddenv;
olddenv = xldenv;
xldbind(s_in_callback, s_true);
xlsave1(ch);
ch = cvchar(key);
argv[0] = object;
argv[1] = sk_do_key;
argv[2] = ch;
argv[3] = shift ? s_true : NIL;
argv[4] = opt ? s_true : NIL;
xscallsubrvec(xmsend, 5, argv);
xlpop();
xlunbind(olddenv);
}
StGWWinInfo *StGWObWinInfo P1C(LVAL, object)
{
LVAL internals = slot_value(object, s_internals);
if (! consp(internals) || ! adatap(car(internals))
|| getadaddr(car(internals)) == NULL)
xlfail("bad internal data");
return((StGWWinInfo *) getadaddr(car(internals)));
}
VOID initialize_graph_window P1C(LVAL, object)
{
LVAL internals, value;
int v, width, height, size;
StGWWinInfo *gwinfo;
ColorCode bc,dc; /* added JKL */
internals = newadata(StGWWinInfoSize(), 1, FALSE);
set_slot_value(object, s_internals, consa(internals));
StGWInitWinInfo(object);
gwinfo = StGWObWinInfo(object);
if (gwinfo == NULL) return;
StGWSetObject(gwinfo, object);
if (slot_value(object, s_black_on_white) == NIL) {
bc = StGWBackColor(gwinfo); /* this seems better for color */
dc = StGWDrawColor(gwinfo); /* machines - 0 and 1 are not */
StGWSetDrawColor(gwinfo, bc); /* the default draw and back */
StGWSetBackColor(gwinfo, dc); /* colors on the Amiga JKL */
}
StGetScreenSize(&width, &height);
size = (width > height) ? width : height;
if ((value = slot_value(object, s_has_h_scroll)) != NIL) {
v = (fixp(value)) ? getfixnum(value) : size;
StGWSetHasHscroll(gwinfo, TRUE, v);
}
if ((value = slot_value(object, s_has_v_scroll)) != NIL) {
v = (fixp(value)) ? getfixnum(value) : size;
StGWSetHasVscroll(gwinfo, TRUE, v);
}
}
LVAL xsiview_window_update(V)
{
#ifdef MACINTOSH
LVAL object;
int resized;
object = xlgaobject();
resized = (xlgetarg() != NIL);
xllastarg();
graph_update_action(StGWObWinInfo(object), resized);
#endif /* MACINTOSH */
return(NIL);
}
LVAL xsiview_window_activate(V)
{
#ifdef MACINTOSH
LVAL object, menu;
int active;
object = xlgaobject();
active = (xlgetarg() != NIL);
xllastarg();
graph_activate_action(StGWObWinInfo(object), active);
menu = slot_value(object, s_menu);
if (menu_p(menu)) {
if (active) send_message(menu, sk_install);
else send_message(menu, sk_remove);
}
#endif /* MACINTOSH */
return(NIL);
}
/**************************************************************************/
/** **/
/** Idle Installation Functions **/
/** **/
/**************************************************************************/
LVAL iview_window_idle_on(V)
{
StGWWinInfo *gwinfo;
int on = 0, set = FALSE;
gwinfo = StGWObWinInfo(xlgaobject());
if (gwinfo == NULL) return(NIL);
if (moreargs()) {
set = TRUE;
on = (xlgetarg() != NIL) ? TRUE : FALSE;
}
xllastarg();
if (set) StGWSetIdleOn(gwinfo, on);
return((StGWIdleOn(gwinfo)) ? s_true : NIL);
}
/**************************************************************************/
/** **/
/** Menu Installation and Access Functions **/
/** **/
/**************************************************************************/
LVAL iview_window_menu(V)
{
LVAL object, menu = NULL;
int set = FALSE;
object = xlgaobject();
if (moreargs()) {
set = TRUE;
menu = xlgetarg();
}
xllastarg();
if (set) {
if (menu_p(menu)) set_slot_value(object, s_menu, menu);
else if (menu == NIL) set_slot_value(object, s_menu, NIL);
else xlerror("not a menu", menu);
}
return(slot_value(object, s_menu));
}
|