* fix border problems for views and menus

This commit is contained in:
pierre 2001-05-30 13:26:17 +00:00
parent 52f77478c0
commit 610da7b3e5
4 changed files with 208 additions and 114 deletions

View File

@ -1048,12 +1048,33 @@ END;
{ Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 11May98 LdB }
{---------------------------------------------------------------------------}
PROCEDURE TMenuBox.Draw;
VAR CNormal, CSelect, CDisabled, Color: Word; Tx, Ty, Y: Integer;
VAR CNormal, CSelect, CDisabled, Color: Word; Index, Tx, Ty, Y: Integer;
S: String; P: PMenuItem; B: TDrawBuffer;
Type
FrameLineType = (UpperLine,NormalLine,SeparationLine,LowerLine);
FrameLineChars = Array[0..2] of char;
Const
FrameLines : Array[FrameLineType] of FrameLineChars =
('ÚÄ¿','³ ³','ÃÄ´','ÀÄÙ');
Procedure CreateBorder(LineType : FrameLineType);
Begin
MoveChar(B, ' ', CNormal, 1);
MoveChar(B[1], FrameLines[LineType][0], CNormal, 1);
MoveChar(B[2], FrameLines[LineType][1], Color, Size.X-4);
MoveChar(B[Size.X-2], FrameLines[LineType][2], CNormal, 1);
MoveChar(B[Size.X-1], ' ', CNormal, 1);
End;
BEGIN
CNormal := GetColor($0301); { Normal colour }
CSelect := GetColor($0604); { Selected colour }
CDisabled := GetColor($0202); { Disabled colour }
If TextModeGFV then
Begin
CreateBorder(UpperLine);
WriteBuf(0, 0, Size.X, 1, B); { Write the line }
End;
Y := 1;
If (Menu <> Nil) Then Begin { We have a menu }
P := Menu^.Items; { Start on first }
@ -1062,18 +1083,30 @@ BEGIN
If (P^.Name <> Nil) Then Begin { Item has text }
If P^.Disabled Then Color := CDisabled { Is item disabled }
Else If (P = Current) Then Color := CSelect; { Select colour }
MoveChar(B, ' ', Color, Size.X-4); { Clear buffer }
If TextModeGFV then
Begin
CreateBorder(NormalLine);
Index:=2;
End
Else
Begin
MoveChar(B, ' ', Color, Size.X-4); { Clear buffer }
Index:=0;
End;
S := ' ' + P^.Name^ + ' '; { Menu string }
MoveCStr(B[0], S, Color); { Transfer string }
MoveCStr(B[Index], S, Color); { Transfer string }
If (P^.Command <> 0) AND(P^.Param <> Nil)
Then Begin
MoveCStr(B[CStrLen(S)], ' - ' + P^.Param^,
MoveCStr(B[CStrLen(S)+Index], ' - ' + P^.Param^,
Color); { Add param chars }
S := S + ' - ' + P^.Param^; { Add to string }
End;
If (OldItem = Nil) OR (OldItem = P) OR
(Current = P) Then Begin { We need to fix draw }
WriteBuf(2, Y, CStrLen(S), 1, B); { Write the line }
If TextModeGFV then
WriteBuf(0, Y, Size.X, 1, B) { Write the whole line }
Else
WriteBuf(2, Y, CStrLen(S), 1, B); { Write the line }
If (P = Current) Then Begin { Selected item }
Tx := 2 * FontWidth; { X offset }
Ty := Y * FontHeight; { Y offset }
@ -1083,15 +1116,20 @@ BEGIN
End;
End;
End Else Begin { no text NewLine }
MoveChar(B, 'Ã', Color, 1);
MoveChar(B[1], 'Ä', Color, Size.X-2);
MoveChar(B[Size.X-1], '´', Color, 1);
Color := CNormal; { Normal colour }
CreateBorder(SeparationLine);
WriteBuf(0, Y, Size.X, 1, B); { Write the line }
End;
Inc(Y); { Next line down }
P := P^.Next; { fetch next item }
End;
End;
If TextModeGFV then
Begin
Color := CNormal; { Normal colour }
CreateBorder(LowerLine);
WriteBuf(0, Size.Y-1, Size.X, 1, B); { Write the line }
End;
END;
{--TMenuBox-----------------------------------------------------------------}
@ -1673,7 +1711,10 @@ END;
END.
{
$Log$
Revision 1.7 2001-05-07 22:22:03 pierre
Revision 1.8 2001-05-30 13:26:17 pierre
* fix border problems for views and menus
Revision 1.7 2001/05/07 22:22:03 pierre
* removed NO_WINDOW cond, added GRAPH_API
Revision 1.6 2001/05/04 15:43:45 pierre

View File

@ -1339,15 +1339,6 @@ END;
{ DrawBorder -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17May98 LdB }
{---------------------------------------------------------------------------}
PROCEDURE TView.DrawBorder;
VAR I : sw_integer;
LeftUpCorner,
RightUpCorner,
HorizontalBar,
VerticalBar,
LeftLowCorner,
RightLowCorner : Char;
Color : Byte;
Focused : Boolean;
BEGIN
If (TextModeGFV = FALSE) Then Begin { GRAPHICS GFV MODE }
BiColorRectangle(0, 0, RawSize.X, RawSize.Y,
@ -1360,44 +1351,8 @@ BEGIN
BiColorRectangle(3, 3, RawSize.X-3, RawSize.Y-3,
White, DarkGray, True); { Draw highlights }
End;
End Else Begin { TEXT GFV MODE }
Focused:=(State AND (sfSelected + sfModal)<>0);
if Assigned(Owner) then
Focused := Focused AND (@Self = Owner^.First);
If not Focused or (GOptions AND goThickFramed = 0) then
begin
LeftUpCorner:='Ú';
RightUpCorner:='¿';
HorizontalBar:='Ä';
VerticalBar:='³';
LeftLowCorner:='À';
RightLowCorner:='Ù';
end
else
begin
LeftUpCorner:='É';
RightUpCorner:='»';
HorizontalBar:='Í';
VerticalBar:='º';
LeftLowCorner:='È';
RightLowCorner:='¼';
end;
if Focused then
Color := 2
else
Color := 1;
WriteChar(0,0,LeftUpCorner,Color,1);
WriteChar(1,0,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,0,RightUpcorner,Color,1);
For i:=1 to Size.Y -1 do
begin
WriteChar(0,i,VerticalBar,Color,1);
WriteChar(Size.X-1,i,VerticalBar,Color,1);
end;
WriteChar(0,Size.Y-1,LeftLowCorner,Color,1);
WriteChar(1,Size.Y-1,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,Size.Y-1,RightLowCorner,Color,1);
End;
{ TView DrawBorder is empty for TextModeGFV }
END;
PROCEDURE TView.DrawShadow;
@ -4990,6 +4945,15 @@ END;
PROCEDURE TWindow.DrawBorder;
VAR Fc, Bc: Byte; X, Y: Integer; S: String;
ViewPort: ViewPortType;
I : sw_integer;
LeftUpCorner,
RightUpCorner,
HorizontalBar,
VerticalBar,
LeftLowCorner,
RightLowCorner : Char;
Color : Byte;
Focused : Boolean;
BEGIN
Fc := GetColor(2) AND $0F; { Foreground colour }
Bc := (GetColor(2) AND $70) SHR 4; { Background colour }
@ -5001,7 +4965,46 @@ BEGIN
If (GOptions AND goThickFramed<>0) Then Inc(Y, 3); { Adjust position }
end;
ClearArea(0, Y, RawSize.X, Y+FontHeight, Bc); { Clear background }
Inherited DrawBorder;
If not TextModeGFV then
Inherited DrawBorder
Else Begin { TEXT GFV MODE }
Focused:=(State AND (sfSelected + sfModal)<>0);
if Assigned(Owner) then
Focused := Focused AND (@Self = Owner^.First);
If not Focused or (GOptions AND goThickFramed = 0) then
begin
LeftUpCorner:='Ú';
RightUpCorner:='¿';
HorizontalBar:='Ä';
VerticalBar:='³';
LeftLowCorner:='À';
RightLowCorner:='Ù';
end
else
begin
LeftUpCorner:='É';
RightUpCorner:='»';
HorizontalBar:='Í';
VerticalBar:='º';
LeftLowCorner:='È';
RightLowCorner:='¼';
end;
if Focused then
Color := 2
else
Color := 1;
WriteChar(0,0,LeftUpCorner,Color,1);
WriteChar(1,0,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,0,RightUpcorner,Color,1);
For i:=1 to Size.Y -1 do
begin
WriteChar(0,i,VerticalBar,Color,1);
WriteChar(Size.X-1,i,VerticalBar,Color,1);
end;
WriteChar(0,Size.Y-1,LeftLowCorner,Color,1);
WriteChar(1,Size.Y-1,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,Size.Y-1,RightLowCorner,Color,1);
End;
If (Title<>Nil) AND (GOptions AND goTitled<>0)
Then Begin { View has a title }
GetViewSettings(ViewPort, TextModeGFV);
@ -5143,7 +5146,10 @@ END.
{
$Log$
Revision 1.11 2001-05-30 10:22:25 pierre
Revision 1.12 2001-05-30 13:26:18 pierre
* fix border problems for views and menus
Revision 1.11 2001/05/30 10:22:25 pierre
* fix Shadow bugs
Revision 1.10 2001/05/10 16:46:28 pierre

View File

@ -1048,12 +1048,33 @@ END;
{ Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 11May98 LdB }
{---------------------------------------------------------------------------}
PROCEDURE TMenuBox.Draw;
VAR CNormal, CSelect, CDisabled, Color: Word; Tx, Ty, Y: Integer;
VAR CNormal, CSelect, CDisabled, Color: Word; Index, Tx, Ty, Y: Integer;
S: String; P: PMenuItem; B: TDrawBuffer;
Type
FrameLineType = (UpperLine,NormalLine,SeparationLine,LowerLine);
FrameLineChars = Array[0..2] of char;
Const
FrameLines : Array[FrameLineType] of FrameLineChars =
('ÚÄ¿','³ ³','ÃÄ´','ÀÄÙ');
Procedure CreateBorder(LineType : FrameLineType);
Begin
MoveChar(B, ' ', CNormal, 1);
MoveChar(B[1], FrameLines[LineType][0], CNormal, 1);
MoveChar(B[2], FrameLines[LineType][1], Color, Size.X-4);
MoveChar(B[Size.X-2], FrameLines[LineType][2], CNormal, 1);
MoveChar(B[Size.X-1], ' ', CNormal, 1);
End;
BEGIN
CNormal := GetColor($0301); { Normal colour }
CSelect := GetColor($0604); { Selected colour }
CDisabled := GetColor($0202); { Disabled colour }
If TextModeGFV then
Begin
CreateBorder(UpperLine);
WriteBuf(0, 0, Size.X, 1, B); { Write the line }
End;
Y := 1;
If (Menu <> Nil) Then Begin { We have a menu }
P := Menu^.Items; { Start on first }
@ -1062,18 +1083,30 @@ BEGIN
If (P^.Name <> Nil) Then Begin { Item has text }
If P^.Disabled Then Color := CDisabled { Is item disabled }
Else If (P = Current) Then Color := CSelect; { Select colour }
MoveChar(B, ' ', Color, Size.X-4); { Clear buffer }
If TextModeGFV then
Begin
CreateBorder(NormalLine);
Index:=2;
End
Else
Begin
MoveChar(B, ' ', Color, Size.X-4); { Clear buffer }
Index:=0;
End;
S := ' ' + P^.Name^ + ' '; { Menu string }
MoveCStr(B[0], S, Color); { Transfer string }
MoveCStr(B[Index], S, Color); { Transfer string }
If (P^.Command <> 0) AND(P^.Param <> Nil)
Then Begin
MoveCStr(B[CStrLen(S)], ' - ' + P^.Param^,
MoveCStr(B[CStrLen(S)+Index], ' - ' + P^.Param^,
Color); { Add param chars }
S := S + ' - ' + P^.Param^; { Add to string }
End;
If (OldItem = Nil) OR (OldItem = P) OR
(Current = P) Then Begin { We need to fix draw }
WriteBuf(2, Y, CStrLen(S), 1, B); { Write the line }
If TextModeGFV then
WriteBuf(0, Y, Size.X, 1, B) { Write the whole line }
Else
WriteBuf(2, Y, CStrLen(S), 1, B); { Write the line }
If (P = Current) Then Begin { Selected item }
Tx := 2 * FontWidth; { X offset }
Ty := Y * FontHeight; { Y offset }
@ -1083,15 +1116,20 @@ BEGIN
End;
End;
End Else Begin { no text NewLine }
MoveChar(B, 'Ã', Color, 1);
MoveChar(B[1], 'Ä', Color, Size.X-2);
MoveChar(B[Size.X-1], '´', Color, 1);
Color := CNormal; { Normal colour }
CreateBorder(SeparationLine);
WriteBuf(0, Y, Size.X, 1, B); { Write the line }
End;
Inc(Y); { Next line down }
P := P^.Next; { fetch next item }
End;
End;
If TextModeGFV then
Begin
Color := CNormal; { Normal colour }
CreateBorder(LowerLine);
WriteBuf(0, Size.Y-1, Size.X, 1, B); { Write the line }
End;
END;
{--TMenuBox-----------------------------------------------------------------}
@ -1673,7 +1711,10 @@ END;
END.
{
$Log$
Revision 1.7 2001-05-07 22:22:03 pierre
Revision 1.8 2001-05-30 13:26:17 pierre
* fix border problems for views and menus
Revision 1.7 2001/05/07 22:22:03 pierre
* removed NO_WINDOW cond, added GRAPH_API
Revision 1.6 2001/05/04 15:43:45 pierre

View File

@ -1339,15 +1339,6 @@ END;
{ DrawBorder -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17May98 LdB }
{---------------------------------------------------------------------------}
PROCEDURE TView.DrawBorder;
VAR I : sw_integer;
LeftUpCorner,
RightUpCorner,
HorizontalBar,
VerticalBar,
LeftLowCorner,
RightLowCorner : Char;
Color : Byte;
Focused : Boolean;
BEGIN
If (TextModeGFV = FALSE) Then Begin { GRAPHICS GFV MODE }
BiColorRectangle(0, 0, RawSize.X, RawSize.Y,
@ -1360,44 +1351,8 @@ BEGIN
BiColorRectangle(3, 3, RawSize.X-3, RawSize.Y-3,
White, DarkGray, True); { Draw highlights }
End;
End Else Begin { TEXT GFV MODE }
Focused:=(State AND (sfSelected + sfModal)<>0);
if Assigned(Owner) then
Focused := Focused AND (@Self = Owner^.First);
If not Focused or (GOptions AND goThickFramed = 0) then
begin
LeftUpCorner:='Ú';
RightUpCorner:='¿';
HorizontalBar:='Ä';
VerticalBar:='³';
LeftLowCorner:='À';
RightLowCorner:='Ù';
end
else
begin
LeftUpCorner:='É';
RightUpCorner:='»';
HorizontalBar:='Í';
VerticalBar:='º';
LeftLowCorner:='È';
RightLowCorner:='¼';
end;
if Focused then
Color := 2
else
Color := 1;
WriteChar(0,0,LeftUpCorner,Color,1);
WriteChar(1,0,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,0,RightUpcorner,Color,1);
For i:=1 to Size.Y -1 do
begin
WriteChar(0,i,VerticalBar,Color,1);
WriteChar(Size.X-1,i,VerticalBar,Color,1);
end;
WriteChar(0,Size.Y-1,LeftLowCorner,Color,1);
WriteChar(1,Size.Y-1,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,Size.Y-1,RightLowCorner,Color,1);
End;
{ TView DrawBorder is empty for TextModeGFV }
END;
PROCEDURE TView.DrawShadow;
@ -4990,6 +4945,15 @@ END;
PROCEDURE TWindow.DrawBorder;
VAR Fc, Bc: Byte; X, Y: Integer; S: String;
ViewPort: ViewPortType;
I : sw_integer;
LeftUpCorner,
RightUpCorner,
HorizontalBar,
VerticalBar,
LeftLowCorner,
RightLowCorner : Char;
Color : Byte;
Focused : Boolean;
BEGIN
Fc := GetColor(2) AND $0F; { Foreground colour }
Bc := (GetColor(2) AND $70) SHR 4; { Background colour }
@ -5001,7 +4965,46 @@ BEGIN
If (GOptions AND goThickFramed<>0) Then Inc(Y, 3); { Adjust position }
end;
ClearArea(0, Y, RawSize.X, Y+FontHeight, Bc); { Clear background }
Inherited DrawBorder;
If not TextModeGFV then
Inherited DrawBorder
Else Begin { TEXT GFV MODE }
Focused:=(State AND (sfSelected + sfModal)<>0);
if Assigned(Owner) then
Focused := Focused AND (@Self = Owner^.First);
If not Focused or (GOptions AND goThickFramed = 0) then
begin
LeftUpCorner:='Ú';
RightUpCorner:='¿';
HorizontalBar:='Ä';
VerticalBar:='³';
LeftLowCorner:='À';
RightLowCorner:='Ù';
end
else
begin
LeftUpCorner:='É';
RightUpCorner:='»';
HorizontalBar:='Í';
VerticalBar:='º';
LeftLowCorner:='È';
RightLowCorner:='¼';
end;
if Focused then
Color := 2
else
Color := 1;
WriteChar(0,0,LeftUpCorner,Color,1);
WriteChar(1,0,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,0,RightUpcorner,Color,1);
For i:=1 to Size.Y -1 do
begin
WriteChar(0,i,VerticalBar,Color,1);
WriteChar(Size.X-1,i,VerticalBar,Color,1);
end;
WriteChar(0,Size.Y-1,LeftLowCorner,Color,1);
WriteChar(1,Size.Y-1,HorizontalBar,Color,Size.X-2);
WriteChar(Size.X-1,Size.Y-1,RightLowCorner,Color,1);
End;
If (Title<>Nil) AND (GOptions AND goTitled<>0)
Then Begin { View has a title }
GetViewSettings(ViewPort, TextModeGFV);
@ -5143,7 +5146,10 @@ END.
{
$Log$
Revision 1.11 2001-05-30 10:22:25 pierre
Revision 1.12 2001-05-30 13:26:18 pierre
* fix border problems for views and menus
Revision 1.11 2001/05/30 10:22:25 pierre
* fix Shadow bugs
Revision 1.10 2001/05/10 16:46:28 pierre