📄 dbgrideh.pas
字号:
TColumnsEhList = class(TObjectList)
private
function GetColumn(Index: Integer): TColumnEh;
procedure SetColumn(Index: Integer; const Value: TColumnEh);
public
constructor Create; overload;
property Items[Index: Integer]: TColumnEh read GetColumn write SetColumn; default;
end;
{ TGridDataLinkEh }
TGridDataLinkEh = class(TDataLink)
private
FFieldCount: Integer;
FFieldMap: array of Integer;
FFieldMapSize: Integer;
FGrid: TCustomDBGridEh;
FInUpdateData: Boolean;
FModified: Boolean;
FSparseMap: Boolean;
function GetDefaultFields: Boolean;
function GetFields(I: Integer): TField;
protected
function GetMappedIndex(ColIndex: Integer): Integer;
function MoveBy(Distance: Integer): Integer; override;
procedure ActiveChanged; override;
{$IFDEF CIL}
procedure DataEvent(Event: TDataEvent; Info: TObject); override;
{$ELSE}
procedure DataEvent(Event: TDataEvent; Info: Integer); override;
{$ENDIF}
procedure DataSetChanged; override;
procedure DataSetScrolled(Distance: Integer); override;
procedure EditingChanged; override;
{$IFDEF CIL}
procedure FocusControl(const Field: TField); override;
{$ELSE}
procedure FocusControl(Field: TFieldRef); override;
{$ENDIF}
procedure LayoutChanged; override;
procedure RecordChanged(Field: TField); override;
procedure UpdateData; override;
public
constructor Create(AGrid: TCustomDBGridEh);
destructor Destroy; override;
function AddMapping(const FieldName: string): Boolean;
procedure ClearMapping;
procedure Modified;
procedure Reset;
property DefaultFields: Boolean read GetDefaultFields;
property FieldCount: Integer read FFieldCount;
property Fields[I: Integer]: TField read GetFields;
property SparseMap: Boolean read FSparseMap write FSparseMap;
end;
{ TBookmarkListEh }
TBookmarkListEh = class(TBMListEh)
private
FGrid: TCustomDBGridEh;
protected
function GetDataSet: TDataSet; override;
procedure Invalidate; override;
procedure SetCurrentRowSelected(Value: Boolean); override;
procedure UpdateState; override;
public
constructor Create(AGrid: TCustomDBGridEh);
function SelectionToGridRect: TGridRect;
procedure Clear; override;
end;
{ THeadTreeNode }
THeadTreeNode = class;
TDBGridEh = class;
LeafCol = record
FLeaf: THeadTreeNode;
FColumn: TColumnEh;
end;
PLeafCol = ^LeafCol;
TLeafCol = array[0..MaxListSize - 1] of LeafCol;
// PTLeafCol = ^TLeafCol;
PTLeafCol = array of LeafCol;
THeadTreeProc = procedure(node: THeadTreeNode) of object;
THeadTreeNode = class(TObject)
public
Child: THeadTreeNode;
Column: TColumnEh;
Drawed: Boolean;
Height: Integer;
HeightPrn: Integer;
Host: THeadTreeNode;
Next: THeadTreeNode;
Text: String;
VLineWidth: Integer;
Width: Integer;
WidthPrn: Integer;
WIndent: Integer;
constructor Create;
constructor CreateText(AText: String; AHeight, AWidth: Integer);
destructor Destroy; override;
function Add(AAfter: THeadTreeNode; AText: String; AHeight, AWidth: Integer): THeadTreeNode;
function AddChild(ANode: THeadTreeNode; AText: String; AHeight, AWidth: Integer): THeadTreeNode;
function Find(ANode: THeadTreeNode): Boolean;
function GetLevel: Integer;
procedure CreateFieldTree(AGrid: TCustomDBGridEh);
procedure DoForAllNode(proc: THeadTreeProc);
procedure FreeAllChild;
procedure Union(AFrom, ATo: THeadTreeNode; AText: String; AHeight: Integer);
end;
{ TDBGridEhSumList }
TDBGridEhSumList = class(TDBSumListProducer)
private
function GetActive: Boolean;
procedure SetActive(const Value: Boolean);
protected
procedure ReturnEvents; override;
public
constructor Create(AOwner: TComponent);
procedure SetDataSetEvents; override;
published
property Active: Boolean read GetActive write SetActive default False;
property ExternalRecalc default False;
property OnRecalcAll;
property OnAfterRecalcAll;
property SumListChanged;
property VirtualRecords default False;
end;
{TDBGridEhScrollBar}
TScrollBarVisibleModeEh = (sbAlwaysShowEh, sbNeverShowEh, sbAutoShowEh);
TDBGridEhScrollBar = class(TPersistent)
private
FDBGridEh: TCustomDBGridEh;
FExtScrollBar: TScrollBar;
FKind: TScrollBarKind;
FTracking: Boolean;
FVisibleMode: TScrollBarVisibleModeEh;
function GetVisible: Boolean;
procedure ExtScrollWindowProc(var Message: TMessage);
procedure SetExtScrollBar(const Value: TScrollBar);
procedure SetVisible(Value: Boolean);
procedure SetVisibleMode(const Value: TScrollBarVisibleModeEh);
public
constructor Create(AGrid: TCustomDBGridEh; AKind: TScrollBarKind);
destructor Destroy; override;
function GetScrollInfo(var ScrollInfo: TScrollInfo): Boolean;
function IsScrollBarVisible: Boolean;
procedure Assign(Source: TPersistent); override;
procedure UpdateExtScrollBar;
property Kind: TScrollBarKind read FKind;
property VisibleMode: TScrollBarVisibleModeEh read FVisibleMode write SetVisibleMode default sbAutoShowEh;
published
property ExtScrollBar: TScrollBar read FExtScrollBar write SetExtScrollBar;
property Tracking: Boolean read FTracking write FTracking default False;
property Visible: Boolean read GetVisible write SetVisible default True;
end;
TVertDBGridEhScrollBar = class(TDBGridEhScrollBar)
published
property Visible stored False;
property VisibleMode;
end;
TDBGridEhSelectionType = (gstNon, gstRecordBookmarks, gstRectangle, gstColumns, gstAll);
TDBGridEhAllowedSelection = gstRecordBookmarks..gstAll;
TDBGridEhAllowedSelections = set of TDBGridEhAllowedSelection;
TDBCell = record
Col: Longint;
Row: TBookmarkStr;
end;
{ TDBGridEhSelectionRect }
TDBGridEhSelectionRect = class(TObject)
private
FAnchor: TDBCell;
FGrid: TCustomDBGridEh;
FShiftCell: TDBCell;
function BoxRect(ALeft: Longint; ATop: TBookmarkStr; ARight: Longint; ABottom: TBookmarkStr): TRect;
function CheckState: Boolean;
function GetBottomRow: TBookmarkStr;
function GetLeftCol: Longint;
function GetRightCol: Longint;
function GetTopRow: TBookmarkStr;
public
constructor Create(AGrid: TCustomDBGridEh);
function DataCellSelected(DataCol: Longint; DataRow: TBookmarkStr): Boolean;
function SelectionToGridRect: TGridRect;
procedure Clear;
procedure Select(ACol: Longint; ARow: TBookmarkStr; AddSel: Boolean);
property BottomRow: TBookmarkStr read GetBottomRow;
property LeftCol: Longint read GetLeftCol;
property RightCol: Longint read GetRightCol;
property TopRow: TBookmarkStr read GetTopRow;
end;
{ TDBGridEhSelectionCols }
TDBGridEhSelectionCols = class(TColumnsEhList)
private
FAnchor: TColumnEh;
FGrid: TCustomDBGridEh;
FShiftCol: TColumnEh;
FShiftSelectedCols: TColumnsEhList;
procedure Add(ACol: TColumnEh);
public
constructor Create(AGrid: TCustomDBGridEh);
destructor Destroy; override;
function SelectionToGridRect: TGridRect;
procedure Clear; override;
procedure InvertSelect(ACol: TColumnEh);
procedure Refresh;
procedure Select(ACol: TColumnEh; AddSel: Boolean);
procedure SelectShift(ACol: TColumnEh {; Clear:Boolean});
end;
{ TDBGridEhSelection }
TDBGridEhSelection = class
private
FColumns: TDBGridEhSelectionCols;
FGrid: TCustomDBGridEh;
FRect: TDBGridEhSelectionRect;
FSelectionType: TDBGridEhSelectionType;
function GetRows: TBookmarkListEh;
procedure LinkActive(Value: Boolean);
procedure SetSelectionType(ASelType: TDBGridEhSelectionType);
protected
procedure SelectionChanged; virtual;
public
constructor Create(AGrid: TCustomDBGridEh);
destructor Destroy; override;
function DataCellSelected(DataCol: Longint; DataRow: TBookmarkStr): Boolean;
function SelectionToGridRect: TGridRect;
procedure Clear;
procedure Refresh;
procedure SelectAll;
procedure UpdateState;
property Columns: TDBGridEhSelectionCols read FColumns;
property Rect: TDBGridEhSelectionRect read FRect;
property Rows: TBookmarkListEh read GetRows;
property SelectionType: TDBGridEhSelectionType read FSelectionType;
end;
{ TSTDBGridEhFilter }
TSTDBGridEhFilter = class(TPersistent)
private
FGrid: TCustomDBGridEh;
FLocal: Boolean;
FUpateCount: Integer;
FVisible: Boolean;
procedure SetLocal(const Value: Boolean);
procedure SetVisible(const Value: Boolean);
public
constructor Create(AGrid: TCustomDBGridEh);
procedure Assign(Source: TPersistent); override;
procedure BeginUpdate;
procedure EndUpdate;
property UpdateCount: Integer read FUpateCount;
published
property Local: Boolean read FLocal write SetLocal default False;
property Visible: Boolean read FVisible write SetVisible default False;
end;
{ TCustomDBGridEh }
THorzCellTypeEh = (hctIndicatorEh, hctDataEh);
TVertCellTypeEh = (vctTitleEh, vctSubTitleEh, vctDataEh, vctAboveFooterEh, vctFooterEh);
TCellTypeEh = record
HorzType: THorzCellTypeEh;
VertType: TVertCellTypeEh;
end;
TDBGridEhOption = (dghFixed3D, dghFrozen3D, dghFooter3D, dghData3D, dghResizeWholeRightPart,
dghHighlightFocus, dghClearSelection, dghFitRowHeightToText, dghAutoSortMarking,
dghMultiSortMarking, dghEnterAsTab, dghTraceColSizing, dghIncSearch,
dghPreferIncSearch, dghRowHighlight, dghDblClickOptimizeColWidth, dghDialogFind,
dghRecordMoving);
TDBGridEhOptions = set of TDBGridEhOption;
TDBGridEhState = (dgsNormal, dgsRowSelecting, dgsColSelecting, dgsRectSelecting,
dgsPosTracing, dgsTitleDown, dgsColSizing, dgsRowMoving);
TDBGridEhAllowedOperation = (alopInsertEh, alopUpdateEh, alopDeleteEh, alopAppendEh);
TDBGridEhAllowedOperations = set of TDBGridEhAllowedOperation;
TDBGridEhEditAction = (geaCutEh, geaCopyEh, geaPasteEh, geaDeleteEh, geaSelectAllEh);
TDBGridEhEditActions = set of TDBGridEhEditAction;
TInpsDirectionEh = (inpsFromFirstEh, inpsToNextEh, inpsToPriorEh);
{ The DBGridEh's DrawDataCell virtual method and OnDrawDataCell event are only
called when the grid's Columns.State is csDefault. This is for compatibility
with existing code. These routines don't provide sufficient information to
determine which column is being drawn, so the column attributes aren't
easily accessible in these routines. Column attributes also introduce the
possibility that a column's field may be nil, which would break existing
DrawDataCell code. DrawDataCell, OnDrawDataCell, and DefaultDrawDataCell
are obsolete, retained for compatibility purposes. }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -