cxgridcardview.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,418 行 · 第 1/5 页
PAS
1,418 行
{********************************************************************}
{ }
{ 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 cxGridCardView;
{$I cxVer.inc}
interface
uses
{$IFDEF DELPHI6}
Variants,
{$ENDIF}
Windows, Classes, Graphics, Controls, Forms, StdCtrls,
cxClasses, cxGraphics, cxControls, cxStyles, cxLookAndFeelPainters,
cxGridCommon, cxGrid, cxGridCustomView, cxGridCustomTableView,
cxDataStorage, cxCustomData;
const
cxGridCardViewAlternateCaptionSeparator: string = '-';
cxGridDefaultCardBorderWidth = 3;
cxGridDefaultCardViewCaptionSeparator = ':';
cxGridDefaultCardViewSeparatorWidth = 2;
cxGridCardDefaultCategoryIndent = 17;
cxGridCardDefaultCategorySeparatorWidth = 2;
cxGridCardDefaultLayerSeparatorWidth = 0;
cxGridCardDefaultWidth = 200;
cxGridCardBorderMinWidth = 1;
cxGridCardDefaultIndent = 7;
cxGridCardMinWidth = 40;
htCardViewBase = htCustomGridTableBase + 50;
htCardRowIndent = htCardViewBase + 1;
htCardRowExpandButton = htCardViewBase + 2;
htRowCaption = htCardViewBase + 3;
htRowFilterButton = htCardViewBase + 4;
htCardScrollButtonUp = htCardViewBase + 5;
htCardScrollButtonDown = htCardViewBase + 6;
htSeparator = htCardViewBase + 7;
ckRows = 2;
bbCardViewFirst = bbCustomTableLast + 1;
bbCaptionRow = bbCardViewFirst;
bbCardBorder = bbCardViewFirst + 1;
bbRowCaption = bbCardViewFirst + 2;
bbCardViewLast = bbRowCaption;
isRowFirst = isCustomItemLast + 1;
isCaptionRow = isRowFirst;
isCategoryRow = isRowFirst + 1;
isRowCaption = isRowFirst + 2;
isRowLast = isRowCaption;
vsCardViewFirst = vsCustomTableLast + 1;
vsCaptionRow = vsCardViewFirst;
vsCardBorder = vsCardViewFirst + 1;
vsCategoryRow = vsCardViewFirst + 2;
vsCategorySeparator = vsCardViewFirst + 3;
vsLayerSeparator = vsCardViewFirst + 4;
vsRowCaption = vsCardViewFirst + 5;
vsCardViewLast = vsRowCaption;
type
TcxGridCardViewController = class;
TcxGridCard = class;
TcxGridCardViewViewData = class;
TcxGridCardRowFilterButtonViewInfo = class;
TcxGridCardRowCaptionViewInfo = class;
TcxGridCardRowViewInfo = class;
TcxCustomGridCardScrollButtonViewInfo = class;
TcxGridCardExpandButtonViewInfo = class;
TcxGridCardRowLayer = class;
TcxGridCardRowLayoutClass = class of TcxGridCardRowLayout;
TcxGridCardRowLayout = class;
TcxGridCardRowHorizontalLayout = class;
TcxGridCardViewInfoClass = class of TcxGridCardViewInfo;
TcxGridCardViewInfo = class;
TcxGridCardViewColumns = class;
TcxGridCardsViewInfo = class;
TcxGridCardViewSeparatorsViewInfo = class;
TcxGridCardViewViewInfo = class;
TcxGridCardViewInfoCacheItem = class;
TcxGridCardViewRow = class;
TcxGridCardVisibleRowLayoutObject = class;
TcxGridCardViewRowLayoutObject = class;
TcxGridCardViewVisibleRowLayoutObject = class;
TcxGridCardViewRowLayoutController = class;
TcxGridCardView = class;
TcxGridCardExpandButtonAlignment = (cebaLeft, cebaRight);
TcxGridCardViewLayoutDirection = (ldHorizontal, ldVertical);
{ hit tests }
TcxGridCardRowFilterButtonHitTest = class(TcxGridRecordCellHitTest)
protected
class function GetHitTestCode: Integer; override;
public
class function CanClick: Boolean; override;
end;
TcxGridCardRowIndentHitTest = class(TcxGridRecordCellHitTest)
protected
class function GetHitTestCode: Integer; override;
end;
TcxGridCardRowExpandButtonHitTest = class(TcxGridRecordCellHitTest)
protected
class function GetHitTestCode: Integer; override;
end;
TcxGridCardRowCellHitTest = class(TcxGridRecordCellHitTest)
public
function DragAndDropObjectClass: TcxCustomGridDragAndDropObjectClass; override;
end;
TcxGridCardRowCaptionHitTest = class(TcxGridCardRowCellHitTest)
protected
class function GetHitTestCode: Integer; override;
public
RowContainerKind: TcxGridItemContainerKind;
end;
TcxGridCardScrollButtonDownHitTest = class(TcxGridRecordHitTest)
protected
class function GetHitTestCode: Integer; override;
public
class function CanClick: Boolean; override;
end;
TcxGridCardScrollButtonUpHitTest = class(TcxGridRecordHitTest)
protected
class function GetHitTestCode: Integer; override;
public
class function CanClick: Boolean; override;
end;
TcxGridCardViewSeparatorHitTest = class(TcxCustomGridHitTest)
protected
class function GetHitTestCode: Integer; override;
public
Index: Integer;
Separators: TcxGridCardViewSeparatorsViewInfo;
function Cursor: TCursor; override;
function DragAndDropObjectClass: TcxCustomGridDragAndDropObjectClass; override;
end;
{ view data }
TcxGridCard = class(TcxCustomGridRecord)
private
FExpanded: Boolean;
function GetGridView: TcxGridCardView;
protected
procedure DoCollapse(ARecurse: Boolean); override;
procedure DoExpand(ARecurse: Boolean); override;
function GetExpandable: Boolean; override;
function GetExpanded: Boolean; override;
function GetHasCells: Boolean; override;
function GetViewInfoCacheItemClass: TcxCustomGridViewInfoCacheItemClass; override;
function GetViewInfoClass: TcxCustomGridRecordViewInfoClass; override;
public
constructor Create(AViewData: TcxCustomGridTableViewData; AIndex: Integer;
const ARecordInfo: TcxRowInfo); override;
procedure GetVisibleRows(ARows: TList);
property GridView: TcxGridCardView read GetGridView;
end;
TcxGridCardViewViewData = class(TcxCustomGridTableViewData)
private
function GetCard(Index: Integer): TcxGridCard;
function GetCardCount: Integer;
protected
function GetRecordClass(ARecordInfo: TcxRowInfo): TcxCustomGridRecordClass; override;
public
property CardCount: Integer read GetCardCount;
property Cards[Index: Integer]: TcxGridCard read GetCard;
end;
{ controller }
// drag&drop objects
TcxGridCardRowInsertionPos = (ripPrevLayer, ripNewLayer, ripSameLayer);
TcxGridCardRowContainerZone = class(TcxGridItemContainerZone)
private
function GetItem: TcxGridCardViewRow;
function GetRecordViewInfo: TcxGridCardViewInfo;
public
GridRecord: TcxCustomGridRecord;
InsertionPos: TcxGridCardRowInsertionPos;
constructor Create(AGridRecord: TcxCustomGridRecord; AItemIndex: Integer;
AInsertionPos: TcxGridCardRowInsertionPos); reintroduce;
function IsEqual(Value: TcxGridItemContainerZone): Boolean; override;
property RecordViewInfo: TcxGridCardViewInfo read GetRecordViewInfo;
property Item: TcxGridCardViewRow read GetItem;
end;
TcxGridCardRowMovingObjectClass = class of TcxGridCardRowMovingObject;
TcxGridCardRowMovingObject = class(TcxCustomGridTableItemMovingObject)
private
FExpandingRow: TcxGridCardViewRow;
FRowExpandingTimer: TcxTimer;
FSourceGridRecord: TcxCustomGridRecord;
function GetDestZone: TcxGridCardRowContainerZone;
function GetGridView: TcxGridCardView;
function GetRowLayout: TcxGridCardViewRowLayoutObject;
function GetSourceItem: TcxGridCardViewRow;
function GetViewInfo: TcxGridCardViewViewInfo;
function GetVisibleRowLayout: TcxGridCardViewVisibleRowLayoutObject;
procedure SetDestZone(Value: TcxGridCardRowContainerZone);
procedure SetSourceItem(Value: TcxGridCardViewRow);
procedure RowExpandingHandler(Sender: TObject);
protected
function AreArrowsVertical: Boolean; override;
procedure CalculateDestParams(AHitTest: TcxCustomGridHitTest;
out AContainerKind: TcxGridItemContainerKind; out AZone: TcxGridItemContainerZone); override;
function CanRemove: Boolean; override;
procedure ChangeSourceItemPosition; virtual;
function GetArrowAreaBounds(APlace: TcxGridArrowPlace): TRect; override;
function GetArrowsClientRect: TRect; override;
function GetSourceItemViewInfo: TcxCustomGridCellViewInfo; override;
function IsValidDestination: Boolean; override;
procedure BeginDragAndDrop; override;
procedure DragAndDrop(const P: TPoint; var Accepted: Boolean); override;
procedure EndDragAndDrop(Accepted: Boolean); override;
procedure StartRowExpanding(ARow: TcxGridCardViewRow);
procedure StopRowExpanding;
property ExpandingRow: TcxGridCardViewRow read FExpandingRow;
property DestZone: TcxGridCardRowContainerZone read GetDestZone write SetDestZone;
property GridView: TcxGridCardView read GetGridView;
property RowLayout: TcxGridCardViewRowLayoutObject read GetRowLayout;
property SourceGridRecord: TcxCustomGridRecord read FSourceGridRecord write FSourceGridRecord;
property SourceItem: TcxGridCardViewRow read GetSourceItem write SetSourceItem;
property ViewInfo: TcxGridCardViewViewInfo read GetViewInfo;
property VisibleRowLayout: TcxGridCardViewVisibleRowLayoutObject read GetVisibleRowLayout;
public
procedure Init(const P: TPoint; AParams: TcxCustomGridHitTest); override;
end;
TcxGridCardSizingObject = class(TcxCustomGridDragAndDropObject)
private
FCardColumnIndex: Integer;
FCardOriginalWidth: Integer;
FDestPointX: Integer;
FSeparators: TList;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?