cxgridcustomview.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,463 行 · 第 1/5 页
PAS
1,463 行
{********************************************************************}
{ }
{ Developer Express Visual Component Library }
{ ExpressQuantumGrid }
{ }
{ Copyright (c) 1998-2008 Developer Express Inc. }
{ ALL RIGHTS RESERVED }
{ }
{ The entire contents of this file is protected by U.S. and }
{ International Copyright Laws. Unauthorized reproduction, }
{ reverse-engineering, and distribution of all or any portion of }
{ the code contained in this file is strictly prohibited and may }
{ result in severe civil and criminal penalties and will be }
{ prosecuted to the maximum extent possible under the law. }
{ }
{ RESTRICTIONS }
{ }
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
{ (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE }
{ SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS }
{ LICENSED TO DISTRIBUTE THE EXPRESSQUANTUMGRID AND ALL }
{ ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
{ }
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
{ }
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
{ ADDITIONAL RESTRICTIONS. }
{ }
{********************************************************************}
unit cxGridCustomView;
{$I cxVer.inc}
interface
uses
Windows, Messages, Classes, Graphics, Controls, Forms, StdCtrls, Menus,
cxClasses, cxControls, cxContainer, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters,
cxStyles, cxStorage, cxGridCommon, cxCustomData, cxData, cxListBox, cxPC;
const
cxGridCustomizationFormDefaultWidth = 180;
cxGridCustomizationFormDefaultHeight = 300;
htError = -1;
htNone = 0;
htNavigator = 1;
htCustomizationForm = 2;
htDesignSelector = 3;
ckNone = 0;
ckCustomizationForm = 1;
bbCustomFirst = 0;
bbBackground = bbCustomFirst;
bbCustomLast = bbBackground;
vsCustomFirst = 0;
vsBackground = vsCustomFirst;
vsCustomLast = vsBackground;
StoringVersion = 1;
type
TcxCustomGridDragAndDropObjectClass = class of TcxCustomGridDragAndDropObject;
TcxCustomGridItemsListBox = class;
TcxCustomGridCustomizationForm = class;
TcxGridPopupListBox = class;
TcxCustomGridController = class;
TcxCustomGridPainter = class;
TcxCustomGridViewData = class;
TcxCustomGridCellViewInfo = class;
TcxCustomGridViewCellViewInfo = class;
TcxGridDesignSelectorViewInfo = class;
TcxCustomGridViewInfo = class;
TcxCustomGridViewInfoCache = class;
TcxGridSite = class;
TcxCustomGridView = class;
IcxGridViewLayoutEditorSupport = interface // it is here because of problem in CBuilder
['{9C5EC9C0-A912-4822-BBD0-87AB45FDCC78}']
procedure BeforeEditLayout(ALayoutView: TcxCustomGridView);
procedure DoAssignLayout(ALayoutView: TcxCustomGridView);
function GetLayoutCustomizationFormButtonCaption: string;
function HasLayoutCustomizationForm: Boolean;
function IsLayoutChangeable: Boolean;
procedure RunLayoutCustomizationForm;
end;
{ change }
TcxCustomGridViewChange = class(TcxCustomGridChange)
private
FGridView: TcxCustomGridView;
public
constructor Create(AGridView: TcxCustomGridView); virtual;
property GridView: TcxCustomGridView read FGridView write FGridView;
function IsEqual(AChange: TcxCustomGridChange): Boolean; override;
end;
TcxGridControlFocusChange = class(TcxCustomGridViewChange)
public
procedure Execute; override;
end;
{ hit tests }
TcxCustomGridHitTestClass = class of TcxCustomGridHitTest;
TcxCustomGridHitTest = class
private
FPos: TPoint;
FViewInfo: TcxCustomGridCellViewInfo;
procedure SetViewInfo(Value: TcxCustomGridCellViewInfo);
protected
class function GetHitTestCode: Integer; virtual;
procedure Init(const APos: TPoint);
public
destructor Destroy; override;
function Cursor: TCursor; virtual;
function DragAndDropObjectClass: TcxCustomGridDragAndDropObjectClass; virtual;
class function HitTestCode: Integer;
class function Instance(const APos: TPoint): TcxCustomGridHitTest;
property Pos: TPoint read FPos;
property ViewInfo: TcxCustomGridCellViewInfo read FViewInfo write SetViewInfo;
end;
TcxGridNoneHitTest = class(TcxCustomGridHitTest)
protected
class function GetHitTestCode: Integer; override;
end;
TcxCustomGridViewHitTest = class(TcxCustomGridHitTest)
private
FGridView: TcxCustomGridView;
public
property GridView: TcxCustomGridView read FGridView write FGridView;
end;
TcxGridViewNoneHitTest = class(TcxCustomGridViewHitTest)
protected
class function GetHitTestCode: Integer; override;
end;
TcxGridNavigatorHitTest = class(TcxCustomGridViewHitTest)
protected
class function GetHitTestCode: Integer; override;
end;
TcxGridCustomizationFormHitTest = class(TcxCustomGridViewHitTest)
protected
class function GetHitTestCode: Integer; override;
end;
TcxGridDesignSelectorHitTest = class(TcxCustomGridViewHitTest)
protected
class function GetHitTestCode: Integer; override;
public
function Cursor: TCursor; override;
end;
{ custom handler }
TcxGridViewHandler = class(TcxInterfacedPersistent)
private
FGridView: TcxCustomGridView;
function GetControl: TcxControl;
function GetController: TcxCustomGridController;
function GetDataController: TcxCustomDataController;
function GetLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
function GetPainter: TcxCustomGridPainter;
function GetSite: TcxGridSite;
function GetViewData: TcxCustomGridViewData;
function GetViewInfo: TcxCustomGridViewInfo;
protected
property Control: TcxControl read GetControl;
property Controller: TcxCustomGridController read GetController;
property DataController: TcxCustomDataController read GetDataController;
property ViewData: TcxCustomGridViewData read GetViewData;
public
constructor Create(AGridView: TcxCustomGridView); reintroduce; virtual;
procedure BeginUpdate;
procedure EndUpdate;
property GridView: TcxCustomGridView read FGridView;
property LookAndFeelPainter: TcxCustomLookAndFeelPainterClass read GetLookAndFeelPainter;
property Painter: TcxCustomGridPainter read GetPainter;
property Site: TcxGridSite read GetSite;
property ViewInfo: TcxCustomGridViewInfo read GetViewInfo;
end;
{ contoller }
// drag&drop objects
TcxCustomGridDragAndDropObject = class(TcxDragAndDropObject)
private
function GetController: TcxCustomGridController;
function GetGridView: TcxCustomGridView;
function GetViewInfo: TcxCustomGridViewInfo;
protected
procedure AfterDragAndDrop(Accepted: Boolean); override;
procedure AfterPaint; virtual;
procedure BeforePaint; virtual;
property Controller: TcxCustomGridController read GetController;
property ViewInfo: TcxCustomGridViewInfo read GetViewInfo;
public
SourcePoint: TPoint;
procedure AfterScrolling; virtual;
procedure BeforeScrolling; virtual;
procedure AfterViewChange; virtual;
procedure BeforeViewChange; virtual;
procedure Init(const P: TPoint; AParams: TcxCustomGridHitTest); virtual;
property GridView: TcxCustomGridView read GetGridView;
end;
TcxGridArrowNumber = (anFirst, anLast);
TcxGridArrowPlace = TcxArrowPlace;
TcxCustomGridMovingObject = class(TcxCustomGridDragAndDropObject)
private
FDragImage: TcxDragImage;
FSourceItem: TObject;
function GetArrowPlace(AArrowNumber: TcxGridArrowNumber): TcxGridArrowPlace;
function GetCustomizationForm: TcxCustomGridCustomizationForm;
protected
Arrows: array[TcxGridArrowNumber] of TcxDragAndDropArrow;
procedure DirtyChanged; override;
function GetDragAndDropCursor(Accepted: Boolean): TCursor; override;
procedure ChangeArrowsPosition(AVisible: Boolean = True);
procedure ChangeDragImagePosition(AVisible: Boolean = True);
function AreArrowsVertical: Boolean; virtual;
function CanRemove: Boolean; virtual; abstract;
function GetArrowAreaBounds(APlace: TcxGridArrowPlace): TRect; virtual; abstract;
function GetArrowClass: TcxDragAndDropArrowClass; virtual;
function GetArrowsClientRect: TRect; virtual;
function GetCustomizationFormListBox: TcxCustomGridItemsListBox; virtual; abstract;
function GetDragImageClass: TcxDragImageClass; virtual;
function GetSourceItemBounds: TRect; virtual;
function GetSourceItemViewInfo: TcxCustomGridCellViewInfo; virtual;
procedure InitDragImage; virtual;
procedure InitDragImageUsingCustomizationForm(ACanvas: TcxCanvas;
const R: TRect; AItem: TObject); virtual;
function IsSourceCustomizationForm: Boolean; virtual; abstract;
function IsValidDestination: Boolean; virtual; abstract;
procedure BeginDragAndDrop; override;
procedure DragAndDrop(const P: TPoint; var Accepted: Boolean); override;
procedure EndDragAndDrop(Accepted: Boolean); override;
property ArrowPlaces[AArrowNumber: TcxGridArrowNumber]: TcxGridArrowPlace read GetArrowPlace;
property ArrowsClientRect: TRect read GetArrowsClientRect;
property CustomizationForm: TcxCustomGridCustomizationForm read GetCustomizationForm;
property CustomizationFormListBox: TcxCustomGridItemsListBox read GetCustomizationFormListBox;
property DragImage: TcxDragImage read FDragImage;
property SourceItem: TObject read FSourceItem write FSourceItem;
property SourceItemBounds: TRect read GetSourceItemBounds;
property SourceItemViewInfo: TcxCustomGridCellViewInfo read GetSourceItemViewInfo;
public
procedure AfterScrolling; override;
end;
// customization form
TcxCustomGridItemsInnerListBox = class(TcxInnerListBox)
private
FDragAndDropItemIndex: Integer;
FMouseDownPos: TPoint;
function GetContainer: TcxCustomGridItemsListBox;
function GetDragAndDropItem: TObject;
function GetGridView: TcxCustomGridView;
function GetLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
procedure WMCancelMode(var Message: TWMCancelMode); message WM_CANCELMODE;
procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure LookAndFeelChanged(Sender: TcxLookAndFeel;
AChangedValues: TcxLookAndFeelValues); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?