end;
procedure TCustomVDBGrid.DefaultDrawColumnCell(const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
Value: string;
begin
Value := '''''''';
if Assigned(Column.Field) then
Value := Column.Field.DisplayText;
WriteText(Canvas, Rect, 2, 2, Value, Column.Alignment);
end;
procedure TCustomVDBGrid.ReadColumns(Reader: TReader);
begin
Columns.Clear;
Reader.ReadValue;
Reader.ReadCollection(Columns);
end;
procedure TCustomVDBGrid.WriteColumns(Writer: TWriter);
begin
Writer.WriteCollection(Columns);
end;
procedure TCustomVDBGrid.DefineProperties(Filer: TFiler);
begin
Filer.DefineProperty(''''Columns'''', ReadColumns, WriteColumns,
((Columns.State = csCustomized) and (Filer.Ancestor = nil)) or
((Filer.Ancestor <> nil) and
((Columns.State <> TCustomVDBGrid(Filer.Ancestor).Columns.State) or
(not CollectionsEqual(Columns, TCustomVDBGrid(Filer.Ancestor).Columns, nil,nil)) )));
end;
procedure TCustomVDBGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
function RowIsMultiSelected: Boolean;
var
Index: Integer;
begin
Result := (dgMultiSelect in Options) and Datalink.Active and
FBookmarks.Find(Datalink.Datasource.Dataset.Bookmark, Index);
end;
var
OldActive: Integer;
Indicator: Integer;
Highlight: Boolean;
Value: string;
DrawColumn: TColumn;
FrameOffs: Byte;
MultiSelected: Boolean;
AACol, AARow: Longint;
begin
if csLoading in ComponentState then
begin
Canvas.Brush.Color := Color;
Canvas.FillRect(ARect);
Exit;
end;
AARow := IIF(FVertical, ACol, ARow);
AACol := IIF(FVertical, ARow, ACol);
Dec(AARow, FTitleOffset);
Dec(AACol, FIndicatorOffset);
if (gdFixed in AState) and ([dgRowLines, dgColLines] * Options =
[dgRowLines, dgColLines]) then
begin
InflateRect(ARect, -1, -1);
FrameOffs := 1;
end
else
FrameOffs := 2;
if (gdFixed in AState) and (AACol < 0) then
begin
Canvas.Brush.Color := FixedColor;
Canvas.FillRect(ARect);
if Assigned(DataLink) and DataLink.Active then
begin
MultiSelected := False;
if AARow >= 0 then
begin
OldActive := FDataLink.ActiveRecord;
try
FDatalink.ActiveRecord := AARow;
MultiSelected := RowIsMultiselected;
finally
FDatalink.ActiveRecord := OldActive;
end;
end;
if (AARow = FDataLink.ActiveRecord) or MultiSelected then
begin
Indicator := 0;
if FDataLink.DataSet <> nil then
case FDataLink.DataSet.State of
dsEdit: Indicator := 1;
dsInsert: Indicator := 2;
dsBrowse:
if MultiSelected then
if (AARow <> FDatalink.ActiveRecord) then
Indicator := 3
else
Indicator := 4; // multiselected and current row
end;
FIndicators.BkColor := FixedColor;
if FVertical then
FIndicators.Draw(Canvas, ARect.Left FrameOffs,
(ARect.Top ARect.Bottom - FIndicators.Height) shr 1, Indicator)
else
FIndicators.Draw(Canvas, ARect.Right - FIndicators.Width - FrameOffs,
(ARect.Top ARect.Bottom - FIndicators.Height) shr 1, Indicator);
if AARow = FDatalink.ActiveRecord then
FSelRow := AARow FTitleOffset;
end;
end;
end
else with Canvas do
begin
DrawColumn := Columns[AACol];
if gdFixed in AState then
begin
Font := DrawColumn.Title.Font;
Brush.Color := DrawColumn.Title.Color;
end
else
begin
Font := DrawColumn.Font;
Brush.Color := DrawColumn.Color;
end;
if AARow < 0 then with DrawColumn.Title do
WriteText(Canvas, ARect, FrameOffs, FrameOffs, Caption, Alignment)
else if (FDataLink = nil) or not FDataLink.Active then
FillRect(ARect)
else
begin
Value := '''''''';
OldActive := FDataLink.ActiveRecord;
try
FDataLink.ActiveRecord := AARow;
if Assigned(DrawColumn.Field) then
Value := DrawColumn.Field.DisplayText;
Highlight := HighlightCell(AACol, AARow, Value, AState);
if Highlight then
begin
Brush.Color := clHighlight;
Font.Color := clHighlightText;
end;
if FDefaultDrawing then
WriteText(Canvas, ARect, 2, 2, Value, DrawColumn.Alignment);
if Columns.State = csDefault then
DrawDataCell(ARect, DrawColumn.Field, AState);
DrawColumnCell(ARect, AACol, DrawColumn, AState);
finally
FDataLink.ActiveRecord := OldActive;
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




