mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 14:36:09 +02:00
tpipro: draw css table border using style and color
git-svn-id: trunk@22567 -
This commit is contained in:
parent
09023a487e
commit
c88c2b2dce
@ -33,6 +33,8 @@
|
|||||||
FColor: TColor;
|
FColor: TColor;
|
||||||
FStyle: TCSSBorderStyle;
|
FStyle: TCSSBorderStyle;
|
||||||
FWidth: Integer;
|
FWidth: Integer;
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
published
|
published
|
||||||
property Color: TColor read FColor write FColor;
|
property Color: TColor read FColor write FColor;
|
||||||
property Style: TCSSBorderStyle read FStyle write FStyle;
|
property Style: TCSSBorderStyle read FStyle write FStyle;
|
||||||
@ -805,6 +807,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCSSBorder }
|
||||||
|
|
||||||
|
constructor TCSSBorder.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
FWidth := -1;
|
||||||
|
FColor := clBlack;
|
||||||
|
FStyle := cbsNone;
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFDEF IP_LAZARUS_DBG}
|
{$IFDEF IP_LAZARUS_DBG}
|
||||||
procedure DumpTCSSProps(aProp: TCSSProps);
|
procedure DumpTCSSProps(aProp: TCSSProps);
|
||||||
var
|
var
|
||||||
|
@ -86,6 +86,7 @@ uses
|
|||||||
GIFImage,
|
GIFImage,
|
||||||
JPeg,
|
JPeg,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
GraphUtil,
|
||||||
Controls,
|
Controls,
|
||||||
StdCtrls,
|
StdCtrls,
|
||||||
ExtCtrls,
|
ExtCtrls,
|
||||||
@ -2200,6 +2201,8 @@ type
|
|||||||
private
|
private
|
||||||
FBgColor: TColor;
|
FBgColor: TColor;
|
||||||
FBorder: Integer;
|
FBorder: Integer;
|
||||||
|
FBorderColor: TColor;
|
||||||
|
FBorderStyle: TCSSBorderStyle;
|
||||||
FCellSpacing: Integer;
|
FCellSpacing: Integer;
|
||||||
FCellPadding: Integer;
|
FCellPadding: Integer;
|
||||||
FFrame: TIpHtmlFrameProp;
|
FFrame: TIpHtmlFrameProp;
|
||||||
@ -2253,6 +2256,8 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
property BgColor : TColor read FBgColor write FBgColor;
|
property BgColor : TColor read FBgColor write FBgColor;
|
||||||
property Border : Integer read FBorder write SetBorder; {!!.10}
|
property Border : Integer read FBorder write SetBorder; {!!.10}
|
||||||
|
property BorderStyle: TCSSBorderStyle read FBorderStyle write FBorderStyle;
|
||||||
|
property BorderColor: TColor read FBorderColor write FBorderColor;
|
||||||
property CalcMinWidth: Integer read FMin; {!!.10}
|
property CalcMinWidth: Integer read FMin; {!!.10}
|
||||||
property CalcMaxWidth: Integer read FMax; {!!.10}
|
property CalcMaxWidth: Integer read FMax; {!!.10}
|
||||||
property CalcTableWidth: Integer read FTableWidth; {!!.10}
|
property CalcTableWidth: Integer read FTableWidth; {!!.10}
|
||||||
@ -3701,6 +3706,26 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
function CalcBorderColor(AColor: TColor; AStyle: TCSSBorderStyle; ASide: TIpHtmlFrameProp): TColor;
|
||||||
|
begin
|
||||||
|
case AStyle of
|
||||||
|
cbsRidge,
|
||||||
|
cbsInset:
|
||||||
|
if ASide in [hfAbove, hfLhs] then
|
||||||
|
Result := ColorAdjustLuma(AColor, -60, False)
|
||||||
|
else
|
||||||
|
Result := ColorAdjustLuma(AColor, 60, False);
|
||||||
|
cbsGroove,
|
||||||
|
cbsOutset:
|
||||||
|
if ASide in [hfAbove, hfLhs] then
|
||||||
|
Result := ColorAdjustLuma(AColor, 60, False)
|
||||||
|
else
|
||||||
|
Result := ColorAdjustLuma(AColor, -60, False);
|
||||||
|
else
|
||||||
|
Result := AColor;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
RegisterComponents('IPro', [TIpHtmlPanel]);
|
RegisterComponents('IPro', [TIpHtmlPanel]);
|
||||||
@ -7321,13 +7346,6 @@ begin
|
|||||||
Width := ParseHyperLength(htmlAttrWIDTH, '');
|
Width := ParseHyperLength(htmlAttrWIDTH, '');
|
||||||
Width.OnChange := WidthChanged; {!!.10}
|
Width.OnChange := WidthChanged; {!!.10}
|
||||||
Border := ParseInteger(htmlAttrBORDER, 0);
|
Border := ParseInteger(htmlAttrBORDER, 0);
|
||||||
if Border = 0 then begin
|
|
||||||
Frame := hfVoid;
|
|
||||||
Rules := hrNone;
|
|
||||||
end else begin
|
|
||||||
Frame := hfBorder;
|
|
||||||
Rules := hrAll;
|
|
||||||
end;
|
|
||||||
CellSpacing := ParseInteger(htmlAttrCELLSPACING, 2);
|
CellSpacing := ParseInteger(htmlAttrCELLSPACING, 2);
|
||||||
CellPadding := ParseInteger(htmlAttrCELLPADDING, 2);
|
CellPadding := ParseInteger(htmlAttrCELLPADDING, 2);
|
||||||
ParseBaseProps(Self);
|
ParseBaseProps(Self);
|
||||||
@ -13441,6 +13459,8 @@ begin
|
|||||||
FColCount := -1;
|
FColCount := -1;
|
||||||
FMin := -1;
|
FMin := -1;
|
||||||
FMax := -1;
|
FMax := -1;
|
||||||
|
FBorderColor := $808080;
|
||||||
|
FBorderStyle := cbsInset;
|
||||||
ColTextWidth := TIntArr.Create;
|
ColTextWidth := TIntArr.Create;
|
||||||
ColStart := TIntArr.Create;
|
ColStart := TIntArr.Create;
|
||||||
ColTextWidthMin := TIntArr.Create;
|
ColTextWidthMin := TIntArr.Create;
|
||||||
@ -13448,7 +13468,7 @@ begin
|
|||||||
RowSp := TIntArr.Create;
|
RowSp := TIntArr.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNodeTABLE.Draw;
|
procedure TIpHtmlNodeTABLE.Draw(Block: TIpHtmlNodeBlock);
|
||||||
var
|
var
|
||||||
z, i, j : Integer;
|
z, i, j : Integer;
|
||||||
R : TRect;
|
R : TRect;
|
||||||
@ -13533,27 +13553,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{render frames}
|
{render frames}
|
||||||
|
// to frame
|
||||||
if Frame in [hfAbove, hfHSides, hfBox, hfBorder] then
|
if Frame in [hfAbove, hfHSides, hfBox, hfBorder] then
|
||||||
if Border = 1 then
|
if Border = 1 then
|
||||||
ScreenLine(
|
ScreenLine(
|
||||||
BorderRect.TopLeft,
|
BorderRect.TopLeft,
|
||||||
Point(BorderRect.Right-1, BorderRect.Top),
|
Point(BorderRect.Right-1, BorderRect.Top),
|
||||||
1,
|
1,
|
||||||
RGB(220,220,220))
|
CalcBorderColor(BorderColor, BorderStyle, hfAbove))
|
||||||
else
|
else
|
||||||
ScreenPolygon(
|
ScreenPolygon(
|
||||||
[BorderRect.TopLeft,
|
[BorderRect.TopLeft,
|
||||||
Point(BorderRect.Right, BorderRect.Top),
|
Point(BorderRect.Right, BorderRect.Top),
|
||||||
Point(BorderRect.Right - (Border - 1), BorderRect.Top + Border - 1),
|
Point(BorderRect.Right - (Border - 1), BorderRect.Top + Border - 1),
|
||||||
Point(BorderRect.Left + Border - 1, BorderRect.Top + Border - 1)],
|
Point(BorderRect.Left + Border - 1, BorderRect.Top + Border - 1)],
|
||||||
RGB(220,220,220));
|
CalcBorderColor(BorderColor, BorderStyle, hfAbove));
|
||||||
|
// bottom frame
|
||||||
if Frame in [hfBelow, hfHSides, hfBox, hfBorder] then
|
if Frame in [hfBelow, hfHSides, hfBox, hfBorder] then
|
||||||
if Border = 1 then
|
if Border = 1 then
|
||||||
ScreenLine(
|
ScreenLine(
|
||||||
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
|
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
|
||||||
Point(BorderRect.Left, BorderRect.Bottom - 1),
|
Point(BorderRect.Left, BorderRect.Bottom - 1),
|
||||||
1,
|
1,
|
||||||
RGB(64,64,64))
|
CalcBorderColor(BorderColor, BorderStyle, hfBelow))
|
||||||
else
|
else
|
||||||
ScreenPolygon(
|
ScreenPolygon(
|
||||||
[
|
[
|
||||||
@ -13561,28 +13583,30 @@ begin
|
|||||||
Point(BorderRect.Right - (Border - 1), BorderRect.Bottom - (Border - 1) - 1),
|
Point(BorderRect.Right - (Border - 1), BorderRect.Bottom - (Border - 1) - 1),
|
||||||
Point(BorderRect.Left + Border, BorderRect.Bottom - (Border - 1) - 1),
|
Point(BorderRect.Left + Border, BorderRect.Bottom - (Border - 1) - 1),
|
||||||
Point(BorderRect.Left, BorderRect.Bottom - 1)],
|
Point(BorderRect.Left, BorderRect.Bottom - 1)],
|
||||||
RGB(64,64,64));
|
CalcBorderColor(BorderColor, BorderStyle, hfBelow));
|
||||||
|
// left frame
|
||||||
if Frame in [hfLhs, hfvSides, hfBox, hfBorder] then
|
if Frame in [hfLhs, hfvSides, hfBox, hfBorder] then
|
||||||
if Border = 1 then
|
if Border = 1 then
|
||||||
ScreenLine(
|
ScreenLine(
|
||||||
BorderRect.TopLeft,
|
BorderRect.TopLeft,
|
||||||
Point(BorderRect.Left, BorderRect.Bottom - 1),
|
Point(BorderRect.Left, BorderRect.Bottom - 1),
|
||||||
1,
|
1,
|
||||||
RGB(192,192,192))
|
CalcBorderColor(BorderColor, BorderStyle, hfLhs))
|
||||||
else
|
else
|
||||||
ScreenPolygon(
|
ScreenPolygon(
|
||||||
[BorderRect.TopLeft,
|
[BorderRect.TopLeft,
|
||||||
Point(BorderRect.Left, BorderRect.Bottom - 1),
|
Point(BorderRect.Left, BorderRect.Bottom - 1),
|
||||||
Point(BorderRect.Left + (Border - 1), BorderRect.Bottom - Border),
|
Point(BorderRect.Left + (Border - 1), BorderRect.Bottom - Border),
|
||||||
Point(BorderRect.Left + (Border - 1), BorderRect.Top + (Border - 1))],
|
Point(BorderRect.Left + (Border - 1), BorderRect.Top + (Border - 1))],
|
||||||
RGB(192,192,192));
|
CalcBorderColor(BorderColor, BorderStyle, hfLhs));
|
||||||
|
// right frame
|
||||||
if Frame in [hfRhs, hfvSides, hfBox, hfBorder] then
|
if Frame in [hfRhs, hfvSides, hfBox, hfBorder] then
|
||||||
if Border = 1 then
|
if Border = 1 then
|
||||||
ScreenLine(
|
ScreenLine(
|
||||||
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
|
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
|
||||||
Point(BorderRect.Right - 1, BorderRect.Top),
|
Point(BorderRect.Right - 1, BorderRect.Top),
|
||||||
1,
|
1,
|
||||||
RGB(128,128,128))
|
CalcBorderColor(BorderColor, BorderStyle, hfRhs))
|
||||||
else
|
else
|
||||||
ScreenPolygon(
|
ScreenPolygon(
|
||||||
[
|
[
|
||||||
@ -13590,7 +13614,7 @@ begin
|
|||||||
Point(BorderRect.Right - 1, BorderRect.Top),
|
Point(BorderRect.Right - 1, BorderRect.Top),
|
||||||
Point(BorderRect.Right - (Border - 1) - 1, BorderRect.Top + (Border - 1)),
|
Point(BorderRect.Right - (Border - 1) - 1, BorderRect.Top + (Border - 1)),
|
||||||
Point(BorderRect.Right - (Border - 1) - 1, BorderRect.Bottom - Border)],
|
Point(BorderRect.Right - (Border - 1) - 1, BorderRect.Bottom - Border)],
|
||||||
RGB(128,128,128));
|
CalcBorderColor(BorderColor, BorderStyle, hfRhs));
|
||||||
|
|
||||||
{render caption}
|
{render caption}
|
||||||
if assigned(FCaption) then
|
if assigned(FCaption) then
|
||||||
@ -13814,10 +13838,16 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
// if Element.BGColor <> -1 then
|
// if Element.BGColor <> -1 then
|
||||||
// BgColor := Element.BGColor;
|
// BgColor := Element.BGColor;
|
||||||
if Element.Border.Width <> -1 then
|
if Element.Border.Style <> cbsNone then
|
||||||
begin
|
begin
|
||||||
Border := Element.Border.Width;
|
FBorder := Element.Border.Width;
|
||||||
|
BorderColor := Element.Border.Color;
|
||||||
|
BorderStyle := Element.Border.Style;
|
||||||
|
if Frame = hfVoid then
|
||||||
|
begin
|
||||||
|
Frame := hfBorder;
|
||||||
|
Rules := hrGroups;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
Loading…
Reference in New Issue
Block a user