cxgridcustomview.pas

来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,463 行 · 第 1/5 页

PAS
1,463
字号
  private
    FActiveViewInfos: TList;
    FAllowCheckCoordinates: Boolean;
    FAllowHideSite: Boolean;
    FBounds: TRect;
    FClientBounds: TRect;
    FClientBoundsAssigned: Boolean;
    FDesignSelectorViewInfo: TcxGridDesignSelectorViewInfo;
    FIsCalculating: Boolean;
    FIsInternalUse: Boolean;
    FLock: TRTLCriticalSection;
    FMousePos: TPoint;
    FSite: TcxGridSite;
    FSizeCalculating: Boolean;
    FVisibilityChanging: Boolean;

    function GetCalculated: Boolean;
    function GetCanvas: TcxCanvas;
    function GetClientBounds: TRect;
    function GetClientHeight: Integer;
    function GetClientWidth: Integer;
    //function GetIsCalculating: Boolean;
    function GetIsInternalUseValue: Boolean;
    procedure SetClientBounds(const Value: TRect);
  protected
    procedure CreateViewInfos; virtual;
    procedure DestroyViewInfos(AIsRecreating: Boolean); virtual;
    procedure RecreateViewInfos; virtual;
    function GetDesignSelectorViewInfoClass: TcxGridDesignSelectorViewInfoClass; virtual;

    function CanHideSite: Boolean; virtual;
    procedure CreateSite;
    procedure DestroySite;
    function GetSiteClass: TcxGridSiteClass; virtual;
    function GetSiteParent: TWinControl;

    procedure AddActiveViewInfo(AViewInfo: TObject);
    function IsViewInfoActive(AViewInfo: TObject): Boolean;
    procedure RemoveActiveViewInfo(AViewInfo: TObject; ARemoveAll: Boolean = False);

    procedure AddScrollBarHeight(var AHeight: Integer);
    procedure AdjustClientBounds(var ABounds: TRect); virtual;
    procedure AfterCalculating; virtual;
    procedure BeforeCalculating; virtual;
    procedure Calculate; virtual;
    function CalculateClientBounds: TRect; virtual;
    procedure CalculateHeight(const AMaxSize: TPoint; var AHeight: Integer;
      var AFullyVisible: Boolean); virtual;
    procedure CalculateWidth(const AMaxSize: TPoint; var AWidth: Integer); virtual;
    function CanCheckCoordinates: Boolean; virtual;
    procedure ControlFocusChanged; virtual;
    function DoGetHitTest(const P: TPoint): TcxCustomGridHitTest; virtual;
    function GetAllowBoundsChangedNotification: Boolean; virtual;
    function GetBackgroundBitmap: TBitmap; virtual;
    function GetBackgroundColor: TColor; virtual;
    //function GetContentBounds: TRect; virtual;
    function GetDesignSelectorPos: TPoint; virtual;
    procedure GetHScrollBarBounds(var ABounds: TRect); virtual;
    function GetIsInternalUse: Boolean; virtual;
    function GetVisible: Boolean; virtual;
    procedure InitHitTest(AHitTest: TcxCustomGridHitTest); virtual;
    procedure UpdateMousePos;
    procedure VisibilityChanged(AVisible: Boolean); virtual;

    property AllowBoundsChangedNotification: Boolean read GetAllowBoundsChangedNotification;
    property AllowCheckCoordinates: Boolean read FAllowCheckCoordinates write FAllowCheckCoordinates;
    property ClientBoundsAssigned: Boolean read FClientBoundsAssigned write FClientBoundsAssigned;
    property SizeCalculating: Boolean read FSizeCalculating;
    property VisibilityChanging: Boolean read FVisibilityChanging;
    property Visible: Boolean read GetVisible;
  public
    constructor Create(AGridView: TcxCustomGridView); override;
    destructor Destroy; override;
    procedure BeforeDestruction; override;
    procedure DoVisibilityChanged(AVisible: Boolean);
    function GetFontHeight(AFont: TFont): Integer;
    procedure GetFontMetrics(AFont: TFont; out AMetrics: TTextMetric);
    procedure GetHeight(const AMaxSize: TPoint; var AHeight: Integer;
      var AFullyVisible: Boolean);
    function GetHitTest(const P: TPoint): TcxCustomGridHitTest; overload; virtual;
    function GetHitTest(X, Y: Integer): TcxCustomGridHitTest; overload; virtual;
    procedure GetWidth(const AMaxSize: TPoint; var AWidth: Integer);
    procedure MainCalculate(const ABounds: TRect);
    procedure Recalculate;

    property AllowHideSite: Boolean read FAllowHideSite write FAllowHideSite;
    property BackgroundColor: TColor read GetBackgroundColor;
    property BackgroundBitmap: TBitmap read GetBackgroundBitmap;
    property Bounds: TRect read FBounds;
    property Calculated: Boolean read GetCalculated;
    property Canvas: TcxCanvas read GetCanvas;
    property ClientBounds: TRect read GetClientBounds write SetClientBounds;
    property ClientHeight: Integer read GetClientHeight;
    property ClientWidth: Integer read GetClientWidth;
    //property ContentBounds: TRect read GetContentBounds;
    property DesignSelectorViewInfo: TcxGridDesignSelectorViewInfo read FDesignSelectorViewInfo;
    property IsCalculating: Boolean read FIsCalculating;
    property IsInternalUse: Boolean read GetIsInternalUseValue write FIsInternalUse;
    property MousePos: TPoint read FMousePos;
    property Site: TcxGridSite read FSite;
  end;

  TcxCustomGridViewInfoCacheItemClass = class of TcxCustomGridViewInfoCacheItem;

  TcxCustomGridViewInfoCacheItem = class
  private
    FIndex: Integer;
    FOwner: TcxCustomGridViewInfoCache;
  protected
    property Index: Integer read FIndex;
    property Owner: TcxCustomGridViewInfoCache read FOwner;
  public
    constructor Create(AOwner: TcxCustomGridViewInfoCache; AIndex: Integer); virtual;
    procedure UnassignValues(AKeepMaster: Boolean); virtual;
  end;

  TcxCustomGridViewInfoCacheClass = class of TcxCustomGridViewInfoCache;

  TcxCustomGridViewInfoCache = class(TcxGridViewHandler)
  private
    FItems: TList;
    FUnassigningValues: Boolean;
    function GetCount: Integer;
    function GetInternalItem(Index: Integer): TcxCustomGridViewInfoCacheItem;
    function GetItem(Index: Integer): TcxCustomGridViewInfoCacheItem;
    procedure SetCount(Value: Integer);
    procedure DestroyItems;
  protected
    function GetItemClass(Index: Integer): TcxCustomGridViewInfoCacheItemClass; virtual; abstract;
    property InternalItems[Index: Integer]: TcxCustomGridViewInfoCacheItem read GetInternalItem;
  public
    constructor Create(AGridView: TcxCustomGridView); override;
    destructor Destroy; override;
    procedure UnassignValues(AKeepMaster: Boolean = False); virtual;
    property Count: Integer read GetCount write SetCount;
    property Items[Index: Integer]: TcxCustomGridViewInfoCacheItem read GetItem; default;
  end;

  { custom view }

  TcxGridViewChangeKind = (vcProperty, vcLayout, vcSize);

  TcxCustomGridOptions = class(TcxInterfacedPersistent)
  private
    FGridView: TcxCustomGridView;
    function GetLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
  protected
    procedure Changed(AChangeKind: TcxGridViewChangeKind); virtual;
    function GetGridViewValue: TcxCustomGridView; virtual;
    procedure Notification(AComponent: TComponent; AOperation: TOperation); virtual;

    procedure GetStoredProperties(AProperties: TStrings); virtual;
    procedure GetStoredPropertyValue(const AName: string; var AValue: Variant); virtual;
    procedure SetStoredPropertyValue(const AName: string; const AValue: Variant); virtual;

    property LookAndFeelPainter: TcxCustomLookAndFeelPainterClass read GetLookAndFeelPainter;
  public
    constructor Create(AGridView: TcxCustomGridView); reintroduce; virtual;
    destructor Destroy; override;
    procedure Assign(Source: TPersistent); override;
    property GridView: TcxCustomGridView read GetGridViewValue;
  end;

  TcxCustomGridBackgroundBitmapsClass = class of TcxCustomGridBackgroundBitmaps;

  TcxCustomGridBackgroundBitmaps = class(TcxCustomGridOptions)
  private
    FItems: TList;
    function GetCount: Integer;
    procedure BitmapChanged(Sender: TObject);
  protected
    function GetBitmapStyleIndex(Index: Integer): Integer; virtual;
    function GetDefaultBitmap(Index: Integer): TBitmap; virtual;
    function GetValue(Index: Integer): TBitmap;
    procedure SetValue(Index: Integer; Value: TBitmap);
    property Count: Integer read GetCount;
  public
    constructor Create(AGridView: TcxCustomGridView); override;
    destructor Destroy; override;
    procedure Assign(Source: TPersistent); override;
    function GetBitmap(Index: Integer): TBitmap; virtual;
    property Values[Index: Integer]: TBitmap read GetValue write SetValue; default;
  published
    property Background: TBitmap index bbBackground read GetValue write SetValue;
  end;

  TcxCustomGridOptionsBehaviorClass = class of TcxCustomGridOptionsBehavior;

  TcxCustomGridOptionsBehavior = class(TcxCustomGridOptions)
  private
    FPostponedSynchronization: Boolean;
    function GetPostponedSynchronization: Boolean;
  public
    constructor Create(AGridView: TcxCustomGridView); override;
    procedure Assign(Source: TPersistent); override;
  published
    property PostponedSynchronization: Boolean read GetPostponedSynchronization
      write FPostponedSynchronization default True;  // should be published in all descendants
  end;

  TcxCustomGridOptionsDataClass = class of TcxCustomGridOptionsData;

  TcxCustomGridOptionsData = class(TcxCustomGridOptions);

  TcxCustomGridOptionsSelectionClass = class of TcxCustomGridOptionsSelection;

  TcxCustomGridOptionsSelection = class(TcxCustomGridOptions);

  TcxCustomGridOptionsViewClass = class of TcxCustomGridOptionsView;

  TcxCustomGridOptionsView = class(TcxCustomGridOptions)
  private
    function GetScrollBars: TScrollStyle;
    procedure SetScrollBars(Value: TScrollStyle);
  protected
    property ScrollBars: TScrollStyle read GetScrollBars write SetScrollBars default ssBoth;
  public
    procedure Assign(Source: TPersistent); override;
  end;

  TcxCustomGridStyles = class(TcxStyles)
  private
    function GetLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
  protected
    procedure Changed(AIndex: Integer); override;
    procedure GetDefaultViewParams(Index: Integer; AData: TObject; out AParams: TcxViewParams); override;
    procedure GetFakeComponentLinks(AList: TList); virtual;
    function GetGridView: TcxCustomGridView; virtual; abstract;
    property LookAndFeelPainter: TcxCustomLookAndFeelPainterClass read GetLookAndFeelPainter;
  public
    property GridView: TcxCustomGridView read GetGridView;
  end;

  TcxCustomGridViewStylesClass = class of TcxCustomGridViewStyles;

  TcxCustomGridViewStyles = class(TcxCustomGridStyles)
  protected
    procedure GetDefaultViewParams(Index: Integer; AData: TObject; out AParams: TcxViewParams); override;
    function GetGridView: TcxCustomGridView; override;
  public
    procedure Assign(Source: TPersistent); override;
  published
    property Background: TcxStyle index vsBackground read GetValue write SetValue;
  end;

  TcxGridListenerLink = class
  private
    FGridView: TcxCustomGridView;
  public
    constructor Create(AGridView: TcxCustomGridView);
    destructor Destroy; override;
    procedure Clear;
    property GridView: TcxCustomGridView read FGridView;
  end;

  TcxGridStorageOption = (gsoUseFilter, gsoUseSummary);
  TcxGridStorageOptions = set of TcxGridStorageOption;
  TcxGridViewChangeNotificationKind = (vcnName{, vsRemoved});

  TcxGridInitStoredObjectEvent = procedure(Sender: TcxCustomGridView; AObject: TObject) of object;
  TcxGridViewGetStoredPropertiesEvent = procedure(Sender: TcxCustomGridView;
    AProperties: TStrings) of object;
  TcxGridViewGetStoredPropertyValueEvent = procedure(Sender: TcxCustomGridView;
    const AName: string; var AValue: Variant) of object;
  TcxGridViewSetStoredPropertyValueEvent = procedure(Sender: TcxCustomGridView;
    const AName: string; const AValue: Variant) of object;

  TcxCustomGridViewClass = class of TcxCustomGridView;

  TcxCustomGridView = class(TcxControlChildComponent, IcxStoredObject, IcxStoredParent,
    IcxGridViewLayoutEditorSupport)
  private
    FAssigningPattern: Boolean;
    FAssigningSettings: Boolean;
    FBackgroundBitmaps: TcxCustomGridBackgroundBitmaps;
    FClones: TList;
    FController: TcxCustomGridController;
    FIsRestoring: Boolean;
    FIsSynchronizing: Boolean;
    FLevel: TComponent;
    FListenerLinks: TList;
    FOptionsList: TList;
    FOptionsBehavior: TcxCustomGridOptionsBehavior;
    FOptionsData: TcxCustomGridOptionsData;
    FOptionsSelection: TcxCustomGridOptionsSelection;
    FOptionsView: TcxCustomGridOptionsView;
    FPainter: TcxCustomGridPainter;
    FPatternGridView: TcxCustomGridView;
    FRepository: TComponent;
    FStorageControl: TcxControl;
    F

⌨️ 快捷键说明

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