📄 iplottable.pas
字号:
Polyline([Point(FGridRect.Left, CurrentPos), Point(FGridRect.Right+1, CurrentPos)]);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.DrawColumnTitles(const Canvas: TCanvas);
var
x : Integer;
CurrentLeft : Integer;
ARect : TRect;
ACharWidth : Integer;
begin
if not FColumnTitlesVisible then Exit;
with Canvas do
begin
Font.Assign(FColumnTitlesFont);
Brush.Style := bsClear;
ACharWidth := TextWidth ('0');
CurrentLeft := FGridRect.Left;
for x := 0 to ColumnCount-1 do
begin
if not Column[x].Visible then Continue;
Font.Color := Column[x].TitleFontColor;
ARect := Rect(CurrentLeft, FTitleRect.Top, CurrentLeft + Column[x].WidthPixels, FTitleRect.Bottom);
case Column[x].TitleAlignment of
iahCenter : iDrawText(Canvas, Column[x].Title, ARect, [itfHCenter, itfVCenter, itfSingleLine]);
iahLeft : begin
ARect.Left := ARect.Left + Round(Column[x].TitleAlignmentMargin * ACharWidth);
iDrawText(Canvas, Column[x].Title, ARect, [itfHLeft, itfVCenter, itfSingleLine]);
end;
iahRight : begin
ARect.Right := ARect.Right - Round(Column[x].TitleAlignmentMargin * ACharWidth);
iDrawText(Canvas, Column[x].Title, ARect, [itfHRight, itfVCenter, itfSingleLine]);
end;
end;
CurrentLeft := CurrentLeft + Column[x].WidthPixels;
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.DrawData(const Canvas: TCanvas);
var
Row, Col : Integer;
CurrentLeft : Integer;
CurrentTop : Integer;
ARect : TRect;
ACharWidth : Integer;
begin
with Canvas do
begin
Font.Assign(FDataFont);
Brush.Style := bsClear;
ACharWidth := TextWidth ('0');
CurrentTop := FTitleRect.Bottom;
for Row := FItemViewStartIndex to FItemViewStopIndex do
begin
CurrentLeft := FGridRect.Left;
for Col := 0 to ColumnCount-1 do
begin
if not Column[Col].Visible then Continue;
Font.Color := Column[Col].DataFontColor;
ARect := Rect(CurrentLeft, CurrentTop, CurrentLeft + Column[Col].WidthPixels, CurrentTop + FRowHeight);
case Column[Col].DataAlignment of
iahCenter : iDrawText(Canvas, Data[Col, Row], ARect, [itfHCenter, itfVCenter, itfSingleLine]);
iahLeft : begin
ARect.Left := ARect.Left + Round(Column[Col].DataAlignmentMargin * ACharWidth);
iDrawText(Canvas, Data[Col, Row], ARect, [itfHLeft, itfVCenter, itfSingleLine]);
end;
iahRight : begin
ARect.Right := ARect.Right - Round(Column[Col].DataAlignmentMargin * ACharWidth);
iDrawText(Canvas, Data[Col, Row], ARect, [itfHRight, itfVCenter, itfSingleLine]);
end;
end;
CurrentLeft := CurrentLeft + Column[Col].WidthPixels;
end;
CurrentTop := CurrentTop + FRowHeight;
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.DrawUpButton(const Canvas: TCanvas);
var
CenterPoint : TPoint;
begin
if not FUpButton.Visible then Exit;
with Canvas do
begin
FUpButton.Draw(Canvas, GridBackGroundColor);
if FUpButton.Enabled then
begin
Pen.Color := clBlack;
Brush.Color := clBlack;
end
else
begin
Pen.Color := clGray;
Brush.Color := clGray;
end;
CenterPoint.X := (FUpButton.Left + FUpButton.Right) div 2;
CenterPoint.Y := (FUpButton.Bottom + FUpButton.Top ) div 2;
Polygon([Point(CenterPoint.x - 4, CenterPoint.y + 2),
Point(CenterPoint.x + 4, CenterPoint.y + 2),
Point(CenterPoint.x, CenterPoint.y - 2)]);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.DrawDownButton(const Canvas: TCanvas);
var
CenterPoint : TPoint;
begin
if not FDownButton.Visible then Exit;
with Canvas do
begin
FDownButton.Draw(Canvas, GridBackGroundColor);
if FDownButton.Enabled then
begin
Pen.Color := clBlack;
Brush.Color := clBlack;
end
else
begin
Pen.Color := clGray;
Brush.Color := clGray;
end;
CenterPoint.X := (FDownButton.Left + FDownButton.Right) div 2;
CenterPoint.Y := (FDownButton.Bottom + FDownButton.Top ) div 2;
Polygon([Point(CenterPoint.x - 4, CenterPoint.y - 2),
Point(CenterPoint.x + 4, CenterPoint.y - 2),
Point(CenterPoint.x, CenterPoint.y + 2)]);
end;
end;
//****************************************************************************************************************************************************
function TiPlotTable.GetRequiredWidth(const Canvas: TCanvas) : Integer;
begin
CalcRects(Canvas);
if Horizontal then Result := FRequiredHeight else Result := FRequiredWidth;
end;
//****************************************************************************************************************************************************
{ TiPlotTableButton }
//****************************************************************************************************************************************************
procedure TiPlotTableButton.Draw(const Canvas: TCanvas; const BackGroundColor: TColor);
var
ARect : TRect;
begin
if not Visible then exit;
with Canvas do
begin
ARect := DrawRect;
Brush.Color := clBtnFace;
FillRect(ARect);
if MouseDown then
iDrawEdge(Canvas, ARect, idesSunken)
else
iDrawEdge(Canvas, ARect, idesRaised);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.ButtonInvalidate(Sender: TObject);
begin
TriggerInvalidateNow(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.DownButtonClick(Sender: TObject);
begin
if FItemViewStartIndex < FRowDataList.Count-1 then FItemViewStartIndex := FItemViewStartIndex + 1;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.UpButtonClick(Sender: TObject);
begin
if FItemViewStartIndex > 0 then FItemViewStartIndex := FItemViewStartIndex - 1;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.NotificationSetFocus(Sender: TObject);
begin
if Sender = Self then Exit;
if not (Sender as TiPlotObject).UserSelected then Exit;
SetUserSelected(False);
end;
//***************************************************************************************************************************************************
procedure TiPlotTable.DoMouseUp(MouseData: TiPlotMouseData);
begin
if MouseDown then
begin
if PtInRect(DrawRect, Point(MouseData.X, MouseData.Y)) then TiPlotComponentAccess(Owner).DoObjectClick(Self);
end;
end;
//****************************************************************************************************************************************************
function TiPlotTable.AddRow: Integer;
begin
Result := FRowDataList.Add('');
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.DeleteRow(Index: Integer);
begin
FRowDataList.Delete(Index);
end;
//****************************************************************************************************************************************************
function TiPlotTable.GetRowCount: Integer;
begin
Result := FRowDataList.Count;
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.RemoveAllRows;
begin
FRowDataList.Clear;
end;
//****************************************************************************************************************************************************
function TiPlotTable.GetData(Col, Row: Integer): String;
var
RowString : String;
begin
RowString := FRowDataList.Strings[Row];
FTempStringList.Text := RowString;
while FTempStringList.Count < ColumnCount do
FTempStringList.Add('');
Result := FTempStringList.Strings[Col];
end;
//****************************************************************************************************************************************************
procedure TiPlotTable.SetData(Col, Row: Integer; const Value: String);
var
RowString : String;
begin
RowString := FRowDataList.Strings[Row];
FTempStringList.Text := RowString;
while FTempStringList.Count < ColumnCount do
FTempStringList.Add('');
FTempStringList.Strings[Col] := Value;
FRowDataList.Strings[Row] := FTempStringList.Text;
end;
//****************************************************************************************************************************************************
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -