📄 dbgrideh.pas
字号:
procedure Clear;
procedure SelectAll;
procedure Refresh;
procedure UpdateState;
property Columns: TDBGridEhSelectionCols read FColumns;
property SelectionType:TDBGridEhSelectionType read FSelectionType;
property Rect: TDBGridEhSelectionRect read FRect;
property Rows: TBookmarkListEh read GetRows;
end;
TDBGridEhState = (dgsNormal, dgsRowSelecting, dgsColSelecting, dgsRectSelecting,
dgsPosTracing, dgsTitleDown, dgsColSizing);
TDBGridEhAllowedOperation = (alopInsertEh, alopUpdateEh, alopDeleteEh, alopAppendEh);
TDBGridEhAllowedOperations = set of TDBGridEhAllowedOperation;
TDBGridEhEditAction = (geaCutEh, geaCopyEh, geaPasteEh, geaDeleteEh, geaSelectAllEh);
TDBGridEhEditActions = set of TDBGridEhEditAction;
{ 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. }
(* TDrawDataCellEvent = procedure (Sender: TObject; const Rect: TRect; Field: TField;
State: TGridDrawState) of object; *)
{ The DBGridEh's DrawColumnCell virtual method and OnDrawColumnCell event are
always called, when the grid has defined column attributes as well as when
it is in default mode. These new routines provide the additional
information needed to access the column attributes for the cell being
drawn, and must support nil fields. }
TDrawColumnEhCellEvent = procedure (Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumnEh; State: TGridDrawState) of object;
TDBGridEhClickEvent = procedure (Column: TColumnEh) of object;
TDrawFooterCellEvent = procedure (Sender: TObject; DataCol, Row: Longint;
Column: TColumnEh; Rect: TRect; State: TGridDrawState) of object;
TGetFooterParamsEvent = procedure (Sender: TObject; DataCol, Row: Longint;
Column: TColumnEh; AFont: TFont; var Background: TColor;
var Alignment : TAlignment; State: TGridDrawState; var Text:String) of object;
TTitleEhClickEvent = procedure (Sender: TObject; ACol: Longint;
Column: TColumnEh) of object;
TCheckTitleEhBtnEvent = procedure (Sender: TObject; ACol: Longint;
Column: TColumnEh; var Enabled: Boolean) of object;
TGetBtnEhParamsEvent = procedure (Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; var SortMarker: TSortMarkerEh;
IsDown: Boolean) of object;
TGetCellEhParamsEvent = procedure (Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState) of object;
{ Internal grid types }
TGridAxisDrawInfoEh = record
EffectiveLineWidth: Integer;
FixedBoundary: Integer;
GridBoundary: Integer;
GridExtent: Integer;
LastFullVisibleCell: Longint;
FullVisBoundary: Integer;
FixedCellCount: Integer;
FirstGridCell: Integer;
GridCellCount: Integer;
GetExtent: TGetExtentsFunc;
FrozenExtent:Integer;
FooterExtent:Integer;
end;
TGridDrawInfoEh = record
Horz, Vert: TGridAxisDrawInfoEh;
end;
//Wang Zhenhua Added Event Type
TSetEditEventEH = procedure (Sender: TObject; ACol, ARow: Longint; Const Value: string) of object;
TGetConfirmTextEvent = procedure (Sender:TObject;var Text:String)of object;
//Wang Zhenhua Added End
TCustomDBGridEh = class(TCustomGrid)
private
//Wang Zhenhua Added Event & property
FOnGetEditText: TGetEditEvent;
FOnSetEditText: TSetEditEventEH;
FOnTopLeftChanged: TNotifyEvent;
FOnGetConfirmText:TGetConfirmTextEvent;
//Wang Zhenhua Added Event & property end
FIndicators: TImageList;
FTitleFont: TFont;
FReadOnly: Boolean;
FOriginalImeName: TImeName;
FOriginalImeMode: TImeMode;
FUserChange: Boolean;
FLayoutFromDataset: Boolean;
FOptions: TDBGridOptions;
FTitleOffset, FIndicatorOffset: Byte;
FUpdateLock: Byte;
FLayoutLock: Byte;
FInColExit: Boolean;
FDefaultDrawing: Boolean;
FSelfChangingTitleFont: Boolean;
FSelecting: Boolean;
FSelRow: Integer;
FDataLink: TGridDataLinkEh;
FOnColEnter: TNotifyEvent;
FOnColExit: TNotifyEvent;
FOnDrawDataCell: TDrawDataCellEvent;
FOnDrawColumnCell: TDrawColumnEhCellEvent;
FEditText: string;
FColumns: TDBGridColumnsEh;
FOnEditButtonClick: TNotifyEvent;
FOnColumnMoved: TMovedEvent;
FBookmarks: TBookmarkListEh;
FSelectionAnchor: TBookmarkStr;
FOnCellClick: TDBGridEhClickEvent;
FOnTitleClick:TDBGridEhClickEvent;
//ddd
FOnGetCellParams: TGetCellEhParamsEvent;
FOnGetFooterParams: TGetFooterParamsEvent;
FOnSumListRecalcAll: TNotifyEvent;
FHorzScrollBar: TDBGridEhScrollBar;
FVertScrollBar: TDBGridEhScrollBar;
FOptionsEh: TDBGridEhOptions;
FEditKeyValue: Variant; // For lookup fields and KeyList based column
ThumbTracked:Boolean;
FOnSortMarkingChanged: TNotifyEvent;
FOnColWidthsChanged: TNotifyEvent;
FSortMarking:Boolean;
FUpDownBitmap:TBitmap;
FTopLeftVisible:Boolean;
FSelection: TDBGridEhSelection;
FAutoDrag, FSelectedCellPressed:Boolean;
// FHintCell: TGridCoord;
FTitleImages: {$IFDEF EH_LIB_4}TCustomImageList{$ELSE}TImageList{$ENDIF};
FAllowedOperations: TDBGridEhAllowedOperations;
FSizingIndex: Longint;
FSizingPos, FSizingOfs: Integer;
FSelfChangingFooterFont: Boolean;
FFooterFont: TFont;
FFooterColor: TColor;
FHintFont:TFont;
FFlat: Boolean;
FInterlinear:Integer;
FBorderWidth:Integer;
FEditActions: TDBGridEhEditActions;
//Wang Zhenhua Add
FWzhStyle: Boolean;
FCurrencyStyle: TMoneyStyle;
FHasCurrency: Boolean;
FDrawCurrency: Boolean;
//Wang Zhenhua Add End
//\\\
function AcquireFocus: Boolean;
procedure DataChanged;
procedure EditingChanged;
function GetDataSource: TDataSource;
function GetFieldCount: Integer;
function GetFields(FieldIndex: Integer): TField;
function GetSelectedField: TField;
function GetSelectedIndex: Integer;
procedure InternalLayout;
procedure MoveCol(RawCol, Direction: Integer; Select:Boolean);
procedure ReadColumns(Reader: TReader);
procedure RecordChanged(Field: TField);
procedure SetIme;
procedure SetColumns(Value: TDBGridColumnsEh);
procedure SetDataSource(Value: TDataSource);
procedure SetOptions(Value: TDBGridOptions);
procedure SetSelectedField(Value: TField);
procedure SetSelectedIndex(Value: Integer);
procedure SetTitleFont(Value: TFont);
procedure TitleFontChanged(Sender: TObject);
procedure UpdateData;
procedure UpdateActive;
procedure UpdateIme;
procedure UpdateScrollBar;
procedure UpdateRowCount;
procedure WriteColumns(Writer: TWriter);
procedure CMExit(var Message: TMessage); message CM_EXIT;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMParentFontChanged(var Message: TMessage); message CM_PARENTFONTCHANGED;
procedure CMDeferLayout(var Message); message cm_DeferLayout;
procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;
procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMIMEStartComp(var Message: TMessage); message WM_IME_STARTCOMPOSITION;
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SetFOCUS;
procedure WMKillFocus(var Message: TMessage); message WM_KillFocus;
procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND; //tmp
procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT;
procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
procedure SetDrawMemoText(const Value: Boolean);
procedure SetSumList(const Value: TDBGridEhSumList);
procedure SetHorzScrollBar(const Value: TDBGridEhScrollBar);
procedure SetVertScrollBar(const Value: TDBGridEhScrollBar);
procedure SetOptionsEh(const Value: TDBGridEhOptions);
//ddd
procedure WMChar(var Message: TWMChar); message WM_CHAR;
procedure WMTimer(var Message: TMessage); message WM_TIMER;
procedure ClearSelection;
procedure DoSelection(Select: Boolean; Direction: Integer; MaxDirection,RowOnly: Boolean);
function UpDownBitmap: TBitmap;
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
{$IFDEF EH_LIB_4}
procedure CMHintsShowPause(var Message: TCMHintShowPause); message CM_HINTSHOWPAUSE;
{$ENDIF}
procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
procedure SetTitleImages(const Value: {$IFDEF EH_LIB_4}TCustomImageList{$ELSE}TImageList{$ENDIF});
function GetCol: Longint;
procedure SetCol(Value: Longint);
procedure SetFooterFont(Value: TFont);
procedure FooterFontChanged(Sender: TObject);
procedure SetFooterColor(Value: TColor);
function IsActiveControl: Boolean;
procedure ChangeGridOrientation(RightToLeftOrientation: Boolean);
procedure CalcDrawInfoXYEh(var DrawInfo: TGridDrawInfoEh; UseWidth, UseHeight: Integer);
function GetRowHeights(Index: Longint): Integer;
{$IFNDEF EH_LIB_4} {Borland Delphi 3.0 or C++ Builder 3.0}
function UseRightToLeftAlignment: Boolean;
{$ENDIF}
procedure SetFlat(const Value: Boolean);
procedure DrawEdgeEh(ACanvas:TCanvas;var qrc: TRect; IsDown,IsSelected:Boolean; NeedLeft,NeedRight:Boolean);
//Wang Zhenhua Add
procedure SetWzhStyle(Value: Boolean);
function GetWzhStyle: Boolean;
procedure SetDrawCurrency(Value: Boolean);
function GetDrawCurrency: Boolean;
procedure SetCurrencyStyle(Value: TMoneyStyle);
function GetCurrencyStyle: TMoneyStyle;
//Wang Zhenhua Add end
//\\\
protected
FUpdateFields: Boolean;
FAcquireFocus: Boolean;
FUpdatingEditor: Boolean;
//ddd
FDBGridEhState: TDBGridEhState;
FTitleHeight: Integer;
FTitleLines: Integer;
FTitleHeightFull: Integer;
FMarginText:Boolean;
FVTitleMargin: Integer;
FHTitleMargin: Integer;
FUseMultiTitle: Boolean;
FAutoFitColWidths:Boolean;
FMinAutoFitWidth:Integer;
FInitColWidth:TList;
FFooterRowCount: Integer;
FOnDrawFooterCell:TDrawFooterCellEvent;
FHeadTree:THeadTreeNode;
FLeafFieldArr:PTLeafCol;
FNewRowHeight: Integer;
FRowLines: Integer;
FRowSizingAllowed : Boolean;
FDefaultRowChanged: Boolean;
FAllowWordWrap: Boolean; // True if RowHeight + 3 > TextHeight
FDrawMemoText: Boolean;
FSortMarkerImages:TImageList;
FPressedCol: Longint;
FPressed: Boolean;
FTracking: Boolean;
FSwapButtons: Boolean;
FOnCheckButton: TCheckTitleEhBtnEvent;
FOnGetBtnParams: TGetBtnEhParamsEvent;
FOnTitleBtnClick: TTitleEhClickEvent;
FInplaceEditorButtonWidth: Integer;
FFrozenCols: Integer;
FSumList:TDBGridEhSumList;
FVisibleColumns:TColumnsEhList;
FPressedCell:TGridCoord;
FIndicatorPressed:Boolean;
FDownMousePos: TPoint;
FMoveMousePos: TPoint;
FMouseShift:TShiftState;
FTimerActive:Boolean;
FTimerInterval:Integer;
FPresedRecord:TBookMarkStr;
FSelectionAnchorSelected:Boolean;
FAntiSelection:Boolean;
FDataTracking:Boolean;
FSortMarkedColumns:TColumnsEhList;
FLockPaint:Boolean;
FLockedBookmark:TBookmarkStr;
FLookedOffset:Integer;
// FFrozenFocuse:Boolean;
FFrozenCol:Integer;
//
procedure Paint;override; //
function GetFooterRowCount: Integer;
procedure SetFooterRowCount(Value: Integer);
procedure ClearPainted(node:THeadTreeNode);
function SetChildTreeHeight(ANode:THeadTreeNode):Integer;
function ReadTitleHeight: Integer;
procedure WriteTitleHeight(th: Integer);
function ReadTitleLines: Integer;
procedure WriteTitleLines(tl: Integer);
procedure WriteMarginText(IsMargin:Boolean);
procedure WriteVTitleMargin(Value: Integer);
procedure WriteHTitleMargin(Value: Integer);
procedure WriteUseMultiTitle(Value:Boolean);
procedure WriteAutoFitColWidths(Value:Boolean);
procedure WriteMinAutoFitWidth(Value:Integer);
function GetColWidths(Index: Longint): Integer;
procedure SetColWidths(Index: Longint; Value: Integer);
procedure SetRowSizingAllowed(Value:Boolean);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -