mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-23 14:49:13 +02:00
* several graphic mode improovements
This commit is contained in:
parent
981d0bf876
commit
909d705e2f
127
fv/gfvgraph.pas
127
fv/gfvgraph.pas
@ -135,7 +135,7 @@ CONST
|
||||
|
||||
type
|
||||
|
||||
textrainfo = array[0..0] of byte;
|
||||
textrainfo = array[0..0] of word;
|
||||
pextrainfo = ^textrainfo;
|
||||
|
||||
TSpVideoBuf = array [0..0] of pextrainfo;
|
||||
@ -222,7 +222,7 @@ PROCEDURE OutTextXY(X,Y: Integer; TextString: String);
|
||||
|
||||
{$IFDEF GRAPH_API}
|
||||
procedure GraphUpdateScreen(Force: Boolean);
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; color : word);
|
||||
procedure SetupExtraInfo;
|
||||
procedure FreeExtraInfo;
|
||||
|
||||
@ -469,8 +469,11 @@ END;
|
||||
PROCEDURE OutTextXY(X,Y: Integer; TextString: string);
|
||||
{$IFDEF GRAPH_API}
|
||||
var
|
||||
i,j,xi,yj : longint;
|
||||
i,j,xi,yj,xs,ys : longint;
|
||||
Ts: Graph.ViewPortType;
|
||||
Txs : TextSettingsType;
|
||||
tw, th : integer;
|
||||
color : word;
|
||||
{$ENDIF GRAPH_API}
|
||||
|
||||
BEGIN
|
||||
@ -479,13 +482,30 @@ BEGIN
|
||||
if true then
|
||||
begin
|
||||
Graph.GetViewSettings(Ts);
|
||||
For j:=0 to TextWidth(TextString) -1 do
|
||||
For i:=0 to TextHeight(TextString)-1 do
|
||||
Graph.GetTextSettings(Txs);
|
||||
tw:=TextWidth(TextString);
|
||||
th:=TextHeight(TextString);
|
||||
case Txs.Horiz of
|
||||
centertext : Xs:=(tw shr 1);
|
||||
lefttext : Xs:=0;
|
||||
righttext : Xs:=tw;
|
||||
end;
|
||||
case txs.vert of
|
||||
centertext : Ys:=-(th shr 1);
|
||||
bottomtext : Ys:=-th;
|
||||
toptext : Ys:=0;
|
||||
end;
|
||||
x:=x-xs;
|
||||
y:=y+ys;
|
||||
|
||||
For j:=0 to tw-1 do
|
||||
For i:=0 to th-1 do
|
||||
begin
|
||||
xi:=x+i+Ts.x1;
|
||||
yj:=y+j+Ts.y1;
|
||||
Color:=GetPixel(xi,yj);
|
||||
SetExtraInfo(xi div SysFontWidth,yj div SysFontHeight,
|
||||
xi mod SysFontWidth,yj mod SysFontHeight, true);
|
||||
xi mod SysFontWidth,yj mod SysFontHeight, Color);
|
||||
end;
|
||||
end;
|
||||
{$ENDIF GRAPH_API}
|
||||
@ -583,27 +603,23 @@ end;
|
||||
const
|
||||
SetExtraInfoCalled : boolean = false;
|
||||
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; color : word);
|
||||
var
|
||||
i,k,l : longint;
|
||||
extrainfo : pextrainfo;
|
||||
|
||||
begin
|
||||
i:=y*TextScreenWidth+x;
|
||||
if not assigned(SpVideoBuf^[i]) then
|
||||
if not assigned(SpVideoBuf^[i]) or (SpVideoBuf^[i]=EmptyVideoBufCell) then
|
||||
begin
|
||||
GetMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FillChar(SpVideoBuf^[i]^,SysFontHeight*((SysFontWidth +7) div 8),#0);
|
||||
GetMem(SpVideoBuf^[i],SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
FillChar(SpVideoBuf^[i]^,SysFontHeight*SysFontWidth*Sizeof(word),#255);
|
||||
end;
|
||||
extrainfo:=SpVideoBuf^[i];
|
||||
k:=xi mod 8;
|
||||
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
|
||||
if l>=SysFontHeight*((SysFontWidth +7) div 8) then
|
||||
l:=yi*SysFontWidth + xi;
|
||||
if l>=SysFontHeight*SysFontWidth then
|
||||
RunError(219);
|
||||
if shouldskip then
|
||||
extrainfo^[l]:=extrainfo^[l] or (1 shl k)
|
||||
else
|
||||
extrainfo^[l]:=extrainfo^[l] and not (1 shl k);
|
||||
extrainfo^[l]:=color;
|
||||
SetExtraInfoCalled:=true;
|
||||
end;
|
||||
|
||||
@ -611,8 +627,8 @@ procedure SetupExtraInfo;
|
||||
begin
|
||||
if not assigned(EmptyVideoBufCell) then
|
||||
begin
|
||||
GetMem(EmptyVideoBufCell,SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FillChar(EmptyVideoBufCell^,SysFontHeight*((SysFontWidth +7) div 8),#0);
|
||||
GetMem(EmptyVideoBufCell,SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
FillChar(EmptyVideoBufCell^,SysFontHeight*SysFontWidth*Sizeof(word),#255);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -625,14 +641,16 @@ begin
|
||||
begin
|
||||
for i:=0 to (TextScreenWidth+1)*(TextScreenHeight+1) - 1 do
|
||||
if assigned(SpVideoBuf^[i]) and (SpVideoBuf^[i]<>EmptyVideoBufCell) then
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
if assigned(EmptyVideoBufCell) then
|
||||
FreeMem(EmptyVideoBufCell,SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FreeMem(EmptyVideoBufCell,SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
FreeMem(SpVideoBuf,sizeof(pextrainfo)*(TextScreenWidth+1)*(TextScreenHeight+1));
|
||||
SpVideoBuf:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
{define Use_ONLY_COLOR}
|
||||
|
||||
procedure GraphUpdateScreen(Force: Boolean);
|
||||
var
|
||||
smallforce : boolean;
|
||||
@ -640,11 +658,18 @@ var
|
||||
xi,yi,k,l : longint;
|
||||
ch : char;
|
||||
attr : byte;
|
||||
SavedColor,SavedBkColor : longint;
|
||||
CurColor,CurBkColor : longint;
|
||||
color : word;
|
||||
SavedColor : longint;
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
SavedBkColor,CurBkColor : longint;
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
CurColor : longint;
|
||||
NextColor,NextBkColor : longint;
|
||||
StoreFillSettings: FillSettingsType;
|
||||
Ts: Graph.ViewPortType;
|
||||
{$ifdef debug}
|
||||
ChangedCount, SpecialCount : longint;
|
||||
{$endif debug}
|
||||
begin
|
||||
{$ifdef USE_VIDEO_API}
|
||||
if force or SetExtraInfoCalled then
|
||||
@ -666,16 +691,27 @@ begin
|
||||
end;
|
||||
if SmallForce then
|
||||
begin
|
||||
{$ifdef debug}
|
||||
SpecialCount:=0;
|
||||
ChangedCount:=0;
|
||||
{$endif debug}
|
||||
SetExtraInfoCalled:=false;
|
||||
SavedColor:=Graph.GetColor;
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
SavedBkColor:=Graph.GetBkColor;
|
||||
CurColor:=SavedColor;
|
||||
CurBkColor:=SavedBkColor;
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
CurColor:=SavedColor;
|
||||
Graph.GetViewSettings(Ts);
|
||||
Graph.SetViewPort(0,0,Graph.GetMaxX,Graph.GetMaxY,false);
|
||||
Graph.GetFillSettings(StoreFillSettings);
|
||||
{$ifdef Use_ONLY_COLOR}
|
||||
Graph.SetFillStyle(SolidFill,0);
|
||||
{$else not Use_ONLY_COLOR}
|
||||
Graph.SetFillStyle(EmptyFill,0);
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
Graph.SetWriteMode(CopyPut);
|
||||
Graph.SetTextJustify(LeftText,TopText);
|
||||
for y := 0 to TextScreenHeight - 1 do
|
||||
begin
|
||||
for x := 0 to TextScreenWidth - 1 do
|
||||
@ -687,29 +723,42 @@ begin
|
||||
ch:=chr(VideoBuf^[i] and $ff);
|
||||
if ch<>#0 then
|
||||
begin
|
||||
{$ifdef debug}
|
||||
Inc(ChangedCount);
|
||||
{$endif debug}
|
||||
if (SpVideoBuf^[i]=EmptyVideoBufCell) then
|
||||
SpVideoBuf^[i]:=nil;
|
||||
Attr:=VideoBuf^[i] shr 8;
|
||||
NextColor:=Attr and $f;
|
||||
NextBkColor:=(Attr and $70) shr 4;
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
if NextBkColor<>CurBkColor then
|
||||
begin
|
||||
Graph.SetBkColor(NextBkColor);
|
||||
CurBkColor:=NextBkColor;
|
||||
end;
|
||||
{$else Use_ONLY_COLOR}
|
||||
if NextBkColor<>CurColor then
|
||||
begin
|
||||
Graph.SetColor(NextBkColor);
|
||||
CurColor:=NextBkColor;
|
||||
end;
|
||||
{$endif Use_ONLY_COLOR}
|
||||
if (x=CursorX) and (y=CursorY) then
|
||||
HideCursor;
|
||||
if not assigned(SpVideoBuf^[i]) then
|
||||
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth-1,(y+1)*SysFontHeight-1)
|
||||
else
|
||||
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth-1,(y+1)*SysFontHeight-1);
|
||||
if assigned(SpVideoBuf^[i]) then
|
||||
begin
|
||||
{$ifdef debug}
|
||||
Inc(SpecialCount);
|
||||
{$endif debug}
|
||||
For yi:=0 to SysFontHeight-1 do
|
||||
For xi:=0 to SysFontWidth-1 do
|
||||
begin
|
||||
k:=xi mod 8;
|
||||
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
|
||||
if SpVideoBuf^[i]^[l] and (1 shl k) = 0 then
|
||||
Graph.PutPixel(x*SysfontWidth+xi,y*SysFontHeight+yi,CurBkColor);
|
||||
l:=yi*SysFontWidth + xi;
|
||||
color:=SpVideoBuf^[i]^[l];
|
||||
if color<>$ffff then
|
||||
Graph.PutPixel(x*SysfontWidth+xi,y*SysFontHeight+yi,color);
|
||||
end;
|
||||
end;
|
||||
if NextColor<>CurColor then
|
||||
@ -719,12 +768,13 @@ begin
|
||||
end;
|
||||
{ SetBkColor does change the palette index 0 entry...
|
||||
which leads to troubles if we want to write in dark }
|
||||
if (CurColor=0) then
|
||||
(* if (CurColor=0) and (ch<>' ') and assigned(SpVideoBuf^[i]) then
|
||||
begin
|
||||
Graph.SetBkColor(0);
|
||||
CurBkColor:=0;
|
||||
end;
|
||||
Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight+2,ch);
|
||||
end; *)
|
||||
if ch<>' ' then
|
||||
Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight+2,ch);
|
||||
if (x=CursorX) and (y=CursorY) then
|
||||
ShowCursor;
|
||||
end;
|
||||
@ -735,7 +785,7 @@ begin
|
||||
SpVideoBuf^[i]:=nil
|
||||
else
|
||||
begin
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*SysFontWidth*sizeof(word));
|
||||
SpVideoBuf^[i]:=EmptyVideoBufCell;
|
||||
end;
|
||||
end;
|
||||
@ -744,7 +794,9 @@ begin
|
||||
end;
|
||||
Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color);
|
||||
Graph.SetColor(SavedColor);
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
Graph.SetBkColor(SavedBkColor);
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
Graph.SetViewPort(TS.X1,Ts.Y1,ts.X2,ts.Y2,ts.Clip);
|
||||
end;
|
||||
{$else not USE_VIDEO_API}
|
||||
@ -757,7 +809,10 @@ end;
|
||||
END.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2002-06-06 06:41:14 pierre
|
||||
Revision 1.17 2002-08-22 13:40:49 pierre
|
||||
* several graphic mode improovements
|
||||
|
||||
Revision 1.16 2002/06/06 06:41:14 pierre
|
||||
+ Cursor functions for UseFixedFont case
|
||||
|
||||
Revision 1.15 2002/05/31 12:37:47 pierre
|
||||
|
40
fv/views.pas
40
fv/views.pas
@ -374,6 +374,7 @@ TYPE
|
||||
HoldLimit: PComplexArea; { Hold limit values }
|
||||
|
||||
RevCol : Boolean;
|
||||
BackgroundChar : Char;
|
||||
|
||||
CONSTRUCTOR Init (Var Bounds: TRect);
|
||||
CONSTRUCTOR Load (Var S: TStream);
|
||||
@ -947,6 +948,7 @@ BEGIN
|
||||
State := sfVisible; { Default state }
|
||||
EventMask := evMouseDown + evKeyDown + evCommand; { Default event masks }
|
||||
GOptions := goTabSelect; { Set new options }
|
||||
BackgroundChar := ' ';
|
||||
SetBounds(Bounds); { Set view bounds }
|
||||
END;
|
||||
|
||||
@ -1679,7 +1681,7 @@ BEGIN
|
||||
If (State AND sfDisabled = 0) Then
|
||||
Bc := GetColor(1) AND $F0 SHR 4 Else { Select back colour }
|
||||
Bc := GetColor(4) AND $F0 SHR 4; { Disabled back colour }
|
||||
GetViewSettings(ViewPort, TextModeGFV); { Get view settings }
|
||||
GetViewSettings(ViewPort, TextModeGFV or UseFixedFont); { Get view settings }
|
||||
If not TextModeGFV and not UseFixedFont Then Begin { GRAPHICS MODE GFV }
|
||||
If (ViewPort.X1 <= RawOrigin.X) Then X1 := 0 { Right to left edge }
|
||||
Else X1 := ViewPort.X1-RawOrigin.X; { Offset from left }
|
||||
@ -1710,7 +1712,7 @@ BEGIN
|
||||
Bc := GetColor(1) Else { Select back colour }
|
||||
Bc := GetColor(4); { Disabled back colour }
|
||||
For X := X1 To X2 Do Begin
|
||||
Buf[X-X1]:=(Bc shl 8) or $20;
|
||||
Buf[X-X1]:=(Bc shl 8) or ord(BackgroundChar){$20};
|
||||
End;
|
||||
For Y := Y1 To Y2 Do Begin
|
||||
WriteAbs(X1,Y, X2-X1, Buf);
|
||||
@ -2591,14 +2593,14 @@ BEGIN
|
||||
(Y1<RawOrigin.Y+RawSize.Y) and
|
||||
(X2>=RawOrigin.X) and { No need to parse childs for Shadows }
|
||||
(Y2>=RawOrigin.Y) Then { No draw child clear }
|
||||
ReDrawVisibleArea(X1, Y1, X2, Y2,Last^.Next); { Redraw each subview }
|
||||
ReDrawVisibleArea(X1, Y1, X2, Y2,First); { Redraw each subview }
|
||||
(* { redraw group members }
|
||||
If (DrawMask AND vdNoChild = 0) and
|
||||
(X1<RawOrigin.X+RawSize.X) and { No need to parse childs for Shadows }
|
||||
(Y1<RawOrigin.Y+RawSize.Y) Then Begin { No draw child clear }
|
||||
P := Last; { Start on Last }
|
||||
While (P <> Nil) Do Begin
|
||||
P^.ReDrawVisibleArea(X1, Y1, X2, Y2,Last^.Next,P); { Redraw each subview }
|
||||
P^.ReDrawVisibleArea(X1, Y1, X2, Y2,First,P); { Redraw each subview }
|
||||
P := P^.PrevView; { Move to prior view }
|
||||
End;
|
||||
End; *)
|
||||
@ -2845,7 +2847,7 @@ BEGIN
|
||||
I := I - (P^.Origin.X * FontWidth); { Subtract x origin }
|
||||
End;
|
||||
{ make sure that I is a multiple of FontWidth }
|
||||
if TextModeGFV then
|
||||
if TextModeGFV or UseFixedFont then
|
||||
I:= (I div FontWidth) * FontWidth;
|
||||
P^.DisplaceBy(I, 0); { Displace the view }
|
||||
End;
|
||||
@ -2861,7 +2863,7 @@ BEGIN
|
||||
I := I - (P^.Origin.Y * FontHeight); { Subtract y origin }
|
||||
End;
|
||||
{ make sure that I is a multiple of FontHeight }
|
||||
if TextModeGFV then
|
||||
if TextModeGFV or UseFixedFont then
|
||||
I:= (I div FontHeight) * FontHeight;
|
||||
P^.DisplaceBy(0, I); { Displace the view }
|
||||
End;
|
||||
@ -4614,7 +4616,7 @@ BEGIN
|
||||
x:=(RawOrigin.X + X1 + ((x2-x1)*(j-y1)) div (y2-y1));
|
||||
if (x>=0) and (x<=Graph.GetMaxX) and (y>=0) and (y<=Graph.GetMaxY) then
|
||||
SetExtraInfo(x div SysFontWidth,y div SysFontHeight,
|
||||
x mod SysFontWidth,y mod SysFontHeight, true);
|
||||
x mod SysFontWidth,y mod SysFontHeight, Colour);
|
||||
end;
|
||||
end
|
||||
else
|
||||
@ -4625,7 +4627,7 @@ BEGIN
|
||||
y:=(RawOrigin.y + y1 + ((j-x1)*(y2-y1)) div (x2-x1));
|
||||
if (x>=0) and (x<=Graph.GetMaxX) and (y>=0) and (y<=Graph.GetMaxY) then
|
||||
SetExtraInfo(x div SysFontWidth,y div SysFontHeight,
|
||||
x mod SysFontWidth,y mod SysFontHeight, true);
|
||||
x mod SysFontWidth,y mod SysFontHeight, Colour);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -4904,6 +4906,9 @@ BEGIN
|
||||
$F0 SHR 4); { Set back colour }
|
||||
SetColor(Hi(P^[I]) AND $0F); { Set text colour }
|
||||
Bar(K, Y, K+Cw, Y+FontHeight-1); { Clear text backing }
|
||||
{$IFDEF GRAPH_API}
|
||||
SetTextJustify(LeftText,TopText);
|
||||
{$ENDIF GRAPH_API}
|
||||
OutTextXY(K, Y+2, Chr(Lo(P^[I]))); { Write text char }
|
||||
Inc(K,Cw);
|
||||
End;
|
||||
@ -5001,8 +5006,12 @@ BEGIN
|
||||
End;
|
||||
|
||||
{ increase position on screen }
|
||||
inc(X,(i-j));
|
||||
|
||||
If (X >= 0) AND (Y >= 0) AND ((GOptions and goGraphView)=0) Then
|
||||
inc(X,(i-j))
|
||||
else if X>0 then
|
||||
inc(X,(i-j)*FontWidth)
|
||||
else
|
||||
dec(X,(i-j)*FontWidth);
|
||||
{ Swap colors }
|
||||
if FoundSwap then
|
||||
begin
|
||||
@ -5543,11 +5552,13 @@ BEGIN
|
||||
If TextModeGFV then
|
||||
Y:=0 else
|
||||
begin
|
||||
If (Options AND ofFramed<>0) Then Y := 1
|
||||
Y:=0;
|
||||
(* If (Options AND ofFramed<>0) Then Y := 1
|
||||
Else Y := 0; { Initial value }
|
||||
If (GOptions AND goThickFramed<>0) Then Inc(Y, 3); { Adjust position }
|
||||
*)
|
||||
end;
|
||||
ClearArea(0, Y, RawSize.X, Y+FontHeight, Bc); { Clear background }
|
||||
ClearArea(0, Y, RawSize.X, Y+FontHeight-1, Bc); { Clear background }
|
||||
If not TextModeGFV then
|
||||
Inherited DrawBorder
|
||||
Else Begin { TEXT GFV MODE }
|
||||
@ -5771,7 +5782,10 @@ END.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.33 2002-06-10 13:47:38 pierre
|
||||
Revision 1.34 2002-08-22 13:40:49 pierre
|
||||
* several graphic mode improovements
|
||||
|
||||
Revision 1.33 2002/06/10 13:47:38 pierre
|
||||
* correct the check for drawing a double line border
|
||||
|
||||
Revision 1.32 2002/06/10 12:39:43 pierre
|
||||
|
@ -135,7 +135,7 @@ CONST
|
||||
|
||||
type
|
||||
|
||||
textrainfo = array[0..0] of byte;
|
||||
textrainfo = array[0..0] of word;
|
||||
pextrainfo = ^textrainfo;
|
||||
|
||||
TSpVideoBuf = array [0..0] of pextrainfo;
|
||||
@ -222,7 +222,7 @@ PROCEDURE OutTextXY(X,Y: Integer; TextString: String);
|
||||
|
||||
{$IFDEF GRAPH_API}
|
||||
procedure GraphUpdateScreen(Force: Boolean);
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; color : word);
|
||||
procedure SetupExtraInfo;
|
||||
procedure FreeExtraInfo;
|
||||
|
||||
@ -469,8 +469,11 @@ END;
|
||||
PROCEDURE OutTextXY(X,Y: Integer; TextString: string);
|
||||
{$IFDEF GRAPH_API}
|
||||
var
|
||||
i,j,xi,yj : longint;
|
||||
i,j,xi,yj,xs,ys : longint;
|
||||
Ts: Graph.ViewPortType;
|
||||
Txs : TextSettingsType;
|
||||
tw, th : integer;
|
||||
color : word;
|
||||
{$ENDIF GRAPH_API}
|
||||
|
||||
BEGIN
|
||||
@ -479,13 +482,30 @@ BEGIN
|
||||
if true then
|
||||
begin
|
||||
Graph.GetViewSettings(Ts);
|
||||
For j:=0 to TextWidth(TextString) -1 do
|
||||
For i:=0 to TextHeight(TextString)-1 do
|
||||
Graph.GetTextSettings(Txs);
|
||||
tw:=TextWidth(TextString);
|
||||
th:=TextHeight(TextString);
|
||||
case Txs.Horiz of
|
||||
centertext : Xs:=(tw shr 1);
|
||||
lefttext : Xs:=0;
|
||||
righttext : Xs:=tw;
|
||||
end;
|
||||
case txs.vert of
|
||||
centertext : Ys:=-(th shr 1);
|
||||
bottomtext : Ys:=-th;
|
||||
toptext : Ys:=0;
|
||||
end;
|
||||
x:=x-xs;
|
||||
y:=y+ys;
|
||||
|
||||
For j:=0 to tw-1 do
|
||||
For i:=0 to th-1 do
|
||||
begin
|
||||
xi:=x+i+Ts.x1;
|
||||
yj:=y+j+Ts.y1;
|
||||
Color:=GetPixel(xi,yj);
|
||||
SetExtraInfo(xi div SysFontWidth,yj div SysFontHeight,
|
||||
xi mod SysFontWidth,yj mod SysFontHeight, true);
|
||||
xi mod SysFontWidth,yj mod SysFontHeight, Color);
|
||||
end;
|
||||
end;
|
||||
{$ENDIF GRAPH_API}
|
||||
@ -583,27 +603,23 @@ end;
|
||||
const
|
||||
SetExtraInfoCalled : boolean = false;
|
||||
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
|
||||
procedure SetExtraInfo(x,y,xi,yi : longint; color : word);
|
||||
var
|
||||
i,k,l : longint;
|
||||
extrainfo : pextrainfo;
|
||||
|
||||
begin
|
||||
i:=y*TextScreenWidth+x;
|
||||
if not assigned(SpVideoBuf^[i]) then
|
||||
if not assigned(SpVideoBuf^[i]) or (SpVideoBuf^[i]=EmptyVideoBufCell) then
|
||||
begin
|
||||
GetMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FillChar(SpVideoBuf^[i]^,SysFontHeight*((SysFontWidth +7) div 8),#0);
|
||||
GetMem(SpVideoBuf^[i],SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
FillChar(SpVideoBuf^[i]^,SysFontHeight*SysFontWidth*Sizeof(word),#255);
|
||||
end;
|
||||
extrainfo:=SpVideoBuf^[i];
|
||||
k:=xi mod 8;
|
||||
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
|
||||
if l>=SysFontHeight*((SysFontWidth +7) div 8) then
|
||||
l:=yi*SysFontWidth + xi;
|
||||
if l>=SysFontHeight*SysFontWidth then
|
||||
RunError(219);
|
||||
if shouldskip then
|
||||
extrainfo^[l]:=extrainfo^[l] or (1 shl k)
|
||||
else
|
||||
extrainfo^[l]:=extrainfo^[l] and not (1 shl k);
|
||||
extrainfo^[l]:=color;
|
||||
SetExtraInfoCalled:=true;
|
||||
end;
|
||||
|
||||
@ -611,8 +627,8 @@ procedure SetupExtraInfo;
|
||||
begin
|
||||
if not assigned(EmptyVideoBufCell) then
|
||||
begin
|
||||
GetMem(EmptyVideoBufCell,SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FillChar(EmptyVideoBufCell^,SysFontHeight*((SysFontWidth +7) div 8),#0);
|
||||
GetMem(EmptyVideoBufCell,SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
FillChar(EmptyVideoBufCell^,SysFontHeight*SysFontWidth*Sizeof(word),#255);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -625,14 +641,16 @@ begin
|
||||
begin
|
||||
for i:=0 to (TextScreenWidth+1)*(TextScreenHeight+1) - 1 do
|
||||
if assigned(SpVideoBuf^[i]) and (SpVideoBuf^[i]<>EmptyVideoBufCell) then
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
if assigned(EmptyVideoBufCell) then
|
||||
FreeMem(EmptyVideoBufCell,SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FreeMem(EmptyVideoBufCell,SysFontHeight*SysFontWidth*Sizeof(word));
|
||||
FreeMem(SpVideoBuf,sizeof(pextrainfo)*(TextScreenWidth+1)*(TextScreenHeight+1));
|
||||
SpVideoBuf:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
{define Use_ONLY_COLOR}
|
||||
|
||||
procedure GraphUpdateScreen(Force: Boolean);
|
||||
var
|
||||
smallforce : boolean;
|
||||
@ -640,11 +658,18 @@ var
|
||||
xi,yi,k,l : longint;
|
||||
ch : char;
|
||||
attr : byte;
|
||||
SavedColor,SavedBkColor : longint;
|
||||
CurColor,CurBkColor : longint;
|
||||
color : word;
|
||||
SavedColor : longint;
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
SavedBkColor,CurBkColor : longint;
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
CurColor : longint;
|
||||
NextColor,NextBkColor : longint;
|
||||
StoreFillSettings: FillSettingsType;
|
||||
Ts: Graph.ViewPortType;
|
||||
{$ifdef debug}
|
||||
ChangedCount, SpecialCount : longint;
|
||||
{$endif debug}
|
||||
begin
|
||||
{$ifdef USE_VIDEO_API}
|
||||
if force or SetExtraInfoCalled then
|
||||
@ -666,16 +691,27 @@ begin
|
||||
end;
|
||||
if SmallForce then
|
||||
begin
|
||||
{$ifdef debug}
|
||||
SpecialCount:=0;
|
||||
ChangedCount:=0;
|
||||
{$endif debug}
|
||||
SetExtraInfoCalled:=false;
|
||||
SavedColor:=Graph.GetColor;
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
SavedBkColor:=Graph.GetBkColor;
|
||||
CurColor:=SavedColor;
|
||||
CurBkColor:=SavedBkColor;
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
CurColor:=SavedColor;
|
||||
Graph.GetViewSettings(Ts);
|
||||
Graph.SetViewPort(0,0,Graph.GetMaxX,Graph.GetMaxY,false);
|
||||
Graph.GetFillSettings(StoreFillSettings);
|
||||
{$ifdef Use_ONLY_COLOR}
|
||||
Graph.SetFillStyle(SolidFill,0);
|
||||
{$else not Use_ONLY_COLOR}
|
||||
Graph.SetFillStyle(EmptyFill,0);
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
Graph.SetWriteMode(CopyPut);
|
||||
Graph.SetTextJustify(LeftText,TopText);
|
||||
for y := 0 to TextScreenHeight - 1 do
|
||||
begin
|
||||
for x := 0 to TextScreenWidth - 1 do
|
||||
@ -687,29 +723,42 @@ begin
|
||||
ch:=chr(VideoBuf^[i] and $ff);
|
||||
if ch<>#0 then
|
||||
begin
|
||||
{$ifdef debug}
|
||||
Inc(ChangedCount);
|
||||
{$endif debug}
|
||||
if (SpVideoBuf^[i]=EmptyVideoBufCell) then
|
||||
SpVideoBuf^[i]:=nil;
|
||||
Attr:=VideoBuf^[i] shr 8;
|
||||
NextColor:=Attr and $f;
|
||||
NextBkColor:=(Attr and $70) shr 4;
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
if NextBkColor<>CurBkColor then
|
||||
begin
|
||||
Graph.SetBkColor(NextBkColor);
|
||||
CurBkColor:=NextBkColor;
|
||||
end;
|
||||
{$else Use_ONLY_COLOR}
|
||||
if NextBkColor<>CurColor then
|
||||
begin
|
||||
Graph.SetColor(NextBkColor);
|
||||
CurColor:=NextBkColor;
|
||||
end;
|
||||
{$endif Use_ONLY_COLOR}
|
||||
if (x=CursorX) and (y=CursorY) then
|
||||
HideCursor;
|
||||
if not assigned(SpVideoBuf^[i]) then
|
||||
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth-1,(y+1)*SysFontHeight-1)
|
||||
else
|
||||
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth-1,(y+1)*SysFontHeight-1);
|
||||
if assigned(SpVideoBuf^[i]) then
|
||||
begin
|
||||
{$ifdef debug}
|
||||
Inc(SpecialCount);
|
||||
{$endif debug}
|
||||
For yi:=0 to SysFontHeight-1 do
|
||||
For xi:=0 to SysFontWidth-1 do
|
||||
begin
|
||||
k:=xi mod 8;
|
||||
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
|
||||
if SpVideoBuf^[i]^[l] and (1 shl k) = 0 then
|
||||
Graph.PutPixel(x*SysfontWidth+xi,y*SysFontHeight+yi,CurBkColor);
|
||||
l:=yi*SysFontWidth + xi;
|
||||
color:=SpVideoBuf^[i]^[l];
|
||||
if color<>$ffff then
|
||||
Graph.PutPixel(x*SysfontWidth+xi,y*SysFontHeight+yi,color);
|
||||
end;
|
||||
end;
|
||||
if NextColor<>CurColor then
|
||||
@ -719,12 +768,13 @@ begin
|
||||
end;
|
||||
{ SetBkColor does change the palette index 0 entry...
|
||||
which leads to troubles if we want to write in dark }
|
||||
if (CurColor=0) then
|
||||
(* if (CurColor=0) and (ch<>' ') and assigned(SpVideoBuf^[i]) then
|
||||
begin
|
||||
Graph.SetBkColor(0);
|
||||
CurBkColor:=0;
|
||||
end;
|
||||
Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight+2,ch);
|
||||
end; *)
|
||||
if ch<>' ' then
|
||||
Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight+2,ch);
|
||||
if (x=CursorX) and (y=CursorY) then
|
||||
ShowCursor;
|
||||
end;
|
||||
@ -735,7 +785,7 @@ begin
|
||||
SpVideoBuf^[i]:=nil
|
||||
else
|
||||
begin
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
|
||||
FreeMem(SpVideoBuf^[i],SysFontHeight*SysFontWidth*sizeof(word));
|
||||
SpVideoBuf^[i]:=EmptyVideoBufCell;
|
||||
end;
|
||||
end;
|
||||
@ -744,7 +794,9 @@ begin
|
||||
end;
|
||||
Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color);
|
||||
Graph.SetColor(SavedColor);
|
||||
{$ifndef Use_ONLY_COLOR}
|
||||
Graph.SetBkColor(SavedBkColor);
|
||||
{$endif not Use_ONLY_COLOR}
|
||||
Graph.SetViewPort(TS.X1,Ts.Y1,ts.X2,ts.Y2,ts.Clip);
|
||||
end;
|
||||
{$else not USE_VIDEO_API}
|
||||
@ -757,7 +809,10 @@ end;
|
||||
END.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2002-06-06 06:41:14 pierre
|
||||
Revision 1.17 2002-08-22 13:40:49 pierre
|
||||
* several graphic mode improovements
|
||||
|
||||
Revision 1.16 2002/06/06 06:41:14 pierre
|
||||
+ Cursor functions for UseFixedFont case
|
||||
|
||||
Revision 1.15 2002/05/31 12:37:47 pierre
|
||||
|
@ -374,6 +374,7 @@ TYPE
|
||||
HoldLimit: PComplexArea; { Hold limit values }
|
||||
|
||||
RevCol : Boolean;
|
||||
BackgroundChar : Char;
|
||||
|
||||
CONSTRUCTOR Init (Var Bounds: TRect);
|
||||
CONSTRUCTOR Load (Var S: TStream);
|
||||
@ -947,6 +948,7 @@ BEGIN
|
||||
State := sfVisible; { Default state }
|
||||
EventMask := evMouseDown + evKeyDown + evCommand; { Default event masks }
|
||||
GOptions := goTabSelect; { Set new options }
|
||||
BackgroundChar := ' ';
|
||||
SetBounds(Bounds); { Set view bounds }
|
||||
END;
|
||||
|
||||
@ -1679,7 +1681,7 @@ BEGIN
|
||||
If (State AND sfDisabled = 0) Then
|
||||
Bc := GetColor(1) AND $F0 SHR 4 Else { Select back colour }
|
||||
Bc := GetColor(4) AND $F0 SHR 4; { Disabled back colour }
|
||||
GetViewSettings(ViewPort, TextModeGFV); { Get view settings }
|
||||
GetViewSettings(ViewPort, TextModeGFV or UseFixedFont); { Get view settings }
|
||||
If not TextModeGFV and not UseFixedFont Then Begin { GRAPHICS MODE GFV }
|
||||
If (ViewPort.X1 <= RawOrigin.X) Then X1 := 0 { Right to left edge }
|
||||
Else X1 := ViewPort.X1-RawOrigin.X; { Offset from left }
|
||||
@ -1710,7 +1712,7 @@ BEGIN
|
||||
Bc := GetColor(1) Else { Select back colour }
|
||||
Bc := GetColor(4); { Disabled back colour }
|
||||
For X := X1 To X2 Do Begin
|
||||
Buf[X-X1]:=(Bc shl 8) or $20;
|
||||
Buf[X-X1]:=(Bc shl 8) or ord(BackgroundChar){$20};
|
||||
End;
|
||||
For Y := Y1 To Y2 Do Begin
|
||||
WriteAbs(X1,Y, X2-X1, Buf);
|
||||
@ -2591,14 +2593,14 @@ BEGIN
|
||||
(Y1<RawOrigin.Y+RawSize.Y) and
|
||||
(X2>=RawOrigin.X) and { No need to parse childs for Shadows }
|
||||
(Y2>=RawOrigin.Y) Then { No draw child clear }
|
||||
ReDrawVisibleArea(X1, Y1, X2, Y2,Last^.Next); { Redraw each subview }
|
||||
ReDrawVisibleArea(X1, Y1, X2, Y2,First); { Redraw each subview }
|
||||
(* { redraw group members }
|
||||
If (DrawMask AND vdNoChild = 0) and
|
||||
(X1<RawOrigin.X+RawSize.X) and { No need to parse childs for Shadows }
|
||||
(Y1<RawOrigin.Y+RawSize.Y) Then Begin { No draw child clear }
|
||||
P := Last; { Start on Last }
|
||||
While (P <> Nil) Do Begin
|
||||
P^.ReDrawVisibleArea(X1, Y1, X2, Y2,Last^.Next,P); { Redraw each subview }
|
||||
P^.ReDrawVisibleArea(X1, Y1, X2, Y2,First,P); { Redraw each subview }
|
||||
P := P^.PrevView; { Move to prior view }
|
||||
End;
|
||||
End; *)
|
||||
@ -2845,7 +2847,7 @@ BEGIN
|
||||
I := I - (P^.Origin.X * FontWidth); { Subtract x origin }
|
||||
End;
|
||||
{ make sure that I is a multiple of FontWidth }
|
||||
if TextModeGFV then
|
||||
if TextModeGFV or UseFixedFont then
|
||||
I:= (I div FontWidth) * FontWidth;
|
||||
P^.DisplaceBy(I, 0); { Displace the view }
|
||||
End;
|
||||
@ -2861,7 +2863,7 @@ BEGIN
|
||||
I := I - (P^.Origin.Y * FontHeight); { Subtract y origin }
|
||||
End;
|
||||
{ make sure that I is a multiple of FontHeight }
|
||||
if TextModeGFV then
|
||||
if TextModeGFV or UseFixedFont then
|
||||
I:= (I div FontHeight) * FontHeight;
|
||||
P^.DisplaceBy(0, I); { Displace the view }
|
||||
End;
|
||||
@ -4614,7 +4616,7 @@ BEGIN
|
||||
x:=(RawOrigin.X + X1 + ((x2-x1)*(j-y1)) div (y2-y1));
|
||||
if (x>=0) and (x<=Graph.GetMaxX) and (y>=0) and (y<=Graph.GetMaxY) then
|
||||
SetExtraInfo(x div SysFontWidth,y div SysFontHeight,
|
||||
x mod SysFontWidth,y mod SysFontHeight, true);
|
||||
x mod SysFontWidth,y mod SysFontHeight, Colour);
|
||||
end;
|
||||
end
|
||||
else
|
||||
@ -4625,7 +4627,7 @@ BEGIN
|
||||
y:=(RawOrigin.y + y1 + ((j-x1)*(y2-y1)) div (x2-x1));
|
||||
if (x>=0) and (x<=Graph.GetMaxX) and (y>=0) and (y<=Graph.GetMaxY) then
|
||||
SetExtraInfo(x div SysFontWidth,y div SysFontHeight,
|
||||
x mod SysFontWidth,y mod SysFontHeight, true);
|
||||
x mod SysFontWidth,y mod SysFontHeight, Colour);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -4904,6 +4906,9 @@ BEGIN
|
||||
$F0 SHR 4); { Set back colour }
|
||||
SetColor(Hi(P^[I]) AND $0F); { Set text colour }
|
||||
Bar(K, Y, K+Cw, Y+FontHeight-1); { Clear text backing }
|
||||
{$IFDEF GRAPH_API}
|
||||
SetTextJustify(LeftText,TopText);
|
||||
{$ENDIF GRAPH_API}
|
||||
OutTextXY(K, Y+2, Chr(Lo(P^[I]))); { Write text char }
|
||||
Inc(K,Cw);
|
||||
End;
|
||||
@ -5001,8 +5006,12 @@ BEGIN
|
||||
End;
|
||||
|
||||
{ increase position on screen }
|
||||
inc(X,(i-j));
|
||||
|
||||
If (X >= 0) AND (Y >= 0) AND ((GOptions and goGraphView)=0) Then
|
||||
inc(X,(i-j))
|
||||
else if X>0 then
|
||||
inc(X,(i-j)*FontWidth)
|
||||
else
|
||||
dec(X,(i-j)*FontWidth);
|
||||
{ Swap colors }
|
||||
if FoundSwap then
|
||||
begin
|
||||
@ -5543,11 +5552,13 @@ BEGIN
|
||||
If TextModeGFV then
|
||||
Y:=0 else
|
||||
begin
|
||||
If (Options AND ofFramed<>0) Then Y := 1
|
||||
Y:=0;
|
||||
(* If (Options AND ofFramed<>0) Then Y := 1
|
||||
Else Y := 0; { Initial value }
|
||||
If (GOptions AND goThickFramed<>0) Then Inc(Y, 3); { Adjust position }
|
||||
*)
|
||||
end;
|
||||
ClearArea(0, Y, RawSize.X, Y+FontHeight, Bc); { Clear background }
|
||||
ClearArea(0, Y, RawSize.X, Y+FontHeight-1, Bc); { Clear background }
|
||||
If not TextModeGFV then
|
||||
Inherited DrawBorder
|
||||
Else Begin { TEXT GFV MODE }
|
||||
@ -5771,7 +5782,10 @@ END.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.33 2002-06-10 13:47:38 pierre
|
||||
Revision 1.34 2002-08-22 13:40:49 pierre
|
||||
* several graphic mode improovements
|
||||
|
||||
Revision 1.33 2002/06/10 13:47:38 pierre
|
||||
* correct the check for drawing a double line border
|
||||
|
||||
Revision 1.32 2002/06/10 12:39:43 pierre
|
||||
|
Loading…
Reference in New Issue
Block a user