⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezmiscelentities.pas

📁 很管用的GIS控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      FFont := Source[I].Font;
      Width := Source[I].Width;
      With Title Do
      Begin
        Caption := Source[I].Title.Caption;
        Alignment := Source[I].Title.Alignment;
        Color := Source[I].Title.Color;
        Transparent := Source[I].Title.Transparent;
        FFont := Source[I].Title.Font;
      End;
    End;
End;

Procedure TEzColumnList.Exchange( Index1, Index2: Integer );
Begin
  FItems.Exchange( Index1, Index2 );
End;

function TEzColumnList.Down( Index: Integer ): Boolean;
var
  temp: Pointer;
begin
  Result:= False;
  if ( Index < 0 ) or ( Index >= FItems.Count - 1 ) then Exit;
  temp:= FItems[Index + 1];
  FItems[Index + 1]:= FItems[Index];
  FItems[Index]:= temp;
  Result:= True;
end;

function TEzColumnList.Up( Index: Integer ): Boolean;
var
  temp: Pointer;
begin
  Result:= False;
  if ( Index <= 0 ) or ( Index > FItems.Count - 1 ) then Exit;
  temp:= FItems[Index - 1];
  FItems[Index - 1]:= FItems[Index];
  FItems[Index]:= temp;
  Result:= True;
end;

{ ----- TEzTableEntity ----- }

Constructor TEzTableEntity.CreateEntity( Const P1, P2: TEzPoint );
Begin
  Inherited CreateEntity( P1, P2 );
  FRowHeight := Abs( P1.Y - P2.Y ) / FRowCount;
  FTitleHeight := FRowHeight;
End;

Destructor TEzTableEntity.Destroy;
Begin
  FColumns.free;
  Inherited Destroy;
End;

procedure TEzTableEntity.Initialize;
begin
  inherited;
  FColumns := TEzColumnList.Create( Self );
  FOptions := [ezgoVertLine, ezgoHorzLine];
  FRowCount := 5;
  With FGridStyle Do
  Begin
    Visible := true;
    Style := 1;
    Color := clBlack;
    Width := 0.0;
  End;
  FDefaultDrawing := True;
  FLoweredColor := clGray;
end;

Function TEzTableEntity.BasicInfoAsString: string;
Var
  I,J: Integer;
  temp: string;
Begin
  result := Format(sTableInfo, [FPoints.AsString, RowCount,Columns.Count,
    EzBaseExpr.NBoolean[ezgoHorzLine in Options],
    EzBaseExpr.NBoolean[ezgoVertLine in Options],
    EzBaseExpr.NBoolean[Gridstyle.Visible], Gridstyle.Style,Gridstyle.Color,Gridstyle.Width,
    BorderWidth,LoweredColor]) + CrLf + '{' + CrLf;
  For I:= 0 to Columns.Count-1 do
  begin
    With Columns[I] Do
    Begin
      // the row data
      temp := '';
      For J:= 0 to Self.RowCount - 1 do
        If J < Self.RowCount - 1 Then
          temp := temp + StringOfChar(#32,6) + Format(sRowDataInfo,[Strings[J]]) + ',' + CrLf
        Else
          temp := temp + StringOfChar(#32,6) + Format(sRowDataInfo,[Strings[J]]);

      Result:= Result + StringOfChar(#32,2) + sColumnInfo + CrLf +
        StringOfChar(#32,4) + Format(sTTFontInfo,[Font.Name,
        EzBaseExpr.NBoolean[fsbold in Font.Style],
        EzBaseExpr.NBoolean[fsitalic in Font.Style],
        EzBaseExpr.NBoolean[fsUnderline in Font.Style],
        EzBaseExpr.NBoolean[fsStrikeout in Font.Style],
        Font.Color,Windows.ANSI_CHARSET]) + CrLf +

        StringOfChar(#32,4) + Format(sTableColumnInfo, [Width,EzBaseExpr.NBoolean[Transparent],
          Color,Ord(Alignment),Ord(ColumnType),Font.Height]) + CrLf +

        StringOfChar(#32,4) + sTitleCaption + CrLf +
        StringOfChar(#32,6) + Format(sTTFontInfo,[Title.Font.Name,
        EzBaseExpr.NBoolean[fsbold in Title.Font.Style],
        EzBaseExpr.NBoolean[fsitalic in Title.Font.Style],
        EzBaseExpr.NBoolean[fsUnderline in Title.Font.Style],
        EzBaseExpr.NBoolean[fsStrikeout in Title.Font.Style],
        Title.Font.Color,Windows.ANSI_CHARSET]) + CrLf+
        StringOfChar(#32,6) + Format(sColumnTitleInfo, [Title.Caption,Ord(Title.Alignment),
          Title.Color,EzBaseExpr.NBoolean[Title.Transparent],
          Title.Font.Height] ) + CrLf +

        StringOfChar(#32,4) + sDataInfo + CrLf + temp + CrLf + '  }' + CrLf + CrLf;
    End;
  end;
  result:= result + '}' + CrLf;
  
End;

Function TEzTableEntity.GetEntityID: TEzEntityID;
Begin
  result := idTable;
End;

Function TEzTableEntity.GetColumns: TEzColumnList;
Begin
  If ( FColumns = Nil ) Then
    FColumns := TEzColumnList.Create( self );
  result := FColumns
End;

{$IFDEF BCB}
function TEzTableEntity.GetBorderWidth: Double;
begin
  Result := FBorderWidth;
end;

function TEzTableEntity.GetDefaultDrawing: Boolean;
begin
  Result := FDefaultDrawing;
end;

function TEzTableEntity.GetGridStyle: TEzTableBorderStyle;
begin
  Result := FGridStyle;
end;

function TEzTableEntity.GetLoweredColor: TColor;
begin
  Result := FLoweredColor;
end;

function TEzTableEntity.GetOnDrawCell: TEzTableDrawCellEvent;
begin
  Result := FOnDrawCell;
end;

function TEzTableEntity.GetOptions: TEzGridOptions;
begin
  Result := FOptions;
end;

function TEzTableEntity.GetOwnerDraw: Boolean;
begin
  Result := FOwnerDraw;
end;

function TEzTableEntity.GetRowCount: Integer;
begin
  Result := FRowCount;
end;

function TEzTableEntity.GetRowHeight: Double;
begin
  Result := FRowHeight;
end;

function TEzTableEntity.GetTitleHeight: Double;
begin
  Result := FTitleHeight;
end;

procedure TEzTableEntity.SetBorderWidth(const Value: Double);
begin
  FBorderWidth := Value;
end;

procedure TEzTableEntity.SetDefaultDrawing(const Value: Boolean);
begin
  FDefaultDrawing := Value;
end;

procedure TEzTableEntity.SetGridStyle(const Value: TEzTableBorderStyle);
begin
  FGridStyle := Value;
end;

procedure TEzTableEntity.SetLoweredColor(const Value: TColor);
begin
  FLoweredColor := Value;
end;

procedure TEzTableEntity.SetOnDrawCell(const Value: TEzTableDrawCellEvent);
begin
  FOnDrawCell := Value;
end;

procedure TEzTableEntity.SetOptions(const Value: TEzGridOptions);
begin
  FOptions := Value;
end;

procedure TEzTableEntity.SetOwnerDraw(const Value: Boolean);
begin
  FOwnerDraw := Value;
end;

procedure TEzTableEntity.SetRowHeight(const Value: Double);
begin
  FRowHeight := Value;
end;

procedure TEzTableEntity.SetTitleHeight(const Value: Double);
begin
  FTitleHeight := Value;
end;
{$ENDIF}

Function TEzTableEntity.StorageSize: Integer;
Var
  i, j: Integer;
Begin
  Result := Inherited StorageSize + SizeOf( FOptions ) + SizeOf( FRowHeight )
    + sizeof( FRowCount ) + sizeof( FTitleHeight )
    + sizeof( FGridStyle ) + sizeof( FOwnerDraw )
    + sizeof( FBorderWidth ) + sizeof( FDefaultDrawing )
    + sizeof( FLoweredColor );
  For i := 0 To Columns.Count - 1 Do
    With Columns[i] Do
    Begin
      result := result + sizeof( FAlignment ) + sizeof( FColor )
        + sizeof( FTransparent ) + sizeof( FFont ) + sizeof( FWidth );
      With FTitle Do
        result := result + Length( FCaption ) + sizeof( FAlignment ) + sizeof( FColor )
          + sizeof( FTransparent ) + sizeof( FFont );
      for J:= 0 to FRowCount - 1 do
        result := result + Length( Strings[ J ] );
    End;
End;

Procedure TEzTableEntity.LoadFromStream( Stream: TStream );
Var
  i, j, n: integer;
  Item: TEzColumnItem;
Begin
  Inherited LoadFromStream( Stream );
  With Stream Do
  Begin
    Read( FOptions, sizeof( FOptions ) );
    Read( FRowHeight, sizeof( FRowHeight ) );
    Read( FRowCount, sizeof( FRowCount ) );
    Read( FTitleHeight, sizeof( FTitleHeight ) );
    Read( FGridStyle, sizeof( FGridStyle ) );
    Read( FOwnerDraw, sizeof( FOwnerDraw ) );
    Read( FBorderWidth, sizeof( FBorderWidth ) );
    Read( FDefaultDrawing, sizeof( FDefaultDrawing ) );
    Read( FLoweredColor, sizeof( FLoweredColor ) );
    Read( n, sizeof( n ) ); // number of columns
    Columns.Clear;
    For i := 0 To n - 1 Do
    Begin
      Item := Columns.Add;
      With Item Do
      Begin
        Read( FColumnType, sizeof( FColumnType ) );
        Read( FAlignment, sizeof( FAlignment ) );
        Read( FColor, sizeof( FColor ) );
        Read( FTransparent, sizeof( FTransparent ) );
        Read( FFont, sizeof( FFont ) );
        Read( FWidth, sizeof( FWidth ) );
        With FTitle Do
        Begin
          FCaption := EzReadStrFromStream( stream );
          Read( FAlignment, sizeof( FAlignment ) );
          Read( FColor, sizeof( FColor ) );
          Read( FTransparent, sizeof( FTransparent ) );
          Read( FFont, sizeof( FFont ) );
        End;
        for j:= 0 to FRowCount - 1 do
          Strings[J]:= EzReadStrFromStream( stream );
      End;
    End;
    SetRowCount( FRowCount ); { force to fix Strings data }
  End;
  FOriginalSize := StorageSize;
End;

Procedure TEzTableEntity.SaveToStream( Stream: TStream );
Var
  i, j, n: integer;
Begin
  Inherited SaveToStream( Stream );
  With Stream Do
  Begin
    Write( FOptions, sizeof( FOptions ) );
    Write( FRowHeight, sizeof( FRowHeight ) );
    Write( FRowCount, sizeof( FRowCount ) );
    Write( FTitleHeight, sizeof( FTitleHeight ) );
    Write( FGridStyle, sizeof( FGridStyle ) );
    Write( FOwnerDraw, sizeof( FOwnerDraw ) );
    Write( FBorderWidth, sizeof( FBorderWidth ) );
    Write( FDefaultDrawing, sizeof( FDefaultDrawing ) );
    Write( FLoweredColor, sizeof( FLoweredColor ) );
    n := Columns.Count;
    Write( n, sizeof( n ) ); // number of columns
    For i := 0 To n - 1 Do
      With Columns[i] Do
      Begin
        Write( FColumnType, sizeof( FColumnType ) );
        Write( FAlignment, sizeof( FAlignment ) );
        Write( FColor, sizeof( FColor ) );
        Write( FTransparent, sizeof( FTransparent ) );
        Write( FFont, sizeof( FFont ) );
        Write( FWidth, sizeof( FWidth ) );
        With FTitle Do
        Begin
          EzWriteStrToStream( FCaption, stream );
          Write( FAlignment, sizeof( FAlignment ) );
          Write( FColor, sizeof( FColor ) );
          Write( FTransparent, sizeof( FTransparent ) );
          Write( FFont, sizeof( FFont ) );
        End;
        for j:= 0 to FRowCount - 1 do
          EzWriteStrToStream( FStrings[j], stream );
      End;
  End;
  FOriginalSize := StorageSize;
End;

Procedure TEzTableEntity.SetRowCount( Value: Integer );
var
  I,J: Integer;
Begin
  FRowCount := Value;
  if Columns.Count > 0 then
  begin
    for I:= 0 to Columns.Count - 1 do
    begin
      for j:= Columns[I].Strings.Count to Value do
        Columns[I].FStrings.Add( '' );
    end;
  end;
End;

Procedure TEzTableEntity.Draw( Grapher: TEzGrapher; Canvas: TCanvas;
  Const Clip: TEzRect; DrawMode: TEzDrawMode; Data: Pointer = Nil );
Var
  TmpR: TEzRect;
  GridRect, R, Rect: TRect;
  GridLineWidth, OuterLineWidth, OuterLineHeight: Integer;
  BorderWidthPix, BorderHeightPix: Integer;
  GridRowHeight: Integer;
  GridWidth, I, J, K, N, X, Y, TmpHeight: Integer;
  GridColWidths: Array[0..1000] Of Integer; // max of 1000 columns
  uFormat: Word;
  txt: String;
  ValInteger: Integer;
  Poly: array[0..4] of TPoint;
  Parts: array[0..0] of Integer;
  BmpRes: HBitmap;
  Bmp: TBitmap;
  ForeColor,BackColor:TColor;
  Resname: string;
  TmpGrapher: TEzGrapher;
  linetype: integer;
  Penwidth: integer;
  ALineColor: TColor;
  Symbol: TEzSymbol;
  dist: double;
  V: TEzVector;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -