-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathAIREGIONS
725 lines (592 loc) · 36.8 KB
/
AIREGIONS
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
(DEFINE-FILE-INFO READTABLE "INTERLISP" PACKAGE "INTERLISP")
(FILECREATED "11-Dec-87 13:48:32" {ERINYES}<LISPUSERS>LYRIC>AIREGIONS.;1 37025
changes to%: (VARS AIREGIONSCOMS)
previous date%: " 9-Mar-87 16:37:52" {DANTE}<LISPUSERS>LYRIC>AIREGIONS.;1)
(* "
Copyright (c) 1985, 1986, 1987 by XEROX Corporation. All rights reserved.
")
(PRETTYCOMPRINT AIREGIONSCOMS)
(RPAQQ AIREGIONSCOMS [(FILES FILLREGION)
(FNS ADD.IREGION ALL.IREGIONS CREATEIR REMOVE.IREGION DOSELECTED.IREGION
EDIT.MASK IREGIONP IREGIONPROP SHOW.ALL.IREGIONS INTERSECTING.IREGIONS?
INVERT.IREGION WHICH.IREGIONS SURROUNDIR)
(FNS IN.CURSOR.REGION \IR.CLIP.REGION \IR.SHOW.REGION \VALID.POSITION.LIST
\SAME.IREGIONS.LIST \WITH.INTERSECTION \IREGION.ON.WINDOWP)
(RECORDS IREGION)
(PROP ARGNAMES IREGIONPROP)
(VARS (DEFAULT.IREGION.SHADE 65535))
(GLOBALVARS DEFAULT.IREGION.SHADE)
(DECLARE%: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS
(ADDVARS (NLAMA)
(NLAML)
(LAMA IREGIONPROP])
(FILESLOAD FILLREGION)
(DEFINEQ
(ADD.IREGION
[LAMBDA (WINDOW IREGION) (* GWexler " 7-Feb-86 10:22")
(if (AND (NOT (\IREGION.ON.WINDOWP IREGION WINDOW))
(IREGIONP IREGION)
(WINDOWP WINDOW))
then (WINDOWPROP WINDOW 'BUTTONEVENTFN 'IN.CURSOR.REGION)
(WINDOWADDPROP WINDOW 'IREGIONSLIST IREGION T)
IREGION])
(ALL.IREGIONS
[LAMBDA (WINDOW) (* GWexler " 7-Feb-86 10:23")
(* * This function returns all the IREGIONs of WINDOW.)
(if (WINDOWP WINDOW)
then (WINDOWPROP WINDOW 'IREGIONSLIST)
else NIL])
(CREATEIR
[LAMBDA (WINDOW SHADE BUTTONEVENTFN HELPSTRING REGION POSLIST)
(* GWexler " 7-Feb-86 10:30")
(* * This function is the top-level interface to creating IREGIONS and
associating them with a given window.)
(PROG (TEMP-REGION TEMP-BITMAP POS MASK POSITIONS)
(* If WINDOW is not a window, then return.
If the user wants just an IREGION record, he/she should use
(create IREGION BUTTONEVENTFN _ ??? USERDATA _ ??? REGION _ ??? MASK _ ???
SHADE _ ??? HELPSTRING _ ???))
(OR (WINDOWP WINDOW)
(RETURN NIL))
(WINDOWPROP WINDOW 'BUTTONEVENTFN 'IN.CURSOR.REGION)
(SETQ TEMP-REGION (if (REGIONP REGION)
then
(* Here, the user passes us a REGION relative to WINDOW and we translate it to
screen coordinates. (We need this in screen coordinates since that is what
GETREGION returns.))
(LIST [IPLUS (CAR REGION)
(CAR (WINDOWPROP WINDOW 'REGION]
[IPLUS (CADR REGION)
(CADR (WINDOWPROP WINDOW 'REGION]
(CADDR REGION)
(CADDDR REGION))
else
(* If REGION was not a region, then we prompt the user for one.)
(PROMPTPRINT "Please closely surround the irregular region "
"without cutting off the region's borders")
(TOTOPW WINDOW)
(GETREGION)))
(* Here, we clip TEMP-REGION so that it fits inside the window so that we don't
waste any space with too large bitmaps. If the region did not fall inside the
window at all, then \IR.CLIP.REGION returns NIL and we return from CREATEIR.)
(SETQ TEMP-REGION (OR (\IR.CLIP.REGION TEMP-REGION WINDOW)
(RETURN NIL)))
(* We create two bitmaps the size of TEMP-REGION that will contain the mask for
the IREGION. We need one extra just for temporary storage in CREATEIR.)
(SETQ TEMP-BITMAP (BITMAPCREATE (CADDR TEMP-REGION)
(CADDDR TEMP-REGION)
1)) (* We save the window image in
TEMP-REGION in TEMP-BITMAP.)
(TOTOPW WINDOW)
(BITBLT WINDOW (CAR TEMP-REGION)
(CADR TEMP-REGION)
TEMP-BITMAP 0 0) (* MASK is just a copy of TEMP-BITMAP)
(SETQ MASK (BITMAPCOPY TEMP-BITMAP))
(* The user can pass either NIL or a list of positions to fill from in the
argument POSLIST. \VALID.POSITION.LIST returns either NIL %, ERROR, or a list
of positions. ERROR means to abort the call to CREATEIR since POSLIST was not
in any valid form.)
(SETQ POSITIONS (\VALID.POSITION.LIST POSLIST))
(OR (NOT (EQ 'ERROR POSITIONS))
(RETURN NIL))
(* If the user did not specify POSLIST %, then we box out TEMP-REGION to let
him/her know where they are working.)
(OR POSITIONS (\IR.SHOW.REGION WINDOW TEMP-REGION))
[if (NOT POSITIONS)
then
(* This part prompts for positions to area fill from until the user buttons
outside of TEMP-REGION.)
(PROMPTPRINT "Point your mouse to the inside of the region and "
"left-button the irregular shapes in that region. "
"To stop selection(s), left-button anywhere away "
"from the squared-off region.")
(TOTOPW WINDOW)
(until (NOT (INSIDEP TEMP-REGION (CAR (SETQ POS (GETPOSITION WINDOW)))
(CDR POS))) do (FILL.REGION MASK (CONS (IDIFFERENCE
(CAR POS)
(CAR TEMP-REGION))
(IDIFFERENCE
(CDR POS)
(CADR TEMP-REGION)))
65535)
(* Show in WINDOW, what was just
filled.)
(BITBLT MASK 0 0 WINDOW (CAR TEMP-REGION)
(CADR TEMP-REGION))
(TOTOPW WINDOW))
else
(* Here, the user has given us a list of positions, and we just go through each
one and fill.)
(for P in POSITIONS do (if (INSIDEP TEMP-REGION P)
then (FILL.REGION MASK (CONS (IDIFFERENCE (CAR P)
(CAR TEMP-REGION))
(IDIFFERENCE (CDR P)
(CADR TEMP-REGION)))
65535]
(PROMPTPRINT) (* Unbox the region if need be.)
(OR POSITIONS (\IR.SHOW.REGION WINDOW TEMP-REGION))
(* Set up MASK to have only black where the area fill filled.)
(BITBLT TEMP-BITMAP 0 0 MASK 0 0 NIL NIL 'INPUT 'ERASE)
(* Restore the window to its original
image.)
(BITBLT TEMP-BITMAP 0 0 WINDOW (CAR TEMP-REGION)
(CADR TEMP-REGION)) (* Add the appropriate IREGION to the
windows IREGIONSLIST...)
(RETURN (ADD.IREGION WINDOW
(create IREGION
BUTTONEVENTFN _ BUTTONEVENTFN
USERDATA _ NIL
REGION _ TEMP-REGION
MASK _ MASK
SHADE _ (if (NOT (OR (NUMBERP SHADE)
(BITMAPP SHADE)))
then DEFAULT.IREGION.SHADE
else SHADE)
HELPSTRING _ HELPSTRING])
(REMOVE.IREGION
[LAMBDA (WINDOW IREGION) (* GWexler " 7-Feb-86 10:24")
(* Given a window and an IREGION, remove it from that windows IREGIONSLIST)
(if (\IREGION.ON.WINDOWP IREGION WINDOW)
then (WINDOWDELPROP WINDOW 'IREGIONSLIST IREGION)
IREGION])
(DOSELECTED.IREGION
[LAMBDA (WINDOW IREGION BUTTON) (* GWexler " 7-Feb-86 10:24")
(if (AND (\IREGION.ON.WINDOWP IREGION WINDOW)
(IREGIONPROP IREGION 'BUTTONEVENTFN))
then (APPLY* (IREGIONPROP IREGION 'BUTTONEVENTFN)
WINDOW IREGION BUTTON])
(EDIT.MASK
[LAMBDA (IREGION) (* GWexler " 7-Feb-86 10:24")
(* A way of simply editing the MASK of an IREGION)
(if (IREGIONP IREGION)
then (EDITBM (fetch (IREGION MASK) of IREGION])
(IREGIONP
[LAMBDA (IREGION) (* GWexler " 7-Feb-86 10:24")
(* Tests to see if IREGION is a valid IREGION.
Returns IREGION if true NIL otherwise.)
(if (type? IREGION IREGION)
then IREGION
else NIL])
(IREGIONPROP
[LAMBDA X (* GWexler " 7-Feb-86 10:24")
(* Modeled after WINDOWPROP. This is a convenient way of associating
information with an IREGION. If the property of the IREGION is not one of the
fields, then it is stored on the USERDATA field in property list format.)
(PROG (IREGION PROP NEWVALUE)
(SETQ IREGION (ARG X 1))
(SETQ PROP (ARG X 2)) (* Abort if we do not have an IREGION.)
(OR (IREGIONP IREGION)
(RETURN NIL))
(if (EQ X 3)
then
(* In this case, we have a value to set, so do replaces or LISTPUTs.)
(SETQ NEWVALUE (ARG X 3))
[if [NOT (MEMB PROP (RECORDFIELDNAMES 'IREGION]
then
(* In this case, we store the property on the USERDATA field.)
(if (NOT (fetch (IREGION USERDATA) of IREGION))
then
(* If USERDATA is NIL, we need to set it to
(PROPNAME VALUE))
(replace (IREGION USERDATA) of IREGION with (LIST PROP NEWVALUE)
)
else
(* USERDATA should already be in proplist format so just do a LISTPUT)
(LISTPUT (fetch (IREGION USERDATA) of IREGION)
PROP NEWVALUE))
[if (NOT NEWVALUE)
then (replace (IREGION USERDATA) of IREGION
with (for X on (fetch (IREGION USERDATA) of IREGION)
by (CDDR X) when (NOT (EQ (CAR X)
PROP))
join (LIST (CAR X)
(CADR X]
(RETURN NEWVALUE)
else
(* Here, PROP is one of the IREGIONS fields, so we just replace it.)
(RETURN (SELECTQ PROP
(BUTTONEVENTFN (replace (IREGION BUTTONEVENTFN) of IREGION
with NEWVALUE))
(USERDATA (replace (IREGION USERDATA) of IREGION with NEWVALUE))
(REGION (replace (IREGION REGION) of IREGION with NEWVALUE))
(MASK (replace (IREGION MASK) of IREGION with NEWVALUE))
(SHADE (replace (IREGION SHADE) of IREGION with NEWVALUE))
(HELPSTRING (replace (IREGION HELPSTRING) of IREGION
with NEWVALUE))
(ERROR "Not a valid IREGION prop: " PROP]
else
(* No NEWVALUE was specified so we just want to fetch the right info.)
(if [NOT (MEMB PROP (RECORDFIELDNAMES 'IREGION]
then
(* PROP is not one of IREGIONs fields, so we need to get it off of USERDATA)
(RETURN (LISTGET (fetch (IREGION USERDATA) of IREGION)
PROP))
else (* Simply fetch the right field of
IREGION.)
(RETURN (SELECTQ PROP
(BUTTONEVENTFN (fetch (IREGION BUTTONEVENTFN) of IREGION))
(USERDATA (fetch (IREGION USERDATA) of IREGION))
(REGION (fetch (IREGION REGION) of IREGION))
(MASK (fetch (IREGION MASK) of IREGION))
(SHADE (fetch (IREGION SHADE) of IREGION))
(HELPSTRING (fetch (IREGION HELPSTRING) of IREGION))
(ERROR "Not a valid IREGION prop: " PROP])
(SHOW.ALL.IREGIONS
[LAMBDA (WINDOW SHADE DELAY) (* GWexler " 7-Feb-86 10:24")
(* This function cycles through each IREGION on WINDOW and flashes it in black
and waits DELAY milliseconds. There is code here to do the right thing when the
user aborts.)
(LET ((IRS (ALL.IREGIONS WINDOW)))
(for X in IRS do (RESETLST [RESETSAVE NIL (LIST 'IREGIONPROP X 'SHADE (IREGIONPROP
X
'SHADE]
(IREGIONPROP X 'SHADE (OR SHADE 65535))
(INVERT.IREGION WINDOW X)
(RESETSAVE NIL (LIST 'INVERT.IREGION WINDOW X))
(BLOCK (OR (NUMBERP DELAY)
500])
(INTERSECTING.IREGIONS?
[LAMBDA (WINDOW FLG) (* GWexler " 7-Feb-86 10:24")
(* This sets up WINDOW to specify whether or not its overlapping active regions
all get called when buttoned in the overlapping area %.
NIL means no overlapping and T means yes.)
(WINDOWPROP WINDOW 'IR.INTERSECTIONFLG FLG])
(INVERT.IREGION
[LAMBDA (WINDOW IREGION) (* GWexler " 7-Feb-86 10:25")
(* Simply inverts IREGION associated with WINDOW %.
Doesn't do anything if IREGION is not on the window's IREGIONLIST.)
(if (\IREGION.ON.WINDOWP IREGION WINDOW)
then (TOTOPW WINDOW)
(BITBLT (fetch (IREGION MASK) of IREGION)
0 0 WINDOW (CAR (fetch (IREGION REGION) of IREGION))
(CADR (fetch (IREGION REGION) of IREGION))
NIL NIL 'MERGE 'INVERT (fetch (IREGION SHADE) of IREGION])
(WHICH.IREGIONS
[LAMBDA (WINDOW POSORX Y) (* GWexler " 7-Feb-86 10:25")
(* Returns all the IREGIONS of WINDOW in a list.
NIL if there were none.)
(* * IF CURSOR IN REGION'S WINDOW AND REGION'S MASK, IDENTIFY REGION)
(* * X AND Y are optional arguments. Same with WINDOW.
The user could just say (WHICHIR) and it would notice where it is, or
Programmatically, the user could pass a window and an X and Y to get which
Iregion.)
(LET* [(W (OR (WINDOWP WINDOW)
(WHICHW)))
(POSITION (if (POSITIONP POSORX)
then POSORX
else (if (OR (NOT (NUMBERP POSORX))
(NOT (NUMBERP Y)))
then (CONS (LASTMOUSEX W)
(LASTMOUSEY W))
else (CONS POSORX Y]
(for SOME-IREGION in (WINDOWPROP W 'IREGIONSLIST)
when [NOT (ZEROP (BITMAPBIT (fetch (IREGION MASK) of SOME-IREGION)
(IDIFFERENCE (CAR POSITION)
(CAR (fetch (IREGION REGION) of SOME-IREGION)))
(IDIFFERENCE (CDR POSITION)
(CADR (fetch (IREGION REGION) of SOME-IREGION]
collect SOME-IREGION])
(SURROUNDIR
[LAMBDA (WINDOW SHADE BUTTONEVENTFN HELPSTRING POSLIST INSIDE.POS)
(* GWexler " 7-Feb-86 10:46")
(* * This function is the top-level interface to creating IREGIONS inwhich the
innereds specified are ignored and the entire surround regions becomes the
AIREGION which is associated with the given window)
(PROG (TEMPW TEMP-REGION TEMP-BITMAP POS MASK POSITIONS POINTS.LST TEMPPOS)
(* If WINDOW is not a window, then return.
If the user wants just an IREGION record, he/she should use
(create IREGION BUTTONEVENTFN _ ??? USERDATA _ ??? REGION _ ??? MASK _ ???
SHADE _ ??? HELPSTRING _ ???))
(OR (WINDOWP WINDOW)
(RETURN NIL))
(WINDOWPROP WINDOW 'BUTTONEVENTFN 'IN.CURSOR.REGION)
(PROMPTPRINT "Please button the area around the particular region. To end, hold the SHIFT key when hitting the last point with the mouse."
)
(FLASHWINDOW PROMPTWINDOW 2)
(TOTOPW WINDOW)
[OR (LISTP POSLIST)
(while [AND (NOT (KEYDOWNP 'LSHIFT))
(NOT (KEYDOWNP 'RSHIFT] do [SETQ POSLIST (APPEND POSLIST
(LIST (SETQ TEMPPOS
(GETPOSITION WINDOW]
(BITBLT (CAR CROSSHAIRS)
0 0 WINDOW (DIFFERENCE (CAR TEMPPOS)
(CADR CROSSHAIRS))
(DIFFERENCE (CDR TEMPPOS)
(CDDR CROSSHAIRS))
NIL NIL 'INPUT 'INVERT]
[OR [NLSETQ (SETQ TEMP-REGION
(WINDOWPROP (SETQ TEMPW (CREATEW
(LIST 0 0 (PLUS (APPLY 'MAX
(for I in POSLIST
collect (CAR I)))
50)
(PLUS (APPLY 'MAX (for I in POSLIST
collect (CDR I)))
50))
NIL NIL T))
'REGION]
(SETQ TEMP-REGION (WINDOWPROP (SETQ TEMPW (CREATEW '(0 0 10 10) NIL NIL T))
'REGION]
(PROMPTPRINT "Please button once INSIDE the region")
(FLASHWINDOW PROMPTWINDOW 2)
[OR (POSITIONP INSIDE.POS)
(AND (SETQ INSIDE.POS (GETPOSITION WINDOW))
(for POSITION in POSLIST do (BITBLT (CAR CROSSHAIRS)
0 0 WINDOW (DIFFERENCE (CAR POSITION)
(CADR CROSSHAIRS))
(DIFFERENCE (CDR POSITION)
(CDDR CROSSHAIRS))
NIL NIL 'INPUT 'INVERT]
(* * MAYBE TEMPORARILY XOR IT ON...)
(DRAWCURVE POSLIST T 1 NIL TEMPW)
(* * Note that having the window open when drawing the curve is kludgy.
In the KOTO release, DIG will be implemented in the system so rather than
having the TEMPW, use an IMAGESTREAM via OPENIMAGESTREAM and do a IMDRAWCURVE
and IMBITBLT. In this mannor, all drawing is hidden from the user and it makes
the package a lot cleaner.)
(SETQ TEMP-BITMAP (BITMAPCREATE (CADDR TEMP-REGION)
(CADDDR TEMP-REGION)
1)) (* We save the window image in
TEMP-REGION in TEMP-BITMAP.)
(TOTOPW TEMPW)
(BITBLT TEMPW (CAR TEMP-REGION)
(CADR TEMP-REGION)
TEMP-BITMAP 0 0)
(CLOSEW TEMPW) (* MASK is just a copy of TEMP-BITMAP)
(SETQ MASK (BITMAPCOPY TEMP-BITMAP))
(* The user can pass either NIL or a list of positions to fill from in the
argument POSLIST. \VALID.POSITION.LIST returns either NIL %, ERROR, or a list
of positions. ERROR means to abort the call to CREATEIR since POSLIST was not
in any valid form.)
(FILL.REGION MASK (CONS (IDIFFERENCE (CAR INSIDE.POS)
(CAR TEMP-REGION))
(IDIFFERENCE (CDR INSIDE.POS)
(CADR TEMP-REGION)))
65535) (* (BITBLT MASK 0 0 WINDOW
(CAR TEMP-REGION) (CADR TEMP-REGION)))
(* * Removing the border)
(BITBLT TEMP-BITMAP 0 0 MASK 0 0 NIL NIL 'INPUT 'ERASE)
(* (BITBLT TEMP-BITMAP 0 0 WINDOW
(CAR TEMP-REGION) (CADR TEMP-REGION)))
(RETURN (ADD.IREGION WINDOW
(create IREGION
BUTTONEVENTFN _ BUTTONEVENTFN
USERDATA _ NIL
REGION _ TEMP-REGION
MASK _ MASK
SHADE _ (if (NOT (OR (NUMBERP SHADE)
(BITMAPP SHADE)))
then DEFAULT.IREGION.SHADE
else SHADE)
HELPSTRING _ HELPSTRING])
)
(DEFINEQ
(IN.CURSOR.REGION
[LAMBDA (WINDOW) (* GWexler " 7-Feb-86 10:27")
(* This is WINDOWs BUTTONEVENTFN that gets called for windows with IREGIONS.)
(* * IF CURSOR IN REGION'S WINDOW AND REGION'S MASK, SHADE REGION)
(PROG [OLD-REGIONS TEMPX TEMPY BUTTON ALLREADY.PROMPT (TIMEOUT.WAIT 1500)
(TIMEOUT (SETUPTIMER 1500 NIL 'TICKS 'MILLISECONDS))
(INTERSECTIONFLG (WINDOWPROP WINDOW 'IR.INTERSECTIONFLG]
(TOTOPW WINDOW)
(* OLD-REGIONS starts out to be all the IREGIONS currently pointed to.
\WITH.INTERSECTION is used to determine whether this is a list of all the
IREGIONS or just one.)
(SETQ OLD-REGIONS (\WITH.INTERSECTION (WHICH.IREGIONS WINDOW)
INTERSECTIONFLG))
(SETQ TEMPX (LASTMOUSEX WINDOW))
(SETQ TEMPY (LASTMOUSEY WINDOW))
(* Start out and invert all the IREGIONS being pointed to.)
(for IR in OLD-REGIONS do (INVERT.IREGION WINDOW IR))
(* BUTTON is set so that the user can use this value.)
(SETQ BUTTON (SELECTQ LASTMOUSEBUTTONS
(4 'LEFT)
(2 'RIGHT)
(1 'MIDDLE)
(NULL))) (* Now we loop until the mouse comes
back up.)
[while (NOT (MOUSESTATE UP))
do (PROG NIL
(if (OR (if (EQ TEMPX (SETQ TEMPX (LASTMOUSEX WINDOW)))
then (EQ TEMPY (SETQ TEMPY (LASTMOUSEY WINDOW)))
else (SETQ TEMPY (LASTMOUSEY WINDOW))
NIL)
(\SAME.IREGIONS.LIST OLD-REGIONS (\WITH.INTERSECTION
(WHICH.IREGIONS WINDOW
(CONS TEMPX TEMPY))
INTERSECTIONFLG)))
then (COND
((AND (NOT ALLREADY.PROMPT)
(TIMEREXPIRED? TIMEOUT 'TICKS)
(NOT (NULL OLD-REGIONS)))
(PROMPTPRINT)
(for IR in OLD-REGIONS
do (printout PROMPTWINDOW (OR (fetch (IREGION HELPSTRING)
of IR)
"Will select this IRREGULAR region when you release the button."
)
T))
(SETQ ALLREADY.PROMPT T)))
else
(* * WE have moved AND we are at a new Iregion)
(if ALLREADY.PROMPT
then (PROMPTPRINT))
(for IR in OLD-REGIONS do (INVERT.IREGION WINDOW IR))
(SETQ OLD-REGIONS (\WITH.INTERSECTION (WHICH.IREGIONS WINDOW
(CONS TEMPX TEMPY))
INTERSECTIONFLG))
(for IR in OLD-REGIONS do (INVERT.IREGION WINDOW IR))
(SETQ TIMEOUT (SETUPTIMER 1500 TIMEOUT 'TICKS 'MILLISECONDS))
(SETQ ALLREADY.PROMPT NIL]
(if ALLREADY.PROMPT
then (PROMPTPRINT))
(for IR in OLD-REGIONS do (INVERT.IREGION WINDOW IR))
(for IR in OLD-REGIONS do (DOSELECTED.IREGION WINDOW IR BUTTON])
(\IR.CLIP.REGION
[LAMBDA (REG WINDOW) (* GWexler " 7-Feb-86 10:27")
(* This function takes a regions and a window and returns a new region that
fits inside the window. If region starts out completely outside of window, then
NIL is returned.)
(PROG [LEFT RIGHT TOP BOTTOM (W.REG (WINDOWPROP WINDOW 'REGION]
[SETQ W.REG (LIST (CAR W.REG)
(CADR W.REG)
[IDIFFERENCE (CADDR W.REG)
(ITIMES 2 (WINDOWPROP WINDOW 'BORDER]
(IDIFFERENCE (CADDDR W.REG)
(ITIMES 2 (WINDOWPROP WINDOW 'BORDER]
(if (OR (GREATERP (fetch (REGION LEFT) of REG)
(fetch (REGION PRIGHT) of W.REG))
(GREATERP (fetch (REGION BOTTOM) of REG)
(fetch (REGION PTOP) of W.REG))
(ILESSP (fetch (REGION PRIGHT) of REG)
(fetch (REGION LEFT) of W.REG))
(ILESSP (fetch (REGION PTOP) of REG)
(fetch (REGION BOTTOM) of W.REG)))
then (printout T "None of the region was inside the window." T)
(RETURN NIL))
(SETQ LEFT (IMAX (fetch (REGION LEFT) of REG)
(fetch (REGION LEFT) of W.REG)))
(SETQ RIGHT (IMIN (fetch (REGION PRIGHT) of REG)
(fetch (REGION PRIGHT) of W.REG)))
(SETQ TOP (IMIN (fetch (REGION PTOP) of REG)
(fetch (REGION PTOP) of W.REG)))
(SETQ BOTTOM (IMAX (fetch (REGION BOTTOM) of REG)
(fetch (REGION BOTTOM) of W.REG)))
(RETURN (LIST (IDIFFERENCE LEFT (fetch (REGION LEFT) of W.REG))
(IDIFFERENCE BOTTOM (fetch (REGION BOTTOM) of W.REG))
(IDIFFERENCE RIGHT LEFT)
(IDIFFERENCE TOP BOTTOM])
(\IR.SHOW.REGION
[LAMBDA (WINDOW REGION) (* GWexler " 7-Feb-86 10:27")
(* This function draws a box specified by REGION on WINDOW using invert mode.)
(LET ((REG (COPY REGION))
(W (IPLUS (CADDR REGION)
(CAR REGION)
1))
(H (IPLUS (CADDDR REGION)
(CADR REGION)
1)))
(RPLACA REG (SUB1 (CAR REG)))
(RPLACA (CDR REG)
(SUB1 (CADR REG)))
(DRAWLINE (CAR REG)
(CADR REG)
W
(CADR REG)
1
'INVERT WINDOW)
(DRAWLINE (CAR REG)
H W H 1 'INVERT WINDOW)
(DRAWLINE (CAR REG)
(CADR REG)
(CAR REG)
H 1 'INVERT WINDOW)
(DRAWLINE W (CADR REG)
W H 1 'INVERT WINDOW])
(\VALID.POSITION.LIST
[LAMBDA (POSITIONLIST) (* GWexler " 7-Feb-86 10:34")
(* Checks out to see if POSITIONLIST is either NIL a valid position, or a list
of valid positions. Returns either NIL ERROR or a list of positions
(maybe only one element list.))
(if (NOT POSITIONLIST)
then NIL
else (if (POSITIONP POSITIONLIST)
then (LIST POSITIONLIST)
else (if (LISTP POSITIONLIST)
then (if (for P in POSITIONLIST always (POSITIONP P))
then POSITIONLIST
else (printout T "Not all elements in this list are positions." T)
'ERROR)
else (printout T "POSITIONLIST must be NIL, a position, or a list of positions."
T)
'ERROR])
(\SAME.IREGIONS.LIST
[LAMBDA (LIST1 LIST2) (* GWexler " 7-Feb-86 10:27")
(* Tests to see if two lists of regions are lists of the same regions.)
(if (NEQ (LENGTH LIST1)
(LENGTH LIST2))
then NIL
else (for ELT in LIST1 always (FMEMB ELT LIST2])
(\WITH.INTERSECTION
[LAMBDA (IRLIST FLG) (* GWexler " 7-Feb-86 10:34")
(* If FLG is T then return IRLIST, otherwise return NIL or a list with just one
element.)
(if FLG
then IRLIST
else (if (NOT IRLIST)
then NIL
else (LIST (CAR IRLIST])
(\IREGION.ON.WINDOWP
[LAMBDA (IREGION WINDOW) (* GWexler " 7-Feb-86 10:27")
(if [AND (IREGIONP IREGION)
(WINDOWP WINDOW)
(FMEMB IREGION (WINDOWPROP WINDOW 'IREGIONSLIST]
then IREGION
else NIL])
)
(DECLARE%: EVAL@COMPILE
(DATATYPE IREGION (BUTTONEVENTFN (* The users function to be called.)
USERDATA
(* This is where the users data is kept in proplist format.)
REGION
(* The region relative to the window where the IREGION is located.)
MASK
(* The mask is the same size as region and contains black where ever the
IREGION is to be active.)
SHADE (* The shade which IREGION inverts to
%.)
HELPSTRING
(* The helpstring to be printed when the button is held down in this IREGION)
)
(* there used to be a TYPE? here but it was useless and removed)
)
)
(/DECLAREDATATYPE 'IREGION '(POINTER POINTER POINTER POINTER POINTER POINTER)
'((IREGION 0 POINTER)
(IREGION 2 POINTER)
(IREGION 4 POINTER)
(IREGION 6 POINTER)
(IREGION 8 POINTER)
(IREGION 10 POINTER))
'12)
(PUTPROPS IREGIONPROP ARGNAMES (NIL (IREGION PROP {NEWVALUE}) . U))
(RPAQQ DEFAULT.IREGION.SHADE 65535)
(DECLARE%: DOEVAL@COMPILE DONTCOPY
(GLOBALVARS DEFAULT.IREGION.SHADE)
)
(DECLARE%: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS
(ADDTOVAR NLAMA )
(ADDTOVAR NLAML )
(ADDTOVAR LAMA IREGIONPROP)
)
(PUTPROPS AIREGIONS COPYRIGHT ("XEROX Corporation" 1985 1986 1987))
(DECLARE%: DONTCOPY
(FILEMAP (NIL (1346 25783 (ADD.IREGION 1356 . 1755) (ALL.IREGIONS 1757 . 2056) (CREATEIR 2058 . 9584)
(REMOVE.IREGION 9586 . 9944) (DOSELECTED.IREGION 9946 . 10291) (EDIT.MASK 10293 . 10586) (IREGIONP
10588 . 10913) (IREGIONPROP 10915 . 15583) (SHOW.ALL.IREGIONS 15585 . 16587) (INTERSECTING.IREGIONS?
16589 . 16998) (INVERT.IREGION 17000 . 17666) (WHICH.IREGIONS 17668 . 19254) (SURROUNDIR 19256 . 25781
)) (25784 35336 (IN.CURSOR.REGION 25794 . 30072) (\IR.CLIP.REGION 30074 . 32280) (\IR.SHOW.REGION
32282 . 33233) (\VALID.POSITION.LIST 33235 . 34254) (\SAME.IREGIONS.LIST 34256 . 34630) (
\WITH.INTERSECTION 34632 . 35031) (\IREGION.ON.WINDOWP 35033 . 35334)))))
STOP