-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGRVIRT.PAS
executable file
·1636 lines (1468 loc) · 59.2 KB
/
GRVIRT.PAS
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
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Grvirt;
interface
uses Graph,Bitmaps,Pii,Crt,Mouse;
const Visible = true;
Unvisible = false;
MColor = 7;
Stlaceny = true;
Nestlaceny = false;
Zapnuty = true;
Vypnuty = false;
{polohy potenciometra}
const Polohy : array[0..15,1..2] of integer =(
(16,26),(13,24),(11,21),(10,18),(11,15),(12,12),(15,10),(18,9),
(21,9),(24,10),(27,12),(28,15),(29,18),(28,21),(26,24),(23,26));
type TButton = record
Name :string;
a,b,c,d :integer;
Mess :string; {odkaz pre dialogovy riadok}
Akt :boolean; {je pristupny?}
end;
PButton = ^TButton;
{type TRadioButton = record
Butto : array [1..6] of TButton;
Ktory: byte; {ktory je stlaceny}
{ Pocet: byte;
end;}
{polozka do frontu grafickych objektov}
type Polozka = record
x1,y1,x2,y2:integer;
Meno :string;
Typek :char; {typ objektu}
Message :string; {odkaz do dialogoveho riadka}
end;
type TRiadokNaPisanie = record
RName : string;
xx,yy : integer;
VidMena : boolean;
PocetM : byte; {pocet miest na pisanie}
Txt : string; {text v riadku}
Akt : boolean;
Mess : string;
end;
type TSprite = record
Name : string;
a,b,c,d : integer;
HX, HY : integer;
MiX, MiY : integer; {Hranice pohybu vzhladom}
MaX, MaY : integer; {k HotSpot bodom}
PBP : integer; {pocet bodov na posuv}
Mess : string;
Akt : boolean;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ Objekty }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{Eviduje graficke objekty (pre mysku)}
type Front = object
Item : Polozka;
constructor Init;
destructor Done;virtual;
procedure DeleteFromFront;virtual;
procedure ZmenavoFronte(Itemik:Polozka);
end;
{dialogovy riadok}
type Dialog = object(Front)
constructor Init;
destructor Done;virtual;
procedure WriteMessage(Mess:string);
procedure Ramik;
end;
{Hlavna plocha; inicializujeme na zaciatku programu}
type DeskTop = object(Front)
{ CisloPlochy : integer;}
constructor Init(Mess:string;col:byte;styl:byte);
destructor Done;virtual;
procedure Ramik;
end;
{jedno "okno"}
type Plocha = object(DeskTop)
Aktivita : boolean; {je aktivne? ak ano, zobrazi sa}
Back : pointer;
Vidi : boolean;
constructor Init(Name:string;Vid:boolean;a,b,c,d:integer;Mess:string);
procedure Show;virtual;
destructor Done;virtual;
procedure SaveBack;
procedure PutBack;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ Mozne prvky plochy }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{okienko s textikom}
type RiadokNaPisanie = object(Plocha)
Textik : string;
Dlzka : byte;
constructor Init(Riadok:TRiadokNaPisanie);
destructor Done;virtual;
procedure SetText(Txt:string);
procedure Edit(x,y:integer);virtual;
procedure PutKurzor(OldPoz,NewPoz:integer);virtual;
procedure PridajPismeno(Key:char);virtual;
procedure Show;virtual;
procedure ShowText;virtual;
end;
type OriadokNaPisanie = object(RiadokNaPisanie)
NextRNaPI : pointer;
end;
{pohyblive plochy}
type Sprajt = object(Plocha)
PSprajt : pointer;
HotX, HotY : integer;
MinX, MinY : integer; {Hranice pohybu vzhladom}
MaxX, MaxY : integer; {k HotSpot bodom}
PoBoPo : integer; {pocet bodov na posuv}
constructor Init(S:TSprite;P,Pb:pointer);
destructor Done;virtual;
procedure SetToXY(x,y:integer);virtual;
procedure Zmena(x,y:integer);virtual;
function GetX:integer;virtual;
function GetY:integer;virtual;
end;
type OSprajt = object(Sprajt)
NextSprajt:pointer;
end;
{obycajne tlacidlo}
type Button = object(Plocha)
stav : boolean;
constructor Init(Butt:TButton);
destructor Done;virtual;
procedure Show; virtual;
end;
type OButton = object(Button)
NextButton : pointer;
end;
{button s obrazkom}
type BitmapButton = object(Plocha)
Bx,By,Dx,Dy : integer;
nFF : byte;
Bitmapa : pointer;
stav : boolean;
constructor Init(Butt:TButton;x1,y1,xx,yy:integer;nf:byte;Obrazok:Pobrazok);
destructor Done;virtual;
procedure Show; virtual;
end;
type OBitmapButton = object(BitmapButton)
NextBitButton : pointer;
end;
{tlacidla vyberu (.)}
type RadioButton = object(Plocha)
RadioItem : array[0..24] of PButton;
Value: byte; {ktory je stlaceny}
Kolko: byte; {pocet}
constructor Init(nejm:string;Buttons: array of TButton;Ktory,Pocet:byte);
destructor Done;virtual;
procedure Show;virtual;
procedure SetIt;virtual;
procedure WriteMess(xx,yy:integer);virtual;
end;
type ORadioButton = object(RadioButton)
NextRButton : pointer;
end;
{graficky prepinac}
type Prepinac = object(Plocha)
Value: byte;
Kolko: byte; {pocet}
Pozadie : array[0..77] of byte;
constructor Init(Name:string;x,y:integer;Pocet,Ktory:byte;Vid:boolean;Mess:string);
destructor Done;virtual;
procedure Show;virtual;
procedure SetIt(x:integer);virtual;
end;
type OPrepinac = object(Prepinac)
NextPrepinac : pointer;
end;
{Zapinac (x)}
type Zapinac = object(Plocha)
stav : boolean;
value : boolean;
constructor Init(Butt:TButton;Hod:boolean);
destructor Done;virtual;
procedure Show; virtual;
procedure ShowIT; virtual;
procedure Prepni;virtual;
end;
type OZapinac = object(Zapinac)
NextZapinac : pointer;
end;
{graficky Zapinac (x)}
type GrZapinac = object(Plocha)
stav : boolean;
value : byte;
constructor Init(Name:string;x,y:integer;St:byte;Mess:string);
destructor Done;virtual;
procedure Show; virtual;
procedure ShowIT; virtual;
procedure Prepni;virtual;
end;
type OGrZapinac = object(GrZapinac)
NextGrZapinac : pointer;
end;
{Potenciometer}
type Potenciometer = object(Plocha)
Value : byte;
constructor Init(Name:string;x,y:integer;Mess:string;St:boolean);
destructor Done;virtual;
procedure NakresliHo(newval:byte);virtual;
procedure SetTo(newval:integer);virtual;
end;
type OPotenciometer = object(Potenciometer)
NextPotenciometer : pointer;
end;
{graficky Prepinac (x)}
type GrPrepinac = object(Plocha)
Str1,Str2:string;
Ktory : byte;
constructor Init(Name:string;x,y:integer;St:byte;Mess:string);
destructor Done;virtual;
procedure Prepni;virtual;
procedure Show;virtual;
procedure SetIt(x:integer);
procedure ShowMeno;virtual;
end;
type OGrPrepinac = object(GrPrepinac)
NextGrPrepinac : pointer;
end;
{bezec}
type Bezec = object(Plocha)
Value : integer;
Nasobok : integer;
DolH,HorH : integer;
ZaNim : array[0..246] of byte;
constructor Init(Name:string;x,y:integer;HH,DH,Nas:integer;Mess:string;St:boolean);
destructor Done;virtual;
procedure NakresliHo(newval:integer);virtual;
procedure SetToY(Hod:integer);virtual;
procedure SetTo(Hod:integer);virtual;
end;
type OBezec = object(Bezec)
NextBezec : pointer;
end;
procedure Grafika;
var Dial : Dialog; {dialogovy riadok}
ActualX,ActualY : integer; {Aktualne suradnice laveho horneho rohu}
ActualMaxX : integer;
ActualMaxY : integer; {Aktualne suradnice praveho dolneho rohu}
ActualPlochaS : string;
var PocetPoloziek : byte;
Polozky : array[1..500] of ^Polozka; {front grafickych objektov}
Desk : Desktop;
AktualneOkno : integer;
implementation
procedure Grafika;
var gd,gm : integer;
begin
gd:=detect;
Initgraph(gd,gm,'d:\tp7\bgi');
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ Front objektov (grafickych) }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor Front.Init;
begin
PocetPoloziek:=PocetPoloziek+1;
New(Polozky[PocetPoloziek]);
Polozky[PocetPoloziek]^:=Item;
end;
procedure Front.DeleteFromFront;
var prem : byte;
begin
prem:=PocetPoloziek;
repeat
with Polozky[prem]^ do begin
if ((((Meno = Item.Meno) and (Message = Item.Message)) and
((x1 = Item.x1) and (y1 = Item.y1))) and
((y2 = Item.y2) and (x2 = Item.x2))) and
(Typek = Item.Typek) then begin
while prem <> PocetPoloziek do begin
Polozky[prem]^ := Polozky[prem+1]^;
prem:=prem+1;
end;
Dispose(Polozky[Prem]);
Polozky[prem]:=NIL;
PocetPoloziek := PocetPoloziek - 1;
exit;
end;
end;
prem := prem - 1;
until prem = 0;
end;
procedure Front.ZmenaVoFronte(Itemik:polozka);
var prem : integer;
begin
prem:=PocetPoloziek;
repeat
with Polozky[prem]^ do begin
if ((Meno = Itemik.Meno) and (Message = Itemik.Message)) and
(Typek = Itemik.Typek) then begin
Polozky[prem]^ := Itemik;
exit;
end;
end;
prem := prem - 1;
until prem = 0;
end;
destructor Front.Done;
var prem : byte;
begin
for prem := 1 to PocetPoloziek do Dispose(Polozky[prem]);
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ Dialogove okno }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor Dialog.Init;
begin
with Item do begin
x1 := 0; y1 := 455;
x2 := 640; y2 := 480;
Meno := 'Dialog line';
Typek := 'g';
Message:='Zmizni!'
end;
Front.Init;
{Nakresli ho}
SetfillStyle(1,0);
bar(Item.x1,Item.y1,Item.x2,Item.y2);
Ramik;
end;
procedure Dialog.WriteMessage(Mess:string);
begin
setfillstyle(1,0);
bar(3,458,637,477);
SetColor(15);
SettextStyle(10, 0, 4);
SettextJustify(0,1);
Outtextxy(6,466,Mess);
end;
procedure Dialog.Ramik;
begin
setcolor(15);
Line(Item.x1,Item.y1,Item.x2,Item.y1); Line(Item.x1,Item.y1,Item.x1,Item.y2);
Line(Item.x1+2,Item.y2-2,Item.x2-2,Item.y2-2);
Line(Item.x2-2,Item.y1+2,Item.x2-2,Item.y2-2);
setcolor(7);{(Mcolor);}
Line(Item.x1+1,Item.y1+1,Item.x2-1,Item.y1+1);
Line(Item.x1+1,Item.y1+1,Item.x1+1,Item.y2-1);
Line(Item.x2-1,Item.y1+1,Item.x2-1,Item.y2-1);
Line(Item.x1+1,Item.y2-1,Item.x2-1,Item.y2-1);
setcolor(0);
Line(Item.x1+2,Item.y1+2,Item.x2-2,Item.y1+2);
Line(Item.x1+2,Item.y1+2,Item.x1+2,Item.y2-3);
Line(Item.x1,Item.y2,Item.x2,Item.y2);
Line(Item.x2,Item.y1,Item.x2,Item.y2);
end;
destructor Dialog.Done;
begin
Front.DeleteFromFront;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ DeskTop }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor DeskTop.Init(Mess:string;col,styl:byte);
begin
Grafika;
if InstallUserFont('modn') = 100 then ;
ActualX:=4;ActualY:=4;
ActualMaxX:=636;ActualMaxY:=450;
ActualPlochaS := 'desktop';
PocetPoloziek:=0;
with Item do begin
x1 := 0; y1 := 0;
x2 := 640; y2 := 454;
Meno := 'DeskTop';
Typek := 'd';
Message:=Mess;
end;
{Nakresli ho}
SetfillStyle(col,styl);
bar(Item.x1,Item.y1,Item.x2,Item.y2);
Ramik;
Front.Init;
Dial.Init;
end;
procedure DeskTop.Ramik;
begin
with Item do begin
setcolor(15);
Line(x1,y1,x2,y1); Line(x1,y1,x1,y2);
Line(x1+3,y2-3,x2-3,y2-3);
Line(x2-3,y1+3,x2-3,y2-3);
setcolor(7);{(Mcolor);}
Line(x1+1,y1+1,x2-1,y1+1);
Line(x1+2,y1+2,x2-2,y1+2);
Line(x1+1,y1+1,x1+1,y2-1);
Line(x1+2,y1+2,x1+2,y2-2);
Line(x2-1,y1+1,x2-1,y2-1);
Line(x2-2,y1+2,x2-2,y2-2);
Line(x1+1,y2-1,x2-1,y2-1);
Line(x1+2,y2-2,x2-2,y2-2);
setcolor(8);
Line(x1+3,y1+3,x2-3,y1+3);
Line(x1+3,y1+3,x1+3,y2-4);
Line(x1,y2,x2,y2);
Line(x2,y1,x2,y2);
end;
end;
destructor DeskTop.Done;
begin
Front.Done; {znicime front}
CloseGraph; {..a zavrieme grafiku}
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ Plocha }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor Plocha.Init(Name:string;Vid:boolean;a,b,c,d:integer;Mess:string);
begin
Vidi := Vid;
ActualX:=a+4;ActualY:=b+3;
ActualMaxX:=a+c-4;ActualMaxY:=b+d-4;
ActualPlochaS:=Name;
if Vid=true then ActualY := ActualY+20;
Aktivita := true;
with Item do begin
x1 := a; y1 := b;
x2 := a+c; y2 := b+d;
Meno := Name;
Typek := 'p';
Message:=Mess;
end;
Front.Init;
end;
procedure Plocha.Show;
begin
{Nakresli ju}
SetfillStyle(1,MColor);
bar(Item.x1,Item.y1,Item.x2,Item.y2);
if Vidi = visible then begin
SettextStyle(10, 0, 4);
SettextJustify(1,0);
SetColor(0);
outtextxy(Item.x1+trunc((Item.x2-Item.x1)/2)+1,Item.y1+15+1,Item.Meno);
Setcolor(15);
outtextxy(Item.x1+trunc((Item.x2-Item.x1)/2),Item.y1+15,Item.Meno);
setcolor(8);
line(Item.x1+4,Item.y1+20,Item.x2-4,Item.y1+20);
setcolor(15);
line(Item.x1+5,Item.y1+21,Item.x2-5,Item.y1+21);
end;
Ramik;
end;
procedure Plocha.SaveBack;
begin
if ImageSize(Item.x1,Item.y1,Item.x2,Item.y2) <> 0 then begin
GetMem(Back, ImageSize(Item.x1,Item.y1,Item.x2,Item.y2));
GetImage(Item.x1,Item.y1,Item.x2,Item.y2,Back^);
end;
end;
procedure Plocha.PutBack;
begin
if ImageSize(Item.x1,Item.y1,Item.x2,Item.y2) <> 0 then begin
PutImage(Item.x1,Item.y1,Back^,NormalPut);
FreeMem(Back,ImageSize(Item.x1,Item.y1,Item.x2,Item.y2));
end;
end;
destructor Plocha.Done;
begin
PutBack;
Front.DeleteFromFront;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{Sprajt }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor Sprajt.Init(S:TSprite; P,Pb:pointer);
begin
with Item do begin
x1 := S.a;x2:=S.c;
y1 := S.b ;y2:=S.d;
Meno := S.Name;
Typek := 's';
Message:=S.Mess;
Front.Init;
GetMem(PSprajt, ImageSize(x1,y1,x2,y2)); { Allocate memory on heap }
GetMem(Back, ImageSize(x1,y1,x2,y2)); { Allocate memory on heap }
PSprajt:=P;
Back:=Pb;
end;
with S do begin
HotX:=HX; HotY:=HY;
MinX:=Mix; MinY:=MiY;
MaxX:=Max; MaxY:=MaY;
PoBoPo:=PBP;
end;
end;
destructor Sprajt.Done;
begin
PutBack;
FreeMem(PSprajt,ImageSize(Item.x1,Item.y1,Item.x2,Item.y2));
Front.DeleteFromFront;
end;
function Sprajt.GetX:integer;
begin
GetX:=Item.X1;
end;
function Sprajt.GetY:integer;
begin
GetY:=Item.y1;
end;
procedure Sprajt.Zmena(x,y:integer);
begin
if x < 0 then x:=-1;
if x > 0 then x:= 1;
if y < 0 then y:=-1;
if y > 0 then y:= 1;
SetToXY(Item.x1+x,Item.y1+y);
end;
procedure Sprajt.SetToXY(x,y:integer);
var Vx,Vy:integer;
dx,dy:integer;
begin
with Item do begin
if x<MinX then x:=MinX;
if y<MinY then y:=MinY;
if x > MaxX then x:= MaxX;
if y > MaxY then y:= MaxY;
if (x <> x1) or (y <> y1) then begin
HotX:=x+(HotX-x1);
HotY:=y+(HotY-y1);
PutImage(x1,y1,Back^,NormalPut);
VX:=abs(x2-x1);VY:=abs(y2-y1);
x1:=x;y1:=y;
x2:=x+VX;y2:=y+VY;
GetImage(x1,y1,x2,y2,Back^);
Putimage(x1,y1,PSprajt^,NormalPut);
end;
ZmenaVoFronte(Item);
end;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{Riadok na pisanie }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor RiadokNaPisanie.Init(Riadok:TRiadokNaPisanie);
var DP : byte;
begin
DP:=8;
with Riadok do begin
xx:=xx+ActualX;
yy:=yy+ActualY;
Dlzka:= PocetM;
Textik:=Txt;
Vidi:=VidMena;
Item.x1 := xx; Item.y1 := yy;
Item.x2 := xx+(DP*Dlzka)+14; Item.y2 := yy+17;
Item.Meno := RName;
Item.Typek := 'l';
Item.Message := Mess;
end;
Front.Init;
end;
procedure RiadokNaPisanie.SetText(Txt:string);
begin
Textik:=Txt;
end;
procedure RiadokNaPisanie.PutKurzor(OldPoz,NewPoz:integer);
var StredY : integer;
begin
SetColor(15);
with Item do begin
StredY:=trunc((y1+y2)/2)+6;
if OldPoz <> -1 then begin
SetWriteMode(1);
Line(x1+7+OldPoz*8,StredY,x1+13+OldPoz*8,StredY);
end;
if OldPoz<>NewPoz then begin
SetWriteMode(1);
Line(x1+7+NewPoz*8,StredY,x1+13+NewPoz*8,StredY);
end;
end;
end;
procedure RiadokNaPisanie.PridajPismeno(Key:char);
begin
end;
procedure RiadokNaPisanie.Edit(x,y:integer);
var OldPoz,NewPoz:integer;
Key : char;
label koniec;
begin
with Item do begin
OldPoz := -1;
NewPoz := trunc((X-x1-5)/8);
If NewPoz > length(Textik) then NewPoz:=length(Textik);
PutKurzor(OldPoz,NewPoz);
OldPoz:=NewPoz;
repeat
Key := ReadKey;
if ord(Key) = 0 then begin
Key := Readkey;
case ord(Key) of
{vlavo}
75 : begin
If OldPoz <> 0 then begin
NewPoz := NewPoz - 1;
PutKurzor(OldPoz,NewPoz);
end;
end;
{vpravo}
77 : begin
If OldPoz < length(Textik) then begin
NewPoz := NewPoz + 1;
PutKurzor(OldPoz,NewPoz);
end;
end;
{END}
79 : begin
if OldPoz <> length(Textik) then begin
NewPoz := length(Textik);
PutKurzor(OldPoz,NewPoz);
end;
end;
{HOME}
71 : begin
if OldPoz <> 0 then begin
NewPoz := 0;
PutKurzor(OldPoz,NewPoz);
end;
end;
{DEL}
83 : begin
Delete(Textik,NewPoz+1,1);
ShowText;
PutKurzor(OldPoz,NewPoz);
end;
end;
end
else begin
case ord(Key) of
{BackSpace}
8 : begin
if OldPoz <> 0 then begin
Delete(Textik,OldPoz,1);
ShowText;
NewPoz := NewPoz - 1;
PutKurzor(-1,NewPoz);
end;
end;
{ESC}
27 : goto koniec;
32..126: begin
if length(Textik) <> Dlzka then begin
{ if OldPoz = length(Textik) then PridajPismeno(Key)}
{ else begin}
Insert(Key,Textik,OldPoz+1);
ShowText;
NewPoz:=NewPoz+1;
PutKurzor(-1,NewPoz);
{ end;}
end;
end;
end;
end;
OldPoz:=NewPoz;
until ord(Key) = 13;
koniec:
PutKurzor(NewPoz,NewPoz);
SetWriteMode(0);
end;
end;
Procedure RiadokNaPisanie.Show;
var DP : byte;
Col : byte;
begin
DP:=8;
Col:=0;
With Item do begin
SetFillstyle(1,Col);
Bar(x1,y1,x2,y2);
SetColor(8);Line(x1,y1,x2,y1);Line(x1,y1,x1,y2);
SetColor(15);Line(x1+1,y2,x2,y2);Line(x2,y1,x2,y2);
if Vidi = true then begin
SetColor(0);
SettextStyle(10, 0, 4);
SettextJustify(0,1);
OuttextXY(x1+1,y1-8,Meno);
SetColor(15);
OuttextXY(x1,y1-9,Meno);
end;
end;
end;
Procedure RiadokNaPisanie.ShowText;
var col : byte;
begin
SetWriteMode(0);
with Item do begin
SetFillstyle(1,0);
Bar(x1+2,y1+2,x2-2,y2-2);
col := 7;
Setcolor(col);
SettextStyle(0, 0, 1);
SettextJustify(0,1);
OuttextXY(x1+7,trunc((y1+y2)/2)+2,Textik);
end;
end;
destructor RiadokNaPisanie.Done;
begin
Front.DeleteFromFront;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ Prepinac }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor Prepinac.Init(Name:string;x,y:integer;Pocet,Ktory:byte;Vid:boolean;Mess:string);
begin
with Item do begin
x1 := x + 1+ActualX;
y1 := y + 1+ActualY;
Meno := Name;
Message := Mess;
x2 := x + (Pocet*5) + 2+ActualX;
y2 := y + 8+ActualY;
Typek := 'q';
Aktivita := true;
end;
Kolko := Pocet;
Value := Ktory;
Front.Init;
end;
destructor Prepinac.Done;
begin
Front.DeleteFromFront;
end;
procedure Prepinac.Show;
var px,py:integer;
prem : integer;
begin
with Item do begin
SetFillStyle(1,0);
Bar(x1,y1,x1+(Kolko*5)+2,y1+8);
SetColor(15);
line(x1+1,y1+7,x1+(Kolko*5)+1,y1+7);
line(x1+(Kolko*5)+1,y1+2,x1+(Kolko*5)+1,y1+7);
SetFillstyle(1,8);
Bar(x1+2,y1+2,x1+(Kolko*5),y1+6);
SetColor(7);
px:=x1+6;
for prem:=1 to Kolko - 1 do begin
Line(px,y1+2,px,y1+6);
px:=px+5;
end;
SetColor(0);
SettextStyle(2, 0, 4);
SettextJustify(1,1);
OuttextXY(trunc((x1+x2)/2)+1,y1-9,Meno);
SetColor(15);
OuttextXY(trunc((x1+x2)/2),y1-10,Meno);
prem :=0;
for py := (y1-2) to y1+10 do begin
for px:=(x1+1+(Value*5)) to (x1+6+(Value*5))do
begin
Pozadie[prem] := GetPixel(px,py);
prem:=prem+1;
end;
end;
PutBitmap(X1+1+(Value*5),Y1-2,5,12,1,@GPrepinac);
end;
end;
procedure Prepinac.SetIt(x:integer);
var Val : integer;
px,py:integer;
prem : integer;
begin
Val := trunc((x-Item.x1)/5);
if (Val > Kolko-1) or (Val < 0) then exit;
if Val <> Value then begin
HideMouse;
with Item do begin
PutBitmap(X1+1+(Value*5),Y1-2,5,12,1,@Pozadie);
Value := Val;
prem :=0;
for py := (y1-2) to y1+10 do begin
for px:=(x1+1+(Value*5)) to (x1+6+(Value*5))do
begin
Pozadie[prem] := GetPixel(px,py);
prem:=prem+1;
end;
end;
PutBitmap(X1+1+(Value*5),Y1-2,5,12,1,@GPrepinac);
end;
end;
ShowMouse;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ Button }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor Button.Init(Butt:TButton);
begin
with Butt do begin
Item.Meno := Name;
Item.x1 := ActualX+a; Item.y1 := ActualY+b;
Item.x2 := Actualx+a+c; Item.y2 := ActualY+b+d;
Item.typek := 'b';
Item.Message := Mess;
Aktivita := Akt;
Stav:=false;
Front.Init;
end;
end;
destructor Button.Done;
begin
Front.DeleteFromFront;
end;
procedure Button.Show;
var FP,FPT,CL,CD:byte; {farba pisma, tmava cast, bleda cast}
begin
FP := 15;FPT:=0;
if Aktivita = false then FP:= 7;
CL := 15; CD := 8;
with Item do begin
if Stav = Stlaceny then begin
CL := 8; CD := 7;
FP:=15;FPT:=0;
end;
SetFillStyle(1,Mcolor);
bar(x1,y1,x2,y2);
SetColor(0);
line(x1,y1,x1,y2);line(x1,y1,x2,y1);
line(x2,y1,x2,y2);line(x1,y2,x2,y2);
SetColor(CL);
line(x1+1,y1+1,x1+1,y2-1);line(x1+1,y1+1,x2-1,y1+1);
SetColor(CD);
line(x1+2,y2-1,x2-1,y2-1);line(x2-1,y1+1,x2-1,y2-1);
if Stav = Stlaceny then begin
x1:=x1+1;y1:=y1+1;
end;
SetColor(FPT);
SettextStyle(10, 0, 4);
SettextJustify(1,1);
OuttextXY(trunc((x1+x2)/2)+1,trunc((y1+y2)/2)+1,Meno);
SetColor(FP);
OuttextXY(trunc((x1+x2)/2),trunc((y1+y2)/2),Meno);
if Stav = Stlaceny then begin
x1:=x1-1;y1:=y1-1;
end;
end;
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
{ BitmapButton }
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
constructor BitmapButton.Init(Butt:TButton;x1,y1,xx,yy:integer;nf:byte;Obrazok:Pobrazok);
begin
with Butt do begin
Item.Meno := Name;
Item.x1 := a; Item.y1 := b;
Item.x2 := a+c; Item.y2 := b+d;
Item.typek := 'B';
Item.Message := Mess;
Aktivita := Akt;
Stav:=false;
Front.Init;
end;
BX:=x1+Item.x1;BY:=y1+Item.y1;
DX:=xx;DY:=yy;nFF:=nF;
Bitmapa:=Obrazok;
end;
destructor BitmapButton.Done;
begin
Front.DeleteFromFront;
end;
procedure BitmapButton.Show;
var FP,FPT,CL,CD:byte; {farba pisma, tmava cast, bleda cast}
begin
FP := 15;FPT:=0;
if Aktivita = false then FP:= 7;
CL := 15; CD := 8;
with Item do begin
if Stav = Stlaceny then begin
CL := 8; CD := 7;
FP:=15;FPT:=0;
end;
SetFillStyle(1,Mcolor);
bar(x1,y1,x2,y2);
SetColor(0);
line(x1,y1,x1,y2);line(x1,y1,x2,y1);
line(x2,y1,x2,y2);line(x1,y2,x2,y2);
SetColor(CL);
line(x1+1,y1+1,x1+1,y2-1);line(x1+1,y1+1,x2-1,y1+1);
SetColor(CD);
line(x1+2,y2-1,x2-1,y2-1);line(x2-1,y1+1,x2-1,y2-1);
if Stav = Stlaceny then begin
x1:=x1+1;y1:=y1+1;
Bx:=Bx+1;By:=By+1;
end;
PutBitmap(Bx,By,Dx,Dy,nFF,Bitmapa);