新发一个像 Excel 那样的表格控件 ( 积分: 200 )

  • 主题发起人 主题发起人 kinneng
  • 开始时间 开始时间
K

kinneng

Unregistered / Unconfirmed
GUEST, unregistred user!
新发一个像 Excel 那样的表格控件,刚开始做,没有学历,水平有限,
画边框部分就用了两个月,难啊!
初步在 http://kinneng.ys168.com/ 演示
 
flexcel就很好了
 
就是讨厌 ActiveX 才使用 delphi 的,flexcel 是 ActiveX 控件,用 ActiveX 那么
我干脆用 VB,其实用 VB 也不错,就是一大堆文件令人头疼!
 
用StringGrid实现的?
 
可否提供源代码呢?
 
用 TCustomGrid + TList 实现的
 
绘图技术一流啊。。。
 
不给源码。也要对于大家的试用说点原理什么的才好。哈哈
 
你要什么原理?我没有原理
 
我这是发布控件,不是发布技术,不是教学,也不收费。
在网上,这种表格是许多人的生计,如果哪一天,我不玩了,我也考虑像 EasyGrid 的
作者那样,公开源代码,结果就是一个菜鸟从此消失,一项技术永远定格,不会再升级,
最后沉沦,开源控件是 delphi 的卖点,它令当年的 delphi 兴起,也是令今天的delphi
衰落。
 
哈哈,同意楼主观点,对于控件,只要能达到BUG少,费用低,好用就行
 
绘图技术一流,呵呵,肯定的,绘制格子的边框为例,在绘制之前,我用了 一千二百行
代码,预先将要绘制边线,全部分析准备好,然后用几十行的代码落实绘制,这样做效果
好,速度快,没理由不一流,就是代码写得辛苦,如果急功近利,不分析,直接绘制,
即使绘出的图案一样,但闪烁明显,效果同一般老菜的作品没有区别,正所谓,要么不做,
要做就做到比商品级的更好,现在绘制边框部分,已经超过了 Excel 的水平,这个各位
可以比较,我的边框绘制效果跟 Excel 差不多,只是绘线规则不同,算法不同,而我的线
型更丰富,且允许客户自定义,这样技术门槛提高了,各位做同类东西的高手又要辛苦了。
 
控件继承TCustomGrid,但 Paint 部分我自己写,下面是 Paint 的完整代码,比 TCustomGrid 的
还要简单,但效果比它好,最主要的是适用。
procedure TEXGrid.Paint;
var
C, R: Longint;
DrawInfo: TGridDrawInfo;
AFocRect, FocRect: TRect;
UpdateRect: TRect;
Focused: Boolean;
OldPen: TPen;
procedure DrawCells(ACol, ARow: Longint;
StartX, StartY, StopX, StopY: Integer;
Color: TColor;
IncludeDrawState: TGridDrawState);
var
CurCol, CurRow: Longint;
AWhere, Where, TempRect: TRect;
DrawState: TGridDrawState;
begin
CurRow := ARow;
Where.Top := StartY;
if CurRow = FixedRows then
CurRow := TopRow;
while (Where.Top < StopY) and (CurRow <= TopRow + VisibleRowCount + 1) and (CurRow < RowCount)do
begin
CurCol := ACol;
if CurRow = FixedRows then
CurRow := TopRow;
Where.Left := StartX;
Where.Bottom := Where.Top + RowHeights[CurRow];
if FixedCols <> LeftCol then
if CurCol = FixedCols then
CurCol := LeftCol;
while (Where.Left < StopX) and (CurCol <= LeftCol + VisibleColCount + 1) and (CurCol < ColCount)do
begin
if FixedCols <> LeftCol then
if CurCol = FixedCols then
CurCol := LeftCol;
Where.Right := Where.Left + ColWidths[CurCol];
TempRect := Where;
InflateRect(TempRect, 1, 1);
if (Where.Right > Where.Left) and RectVisible(Canvas.Handle, TempRect) then
begin
DrawState := IncludeDrawState;
AWhere := CellInfos[CurCol, CurRow].Merge;
if CellInRect(AWhere, FAnchor.X, FAnchor.Y) then
Include(DrawState, gdFocused);
if PointInGridRect(CurCol, CurRow, Sel) then
Include(DrawState, gdSelected);
if not (gdFocused in DrawState) or not (goEditing in Options) or not EditorMode or (csDesigning in
ComponentState) then
DrawCell(CurCol, CurRow, Where, DrawState);
end;
Where.Left := Where.Right + DrawInfo.Horz.EffectiveLineWidth;
Inc(CurCol);
end;
Where.Top := Where.Bottom + DrawInfo.Vert.EffectiveLineWidth;
Inc(CurRow);
end;
end;

begin

OldPen := TPen.Create;
OldPen.Assign(Canvas.Pen);
if UseRightToLeftAlignment then
ChangeGridOrientation(True);
UpdateRect := Canvas.ClipRect;
for C := ColCount - 1do
wnto 0do
for R := RowCount - 1do
wnto 0do
CellInfos[C, R].Draw := True;
Focused := IsActiveControl;
CalcDrawInfo(DrawInfo);
with DrawInfodo
begin
if (FGridState <> gsRowSizing) and (FGridState <> gsColSizing) then
begin
DrawCells(0, 0, 0, 0, DrawInfo.Horz.GridBoundary, DrawInfo.Vert.GridBoundary, Color, []);
DrawSelectFrame;
SelectClipRgn(Canvas.Handle, 0);
end
else
begin
DrawCells(LeftCol, 0, DrawInfo.Horz.FixedBoundary, 0, DrawInfo.Horz.GridBoundary,
1, FixedColor, [gdFixed]);
DrawCells(0, TopRow, 0, DrawInfo.Vert.FixedBoundary, 1,
DrawInfo.Vert.GridBoundary, FixedColor, [gdFixed]);
end;

if not (csDesigning in ComponentState) and
(goRowSelect in inherited Options) and inherited DefaultDrawing and Focused then
begin
with inherited Selectiondo
FocRect := BoxRect(Left, Top, Right, Bottom);
if not UseRightToLeftAlignment then
Canvas.DrawFocusRect(FocRect)
else
begin
AFocRect := FocRect;
AFocRect.Left := FocRect.Right;
AFocRect.Right := FocRect.Left;
DrawFocusRect(Canvas.Handle, AFocRect);
end;
end;

if (FGridState <> gsRowSizing) and (FGridState <> gsColSizing) then
begin
if Horz.GridBoundary < Horz.GridExtent then
begin
Canvas.Brush.Color := clSilver;
Canvas.FillRect(Rect(Horz.GridBoundary, 0, Horz.GridExtent, Vert.GridBoundary));
end;
if Vert.GridBoundary < Vert.GridExtent then
begin
Canvas.Brush.Color := clSilver;
Canvas.FillRect(Rect(0, Vert.GridBoundary, Horz.GridExtent, Vert.GridExtent));
end;
end
else
begin
if Horz.GridBoundary < Horz.GridExtent then
begin
Canvas.Brush.Color := clSilver;
Canvas.FillRect(Rect(Horz.GridBoundary, 0, Horz.GridExtent, RowHeights[0]));
end;
if Vert.GridBoundary < Vert.GridExtent then
begin
Canvas.Brush.Color := clSilver;
Canvas.FillRect(Rect(0, Vert.GridBoundary, ColWidths[0], Vert.GridExtent));
end;
end;

if DrawDashed = True then
DrawDashedFrame(DashedFrameRect);
end;
if UseRightToLeftAlignment then
ChangeGridOrientation(False);
OldPen.Free;
end;
 
有在QQ问我怎么绘制边框,这里将分析框线部分完整贴出,占程序的 1/20,它分析一个格子 4 条边的
边框如何绘制,按挨首7468标准,菜鸟作品是没有注释的。这里没有使用技巧,全部都是普通代码,组
织起来实现一个巨繁复的算法。
许多人看了或者觉得没意思,或者看晕了,但控件就是这么做出来的,x,y 是待绘格子的坐标。
procedure CheckLine(X, Y: Integer);
var
D, E, F, T: Integer;
Loc: TRect;
LineStyle: Integer;
LineColor: TColor;
LineStyle1: Integer;
LineColor1: TColor;
LineStyle2: Integer;
LineColor2: TColor;
LineStyle3: Integer;
LineColor3: TColor;
LineStyle4: Integer;
LineColor4: TColor;
procedure GetLineStyles;
begin
LineStyle1 := CellInfos[X, Y].TopLineStyle;
LineColor1 := CellInfos[X, Y].TopLineColor;
if Y - 1 >= 0 then
if (FLineWidth[LineStyle1] < FLineWidth[CellInfos[X, Y - 1].BottomLineStyle])
or ((FLineWidth[LineStyle1] = FLineWidth[CellInfos[X, Y - 1].BottomLineStyle])
and (LineColor1 < CellInfos[X, Y - 1].BottomLineColor)) then
begin
LineStyle1 := CellInfos[X, Y - 1].BottomLineStyle;
LineColor1 := CellInfos[X, Y - 1].BottomLineColor;
end;

LineStyle2 := CellInfos[X, Y].LeftLineStyle;
LineColor2 := CellInfos[X, Y].LeftLineColor;
if X - 1 >= 0 then
if (FLineWidth[LineStyle2] < FLineWidth[CellInfos[X - 1, Y].RightLineStyle])
or ((FLineWidth[LineStyle2] = FLineWidth[CellInfos[X - 1, Y].RightLineStyle])
and (LineColor2 < CellInfos[X - 1, Y].RightLineColor)) then
begin
LineStyle2 := CellInfos[X - 1, Y].RightLineStyle;
LineColor2 := CellInfos[X - 1, Y].RightLineColor;
end;

if X - 1 >= 0 then
begin
LineStyle3 := CellInfos[X - 1, Y].TopLineStyle;
LineColor3 := CellInfos[X - 1, Y].TopLineColor;
end
else
begin
LineStyle3 := 0;
LineColor3 := 0;
end;

if (X - 1 >= 0) and (Y - 1 >= 0) then
if (FLineWidth[LineStyle3] < FLineWidth[CellInfos[X - 1, Y - 1].BottomLineStyle])
or ((FLineWidth[LineStyle3] = FLineWidth[CellInfos[X - 1, Y - 1].BottomLineStyle])
and (LineColor3 < CellInfos[X - 1, Y - 1].BottomLineColor)) then
begin
LineStyle3 := CellInfos[X - 1, Y - 1].BottomLineStyle;
LineColor3 := CellInfos[X - 1, Y - 1].BottomLineColor;
end;

if Y - 1 >= 0 then
begin
LineStyle4 := CellInfos[X, Y - 1].LeftLineStyle;
LineColor4 := CellInfos[X, Y - 1].LeftLineColor;
end
else
begin
LineStyle4 := 0;
LineColor4 := 0;
end;

if (X - 1 >= 0) and (Y - 1 >= 0) then
if (FLineWidth[LineStyle4] < FLineWidth[CellInfos[X - 1, Y - 1].RightLineStyle])
or ((FLineWidth[LineStyle4] = FLineWidth[CellInfos[X - 1, Y - 1].RightLineStyle])
and (LineColor4 < CellInfos[X - 1, Y - 1].RightLineColor)) then
begin
LineStyle4 := CellInfos[X - 1, Y - 1].RightLineStyle;
LineColor4 := CellInfos[X - 1, Y - 1].RightLineColor;
end;

if ExtCell then
begin
LineStyle2:=1;
LineColor2:=1;
LineStyle4:=1;
LineColor4:=1;
end;

end;

function DrawQuadrateCorner(AWidth: Integer): Boolean;
begin

result := False;
T := 0;
if FLineWidth[LineStyle1] = AWidth then

T := 1;
if FLineWidth[LineStyle2] = AWidth then
T := T + 2;
if FLineWidth[LineStyle3] = AWidth then

T := T + 4;
if FLineWidth[LineStyle4] = AWidth then
T := T + 8;
if (T <> 0) and (T <> 1) and (T <> 2) and (T <> 4) and (T <> 8) then
begin
Loc := EXBoxRect(X, Y, X, Y);
InflateRect(Loc, 1, 1);
Loc := Rect(Loc.Left - 1, Loc.Top - 1, Loc.Left + AWidth - 1, Loc.Top + AWidth - 1);
case T of
7: begin
if (LineColor2 = LineColor3) and (LineColor1 <> LineColor3) then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
Loc.Bottom := Loc.Top;
end
else
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
Loc.Bottom := Loc.Top;
end;
end;
13: begin

if (LineColor3 = LineColor4) and (LineColor1 <> LineColor3) then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
Loc.Bottom := Loc.Top;
end
else
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
Loc.Bottom := Loc.Top;
end;
end;
5:
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
Loc.Bottom := Loc.Top;
end;
11:
begin
if (LineColor1 = LineColor4) and (LineColor2 <> LineColor4) then
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
Loc.Right := Loc.Left;
end
else
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end;
end;
14:
begin
if (LineColor3 = LineColor4) and (LineColor2 <> LineColor4) then
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
Loc.Right := Loc.Left;
end
else
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end;
end;

10:
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end;
3: begin

E := 1;
if X + E < ColCount then
repeat
LineStyle := CellInfos[X + E, Y].TopLineStyle;
LineColor := CellInfos[X + E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X + E, Y].BottomLineStyle] then
begin
LineStyle := CellInfos[X + E, Y].BottomLineStyle;
LineColor := CellInfos[X + E, Y].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X + E, Y].BottomLineStyle] then
if LineColor < CellInfos[X + E, Y].BottomLineColor then
begin
LineStyle := CellInfos[X + E, Y].BottomLineStyle;
LineColor := CellInfos[X + E, Y].BottomLineColor;
end;
Inc(E);
until (X + E >= ColCount) or (FLineWidth[LineStyle] <> AWidth) or (LineColor1 <> LineColor);
F := 0;
repeat
LineStyle := CellInfos[X, Y + F].LeftLineStyle;
LineColor := CellInfos[X, Y + F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
if LineColor < CellInfos[X - 1, Y + F].RightLineColor then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
Inc(F);
until (Y + F >= RowCount) or (FLineWidth[LineStyle] <> AWidth) or (LineColor2 <> LineColor);
D := 0;
if E > F then
D := 1
else
if E < F then
D := 2
else
if LineColor2 > LineColor1 then
D := 2
else
D := 1;
if FLineCorner[LineStyle1] and not FLineCorner[LineStyle2] then
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end
else
if not FLineCorner[LineStyle1] and FLineCorner[LineStyle2] then
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
Loc.Bottom := Loc.Top;
end
else
if D = 1 then
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
Loc.Bottom := Loc.Top;
end
else
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end;
end;
6: begin
E := 1;
if X - E > 0 then
begin
repeat
LineStyle := CellInfos[X - E, Y].TopLineStyle;
LineColor := CellInfos[X - E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
if LineColor < CellInfos[X - E, Y - 1].BottomLineColor then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
Inc(E);
until (X - E <= 0) or (FLineWidth[LineStyle] <> AWidth) or (LineColor3 <> LineColor);
E := E - 2;
end;

F := 0;
repeat
LineStyle := CellInfos[X, Y + F].LeftLineStyle;
LineColor := CellInfos[X, Y + F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
if LineColor < CellInfos[X - 1, Y + F].RightLineColor then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
Inc(F);
until (Y + F >= RowCount) or (FLineWidth[LineStyle] <> AWidth) or (LineColor2 <> LineColor);
D := 0;
if E > F - 1 then
D := 1
else
if E < F - 1 then
D := 2
else
if (X - 1 > 0) and (LineColor2 > LineColor3) then
D := 2
else
D := 1;
if FLineCorner[LineStyle2] and not FLineCorner[LineStyle3] then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
Loc.Bottom := Loc.Top;
end
else
if not FLineCorner[LineStyle2] and FLineCorner[LineStyle3] then
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end
else
if (D = 1) or FLineCorner[LineStyle2] then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
Loc.Bottom := Loc.Top;
end
else
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end;
end;
9: begin

E := 1;
if X + E < ColCount then
begin
repeat
LineStyle := CellInfos[X + E, Y].TopLineStyle;
LineColor := CellInfos[X + E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X + E, Y - 1].BottomLineStyle] then
begin
LineStyle := CellInfos[X + E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X + E, Y - 1].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X + E, Y - 1].BottomLineStyle] then
if LineColor < CellInfos[X + E, Y - 1].BottomLineColor then
begin
LineStyle := CellInfos[X + E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X + E, Y - 1].BottomLineColor;
end;
Inc(E);
until (X + E >= ColCount) or (FLineWidth[LineStyle] <> AWidth) or (LineColor1 <> LineColor);
E := E - 1;
end;

F := 1;
if Y - F > 0 then
begin
repeat
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X, Y - F].LeftLineStyle] then
begin
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X, Y - F].LeftLineStyle] then
if LineColor < CellInfos[X, Y - F].LeftLineColor then
begin
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
end;
Inc(F);
until (Y - F <= 0) or (FLineWidth[LineStyle] <> AWidth) or (LineColor4 <> LineColor);
F := F - 2;
end;

D := 0;
if E > F then
D := 1
else
if E < F then
D := 2
else
if (X - 1 > 0) and (LineColor4 > LineColor1) then
D := 2
else
D := 1;
if FLineCorner[LineStyle1] and not FLineCorner[LineStyle4] then
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
Loc.Right := Loc.Left;
end
else
if not FLineCorner[LineStyle1] and FLineCorner[LineStyle4] then
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
Loc.Bottom := Loc.Top;
end
else
if (D = 1) or FLineCorner[LineStyle4] then
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
Loc.Bottom := Loc.Top;
end
else
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
Loc.Right := Loc.Left;
end;
end;
12: begin

E := 1;
if X - E > 0 then
begin
repeat
LineStyle := CellInfos[X - E, Y].TopLineStyle;
LineColor := CellInfos[X - E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
if LineColor < CellInfos[X - E, Y - 1].BottomLineColor then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
Inc(E);
until (X - E <= 0) or (FLineWidth[LineStyle] <> AWidth) or (LineColor3 <> LineColor);
E := E - 2;
end;

F := 1;
if Y - F >= 0 then
begin
repeat
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - 1, Y - F].RightLineStyle] then
begin
LineStyle := CellInfos[X - 1, Y - F].RightLineStyle;
LineColor := CellInfos[X - 1, Y - F].RightLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - 1, Y - F].RightLineStyle] then
if LineColor < CellInfos[X - 1, Y - F].RightLineColor then
begin
LineStyle := CellInfos[X - 1, Y - F].RightLineStyle;
LineColor := CellInfos[X - 1, Y - F].RightLineColor;
end;
Inc(F);
until (Y - F >= RowCount) or (FLineWidth[LineStyle] <> AWidth) or (LineColor4 <> LineColor);
F := F - 2;
end;

D := 0;
if E > F then
D := 1
else
if E < F then
D := 2
else
if (X - 1 > 0) and (LineColor4 > LineColor3) then
D := 2
else
D := 1;
if FLineCorner[LineStyle3] and not FLineCorner[LineStyle4] then
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
Loc.Right := Loc.Left;
end
else
if not FLineCorner[LineStyle3] and FLineCorner[LineStyle4] then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
Loc.Bottom := Loc.Top;
end
else
if (D = 1) or FLineCorner[LineStyle4] then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
Loc.Bottom := Loc.Top;
end
else
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
Loc.Right := Loc.Left;
end;
end;
15:
begin
if LineColor2 = LineColor4 then
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
Loc.Right := Loc.Left;
end
else
if LineColor1 = LineColor3 then
begin
LineStyle := LineStyle1;
LineColor := LineStyle1;
Loc.Bottom := Loc.Top;
end
else
if LineColor1 = LineColor2 then
begin
LineStyle := LineStyle1;
LineColor := LineStyle1;
Loc.Bottom := Loc.Top;
end
else
if LineColor1 = LineColor4 then
begin
LineStyle := LineStyle4;
LineColor := LineStyle4;
Loc.Right := Loc.Left;
end
else
if LineColor2 = LineColor3 then
begin
LineStyle := LineStyle2;
LineColor := LineStyle2;
Loc.Right := Loc.Left;
end
else
if LineColor3 = LineColor4 then
begin
LineStyle := LineStyle4;
LineColor := LineStyle4;
Loc.Right := Loc.Left;
end
else
begin
LineStyle := LineStyle1;
LineColor := LineStyle1;
Loc.Bottom := Loc.Top;
end;
end;
end;
Canvas.Pen.Color := LineColor;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle);
result := True;
end;
end;

procedure DrawOtherCorner;
var
R: TRect;
H, W: Integer;
begin
R := EXBoxRect(X, Y, X, Y);
InflateRect(R, 1, 1);
Loc := Rect(R.Left - 1, R.Top - 1, R.Left - 1, R.Top - 1);
LineStyle := 0;
LineColor := 0;
H := 0;
W := 0;
if (FLineWidth[LineStyle1] = 3) or (FLineWidth[LineStyle3] = 3) then
begin
Loc.Bottom := R.Top + 3 - 1;
H := 3;
if (FLineWidth[LineStyle2] <> 3) and (FLineWidth[LineStyle2] <> 0) then
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
W := FLineWidth[LineStyle2];
end
else
if (FLineWidth[LineStyle4] <> 3) and (FLineWidth[LineStyle4] <> 0) then
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
W := FLineWidth[LineStyle4];
end;
end
else
if (FLineWidth[LineStyle2] = 3) or (FLineWidth[LineStyle4] = 3) then
begin
Loc.Right := R.Left + 2;
W := 3;
if (FLineWidth[LineStyle3] <> 3) and (FLineWidth[LineStyle3] <> 0) then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
H := FLineWidth[LineStyle3];
end
else
if (FLineWidth[LineStyle1] <> 3) and (FLineWidth[LineStyle1] <> 0) then
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
H := FLineWidth[LineStyle1];
end;
end
else
if (FLineWidth[LineStyle1] = 2) or (FLineWidth[LineStyle3] = 2) then
begin
Loc.Bottom := R.Top + 2 - 1;
H := 2;
if (FLineWidth[LineStyle2] <> 2) and (FLineWidth[LineStyle2] <> 0) then
begin
LineStyle := LineStyle2;
LineColor := LineColor2;
W := FLineWidth[LineStyle2];
end
else
if (FLineWidth[LineStyle4] <> 2) and (FLineWidth[LineStyle4] <> 0) then
begin
LineStyle := LineStyle4;
LineColor := LineColor4;
W := FLineWidth[LineStyle4];
end;
end
else
if (FLineWidth[LineStyle2] = 2) or (FLineWidth[LineStyle4] = 2) then
begin
Loc.Right := R.Left + 1;
W := 2;
if (FLineWidth[LineStyle3] <> 2) and (FLineWidth[LineStyle3] <> 0) then
begin
LineStyle := LineStyle3;
LineColor := LineColor3;
H := FLineWidth[LineStyle3];
end
else
if (FLineWidth[LineStyle1] <> 2) and (FLineWidth[LineStyle1] <> 0) then
begin
LineStyle := LineStyle1;
LineColor := LineColor1;
H := FLineWidth[LineStyle1];
end;
end;
if W = 1 then
W := 2;
if H = 1 then
H := 2;
Canvas.Pen.Color := LineColor;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle);
end;

function DrawDoubleLineCorner: Boolean;
var
R: TRect;
begin
result := False;
T := 0;
if FLineCorner[LineStyle1] then
T := 1;
if FLineCorner[LineStyle2] then
T := T + 2;
if FLineCorner[LineStyle3] then
T := T + 4;
if FLineCorner[LineStyle4] then
T := T + 8;
if (T <> 0) and (T <> 1) and (T <> 2) and (T <> 4) and (T <> 8) then

begin
Loc := EXBoxRect(X, Y, X, Y);
InflateRect(Loc, 1, 1);
R := Rect(Loc.Left - 1, Loc.Top - 1, Loc.Left + 3 - 1, Loc.Top + 3 - 1);
case T of
7: begin

if LineColor1 <> LineColor2 then
begin
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle3);
end
else
begin
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle3);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1);
end;
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top + 2, Loc.Right, Loc.Bottom, LineStyle2);
end;
13: begin

if LineColor1 <> LineColor4 then
begin
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle3);
end
else
begin
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle3);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1);
end;
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom - 2, LineStyle4);
end;
5:
begin
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
DrawLine(Loc.Left, Loc.Top, Loc.Right - 1, Loc.Bottom, LineStyle3);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
DrawLine(Loc.Left + 1, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1);
end;
11:
begin
if LineColor1 <> LineColor2 then
begin
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle2);
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle4);
end
else
begin
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle4);
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle2);
end;
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
DrawLine(Loc.Left + 2, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1);
end;
14:
begin
if LineColor2 <> LineColor3 then
begin
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle2);
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle4);
end
else
begin
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle4);
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle2);
end;
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
DrawLine(Loc.Left, Loc.Top, Loc.Right - 2, Loc.Bottom, LineStyle3);
end;

10:
begin
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom - 2, LineStyle4);
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top + 1, Loc.Right, Loc.Bottom, LineStyle2);
end;
3: begin

E := 1;
if X + E < ColCount then
repeat
LineStyle := CellInfos[X + E, Y].TopLineStyle;
LineColor := CellInfos[X + E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X + E, Y].BottomLineStyle] then
begin
LineStyle := CellInfos[X + E, Y].BottomLineStyle;
LineColor := CellInfos[X + E, Y].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X + E, Y].BottomLineStyle] then
if LineColor < CellInfos[X + E, Y].BottomLineColor then
begin
LineStyle := CellInfos[X + E, Y].BottomLineStyle;
LineColor := CellInfos[X + E, Y].BottomLineColor;
end;
Inc(E);
until (X + E >= ColCount) or (FLineWidth[LineStyle] <> 3) or (LineColor1 <> LineColor);
F := 0;
repeat
LineStyle := CellInfos[X, Y + F].LeftLineStyle;
LineColor := CellInfos[X, Y + F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
if LineColor < CellInfos[X - 1, Y + F].RightLineColor then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
Inc(F);
until (Y + F >= RowCount) or (FLineWidth[LineStyle] <> 3) or (LineColor2 <> LineColor);
D := 0;
if E > F then
D := 1
else
if E < F then
D := 2
else
if LineColor2 > LineColor1 then
D := 2
else
D := 1;
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle2);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
if D = 1 then
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1, 1)
else
DrawLine(Loc.Left + 1, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1, 1);
end;
6: begin

E := 1;
if X - E > 0 then
begin
repeat
LineStyle := CellInfos[X - E, Y].TopLineStyle;
LineColor := CellInfos[X - E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
if LineColor < CellInfos[X - E, Y - 1].BottomLineColor then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
Inc(E);
until (X - E <= 0) or (FLineWidth[LineStyle] <> 3) or (LineColor3 <> LineColor);
E := E - 2;
end;

F := 0;
repeat
LineStyle := CellInfos[X, Y + F].LeftLineStyle;
LineColor := CellInfos[X, Y + F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - 1, Y + F].RightLineStyle] then
if LineColor < CellInfos[X - 1, Y + F].RightLineColor then
begin
LineStyle := CellInfos[X - 1, Y + F].RightLineStyle;
LineColor := CellInfos[X - 1, Y + F].RightLineColor;
end;
Inc(F);
until (Y + F >= RowCount) or (FLineWidth[LineStyle] <> 3) or (LineColor2 <> LineColor);
D := 0;
if E > F - 1 then
D := 1
else
if E < F - 1 then
D := 2
else
if (X - 1 > 0) and (LineColor2 > LineColor3) then
D := 2
else
D := 1;
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle2);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
if D = 1 then
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle3, 3)
else
DrawLine(Loc.Left, Loc.Top, Loc.Right - 1, Loc.Bottom, LineStyle3, 3);
end;
9: begin

E := 1;
if X + E < ColCount then
begin
repeat
LineStyle := CellInfos[X + E, Y].TopLineStyle;
LineColor := CellInfos[X + E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X + E, Y - 1].BottomLineStyle] then
begin
LineStyle := CellInfos[X + E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X + E, Y - 1].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X + E, Y - 1].BottomLineStyle] then
if LineColor < CellInfos[X + E, Y - 1].BottomLineColor then
begin
LineStyle := CellInfos[X + E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X + E, Y - 1].BottomLineColor;
end;
Inc(E);
until (X + E >= ColCount) or (FLineWidth[LineStyle] <> 3) or (LineColor1 <> LineColor);
E := E - 1;
end;

F := 1;
if Y - F > 0 then
begin
repeat
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X, Y - F].LeftLineStyle] then
begin
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X, Y - F].LeftLineStyle] then
if LineColor < CellInfos[X, Y - F].LeftLineColor then
begin
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
end;
Inc(F);
until (Y - F <= 0) or (FLineWidth[LineStyle] <> 3) or (LineColor4 <> LineColor);
F := F - 2;
end;

D := 0;
if E > F then
D := 1
else
if E < F then
D := 2
else
if (X - 1 > 0) and (LineColor4 > LineColor1) then
D := 2
else
D := 1;
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle4);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
if D = 1 then
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1, 2)
else
DrawLine(Loc.Left + 1, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1, 2);
end;
12: begin

E := 1;
if X - E > 0 then
begin
repeat
LineStyle := CellInfos[X - E, Y].TopLineStyle;
LineColor := CellInfos[X - E, Y].TopLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - E, Y - 1].BottomLineStyle] then
if LineColor < CellInfos[X - E, Y - 1].BottomLineColor then
begin
LineStyle := CellInfos[X - E, Y - 1].BottomLineStyle;
LineColor := CellInfos[X - E, Y - 1].BottomLineColor;
end;
Inc(E);
until (X - E <= 0) or (FLineWidth[LineStyle] <> 3) or (LineColor3 <> LineColor);
E := E - 2;
end;

F := 1;
if Y - F >= 0 then
begin
repeat
LineStyle := CellInfos[X, Y - F].LeftLineStyle;
LineColor := CellInfos[X, Y - F].LeftLineColor;
if FLineWidth[LineStyle] < FLineWidth[CellInfos[X - 1, Y - F].RightLineStyle] then
begin
LineStyle := CellInfos[X - 1, Y - F].RightLineStyle;
LineColor := CellInfos[X - 1, Y - F].RightLineColor;
end;
if FLineWidth[LineStyle] = FLineWidth[CellInfos[X - 1, Y - F].RightLineStyle] then
if LineColor < CellInfos[X - 1, Y - F].RightLineColor then
begin
LineStyle := CellInfos[X - 1, Y - F].RightLineStyle;
LineColor := CellInfos[X - 1, Y - F].RightLineColor;
end;
Inc(F);
until (Y - F >= RowCount) or (FLineWidth[LineStyle] <> 3) or (LineColor4 <> LineColor);
F := F - 2;
end;

D := 0;
if E > F then
D := 1
else
if E < F then
D := 2
else
if (X - 1 > 0) and (LineColor4 > LineColor3) then
D := 2
else
D := 1;
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle4);
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor3;
if D = 1 then
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom, LineStyle3, 4)
else
DrawLine(Loc.Left, Loc.Top, Loc.Right - 1, Loc.Bottom, LineStyle3, 4);
end;
15:
begin
Loc := R;
Loc.Bottom := Loc.Top;
Canvas.Pen.Color := LineColor1;
DrawLine(Loc.Left + 2, Loc.Top, Loc.Right, Loc.Bottom, LineStyle1);
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor2;
DrawLine(Loc.Left, Loc.Top + 2, Loc.Right, Loc.Bottom, LineStyle2);
Loc := R;
Loc.Right := Loc.Left;
Canvas.Pen.Color := LineColor4;
DrawLine(Loc.Left, Loc.Top, Loc.Right, Loc.Bottom - 2, LineStyle4);
end;
end;
result := True;
end;
end;

begin
GetLineStyles;
if DrawDoubleLineCorner = False then
if DrawQuadrateCorner(3) = False then
if DrawQuadrateCorner(2) = False then
DrawOtherCorner;
end;

procedure DefLine(ARect: TRect;
LeftTop: Boolean;
Horz: Boolean = True);
begin
with Canvas, ARectdo
begin
if Horz then
begin
Pen.Color := clSilver;
if ShowColumnTitle and (ARow = 0) then

Pen.Color := clGray;
if ShowIndicator and (ACol = 0) then

Pen.Color := clGray;
if (ACol = FixedCols - 1) then

Pen.Color := $00888888;
if LeftTop then
Polyline([Point(Left - 1, Top), Point(Left - 1, Bottom + 1)])
else
Polyline([Point(Right, Top), Point(Right, Bottom + 1)]);
end
else
begin
Pen.Color := clSilver;
if ShowIndicator and (ACol = 0) then
Pen.Color := clGray;
if ShowColumnTitle and (ARow = 0) then
Pen.Color := clGray;
if (ARow = FixedRows - 1) then
Pen.Color := $00888888;
if LeftTop then
Polyline([Point(Left, Top - 1), Point(Right + 1, Top - 1)])
else
Polyline([Point(Left, Bottom), Point(Right + 1, Bottom)]);
end;

end;
end;

procedure DrawBorderLine(ARect: TRect;
CellRect: TRect);
var
X, Y, Z: Integer;
R, Loc, G: TRect;
LineStyle: Integer;
LineColor: TColor;
begin
G := ARect;
InflateRect(G, 1, 1);
R := CellRect;
CheckLine(R.Left, R.Top);
X := CellRect.Left;
for Y := R.Top to R.Bottomdo

begin
LineStyle := CellInfos[X, Y].LeftLineStyle;
LineColor := CellInfos[X, Y].LeftLineColor;
if X - 1 >= 0 then
if (FLineWidth[LineStyle] < FLineWidth[CellInfos[X - 1, Y].RightLineStyle])
or ((LineStyle = 0) and (CellInfos[X - 1, Y].RightLineStyle = 1))
or ((FLineWidth[LineStyle] = FLineWidth[CellInfos[X - 1, Y].RightLineStyle])
and (LineColor < CellInfos[X - 1, Y].RightLineColor)) then
begin
LineStyle := CellInfos[X - 1, Y].RightLineStyle;
LineColor := CellInfos[X - 1, Y].RightLineColor;
end;

if ExtCell then
begin
LineStyle:=1;
LineColor:=1;
end;

Loc := EXBoxRect(X, Y, X, Y);
if LineStyle = 0 then
begin
DefLine(Loc, True);
InflateRect(Loc, 1, 1);
end
else
begin
InflateRect(Loc, 1, 1);
Z := FLineWidth[LineStyle];
if Z >= 1 then
begin
Canvas.Pen.Color := LineColor;
DrawLine(Loc.Left - 1, Loc.Top, Loc.Left - 1, Loc.Bottom, LineStyle);
end;
end;
end;

Y := CellRect.Top;
for X := R.Left to R.Rightdo

begin
LineStyle := CellInfos[X, Y].TopLineStyle;
LineColor := CellInfos[X, Y].TopLineColor;
if Y - 1 >= 0 then

if (FLineWidth[LineStyle] < FLineWidth[CellInfos[X, Y - 1].BottomLineStyle])
or ((LineStyle = 0) and (CellInfos[X, Y - 1].BottomLineStyle = 1))
or ((FLineWidth[LineStyle] = FLineWidth[CellInfos[X, Y - 1].BottomLineStyle])
and (LineColor < CellInfos[X, Y - 1].BottomLineColor))
then
begin
LineStyle := CellInfos[X, Y - 1].BottomLineStyle;
LineColor := CellInfos[X, Y - 1].BottomLineColor;
end;
Loc := EXBoxRect(X, Y, X, Y);
if LineStyle = 0 then
begin
DefLine(Loc, True, False);
InflateRect(Loc, 1, 1);
end
else
begin
InflateRect(Loc, 1, 1);
Z := FLineWidth[LineStyle];
if Z >= 1 then
begin
Canvas.Pen.Color := LineColor;
DrawLine(Loc.Left, Loc.Top - 1, Loc.Right, Loc.Top - 1, LineStyle);
end;
end;
end;

X := CellRect.Right;
for Y := R.Top to R.Bottomdo

begin
LineStyle := CellInfos[X, Y].RightLineStyle;
LineColor := CellInfos[X, Y].RightLineColor;
if X < ColCount - 1 then
if (FLineWidth[LineStyle] < FLineWidth[CellInfos[X + 1, Y].LeftLineStyle])
or ((LineStyle = 0) and (CellInfos[X + 1, Y].LeftLineStyle = 1))
or ((FLineWidth[LineStyle] = FLineWidth[CellInfos[X + 1, Y].LeftLineStyle]) and
(LineColor < CellInfos[X + 1, Y].LeftLineColor)) then
begin
LineStyle := CellInfos[X + 1, Y].LeftLineStyle;
LineColor := CellInfos[X + 1, Y].LeftLineColor;
end;
if ExtCell then
begin
LineStyle:=1;
LineColor:=1;
end;

Loc := EXBoxRect(X, Y, X, Y);
if LineStyle = 0 then
begin
DefLine(Loc, False);
InflateRect(Loc, 1, 1);
end
else
begin
InflateRect(Loc, 1, 1);
Z := FLineWidth[LineStyle];
if Z >= 1 then
begin

if (R.Right <> FixedCols - 1) or (LeftCol = FixedCols) then
if R.Right = ColCount - 1 then
begin
Canvas.Pen.Color := LineColor;
DrawLine(Loc.Right - 2, Loc.Top, Loc.Right - 2, Loc.Bottom, LineStyle);
end;
end;
end;
end;

Y := CellRect.Bottom;
for X := R.Left to R.Rightdo

begin
LineStyle := CellInfos[X, Y].BottomLineStyle;
LineColor := CellInfos[X, Y].BottomLineColor;
if Y < RowCount - 1 then
if (FLineWidth[LineStyle] < FLineWidth[CellInfos[X, Y + 1].TopLineStyle])
or ((LineStyle = 0) and (CellInfos[X, Y + 1].TopLineStyle = 1))
or ((FLineWidth[LineStyle] = FLineWidth[CellInfos[X, Y + 1].TopLineStyle]) and
(LineColor < CellInfos[X, Y + 1].TopLineColor)) then
begin
LineStyle := CellInfos[X, Y + 1].TopLineStyle;
LineColor := CellInfos[X, Y + 1].TopLineColor;
end;
Loc := EXBoxRect(X, Y, X, Y);
if LineStyle = 0 then
begin
DefLine(Loc, False, False);
InflateRect(Loc, 1, 1);
end
else
begin
InflateRect(Loc, 1, 1);
Z := FLineWidth[LineStyle];
if Z >= 1 then
begin
if (R.Bottom <> FixedRows - 1) or (TopRow = FixedRows) then
if R.Bottom = RowCount - 1 then
begin
Canvas.Pen.Color := LineColor;
DrawLine(Loc.Left + T, Loc.Bottom - 2, Loc.Right, Loc.Bottom - 2, LineStyle);
end;
end;
end;
end;
 

Similar threads

D
回复
0
查看
832
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部