home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari FTP
/
ATARI_FTP_0693.zip
/
ATARI_FTP_0693
/
Tex
/
td187src.lzh
/
TEXTBOX.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
51KB
|
1,628 lines
IMPLEMENTATION MODULE TextBox ;
FROM SYSTEM IMPORT ADDRESS , ADR;
FROM Storage IMPORT ALLOCATE , DEALLOCATE ;
FROM OwnBoxes IMPORT MousePos, WaitForDepress;
IMPORT CommonData ;
IMPORT Diverses;
IMPORT Fill;
IMPORT HelpModule ;
IMPORT MagicAES ;
IMPORT MagicBIOS ;
IMPORT MagicStrings;
IMPORT MagicSys;
IMPORT MagicVDI ;
IMPORT MathLib0;
IMPORT mtAppl ;
IMPORT Types;
IMPORT Undo;
IMPORT Variablen ;
IMPORT VectorFont;
(**
IMPORT RTD;
**)
CONST UseXBIOS = FALSE;
TYPE XYArray = ARRAY [0..3] OF INTEGER;
VAR AlignMode : INTEGER;
Internal : BOOLEAN;
VectorFontMode : BOOLEAN;
storesize : LONGREAL;
storeslant : LONGREAL;
storeangle : INTEGER;
PROCEDURE SetVectorText(On : BOOLEAN);
(*
Schaltet auf Vektor-Zeichensatz um;
standardmä₧ig jedoch ausgeschaltet.
*)
BEGIN
VectorFontMode := On;
IF VectorFontMode THEN
VectorFontMode := VectorFont.FontsLoaded()>0;
END;
END SetVectorText;
PROCEDURE RoundedRect(pxy : ARRAY OF INTEGER);
VAR maxradius : INTEGER;
min : INTEGER;
radius : INTEGER;
MinX, MinY : INTEGER;
distx, disty : INTEGER;
line : ARRAY [0..3] OF INTEGER;
BEGIN
maxradius := Variablen.MaxCircle();
maxradius := Variablen.PicDistance(maxradius);
MinX := Diverses.min(pxy[0], pxy[2]);
MinY := Diverses.min(pxy[1], pxy[3]);
min := Diverses.min(ABS(pxy[2] - pxy[0]), ABS(pxy[3] - pxy[1]));
radius := Variablen.PicDistance(min DIV 2);
IF radius>maxradius THEN radius := maxradius; END;
IF min>0 THEN
distx := ABS(pxy[2] - pxy[0]) - 2*radius;
disty := ABS(pxy[3] - pxy[1]) - 2*radius;
(* Zeichne die 4 Eckkreise *)
(* Links oben *)
MagicVDI.Arc (mtAppl.VDIHandle , MinX + radius, MinY + radius,
radius , 900 , 1800) ;
(* Links unten *)
MagicVDI.Arc (mtAppl.VDIHandle , MinX + radius, MinY + radius + disty,
radius , 1800 , 2700) ;
(* Rechts unten *)
MagicVDI.Arc (mtAppl.VDIHandle , MinX + radius + distx, MinY + radius + disty,
radius , 2700 , 3600) ;
(* Rechts oben *)
MagicVDI.Arc (mtAppl.VDIHandle , MinX + radius + distx, MinY + radius,
radius , 0 , 900) ;
(* Und dann die Zwischenlinien *)
IF distx>0 THEN
line[0] := MinX + radius; line[1] := pxy[1];
line[2] := MinX + radius + distx; line[3] := pxy[1];
MagicVDI.Polyline (mtAppl.VDIHandle , 2 , line) ;
line[1] := pxy[3];
line[3] := pxy[3];
MagicVDI.Polyline (mtAppl.VDIHandle , 2 , line) ;
END;
IF disty>0 THEN
line[0] := pxy[0];
line[1] := MinY + radius;
line[2] := pxy[0];
line[3] := MinY + radius + disty;
MagicVDI.Polyline (mtAppl.VDIHandle , 2 , line) ;
line[0] := pxy[2];
line[2] := pxy[2];
MagicVDI.Polyline (mtAppl.VDIHandle , 2 , line) ;
END;
END;
END RoundedRect;
PROCEDURE FillBox(x1, y1, x2, y2 : INTEGER);
VAR pxy : XYArray;
i : INTEGER;
BEGIN
IF x1<x2 THEN
pxy[0] := x1; pxy[2] := x2;
ELSE
pxy[0] := x2; pxy[2] := x1;
END;
IF y1<y2 THEN
pxy[1] := y1; pxy[3] := y2;
ELSE
pxy[1] := y2; pxy[3] := y1;
END;
IF (x1<>x2) AND (y1<>y2) THEN
(**
FOR i:=0 TO 3 DO
RTD.ShowVar('pxy', pxy[i]);
END;
**)
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
MagicVDI.FillRectangle(mtAppl.VDIHandle, pxy);
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
END;
END FillBox;
PROCEDURE MakeBox (Style, FillMode : INTEGER ;
VAR XY : XYArray) : BOOLEAN ;
VAR
dum, x, y,
xo, yo, i,
picx, picy : INTEGER ;
xy , xyo : ARRAY [ 0..9 ] OF INTEGER ;
PxyArray : XYArray;
result : BOOLEAN;
delete : BOOLEAN;
lbut, rbut : BOOLEAN;
(* Style = -1 => RoundedBox *)
(* Style = -2 => FrameBox (wobei Box später gelöscht wird) *)
BEGIN
(**
RTD.Into('MakeBox');
**)
WaitForDepress(x, y);
(**
RTD.Message('Buttons released');
**)
MagicVDI.SetLineEndstyles (mtAppl.VDIHandle , MagicVDI.Cornerd , MagicVDI.Cornerd) ;
(**
RTD.Message('EndStyle ready');
**)
IF Style=-2 THEN
Style := 1;
delete := TRUE;
ELSE
delete := FALSE;
END;
IF Style <> -1 THEN
dum := MagicVDI.SetLinetype (mtAppl.VDIHandle , Style) ;
ELSE
dum := MagicVDI.SetLinetype (mtAppl.VDIHandle , MagicVDI.Line) ;
END;
(**
RTD.Message('Linetype ready');
**)
IF (Style=1) AND delete THEN
dum := MagicVDI.SetLinewidth (mtAppl.VDIHandle , 1);
ELSE
dum := MagicVDI.SetLinewidth (mtAppl.VDIHandle ,
CommonData.LineWidth) ;
END;
(**
RTD.Message('Linewidth ready');
**)
dum := MagicVDI.SetLinecolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
(**
RTD.Message('Linecolor ready');
**)
FOR i := 0 TO 4 DO
xy [ 2*i ] := x ;
xyo [ 2*i ] := x ;
xy [ 2*i + 1 ] := y ;
xyo [ 2*i + 1 ] := y ;
END ;
xo := x ; yo:=y ;
(**
RTD.Message('Entering repeat...');
**)
REPEAT
MousePos(x, y, picx, picy, lbut, rbut);
Variablen.Position (TRUE, x, y, xy[0], xy[1]) ;
IF (x <> xo) OR (y <> yo) THEN
IF Style<>-1 THEN
xy [ 2 ] := x ; xy [ 4 ] := x ;
xy [ 5 ] := y ; xy [ 7 ] := y ;
ELSE
xy [ 2 ] := x; xy [ 3 ] := y;
END;
(**
RTD.Message('Init. start');
**)
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.XOR) ;
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
Diverses.MouseOff;
(**
RTD.Message('Init. end');
**)
IF Style<>-1 THEN
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.XOR) ;
MagicVDI.Polyline (mtAppl.VDIHandle , 5 , xyo) ;
MagicVDI.Polyline (mtAppl.VDIHandle , 5 , xy) ;
IF (FillMode>=0) THEN
Fill.SetFillMode(FillMode);
(**
RTD.Message('Set Clip');
**)
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
(**
RTD.Message('Set WriteMode');
**)
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.XOR) ;
FillBox(xyo[0], xyo[1], xyo[4], xyo[5]);
FillBox(xy[0], xy[1], xy[4], xy[5]);
(*
MagicVDI.FilledArea(mtAppl.VDIHandle , 5, xyo);
MagicVDI.FilledArea(mtAppl.VDIHandle , 5, xy);
*)
Fill.SetFillMode(-1);
END;
ELSE
FOR i := 0 TO 3 DO
PxyArray[i] := xyo[i];
END;
RoundedRect (PxyArray);
FOR i := 0 TO 3 DO
PxyArray[i] := xy[i];
END;
RoundedRect (PxyArray);
END;
Diverses.MouseOn;
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.REPLACE) ;
IF Style<> -1 THEN
xyo [ 2 ] := x ; xyo [ 4 ] := x ;
xyo [ 5 ] := y ; xyo [ 7 ] := y ;
ELSE
xyo [ 2 ] := x ; xyo [ 3 ] := y ;
END;
xo := x ; yo := y ;
END ;
UNTIL lbut OR rbut;
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.XOR) ;
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
Diverses.MouseOff;
IF Style<>-1 THEN
IF (FillMode>=0) THEN
Fill.SetFillMode(FillMode);
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.XOR) ;
FillBox(xy[0], xy[1], xy[4], xy[5]);
Fill.SetFillMode(-1);
END;
MagicVDI.Polyline (mtAppl.VDIHandle , 5 , xy) ;
ELSE
FOR i := 0 TO 3 DO
PxyArray[i] := xy[i];
END;
RoundedRect (PxyArray);
END;
Diverses.MouseOn;
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.REPLACE) ;
IF lbut AND NOT rbut THEN
IF NOT delete THEN
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.REPLACE) ;
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
Diverses.MouseOff;
IF Style<>-1 THEN
IF FillMode=0 THEN
Fill.SetFillMode(FillMode);
FillBox(xy[0], xy[1], xy[4], xy[5]);
Fill.SetFillMode(-1);
ELSE
MagicVDI.Polyline (mtAppl.VDIHandle , 5 , xy) ;
END;
ELSE
FOR i := 0 TO 3 DO
PxyArray[i] := xy[i];
END;
RoundedRect (PxyArray);
END;
Diverses.MouseOn;
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
END;
(* Wir berechnen nun den linken UNTEREN Punkt *)
(* y-Achse ist umgekehrt bei GEM *)
IF Style <> -1 THEN
IF xy [ 0 ] < xy [ 4 ] THEN
XY [ 0 ] := xy [ 0 ] ;
XY [ 2 ] := xy [ 4 ] - xy [ 0 ] ; (* + 1 enfällt wegen LaTeX *)
ELSE
XY [ 0 ] := xy [ 4 ] ;
XY [ 2 ] := xy [ 0 ] - xy [ 4 ] ;
END ;
IF xy [ 1 ] > xy [ 5 ] THEN
XY [ 1 ] := xy [ 1 ] ;
XY [ 3 ] := xy [ 1 ] - xy [ 5 ] ;
ELSE
XY [ 1 ] := xy [ 5 ] ;
XY [ 3 ] := xy [ 5 ] - xy [ 1 ] ;
END ;
ELSE
FOR i:= 0 TO 3 DO
XY [ i ] := PxyArray [ i ] ;
END;
END ;
result := TRUE;
ELSE
result:= FALSE;
END ;
dum := MagicVDI.SetLinetype (mtAppl.VDIHandle , MagicVDI.Line) ;
(**
RTD.Leaving('MakeBox');
**)
RETURN result;
END MakeBox ;
PROCEDURE NrOfSublines(REF txt : ARRAY OF CHAR;
VAR maxsublinelen : INTEGER) : INTEGER;
VAR i, j, len, res, max : INTEGER;
BEGIN
i := 0;
j := 0;
res := 1;
max := 0;
len := LENGTH(txt);
WHILE (i<len) DO
IF txt[i]='\' THEN
IF txt[i+1]='\' THEN
(* Zeilenumbruch *)
INC(i, 1);
max := Diverses.max(max, j);
INC(res, 1);
j := 0;
ELSE
INC(j, 1);
END;
ELSE
INC(j, 1);
END;
INC(i, 1);
END;
max := Diverses.max(max, j);
maxsublinelen := max;
RETURN res;
END NrOfSublines;
PROCEDURE WriteText (VAR str : ARRAY OF CHAR ; len : INTEGER ;
Mode : INTEGER; xy : ARRAY OF INTEGER) ;
CONST MaxSubLines = 16;
TYPE Subline = ARRAY [0..Types.CharArraySize] OF CHAR;
VAR x, y, xo, yo, d : INTEGER ;
mode : Types.TextPosTyp ;
Sublines : ARRAY [0..MaxSubLines-1] OF Subline;
blank : ARRAY [0..1] OF CHAR;
i, j, NrSubs : INTEGER;
maxlen : INTEGER;
BEGIN
blank := ' ';
mode := VAL(Types.TextPosTyp, ORD(Mode));
NrSubs := 0;
(* Jetzt spalte den String in Sublines auf: *)
FOR i:=0 TO MaxSubLines-1 DO
Sublines[i, 0] := 0C;
END;
i := 0;
j := 0;
WHILE (i<len) DO
IF str[i]='\' THEN
IF str[i+1]='\' THEN
(* Zeilenumbruch *)
INC(i, 1);
IF NrSubs<MaxSubLines-1 THEN
Sublines[NrSubs, j] := 0C;
INC(NrSubs, 1);
j := 0;
Sublines[NrSubs,0 ] := 0C;
ELSE
INC(j, 1);
END;
ELSE
Sublines[NrSubs, j] := str[i];
Sublines[NrSubs, j+1] := 0C;
INC(j, 1);
END;
ELSE
Sublines[NrSubs, j] := str[i];
Sublines[NrSubs, j+1] := 0C;
INC(j, 1);
END;
INC(i, 1);
END;
maxlen := 0;
FOR i:=0 TO NrSubs DO
IF MagicSys.CastToInt(MagicStrings.Length(Sublines[i])) > maxlen THEN
maxlen := MagicSys.CastToInt(MagicStrings.Length(Sublines[i]));
END;
END;
IF (NrSubs>0) THEN
CASE AlignMode OF
0: (* center, vorn und hinten auffüllen *)
FOR i:=0 TO NrSubs DO
WHILE MagicSys.CastToInt(MagicStrings.Length(Sublines[i]))<maxlen DO
MagicStrings.Insert(blank, Sublines[i], 0);
IF MagicSys.CastToInt(MagicStrings.Length(Sublines[i]))<maxlen THEN
MagicStrings.Append(blank, Sublines[i]);
END;
END;
END; |
1: (* left, also Leerzeichen hinten auffüllen *)
FOR i:=0 TO NrSubs DO
WHILE MagicSys.CastToInt(MagicStrings.Length(Sublines[i]))<maxlen DO
MagicStrings.Append(blank, Sublines[i]);
END;
END; |
2: (* right, also vorne auffüllen *)
FOR i:=0 TO NrSubs DO
WHILE MagicSys.CastToInt(MagicStrings.Length(Sublines[i]))<maxlen DO
MagicStrings.Insert(blank, Sublines[i], 0);
END;
END; |
ELSE
END;
END;
CASE mode OF
Types.NoJust : xo := xy [ 0 ] ;
yo := xy [ 1 ] - NrSubs*16; |
Types.LeftTop : xo := xy [ 0 ] + 2 ;
yo := xy [ 1 ] + 16 ; |
Types.Left : xo := xy [ 0 ] + 2 ;
yo := xy [ 1 ] + (xy [ 3 ] DIV 2);
IF (NrSubs+1) MOD 2 = 0 THEN
(* gerade Anzahl *)
yo := yo - (((NrSubs+1) DIV 2)-1) * 16;
ELSE
(* ungerade Anzahl *)
yo := yo - (NrSubs DIV 2) * 16 + 8 ;
END; |
Types.LeftBot : xo := xy[0] + 2 ;
yo := xy[1] + xy[3] - 2 - NrSubs * 16;|
Types.Top : xo := xy[0];
yo := xy[1] + 16 ; |
Types.Bottom : xo := xy[0];
yo := xy[1] + xy[ 3 ] - 2 ; |
Types.RightTop : xo := xy[0] + xy[ 2 ] - 1 ;
yo := xy[1] + 16 ; |
Types.Right : xo := xy[0] + xy[ 2 ] - 1 ;
yo := xy[1] + (xy[3] DIV 2);
IF (NrSubs+1) MOD 2 = 0 THEN
(* gerade Anzahl *)
yo := yo - (((NrSubs+1) DIV 2)-1) * 16;
ELSE
(* ungerade Anzahl *)
yo := yo - (NrSubs DIV 2) * 16 + 8 ;
END; |
Types.RightBot : xo := xy [0] + xy [2] - 1 ;
yo := xy [1] + xy [3] - 2 - NrSubs * 16 ; |
Types.Center : xo := xy [ 0 ];
yo := xy [ 1 ] + (xy [ 3 ] DIV 2);
IF (NrSubs+1) MOD 2 = 0 THEN
(* gerade Anzahl *)
yo := yo - (((NrSubs+1) DIV 2)-1) * 16;
ELSE
(* ungerade Anzahl *)
yo := yo - (NrSubs DIV 2) * 16 + 8 ;
END; |
ELSE
END ;
IF NOT Internal THEN
Diverses.MouseOff;
END;
FOR i:=0 TO NrSubs DO
y := yo + i * 16;
j := MagicStrings.Length(Sublines[i]);
CASE mode OF
Types.LeftTop, Types.NoJust, Types.Left, Types.LeftBot :
x := xo; |
Types.Top, Types.Bottom, Types.Center :
x := xo + ((xy[2] - j*8) DIV 2) ; |
Types.Right, Types.RightTop, Types.RightBot :
x := xo - (j*8); |
ELSE
x := xo; (* Sollte nie auftreten *)
END ;
d := MagicVDI.SetTextcolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
MagicVDI.SetTextalignment (mtAppl.VDIHandle ,
MagicVDI.BaseJust , MagicVDI.BottomJust ,
d ,d) ;
IF NOT Internal THEN
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
END;
MagicVDI.Text (mtAppl.VDIHandle , x , y , Sublines[i]) ;
IF NOT Internal THEN
MagicVDI.SetClipping (mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
END;
MagicVDI.SetTextalignment (mtAppl.VDIHandle ,
MagicVDI.BaseJust , MagicVDI.BaseJust ,
d ,d) ;
END ;
IF NOT Internal THEN
Diverses.MouseOn;
END ;
END WriteText ;
PROCEDURE MakeDialog (VAR str : ARRAY OF CHAR ;
VAR len, align : INTEGER ;
mode : INTEGER ;
xy : ARRAY OF INTEGER) ;
VAR dum, i : INTEGER ;
char, scan : CHAR ;
shift, ok : BOOLEAN;
emp : ARRAY [ 0..1 ] OF CHAR ;
helptxt : ARRAY [0..39] OF CHAR;
long : LONGCARD;
card : CARDINAL;
hilo : RECORD
CASE : BOOLEAN OF
TRUE : long : LONGCARD; |
FALSE: hi, lo : CARDINAL; |
END;
END;
fontsize, fontslant : LONGREAL;
oldsize, oldslant : LONGREAL;
fontnum, fontangle : INTEGER;
oldnum, oldangle : INTEGER;
newfont : INTEGER;
xp, yp, xc, yc : INTEGER;
CONST NUL = 0C ; LF = 12C; CR = 15C ; BS = 10C ; BL = 40C ;
(* Null , Return , Backspace und Blank *)
PROCEDURE GetPos(xy : ARRAY OF INTEGER;
VAR xp, yp : INTEGER;
str : ARRAY OF CHAR);
VAR mypos : ARRAY [0..3] OF INTEGER;
newpos : ARRAY [0..7] OF INTEGER;
i, xo, yo : INTEGER;
xmin, xmax, ymin, ymax : INTEGER;
BEGIN
mypos[0] := 0; (* x0 *)
mypos[1] := 0; (* y0 *)
mypos[2] := VectorFont.TextWidth(str);
mypos[3] := VectorFont.TextHeight(str);
(* (6,7) +---------------+ (4,5) *)
(* | | *)
(* (0,1) +---------------+ (2,3) *)
VectorFont.TurnedVal(mypos[0], mypos[1], newpos[0], newpos[1]);
VectorFont.TurnedVal(mypos[2], mypos[1], newpos[2], newpos[3]);
VectorFont.TurnedVal(mypos[2], mypos[3], newpos[4], newpos[5]);
VectorFont.TurnedVal(mypos[0], mypos[3], newpos[6], newpos[7]);
xmin := newpos[0]; xmax := newpos[0];
ymin := newpos[1]; ymax := newpos[1];
FOR i:=1 TO 3 DO
IF newpos[i*2 ]<xmin THEN xmin := newpos[i*2 ]; END;
IF newpos[i*2 ]>xmax THEN xmax := newpos[i*2 ]; END;
IF newpos[i*2+1]<ymin THEN ymin := newpos[i*2+1]; END;
IF newpos[i*2+1]>ymax THEN ymax := newpos[i*2+1]; END;
END;
(**
RTD.ShowVar('Width', mypos[2]);
RTD.ShowVar('Height', mypos[3]);
RTD.ShowVar('xmin', xmin);
RTD.ShowVar('ymin', ymin);
RTD.ShowVar('xmax', xmax);
RTD.ShowVar('ymax', ymax);
FOR i:=0 TO 3 DO
RTD.ShowVar('xy[i]', xy[i]);
END;
**)
CASE VAL(Types.TextPosTyp, ORD(mode)) OF
Types.NoJust : xo := xy [ 0 ] ;
yo := xy [ 1 ] ; |
Types.LeftTop : xo := xy [ 0 ] + 2;
yo := xy [ 1 ] + (ymax-ymin); |
Types.Left : xo := xy [ 0 ] + 2 ;
yo := xy[1] + (xy[3]+ymax-ymin) DIV 2 ; |
Types.LeftBot : xo := xy[0] + 2 ;
yo := xy[1] + xy[3] - 2; |
Types.Top : xo := xy[0] + (xy[2]-xmax+xmin) DIV 2 ;
yo := xy[1] + (ymax-ymin) ; |
Types.Bottom : xo := xy[0] + (xy[2]-xmax+xmin) DIV 2 ;
yo := xy[1] + xy[3] - 2; |
Types.RightTop : xo := xy[0] + xy[2] - (xmax-xmin) ;
yo := xy[1] + (ymax-ymin); |
Types.Right : xo := xy[0] + xy[2] - (xmax-xmin) ;
yo := xy[1] + (xy[3]+ymax-ymin) DIV 2 ; |
Types.RightBot : xo := xy[0] + xy[2] - (xmax-xmin) ;
yo := xy[1] + xy[3] - 2; |
Types.Center : xo := xy[0] + (xy[2]-xmax+xmin) DIV 2;
yo := xy[1] + (xy[3]+ymax-ymin) DIV 2 ; |
ELSE
END ;
(**
RTD.ShowVar('xo', xo);
RTD.ShowVar('yo', yo);
**)
xp := xo;
yp := yo;
END GetPos;
PROCEDURE AddFontSize(val : INTEGER);
BEGIN
fontsize := fontsize + MathLib0.real(val)/100.0;
IF fontsize<1.0 THEN
fontsize := 1.0;
END;
END AddFontSize;
PROCEDURE AddAngle(val : INTEGER);
BEGIN
fontangle := fontangle + val;
IF fontangle<0 THEN
WHILE fontangle<0 DO
fontangle := fontangle + 360;
END;
END;
IF fontangle>=360 THEN
fontangle := fontangle MOD 360;
END;
END AddAngle;
PROCEDURE AddSlant(val : LONGREAL);
BEGIN
fontslant := fontslant + val;
IF fontslant>3.5 THEN
fontslant := 3.5;
END;
IF fontslant<-3.5 THEN
fontslant := -3.5;
END;
END AddSlant;
PROCEDURE LoescheQueue;
(* Schamlos aus dem GME geklaut ;-) *)
VAR localEvents : BITSET;
MoX,MoY : INTEGER ;
MoButton : BITSET ;
MoKState : BITSET ;
KBtaste : INTEGER ;
KBscan : INTEGER ;
KBascii : CHAR ;
MoClicks : INTEGER ;
MessagePipe : ARRAY [ 0..15 ] OF INTEGER ;
M1rect,
M2rect : ARRAY [0..3] OF INTEGER;
BEGIN
(* UpdateWindow (FALSE); *)
REPEAT
(* KeyBoardEvent (key); *)
(* hm... wie soll das gehen, ehe ich nicht wei₧, ob noch
KeyBoardEvents anhängig sind??? *)
localEvents:=
MagicAES.EvntMulti (
BITSET{MagicAES.MUKEYBD,
MagicAES.MUTIMER}, 0,
BITSET{}, BITSET{},
MagicAES.EnterRect, M1rect,
MagicAES.EnterRect, M2rect,
MessagePipe,
0, 0, (* MUSS NULL SEIN, sonst geht Autorepeat nicht!? *)
MoX, MoY, MoButton, KBtaste,
MoKState, KBscan, KBascii, MoClicks) ;
UNTIL NOT (MagicAES.MUKEYBD IN localEvents);
(* UpdateWindow (TRUE); *)
END LoescheQueue;
PROCEDURE GetGEMKey(VAR char, scan : CHAR;
VAR shift : BOOLEAN);
(* Schamlos aus dem GME geklaut ;-) *)
VAR localEvents : BITSET;
MoX,MoY : INTEGER ;
MoButton : BITSET ;
MoKState : BITSET ;
KBtaste : INTEGER ;
KBscan : INTEGER ;
KBascii : CHAR ;
MoClicks : INTEGER ;
MessagePipe : ARRAY [ 0..15 ] OF INTEGER ;
M1rect,
M2rect : ARRAY [0..3] OF INTEGER;
BEGIN
localEvents:=
MagicAES.EvntMulti (
BITSET{MagicAES.MUKEYBD}, 0,
BITSET{}, BITSET{},
MagicAES.EnterRect, M1rect,
MagicAES.EnterRect, M2rect,
MessagePipe,
0, 0, (* MUSS NULL SEIN, sonst geht Autorepeat nicht!? *)
MoX, MoY, MoButton, KBtaste,
MoKState, KBscan, KBascii, MoClicks) ;
char := KBascii;
scan := CHR(ORD(KBscan));
shift := (MagicAES.KLSHIFT IN MoKState) OR (MagicAES.KRSHIFT IN MoKState);
END GetGEMKey;
BEGIN
(**
RTD.Into('MakeDialog');
**)
fontsize := 1.0; (* normal *)
fontangle := 0; (* horizontal *)
fontslant := 0.0; (* keine Neigung *)
fontnum := CommonData.CurrentVectorFont; (* aktueller Font *)
oldnum := fontnum;
oldslant := fontslant;
oldsize := fontsize;
oldangle := fontangle;
AlignMode := 0; (* center *)
Diverses.MouseOff;
IF VectorFontMode THEN
Diverses.GetHelpText(16, helptxt);
ok := VectorFont.SetFont(fontnum);
VectorFont.SetTextStyle (fontsize * Variablen.zoomfak,
fontsize * Variablen.zoomfak,
fontslant, fontangle);
ELSE
Diverses.GetHelpText(15, helptxt);
END;
FOR i:=0 TO MagicSys.CastToInt(MagicStrings.Length(helptxt)) DO
IF helptxt[i] ='<' THEN helptxt[i] := 4C; END;
IF helptxt[i] ='>' THEN helptxt[i] := 3C; END;
IF helptxt[i] ='^' THEN helptxt[i] := 1C; END;
IF helptxt[i] ='_' THEN helptxt[i] := 2C; END;
END;
HelpModule.HelpMessage(helptxt);
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.XOR) ;
FOR dum := 0 TO Types.CharArraySize-1 DO str [ dum ] := NUL END ;
(**
RTD.Message('Set to zero, ready');
**)
(* Simuliere Cursor *)
emp := "|";
len := 0 ;
IF VectorFontMode THEN
GetPos(xy, xp, yp, emp);
VectorFont.EnableCache(TRUE);
VectorFont.OutText(xp, yp, emp);
ELSE
Internal := FALSE;
WriteText (emp , 1 , mode , xy) ;
END;
(* Tastaturpuffer leeren *)
(*$? UseXBIOS:
WHILE MagicBIOS.Bconstat (MagicBIOS.CON) DO
long := MagicBIOS.Bconin (MagicBIOS.CON) ;
END ;
*)
(*$? NOT UseXBIOS:
LoescheQueue;
*)
REPEAT
(*$? UseXBIOS:
long := MagicBIOS.Bconin (MagicBIOS.CON) ;
hilo.long := long;
char := CHR(hilo.lo);
scan := CHR(hilo.hi);
card := MagicSys.CastToCard(long MOD 10000H);
*)
(*$? NOT UseXBIOS:
GetGEMKey(char, scan, shift);
LoescheQueue;
*)
(* Alten String löschen *)
IF len = 0 THEN
IF VectorFontMode THEN
VectorFont.AgainText;
ELSE
Internal := FALSE;
WriteText (emp , 1 , mode , xy) ;
END;
ELSE
IF VectorFontMode THEN
VectorFont.AgainText;
(**
GetPos(xy, xp, yp, str);
VectorFont.OutText(xp, yp, str);
**)
ELSE
Internal := FALSE;
WriteText (str , len+1 , mode , xy) ;
END;
END ;
IF (char= NUL) THEN
CASE scan OF
73C..75C : (* F1..F3 *)
dum := ORD(scan) -ORD(73C);
IF VectorFontMode THEN
newfont := dum+1;
ELSE
AlignMode := dum; (* center, left, right *)
END; |
76C..104C : (* F4..F10 *)
dum := ORD(scan) - ORD(73C) + 1;
IF VectorFontMode THEN
newfont := dum;
END; |
113C : (* left arrow *)
IF VectorFontMode THEN
AddAngle(+5);
END; |
115C : (* right arrow *)
IF VectorFontMode THEN
AddAngle(-5);
END; |
163C : (* Ctrl left arrow *)
IF VectorFontMode THEN
AddAngle(45);
END; |
164C : (* Ctrl right arrow *)
IF VectorFontMode THEN
AddAngle(-45);
END; |
110C : (* Up arrow *)
IF VectorFontMode THEN
AddFontSize(10);
END; |
120C : (* Down arrow *)
IF VectorFontMode THEN
AddFontSize(-10);
END; |
141C : (* Undo *)
IF VectorFontMode THEN
fontsize := storesize;
fontangle := storeangle;
fontslant := storeslant;
END; |
142C : (* Help *)
IF VectorFontMode THEN
storesize := fontsize;
storeangle := fontangle;
storeslant := fontslant;
END; |
ELSE
END;
ELSIF char = LF THEN
str[len] := '\';
str[len+1] := '\';
str[len+2] := '|';
INC(len, 2);
ELSIF char = BS THEN
IF len > 0 THEN
IF (len>1) AND (str [len-1]='\') AND (str[len-2]='\') THEN
(* CR löschen *)
len := len - 1 ;
str [ len ] := NUL ;
END;
len := len - 1 ;
str [ len ] := '|' ;
str [ len + 1 ] := NUL ;
END ;
ELSIF (char=33C) THEN (* ESC *)
(* gesamten String löschen *)
FOR dum := 0 TO len DO
str[dum] := NUL;
END;
len := 0;
ELSIF (scan='H') AND (char='8') THEN (* Shift-Cursor-Up-Taste *)
IF VectorFontMode THEN
AddFontSize(50);
END;
ELSIF (scan='M') AND (char='6') THEN (* Shift-Cursor-Right-Taste *)
IF VectorFontMode THEN
AddSlant(+0.1);
END;
ELSIF (scan='P') AND (char='2') THEN (* Shift-Cursor-Down-Taste *)
IF VectorFontMode THEN
AddFontSize(-50);
END;
ELSIF (scan='K') AND (char='4') THEN (* Shift-Cursor-Left-Taste *)
IF VectorFontMode THEN
AddSlant(-0.1);
END;
ELSE
IF ORD (char) >= 32 THEN
str [ len ] := char ;
str [ len + 1 ] := '|' ;
len := len + 1 ;
END ;
END ;
(* Neuen String schreiben *)
IF VectorFontMode THEN
IF newfont>0 THEN
ok := VectorFont.FontsLoaded()>=newfont;
IF ok THEN
fontnum := newfont;
END;
newfont := -1;
END;
END;
IF VectorFontMode THEN
IF oldnum<>fontnum THEN
ok := VectorFont.SetFont(fontnum);
oldnum := fontnum;
END;
IF (oldangle<>fontangle) OR
(oldsize <>fontsize) OR
(oldslant<>fontslant) THEN
VectorFont.SetTextStyle (fontsize * Variablen.zoomfak,
fontsize * Variablen.zoomfak,
fontslant, fontangle);
oldsize := fontsize;
oldslant := fontslant;
oldangle := fontangle;
END;
END;
IF len = 0 THEN
IF VectorFontMode THEN
GetPos(xy, xp, yp, emp);
VectorFont.OutText (xp, yp, emp);
ELSE
Internal := FALSE;
WriteText (emp , 1 , mode , xy) ;
END;
ELSE
IF VectorFontMode THEN
GetPos(xy, xp, yp, str);
VectorFont.OutText (xp, yp, str);
ELSE
Internal := FALSE;
WriteText (str , len+1 , mode , xy) ;
END;
END ;
UNTIL (char = CR) OR (len = Types.CharArraySize-2) ;
(* Zum Schlu₧ String löschen ... *)
IF len = 0 THEN
IF VectorFontMode THEN
(**
GetPos(xy, xp, yp, emp);
VectorFont.OutText (xp, yp, emp);
**)
VectorFont.AgainText;
ELSE
Internal := FALSE;
WriteText (emp , 1 , mode , xy) ;
END;
ELSE
IF VectorFontMode THEN
VectorFont.AgainText;
(**
GetPos(xy, xp, yp, str);
VectorFont.OutText (xp, yp, str);
**)
ELSE
Internal := FALSE;
WriteText (str , len+1 , mode , xy) ;
END;
END ;
(* ... und String im neuen Modus schreiben. *)
str [ len ] := NUL ;
dum := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.TRANSPARENT) ;
IF len > 0 THEN
IF VectorFontMode THEN
GetPos(xy, xp, yp, str);
Variablen.PixToPic (xp, yp, xc, yc);
VectorFont.OutText (xp, yp, str);
VectorFont.SetTextStyle (fontsize, fontsize, fontslant, fontangle);
Undo.PrepareUndo(TRUE);
VectorFont.CreateText (xc, yc, str);
VectorFont.EnableCache(FALSE);
ELSE
Internal := FALSE;
WriteText (str , len , mode , xy) ;
END;
END ;
Diverses.MouseOn;
align := AlignMode;
(**
RTD.Leaving('MakeDialog');
**)
END MakeDialog ;
(*------------------------------------------------------------------------*)
PROCEDURE Text () ;
VAR xy : XYArray ; ptr : Types.CharPtrTyp ;
but : BITSET;
len , dum , x , y , i : INTEGER ;
pxy : Types.CodeAryTyp ;
Surround : XYArray;
BEGIN
WaitForDepress(x, y);
xy [ 0 ] := x ; xy [ 1 ]:= y ;
xy [ 2 ] := 1 ; xy [ 3 ]:= 1 ;
NEW (ptr) ;
FOR i := 0 TO Types.CharArraySize-2 DO ptr^ [ i ] := CHR (0) END ;
MakeDialog (ptr^ , len , i, ORD(Types.NoJust) , xy) ;
IF (len > 0) AND NOT VectorFontMode THEN
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
pxy [ 0 ] := ORD(Types.Text) ;
Variablen.PixToPic (xy [ 0 ] , xy [ 1 ] , pxy [ 1 ] , pxy [ 2 ]);
pxy [ 5 ] := MagicSys.CastToInt(ORD(Types.NoJust));
pxy [ 7 ] := AlignMode ;
pxy [ 8 ] := CommonData.LineWidth ;
pxy [ 9 ] := len ;
IF (len > 0) AND NOT VectorFontMode THEN
(* reiner Test: *)
y := 16 * NrOfSublines(ptr^, i);
x := 8 * i;
pxy [ 3 ] := x;
pxy [ 4 ] := y;
Surround[0] := pxy[1]; Surround[1] := pxy[2] -1 + y;
Surround[2] := x; Surround[3] := y;
Undo.PrepareUndo(TRUE);
Variablen.NewObject (pxy , ptr, NIL, Surround) ;
END ;
END ;
DISPOSE (ptr) ;
END Text ;
PROCEDURE BoxText () ;
VAR xy , xyo : XYArray ;
ptr : Types.CharPtrTyp ;
RectSurr : ARRAY [0..59] OF CHAR;
x, y, len, mode, i : INTEGER ; but : BITSET;
ok : BOOLEAN;
pxy : Types.CodeAryTyp ;
Surround : XYArray;
BEGIN
NEW (ptr) ;
FOR i := 0 TO Types.CharArraySize-2 DO ptr^ [ i ] := CHR (0) END ;
Diverses.GetHelpText(14, RectSurr);
HelpModule.HelpMessage(RectSurr);
ok := MakeBox (-2 , -1, xy);
IF ok THEN
(* Gibt linken unteren Punkt und Ausma₧e zurück *)
(* WriteText arbeitet mit linkem oberen Punkt *)
Surround [0] := xy[0]; Surround [1] := xy[1] - xy [3];
Surround [2] := xy[2]; Surround [3] := xy[3];
FOR i:= 0 TO 3 DO
xyo[i] := Surround[i];
END;
Surround [2] := Variablen.PicDistance(xy[2]);
Surround [3] := Variablen.PicDistance(xy[3]);
Variablen.PixToPic (xyo[0], xyo[1], Surround[0], Surround[1]);
MakeDialog (ptr^ , len , i, ORD(CommonData.TextPosition) , xyo) ;
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
pxy [ 0 ] := ORD(Types.Framebox) ;
Variablen.PixToPic (xy [ 0 ] , xy [ 1 ] , pxy [ 1 ] , pxy [ 2 ]) ;
pxy [ 3 ] := Variablen.PicDistance(xy [ 2 ]);
pxy [ 4 ] := Variablen.PicDistance(xy [ 3 ]);
pxy [ 7 ] := AlignMode;
pxy [ 8 ] := CommonData.LineWidth ;
IF (len > 0) AND NOT VectorFontMode THEN
pxy [ 5 ] := ORD(CommonData.TextPosition) ;
pxy [ 6 ] := 1 ; (* Flag für Makebox *)
pxy [ 9 ] := len ;
Undo.PrepareUndo(TRUE);
Variablen.NewObject (pxy , ptr, NIL, Surround) ;
END ;
END;
DISPOSE (ptr) ;
END BoxText ;
PROCEDURE FrameText () ;
VAR xy , xyo : XYArray ;
ptr : Types.CharPtrTyp ;
obj : Types.ObjectPtrTyp ;
len, mode, i : INTEGER ;
pxy : Types.CodeAryTyp ;
Surround : XYArray;
RectSurr : ARRAY [0..59] OF CHAR;
BEGIN
obj := Variablen.LastObject;
NEW (ptr) ;
FOR i := 0 TO Types.CharArraySize-2 DO ptr^ [ i ] := CHR (0) END ;
Diverses.GetHelpText(14, RectSurr);
HelpModule.HelpMessage(RectSurr);
IF MakeBox (1 , -1, xy) THEN
(* Gibt linken unteren Punkt und Ausma₧e zurück *)
(* WriteText arbeitet mit linkem oberen Punkt *)
Surround [0] := xy[0]; Surround [1] := xy[1] - xy [3];
Surround [2] := xy[2]; Surround [3] := xy[3];
FOR i:= 0 TO 3 DO
xyo[i] := Surround[i];
END;
Surround [2] := Variablen.PicDistance(xy[2]);
Surround [3] := Variablen.PicDistance(xy[3]);
Variablen.PixToPic (xyo[0], xyo[1], Surround[0], Surround[1]);
MakeDialog (ptr^ , len , i, ORD(CommonData.TextPosition) , xyo) ;
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
pxy [ 0 ] := ORD(Types.Framebox) ;
Variablen.PixToPic (xy [ 0 ] , xy [ 1 ] , pxy [ 1 ] , pxy [ 2 ]) ;
pxy [ 3 ] := Variablen.PicDistance(xy [ 2 ]);
pxy [ 4 ] := Variablen.PicDistance(xy [ 3 ]);
pxy [ 7 ] := AlignMode;
pxy [ 8 ] := CommonData.LineWidth ;
IF (len > 0) AND NOT VectorFontMode THEN
pxy [ 5 ] := ORD(CommonData.TextPosition) ;
pxy [ 9 ] := len ;
Undo.PrepareUndo(TRUE);
Variablen.NewObject (pxy , ptr, NIL, Surround) ;
ELSE
Variablen.NewObject (pxy , NIL, NIL, Surround) ;
(**
Variablen.MergeToSubpic(obj, pxy[1], pxy[2], pxy[3], pxy[4]);
**)
END ;
END;
DISPOSE (ptr) ;
END FrameText ;
PROCEDURE DashText () ;
VAR xy , xyo : XYArray ; ptr : Types.CharPtrTyp ;
len : INTEGER ; mode , i : INTEGER ;
pxy : Types.CodeAryTyp ;
Surround : XYArray;
obj : Types.ObjectPtrTyp ;
RectSurr : ARRAY [0..59] OF CHAR;
BEGIN
obj := Variablen.LastObject;
NEW (ptr) ;
FOR i := 0 TO Types.CharArraySize-2 DO ptr^ [ i ] := CHR (0) END ;
Diverses.GetHelpText(14, RectSurr);
HelpModule.HelpMessage(RectSurr);
IF MakeBox (5 , -1, xy) THEN
(* Gibt linken unteren Punkt zurück *)
(* WriteText arbeitet mit linkem oberen Punkt *)
Surround [0] := xy[0]; Surround [1] := xy[1] - xy [3];
Surround [2] := xy[2]; Surround [3] := xy[3];
FOR i:= 0 TO 3 DO
xyo[i] := Surround[i];
END;
Surround [2] := Variablen.PicDistance(xy[2]);
Surround [3] := Variablen.PicDistance(xy[3]);
Variablen.PixToPic (xyo[0], xyo[1], Surround[0], Surround[1]);
MakeDialog (ptr^ , len , i, ORD(CommonData.TextPosition) , xyo) ;
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
pxy [ 0 ] := ORD(Types.Dashbox) ;
Variablen.PixToPic (xy [ 0 ] , xy [ 1 ] , pxy [ 1 ] , pxy [ 2 ]) ;
pxy [ 3 ] := Variablen.PicDistance(xy [ 2 ]);
pxy [ 4 ] := Variablen.PicDistance(xy [ 3 ]);
pxy [ 7 ] := AlignMode;
pxy [ 8 ] := CommonData.LineWidth ;
IF (len > 0) AND NOT VectorFontMode THEN
pxy [ 5 ] := ORD(CommonData.TextPosition) ;
pxy [ 9 ] := len ;
Undo.PrepareUndo(TRUE);
Variablen.NewObject (pxy , ptr, NIL, Surround) ;
ELSE
Variablen.NewObject (pxy , NIL, NIL, Surround) ;
(**
Variablen.MergeToSubpic(obj, pxy[1], pxy[2], pxy[3], pxy[4]);
**)
END ;
END ;
DISPOSE (ptr) ;
END DashText ;
PROCEDURE FrameBox () ;
VAR xy : XYArray ;
Surround : XYArray;
pxy : Types.CodeAryTyp ;
i, X, Y : INTEGER ;
HelpRect : ARRAY [0..59] OF CHAR;
BEGIN
Diverses.GetHelpText(12, HelpRect);
HelpModule.HelpMessage(HelpRect);
IF MakeBox (1 , -1, xy) THEN
X := xy[0]; Y := xy[1] - xy [3];
Surround [2] := Variablen.PicDistance(xy[2]);
Surround [3] := Variablen.PicDistance(xy[3]);
Variablen.PixToPic (X, Y, Surround[0], Surround[1]);
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
pxy [ 0 ] := ORD(Types.Framebox) ;
Variablen.PixToPic (xy [ 0 ] , xy [ 1 ] , pxy [ 1 ] , pxy [ 2 ]) ;
pxy [ 3 ] := Variablen.PicDistance(xy [ 2 ]);
pxy [ 4 ] := Variablen.PicDistance(xy [ 3 ]);
pxy [ 8 ] := CommonData.LineWidth ;
Undo.PrepareUndo(TRUE);
Variablen.NewObject (pxy , NIL, NIL, Surround) ;
END;
END FrameBox ;
PROCEDURE DashBox () ;
VAR xy : XYArray ;
Surround : XYArray;
pxy : Types.CodeAryTyp ;
i, X, Y : INTEGER ;
HelpRect : ARRAY [0..59] OF CHAR;
BEGIN
Diverses.GetHelpText(12, HelpRect);
HelpModule.HelpMessage(HelpRect);
IF MakeBox (5 , -1 , xy) THEN
X := xy[0]; Y := xy[1] - xy [3];
Surround [2] := Variablen.PicDistance(xy[2]);
Surround [3] := Variablen.PicDistance(xy[3]);
Variablen.PixToPic (X, Y, Surround[0], Surround[1]);
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
pxy [ 0 ] := ORD(Types.Dashbox) ;
Variablen.PixToPic (xy [ 0 ] , xy [ 1 ] , pxy [ 1 ] , pxy [ 2 ]) ;
pxy [ 3 ] := Variablen.PicDistance(xy [ 2 ]);
pxy [ 4 ] := Variablen.PicDistance(xy [ 3 ]);
pxy [ 8 ] := CommonData.LineWidth ;
Undo.PrepareUndo(TRUE);
Variablen.NewObject (pxy , NIL, NIL, Surround) ;
END;
END DashBox ;
PROCEDURE OvalBox () ;
VAR xy : XYArray ;
Surround : XYArray;
pxy : Types.CodeAryTyp ;
i, X, Y : INTEGER ;
dum1, dum2 : INTEGER;
HelpRect : ARRAY [0..59] OF CHAR;
BEGIN
Diverses.GetHelpText(12, HelpRect);
HelpModule.HelpMessage(HelpRect);
IF MakeBox (-1 , -1, xy) THEN
(* es wird nicht wie üblich der linke untere Punkt und die Ausma₧e *)
(* geliefert, sondern die beiden gegenüberliegenden Eckpunkte! *)
IF xy[0]<xy[2] THEN X := xy[0]; ELSE X := xy[2]; END;
IF xy[1]<xy[3] THEN Y := xy[1]; ELSE Y := xy[3]; END;
Variablen.PixToPic (X, Y, Surround[0], Surround[1]);
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
pxy [ 0 ] := ORD(Types.Ovalbox) ;
pxy [ 8 ] := CommonData.LineWidth ;
dum1 := (xy [ 0 ] + xy [ 2 ]) DIV 2;
dum2 := (xy [ 1 ] + xy [ 3 ]) DIV 2;
Variablen.PixToPic (dum1, dum2 , pxy [ 1 ] , pxy [ 2 ]) ;
Variablen.PixToPic (xy[0], xy[1] , pxy [ 3 ] , pxy [ 4 ]) ;
pxy [ 3 ] := 2 * ABS(pxy[1]-pxy[3]);
pxy [ 4 ] := 2 * ABS(pxy[2]-pxy[4]);
Surround [2] := pxy[3];
Surround [3] := pxy[4];
(**
Surround [2] := ABS(xy[2]-xy[0]);
Surround [3] := ABS(xy[3]-xy[1]);
**)
Undo.PrepareUndo(TRUE);
Variablen.NewObject (pxy , NIL, NIL, Surround) ;
END;
END OvalBox ;
PROCEDURE FilledBox (FillMode : INTEGER);
(*
0 : solid,
1 : horfill,
2 : verfill,
3 : horverfill,
4 : leftfill,
5 : rightfill,
6 : lftrghtfill
*)
VAR xy : XYArray ;
pxy : Types.CodeAryTyp ;
i, X, Y : INTEGER ;
dum : INTEGER;
Surround : XYArray;
PxyArray : XYArray;
fillstyleindex, fillstyle : INTEGER;
HelpRect : ARRAY [0..59] OF CHAR;
BEGIN
(**
RTD.ShowVar('Fillmode', FillMode);
**)
Diverses.GetHelpText(12, HelpRect);
HelpModule.HelpMessage(HelpRect);
IF FillMode=0 THEN
i := 1;
ELSE
i := -2;
END;
dum := FillMode;
IF MakeBox (i , dum, xy) THEN
X := xy[0];
Y := xy[1] - xy[3];
Surround [2] := Variablen.PicDistance(xy[2]);
Surround [3] := Variablen.PicDistance(xy[3]);
Variablen.PixToPic (X, Y, Surround[0], Surround[1]);
FOR i := 0 TO 9 DO pxy [ i ] := 0 END ;
IF FillMode=0 THEN
pxy [ 0 ] := ORD(Types.Filledbox) ;
ELSE
pxy [ 0 ] := ORD(Types.Framebox) ;
END;
Variablen.PixToPic ( xy [ 0 ] , xy [ 1 ] ,
pxy [ 1 ] , pxy [ 2 ]) ;
pxy [ 3 ] := Variablen.PicDistance(xy [ 2 ]);
pxy [ 4 ] := Variablen.PicDistance(xy [ 3 ]);
pxy [ 8 ] := CommonData.LineWidth ;
(**
FOR i := 0 TO 3 DO
RTD.ShowVar('Sur', Surround[i]);
END;
FOR i := 0 TO 9 DO
RTD.ShowVar('pxy', pxy[i]);
END;
**)
Variablen.NewObject (pxy , NIL, NIL, Surround) ;
END;
(**
RTD.Leaving('FilledBox');
**)
END FilledBox;
PROCEDURE Show (Object : Types.ObjectPtrTyp) ;
VAR xy : ARRAY [ 0..9 ] OF INTEGER ; dum , style : INTEGER ;
xya : XYArray ;
str : ARRAY [ 0..Types.CharArraySize ] OF CHAR ;
X0, Y0, DX, DY : INTEGER;
fillstyle, fillstyleindex : INTEGER;
PxyArray : XYArray;
nodraw : BOOLEAN;
tmpstr : ARRAY [0..255] OF CHAR;
BEGIN
Internal := TRUE;
Variablen.PicToPix (xy [ 0 ] , xy [ 1 ] ,
Object^.Code [ 1 ] ,
Object^.Code [ 2 ]) ;
(**
RTD.Message('Coord ready');
**)
IF VAL(Types.DrawObjectTyp, Object^.Code [ 0 ]) <>
Types.Ovalbox THEN
(**
RTD.Message('Not Ovalbox');
**)
(* wir haben linken UNTEREN Punkt gespeichert *)
DX := Variablen.PixDistance(Object^.Code[3]);
DY := Variablen.PixDistance(Object^.Code[4]);
X0 := xy[0];
Y0 := xy[1] - DY;
xy [ 4 ] := xy [ 0 ] + DX ; (* -1 entfällt , LaTeX ! *)
xy [ 5 ] := xy [ 1 ] - DY ; (* Diagonalpunkt *)
xy [ 2 ] := xy [ 4 ] ; xy [ 3 ] := xy [ 1 ] ;
xy [ 6 ] := xy [ 0 ] ; xy [ 7 ] := xy [ 5 ] ;
xy [ 8 ] := xy [ 0 ] ; xy [ 9 ] := xy [ 1 ] ;
(* WriteText arbeitet mit linkem oberen Punkt *)
xya [ 0 ] := xy [ 0 ] ;
xya [ 1 ] := xy [ 1 ] - DY ;
IF ORD(Object^.Code[0]) = ORD (Types.Text) THEN
xya [ 1 ] := xy [ 1 ];
xya [ 2 ] := 1 ;
xya [ 3 ] := 1 ;
ELSE
xya [ 2 ] := DX ;
xya [ 3 ] := DY ;
END;
IF DX=0 THEN DX:=1; END; IF DY=0 THEN DY:=1; END;
Object^.Surround[0] := Object^.Code[1] + CommonData.FatherXOffset;
Object^.Surround[1] := Object^.Code[2] + Object^.Code[4] + CommonData.FatherYOffset;
Object^.Surround[2] := Object^.Code[3];
Object^.Surround[3] := Object^.Code[4];
Object^.SurrDirty := FALSE;
(**
RTD.Message('Vis?');
**)
IF Variablen.Visible(Object^.Surround) THEN
(**
RTD.Message('Yes!');
**)
dum := MagicVDI.SetLinewidth (mtAppl.VDIHandle ,
Object^.Code [ 8 ]) ;
dum := MagicVDI.SetLinetype (mtAppl.VDIHandle , MagicVDI.Line) ;
dum := MagicVDI.SetLinecolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
dum := MagicVDI.SetMarkercolor(mtAppl.VDIHandle, MagicAES.BLACK);
MagicVDI.SetLineEndstyles (mtAppl.VDIHandle ,
MagicVDI.Cornerd , MagicVDI.Cornerd) ;
dum := MagicVDI.SetFillinterior (mtAppl.VDIHandle , MagicVDI.Full) ;
dum := MagicVDI.SetFillcolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
IF VAL(Types.DrawObjectTyp, Object^.Code [ 0 ]) =
Types.Dashbox THEN
style := MagicVDI.Dash ;
ELSE
style := MagicVDI.Line ;
END ;
dum := MagicVDI.SetLinetype (mtAppl.VDIHandle , style) ;
IF (VAL(Types.DrawObjectTyp, Object^.Code [ 0 ]) <>
Types.Text) THEN
IF VAL(Types.DrawObjectTyp, Object^.Code [ 0 ]) =
Types.Framebox THEN
IF Object^.Code[6] = 1 THEN
nodraw := TRUE;
(**
RTD.Message('No Boxdraw');
**)
ELSE
nodraw := FALSE;
END ;
ELSE
nodraw := FALSE;
END ;
IF NOT nodraw THEN
(**
RTD.Message('Now Polyline');
**)
MagicVDI.Polyline (mtAppl.VDIHandle , 5 , xy) ;
IF VAL(Types.DrawObjectTyp, Object^.Code [ 0 ]) =
Types.Filledbox THEN
PxyArray[0] := xy[0]; PxyArray[1] := xy[1];
PxyArray[2] := xy[4]; PxyArray[3] := xy[5];
(**
RTD.Message('Now Fill');
**)
Fill.SetFillMode(Fill.Solid);
FillBox(xy[0], xy[1], xy[4], xy[5]);
(*
MagicVDI.FilledArea(mtAppl.VDIHandle , 5, xy);
*)
Fill.SetFillMode(-1);
dum := MagicVDI.SetWritemode(mtAppl.VDIHandle, MagicVDI.REPLACE);
END;
END;
END;
dum := MagicVDI.SetLinetype (mtAppl.VDIHandle , MagicVDI.Line) ;
ELSE
(* reiner Text *)
FOR dum:=1 TO Object^.Code[9] DO
tmpstr[dum] := Object^.CPtr^[dum-1];
END;
tmpstr[Object^.Code[9]] := 0C;
DY := 16 * NrOfSublines(tmpstr, dum);
DX := 8 * dum;
Variablen.PicToPix (X0, Y0, Object^.Code[1], Object^.Code[2]);
Y0 := Y0 + 1 - DY;
Variablen.PixToPic (X0, Y0, Object^.Surround[0], Object^.Surround[1]);
IF DX=0 THEN DX:=1; END; IF DY=0 THEN DY:=1; END;
Object^.Surround[2] := DX;
Object^.Surround[3] := DY;
Object^.SurrDirty := FALSE;
END ;
IF (Object^.Code [ 9 ] <> 0) THEN
IF Object^.CPtr<>NIL THEN
(**
RTD.Message('Text');
RTD.ShowVar('Object^.Code [ 9 ]', Object^.Code [ 9 ]);
**)
IF Variablen.Visible(Object^.Surround) THEN
FOR dum := 0 TO Object^.Code [ 9 ] - 1 DO
str [ dum ] := Object^.CPtr^ [ dum ] ;
END ;
str [ Object^.Code [ 9 ] ] := CHR (0) ;
(* dum := MagicVDI.SetWritemode(mtAppl.VDIHandle, MagicVDI.TRANSPARENT);
*)
dum := MagicVDI.SetWritemode(mtAppl.VDIHandle, MagicVDI.XOR);
AlignMode := Object^.Code[7];
(**
RTD.Message('Now WriteText');
**)
Internal := TRUE;
WriteText (str , Object^.Code [ 9 ] ,
Object^.Code [ 5 ] , xya) ;
Internal := FALSE;
dum := MagicVDI.SetWritemode(mtAppl.VDIHandle, MagicVDI.REPLACE);
END ;
ELSE
(**
RTD.Message('Oops, CPtr=NIL!');
**)
END ;
END ;
ELSE
(* Die Mitte ist gespeichert worden *)
DX := Variablen.PixDistance(Object^.Code[3]);
DY := Variablen.PixDistance(Object^.Code[4]);
xy[0] := Object^.Code[1] + Object^.Code[3];
xy[1] := Object^.Code[2] + Object^.Code[4];
Variablen.PicToPix (PxyArray [ 0 ] , PxyArray [ 1 ] ,
Object^.Code [ 1 ] , Object^.Code [ 2 ]) ;
Variablen.PicToPix (PxyArray [ 2 ] , PxyArray [ 3 ] ,
xy [ 0 ] , xy [ 1 ]);
dum := (PxyArray[2] - PxyArray[0]) DIV 2;
PxyArray[ 0 ] := PxyArray[ 0 ] - dum;
PxyArray[ 2 ] := PxyArray[ 2 ] - dum;
dum := (PxyArray[3] - PxyArray[1]) DIV 2;
PxyArray[ 1 ] := PxyArray[ 1 ] - dum;
PxyArray[ 3 ] := PxyArray[ 3 ] - dum;
IF PxyArray[0] < PxyArray[2] THEN
X0 := PxyArray[0];
ELSE
X0 := PxyArray[2];
END;
IF PxyArray[1] < PxyArray[3] THEN
Y0 := PxyArray[1];
ELSE
Y0 := PxyArray[3];
END;
Variablen.PixToPic (X0, Y0, Object^.Surround[0], Object^.Surround[1]);
IF DX=0 THEN DX:=1; END; IF DY=0 THEN DY:=1; END;
Object^.Surround[2] := Variablen.PicDistance(DX);
Object^.Surround[3] := Variablen.PicDistance(DY);
Object^.SurrDirty := FALSE;
IF Variablen.Visible(Object^.Surround) THEN
dum := MagicVDI.SetLinewidth (mtAppl.VDIHandle ,
Object^.Code [ 8 ]) ;
RoundedRect (PxyArray);
END;
dum := MagicVDI.SetLinetype (mtAppl.VDIHandle , MagicVDI.Line) ;
dum := MagicVDI.SetLinecolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
dum := MagicVDI.SetMarkercolor(mtAppl.VDIHandle, MagicAES.BLACK);
MagicVDI.SetLineEndstyles (mtAppl.VDIHandle ,
MagicVDI.Cornerd , MagicVDI.Cornerd) ;
dum := MagicVDI.SetFillinterior (mtAppl.VDIHandle , MagicVDI.Full) ;
dum := MagicVDI.SetFillcolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
END;
Internal := FALSE;
(**
RTD.Message('Show ready');
**)
END Show ;
PROCEDURE Change (Object : Types.ObjectPtrTyp;
DX, DY : LONGREAL) ;
BEGIN
IF ORD(Object^.Code[0]) <> ORD(Types.Text) THEN
IF DX<>0.0 THEN
Object^.Code[3] := Diverses.round(MathLib0.real(Object^.Code[3]) * DX);
END;
IF DY<>0.0 THEN
Object^.Code[4] := Diverses.round(MathLib0.real(Object^.Code[4]) * DY);
END;
Object^.SurrDirty := TRUE;
END;
END Change;
BEGIN
Internal := FALSE;
SetVectorText(FALSE);
storeangle := 0;
storesize := 1.0;
storeslant := 0.0;
(**
RTD.SetDevice(RTD.printer);
**)
END TextBox .