This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_handling.adb
721 lines (609 loc) · 26.6 KB
/
event_handling.adb
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
with Ada_SDL_Video,Ada.Unchecked_Deallocation, Interfaces.C, Gr_Shapes, Drawline_Pkg, Circle_Pkg, Aux_Fct, Ada.Text_Io;
use Ada_SDL_Video, Ada_SDL_Video.PixelPtrPkg, Interfaces.C, Gr_Shapes, Drawline_Pkg, Circle_Pkg, Aux_Fct, Ada.Text_Io;
package body Event_Handling is
procedure free is new Ada.Unchecked_Deallocation (Shape, ShapePtr);
procedure free is new Ada.Unchecked_Deallocation (Point, PointPtr);
procedure insert_shape(Shape_Table: in out ShapePtr; Shape: in ShapePtr) is
-- Insert a shape into the Scene (called Shape_Table), the table is sorted in order of Identifier
-- The insertion will never unsort the table,
-- unless the Identifier is not unique (god only knows what might happen then)
curr : ShapePtr := Shape_Table;
begin
Shape.next := null;
if Shape_Table /= null then
while curr.next /= null loop
if shape.Identifier(2)< curr.next.Identifier(2) or else shape.Identifier(1)< curr.next.Identifier(1) or else shape.Identifier(0)< curr.next.Identifier(0) then
-- Insert the side
shape.next := curr.next;
curr.next := shape;
return;
end if;
curr := curr.next;
end loop;
curr.next := Shape;
else
Shape_Table := Shape;
end if;
end insert_shape;
function lowestPriority(Line, Polyline, Polygone, Circle, FCircle : pixel; iR, iG, iB, iA : Integer) return pixel is
-- Return the lowest priority of the five entered.
-- Requires: All Identifiers are unique.
begin
if (Line(iA) /= 0) and then (Line(iB) <= Polygone(iB) and Line(iB) <= Polyline(iB) and Line(iB) <= Circle(iB) and Line(iB) <= FCircle(iB)) and then (Line(iG) <= Polygone(iG) and Line(iG) <= Polyline(iG) and Line(iG) <= Circle(iG) and Line(iG) <= FCircle(iG)) and then (Line(iR) <= Polygone(iR) and Line(iR) <= Polyline(iR) and Line(iR) <= Circle(iR) and Line(iR) <= FCircle(iR)) then
return Line;
elsif (PolyLine(iA) /= 0) and then (PolyLine(iB) <= Polygone(iB) and PolyLine(iB) <= Line(iB) and PolyLine(iB) <= Circle(iB) and PolyLine(iB) <= FCircle(iB)) and then (PolyLine(iG) <= Polygone(iG) and PolyLine(iG) <= Line(iG) and PolyLine(iG) <= Circle(iG) and PolyLine(iG) <= FCircle(iG)) and then (PolyLine(iR) <= Polygone(iR) and PolyLine(iR) <= Line(iR) and PolyLine(iR) <= Circle(iR) and PolyLine(iR) <= FCircle(iR)) then
return PolyLine;
elsif (Polygone(iA) /= 0) and then (Polygone(iB) <= PolyLine(iB) and PolyGone(iB) <= Line(iB) and Polygone(iB) <= Circle(iB) and Polygone(iB) <= FCircle(iB)) and then (Polygone(iG) <= PolyLine(iG) and Polygone(iG) <= Line(iG) and Polygone(iG) <= Circle(iG) and Polygone(iG) <= FCircle(iG)) and then (Polygone(iR) <= PolyLine(iR) and Polygone(iR) <= Line(iR) and Polygone(iR) <= Circle(iR) and Polygone(iR) <= FCircle(iR)) then
return Polygone;
elsif (Circle(iA) /= 0) and then (Circle(iB) <= PolyLine(iB) and Circle(iB) <= Line(iB) and Circle(iB) <= Polygone(iB) and Circle(iB) <= FCircle(iB)) and then (Circle(iG) <= PolyLine(iG) and Circle(iG) <= Line(iG) and Circle(iG) <= Polygone(iG) and Circle(iG) <= FCircle(iG)) and then (Circle(iR) <= PolyLine(iR) and Circle(iR) <= Line(iR) and Circle(iR) <= Polygone(iR) and Circle(iR) <= FCircle(iR)) then
return Circle;
else
return FCircle;
end if;
end lowestPriority;
procedure RedrawWindow( Window : ImagePtr;
TabObj : Nirvana;
Clipper : RectanglePtr := null) is
-- Procedure to draw the background (canvas) and all the object we have created, normally called with a rectangular window for clipping.
pPixel : PixelPtr := Window.basePixel;
PCour : PointPtr;
CurrLine, CurrPolyline, CurrPolygone, CurrCircle, CurrCircleF : ShapePtr;
lowestPrio, LinePrio, PolyLinePrio,PolygonePrio, CirclePrio, CircleFPrio : Pixel;
nullPrio : Pixel := (255, 255, 255, 255);
iR, iG, iB, iA : integer;
begin
-- Draw the "Canvas" (Background)
iR := Window.iR;
iG := Window.iG;
iB := Window.iB;
iA := window.iA;
nullPrio(iA) := 0;
CurrPolygone := TabObj(Canvas);
while CurrPolygone /= null loop
PCour := CurrPolygone.PStart;
Polygone(Window, PCour, CurrPolygone.Color, Clipper);
CurrPolygone := CurrPolygone.next;
end loop;
-- Redraw all objects in order of priority (Identifier)
CurrLine := TabObj(Line);
CurrPolyLine := TabObj(Polyline);
CurrPolygone := TabObj(Polygone);
CurrCircle := TabObj(Circle);
CurrCircleF := TabObj(FilledCircle);
PCour := null;
while not (CurrLine = null and CurrPolyLine = null and CurrPolygone = null and currCircle = null and CurrCircleF = null) loop
-- When one of our pointers does not point anywhere (it is null)
-- give it an identifier > any other identifier
if CurrLine = null then
LinePrio := nullPrio;
else
LinePrio := CurrLine.Identifier;
end if;
if CurrPolyLine = null then
PolyLinePrio := nullPrio;
else
PolyLinePrio := CurrPolyLine.Identifier;
end if;
if CurrPolygone = null then
PolygonePrio := nullPrio;
else
PolygonePrio := CurrPolygone.Identifier;
end if;
if CurrCircle = null then
CirclePrio := nullPrio;
else
CirclePrio := CurrCircle.Identifier;
end if;
if CurrCircleF = null then
CircleFPrio := nullPrio;
else
CircleFPrio := CurrCircleF.Identifier;
end if;
lowestPrio := lowestPriority(LinePrio, PolyLinePrio, PolygonePrio, CirclePrio, CircleFPrio, iR, iG, iB, iA);
if LinePrio(iA) /= 0 and then LinePrio = lowestPrio then
PCour := CurrLine.PStart;
DrawLine(Window, PCour, CurrLine.Color, Clipper);
CurrLine := CurrLine.next;
elsif PolylinePrio(iA) /= 0 and then PolyLinePrio = lowestPrio then
PCour :=CurrPolyLine.PStart;
Polyline(Window, PCour, CurrPolyLine.Color, Clipper);
CurrPolyLine := CurrPolyLine.next;
elsif PolygonePrio(iA) /= 0 and then PolygonePrio = lowestPrio then
PCour :=CurrPolygone.PStart;
Polygone(Window, PCour, CurrPolygone.Color, Clipper);
CurrPolygone := CurrPolygone.next;
elsif CirclePrio(iA) /= 0 and then CirclePrio = lowestPrio then
Cercle(Window, CurrCircle.PStart, CurrCircle.Pstart.Next, CurrCircle.Color);
CurrCircle := CurrCircle.next;
elsif CircleFPrio(iA) /= 0 and then CircleFPrio = lowestPrio then
CercleRempli(Window, CurrCircleF.Pstart, CurrCircleF.PStart.next, CurrCircleF.Color, Clipper);
CurrCircleF := CurrCircleF.next;
end if;
end loop;
end RedrawWindow;
procedure RedrawOffscreen(Window : ImagePtr;
TabObj : Nirvana;
Clipper : RectanglePtr := null) is
-- Procedure to redraw the offscreen and all the objects we have created, normally called with a Rectangular window for Clipping, the "color" in the offscreen is an objects priority and identifier
pPixel : PixelPtr := Window.basePixel;
PCour : PointPtr;
CurrLine, CurrPolyline, CurrPolygone, CurrCircle, CurrCircleF : ShapePtr;
lowestPrio, LinePrio, PolyLinePrio,PolygonePrio, CirclePrio, CircleFPrio : Pixel;
nullPrio : Pixel := (255, 255, 255, 255);
iR, iG, iB, iA : Integer;
begin
-- Draw the "Canvas" (Background)
iR := Window.iR;
iG := Window.iG;
iB := Window.iB;
iA := window.iA;
nullPrio(iA) := 0;
CurrPolygone := TabObj(Canvas);
while CurrPolygone /= null loop
Polygone(Window, CurrPolygone.Pstart, CurrPolygone.Identifier, Clipper);
CurrPolygone := CurrPolygone.next;
end loop;
-- Redraw all objects in order of priority (Identifier)
CurrLine := TabObj(Line);
CurrPolyLine := TabObj(Polyline);
CurrPolygone := TabObj(Polygone);
CurrCircle := TabObj(Circle);
CurrCircleF := TabObj(FilledCircle);
PCour := null;
while not (CurrLine = null and CurrPolyLine = null and CurrPolygone = null and CurrCircle = null and CurrCircleF = null) loop
-- When one of our pointers does not point anywhere (it is null)
-- give it an identifier > any other identifier
if CurrLine = null then
LinePrio := nullPrio;
else
LinePrio := CurrLine.Identifier;
end if;
if CurrPolyLine = null then
PolyLinePrio := nullPrio;
else
PolyLinePrio := CurrPolyLine.Identifier;
end if;
if CurrPolygone = null then
PolygonePrio := nullPrio;
else
PolygonePrio := CurrPolygone.Identifier;
end if;
if CurrCircle = null then
CirclePrio := nullPrio;
else
CirclePrio := CurrCircle.Identifier;
end if;
if CurrCircleF = null then
CircleFPrio := nullPrio;
else
CircleFPrio := CurrCircleF.Identifier;
end if;
lowestPrio := lowestPriority(LinePrio, PolyLinePrio, PolygonePrio, CirclePrio, CircleFPrio, iR, iG, iB, iA);
if LinePrio = lowestPrio then
PCour := CurrLine.PStart;
DrawLine(Window, PCour, CurrLine.Identifier, Clipper);
CurrLine := CurrLine.next;
elsif PolyLinePrio = lowestPrio then
PCour :=CurrPolyLine.PStart;
Polyline(Window, PCour, CurrPolyLine.Identifier, Clipper);
CurrPolyLine := CurrPolyLine.next;
elsif PolygonePrio = lowestPrio then
PCour :=CurrPolygone.PStart;
Polygone(Window, PCour, CurrPolygone.Identifier, Clipper);
CurrPolygone := CurrPolygone.next;
elsif CirclePrio = lowestPrio then
Cercle(Window, CurrCircle.PStart, CurrCircle.Pstart.Next, CurrCircle.Identifier);
CurrCircle := CurrCircle.next;
elsif CircleFPrio = lowestPrio then
CercleRempli(Window, CurrCircleF.Pstart, CurrCircleF.PStart.next, CurrCircleF.Identifier, Clipper);
CurrCircleF := CurrCircleF.next;
end if;
end loop;
end RedrawOffscreen;
procedure findShape(Id: PixelPtr; Scene: Nirvana; res: out ShapePtr) is
-- Locate an object with Identifier Id in the Scene.
-- Return the object when found
-- If no object with Identifier = Id is found return Null
Curr: ShapePtr;
begin
-- Loop through all the object in the scene.
for i in Line..FilledCircle loop
Curr := Scene(i);
while curr /= null loop
if Curr.Identifier = Id.all then
-- Object found, return object!
res := Curr;
return;
end if;
Curr := Curr.next;
end loop;
end loop;
-- no object was found
res := null;
end findShape;
procedure CheckShape(offscreenImage: ImagePtr; x,y: integer; Zen : Nirvana; res : out ShapePtr) is
-- Simple procedure for using findShape.
pPtr : pixelPtr;
begin
-- Locate the Identifier of the object we clicked and call findShape.
pPtr:= offscreenImage.basePixel + ptrdiff_t (offscreenImage.width * y + x);
findShape(pPtr, Zen, res);
end CheckShape;
procedure eraseShape(id : PixelPtr; Scene : in out Nirvana; Obj : out ShapePtr; erase : Boolean := true) is
-- Function to either remove or erase a shape from the scene
-- Res = null if no object to remove/delete was found
Prec, Curr, Next : ShapePtr;
begin
-- Loop through all the object in the scene.
for i in Line..FilledCircle loop
Curr := Scene(i);
Prec := null;
while curr /= null loop
Next := Curr.next;
if Curr.Identifier = Id.all then
-- Object found, return object!
Obj := Curr;
Obj.next := null;
if Prec = null then
-- First shape in the list is to be removed
Scene(i) := next;
else
Prec.next := next;
end if;
if erase then
free(curr);
end if;
return;
end if;
Prec := Curr;
Curr := Next;
end loop;
end loop;
-- no object was found nothing to do
end eraseShape;
procedure RemoveShape(offscreenImage: ImagePtr; x,y : Integer; Zen: in out nirvana; res : out ShapePtr; erase : Boolean := True) is
-- Function to simplify the calling of eraseShape
pPtr : PixelPtr;
begin
pPtr:= offscreenImage.basePixel + ptrdiff_t (offscreenImage.width * y + x);
eraseShape(pPtr, Zen, Res, erase);
end RemoveShape;
procedure increasePrio (prio: in out pixel; iR, iG, iB, iA : Integer) is
begin
if prio(iR) /= 255 then
prio(iR) := prio(iR) + 1;
else
if prio(iG) /= 255 then
prio(iR) := 0;
prio(iG) := prio(iG) + 1;
else
if prio(iB) /= 255 then
prio(iG) := 0;
prio(iB) := prio(iB) + 1;
else
put_line("The Scene is full, God knows what happens if you enter another object");
end if;
end if;
end if;
end increasePrio;
procedure resortPrio(scene: in out nirvana; iR, iG, iB, iA : integer ; MaxPrio : out Pixel) is
-- Resets all priorities eliminating all possible "holes" amongst the identifiers
-- Returns the new maxPrio (one higher than the highest priority in the Scene)
currLine, currPolyline, currPolygone, CurrCircle, CurrCircleF : ShapePtr;
lowestPrio, linePrio, polylinePrio, polygonePrio, CirclePrio, CircleFPrio : Pixel;
nullPrio : Pixel := (255, 255, 255, 255);
begin
maxPrio := (0, 0, 0, 0);
nullPrio(iA) := 0;
CurrLine := scene(Line);
CurrPolyLine := scene(Polyline);
CurrPolygone := scene(Polygone);
CurrCircle := Scene(Circle);
CurrCircleF := Scene(FilledCircle);
if currline = null then
linePrio := nullprio;
else
linePrio := currLine.Identifier;
end if;
if currPolyline = null then
polylinePrio := nullprio;
else
polylinePrio := currPolyline.Identifier;
end if;
if currPolygone = null then
polygonePrio := nullPrio;
else
polygonePrio := currPolygone.Identifier;
end if;
if CurrCircle = null then
CirclePrio := nullPrio;
else
CirclePrio := CurrCircle.Identifier;
end if;
if CurrCircleF = null then
CircleFPrio := nullPrio;
else
CircleFPrio := CurrCircleF.Identifier;
end if;
maxPrio(iA) := 255;
maxPrio(iR) := 1;
while not (CurrLine = null and CurrPolyLine = null and CurrPolygone = null and currCircle = null and currCircleF = null) loop
-- When one of our pointers does not point anywhere (it is null)
-- give it an identifier > any other identifier and an alpha value of 0
if CurrLine = null then
LinePrio := nullPrio;
else
LinePrio := CurrLine.Identifier;
end if;
if CurrPolyLine = null then
PolyLinePrio := nullPrio;
else
PolyLinePrio := CurrPolyLine.Identifier;
end if;
if CurrPolygone = null then
PolygonePrio := nullPrio;
else
PolygonePrio := CurrPolygone.Identifier;
end if;
if CurrCircle = null then
CirclePrio := nullPrio;
else
CirclePrio := CurrCircle.Identifier;
end if;
if CurrCircleF = null then
CircleFPrio := nullPrio;
else
CircleFPrio := CurrCircleF.Identifier;
end if;
-- Find the lowest priority
lowestPrio := lowestPriority(LinePrio, polylinePrio, polygonePrio, CirclePrio, CircleFPrio, iR, iG, iB, iA);
-- Treat the lowest priority (update the identifier) object
if LinePrio(iA) /= 0 and then LinePrio = lowestPrio then
CurrLine.Identifier := maxPrio;
increasePrio(maxPrio, iR, iG, iB, iA);
CurrLine := CurrLine.next;
elsif PolylinePrio(iA)/= 0 and then PolyLinePrio = lowestPrio then
currPolyline.Identifier := maxprio;
increasePrio(maxPrio, iR, iG, iB, iA);
CurrPolyLine := CurrPolyLine.next;
elsif polygonePrio(iA) /= 0 and then PolygonePrio = lowestPrio then
currPolygone.Identifier := maxPrio;
increasePrio(maxPrio, iR, iG, iB, iA);
CurrPolygone := CurrPolygone.next;
elsif CirclePrio(iA) /= 0 and then CirclePrio = lowestPrio then
CurrCircle.Identifier := maxPrio;
increasePrio(maxPrio, iR, iG, iB, iA);
currCircle := currCircle.next;
elsif CircleFPrio(iA) /= 0 and then CircleFPrio = lowestPrio then
CurrCircleF.Identifier := maxPrio;
increasePrio(maxPrio, iR, iG, iB, iA);
currCircleF := currCircleF.next;
end if;
end loop;
end resortPrio;
function ObjectType(id : PixelPtr; scene : Nirvana) return OBJECT is
-- Returns the Object type of a shape, using it's identifier
-- Returns Canvas if no matching objectwas found
Curr: ShapePtr;
begin
-- Loop through all the object in the scene.
for i in Line..FilledCircle loop
Curr := Scene(i);
while curr /= null loop
if Curr.Identifier = Id.all then
-- Object found, return object!
return i;
end if;
Curr := Curr.next;
end loop;
end loop;
-- no object was found
return Canvas;
end ObjectType;
function whatObject(offscreenImage: ImagePtr; x,y : Integer; Zen: nirvana) return OBJECT is
-- Simple procedure to get an objects identifier and the call ObjectType
pPtr : PixelPtr;
res : OBJECT;
begin
pPtr:= offscreenImage.basePixel + ptrdiff_t (offscreenImage.width * y + x);
res := ObjectType(pPtr, Zen);
return res;
end whatObject;
procedure DrawToolglass(MyImagePtr : ImagePtr; mousex, mousey : Integer; iR, iG, iB, iA : Integer; Clipper : RectanglePtr := null)is
-- Procedure to draw the toolglass on the screen
Tool1, Tool2, Tool3, Tool4,Tool5 : PointPtr := new point;
width : Integer := MyImagePtr.width;
height : Integer := MyImagePtr.height;
Black, Green, Red, Blue : Pixel := (0,0,0,0);
begin
if iA /= -1 then
Black(iA) := 128;
Green(iA) := 128;
Red(iA) := 128;
Blue(iA) := 128;
end if;
Red(iR) := 255;
Green(iG) := 255;
Blue(iB) := 255;
-- Draw the big rectangle surrounding the toolglass
Tool5.all:= (Mousex,Min(Height,Mousey),null) ;
Tool4.all:= (Mousex,Min(Height,Mousey+160),Tool5) ;
Tool3.all:= (Mousex+80,Min(Height,Mousey+160),Tool4) ;
Tool2.all:= (Mousex+80,Min(Height,Mousey),Tool3) ;
Tool1.all:= (Mousex,Min(Height,Mousey),Tool2) ;
Polyline(MyImagePtr,Tool1,black, Clipper) ;
-- Draw the Drawline button
DrawLine(MyImagePtr,new point'(Mousex+5,Min(Height,Mousey+35), new point'(Mousex+35,Min(Height,Mousey+5), null)),black, Clipper) ;
-- Draw the polyline button
Tool3.all:= (Mousex+45,Min(Height,Mousey+18),null) ;
Tool2.all:= (Mousex+53,Min(Height,Mousey+10),Tool3) ;
Tool1.all:= (Mousex+75,Min(Height,Mousey+35),Tool2) ;
Polyline(MyImagePtr,Tool1 ,Black, Clipper) ;
-- Draw the circle button
if Mousey+75 <= Height then
Tool1.all := (Mousex+20,Mousey+60, null);
Tool2.all := (mousex + 35, mousey + 60, null);
Cercle(MyImagePtr, Tool1, Tool2, black) ;
end if ;
-- Draw the filled circle button
if Mousey+115 <= Height then
Tool1.all := (Mousex+20,Mousey+100, null);
Tool2.all := (mousex + 35, mousey + 100, null);
CercleRempli(MyImagePtr, Tool1, Tool2, black, Clipper) ;
end if ;
-- Draw the polygon button
Tool4.all:= (Mousex+45,Min(Height,Mousey+50),null) ;
Tool3.all:= (Mousex+75,Min(Height,Mousey+50),Tool4) ;
Tool2.all:= (Mousex+75,Min(Height,Mousey+70),Tool3) ;
Tool1.all:= (Mousex+45,Min(Height,Mousey+70),Tool2) ;
Polygone(MyImagePtr,Tool1, black, Clipper) ;
-- Draw the Table of colors button
Tool2.all := (Mousex+60,Min(Height,Mousey+120), null);
Tool1.all := (Mousex+60,Min(Height,Mousey+80), Tool2);
Drawline(MyImagePtr, Tool1, black, Clipper) ;
Tool2.all := (Mousex+80,Min(Height,Mousey+100), null);
Tool1.all := (Mousex+40,Min(Height,Mousey+100), Tool2);
Drawline(MyImagePtr, Tool1, black, Clipper) ;
-- Draw the small, colored squares
Tool4.all:= (Mousex+43,Min(Height,Mousey+83),null) ;
Tool3.all:= (Mousex+57,Min(Height,Mousey+83),Tool4) ;
Tool2.all:= (Mousex+57,Min(Height,Mousey+97),Tool3) ;
Tool1.all:= (Mousex+43,Min(Height,Mousey+97),Tool2) ;
Polygone(MyImagePtr,Tool1,Red, Clipper) ;
Tool4.all:= (Mousex+63,Min(Height,Mousey+83),null) ;
Tool3.all:= (Mousex+77,Min(Height,Mousey+83),Tool4) ;
Tool2.all:= (Mousex+77,Min(Height,Mousey+97),Tool3) ;
Tool1.all:= (Mousex+63,Min(Height,Mousey+97),Tool2) ;
Polygone(MyImagePtr,Tool1,green, Clipper) ;
Tool4.all:= (Mousex+63,Min(Height,Mousey+103),null) ;
Tool3.all:= (Mousex+77,Min(Height,Mousey+103),Tool4) ;
Tool2.all:= (Mousex+77,Min(Height,Mousey+117),Tool3) ;
Tool1.all:= (Mousex+63,Min(Height,Mousey+117),Tool2) ;
Polygone(MyImagePtr,Tool1,black, Clipper) ;
Tool4.all:= (Mousex+43,Min(Height,Mousey+103),null) ;
Tool3.all:= (Mousex+57,Min(Height,Mousey+103),Tool4) ;
Tool2.all:= (Mousex+57,Min(Height,Mousey+117),Tool3) ;
Tool1.all:= (Mousex+43,Min(Height,Mousey+117),Tool2) ;
Polygone(MyImagePtr,Tool1,blue, Clipper) ;
-- Draw the erase button
Tool2.all := (Mousex+35,Min(Height,Mousey+155), null);
Tool1.all := (Mousex+5,Min(Height,Mousey+125), Tool2);
Drawline(MyImagePtr,Tool1, Red, Clipper) ;
Tool2.all := (Mousex+35,Min(Height,Mousey+125), null);
Tool1.all := (Mousex+5,Min(Height,Mousey+155), Tool2);
Drawline(MyImagePtr,Tool1, Red, Clipper) ;
-- Draw the increase priority button
Tool2.all := (Mousex+60,Min(Height,Mousey+155), null);
Tool1.all := (Mousex+60,Min(Height,Mousey+125), Tool2);
Drawline(MyImagePtr, Tool1, Black, Clipper) ;
Tool2.all := (Mousex+50,Min(Height,Mousey+135), null);
Tool1.all := (Mousex+60,Min(Height,Mousey+125), Tool2);
Drawline(MyImagePtr, Tool1, black, clipper) ;
Tool2.all := (Mousex+70,Min(Height,Mousey+135), null);
Tool1.all := (Mousex+60,Min(Height,Mousey+125), Tool2);
Drawline(MyImagePtr, Tool1, black, Clipper) ;
-- Draw all the separating lines between the buttons
Tool2.all := (Mousex+40,Min(Height,Mousey+160), null);
Tool1.all := (Mousex+40,Min(Height,Mousey), Tool2);
DrawLine(MyImagePtr, Tool1, black, Clipper) ;
Tool2.all := (Mousex+80,Min(Height,Mousey+40), null);
Tool1.all := (Mousex,Min(Height,Mousey+40), Tool2);
DrawLine(MyImagePtr, Tool1, black, Clipper) ;
Tool2.all := (Mousex+80,Min(Height,Mousey+80), null);
Tool1.all := (Mousex,Min(Height,Mousey+80), Tool2);
DrawLine(MyImagePtr, Tool1, black, Clipper) ;
Tool2.all := (Mousex+80,Min(Height,Mousey+120), null);
Tool1.all := (Mousex,Min(Height,Mousey+120), Tool2);
DrawLine(MyImagePtr, Tool1, black, Clipper) ;
Tool2.next := Tool3;
Tool4.next := Tool5;
erasePoints(Tool1);
-- erasePoints(Tool8);
-- erasePoints(Tool12);
-- erasePoints(Tool16);
-- erasePoints(Tool20);
-- erasePoints(Tool24);
-- erasePoints(Tool28);
--
end DrawToolglass;
procedure DrawColorTable(MyImagePtr : ImagePtr; mousex, mousey : Integer; iR, iG, iB, iA : Integer; Clipper : RectanglePtr := null) is
-- Procdure to draw the table of colors on the screen
Tabcolor1, TabColor2, TabColor3, TabColor4, TabColor5 : PointPtr := new point;
height : Integer := MyImagePtr.height;
width : Integer := MyImagePtr.width;
Red, Green, Blue, Black, Yellow, White : Pixel := (0, 0, 0, 0);
begin
if iA /= -1 then
Red(iA) := 128;
Green(iA) := 128;
Blue(iA) := 128;
Yellow(iA) := 128;
White(iA) := 128;
Black(iA) := 128;
end if;
red(iR) := 255;
Yellow(iR) := 255;
White(iR) := 255;
Green(iG) := 255;
Yellow(iG) := 255;
White(iG) := 255;
Blue(iB) := 255;
White(iB) := 255;
-- Draw the Rectangle containing the table of colors
Tabcolor5.all:= (Mousex,Min(Height,Mousey),null) ;
Tabcolor4.all:= (Mousex+80,Min(Height,Mousey),Tabcolor5) ;
Tabcolor3.all:= (Mousex+80,Min(Height,Mousey+120),Tabcolor4) ;
Tabcolor2.all:= (Mousex,Min(Height,Mousey+120),Tabcolor3) ;
Tabcolor1.all:= (Mousex,Min(Height,Mousey),Tabcolor2) ;
Polyline(MyImagePtr,Tabcolor1,black, Clipper) ;
-- Draw the red button
Tabcolor4.all:= (Mousex+5,Min(Height,Mousey+5),null) ;
Tabcolor3.all:= (Mousex+35,Min(Height,Mousey+5),Tabcolor4) ;
Tabcolor2.all:= (Mousex+35,Min(Height,Mousey+35),Tabcolor3) ;
Tabcolor1.all:= (Mousex+5,Min(Height,Mousey+35),Tabcolor2) ;
Polygone(MyImagePtr,Tabcolor1,Red, Clipper) ;
-- Draw the green button
Tabcolor4.all:= (Mousex+45,Min(Height,Mousey+5),null) ;
Tabcolor3.all:= (Mousex+75,Min(Height,Mousey+5),Tabcolor4) ;
Tabcolor2.all:= (Mousex+75,Min(Height,Mousey+35),Tabcolor3) ;
Tabcolor1.all:= (Mousex+45,Min(Height,Mousey+35),Tabcolor2) ;
Polygone(MyImagePtr,Tabcolor1,green, Clipper) ;
-- Draw the black button
Tabcolor4.all:= (Mousex+45,Min(Height,Mousey+45),null) ;
Tabcolor3.all:= (Mousex+75,Min(Height,Mousey+45),Tabcolor4) ;
Tabcolor2.all:= (Mousex+75,Min(Height,Mousey+75),Tabcolor3) ;
Tabcolor1.all:= (Mousex+45,Min(Height,Mousey+75),Tabcolor2) ;
Polygone(MyImagePtr,Tabcolor1,black, Clipper) ;
-- Draw the Blue button
Tabcolor4.all:= (Mousex+5,Min(Height,Mousey+45),null) ;
Tabcolor3.all:= (Mousex+35,Min(Height,Mousey+45),Tabcolor4) ;
Tabcolor2.all:= (Mousex+35,Min(Height,Mousey+75),Tabcolor3) ;
Tabcolor1.all:= (Mousex+5,Min(Height,Mousey+75),Tabcolor2) ;
Polygone(MyImagePtr,Tabcolor1,blue, Clipper) ;
-- Draw the Yellow button
Tabcolor4.all:= (Mousex+5,Min(Height,Mousey+85),null) ;
Tabcolor3.all:= (Mousex+35,Min(Height,Mousey+85),Tabcolor4) ;
Tabcolor2.all:= (Mousex+35,Min(Height,Mousey+115),Tabcolor3) ;
Tabcolor1.all:= (Mousex+5,Min(Height,Mousey+115),Tabcolor2) ;
Polygone(MyImagePtr,Tabcolor1, Yellow, Clipper) ;
-- Draw the white button
Tabcolor4.all:= (Mousex+45,Min(Height,Mousey+85),null) ;
Tabcolor3.all:= (Mousex+75,Min(Height,Mousey+85),Tabcolor4) ;
Tabcolor2.all:= (Mousex+75,Min(Height,Mousey+115),Tabcolor3) ;
Tabcolor1.all:= (Mousex+45,Min(Height,Mousey+115),Tabcolor2) ;
Polygone(MyImagePtr,Tabcolor1, White, Clipper) ;
-- Draw the separating lines between all the buttons
TabColor2.all := (Mousex+40,Min(Height,Mousey+120), null);
TabColor1.all := (Mousex+40,Min(Height,Mousey), TabColor2);
Drawline(MyImagePtr, TabColor1, black, Clipper) ;
TabColor2.all := (Mousex+80,Min(Height,Mousey+40), null);
TabColor1.all := (Mousex,Min(Height,Mousey+40), TabColor2);
Drawline(MyImagePtr,TabColor1, black, Clipper) ;
TabColor2.all := (Mousex+80,Min(Height,Mousey+80), null);
TabColor1.all := (Mousex,Min(Height,Mousey+80), TabColor2);
Drawline(MyImagePtr, TabColor1, black, Clipper) ;
TabColor2.next := TabColor3;
TabColor4.next := TabColor5;
erasePoints(Tabcolor1);
end DrawColorTable;
end Event_Handling;