TGridPanel은 델파이XE2 구입후부터 지금까지 Grid로 표시되는 부분 이외의 화면에 사용중인 컴퍼넌트 입니다.
배치에 좀 제약이 있긴해도 화면 구성을 쉽게 할 수 있어서 편리한 컴퍼넌트인데...
HTML의 Table 처럼 각 칸 별로 선이 있으면 더 나을 것 같아서 선을 자동으로 그려주는 기능을 추가해서 사용중입니다.
:
:
TMyGridPanel = class(TGridPanel)
private
{ Private declarations }
FLineColor: TColor;
FLineFlag: Boolean;
protected
{ Protected declarations }
procedure Paint; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
property LineColor: TColor read FLineColor write FLineColor default clSilver;
property LineFlag: Boolean read FLineFlag write FLineFlag default True;
end;
:
:
constructor TMyGridPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLineColor := clSilver;
FLineFlag := True;
BevelOuter := bvNone;
Ctl3D := False;
ParentColor := True;
ParentCtl3D := False;
ShowCaption := False;
end;
procedure TMyGridPanel.Paint;
var
l_Rect: TRect;
i, j, l_Col, l_Row, l_ColSpan, l_RowSpan: Int32;
begin
inherited;
if FLineFlag and (not (csDesigning in ComponentState)) then
begin
Canvas.Pen.Style := psSolid;
Canvas.Pen.Color := FLineColor;
Canvas.Brush.Color := Color;
Canvas.Rectangle(0, 0, Width, Height);
for j := 0 to RowCollection.Count - 1 do
begin
for i := 0 to ColumnCollection.Count - 1 do
begin
if ControlCollection.ControlItems[i,j] <> nil then
begin
l_Rect := CellRect[i,j];
l_Row := ControlCollection.ControlItems[i,j].Row;
l_Col := ControlCollection.ControlItems[i,j].Column;
l_RowSpan := ControlCollection.ControlItems[i,j].RowSpan;
l_ColSpan := ControlCollection.ControlItems[i,j].ColumnSpan;
// Top
if (l_Row >= j) or (l_RowSpan <= 1) then
begin
Canvas.MoveTo(l_Rect.Left, l_Rect.Top);
Canvas.LineTo(l_Rect.Right, l_Rect.Top);
end;
// Bottom
if ((l_Row <> j) or (l_RowSpan <= 1)) and
((l_Row >= j) or ((l_RowSpan + l_Row - j - 1) <= 0)) then
begin
Canvas.MoveTo(l_Rect.Left, l_Rect.Bottom);
Canvas.LineTo(l_Rect.Right, l_Rect.Bottom);
end;
// Left
if (l_Col >= i) or (l_ColSpan <= 1) then
begin
Canvas.MoveTo(l_Rect.Left, l_Rect.Top);
Canvas.LineTo(l_Rect.Left, l_Rect.Bottom);
end;
// Right
if ((l_Col <> i) or (l_ColSpan <= 1)) and
((l_Col >= i) or ((l_ColSpan + l_Col - i - 1) <= 0)) then
begin
Canvas.MoveTo(l_Rect.Right, l_Rect.Top);
Canvas.LineTo(l_Rect.Right, l_Rect.Bottom);
end;
end;
end;
end;
end;
end;
※ 델파이 가격도 오른다고 하고 개인적으로는 일거리 주던 업체들도 하나둘 사라지고... 놀고 있는 날이 길어지니 직업을 바꿔야할 것 같은 위기감이 드네요. ^^
|