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

📄 ezinspect.pas

📁 很管用的GIS控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
unit EzInspect;

{$I EZ_FLAG.PAS}
interface

Uses
  SysUtils, Messages, Classes, Windows, Controls, StdCtrls, Forms, Grids,
  Buttons, Graphics, ComCtrls, EzMiscelCtrls, eznumed, ezcmdline,
  ezbasegis, extdlgs, EzMiscelEntities, EzLib, ShlObj, EzBase, EzColorPicker;

type

  TGoingOffReason = ( goNone, goLeft, goRight, goUp, goDown, goRTab, goLTab,
    goEnter, goEscape, goPgUp, goPgDn, goHome, goEnd );

  TGoingOffEvent = Procedure( Sender: TObject; Reason: TGoingOffReason;
    Var AllowExit: Boolean ) Of Object;

  TEzBaseProperty = class;

  TInplaceComboBox = class(TEzFlatComboBox)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  protected
    procedure Change; override;
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;

  TInplaceDateTimePicker = class(TDateTimePicker)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;

  TInplaceEdit = class(TEdit)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;

  TInplaceNumEd = class(TEzNumEd)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;


  TInplaceSymbolsBox = class(TEzSymbolsGridBox)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  protected
    procedure Click; Override;
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;


  TInplaceBlocksBox = class(TEzBlocksGridBox)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  protected
    procedure Click; Override;
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;

  TInplaceColorBox = class(TEzColorBox)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    procedure Click; Override;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;


  TInplaceBrushstyleBox = class(TEzBrushPatternGridBox)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  protected
    procedure Click; Override;
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;


  TInplaceLinetypeBox = class(TEzLinetypeGridBox)
  private
    FBaseProperty: TEzBaseProperty;
    FOnGoingOff: TGoingOffEvent;
    FRequireNotification: Boolean;
    Procedure CNKeydown( Var Message: TWMkeydown ); Message CN_KEYDOWN;
    Procedure CMEnter( Var Message: TCMEnter ); Message CM_ENTER;
    Procedure CMExit( Var Message: TCMExit ); Message CM_EXIT;
    Procedure TriggerGoingOffEvent( Reason: TGoingOffReason;
      Var AllowExit: Boolean );
    procedure DoChange;
  {$IFDEF BCB} (*_*)
    function GetOnGoingOff: TGoingOffEvent;
    procedure SetOnGoingOff(const Value: TGoingOffEvent);
  {$ENDIF}
  protected
    procedure Click; Override;
  public
    constructor Create(AOwner: TComponent); Override;
    Procedure GoOff;
    Property OnGoingOff: TGoingOffEvent
      Read {$IFDEF BCB} GetOnGoingOff {$ELSE} FOnGoingOff {$ENDIF}
      Write {$IFDEF BCB} SetOnGoingOff{$ELSE} FOnGoingOff {$ENDIF} ; (*_*)
  end;

  { TEzPropertyList }

  TEzPropertyList = Class
  Private
    FList: TList;
    Function Get( Index: Integer ): TEzBaseProperty;
    procedure Put(Index: Integer; const Value: TEzBaseProperty);
  Public
    Constructor Create;
    destructor Destroy; Override;
    Function Add( Item: TEzBaseProperty ): Integer;
    Procedure Clear;
    Procedure ReplaceByIndex(Index : Integer; p : TEzBaseProperty);
    Procedure Delete( Index: Integer );
    Procedure Insert( Index: Integer; Value: TEzBaseProperty );
    Function Count: Integer;
    Function Remove( Item: TEzBaseProperty ): Integer;
    Function Indexof( Item: TEzBaseProperty ): Integer;
    Function IndexofName( const Value: string ): Integer;
    procedure Exchange(Index1, Index2: Integer);
    Procedure SortByName;

    Property Items[Index: Integer]: TEzBaseProperty Read Get Write Put; Default;
  End;

  { TEzInspector }

  TEzInspectorProvider = class;

  TEzBeforePropertyEvent = Procedure (Sender: TObject; const PropertyName: string;
    var CanShow, ReadOnly: Boolean ) Of Object;

  TEzPropertyChangeEvent = Procedure (Sender: TObject; const PropertyName: string) Of Object;

  TEzInspector = class(TCustomGrid)
  private
    FInplaceComboBox      : TInplaceComboBox;
    FInplaceEdit          : TInplaceEdit;
    FInplaceNumEd         : TInplaceNumEd;
    FInplaceSymbolsBox    : TInplaceSymbolsBox;
    FInplaceBlocksBox     : TInplaceBlocksBox;
    FInplaceColorBox      : TInplaceColorBox;
    FInplaceBrushstyleBox : TInplaceBrushstyleBox;
    FInplaceLinetypeBox   : TInplaceLinetypeBox;
    FInplaceDateTimePicker: TInplaceDateTimePicker;
    FButton               : TSpeedButton;
    FPropertyList         : TEzPropertyList;
    FTitleCaptions        : TStrings;
    FLastRow              : Integer;
    FFontReadOnly         : TFont;
    FFontModified         : TFont;
    FInColChange          : Boolean;
    FButtonWidth          : Integer;
    FSettingHeight        : Boolean;
    FPlusBitmap           : TBitmap;
    FMinusBitmap          : TBitmap;
    FReadOnlyBackColor    : TColor;
    FReadOnly             : Boolean;

    FOnBeforeProperty     : TEzBeforePropertyEvent;
    FOnPropertyChange     : TEzPropertyChangeEvent;
    FOnPropertyHint       : TEzPropertyChangeEvent;
    procedure InPlaceEditGoingOff(Sender: TObject; Reason: TGoingOffReason;
      var AllowExit: Boolean);
    procedure EllipsisButtonClick(Sender: TObject);
    procedure PropertyChanged(Sender: TObject);
    procedure WMHScroll(var Msg: TWMHScroll); message WM_HSCROLL;
    procedure WMVScroll(var Msg: TWMVScroll); message WM_VSCROLL;
    procedure SetFontModified(const Value: TFont);
    procedure SetFontReadOnly(const Value: TFont);
    Procedure SetButtonWidth( Value: Integer );
    Procedure SetButtonGlyph;
    procedure CMShowingChanged(var Message: TMessage); message CM_SHOWINGCHANGED;
    Function  GetPropertyByRow(ARow : Integer) : TEzBaseProperty;
    Function  GetRowCount : Integer;
    Function  GetPropertyRow(Sender : TObject) : Integer;
    procedure SetReadOnlyBackColor(const Value: TColor);
    procedure SetTitleCaptions(const Value: TStrings);
    function GetAbout: TEzAbout;
    procedure SetAbout(const Value: TEzAbout);
    procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
  protected
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); override;
    procedure KeyDown(var Key: Word; Shift: TShiftState); override;
    procedure DrawCell(ACol, ARow: Longint; ARect: TRect;
      AState: TGridDrawState); override;
    procedure ColWidthsChanged; override;
    procedure RowHeightsChanged; Override;
    procedure TopLeftChanged; override;
    procedure DblClick; Override;
    procedure Loaded; Override;
    procedure Resize; Override;
  public
    constructor Create(AOwner: TComponent); Override;
    destructor Destroy; override;
    procedure ClearPropertyList;
    function SelectCell(ACol, ARow: Longint): Boolean; override;
    Procedure AddProperty( BaseProperty: TEzBaseProperty );
    function GetPropertyByName(const Value: string): TEzBaseProperty;
    procedure ReplaceProperty( const Value: string; p: TEzBaseProperty );
    procedure ReplacePropertyByIndex( Index: Integer; p: TEzBaseProperty );
    procedure SetModifiedStatus(Value: Boolean);
    Procedure TurnOffEditor;
    Function PropertyCount: Integer;
    procedure AdjustColWidths;
    procedure InsertProperty(Index: Integer; BaseProperty: TEzBaseProperty);
    procedure DeletePropertyByIndex(Index: Integer);
    procedure DeletePropertyByName(const Value: String);
    procedure RemoveProperty(p: TEzBaseProperty);
    procedure RemoveFromProvider(pl: TEzInspectorProvider);
    procedure AdjustRows;
    Procedure FullExpand;
    Procedure FullCompact;

    Property PropList: TEzPropertyList read FPropertyList;

    property ColWidths;
    property Row;
    property RowCount;
    property Col;
    property ColCount;
    property RowHeights;
    property LeftCol;
    property TopRow;

  published
    Property About: TEzAbout read GetAbout write SetAbout;
    property ReadOnly: Boolean read FReadOnly write FReadOnly default False;
    property ButtonWidth: Integer read FButtonWidth write SetButtonWidth;
    property FontReadOnly : TFont read FFontReadOnly write SetFontReadOnly;
    property FontModified : TFont read FFontModified write SetFontModified;
    property TitleCaptions: TStrings read FTitleCaptions write SetTitleCaptions;
    property ReadOnlyBackColor: TColor read FReadOnlyBackColor write SetReadOnlyBackColor default clGray;

    property OnBeforeProperty: TEzBeforePropertyEvent read FOnBeforeProperty Write FOnBeforeProperty;
    property OnPropertyChange: TEzPropertyChangeEvent read FOnPropertyChange write FOnPropertyChange;
    property OnPropertyHint: TEzPropertyChangeEvent read FOnPropertyHint write FOnPropertyHint;

    property Align;
    property Anchors;
    property BiDiMode;
    property BorderStyle;
    property Color;
    property Constraints;
    property Ctl3D;
    property DefaultColWidth;
    property DefaultRowHeight;
    property DragCursor;
    property DragKind;
    property DragMode;
    property Enabled;
    property FixedColor;
    property Font;
    property GridLineWidth;
    property ParentBiDiMode;
    property ParentColor;
    property ParentCtl3D;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ScrollBars;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property Visible;
    property VisibleColCount;
    property VisibleRowCount;
    property OnClick;
{$IFDEF LEVEL5}
    property OnContextPopup;
{$ENDIF}
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;

⌨️ 快捷键说明

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