DBGridEh.pas
资源名称:EhLib.rar [点击查看]
上传用户:lxdzzlq
上传日期:2013-01-26
资源大小:347k
文件大小:673k
源码类别:
Windows编程
开发平台:
C++ Builder
- {*******************************************************}
- { }
- { EhLib v4.1 }
- { }
- { TDBGridEh component }
- { with support of IMemTableEh }
- { Build 4.1.27 }
- { }
- { Copyright (c) 1998-2005 by Dmitry V. Bolshakov }
- { }
- {*******************************************************}
- {$I EhLib.Inc}
- {$IFDEF EH_LIB_VCL}
- unit DBGridEh{$IFDEF CIL}platform{$ENDIF};
- {$ELSE}
- unit QDBGridEh;
- {$ENDIF}
- //{$R-}
- interface
- {$IFDEF EH_LIB_VCL}
- uses Windows, SysUtils, Messages, Classes, Controls, Forms, StdCtrls,
- {$IFDEF EH_LIB_5}Contnrs, {$ENDIF}
- {$IFDEF EH_LIB_6}Variants, Types, {$ENDIF}
- {$IFDEF CIL}
- EhLibVCLNET,
- WinUtils,
- {$ELSE}
- EhLibVCL,
- {$ENDIF}
- Graphics, GridsEh, DBCtrls, Db, Menus, Registry, DBSumLst, DBCtrlsEh,
- IniFiles, ToolCtrlsEh, ImgList, StdActns, PropFilerEh //The PropStorage
- {,dbugintf};
- {$ELSE}
- uses SysUtils, Classes, Types, QControls, QForms, QStdCtrls,
- Variants, QGraphics, QGrids, QDBCtrls, Db, QMenus, QDBGrids, QDBSumLst, QDBCtrlsEh,
- IniFiles, QToolCtrlsEh, QImgList, QStdActns, Qt;
- {$ENDIF}
- type
- TDBGridColumnsState = (csDefault, csCustomized);
- TDrawDataCellEvent = procedure(Sender: TObject; const Rect: TRect; Field: TField;
- State: TGridDrawState) of object;
- TDBGridOption = (dgEditing, dgAlwaysShowEditor, dgTitles, dgIndicator,
- dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect,
- dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgMultiSelect);
- TDBGridOptions = set of TDBGridOption;
- TColumnEhValue = (cvColor, cvWidth, cvFont, cvAlignment, cvReadOnly, cvTitleColor,
- cvTitleCaption, cvTitleAlignment, cvTitleFont, cvTitleButton, cvTitleEndEllipsis,
- cvTitleToolTips, cvTitleOrientation, cvImeMode, cvImeName, cvWordWrap,
- cvLookupDisplayFields, cvCheckboxes, cvAlwaysShowEditButton, cvEndEllipsis,
- cvAutoDropDown, cvDblClickNextVal, cvToolTips, cvDropDownSizing,
- cvDropDownShowTitles, cvLayout, cvHighlightRequired, cvBiDiMode);
- TColumnEhValues = set of TColumnEhValue;
- TColumnFooterEhValue = (cvFooterAlignment, cvFooterFont, cvFooterColor, cvFooterToolTips);
- TColumnFooterValues = set of TColumnFooterEhValue;
- TColumnEhRestoreParam = (crpColIndexEh, crpColWidthsEh, crpSortMarkerEh, crpColVisibleEh,
- crpDropDownRowsEh, crpDropDownWidthEh);
- TColumnEhRestoreParams = set of TColumnEhRestoreParam;
- TDBGridEhRestoreParam = (grpColIndexEh, grpColWidthsEh, grpSortMarkerEh, grpColVisibleEh,
- grpRowHeightEh, grpDropDownRowsEh, grpDropDownWidthEh);
- TDBGridEhRestoreParams = set of TDBGridEhRestoreParam;
- const
- /// 赖-2008-03-13 字段值为空
- CS_NULLVALUE = '<NULL>';
- cm_DeferLayout = WM_USER + 100;
- IndicatorWidth = 11;
- ColumnEhTitleValues = [cvTitleColor..cvTitleOrientation];
- ColumnEhFooterValues = [cvFooterAlignment..cvFooterColor];
- (* cm_DeferLayout = WM_USER + 100; *)
- { TColumnEh defines internal storage for column attributes. If IsStored is
- True, values assigned to properties are stored in this object, the grid-
- or field-based default sources are not modified. Values read from
- properties are the previously assigned value, if any, or the grid- or
- field-based default values if nothing has been assigned to that property.
- This class also publishes the column attribute properties for persistent
- storage.
- If IsStored is True, the column does not maintain local storage of
- property values. Assignments to column properties are passed through to
- the underlying grid- or field-based default sources. }
- type
- TColumnEh = class;
- TCustomDBGridEh = class;
- TColumnDropDownBoxEh = class;
- TDBGridEhStyle = class;
- { for lookup drop-down grid }
- TDBLookupGridEhOption = (dlgColumnResizeEh, dlgColLinesEh, dlgRowLinesEh,
- dlgAutoSortMarkingEh, dlgMultiSortMarkingEh);
- TDBLookupGridEhOptions = set of TDBLookupGridEhOption;
- TCheckTitleEhBtnEvent = procedure(Sender: TObject; ACol: Longint;
- Column: TColumnEh; var Enabled: Boolean) of object;
- TDrawColumnEhCellEvent = procedure(Sender: TObject; const Rect: TRect;
- DataCol: Integer; Column: TColumnEh; State: TGridDrawState) of object;
- TGetCellEhParamsEvent = procedure(Sender: TObject; Column: TColumnEh;
- AFont: TFont; var Background: TColor; State: TGridDrawState) of object;
- TTitleEhClickEvent = procedure(Sender: TObject; ACol: Longint;
- Column: TColumnEh) of object;
- TOnColumnCheckDrawRequiredStateEventEh = procedure(Sender: TObject;
- Text: string; var DrawState: Boolean) of object;
- TGridMoveRecordsEventEh = function(Sender: TObject; BookmarkList: TStrings;
- ToRecNo: Longint; TreeLevel: Integer; CheckOnly: Boolean): Boolean of object;
- { ILookupGridOwner interface }
- ILookupGridOwner = interface
- ['{2A1F4552-15C3-4359-ADAB-F2F6719FAA97}']
- procedure SetListSource(AListSource: TDataSource);
- function GetLookupGrid: TCustomDBGridEh;
- function GetOptions: TDBLookupGridEhOptions;
- procedure SetOptions(Value: TDBLookupGridEhOptions);
- property Options: TDBLookupGridEhOptions read GetOptions write SetOptions;
- end;
- TSortMarkerEh = (smNoneEh, smDownEh, smUpEh);
- TTextOrientationEh = (tohHorizontal, tohVertical);
- { TColumnTitleEh }
- TColumnTitleEh = class(TPersistent)
- private
- FAlignment: TAlignment;
- FCaption: string;
- FColor: TColor;
- FColumn: TColumnEh;
- FEndEllipsis: Boolean;
- FFont: TFont;
- FHint: string;
- FImageIndex: Integer;
- FOrientation: TTextOrientationEh;
- FSortIndex: Integer;
- FToolTips: Boolean;
- function GetAlignment: TAlignment;
- function GetCaption: string;
- function GetColor: TColor;
- function GetEndEllipsis: Boolean;
- function GetFont: TFont;
- function GetOrientation: TTextOrientationEh;
- function GetTitleButton: Boolean;
- function GetToolTips: Boolean;
- function IsAlignmentStored: Boolean;
- function IsCaptionStored: Boolean;
- function IsColorStored: Boolean;
- function IsEndEllipsisStored: Boolean;
- function IsFontStored: Boolean;
- function IsOrientationStored: Boolean;
- function IsTitleButtonStored: Boolean;
- function IsToolTipsStored: Boolean;
- procedure FontChanged(Sender: TObject);
- procedure SetAlignment(Value: TAlignment);
- procedure SetCaption(const Value: string); virtual;
- procedure SetColor(Value: TColor);
- procedure SetEndEllipsis(const Value: Boolean);
- procedure SetFont(Value: TFont);
- procedure SetImageIndex(const Value: Integer);
- procedure SetOrientation(const Value: TTextOrientationEh);
- procedure SetSortIndex(Value: Integer);
- procedure SetToolTips(const Value: Boolean);
- protected
- FSortMarker: TSortMarkerEh;
- FTitleButton: Boolean;
- function GetSortMarkingWidth: Integer;
- procedure RefreshDefaultFont;
- procedure SetSortMarker(Value: TSortMarkerEh);
- procedure SetTitleButton(Value: Boolean);
- public
- constructor Create(Column: TColumnEh);
- destructor Destroy; override;
- function DefaultAlignment: TAlignment;
- function DefaultCaption: string;
- function DefaultColor: TColor;
- function DefaultEndEllipsis: Boolean;
- function DefaultFont: TFont;
- function DefaultOrientation: TTextOrientationEh;
- function DefaultTitleButton: Boolean;
- function DefaultToolTips: Boolean;
- procedure Assign(Source: TPersistent); override;
- procedure RestoreDefaults; virtual;
- procedure SetNextSortMarkerValue(KeepMulti: Boolean);
- property Column: TColumnEh read FColumn;
- published
- property Alignment: TAlignment read GetAlignment write SetAlignment stored IsAlignmentStored;
- property Caption: string read GetCaption write SetCaption stored IsCaptionStored;
- property Color: TColor read GetColor write SetColor stored IsColorStored;
- property EndEllipsis: Boolean read GetEndEllipsis write SetEndEllipsis stored IsEndEllipsisStored;
- property Font: TFont read GetFont write SetFont stored IsFontStored;
- property Hint: string read FHint write FHint;
- property ImageIndex: Integer read FImageIndex write SetImageIndex default -1;
- property Orientation: TTextOrientationEh read GetOrientation write SetOrientation stored IsOrientationStored;
- property SortIndex: Integer read FSortIndex write SetSortIndex default 0;
- property SortMarker: TSortMarkerEh read FSortMarker write SetSortMarker default smNoneEh;
- property TitleButton: Boolean read GetTitleButton write SetTitleButton stored IsTitleButtonStored;
- property ToolTips: Boolean read GetToolTips write SetToolTips stored IsToolTipsStored;
- end;
- { TColumnFooterEh }
- TFooterValueType = (fvtNon, fvtSum, fvtAvg, fvtCount, fvtFieldValue, fvtStaticText);
- TColumnFooterEh = class(TCollectionItem)
- private
- FAlignment: TAlignment;
- FAssignedValues: TColumnFooterValues;
- FColor: TColor;
- FColumn: TColumnEh;
- FDisplayFormat: string;
- FEndEllipsis: Boolean;
- FFieldName: string;
- FFont: TFont;
- FToolTips: Boolean;
- FValue: string;
- FValueType: TFooterValueType;
- FWordWrap: Boolean;
- function GetAlignment: TAlignment;
- function GetColor: TColor;
- function GetFont: TFont;
- function GetSumValue: Variant;
- function GetToolTips: Boolean;
- function IsAlignmentStored: Boolean;
- function IsColorStored: Boolean;
- function IsFontStored: Boolean;
- function IsToolTipsStored: Boolean;
- procedure FontChanged(Sender: TObject);
- procedure SetAlignment(Value: TAlignment);
- procedure SetColor(Value: TColor);
- procedure SetDisplayFormat(const Value: string);
- procedure SetEndEllipsis(const Value: Boolean);
- procedure SetFieldName(const Value: string);
- procedure SetFont(Value: TFont);
- procedure SetToolTips(const Value: Boolean);
- procedure SetValue(const Value: string);
- procedure SetValueType(const Value: TFooterValueType);
- procedure SetWordWrap(const Value: Boolean);
- protected
- FDBSum: TDBSum;
- procedure RefreshDefaultFont;
- public
- constructor Create(Collection: TCollection); override;
- constructor CreateApart(Column: TColumnEh);
- destructor Destroy; override;
- function DefaultAlignment: TAlignment;
- function DefaultColor: TColor;
- function DefaultFont: TFont;
- function DefaultToolTips: Boolean;
- procedure Assign(Source: TPersistent); override;
- procedure EnsureSumValue;
- procedure RestoreDefaults; virtual;
- property AssignedValues: TColumnFooterValues read FAssignedValues;
- property Column: TColumnEh read FColumn;
- property SumValue: Variant read GetSumValue;
- published
- property Alignment: TAlignment read GetAlignment write SetAlignment stored IsAlignmentStored;
- property Color: TColor read GetColor write SetColor stored IsColorStored;
- property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
- property EndEllipsis: Boolean read FEndEllipsis write SetEndEllipsis default False;
- property FieldName: string read FFieldName write SetFieldName;
- property Font: TFont read GetFont write SetFont stored IsFontStored;
- property ToolTips: Boolean read GetToolTips write SetToolTips stored IsToolTipsStored;
- property Value: string read FValue write SetValue;
- property ValueType: TFooterValueType read FValueType write SetValueType default fvtNon;
- property WordWrap: Boolean read FWordWrap write SetWordWrap default False;
- end;
- TColumnFooterEhClass = class of TColumnFooterEh;
- { TColumnFootersEh }
- TColumnFootersEh = class(TCollection)
- private
- FColumn: TColumnEh;
- function GetFooter(Index: Integer): TColumnFooterEh;
- procedure SetFooter(Index: Integer; Value: TColumnFooterEh);
- protected
- function GetOwner: TPersistent; override;
- procedure Update(Item: TCollectionItem); override;
- public
- constructor Create(Column: TColumnEh; FooterClass: TColumnFooterEhClass);
- function Add: TColumnFooterEh;
- property Column: TColumnEh read FColumn;
- property Items[Index: Integer]: TColumnFooterEh read GetFooter write SetFooter; default;
- end;
- TColumnEhType = (ctCommon, ctPickList, ctLookupField, ctKeyPickList, ctKeyImageList,
- ctCheckboxes);
- TColumnButtonStyleEh = (cbsAuto, cbsEllipsis, cbsNone, cbsUpDown, cbsDropDown);
- { TColumnTitleDefValuesEh }
- TColumnDefValuesEh = class;
- TColumnTitleDefValuesEhValue = (cvdpTitleColorEh, cvdpTitleAlignmentEh);
- TColumnTitleDefValuesEhValues = set of TColumnTitleDefValuesEhValue;
- TColumnTitleDefValuesEh = class(TPersistent)
- private
- FAlignment: TAlignment;
- FAssignedValues: TColumnTitleDefValuesEhValues;
- FColor: TColor;
- FColumnDefValues: TColumnDefValuesEh;
- FEndEllipsis: Boolean;
- FOrientation: TTextOrientationEh;
- FTitleButton: Boolean;
- FToolTips: Boolean;
- function DefaultAlignment: TAlignment;
- function DefaultColor: TColor;
- function GetAlignment: TAlignment;
- function GetColor: TColor;
- function IsAlignmentStored: Boolean;
- function IsColorStored: Boolean;
- procedure SetAlignment(const Value: TAlignment);
- procedure SetColor(const Value: TColor);
- procedure SetEndEllipsis(const Value: Boolean);
- procedure SetOrientation(const Value: TTextOrientationEh);
- public
- procedure Assign(Source: TPersistent); override;
- property AssignedValues: TColumnTitleDefValuesEhValues read FAssignedValues;
- published
- constructor Create(ColumnDefValues: TColumnDefValuesEh);
- property Alignment: TAlignment read GetAlignment write SetAlignment stored IsAlignmentStored;
- property Color: TColor read GetColor write SetColor stored IsColorStored;
- property EndEllipsis: Boolean read FEndEllipsis write SetEndEllipsis default False;
- property Orientation: TTextOrientationEh read FOrientation write SetOrientation default tohHorizontal;
- property TitleButton: Boolean read FTitleButton write FTitleButton default False;
- property ToolTips: Boolean read FToolTips write FToolTips default False;
- end;
- { TColumnFooterDefValuesEh }
- TColumnFooterDefValuesEh = class(TPersistent)
- private
- FToolTips: Boolean;
- public
- procedure Assign(Source: TPersistent); override;
- published
- property ToolTips: Boolean read FToolTips write FToolTips default False;
- end;
- { TColumnDefValuesEh }
- TColumnDefValuesEh = class(TPersistent)
- private
- FAlwaysShowEditButton: Boolean;
- FAutoDropDown: Boolean;
- FDblClickNextVal: Boolean;
- FDropDownShowTitles: Boolean;
- FDropDownSizing: Boolean;
- FEndEllipsis: Boolean;
- FLayout: TTextLayout;
- FHighlightRequired: Boolean;
- FGrid: TCustomDBGridEh;
- FTitle: TColumnTitleDefValuesEh;
- FFooter: TColumnFooterDefValuesEh;
- FToolTips: Boolean;
- procedure SetAlwaysShowEditButton(const Value: Boolean);
- procedure SetEndEllipsis(const Value: Boolean);
- procedure SetFooter(const Value: TColumnFooterDefValuesEh);
- procedure SetHighlightRequired(Value: Boolean);
- procedure SetLayout(Value: TTextLayout);
- procedure SetTitle(const Value: TColumnTitleDefValuesEh);
- public
- procedure Assign(Source: TPersistent); override;
- public
- constructor Create(Grid: TCustomDBGridEh);
- destructor Destroy; override;
- property AlwaysShowEditButton: Boolean read FAlwaysShowEditButton write SetAlwaysShowEditButton default False;
- property AutoDropDown: Boolean read FAutoDropDown write FAutoDropDown default False;
- property DblClickNextVal: Boolean read FDblClickNextVal write FDblClickNextVal default False;
- property DropDownShowTitles: Boolean read FDropDownShowTitles write FDropDownShowTitles default False;
- property DropDownSizing: Boolean read FDropDownSizing write FDropDownSizing default False;
- property EndEllipsis: Boolean read FEndEllipsis write SetEndEllipsis default False;
- property Footer: TColumnFooterDefValuesEh read FFooter write SetFooter;
- property HighlightRequired: Boolean read FHighlightRequired write SetHighlightRequired default False;
- property Layout: TTextLayout read FLayout write SetLayout default tlTop;
- property Title: TColumnTitleDefValuesEh read FTitle write SetTitle;
- property ToolTips: Boolean read FToolTips write FToolTips default False;
- end;
- TDBGridEhColumnDefValuesEh = class(TColumnDefValuesEh)
- published
- property AlwaysShowEditButton;
- property AutoDropDown;
- property DblClickNextVal;
- property DropDownShowTitles;
- property DropDownSizing;
- property EndEllipsis;
- property Footer;
- property HighlightRequired;
- property Layout;
- property Title;
- property ToolTips;
- end;
- { TSTColumnFilterEh }
- TSTFilterOperatorEh = (
- foNon, foEqual, foNotEqual,
- foGreaterThan, foLessThan, foGreaterOrEqual, foLessOrEqual,
- foLike, foNotLike,
- foIn, foNotIn,
- foNull, foNotNull,
- foAND, foOR,
- foValue);
- TSTOperandTypeEh = (botNon, botString, botNumber, botDateTime, botBoolean);
- TSTFilterExpressionEh = record
- ExpressionType: TSTOperandTypeEh;
- Operator1: TSTFilterOperatorEh;
- Operand1: Variant;
- Relation: TSTFilterOperatorEh; // foAND, foOR, foNon
- Operator2: TSTFilterOperatorEh;
- Operand2: Variant;
- end;
- TSTColumnFilterEh = class(TPersistent)
- private
- FColumn: TColumnEh;
- FDataField: string;
- FKeyCommaText: string;
- FKeyField: string;
- FKeys: TStrings;
- FKeyValues: Variant;
- FList: TStrings;
- FListField: string;
- FListLink: TFieldDataLink;
- FVisible: Boolean;
- FDropDownListWidth: Integer;
- FDropDownListRows: Integer;
- function GetExpression: TSTFilterExpressionEh;
- function GetGrid: TCustomDBGridEh;
- function GetListSource: TDataSource;
- function ParseExpression(Exp: string): string;
- procedure ListLinkActiveChange(Sender: TObject);
- procedure SetExpression(const Value: TSTFilterExpressionEh);
- procedure SetExpressionStr(const Value: string);
- procedure SetListSource(const Value: TDataSource);
- procedure SetVisible(const Value: Boolean);
- protected
- FExpression: TSTFilterExpressionEh;
- FExpressionStr: string;
- function GetExpressionAsString: string; virtual;
- function DropDownButtonVisible: Boolean; virtual;
- procedure InternalSetExpressionStr(const Value: string);
- procedure CheckRecodeKeyList(var FExpression: TSTFilterExpressionEh); virtual;
- public
- constructor Create(AColumn: TColumnEh);
- destructor Destroy; override;
- function GetFieldValueList: IMemTableDataFieldValueListEh;
- function GetFilterFieldName: string; virtual;
- function GetOperand1: Variant; virtual;
- function GetOperand2: Variant; virtual;
- function CurrentKeyField: string;
- function CurrentDataField: string;
- function CurrentListDataSet: TDataSet;
- function CurrentListField: string;
- procedure Assign(Source: TPersistent); override;
- procedure Clear;
- procedure SetKeyListValues(AText: string; KeyVals: Variant);
- procedure SetKeysFromListValues(ss: TStrings);
- property DropDownListWidth: Integer read FDropDownListWidth write FDropDownListWidth default 0;
- property DropDownListRows: Integer read FDropDownListRows write FDropDownListRows default 0;
- property Column: TColumnEh read FColumn;
- property Expression: TSTFilterExpressionEh read GetExpression write SetExpression;
- property ExpressionStr: string read FExpressionStr write SetExpressionStr;
- property Grid: TCustomDBGridEh read GetGrid;
- property KeyCommaText: string read FKeyCommaText write FKeyCommaText;
- published
- property DataField: string read FDataField write FDataField;
- property KeyField: string read FKeyField write FKeyField;
- property ListField: string read FListField write FListField;
- property ListSource: TDataSource read GetListSource write SetListSource;
- property Visible: Boolean read FVisible write SetVisible default True;
- end;
- { TColumnEh }
- TColCellParamsEh = class(TObject)
- protected
- FAlignment: TAlignment;
- FBackground: TColor;
- FCheckboxState: TCheckBoxState;
- FCol: Longint;
- FFont: TFont;
- FImageIndex: Integer;
- FReadOnly: Boolean;
- FRow: Longint;
- FState: TGridDrawState;
- FText: string;
- public
- property Alignment: TAlignment read FAlignment write FAlignment;
- property Background: TColor read FBackground write FBackground;
- property CheckboxState: TCheckBoxState read FCheckboxState write FCheckboxState;
- property Col: Longint read FCol write FCol;
- property Font: TFont read FFont write FFont;
- property ImageIndex: Integer read FImageIndex write FImageIndex;
- property ReadOnly: Boolean read FReadOnly write FReadOnly;
- property Row: Longint read FRow write FRow;
- property State: TGridDrawState read FState write FState;
- property Text: string read FText write FText;
- end;
- TGetColCellParamsEventEh = procedure(Sender: TObject; EditMode: Boolean;
- Params: TColCellParamsEh) of object;
- TColCellUpdateDataEventEh = procedure(Sender: TObject; var Text: string;
- var Value: Variant; var UseText: Boolean; var Handled: Boolean) of object;
- TColumnEh = class(TCollectionItem, ILookupGridOwner{$IFNDEF CIL}, IUnknown{$ENDIF})
- private
- FAlignment: TAlignment;
- FAssignedValues: TColumnEhValues;
- FBiDiMode: TBiDiMode;
- FButtonStyle: TColumnButtonStyleEh;
- FCheckboxes: Boolean;
- FColor: TColor;
- FDblClickNextVal: Boolean;
- FDisplayFormat: string;
- FDropDownBox: TColumnDropDownBoxEh;
- FDropDownRows: Cardinal;
- FDropDownShowTitles: Boolean;
- FDropDownSizing: Boolean;
- FDropDownSpecRow: TSpecRowEh;
- FEditButtons: TEditButtonsEh;
- FEditMask: string;
- FField: TField;
- FFieldName: string;
- FFont: TFont;
- FFooter: TColumnFooterEh;
- FFooters: TColumnFootersEh;
- FHideDuplicates: Boolean;
- FHighlightRequired: Boolean;
- FImageList: TCustomImageList;
- FImageChangeLink: TChangeLink;
- {$IFDEF EH_LIB_VCL}
- FImeMode: TImeMode;
- FImeName: TImeName;
- {$ENDIF}
- FIncrement: Extended;
- FLayout: TTextLayout;
- FKeyList: TStrings;
- FMaxWidth: Integer;
- FMinWidth: Integer;
- FMRUList: TMRUListEh;
- FNotInKeyListIndex: Integer;
- FNotInWidthRange: Boolean;
- FOnButtonClick: TButtonClickEventEh;
- FOnButtonDown: TButtonDownEventEh;
- FOnGetCellParams: TGetColCellParamsEventEh;
- // FOnGetItemImageIndex: TListGetImageIndexEventEh;
- FOnNotInList: TNotInListEventEh;
- FPickList: TStrings;
- FPopupMenu: TPopupMenu;
- FReadonly: Boolean;
- FStored: Boolean;
- FShowImageAndText: Boolean;
- FTag: Longint;
- FTitle: TColumnTitleEh;
- FToolTips: Boolean;
- FUpdateData: TColCellUpdateDataEventEh;
- FVisible: Boolean;
- FWidth: Integer;
- FSTFilter: TSTColumnFilterEh;
- FFieldValueList: IMemTableDataFieldValueListEh;
- FOnCheckDrawRequiredState: TOnColumnCheckDrawRequiredStateEventEh;
- function DefaultCheckboxes: Boolean;
- function GetAlignment: TAlignment;
- function GetAlwaysShowEditButton: Boolean;
- function GetAutoDropDown: Boolean;
- function GetBiDiMode: TBiDiMode;
- function GetCheckboxes: Boolean;
- function GetCheckboxState: TCheckBoxState;
- function GetColor: TColor;
- function GetDataList: TCustomDBGridEh;
- function GetDblClickNextVal: Boolean;
- function GetDropDownShowTitles: Boolean;
- function GetDropDownSizing: Boolean;
- function GetEndEllipsis: Boolean;
- function GetField: TField;
- function GetFont: TFont;
- {$IFDEF EH_LIB_VCL}
- function GetImeMode: TImeMode;
- function GetImeName: TImeName;
- {$ENDIF}
- function GetHighlightRequired: Boolean;
- function GetKeykList: TStrings;
- function GetLayout: TTextLayout;
- function GetOnDropDownBoxCheckButton: TCheckTitleEhBtnEvent;
- function GetOnDropDownBoxDrawColumnCell: TDrawColumnEhCellEvent;
- function GetOnDropDownBoxGetCellParams: TGetCellEhParamsEvent;
- function GetOnDropDownBoxSortMarkingChanged: TNotifyEvent;
- function GetOnDropDownBoxTitleBtnClick: TTitleEhClickEvent;
- function GetPickList: TStrings;
- function GetReadOnly: Boolean;
- function GetShowImageAndText: Boolean;
- function GetToolTips: Boolean;
- function GetWidth: Integer;
- function IsAlignmentStored: Boolean;
- function IsAlwaysShowEditButtonStored: Boolean;
- function IsAutoDropDownStored: Boolean;
- function IsBiDiModeStored: Boolean;
- function IsCheckboxesStored: Boolean;
- function IsColorStored: Boolean;
- function IsDblClickNextValStored: Boolean;
- function IsDropDownShowTitlesStored: Boolean;
- function IsDropDownSizingStored: Boolean;
- function IsEndEllipsisStored: Boolean;
- function IsFontStored: Boolean;
- function IsImeModeStored: Boolean;
- function IsImeNameStored: Boolean;
- function IsIncrementStored: Boolean;
- function IsReadOnlyStored: Boolean;
- function IsToolTipsStored: Boolean;
- function IsWidthStored: Boolean;
- procedure EditButtonChanged(Sender: TObject);
- procedure ImageListChange(Sender: TObject);
- procedure FontChanged(Sender: TObject);
- procedure SetBiDiMode(Value: TBiDiMode);
- procedure SetButtonStyle(Value: TColumnButtonStyleEh);
- procedure SetCheckboxes(const Value: Boolean);
- procedure SetCheckboxState(const Value: TCheckBoxState);
- procedure SetColor(Value: TColor);
- procedure SetDblClickNextVal(const Value: Boolean);
- procedure SetDisplayFormat(const Value: string);
- procedure SetDropDownBox(const Value: TColumnDropDownBoxEh);
- procedure SetDropDownShowTitles(const Value: Boolean);
- procedure SetDropDownSizing(const Value: Boolean);
- procedure SetDropDownSpecRow(const Value: TSpecRowEh);
- procedure SetEditButtons(const Value: TEditButtonsEh);
- procedure SetEditMask(const Value: string);
- procedure SetFieldName(const Value: string);
- procedure SetFont(Value: TFont);
- procedure SetFooter(const Value: TColumnFooterEh);
- procedure SetFooters(const Value: TColumnFootersEh);
- procedure SetImageList(const Value: TCustomImageList);
- procedure SetKeykList(const Value: TStrings);
- procedure SetLayout(Value: TTextLayout);
- procedure SetMaxWidth(const Value: Integer);
- procedure SetMinWidth(const Value: Integer);
- procedure SetMRUList(const Value: TMRUListEh);
- procedure SetNotInKeyListIndex(const Value: Integer);
- procedure SetOnDropDownBoxCheckButton(const Value: TCheckTitleEhBtnEvent);
- procedure SetOnDropDownBoxDrawColumnCell(const Value: TDrawColumnEhCellEvent);
- procedure SetOnDropDownBoxGetCellParams(const Value: TGetCellEhParamsEvent);
- procedure SetOnDropDownBoxSortMarkingChanged(const Value: TNotifyEvent);
- procedure SetOnDropDownBoxTitleBtnClick(const Value: TTitleEhClickEvent);
- procedure SetOnGetCellParams(const Value: TGetColCellParamsEventEh);
- procedure SetPickList(Value: TStrings);
- procedure SetPopupMenu(Value: TPopupMenu);
- procedure SetShowImageAndText(const Value: Boolean);
- procedure SetSTFilter(const Value: TSTColumnFilterEh);
- procedure SetTitle(Value: TColumnTitleEh);
- procedure SetToolTips(const Value: Boolean);
- procedure SetVisible(const Value: Boolean);
- protected
- FAlwaysShowEditButton: Boolean;
- FAutoDropDown: Boolean;
- FAutoFitColWidth: Boolean;
- FDataList: TCustomDBGridEh;
- FDropDownWidth: Integer;
- FDTListSource: TDataSource;
- FEndEllipsis: Boolean;
- FInitWidth: Integer;
- FLookupDisplayFields: string;
- FWordWrap: Boolean;
- function AllowableWidth(TryWidth: Integer): Integer;
- function CreateEditButtons: TEditButtonsEh; virtual;
- function CreateFooter: TColumnFooterEh; virtual;
- function CreateFooters: TColumnFootersEh; virtual;
- function CreateSTFilter: TSTColumnFilterEh; virtual;
- function CreateTitle: TColumnTitleEh; virtual;
- function DefaultAlwaysShowEditButton: Boolean;
- function DefaultAutoDropDown: Boolean;
- function DefaultDblClickNextVal: Boolean;
- function DefaultDropDownShowTitles: Boolean;
- function DefaultDropDownSizing: Boolean;
- function DefaultEndEllipsis: Boolean;
- function DefaultHighlightRequired: Boolean;
- function DefaultLayout: TTextLayout;
- function DefaultLookupDisplayFields: string;
- function DefaultToolTips: Boolean;
- function DefaultWordWrap: Boolean;
- function GetAutoFitColWidth: Boolean;
- function GetDisplayName: string; override;
- function GetGrid: TCustomDBGridEh;
- function GetLookupDisplayFields: string;
- function GetWordWrap: Boolean;
- function IsHighlightRequiredStored: Boolean;
- function IsLayoutStored: Boolean;
- function IsLookupDisplayFieldsStored: Boolean;
- function IsWordWrapStored: Boolean;
- function SeenPassthrough: Boolean; virtual;
- function UsedLookupDataSet: TDataSet;
- procedure Changed(AllItems: Boolean);
- function FullListDataSet: TDataSet;
- procedure EnsureSumValue;
- procedure RefreshDefaultFont;
- procedure SetAlignment(Value: TAlignment); virtual;
- procedure SetAlwaysShowEditButton(Value: Boolean);
- procedure SetAutoDropDown(Value: Boolean);
- procedure SetAutoFitColWidth(Value: Boolean); virtual;
- procedure SetDropDownWidth(Value: Integer);
- procedure SetEndEllipsis(const Value: Boolean);
- procedure SetField(Value: TField); virtual;
- procedure SetHideDuplicates(Value: Boolean); virtual;
- procedure SetHighlightRequired(Value: Boolean); virtual;
- {$IFDEF EH_LIB_VCL}
- procedure SetImeMode(Value: TImeMode); virtual;
- procedure SetImeName(Value: TImeName); virtual;
- {$ENDIF}
- procedure SetIndex(Value: Integer); override;
- procedure SetLookupDisplayFields(Value: string); virtual;
- procedure SetNextFieldValue(Increment: Extended);
- procedure SetReadOnly(Value: Boolean); virtual;
- procedure SetWidth(Value: Integer); virtual;
- procedure SetWordWrap(Value: Boolean); virtual;
- procedure SpecRowChanged(Sender: TObject); virtual;
- procedure UpdateDataValues(Text: string; Value: Variant; UseText: Boolean);
- property IsStored: Boolean read FStored write FStored default True;
- property FieldValueList: IMemTableDataFieldValueListEh read FFieldValueList write FFieldValueList;
- protected
- { ILookupGridOwner }
- procedure SetDropDownBoxListSource(AListSource: TDataSource);
- procedure ILookupGridOwner.SetListSource = SetDropDownBoxListSource;
- function GetLookupGrid: TCustomDBGridEh;
- function GetOptions: TDBLookupGridEhOptions;
- procedure SetOptions(Value: TDBLookupGridEhOptions);
- {$IFNDEF CIL}
- { IInterface }
- function QueryInterface(const IID: TGUID; out Obj): HResult; virtual; stdcall;
- function _AddRef: Integer; stdcall;
- function _Release: Integer; stdcall;
- {$ENDIF}
- public
- constructor Create(Collection: TCollection); override;
- destructor Destroy; override;
- function CanModify(TryEdit: Boolean): Boolean;
- function DefaultAlignment: TAlignment;
- function DefaultColor: TColor;
- function DefaultFont: TFont;
- {$IFDEF EH_LIB_VCL}
- function DefaultImeMode: TImeMode;
- function DefaultImeName: TImeName;
- {$ENDIF}
- function DefaultReadOnly: Boolean;
- function DefaultWidth: Integer;
- function DisplayText: string;
- function DrawTextBiDiModeFlagsReadingOnly: Longint;
- function UseRightToLeftAlignment: Boolean; virtual;
- function UseRightToLeftReading: Boolean;
- function UseRightToLeftScrollBar: Boolean;
- function EditButtonsWidth: Integer;
- function GetColumnType: TColumnEhType;
- function GetImageIndex: Integer;
- function UsedFooter(Index: Integer): TColumnFooterEh;
- procedure Assign(Source: TPersistent); override;
- procedure DropDown;
- procedure FillColCellParams(ColCellParamsEh: TColCellParamsEh);
- procedure GetColCellParams(EditMode: Boolean; ColCellParamsEh: TColCellParamsEh); virtual;
- procedure OptimizeWidth; virtual;
- procedure RestoreDefaults; virtual;
- property AssignedValues: TColumnEhValues read FAssignedValues;
- property CheckboxState: TCheckBoxState read GetCheckboxState write SetCheckboxState;
- property DataList: TCustomDBGridEh read GetDataList;
- property Field: TField read GetField write SetField;
- property Grid: TCustomDBGridEh read GetGrid;
- public
- property Alignment: TAlignment read GetAlignment write SetAlignment stored IsAlignmentStored;
- property AlwaysShowEditButton: Boolean read GetAlwaysShowEditButton write SetAlwaysShowEditButton stored IsAlwaysShowEditButtonStored;
- property AutoDropDown: Boolean read GetAutoDropDown write SetAutoDropDown stored IsAutoDropDownStored;
- property AutoFitColWidth: Boolean read GetAutoFitColWidth write SetAutoFitColWidth default True;
- property ButtonStyle: TColumnButtonStyleEh read FButtonStyle write SetButtonStyle default cbsAuto;
- property Checkboxes: Boolean read GetCheckboxes write SetCheckboxes stored IsCheckboxesStored;
- property Color: TColor read GetColor write SetColor stored IsColorStored;
- property BiDiMode: TBiDiMode read GetBiDiMode write SetBiDiMode stored IsBiDiModeStored;
- property DblClickNextVal: Boolean read GetDblClickNextVal write SetDblClickNextVal stored IsDblClickNextValStored;
- property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
- property DropDownBox: TColumnDropDownBoxEh read FDropDownBox write SetDropDownBox;
- property DropDownRows: Cardinal read FDropDownRows write FDropDownRows default 7; // obsolete
- property DropDownShowTitles: Boolean read GetDropDownShowTitles write SetDropDownShowTitles stored IsDropDownShowTitlesStored;
- property DropDownSizing: Boolean read GetDropDownSizing write SetDropDownSizing stored IsDropDownSizingStored;
- property DropDownSpecRow: TSpecRowEh read FDropDownSpecRow write SetDropDownSpecRow;
- property DropDownWidth: Integer read FDropDownWidth write SetDropDownWidth default 0;
- property EditButtons: TEditButtonsEh read FEditButtons write SetEditButtons;
- property EditMask: string read FEditMask write SetEditMask;
- property EndEllipsis: Boolean read GetEndEllipsis write SetEndEllipsis stored IsEndEllipsisStored;
- property FieldName: string read FFieldName write SetFieldName;
- property Font: TFont read GetFont write SetFont stored IsFontStored;
- property Footer: TColumnFooterEh read FFooter write SetFooter;
- property Footers: TColumnFootersEh read FFooters write SetFooters;
- property HideDuplicates: Boolean read FHideDuplicates write SetHideDuplicates default False;
- property HighlightRequired: Boolean read GetHighlightRequired write SetHighlightRequired stored IsHighlightRequiredStored;
- property ImageList: TCustomImageList read FImageList write SetImageList;
- {$IFDEF EH_LIB_VCL}
- property ImeMode: TImeMode read GetImeMode write SetImeMode stored IsImeModeStored;
- property ImeName: TImeName read GetImeName write SetImeName stored IsImeNameStored;
- {$ENDIF}
- property Increment: Extended read FIncrement write FIncrement stored IsIncrementStored;
- property KeyList: TStrings read GetKeykList write SetKeykList;
- property LookupDisplayFields: string read GetLookupDisplayFields write SetLookupDisplayFields stored IsLookupDisplayFieldsStored;
- property Layout: TTextLayout read GetLayout write SetLayout stored IsLayoutStored;
- property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 0;
- property MinWidth: Integer read FMinWidth write SetMinWidth default 0;
- property MRUList: TMRUListEh read FMRUList write SetMRUList;
- property NotInKeyListIndex: Integer read FNotInKeyListIndex write SetNotInKeyListIndex default -1;
- property PickList: TStrings read GetPickList write SetPickList;
- property PopupMenu: TPopupMenu read FPopupMenu write SetPopupMenu;
- property ReadOnly: Boolean read GetReadOnly write SetReadOnly stored IsReadOnlyStored;
- property STFilter: TSTColumnFilterEh read FSTFilter write SetSTFilter;
- property ShowImageAndText: Boolean read GetShowImageAndText write SetShowImageAndText default False;
- property Tag: Longint read FTag write FTag default 0;
- property Title: TColumnTitleEh read FTitle write SetTitle;
- property ToolTips: Boolean read GetToolTips write SetToolTips stored IsToolTipsStored;
- property Visible: Boolean read FVisible write SetVisible default True;
- property Width: Integer read GetWidth write SetWidth stored IsWidthStored;
- property WordWrap: Boolean read GetWordWrap write SetWordWrap stored IsWordWrapStored;
- property OnCheckDrawRequiredState: TOnColumnCheckDrawRequiredStateEventEh read FOnCheckDrawRequiredState write FOnCheckDrawRequiredState;
- property OnDropDownBoxCheckButton: TCheckTitleEhBtnEvent
- read GetOnDropDownBoxCheckButton write SetOnDropDownBoxCheckButton;
- property OnDropDownBoxDrawColumnCell: TDrawColumnEhCellEvent
- read GetOnDropDownBoxDrawColumnCell write SetOnDropDownBoxDrawColumnCell;
- property OnDropDownBoxGetCellParams: TGetCellEhParamsEvent
- read GetOnDropDownBoxGetCellParams write SetOnDropDownBoxGetCellParams;
- property OnDropDownBoxSortMarkingChanged: TNotifyEvent
- read GetOnDropDownBoxSortMarkingChanged write SetOnDropDownBoxSortMarkingChanged;
- property OnDropDownBoxTitleBtnClick: TTitleEhClickEvent
- read GetOnDropDownBoxTitleBtnClick write SetOnDropDownBoxTitleBtnClick;
- property OnEditButtonClick: TButtonClickEventEh read FOnButtonClick write FOnButtonClick;
- property OnEditButtonDown: TButtonDownEventEh read FOnButtonDown write FOnButtonDown;
- property OnGetCellParams: TGetColCellParamsEventEh read FOnGetCellParams write SetOnGetCellParams;
- // property OnGetItemImageIndex: TListGetImageIndexEventEh read FOnGetItemImageIndex write FOnGetItemImageIndex;
- property OnNotInList: TNotInListEventEh read FOnNotInList write FOnNotInList;
- property OnUpdateData: TColCellUpdateDataEventEh read FUpdateData write FUpdateData;
- end;
- TColumnEhClass = class of TColumnEh;
- TDBGridColumnEh = class(TColumnEh)
- published
- property Alignment;
- property AlwaysShowEditButton;
- property AutoDropDown;
- property AutoFitColWidth;
- property BiDiMode;
- property ButtonStyle;
- property Checkboxes;
- property Color;
- property DblClickNextVal;
- property DisplayFormat;
- property DropDownBox;
- property DropDownRows;
- property DropDownShowTitles;
- property DropDownSizing;
- property DropDownSpecRow;
- property DropDownWidth;
- property EditButtons;
- property EditMask;
- property EndEllipsis;
- property FieldName;
- property Font;
- property Footer;
- property Footers;
- property HideDuplicates;
- property HighlightRequired;
- property ImageList;
- {$IFDEF EH_LIB_VCL}
- property ImeMode;
- property ImeName;
- {$ENDIF}
- property Increment;
- property KeyList;
- property Layout;
- property LookupDisplayFields;
- property MaxWidth;
- property MinWidth;
- property MRUList;
- property NotInKeyListIndex;
- property PickList;
- property PopupMenu;
- property ReadOnly;
- property ShowImageAndText;
- property STFilter;
- property Tag;
- property Title;
- property ToolTips;
- property Visible;
- property Width;
- property WordWrap;
- property OnCheckDrawRequiredState;
- property OnDropDownBoxCheckButton;
- property OnDropDownBoxDrawColumnCell;
- property OnDropDownBoxGetCellParams;
- property OnDropDownBoxSortMarkingChanged;
- property OnDropDownBoxTitleBtnClick;
- property OnEditButtonClick;
- property OnEditButtonDown;
- property OnGetCellParams;
- // property OnGetItemImageIndex;
- property OnNotInList;
- property OnUpdateData;
- end;
- { TDBGridColumnsEh }
- TDBGridColumnsEh = class(TCollection)
- private
- FGrid: TCustomDBGridEh;
- function GetColumn(Index: Integer): TColumnEh;
- function GetState: TDBGridColumnsState;
- function InternalAdd: TColumnEh;
- procedure SetColumn(Index: Integer; Value: TColumnEh);
- procedure SetState(NewState: TDBGridColumnsState);
- protected
- function GetUpdateCount: Integer;
- protected
- function GetOwner: TPersistent; override;
- procedure Update(Item: TCollectionItem); override;
- property UpdateCount: Integer read GetUpdateCount;
- public
- constructor Create(Grid: TCustomDBGridEh; ColumnClass: TColumnEhClass);
- function Add: TColumnEh;
- function ExistFooterValueType(AFooterValueType: TFooterValueType): Boolean;
- procedure AddAllColumns(DeleteExisting: Boolean);
- procedure ActiveChanged;
- procedure LoadFromFile(const Filename: string);
- procedure LoadFromStream(S: TStream);
- procedure RebuildColumns;
- procedure RestoreDefaults;
- procedure SaveToFile(const Filename: string);
- procedure SaveToStream(S: TStream);
- property Grid: TCustomDBGridEh read FGrid;
- property Items[Index: Integer]: TColumnEh read GetColumn write SetColumn; default;
- property State: TDBGridColumnsState read GetState write SetState;
- end;
- { TColumnsEhList }
- 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. }
- (* 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. }
- 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;
- TGetBtnEhParamsEvent = procedure(Sender: TObject; Column: TColumnEh;
- AFont: TFont; var Background: TColor; var SortMarker: TSortMarkerEh;
- IsDown: Boolean) of object;
- (*
- { Internal grid types }
- TGridAxisDrawInfoEh = record
- EffectiveLineWidth: Integer;
- FirstGridCell: Integer;
- FixedBoundary: Integer;
- FixedCellCount: Integer;
- FooterExtent: Integer;
- FrozenExtent: Integer;
- FullVisBoundary: Integer;
- GetExtent: TGetExtentsFunc;
- GridBoundary: Integer;
- GridCellCount: Integer;
- GridExtent: Integer;
- LastFullVisibleCell: Longint;
- end;
- TGridDrawInfoEh = record
- Horz, Vert: TGridAxisDrawInfoEh;
- end;
- *)
- TCustomDBGridEh = class(TCustomGridEh, IInplaceEditHolderEh{$IFNDEF CIL}, IUnknown{$ENDIF})
- private
- FAllowedOperations: TDBGridEhAllowedOperations;
- FAllowedSelections: TDBGridEhAllowedSelections;
- FAutoDrag, FSelectedCellPressed: Boolean;
- FBookmarks: TBookmarkListEh;
- FCanvasHandleAllocated: Boolean;
- FColumnDefValues: TColumnDefValuesEh;
- FColumns: TDBGridColumnsEh;
- FCompleteKeyPress: string;
- FDataLink: TGridDataLinkEh;
- FDefaultDrawing: Boolean;
- FEditActions: TDBGridEhEditActions;
- FEditKeyValue: Variant; // For lookup fields and KeyList based column
- FEditText: string;
- //gridseh FFlat: Boolean;
- FFooterColor: TColor;
- FFooterFont: TFont;
- FHintFont: TFont;
- FHorzScrollBar: TDBGridEhScrollBar;
- FInColExit: Boolean;
- FInterlinear: Integer;
- FLayoutFromDataset: Boolean;
- FLayoutLock: Byte;
- FOnCellClick: TDBGridEhClickEvent;
- FOnColEnter: TNotifyEvent;
- FOnColExit: TNotifyEvent;
- FOnColumnMoved: TMovedEvent;
- FOnColWidthsChanged: TNotifyEvent;
- FOnDrawColumnCell: TDrawColumnEhCellEvent;
- FOnDrawDataCell: TDrawDataCellEvent;
- FOnEditButtonClick: TNotifyEvent;
- FOnGetCellParams: TGetCellEhParamsEvent;
- FOnGetFooterParams: TGetFooterParamsEvent;
- FOnSelectionChanged: TNotifyEvent;
- FOnSortMarkingChanged: TNotifyEvent;
- FOnSumListAfterRecalcAll: TNotifyEvent;
- FOnSumListRecalcAll: TNotifyEvent;
- FOnTitleClick: TDBGridEhClickEvent;
- FOptions: TDBGridOptions;
- FOptionsEh: TDBGridEhOptions;
- {$IFDEF EH_LIB_VCL}
- FOriginalImeMode: TImeMode;
- FOriginalImeName: TImeName;
- {$ENDIF}
- FReadOnly: Boolean;
- FSelecting: Boolean;
- FSelection: TDBGridEhSelection;
- FSelectionAnchor: TBookmarkStr;
- FSelfChangingFooterFont: Boolean;
- FSelfChangingTitleFont: Boolean;
- FSelRow: Integer;
- FSizingIndex: Longint;
- FSizingPos, FSizingOfs: Integer;
- FSortLocal: Boolean;
- FSortMarking: Boolean;
- FStyle: TDBGridEhStyle;
- FSumListRecalcing: Boolean;
- FThumbTracked: Boolean;
- FTitleFont: TFont;
- FTitleImages: TCustomImageList;
- FTitleImageChangeLink: TChangeLink;
- FTitleOffset: Byte;
- FIndicatorOffset: Byte;
- FTopDataOffset: Byte;
- FTopLeftVisible: Boolean;
- FUpdateLock: Byte;
- FUserChange: Boolean;
- FVertScrollBar: TDBGridEhScrollBar;
- FIntMemTable: IMemTableEh;
- FOldActiveRecord: Integer;
- FLockAutoShowCurCell: Boolean;
- FFetchingRecords: Boolean;
- FTryUseMemTableInt: Boolean;
- FSTFilter: TSTDBGridEhFilter;
- FFilterCol: Integer;
- FFilterEditMode: Boolean;
- FFilterEdit: TCustomDBEditEh;
- FOnApplyFilter: TNotifyEvent;
- FDownMouseMessageTime: LongInt;
- FBufferedPaint: Boolean;
- FSizeChanged: Boolean;
- FEvenRowColorStored: Boolean;
- FOddRowColorStored: Boolean;
- FEvenRowColor: TColor;
- FOddRowColor: TColor;
- FContraColCount: Integer;
- procedure CheckIMemTable;
- procedure MTUpdateRowCount;
- procedure MTScroll(Distance: Integer);
- function IsCurrentRow(DataRowNum: Integer): Boolean;
- procedure FetchRecordsInView;
- procedure InstantReadRecordEnter(DataRowNum: Integer);
- procedure InstantReadRecordLeave;
- function InstantReadRecordCount: Integer;
- procedure MTUpdateVertScrollBar;
- procedure MTUpdateTopRow;
- procedure MTWMVScroll(var Message: TWMVScroll);
- function GetCol: Longint;
- function GetContraColCount: Longint;
- function GetDataSource: TDataSource;
- function GetEvenRowColor: TColor;
- function GetFieldColumns(const FieldName: string): TColumnEh;
- function GetFieldCount: Integer;
- function GetFields(FieldIndex: Integer): TField;
- function GetOddRowColor: TColor;
- // function GetRowHeights(Index: Longint): Integer;
- function GetSelectedField: TField;
- function GetSelectedIndex: Integer;
- function GetTopDataOffset: Byte;
- // function IsActiveControl: Boolean;
- function IsEvenRowColorStored: Boolean;
- function IsOddRowColorStored: Boolean;
- // procedure CalcDrawInfoXYEh(var DrawInfo: TGridDrawInfoEh; UseWidth, UseHeight: Integer);
- procedure ChangeGridOrientation(RightToLeftOrientation: Boolean);
- procedure ClearSelection;
- {$IFDEF EH_LIB_VCL}
- procedure CMCancelMode(var Message: TCMCancelMode); message CM_CancelMode;
- procedure CMDeferLayout(var Message: TMessage); message cm_DeferLayout;
- procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;
- procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
- procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
- procedure CMHintsShowPause(var Message: TCMHintShowPause); message CM_HINTSHOWPAUSE;
- procedure CMMouseWheel(var Message: TCMMouseWheel); message CM_MOUSEWHEEL;
- procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
- procedure CMParentFontChanged(var Message: TCMParentFontChanged); message CM_PARENTFONTCHANGED;
- procedure CMSysColorChange(var Message: TMessage); message CM_SYSCOLORCHANGE;
- {$ENDIF}
- procedure DoSelection(Select: Boolean; Direction: Integer; MaxDirection, RowOnly: Boolean);
- procedure DrawEdgeEh(ACanvas: TCanvas; qrc: TRect; IsDown, IsSelected: Boolean; NeedLeft, NeedRight: Boolean);
- procedure EditingChanged;
- procedure FooterFontChanged(Sender: TObject);
- procedure InternalLayout;
- procedure MoveCol(RawCol, Direction: Integer; Select: Boolean);
- procedure ReadColumns(Reader: TReader);
- procedure RecordChanged(Field: TField);
- procedure SetAllowedSelections(const Value: TDBGridEhAllowedSelections);
- procedure SetCol(Value: Longint);
- procedure SetColumnDefValues(const Value: TColumnDefValuesEh);
- procedure SetColumns(Value: TDBGridColumnsEh);
- procedure SetContraColCount(const Value: Longint);
- procedure SetDataSource(Value: TDataSource);
- procedure SetDrawMemoText(const Value: Boolean);
- procedure SetEvenRowColor(const Value: TColor);
- procedure SetFilterEditMode(const Value: Boolean);
- //gridseh procedure SetFlat(const Value: Boolean);
- procedure SetFooterColor(Value: TColor);
- procedure SetFooterFont(Value: TFont);
- procedure SetHorzScrollBar(const Value: TDBGridEhScrollBar);
- procedure SetIme;
- procedure SetOddRowColor(const Value: TColor);
- procedure SetOptions(Value: TDBGridOptions);
- procedure SetOptionsEh(const Value: TDBGridEhOptions);
- procedure SetReadOnly(const Value: Boolean);
- procedure SetSelectedField(Value: TField);
- procedure SetSelectedIndex(Value: Integer);
- procedure SetSTFilter(const Value: TSTDBGridEhFilter);
- procedure SetStyle(const Value: TDBGridEhStyle);
- procedure SetSumList(const Value: TDBGridEhSumList);
- procedure SetTitleFont(Value: TFont);
- procedure SetTitleImages(const Value: TCustomImageList);
- procedure SetVertScrollBar(const Value: TDBGridEhScrollBar);
- procedure TitleFontChanged(Sender: TObject);
- procedure TitleImageListChange(Sender: TObject);
- procedure UpdateData;
- procedure UpdateIme;
- {$IFDEF EH_LIB_VCL}
- procedure WMCancelMode(var Message: TWMCancelMode); message WM_CANCELMODE;
- procedure WMChar(var Message: TWMChar); message WM_CHAR;
- procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
- procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND; //tmp
- procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
- procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
- procedure WMIMEStartComp(var Message: TMessage); message WM_IME_STARTCOMPOSITION;
- procedure WMKillFocus(var Message: TWMKillFocus); message WM_KillFocus;
- procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
- procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
- procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
- procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
- procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
- procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;
- procedure WMSetFocus(var Message: TWMSetFocus); message WM_SetFOCUS;
- procedure WMSize(var Message: TWMSize); message WM_SIZE;
- procedure WMTimer(var Message: TWMTimer); message WM_TIMER;
- procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
- /// 赖-2008-01-18 加入对 Ctrl+C 的处理
- procedure WMKeyDown(var vMsg: TWMKeyDown); message WM_KEYDOWN;
- {$ENDIF}
- procedure WriteColumns(Writer: TWriter);
- procedure PaintInplaceButton(Column: TColumnEh; Canvas: TCanvas;
- ButtonStyle: TEditButtonStyleEh; Rect, ClipRect: TRect;
- DownButton: Integer; Active, Flat, Enabled: Boolean;
- ParentColor: TColor; Bitmap: TBitmap);
- protected
- { IInplaceEditHolderEh }
- function InplaceEditCanModify(Control: TWinControl): Boolean;
- procedure GetMouseDownInfo(var Pos: TPoint; var Time: LongInt);
- procedure InplaceEditKeyDown(Control: TWinControl; var Key: Word; Shift: TShiftState);
- procedure InplaceEditKeyPress(Control: TWinControl; var Key: Char);
- procedure InplaceEditKeyUp(Control: TWinControl; var Key: Word; Shift: TShiftState);
- procedure InplaceEditWndProc(Control: TWinControl; var Message: TMessage);
- protected
- // FSortMarkerImages: TImageList;
- FAcquireFocus: Boolean;
- FAllowWordWrap: Boolean; // True if RowHeight + 3 > TextHeight
- FAntiSelection: Boolean;
- FAutoFitColWidths: Boolean;
- FBorderWidth: Integer;
- FColCellParamsEh: TColCellParamsEh;
- FDataTracking: Boolean;
- FDBGridEhState: TDBGridEhState;
- FDefaultRowChanged: Boolean;
- FDownMousePos: TPoint;
- FDrawMemoText: Boolean;
- FFooterRowCount: Integer;
- FFrozenCols: Integer;
- FHeadTree: THeadTreeNode;
- FHTitleMargin: Integer;
- FIndicatorPressed: Boolean;
- FInplaceEditorButtonHeight: Integer;
- FInplaceEditorButtonWidth: Integer;
- FInplaceSearching: Boolean;
- FInplaceSearchingInProcess: Boolean;
- FInplaceSearchText: string;
- FInplaceSearchTimeOut: Integer;
- FInplaceSearchTimerActive: Boolean;
- FLeafFieldArr: PTLeafCol;
- FLockedBookmark: TBookmarkStr;
- // FLockPaint: Boolean;
- FLookedOffset: Integer;
- FMinAutoFitWidth: Integer;
- FMouseShift: TShiftState;
- FMoveMousePos: TPoint;
- FNewRowHeight: Integer;
- FOnCheckButton: TCheckTitleEhBtnEvent;
- FOnDrawFooterCell: TDrawFooterCellEvent;
- FOnGetBtnParams: TGetBtnEhParamsEvent;
- FOnMoveRecords: TGridMoveRecordsEventEh;
- FOnTitleBtnClick: TTitleEhClickEvent;
- FOnTopLeftChanged: TNotifyEvent;
- FPressed: Boolean;
- FPressedCell: TGridCoord;
- FPressedCol: Longint;
- FRowLines: Integer;
- FRowSizingAllowed: Boolean;
- FSelectionActive: Boolean;
- FSelectionAnchorSelected: Boolean;
- FSortMarkedColumns: TColumnsEhList;
- FSumList: TDBGridEhSumList;
- FSwapButtons: Boolean;
- FTimerActive: Boolean;
- FTimerInterval: Integer;
- FTitleHeight: Integer;
- FTitleHeightFull: Integer;
- FTitleLines: Integer;
- FTracking: Boolean;
- FUpdateFields: Boolean;
- FUseMultiTitle: Boolean;
- FVertScrollBarVisibleMode: TScrollBarVisibleModeEh;
- FVisibleColumns: TColumnsEhList;
- FVTitleMargin: Integer;
- FMoveRowSour: Integer; //Index
- FMoveBookmarkSour: string;
- FMoveRowDest: Integer; //Pos
- FMoveRowSourLevel: Integer;
- FMoveRowDestLevel: Integer;
- FMoveRowLeftBounds: Integer;
- FDataRowMoveLeftBoundary: Integer;
- FDataRowMoveRightBoundary: Integer;
- FDataRowMoveVisible: Boolean;
- function AcquireFocus: Boolean; virtual;
- function AcquireLayoutLock: Boolean;
- function AllowedOperationUpdate: Boolean;
- function BeginDataRowDrag(var Origin, Destination: Integer; const MousePt: TPoint): Boolean; virtual;
- function BoxRect(ALeft, ATop, ARight, ABottom: Longint): TRect;
- function CalcLeftMoveLine(ARow: Integer; const MousePt: TPoint; var TreeLevel: Integer): Integer; virtual;
- function CanDrawFocusRowRect: Boolean; virtual;
- function CanEditAcceptKey(Key: Char): Boolean; override;
- function CanEditModify: Boolean; override;
- function CanEditModifyColumn(Index: Integer): Boolean;
- function CanEditModifyText: Boolean;
- function CanEditorMode: Boolean; virtual;
- function CanEditShow: Boolean; override;
- function CanFilterCol(DCol: Longint): Boolean;
- function CanFilterEditShow: Boolean; virtual;
- function CanSelectType(const Value: TDBGridEhSelectionType): Boolean;
- function CellHave3DRect(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState): Boolean; virtual;
- function CellIsMultiSelected(ACol, ARow: Integer; DataCol: Integer; DataRowBkmrk: TBookmarkStr): Boolean; virtual;
- function CellTreeElementMouseDown(MouseX, MouseY: Integer; CheckInOnly: Boolean): Boolean; virtual;
- function CheckBeginRowMoving(MouseX, MouseY: Integer; CheckInOnly: Boolean): Boolean; virtual;
- function CheckCellFilter(ACol, ARow: Integer; P: TPoint): Boolean;
- function CreateColumnDefValues: TColumnDefValuesEh; dynamic;
- function CreateColumns: TDBGridColumnsEh; dynamic;
- function CreateEditor: TInplaceEdit; override;
- function CreateFilterEditor: TCustomDBEditEh; virtual;
- function CreateScrollBar(AKind: TScrollBarKind): TDBGridEhScrollBar; dynamic;
- function DataToRawColumn(ACol: Integer): Integer;
- {$IFDEF EH_LIB_VCL}
- function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
- function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
- {$ENDIF}
- function DrawTitleByThemes: Boolean;
- function FrozenSizing(X, Y: Integer): Boolean;
- function GetCellType(ACol, ARow: Integer; var DataCol, DataRow: Integer): TCellTypeEh;
- function GetColField(DataCol: Integer): TField;
- function GetColWidths(Index: Longint): Integer;
- function GetEditLimit: Integer; override;
- {$IFDEF EH_LIB_VCL}
- function GetEditMask(ACol, ARow: Longint): string; override;
- function GetEditText(ACol, ARow: Longint): string; override;
- {$ENDIF}
- function GetFieldValue(ACol: Integer): string;
- function GetFilterValue(DCol: Longint): string;
- function GetFooterRowCount: Integer;
- function GetRowHeight: Integer;
- function GetRowLines: Integer;
- function GetSubTitleRowHeights(ASubTitleRow: Integer): Integer;
- function GetSubTitleRows: Integer; virtual;
- function GetTitleRows: Integer; virtual;
- function HaveHideDuplicates: Boolean;
- function HighlightNoDataCellColor(ACol, ARow: Integer; DataCol, DataRow: Integer;
- CellType: TCellTypeEh; AState: TGridDrawState; InMultiSelect: Boolean; var AColor: TColor;
- AFont: TFont): Boolean; virtual;
- function HighlightDataCellColor(DataCol, DataRow: Integer; const Value: string;
- AState: TGridDrawState; var AColor: TColor; AFont: TFont): Boolean; virtual;
- function InplaceEditorVisible: Boolean;
- function IsSelectionActive: Boolean; virtual;
- function MemTableSupport: Boolean;
- function MoveDataRows(BookmarkList: TStrings; ToIndex: Longint;
- TreeLevel: Integer; CheckOnly: Boolean): Boolean; virtual;
- function MoveSelectedDataRows(ToIndex: Longint; TreeLevel: Integer;
- CheckOnly: Boolean): Boolean; virtual;
- function NeedBufferedPaint: Boolean; virtual;
- function ViewScroll: Boolean;
- function RawToDataColumn(ACol: Integer): Integer;
- function ReadTitleHeight: Integer;
- function ReadTitleLines: Integer;
- function SafeMoveTop(ATop: Integer; CheckOnly: Boolean = False): Integer;
- function SetChildTreeHeight(ANode: THeadTreeNode): Integer;
- function StdDefaultRowHeight: Integer;
- function StoreColumns: Boolean;
- function VisibleDataRowCount: Integer;
- procedure BeginLayout;
- procedure BeginUpdate;
- // procedure CalcDrawInfoEh(var DrawInfo: TGridDrawInfoEh);
- // procedure CalcFixedInfoEh(var DrawInfo: TGridDrawInfoEh);
- procedure CalcFrozenSizingState(X, Y: Integer; var State: TDBGridEhState;
- var Index: Longint; var SizingPos, SizingOfs: Integer);
- procedure CalcSizingState(X, Y: Integer; var State: TGridState;
- var Index: Longint; var SizingPos, SizingOfs: Integer;
- var FixedInfo: TGridDrawInfoEh); override;
- procedure CancelLayout;
- procedure CellClick(Column: TColumnEh); dynamic;
- {$IFDEF EH_LIB_VCL}
- procedure ChangeScale(M, D: Integer); override;
- {$ENDIF}
- procedure CheckTitleButton(ACol: Longint; var Enabled: Boolean); dynamic;
- procedure ClearPainted(node: THeadTreeNode);
- procedure ColEnter; dynamic;
- procedure ColExit; dynamic;
- procedure ColumnMoved(FromIndex, ToIndex: Longint); override;
- procedure ColWidthsChanged; override;
- {$IFDEF EH_LIB_VCL}
- procedure CreateParams(var Params: TCreateParams); override;
- procedure CreateWnd; override;
- {$ENDIF}
- procedure DataChanged; virtual;
- procedure DeferLayout;
- procedure DefineFieldMap; virtual;
- procedure DefineProperties(Filer: TFiler); override;
- procedure DoExit; override;
- procedure DoAfterSizeChanged; virtual;
- procedure DoSortMarkingChanged; dynamic;
- procedure DoTitleClick(ACol: Longint; AColumn: TColumnEh); dynamic;
- procedure DrawBorder; virtual;
- procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
- procedure DrawCellTreeArea(DataCol, DataRow: Integer; AState: TGridDrawState; ARect: TRect; Draw3DRect: Boolean); virtual;
- procedure DrawDataRowMove(LeftBoundary, RightBoundary: Integer);
- procedure DrawTreeArea(Canvas: TCanvas; ARect: TRect; IsDrawEdge: Boolean);
- procedure DrawColumnCell(const Rect: TRect; DataCol: Integer;
- Column: TColumnEh; State: TGridDrawState); dynamic;
- procedure DrawDataCell(const Rect: TRect; Field: TField; State: TGridDrawState); dynamic; { obsolete }
- procedure DrawSubTitleCell(ACol, ARow: Longint; DataCol, DataRow: Integer;
- CellType: TCellTypeEh; ARect: TRect; AState: TGridDrawState; var Highlighted: Boolean); virtual;
- procedure DrawSizingLine(HorzGridBoundary, VertGridBoundary: Integer);
- procedure EditButtonClick; dynamic;
- procedure EndLayout;
- procedure EndRowMoving(MouseX, MouseY: Integer; Accept: Boolean); virtual;
- procedure EndUpdate;
- procedure ExecuteFindDialog(Text, FieldName: string; Modal: Boolean);
- procedure FilterButtonClick(Sender: TObject; var Handled: Boolean);
- procedure FilterExit(Sender: TObject);
- procedure FlatChanged; override;
- procedure GetCellParams(Column: TColumnEh; AFont: TFont;
- var Background: TColor; State: TGridDrawState); dynamic;
- procedure GetDatasetFieldList(FieldList: TList); virtual;
- procedure GetFooterParams(DataCol, Row: Longint; Column: TColumnEh; AFont: TFont;
- var Background: TColor; var Alignment: TAlignment; State: TGridDrawState; var Text: string); dynamic;
- procedure HideFilterEdit;
- procedure HideDataRowMove;
- procedure InvalidateCol(ACol: Longint);
- procedure InvalidateRow(ARow: Longint);
- procedure InvalidateCell(ACol, ARow: Longint);
- procedure InvalidateEditor;
- procedure InvalidateGridRect(ARect: TGridRect);
- procedure KeyDown(var Key: Word; Shift: TShiftState); override;
- procedure KeyPress(var Key: Char); override;
- procedure KeyUp(var Key: Word; Shift: TShiftState); override;
- procedure LayoutChanged; virtual;
- procedure LinkActive(Value: Boolean); virtual;
- procedure Loaded; 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;
- procedure MoveDataRowAndScroll(Mouse, CellHit: Integer; var DrawInfo: TGridDrawInfoEh; var Axis: TGridAxisDrawInfoEh; ScrollBar: Integer; const MousePt: TPoint); virtual;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure OnFilterChange(Sender: TObject);
- procedure OnFilterCloseUp(Sender: TObject; Accept: Boolean);
- procedure OnFilterClosingUp(Sender: TObject; var Accept: Boolean);
- procedure OnFilterEditButtonClick(Sender: TObject; var Handled: Boolean);
- procedure OnFilterGetItemsList(Sender: TObject);
- procedure OnFilterKeyPress(Sender: TObject; var Key: Char);
- procedure OptimizeColsWidth(ColumnsList: TColumnsEhList);
- procedure OptimizeSelectedColsWidth(WithColumn: TColumnEh);
- procedure Paint; override;
- {$IFDEF EH_LIB_VCL}
- procedure PaintButtonControl(DC: HDC; ARect: TRect; ParentColor: TColor;
- Style: TDrawButtonControlStyleEh; DownButton: Integer;
- Flat, Active, Enabled: Boolean; State: TCheckBoxState);
- {$ENDIF}
- // procedure RecreateInplaceSearchIndicator;
- procedure RegetDefaultStyle;
- procedure ResetTimer(Interval: Integer);
- procedure RestoreColumnsLayoutProducer(ARegIni: TObject; Section: string;
- RestoreParams: TColumnEhRestoreParams);
- procedure RestoreGridLayoutProducer(ARegIni: TObject; Section: string;
- RestoreParams: TDBGridEhRestoreParams);
- procedure RowHeightsChanged; override;
- procedure SaveColumnsLayoutProducer(ARegIni: TObject; Section: string; DeleteSection: Boolean);
- procedure SaveGridLayoutProducer(ARegIni: TObject; Section: string; DeleteSection: Boolean);
- procedure Scroll(Distance: Integer); virtual;
- procedure SelectionActiveChanged; virtual;
- procedure SetColumnAttributes; virtual;
- procedure SetColWidths(Index: Longint; Value: Integer);
- {$IFDEF EH_LIB_VCL}
- procedure SetEditText(ACol, ARow: Longint; const Value: string); override;
- {$ENDIF}
- procedure SetDataFilter;
- procedure SetFilterValue(DCol: Longint); virtual;
- procedure SetFooterRowCount(Value: Integer);
- procedure SetFrozenCols(Value: Integer);
- procedure SetRowHeight(Value: Integer);
- procedure SetRowLines(Value: Integer);
- procedure SetRowSizingAllowed(Value: Boolean);
- procedure ShowEditor; virtual;
- procedure ShowFilterEditorChar(Ch: Char);
- procedure StartEditFilter(DCol: Longint);
- procedure StartInplaceSearchTimer;
- procedure StopEditFilter;
- procedure StopInplaceSearchTimer;
- procedure StopTimer;
- procedure StopTracking;
- procedure StyleEhChanged;
- procedure SumListAfterRecalcAll(Sender: TObject);
- procedure SumListChanged(Sender: TObject);
- procedure SumListRecalcAll(Sender: TObject);
- procedure TimedScroll(Direction: TGridScrollDirection); override;
- procedure TimerScroll; virtual;
- procedure TitleClick(Column: TColumnEh); dynamic;
- procedure TopLeftChanged; override;
- procedure TrackButton(X, Y: Integer);
- procedure UpdateActive; virtual;
- procedure UpdateEditorMode;
- procedure UpdateFilterEdit(UpdateData: Boolean);
- procedure UpdateFilterEditProps(DataCol: Longint); virtual;
- procedure UpdateHorzExtScrollBar; virtual;
- procedure UpdateRowCount; virtual;
- procedure UpdateScrollBar; virtual;
- {$IFDEF EH_LIB_VCL}
- procedure WndProc(var Message: TMessage); override;
- {$ENDIF}
- procedure WriteAutoFitColWidths(Value: Boolean);
- procedure WriteCellText(Column: TColumnEh; ACanvas: TCanvas; ARect: TRect;
- FillRect: Boolean; DX, DY: Integer; Text: string; Alignment: TAlignment;
- Layout: TTextLayout; MultyL: Boolean;
- EndEllipsis: Boolean; LeftMarg, RightMarg: Integer);
- procedure WriteHTitleMargin(Value: Integer);
- procedure WriteMinAutoFitWidth(Value: Integer);
- procedure WriteTitleHeight(th: Integer);
- procedure WriteTitleLines(tl: Integer);
- procedure WriteUseMultiTitle(Value: Boolean);
- procedure WriteVTitleMargin(Value: Integer);
- property ColCount;
- property Color;
- property ColWidths;
- property DataLink: TGridDataLinkEh read FDataLink;
- property DefaultColWidth;
- property DefaultDrawing: Boolean read FDefaultDrawing write FDefaultDrawing default True;
- property FilterEdit: TCustomDBEditEh read FFilterEdit;
- property FilterEditMode: Boolean read FFilterEditMode write SetFilterEditMode;
- property FooterColor: TColor read FFooterColor write SetFooterColor;
- property FooterFont: TFont read FFooterFont write SetFooterFont;
- property ImeMode;
- property ImeName;
- property LayoutLock: Byte read FLayoutLock;
- property OnApplyFilter: TNotifyEvent read FOnApplyFilter write FOnApplyFilter;
- property OnCellClick: TDBGridEhClickEvent read FOnCellClick write FOnCellClick;
- property OnColEnter: TNotifyEvent read FOnColEnter write FOnColEnter;
- property OnColExit: TNotifyEvent read FOnColExit write FOnColExit;
- property OnColumnMoved: TMovedEvent read FOnColumnMoved write FOnColumnMoved;
- property OnDrawColumnCell: TDrawColumnEhCellEvent read FOnDrawColumnCell write FOnDrawColumnCell;
- property OnDrawDataCell: TDrawDataCellEvent read FOnDrawDataCell write FOnDrawDataCell; { obsolete }
- property OnEditButtonClick: TNotifyEvent read FOnEditButtonClick write FOnEditButtonClick;
- property OnTitleClick: TDBGridEhClickEvent read FOnTitleClick write FOnTitleClick;
- property ParentColor default False;
- property ReadOnly: Boolean read FReadOnly write SetReadOnly default False;
- property RowCount;
- property RowHeights;
- property SelectedRows: TBookmarkListEh read FBookmarks;
- property STFilter: TSTDBGridEhFilter read FSTFilter write SetSTFilter;
- property TopRow;
- property UpdateLock: Byte read FUpdateLock;
- property ContraColCount: Longint read GetContraColCount write SetContraColCount default 0;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function CellRect(ACol, ARow: Longint): TRect;
- function CheckCopyAction: Boolean;
- function CheckCutAction: Boolean;
- function CheckDeleteAction: Boolean;
- function CheckPasteAction: Boolean;
- function CheckSelectAllAction: Boolean;
- function DataBox: TGridRect;
- function DataRect: TRect;
- function DataRowCount: Integer;
- function DataRowToRecNo(DataRow: Integer): Integer;
- function DefaultMoveDataRows(BookmarkList: TStrings; ToRecNo: Longint;
- TreeLevel: Integer; CheckOnly: Boolean): Boolean; virtual;
- function ExecuteAction(Action: TBasicAction): Boolean; override;
- function LocateText(AGrid: TCustomDBGridEh; const FieldName: string;
- const Text: string; Options: TLocateTextOptionsEh; Direction: TLocateTextDirectionEh;
- Matching: TLocateTextMatchingEh; TreeFindRange: TLocateTextTreeFindRangeEh): Boolean; virtual;
- function GetCellTreeElmentsAreaWidth: Integer;
- function GetCompleteKeyPress: string;
- function GetFooterValue(Row: Integer; Column: TColumnEh): string; virtual;
- function UpdateAction(Action: TBasicAction): Boolean; override;
- function ValidFieldIndex(FieldIndex: Integer): Boolean;
- function IsFindDialogShowAsModal: Boolean; virtual;
- procedure ApplyFilter;
- procedure ClearFilter;
- procedure DefaultDrawColumnCell(const Rect: TRect; DataCol: Integer;
- Column: TColumnEh; State: TGridDrawState);
- procedure DefaultApplyFilter; virtual;
- procedure DefaultApplySorting; virtual;
- procedure DefaultDrawDataCell(const Rect: TRect; Field: TField; State: TGridDrawState); { obsolete }
- procedure DefaultDrawFooterCell(const Rect: TRect; DataCol, Row: Integer;
- Column: TColumnEh; State: TGridDrawState);
- procedure DefaultHandler(var Message); override;
- procedure InvalidateFooter;
- procedure RestoreBookmark;
- procedure RestoreColumnsLayout(ACustIni: TCustomIniFile; Section: string;
- RestoreParams: TColumnEhRestoreParams); overload;
- {$IFDEF EH_LIB_VCL}
- procedure RestoreColumnsLayout(ARegIni: TRegIniFile; RestoreParams: TColumnEhRestoreParams); overload;
- {$ENDIF}
- procedure RestoreColumnsLayoutIni(IniFileName: string; Section: string;
- RestoreParams: TColumnEhRestoreParams);
- procedure RestoreGridLayout(ARegIni: TCustomIniFile; Section: string;
- RestoreParams: TDBGridEhRestoreParams); overload;
- {$IFDEF EH_LIB_VCL}
- procedure RestoreGridLayout(ARegIni: TRegIniFile; RestoreParams: TDBGridEhRestoreParams); overload;
- {$ENDIF}
- procedure RestoreGridLayoutIni(IniFileName: string; Section: string;
- RestoreParams: TDBGridEhRestoreParams);
- procedure SaveBookmark;
- procedure SaveColumnsLayout(ACustIni: TCustomIniFile; Section: string); overload;
- {$IFDEF EH_LIB_VCL}
- procedure SaveColumnsLayout(ARegIni: TRegIniFile); overload;
- {$ENDIF}
- procedure SaveColumnsLayoutIni(IniFileName: string; Section: string; DeleteSection: Boolean);
- procedure SaveGridLayout(ACustIni: TCustomIniFile; Section: string); overload;
- {$IFDEF EH_LIB_VCL}
- procedure SaveGridLayout(ARegIni: TRegIniFile); overload;
- {$ENDIF}
- procedure SaveGridLayoutIni(IniFileName: string; Section: string; DeleteSection: Boolean);
- procedure SetSortMarkedColumns;
- procedure SetValueFromPrevRecord;
- procedure StartInplaceSearch(ss: string; TimeOut: Integer; InpsDirection: TLocateTextDirectionEh);
- procedure StopInplaceSearch;
- property AllowedOperations: TDBGridEhAllowedOperations read FAllowedOperations
- write FAllowedOperations default [alopInsertEh, alopUpdateEh, alopDeleteEh, alopAppendEh];
- property AllowedSelections: TDBGridEhAllowedSelections read FAllowedSelections
- write SetAllowedSelections default [gstRecordBookmarks..gstAll];
- property AutoFitColWidths: Boolean read FAutoFitColWidths
- write WriteAutoFitColWidths default False;
- property BufferedPaint: Boolean read FBufferedPaint write FBufferedPaint;
- property Canvas;
- property Col read GetCol write SetCol;
- property ColumnDefValues: TColumnDefValuesEh read FColumnDefValues write SetColumnDefValues;
- property Columns: TDBGridColumnsEh read FColumns write SetColumns;
- {$IFDEF EH_LIB_VCL}
- property Ctl3D;
- {$ENDIF}
- property DataSource: TDataSource read GetDataSource write SetDataSource;
- property DrawMemoText: Boolean read FDrawMemoText write SetDrawMemoText default false;
- property EvenRowColor: TColor read GetEvenRowColor write SetEvenRowColor stored IsEvenRowColorStored;
- property EditActions: TDBGridEhEditActions read FEditActions write FEditActions default [];
- property EditorMode;
- property FieldColumns[const FieldName: string]: TColumnEh read GetFieldColumns; default;
- property FieldCount: Integer read GetFieldCount;
- property Fields[FieldIndex: Integer]: TField read GetFields;
- property FixedColor;
- //gridseh property Flat: Boolean read FFlat write SetFlat default False;
- property Font;
- property FooterRowCount: Integer read GetFooterRowCount write SetFooterRowCount default 0;
- property FrozenCols: Integer read FFrozenCols write SetFrozenCols default 0;
- property HeadTree: THeadTreeNode read FHeadTree;
- property HorzScrollBar: TDBGridEhScrollBar read FHorzScrollBar write SetHorzScrollBar;
- property IndicatorOffset: Byte read FIndicatorOffset;
- property InplaceEditor;
- property InplaceSearching: Boolean read FInplaceSearching;
- property LeafFieldArr: PTLeafCol read FLeafFieldArr;
- property LeftCol;
- property MinAutoFitWidth: Integer read FMinAutoFitWidth write WriteMinAutoFitWidth default 0;
- property OnCheckButton: TCheckTitleEhBtnEvent read FOnCheckButton write FOnCheckButton;
- property OnColWidthsChanged: TNotifyEvent read FOnColWidthsChanged write FOnColWidthsChanged;
- property OnDrawFooterCell: TDrawFooterCellEvent read FOnDrawFooterCell write FOnDrawFooterCell;
- property OnGetBtnParams: TGetBtnEhParamsEvent read FOnGetBtnParams write FOnGetBtnParams;
- property OnGetCellParams: TGetCellEhParamsEvent read FOnGetCellParams write FOnGetCellParams;
- property OnGetFooterParams: TGetFooterParamsEvent read FOnGetFooterParams write FOnGetFooterParams;
- property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged write FOnSelectionChanged;
- property OnSortMarkingChanged: TNotifyEvent read FOnSortMarkingChanged write FOnSortMarkingChanged;
- property OnSumListAfterRecalcAll: TNotifyEvent read FOnSumListAfterRecalcAll write FOnSumListAfterRecalcAll;
- property OnSumListRecalcAll: TNotifyEvent read FOnSumListRecalcAll write FOnSumListRecalcAll;
- property OnTitleBtnClick: TTitleEhClickEvent read FOnTitleBtnClick write FOnTitleBtnClick;
- property OnTopLeftChanged: TNotifyEvent read FOnTopLeftChanged write FOnTopLeftChanged;
- property OnMoveRecords: TGridMoveRecordsEventEh read FOnMoveRecords write FOnMoveRecords;
- property Options: TDBGridOptions read FOptions write SetOptions
- default [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines,
- dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit];
- property OptionsEh: TDBGridEhOptions read FOptionsEh write SetOptionsEh
- default [dghFixed3D, dghHighlightFocus, dghClearSelection, dghDialogFind];
- property OddRowColor: TColor read GetOddRowColor write SetOddRowColor stored IsOddRowColorStored;
- property Row;
- property RowHeight: Integer read GetRowHeight write SetRowHeight default 0;
- property RowLines: Integer read GetRowLines write SetRowLines default 0;
- property RowSizingAllowed: Boolean read FRowSizingAllowed write SetRowSizingAllowed default False;
- property SelectedField: TField read GetSelectedField write SetSelectedField;
- property SelectedIndex: Integer read GetSelectedIndex write SetSelectedIndex;
- property Selection: TDBGridEhSelection read FSelection;
- property SortLocal: Boolean read FSortLocal write FSortLocal default False;
- property SortMarkedColumns: TColumnsEhList read FSortMarkedColumns write FSortMarkedColumns;
- property Style: TDBGridEhStyle read FStyle write SetStyle;
- property SumList: TDBGridEhSumList read FSumList write SetSumList;
- property TimerActive: Boolean read FTimerActive;
- property TitleFont: TFont read FTitleFont write SetTitleFont;
- property TitleHeight: Integer read ReadTitleHeight write WriteTitleHeight default 0;
- property TitleImages: TCustomImageList read FTitleImages write SetTitleImages;
- property TitleLines: Integer read ReadTitleLines write WriteTitleLines default 0;
- property TitleOffset: Byte read FTitleOffset;
- property TopDataOffset: Byte read FTopDataOffset;
- property TryUseMemTableInt: Boolean read FTryUseMemTableInt write FTryUseMemTableInt;
- property UseMultiTitle: Boolean read FUseMultiTitle write WriteUseMultiTitle default False;
- property VertScrollBar: TDBGridEhScrollBar read FVertScrollBar write SetVertScrollBar;
- property VisibleColCount;
- property VisibleColumns: TColumnsEhList read FVisibleColumns write FVisibleColumns;
- property VisibleRowCount;
- property VTitleMargin: Integer read FVTitleMargin write WriteVTitleMargin default 10;
- property GridLineColors;
- // property HTitleMargin: Integer read FHTitleMargin write WritEhTitleMargin default 0;
- end;
- { TDBGridEh }
- TDBGridEh = class(TCustomDBGridEh)
- public
- property Canvas;
- property GridHeight;
- property RowCount;
- property SelectedRows;
- published
- property Align;
- property AllowedOperations;
- property AllowedSelections;
- property Anchors;
- property AutoFitColWidths;
- {$IFDEF EH_LIB_VCL}
- property BiDiMode;
- {$ENDIF}
- property BorderStyle;
- property Color;
- property ColumnDefValues;
- property Columns stored False; //StoreColumns;
- property Constraints;
- property ContraColCount;
- {$IFDEF EH_LIB_VCL}
- property Ctl3D;
- {$ENDIF}
- property DataSource;
- property DefaultDrawing;
- {$IFDEF EH_LIB_VCL}
- property DragCursor;
- property DragKind;
- {$ENDIF}
- property DragMode;
- property DrawMemoText;
- property EditActions;
- property Enabled;
- property EvenRowColor;
- property FixedColor;
- property Flat;
- property Font;
- property FooterColor;
- property FooterFont;
- property FooterRowCount;
- property FrozenCols;
- property HorzScrollBar;
- {$IFDEF EH_LIB_VCL}
- property ImeMode;
- property ImeName;
- {$ENDIF}
- property MinAutoFitWidth;
- property OddRowColor;
- property Options;
- property OptionsEh;
- {$IFDEF EH_LIB_VCL}
- property ParentBiDiMode;
- property ParentCtl3D;
- {$ENDIF}
- property ParentColor;
- property ParentFont;
- property ParentShowHint;
- property PopupMenu;
- property ReadOnly;
- property RowHeight;
- property RowLines;
- property RowSizingAllowed;
- property ShowHint;
- property SortLocal;
- property STFilter;
- property SumList;
- property TabOrder;
- property TabStop;
- property TitleFont;
- property TitleHeight;
- property TitleImages;
- property TitleLines;
- property UseMultiTitle;
- property VertScrollBar;
- property Visible;
- property VTitleMargin;
- // property HTitleMargin;
- property OnApplyFilter;
- property OnCellClick;
- property OnCheckButton;
- property OnColEnter;
- property OnColExit;
- property OnColumnMoved;
- property OnColWidthsChanged;
- {$IFDEF EH_LIB_5}
- property OnContextPopup;
- {$ENDIF}
- property OnDblClick;
- property OnDragDrop;
- property OnDragOver;
- property OnDrawColumnCell;
- property OnDrawDataCell; { obsolete }
- property OnDrawFooterCell;
- property OnEditButtonClick;
- {$IFDEF EH_LIB_VCL}
- property OnEndDock;
- {$ENDIF}
- property OnEndDrag;
- property OnEnter;
- property OnExit;
- property OnGetBtnParams;
- property OnGetCellParams;
- property OnGetFooterParams;
- property OnKeyDown;
- property OnKeyPress;
- property OnKeyUp;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnMoveRecords;
- property OnSelectionChanged;
- property OnSortMarkingChanged;
- {$IFDEF EH_LIB_VCL}
- property OnStartDock;
- {$ENDIF}
- property OnStartDrag;
- property OnSumListAfterRecalcAll;
- property OnSumListRecalcAll;
- property OnTitleBtnClick;
- property OnTitleClick;
- end;
- { TColumnDropDownBoxEh }
- TColumnDropDownBoxEh = class(TPersistent)
- private
- FAlign: TDropDownAlign;
- FAutoDrop: Boolean;
- FAutoFitColWidths: Boolean;
- FListSource: TDataSource;
- FOwner: TPersistent;
- FRows: Integer;
- FShowTitles: Boolean;
- FSizable: Boolean;
- FSpecRow: TSpecRowEh;
- FUseMultiTitle: Boolean;
- FWidth: Integer;
- function GetAutoFitColWidths: Boolean;
- function GetColumnDefValues: TColumnDefValuesEh;
- function GetColumns: TDBGridColumnsEh;
- function GetListSource: TDataSource;
- function GetOptions: TDBLookupGridEhOptions;
- function StoreColumns: Boolean;
- procedure SetAutoFitColWidths(const Value: Boolean);
- procedure SetColumnDefValues(const Value: TColumnDefValuesEh);
- procedure SetColumns(const Value: TDBGridColumnsEh);
- procedure SetListSource(const Value: TDataSource);
- procedure SetOptions(const Value: TDBLookupGridEhOptions);
- procedure SetSpecRow(const Value: TSpecRowEh);
- protected
- property Align: TDropDownAlign read FAlign write FAlign default daLeft;
- property AutoDrop: Boolean read FAutoDrop write FAutoDrop default False;
- property Rows: Integer read FRows write FRows default 7;
- property ShowTitles: Boolean read FShowTitles write FShowTitles default False;
- property Sizable: Boolean read FSizable write FSizable default False;
- property SpecRow: TSpecRowEh read FSpecRow write SetSpecRow;
- property Width: Integer read FWidth write FWidth default 0;
- public
- constructor Create(Owner: TPersistent);
- destructor Destroy; override;
- function GetOwner: TPersistent; override;
- procedure Assign(Source: TPersistent); override;
- published
- property AutoFitColWidths: Boolean read GetAutoFitColWidths write SetAutoFitColWidths default True;
- property ColumnDefValues: TColumnDefValuesEh read GetColumnDefValues write SetColumnDefValues;
- property Columns: TDBGridColumnsEh read GetColumns write SetColumns stored StoreColumns;
- property ListSource: TDataSource read GetListSource write SetListSource;
- property Options: TDBLookupGridEhOptions read GetOptions write SetOptions default [dlgColLinesEh];
- property UseMultiTitle: Boolean read FUseMultiTitle write FUseMultiTitle default False;
- end;
- TDBGridEhStyle = class(TPersistent)
- private
- FGrids: TObjectList;
- FLuminateSelection: Boolean;
- FScreenNumColors: Integer;
- FWindowHandle: HWND;
- FFilterEditCloseUpApplyFilter: Boolean;
- FIsDrawFocusRect: Boolean;
- procedure SetLuminateSelection(const Value: Boolean);
- protected
- function HighlightDataCellColor(AGrid: TCustomDBGridEh; ACol, ARow: Integer;
- DataCol, DataRow: Integer; const Value: string; AState: TGridDrawState;
- InMultiSelect: Boolean; var AColor: TColor; AFont: TFont): Boolean; virtual;
- function HighlightNoDataCellColor(AGrid: TCustomDBGridEh; ACol, ARow: Integer;
- DataCol, DataRow: Integer; CellType: TCellTypeEh; AState: TGridDrawState;
- InMultiSelect: Boolean; var AColor: TColor; AFont: TFont): Boolean; virtual;
- procedure RemoveAllChangeNotification;
- procedure StyleWndProc(var Msg: TMessage); virtual;
- procedure SysColorChanged; virtual;
- public
- constructor Create;
- destructor Destroy; override;
- function GridInChangeNotification(Grid: TCustomDBGridEh): Boolean;
- function LightenColor(AColor: TColor; GlassColor: TColor; Ungray: Boolean): TColor;
- procedure AddChangeNotification(Grid: TCustomDBGridEh);
- procedure Changed;
- procedure RemoveChangeNotification(Grid: TCustomDBGridEh);
- property LuminateSelection: Boolean read FLuminateSelection write SetLuminateSelection default True;
- property FilterEditCloseUpApplyFilter: Boolean
- read FFilterEditCloseUpApplyFilter write FFilterEditCloseUpApplyFilter default False;
- property IsDrawFocusRect: Boolean read FIsDrawFocusRect write FIsDrawFocusRect default True;
- end;
- function SetDBGridEhDefaultStyle(NewGridDefaultStyle: TDBGridEhStyle): TDBGridEhStyle;
- function DBGridEhDefaultStyle: TDBGridEhStyle;
- type
- { TDBGridEhDataService }
- TDBGridEhDataService = class(TPersistent)
- private
- FOnApplySorting: TNotifyEvent;
- FOnApplyFilter: TNotifyEvent;
- FOnLocateText: TLocateTextEventEh;
- protected
- function DefaultLocateText(AGrid: TCustomDBGridEh; const FieldName: string;
- const Text: string; Options: TLocateTextOptionsEh; Direction: TLocateTextDirectionEh;
- Matching: TLocateTextMatchingEh; TreeFindRange: TLocateTextTreeFindRangeEh): Boolean; virtual;
- function DefaultMoveRecords(AGrid: TCustomDBGridEh; BookmarkList: TStrings; ToRecNo: Longint; CheckOnly: Boolean): Boolean; virtual;
- function LocateText(AGrid: TCustomDBGridEh; const FieldName: string;
- const Text: string; Options: TLocateTextOptionsEh; Direction: TLocateTextDirectionEh;
- Matching: TLocateTextMatchingEh; TreeFindRange: TLocateTextTreeFindRangeEh): Boolean; virtual;
- function MoveRecords(AGrid: TCustomDBGridEh; BookmarkList: TStrings; ToRecNo: Longint; CheckOnly: Boolean): Boolean; virtual;
- procedure ApplyFilter(AGrid: TCustomDBGridEh); virtual;
- procedure ApplySorting(AGrid: TCustomDBGridEh); virtual;
- procedure DefaultApplyFilter(AGrid: TCustomDBGridEh); virtual;
- procedure DefaultApplySorting(AGrid: TCustomDBGridEh); virtual;
- procedure ExecuteFindDialog(AGrid: TCustomDBGridEh; Text, FieldName: string; Modal: Boolean); virtual;
- public
- property OnApplyFilter: TNotifyEvent read FOnApplyFilter write FOnApplyFilter;
- property OnApplySorting: TNotifyEvent read FOnApplySorting write FOnApplySorting;
- property OnLocateText: TLocateTextEventEh read FOnLocateText write FOnLocateText;
- end;
- {const
- IndicatorWidth = 11;}
- var
- DBGridEhDataService: TDBGridEhDataService;
- SortMarkerFont: TFont;
- DBGridEhIndicators: TImageList;
- DBGridEhSortMarkerImages: TImageList;
- DBGridEhInplaceSearchKey: TShortCut;
- DBGridEhInplaceSearchNextKey: TShortCut;
- DBGridEhInplaceSearchPriorKey: TShortCut;
- DBGridEhInplaceSearchTimeOut: Integer; // in millisecond
- DBGridEhInplaceSearchColor: TColor;
- DBGridEhInplaceSearchTextColor: TColor;
- DBGridEhSetValueFromPrevRecordKey: TShortCut;
- DBGridEhFindDialogKey: TShortCut;
- DBGridEhDebugDraw: Boolean;
- const
- ColSelectionAreaHeight: Integer = 7;
- procedure RecreateInplaceSearchIndicator;
- procedure WriteTextEh(ACanvas: TCanvas; // Canvas
- ARect: TRect; // Draw rect and ClippingRect
- FillRect: Boolean; // Fill rect Canvas.Brash.Color
- DX, DY: Integer; // InflateRect(Rect, -DX, -DY) for text
- Text: string; // Draw text
- Alignment: TAlignment; // Text alignment
- Layout: TTextLayout; // Text layout
- MultyL: Boolean; // Word break
- EndEllipsis: Boolean; // Truncate long text by ellipsis
- LeftMarg, // Left margin
- RightMarg: Integer; // Right margin
- RightToLeftReading: Boolean);
- function WriteTextVerticalEh(ACanvas: TCanvas;
- ARect: TRect; // Draw rect and ClippingRect
- FillRect: Boolean; // Fill rect Canvas.Brash.Color
- DX, DY: Integer; // InflateRect(Rect, -DX, -DY) for text
- Text: string; // Draw text
- Alignment: TAlignment; // Text alignment
- Layout: TTextLayout; // Text layout
- EndEllipsis: Boolean; // Truncate long text by ellipsis
- CalcTextExtent: Boolean //
- ): Integer;
- implementation
- {$IFDEF EH_LIB_VCL}
- uses DBConsts, Dialogs, Comctrls, CommCtrl, DBGridEhImpExp, Clipbrd, ExtCtrls,
- {$IFDEF EH_LIB_6}MaskUtils, {$ELSE}Mask, {$ENDIF}
- {$IFDEF EH_LIB_7}Themes, UxTheme, {$ENDIF}
- EhLibConsts, DBLookupGridsEh, CalculatorEh, DBGridEhFindDlgs, DBUtilsEh,
- DBLookupEh;
- {$R DBGRIDEH.RES}
- {$ELSE}
- uses DBConsts, QDialogs, QComctrls, QDBGridEhImpExp, QClipbrd, QExtCtrls,
- QEhLibConsts, QDBLookupGridsEh, QCalculatorEh, QDbUtilsEh, QDBGridEhFindDlgs;
- {$R QDBGRIDEH.RES}
- {$ENDIF}
- const
- bmArrow = 'DBGARROWEH';
- bmEdit = 'DBEDITEH';
- bmInsert = 'DBINSERTEH';
- bmMultiDot = 'DBMULTIDOTEH';
- bmMultiArrow = 'DBMULTIARROWEH';
- bmSmDown = 'DBSMDOWNEH';
- bmSmUp = 'DBSMUPEH';
- bmEditWhite = 'DBGARROWEHW';
- MaxMapSize = (MaxInt div 2) div SizeOf(Integer); { 250 million }
- var
- hcrDownCurEh: HCursor = 0;
- hcrRightCurEh: HCursor = 0;
- hcrLeftCurEh: HCursor = 0;
- VarColCellParamsEh: TColCellParamsEh;
- procedure ChangeCanvasDrawOrientation(Canvas: TCanvas;
- RightToLeftOrientation: Boolean; Width, Height: Integer);
- var
- Org: TPoint;
- Ext: TPoint;
- begin
- if RightToLeftOrientation then
- begin
- Org := Point(Width, 0);
- Ext := Point(-1, 1);
- SetMapMode(Canvas.Handle, mm_Anisotropic);
- SetWindowOrgEx(Canvas.Handle, Org.X, Org.Y, nil);
- SetViewportExtEx(Canvas.Handle, Width, Height, nil);
- SetWindowExtEx(Canvas.Handle, Ext.X * Width, Ext.Y * Height, nil);
- end else
- begin
- Org := Point(0, 0);
- Ext := Point(1, 1);
- SetMapMode(Canvas.Handle, mm_Anisotropic);
- SetWindowOrgEx(Canvas.Handle, Org.X, Org.Y, nil);
- SetViewportExtEx(Canvas.Handle, Width, Height, nil);
- SetWindowExtEx(Canvas.Handle, Ext.X * Width, Ext.Y * Height, nil);
- end;
- end;
- function SafeGetFieldAsInteger(Field: TField; ValueOnError: Integer): Integer;
- begin
- Result := ValueOnError;
- if (Field.DataType in [ftSmallint, ftInteger, ftWord]) then
- Result := Field.AsInteger
- else if (Field is TLargeintField) and
- (TLargeintField(Field).AsLargeInt >= Low(Integer)) and
- (TLargeintField(Field).AsLargeInt <= MAXINT) then
- Result := TLargeintField(Field).AsLargeInt
- else if (Field.DataType in [ftFloat]) and
- (Field.AsFloat >= Low(Integer)) and
- (Field.AsFloat <= MAXINT) then
- Result := Field.AsInteger
- else if (Field.DataType in [ftCurrency]) and
- (Field.AsCurrency >= Low(Integer)) and
- (Field.AsCurrency <= MAXINT) then
- Result := Field.AsInteger
- else if (Field.DataType in [ftBCD{$IFDEF EH_LIB_6}, ftFMTBcd{$ENDIF}]) and
- not VarIsNull(Field.AsVariant) and
- (Field.AsVariant >= Low(Integer)) and
- (Field.AsVariant <= MAXINT) then
- Result := Field.AsInteger;
- end;
- function FieldsCanModify(Fields: TObjectList): Boolean;
- var
- i: Integer;
- begin
- Result := True;
- for i := 0 to Fields.Count - 1 do
- if not TField(Fields[i]).CanModify then
- begin
- Result := False;
- Exit;
- end;
- end;
- function GridRect(ALeft, ATop, ARight, ABottom: Integer): TGridRect;
- begin
- Result.Left := ALeft;
- Result.Top := ATop;
- Result.Bottom := ABottom;
- Result.Right := ARight;
- end;
- { Error reporting }
- procedure RaiseGridError(const S: string);
- begin
- raise EInvalidGridOperationEh.Create(S);
- end;
- procedure KillMessage(Wnd: HWnd; Msg: Integer);
- // Delete the requested message from the queue, but throw back
- // any WM_QUIT msgs that PeekMessage may also return
- var
- M: TMsg;
- begin
- M.Message := 0;
- if PeekMessage(M, Wnd, Msg, Msg, pm_Remove) and (M.Message = WM_QUIT) then
- PostQuitMessage(M.wparam);
- end;
- type
- TCharSet = set of AnsiChar;
- function ExtractWord(N: Integer; const S: string; WordDelims: TCharSet): string; forward;
- function GetDefaultSection(Component: TComponent): string;
- var
- // F: TCustomForm;
- Owner: TComponent;
- begin
- if Component <> nil then
- begin
- if Component is TCustomForm then
- Result := Component.ClassName
- else
- begin
- Result := Component.Name;
- Owner := Component.Owner;
- while (Owner <> nil) and not (Owner is TCustomForm) do
- begin
- Result := Owner.Name + '.' + Result;
- Owner := Owner.Owner;
- end;
- if Owner <> nil then
- Result := Owner.ClassName + Result;
- { if Component is TControl then
- begin
- F := GetParentForm(TControl(Component));
- if F <> nil then Result := F.ClassName + Result
- else
- begin
- if TControl(Component).Parent <> nil then
- Result := TControl(Component).Parent.Name + Result;
- end;
- end
- else
- begin
- Owner := Component.Owner;
- if Owner is TForm then
- Result := Format('%s.%s', [Owner.ClassName, Result]);
- end;}
- end;
- end else
- Result := '';
- end;
- function Max(A, B: Longint): Longint;
- begin
- if A > B
- then Result := A
- else Result := B;
- end;
- function Min(A, B: Longint): Longint;
- begin
- if A < B
- then Result := A
- else Result := B;
- end;
- function iif(Condition: Boolean; V1, V2: Integer): Integer;
- begin
- if (Condition) then Result := V1 else Result := V2;
- end;
- procedure GridInvalidateRow(Grid: TCustomDBGridEh; Row: Longint);
- var
- I: Longint;
- begin
- for I := 0 to Grid.FullColCount - 1 do Grid.InvalidateCell(I, Row);
- end;
- procedure OverturnUpRect(var ARect: TRect);
- var Bottom: Integer;
- begin
- Bottom := ARect.Bottom;
- ARect.Bottom := ARect.Top + (ARect.Right - ARect.Left);
- ARect.Right := ARect.Left + (Bottom - ARect.Top);
- end;
- function CheckHintTextRect(DrawTextBiDiModeFlagsReadingOnly: Longint;
- Canvas: TCanvas; RightIndent, FInterlinear: Integer; ws: string; ARect: TRect;
- WordWrap: Boolean; var TextWidth, TextHeight: Integer): Boolean;
- var
- NewRect: TRect;
- uFormat: Integer;
- begin
- Result := False;
- uFormat := DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DrawTextBiDiModeFlagsReadingOnly;
- if WordWrap then uFormat := uFormat or DT_WORDBREAK;
- NewRect := Rect(0, 0, ARect.Right - ARect.Left - 2 - RightIndent, 0);
- if NewRect.Right <= 0 then NewRect.Right := 1;
- DrawTextEh(Canvas.Handle, ws, Length(ws), NewRect, uFormat);
- TextWidth := NewRect.Right - NewRect.Left;
- TextHeight := NewRect.Bottom - NewRect.Top;
- if (NewRect.Right - NewRect.Left > ARect.Right - ARect.Left - 2 - RightIndent) or
- (NewRect.Bottom - NewRect.Top > ARect.Bottom - ARect.Top - FInterlinear + 1) then
- Result := True;
- end;
- {function DefineCursor(Identifier: PChar): TCursor;
- var Handle:HCursor;
- begin
- Handle := LoadCursor(hInstance, Identifier);
- if Handle = 0 then raise EOutOfResources.Create('Cannot load cursor resource');
- for Result := 1 to High(TCursor) do
- if Screen.Cursors[Result] = Screen.Cursors[crArrow] then
- begin
- Screen.Cursors[Result] := Handle;
- Exit;
- end;
- raise EOutOfResources.Create('Too many user-defined cursors');
- end;}
- function GetTextWidth(Canvas: TCanvas; Text: string): Integer;
- var ARect: TRect;
- uFormat: Integer;
- begin
- uFormat := DT_CALCRECT or DT_LEFT or DT_NOPREFIX;
- ARect := Rect(0, 0, 1, 0);
- DrawTextEh(Canvas.Handle, Text, Length(Text), ARect, uFormat);
- Result := ARect.Right - ARect.Left;
- end;
- function PointInGridRect(Col, Row: Longint; const Rect: TGridRect): Boolean;
- begin
- Result := (Col >= Rect.Left) and (Col <= Rect.Right) and (Row >= Rect.Top)
- and (Row <= Rect.Bottom);
- end;
- var
- FDBGridEhDefaultStyle: TDBGridEhStyle = nil;
- function SetDBGridEhDefaultStyle(NewGridDefaultStyle: TDBGridEhStyle): TDBGridEhStyle;
- begin
- Result := FDBGridEhDefaultStyle;
- FDBGridEhDefaultStyle := NewGridDefaultStyle;
- FDBGridEhDefaultStyle.Changed;
- end;
- function DBGridEhDefaultStyle: TDBGridEhStyle;
- begin
- Result := FDBGridEhDefaultStyle;
- end;
- { TDBGridEhStyle }
- constructor TDBGridEhStyle.Create;
- begin
- inherited Create;
- FGrids := TObjectList.Create(False);
- {$IFDEF CIL}
- FWindowHandle := WinUtils.AllocateHWnd(StyleWndProc);
- {$ELSE}
- FWindowHandle := {$IFDEF EH_LIB_6}Classes.{$ENDIF}AllocateHWnd(StyleWndProc);
- {$ENDIF}
- FLuminateSelection := True;
- FIsDrawFocusRect := True;
- SysColorChanged;
- end;
- destructor TDBGridEhStyle.Destroy;
- var
- i: Integer;
- begin
- {$IFDEF CIL}
- WinUtils.DeallocateHWnd(FWindowHandle);
- {$ELSE}
- {$IFDEF EH_LIB_6}Classes.{$ENDIF}DeallocateHWnd(FWindowHandle);
- {$ENDIF}
- if FDBGridEhDefaultStyle = Self then
- FDBGridEhDefaultStyle := nil;
- for i := FGrids.Count - 1 downto 0 do
- TCustomDBGridEh(FGrids[i]).Style := nil;
- FGrids.Free;
- inherited Destroy;
- end;
- procedure TDBGridEhStyle.Changed;
- var
- i: Integer;
- begin
- for i := 0 to FGrids.Count - 1 do
- TCustomDBGridEh(FGrids[i]).StyleEhChanged;
- end;
- procedure TDBGridEhStyle.AddChangeNotification(Grid: TCustomDBGridEh);
- begin
- if not GridInChangeNotification(Grid) then
- FGrids.Add(Grid);
- end;
- function TDBGridEhStyle.GridInChangeNotification(Grid: TCustomDBGridEh): Boolean;
- begin
- Result := (FGrids.IndexOf(Grid) >= 0);
- end;
- procedure TDBGridEhStyle.RemoveChangeNotification(Grid: TCustomDBGridEh);
- begin
- FGrids.Remove(Grid);
- end;
- procedure TDBGridEhStyle.RemoveAllChangeNotification;
- var
- i: Integer;
- begin
- for i := 0 to FGrids.Count - 1 do
- FGrids.Delete(i);
- end;
- function TDBGridEhStyle.HighlightDataCellColor(AGrid: TCustomDBGridEh;
- ACol, ARow, DataCol, DataRow: Integer; const Value: string;
- AState: TGridDrawState; InMultiSelect: Boolean; var AColor: TColor; AFont: TFont): Boolean;
- var
- AFocused: Boolean;
- begin
- Result := False;
- AFocused := False;
- if {(dgMultiSelect in AGrid.Options) and} AGrid.Datalink.Active then
- Result := AGrid.Selection.DataCellSelected(DataCol, AGrid.Datalink.Datasource.Dataset.Bookmark);
- if not Result then
- begin
- AFocused := AGrid.Focused and (dghHighlightFocus in AGrid.OptionsEh);
- if (dghRowHighlight in AGrid.OptionsEh) and (DataRow + AGrid.TopDataOffset = AGrid.Row) and
- (AGrid.Selection.SelectionType = gstNon) and not (DataCol + AGrid.FIndicatorOffset = AGrid.Col) then
- begin
- AFocused := True;
- AState := AState + [gdSelected];
- end;
- Result := ((gdSelected in AState) {ddd//} or ((ARow) = AGrid.Row) and (dgRowSelect in AGrid.Options))
- and ((dgAlwaysShowSelection in AGrid.Options) or (AFocused {ddd//}))
- { updatelock eliminates flicker when tabbing between rows }
- and ((AGrid.UpdateLock = 0) or (dgRowSelect in AGrid.Options));
- end;
- if Result then
- if AGrid.IsSelectionActive then
- begin
- if LuminateSelection and (FScreenNumColors = -1) and
- not ((ARow = AGrid.Row) and ((ACol = AGrid.Col) or (dgRowSelect in AGrid.Options)))
- then
- //AColor := FLuminateSelectionColor
- AColor := GetNearestColor(AGrid.Canvas.Handle, LightenColor(AColor, clHighlight, True))
- else
- begin
- AColor := clHighlight;
- AFont.Color := clHighlightText;
- end;
- end else if (ARow = AGrid.Row) and
- ((ACol = AGrid.Col) or (dgRowSelect in AGrid.Options)) and
- ((dgAlwaysShowSelection in AGrid.Options) or AFocused) then
- begin
- AColor := clBtnShadow;
- AFont.Color := clHighlightText;
- end else if (FScreenNumColors = -1) then
- AColor := GetNearestColor(AGrid.Canvas.Handle, LightenColor(AColor, clBtnShadow, False))
- else
- AColor := clBtnFace;
- end;
- function TDBGridEhStyle.HighlightNoDataCellColor(AGrid: TCustomDBGridEh;
- ACol, ARow, DataCol, DataRow: Integer; CellType: TCellTypeEh;
- AState: TGridDrawState; InMultiSelect: Boolean; var AColor: TColor;
- AFont: TFont): Boolean;
- begin
- Result := False;
- if InMultiSelect then
- begin
- if ((CellType.HorzType = hctIndicatorEh) and (CellType.VertType <> vctAboveFooterEh)) or
- ((CellType.HorzType = hctDataEh) and (CellType.VertType in [vctTitleEh, vctSubTitleEh])) then
- begin
- AColor := RGB(64, 64, 64);
- AFont.Color := clWhite;
- end else if AGrid.IsSelectionActive then
- begin
- if LuminateSelection and (FScreenNumColors = -1) then
- // AColor := FLuminateSelectionColor
- AColor := LightenColor(AColor, clHighlight, True)
- else
- begin
- AColor := clHighlight;
- AFont.Color := clHighlightText;
- end;
- end else if (FScreenNumColors = -1) then
- AColor := LightenColor(AColor, clBtnShadow, False)
- else
- AColor := clBtnFace;
- Result := True;
- end;
- end;
- procedure TDBGridEhStyle.SetLuminateSelection(const Value: Boolean);
- begin
- if FLuminateSelection = Value then Exit;
- FLuminateSelection := Value;
- Changed;
- end;
- procedure TDBGridEhStyle.StyleWndProc(var Msg: TMessage);
- begin
- with Msg do
- if Msg = WM_SYSCOLORCHANGE then
- try
- SysColorChanged;
- except
- Application.HandleException(Self);
- end
- else
- Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
- end;
- function TDBGridEhStyle.LightenColor(AColor: TColor; GlassColor: TColor; Ungray: Boolean): TColor;
- var
- r, g, b: Double;
- rgb: Longint;
- r_c, g_c, b_c: Double;
- rgb_c: Longint;
- begin
- rgb := ColorToRGB(AColor);
- r := rgb and $FF;
- g := (rgb shr 8) and $FF;
- b := (rgb shr 16) and $FF;
- rgb_c := ColorToRGB(GlassColor);
- r_c := rgb_c and $FF;
- g_c := (rgb_c shr 8) and $FF;
- b_c := (rgb_c shr 16) and $FF;
- r := r + (r_c - r) * 0.5;
- g := g + (g_c - g) * 0.5;
- b := b + (b_c - b) * 0.5;
- r := r + (225 - r) * 0.6;
- g := g + (225 - g) * 0.6;
- b := b + (225 - b) * 0.6;
- if Ungray then
- begin
- r := r - (integer(122) - r) * 0.25;
- g := g - (integer(122) - g) * 0.25;
- b := b - (integer(122) - b) * 0.25;
- end;
- Result := TColor((Max(Min(Round(b), 255), 0) shl 16)
- or (Max(Min(Round(g), 255), 0) shl 8)
- or Max(Min(Round(r), 255), 0));
- end;
- procedure TDBGridEhStyle.SysColorChanged;
- var
- DC: HDC;
- begin
- DC := GetDC(0);
- FScreenNumColors := GetDeviceCaps(DC, NUMCOLORS); // -1 if more then 256
- ReleaseDC(0, DC);
- end;
- { TDBGridInplaceEdit }
- { TDBGridInplaceEdit adds support for a button on the in-place editor,
- which can be used to drop down a table-based lookup list, a stringlist-based
- pick list, or (if button style is esEllipsis) fire the grid event
- OnEditButtonClick. }
- //const
- // InitRepeatPause:Integer = 500; { pause before repeat timer (ms) }
- // RepeatPause:Integer = 100; { pause before hint window displays (ms)}
- type
- TEditStyle = (esSimple, esEllipsis, esPickList, esDataList, esDateCalendar, esUpDown, esDropDown);
- // TPopupListbox = class;
- TDBGridInplaceEdit = class(TInplaceEdit, IComboEditEh{$IFNDEF CIL}, IUnknown{$ENDIF})
- private
- FCanvas: TCanvas;
- FActiveList: TWinControl;
- FButtonHeight: Integer;
- FButtonsWidth: Integer;
- FCharKeyStr: string;
- FDataList: TPopupDataGridEh;
- FDroppedDown: Boolean;
- FEditButtonControlList: TEditButtonControlList;
- FEditStyle: TEditStyle;
- FListColumnMothed: Boolean;
- FListVisible: Boolean;
- FLockCloseList: Boolean;
- FLookupSource: TDatasource;
- FMRUList: TMRUListEh;
- FMRUListControl: TWinControl;
- FNoClickCloseUp: Boolean;
- FPickList: TPopupListboxEh;
- FPopupCalculator: TWinControl;
- FPopupMonthCalendar: TPopupMonthCalendarEh;
- FReadOnlyStored: Boolean;
- FUserTextChanged: Boolean;
- FWordWrap: Boolean;
- FImageIndex: Integer;
- function DeleteSeletedText: string;
- function GetColumn: TColumnEh;
- function GetEditButtonByShortCut(ShortCut: TShortCut): TEditButtonEh;
- function GetGrid: TCustomDBGridEh;
- function GetMRUListControl: TWinControl;
- procedure CMCancelMode(var Message: TCMCancelMode); message CM_CancelMode;
- procedure DoDBCSKeyPress(var Key: Char);
- procedure ListColumnMoved(Sender: TObject; FromIndex, ToIndex: Longint);
- procedure ListMouseCloseUp(Sender: TObject; Accept: Boolean);
- procedure ListMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure LocateListText;
- procedure PopupListboxGetImageIndex(Sender: TObject; ItemIndex: Integer; var ImageIndex: Integer);
- procedure SetEditStyle(Value: TEditStyle);
- procedure SetWordWrap(const Value: Boolean);
- procedure UpdateImageIndex; virtual;
- procedure UpDownClick(Sender: TObject; Button: TUDBtnType);
- procedure WMKillFocus(var Message: TWMKillFocus); message WM_KillFocus;
- procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LButtonDblClk;
- procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
- procedure WMPaste(var Message: TMessage); message WM_PASTE;
- procedure WMSetCursor(var Message: TWMSetCursor); message WM_SetCursor;
- procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
- protected
- function CanDropCalculator: Boolean;
- function CreateEditButtonControl: TEditButtonControlEh; virtual;
- function CreateMRUListControl: TWinControl; virtual;
- function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
- function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
- function GetPopupCalculator: TWinControl; virtual;
- function TraceMouseMoveForPopupListbox(Sender: TObject; Shift: TShiftState; X, Y: Integer): Boolean;
- procedure BoundsChanged; override;
- procedure ButtonDown(IsDownButton: Boolean); virtual;
- procedure CalcEditRect(var ARect: TRect); virtual;
- procedure CloseUp(Accept: Boolean);
- procedure CreateParams(var Params: TCreateParams); override;
- procedure DBCSKeyPress(var Key: string); virtual;
- procedure DoDropDownKeys(var Key: Word; Shift: TShiftState);
- procedure DrawEditImage(DC: HDC);
- procedure DropDown;
- procedure EditButtonClick(Sender: TObject); virtual;
- procedure EditButtonDown(Sender: TObject; TopButton: Boolean;
- var AutoRepeat: Boolean; var Handled: Boolean); virtual;
- procedure EditButtonMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); virtual;
- procedure EditButtonMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer); virtual;
- procedure FilterMRUItem(AText: string; var Accept: Boolean); virtual;
- procedure KeyDown(var Key: Word; Shift: TShiftState); override;
- procedure KeyPress(var Key: Char); override;
- procedure KeyUp(var Key: Word; Shift: TShiftState); 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;
- procedure MRUListCloseUp(Sender: TObject; Accept: Boolean);
- procedure MRUListControlMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure MRUListControlResized(Sender: TObject); virtual;
- procedure MRUListDropDown(Sender: TObject);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure PaintRequiredState(ACanvas: TCanvas); virtual;
- procedure PaintWindow(DC: HDC); override;
- procedure UpdateContents; override;
- procedure UpdateEditButtonControlList;
- procedure UpdateEditButtonControlsState;
- procedure UserChange; virtual;
- procedure WndProc(var Message: TMessage); override;
- property ActiveList: TWinControl read FActiveList write FActiveList;
- property Column: TColumnEh read GetColumn;
- property DataList: TPopupDataGridEh read FDataList;
- property EditStyle: TEditStyle read FEditStyle write SetEditStyle;
- property Grid: TCustomDBGridEh read GetGrid;
- property MRUList: TMRUListEh read FMRUList write FMRUList;
- property MRUListControl: TWinControl read GetMRUListControl;
- property PickList: TPopupListboxEh read FPickList;
- property WordWrap: Boolean read FWordWrap write SetWordWrap;
- property ReadOnly;
- public
- constructor Create(Owner: TComponent); override;
- destructor Destroy; override;
- procedure DefaultHandler(var Message); override;
- end;
- { TDBGridInplaceEdit }
- constructor TDBGridInplaceEdit.Create(Owner: TComponent);
- begin
- inherited Create(Owner);
- FLookupSource := TDataSource.Create(Self);
- FEditStyle := esSimple;
- FCanvas := TControlCanvas.Create;
- TControlCanvas(FCanvas).Control := Self;
- end;
- destructor TDBGridInplaceEdit.Destroy;
- begin
- FCanvas.Free;
- inherited Destroy;
- end;
- function TDBGridInplaceEdit.DeleteSeletedText: string;
- begin
- Result := Text;
- Delete(Result, SelStart + 1, SelLength);
- end;
- function GetTextHeight(Canvas: TCanvas; Font: TFont): Integer;
- var
- DC: HDC;
- SaveFont: HFont;
- Metrics: TTextMetric;
- begin
- if Canvas = nil
- then DC := GetDC(0)
- else DC := Canvas.Handle;
- SaveFont := SelectObject(DC, Font.Handle);
- GetTextMetrics(DC, Metrics);
- SelectObject(DC, SaveFont);
- if Canvas = nil then
- ReleaseDC(0, DC);
- Result := Metrics.tmHeight;
- end;
- procedure TDBGridInplaceEdit.CalcEditRect(var ARect: TRect);
- begin
- if Grid.Flat
- then SetRect(ARect, 2, 1, Width - 2, Height - 1)
- else SetRect(ARect, 2, 2, Width - 2, Height);
- if ((ARect.Bottom - ARect.Top) < GetTextHeight(nil, Font)) and (ARect.Bottom < Height) then
- Inc(ARect.Bottom);
- if FButtonsWidth > 0 then
- if Column.UseRightToLeftAlignment
- then Inc(ARect.Left, FButtonsWidth)
- else Dec(ARect.Right, FButtonsWidth);
- if (Column <> nil) and (Column.ImageList <> nil) and Column.ShowImageAndText then
- if Column.UseRightToLeftAlignment
- then Dec(ARect.Right, Column.ImageList.Width + 5)
- else Inc(ARect.Left, Column.ImageList.Width + 5);
- if (Grid.FIntMemTable <> nil) and (Column = Grid.VisibleColumns[0]) and Grid.FIntMemTable.MemTableIsTreeList then
- if Column.UseRightToLeftAlignment
- then Dec(ARect.Right, Grid.GetCellTreeElmentsAreaWidth + 1)
- else Inc(ARect.Left, Grid.GetCellTreeElmentsAreaWidth + 1);
- end;
- procedure TDBGridInplaceEdit.BoundsChanged;
- var
- R: TRect;
- Msg: TMsg;
- begin
- PeekMessage(Msg, Handle, CM_IGNOREEDITDOWN, CM_IGNOREEDITDOWN, PM_REMOVE);
- UpdateEditButtonControlList;
- UpdateEditButtonControlsState;
- CalcEditRect(R);
- // SendMessage(Handle, EM_SETRECTNP, 0, LongInt(@R));
- SendStructMessage(Handle, EM_SETRECTNP, 0, R);
- SendMessage(Handle, EM_SCROLLCARET, 0, 0);
- if SysLocale.FarEast
- then SetImeCompositionWindow(Font, R.Left, R.Top);
- if Height > Round(FButtonsWidth * 3 / 2)
- then FButtonHeight := FButtonsWidth
- else FButtonHeight := Height;
- end;
- procedure TDBGridInplaceEdit.CreateParams(var Params: TCreateParams);
- begin
- inherited CreateParams(Params);
- if WordWrap then
- Params.Style := Params.Style and (not ES_AUTOHSCROLL) or ES_MULTILINE or ES_LEFT;
- if Grid.Flat then
- FButtonsWidth := FlatButtonWidth + 1
- else
- FButtonsWidth := GetSystemMetrics(SM_CXVSCROLL);
- end;
- procedure TDBGridInplaceEdit.DoDropDownKeys(var Key: Word; Shift: TShiftState);
- begin
- case Key of
- VK_UP, VK_DOWN:
- if ssAlt in Shift then
- begin
- if FListVisible then CloseUp(True) else DropDown;
- Key := 0;
- end;
- VK_RETURN, VK_ESCAPE:
- if FListVisible and not (ssAlt in Shift) and not (FActiveList = FPopupCalculator) then
- begin
- CloseUp(Key = VK_RETURN);
- Key := 0;
- end
- else if not FListVisible and (Key = VK_RETURN) and ([ssCtrl] = Shift) then
- begin
- DropDown;
- Key := 0;
- end;
- end;
- end;
- procedure TDBGridInplaceEdit.DropDown;
- var
- P: TPoint;
- I, J, Y: Integer;
- Column: TColumnEh;
- {WorkArea, }R: TRect;
- FLookupDataSet: TDataSet;
- PopupCalculatorIntf: IPopupCalculatorEh;
- ADropDownAlign: TDropDownAlign;
- begin
- if not FListVisible and Assigned(FActiveList) then
- begin
- FActiveList.Width := Width;
- with Grid do
- Column := Columns[SelectedIndex];
- if FActiveList = FDataList then //DataList
- with Column.Field do
- begin
- //for delete FDataList.FSizeGrip.Visible := Column.DropDownSizing;
- FLookupDataSet := Column.UsedLookupDataSet;
- if not Assigned(FLookupDataSet) then Exit;
- FDataList.Color := Color;
- FDataList.Font := Font;
- // FDataList.RowCount := Column.DropDownRows;
- FDataList.SpecRow := Column.DropDownSpecRow;
- if FLookupDataSet.IsSequenced and
- (FLookupDataSet.RecordCount > 0) and
- (Integer(Column.DropDownRows) > FLookupDataSet.RecordCount)
- then
- FDataList.RowCount := FLookupDataSet.RecordCount
- else
- FDataList.RowCount := Column.DropDownRows;
- FDataList.ShowTitles := Column.DropDownShowTitles;
- FLookupSource.DataSet := FLookupDataSet;
- FDataList.KeyField := LookupKeyFields;
- //ddd FDataList.ListField := {ddd LookupResultField}Column.LookupDisplayFields;
- FDataList.ListFieldIndex := 0;
- FDataList.ListField := Column.LookupDisplayFields; // Assignment ListField must be after ListFieldIndex
- FDataList.AutoFitColWidths := False; // To avoid fit columns width to editbox width for Column.DropDownWidth = -1
- FDataList.UseMultiTitle := Column.DropDownBox.UseMultiTitle;
- FDataList.ListSource := FLookupSource;
- if (Column.DropDownWidth = -1) then
- FDataList.ClientWidth := FDataList.GetColumnsWidthToFit
- else if Column.DropDownWidth > 0 then
- FDataList.Width := Column.DropDownWidth
- else
- FDataList.Width := Self.Width;
- if (FDataList.Width < Width) then
- FDataList.Width := Self.Width;
- FDataList.KeyValue := Grid.FEditKeyValue {DataSet.FieldByName(KeyFields).Value ddd};
- FListColumnMothed := False;
- FDataList.OnColumnMoved := ListColumnMoved;
- FDataList.AutoFitColWidths := Column.DropDownBox.AutoFitColWidths;
- { J := Column.DefaultWidth;
- if J > FDataList.ClientWidth then
- FDataList.ClientWidth := J;
- }end
- else if (FActiveList = FPopupMonthCalendar) then
- begin
- FPopupMonthCalendar.Color := Color;
- FPopupMonthCalendar.Font := Font;
- {try
- FPopupMonthCalendar.Date := StrToDate(Text);
- except
- FPopupMonthCalendar.Date := Grid.Columns[CurColumn.Field.AsDateTime;
- end;}
- try
- if Text = '' then
- FPopupMonthCalendar.Date := TDate(Date)
- else
- FPopupMonthCalendar.Date := TDate(StrToDate(Text));
- except
- if Column.Field.AsDateTime = 0 then
- FPopupMonthCalendar.Date := TDate(Date)
- else
- FPopupMonthCalendar.Date := TDate(Column.Field.AsDateTime);
- end;
- MonthCal_GetMinReqRect(FPopupMonthCalendar.Handle, R);
- FPopupMonthCalendar.Width := R.Right - R.Left;
- FPopupMonthCalendar.Height := R.Bottom - R.Top;
- end else if (FActiveList = FPopupCalculator) then
- begin
- if Supports(FPopupCalculator, IPopupCalculatorEh, PopupCalculatorIntf) then
- begin
- if Text = ''
- then PopupCalculatorIntf.Value := 0
- else PopupCalculatorIntf.Value := StrToFloat(Text);
- PopupCalculatorIntf.Flat := Grid.Flat;
- end;
- HideCaret(Handle);
- SelLength := 0;
- end else
- begin
- //for delete FPickList.FSizeGripResized := False;
- //for delete FPickList.FSizeGrip.Visible := Column.DropDownSizing;
- FPickList.Color := Color;
- FPickList.Font := Font;
- if Assigned(Column.KeyList) and (Column.KeyList.Count > 0) then
- begin
- FPickList.Items.BeginUpdate;
- FPickList.Items.Clear;
- for i := 0 to Min(Column.KeyList.Count, Column.Picklist.Count) - 1 do
- FPickList.Items.AddObject(Column.Picklist.Strings[i], Column.Picklist.Objects[i]);
- FPickList.Items.EndUpdate;
- end else
- FPickList.Items := Column.Picklist;
- if FPickList.Items.Count >= Integer(Column.DropDownRows) then
- FPickList.Height := Integer(Column.DropDownRows) * FPickList.ItemHeight + 4
- else
- FPickList.Height := FPickList.Items.Count * FPickList.ItemHeight + 4;
- if Column.Field.IsNull then
- FPickList.ItemIndex := -1
- else if Assigned(Column.KeyList) and (Column.KeyList.Count > 0)
- then FPickList.ItemIndex := Column.PickList.IndexOf(Text)
- else FPickList.ItemIndex := FPickList.Items.IndexOf({dddColumn.Field.Value}Text);
- J := FPickList.ClientWidth;
- for I := 0 to FPickList.Items.Count - 1 do
- begin
- Y := FPickList.Canvas.TextWidth(FPickList.Items[I]);
- if Y > J then J := Y;
- end;
- FPickList.ClientWidth := J + 4;
- end;
- {
- P := Parent.ClientToScreen(Point(Left, Top));
- Y := P.Y + Height;
- // SystemParametersInfo(SPI_GETWORKAREA, 0, Pointer(@WorkArea), 0);
- SystemParametersInfoEh(SPI_GETWORKAREA, 0, WorkArea, 0);
- if ((Y + FActiveList.Height > WorkArea.Bottom) and (P.Y - FActiveList.Height >= WorkArea.Top)) or
- ((P.Y - FActiveList.Height < WorkArea.Top) and (WorkArea.Bottom - Y < P.Y - WorkArea.Top))
- then
- begin
- if P.Y - FActiveList.Height < WorkArea.Top then
- FActiveList.Height := P.Y - WorkArea.Top;
- Y := P.Y - FActiveList.Height;
- FActiveList.Perform(cm_SetSizeGripChangePosition, Ord(sgcpToTop), 0);
- end else
- begin
- if Y + FActiveList.Height > WorkArea.Bottom then
- FActiveList.Height := WorkArea.Bottom - Y;
- FActiveList.Perform(cm_SetSizeGripChangePosition, Ord(sgcpToBottom), 0);
- end;
- //Drop Down Width
- if (FActiveList.Width > WorkArea.Right - WorkArea.Left) then
- FActiveList.Width := WorkArea.Right - WorkArea.Left;
- if (P.X + FActiveList.Width > WorkArea.Right) then
- begin
- P.X := WorkArea.Right - FActiveList.Width;
- FActiveList.Perform(cm_SetSizeGripChangePosition, Ord(sgcpToLeft), 0);
- end else
- FActiveList.Perform(cm_SetSizeGripChangePosition, Ord(sgcpToRight), 0);
- }
- if MRUList.DroppedDown then
- MRUListCloseUp(MRUList, False);
- if BiDiMode = bdRightToLeft
- then ADropDownAlign := daRight
- else ADropDownAlign := daLeft;
- P := AlignDropDownWindow(Self, FActiveList, ADropDownAlign);
- //To avoid overlapping IME windows need to use HWND_NOTOPMOST instead of HWND_TOP
- SetWindowPos(FActiveList.Handle, {HWND_NOTOPMOST} HWND_TOP, P.X, P.Y, 0, 0,
- SWP_NOSIZE or SWP_NOACTIVATE or SWP_SHOWWINDOW);
- if FActiveList = FDataList then
- begin
- FDataList.Visible := True; //???
- FDataList.SizeGrip.Visible := Column.DropDownSizing;
- FDataList.RowCount := FDataList.RowCount; //To update row count for horz scroll bar
- end
- else if FActiveList = FPickList then
- FPickList.SizeGrip.Visible := Column.DropDownSizing
- else if FActiveList = FPopupCalculator then
- FPopupCalculator.Visible := True; //???
- if FActiveList = FDataList then
- FDataList.SizeGripResized := False
- else if FActiveList = FPickList then
- FPickList.SizeGripResized := False;
- //FActiveList.Visible := True;
- FListVisible := True;
- Invalidate;
- Windows.SetFocus(Handle);
- FEditButtonControlList[0].EditButtonControl.AlwaysDown := True;
- FDroppedDown := True;
- end;
- end;
- procedure TDBGridInplaceEdit.CloseUp(Accept: Boolean);
- var
- MasterFields: TObjectList;
- ListValue: Variant;
- CurColumn: TColumnEh;
- CanChange: Boolean;
- PopupCalculatorIntf: IPopupCalculatorEh;
- begin
- ListValue := Null;
- CurColumn := Grid.Columns[Grid.SelectedIndex];
- if (FActiveList <> nil) and (FActiveList.HandleAllocated) and
- ((GetFocus = FActiveList.Handle) or
- (GetParent(GetFocus) = FActiveList.Handle)) then
- SetFocus;
- if FListVisible then
- begin
- with FEditButtonControlList[0].EditButtonControl do
- AlwaysDown := False;
- if FLockCloseList then Exit;
- if GetCapture <> 0 then SendMessage(GetCapture, WM_CANCELMODE, 0, 0);
- if FActiveList = FDataList then
- begin
- ListValue := FDataList.KeyValue;
- if FDataList.SizeGripResized then
- begin
- CurColumn.DropDownRows := FDataList.RowCount;
- CurColumn.FDropDownWidth := FDataList.Width; //Assign to FValue to avoid nil FActiveList when Tab
- end;
- if FListColumnMothed then
- CurColumn.DropDownSpecRow.CellsText := FDataList.SpecRow.CellsText;
- end else if FActiveList = FPopupMonthCalendar then
- begin //MonthCalendar
- end else if FPickList = FActiveList then
- begin
- if FPickList.ItemIndex <> -1 then
- begin
- if Assigned(CurColumn.KeyList) and (CurColumn.KeyList.Count > 0)
- then ListValue := CurColumn.KeyList.Strings[FPicklist.ItemIndex]
- else ListValue := FPickList.Items[FPicklist.ItemIndex];
- end;
- if PickList.SizeGripResized then
- begin
- CurColumn.DropDownRows := PickList.ClientHeight div FPickList.ItemHeight;
- CurColumn.FDropDownWidth := PickList.Width; //Assign to FValue to avoid nil FActiveList when Tab
- end;
- end;
- SetWindowPos(FActiveList.Handle, 0, 0, 0, 0, 0, SWP_NOZORDER or
- SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE or SWP_HIDEWINDOW);
- FActiveList.Visible := False;
- FDroppedDown := False;
- FListVisible := False;
- if Assigned(FDataList) then
- begin
- FDataList.AutoFitColWidths := False;
- FDataList.ListSource := nil;
- end;
- FLookupSource.Dataset := nil;
- Invalidate;
- ShowCaret(Handle);
- if Accept then
- begin
- if FActiveList = FDataList then // Lookup
- with Grid, Columns[SelectedIndex].Field do
- begin
- MasterFields := TObjectList.Create(False);
- try
- Dataset.GetFieldList(MasterFields, KeyFields);
- if FieldsCanModify(MasterFields) and Grid.CanEditModifyText and
- CurColumn.CanModify(True) then
- begin
- DataSet.Edit;
- try
- CanChange := Grid.Datalink.Editing;
- if CanChange then
- begin
- Grid.Datalink.Modified;
- //Dataset.FieldValues[KeyFields] := ListValue;
- Grid.FEditKeyValue := ListValue;
- Grid.FEditText := FDataList.SelectedItem;
- //MasterField.Value := ListValue;
- end;
- except
- on Exception do
- begin
- Self.Text := CurColumn.Field.Text + ' '; //May be delphi bag. But without ' ' don't assign
- raise;
- end;
- end;
- Self.Text := FDataList.SelectedItem;
- SelectAll;
- end;
- finally
- MasterFields.Free;
- end;
- end
- else if (FActiveList = FPopupMonthCalendar) then
- begin
- with Grid, CurColumn.Field do
- if CurColumn.CanModify(True) and CanEditModifyText then
- begin
- DataSet.Edit;
- CurColumn.UpdateDataValues(DateToStr(TDateTime(FPopupMonthCalendar.Date)), Variant(FPopupMonthCalendar.Date), False);
- //AsDateTime := FPopupMonthCalendar.Date;
- end;
- end
- else if (FActiveList = FPopupCalculator) then
- begin
- if CurColumn.CanModify(True) and Grid.CanEditModifyText then
- begin
- if Supports(FPopupCalculator, IPopupCalculatorEh, PopupCalculatorIntf) then
- if VarType(PopupCalculatorIntf.Value) in
- [varDouble, varSmallint, varInteger, varSingle, varCurrency]
- then
- begin
- Text := FloatToStr(PopupCalculatorIntf.Value);
- Grid.FEditText := Text;
- SelectAll;
- end;
- end;
- end
- else if (not VarIsNull(ListValue)) and Grid.CanEditModifyText then
- with Grid, CurColumn.Field do
- if Assigned(CurColumn) and Assigned(CurColumn.KeyList) and (CurColumn.KeyList.Count > 0) then
- begin
- if (FPicklist.ItemIndex >= 0) then
- begin
- Self.Text := FPickList.Items[FPicklist.ItemIndex];
- Grid.FEditText := Self.Text;
- UpdateImageIndex;
- end
- end else
- begin
- Self.Text := ListValue;
- Grid.FEditText := ListValue;
- UpdateImageIndex;
- end;
- end else if FActiveList = FDataList then
- Text := Grid.FEditText
- else if FActiveList = FPickList then
- if CurColumn.GetColumnType = ctKeyPickList then
- begin
- Text := Grid.FEditText;
- end else
- Text := Grid.FEditText;
- end;
- end;
- function StringsLocate(StrList: TStrings; Str: string; Options: TLocateOptions): Integer;
- function Compare(S1, S2: string): Integer;
- begin
- if loCaseInsensitive in Options
- then Result := NlsCompareText(S1, S2)
- else Result := NlsCompareStr(S1, S2);
- end;
- var i: Integer;
- S: string;
- begin
- Result := -1;
- for i := 0 to StrList.Count - 1 do
- begin
- if loPartialKey in Options
- then S := Copy(StrList.Strings[i], 1, Length(Str))
- else S := StrList.Strings[i];
- if NlsCompareText(S, Str) = 0 then
- begin
- Result := i;
- Break;
- end;
- end;
- end;
- procedure TDBGridInplaceEdit.LocateListText;
- var AColumn: TColumnEh;
- begin
- with Grid do AColumn := Columns[SelectedIndex];
- if not AColumn.CanModify(True) then Exit;
- if (EditStyle = esDataList) then
- begin
- Grid.FEditText := Text;
- if (AColumn.UsedLookupDataSet <> nil) and
- AColumn.UsedLookupDataSet.Locate(AColumn.Field.LookupResultField, Text, [loCaseInsensitive]) then
- Grid.FEditKeyValue :=
- AColumn.UsedLookupDataSet.FieldValues[AColumn.Field.LookupKeyFields]
- else
- Grid.FEditKeyValue := Null;
- end else
- Grid.FEditText := Text;
- end;
- type
- TWinControlCracker = class(TWinControl) end;
- procedure TDBGridInplaceEdit.KeyDown(var Key: Word; Shift: TShiftState);
- var
- MasterFields: TObjectList;
- Field: TField;
- Y: Integer;
- S: string;
- eb: TEditButtonEh;
- AutoRepeat: Boolean;
- procedure SendToParent;
- begin
- Grid.KeyDown(Key, Shift);
- Key := 0;
- end;
- begin
- if (EditStyle in [esEllipsis, esDropDown]) and (Key = VK_RETURN) and (Shift = [ssCtrl]) then
- begin
- KillMessage(Handle, WM_CHAR);
- Grid.EditButtonClick;
- end else
- if (Key = VK_DELETE) and (Shift = []) and (Column.GetColumnType in [ctLookupField, ctKeyPickList])
- {(EditStyle in [esDataList,esPickList])}
- and Column.CanModify(False) then
- begin
- if (SelStart = 0) and (SelLength = Length(Text)) and Column.CanModify(True) then // All text seleted
- begin
- if EditStyle = esDataList then //lookup
- begin
- Field := Column.Field;
- MasterFields := TObjectList.Create(False);
- try
- Field.Dataset.GetFieldList(MasterFields, Field.KeyFields);
- if FieldsCanModify(MasterFields) then
- begin
- Field.DataSet.Edit;
- //for i := 0 to MasterFields.Count-1 do TField(MasterFields[i]).Clear;
- //MasterField.Clear;
- Grid.Datalink.Modified;
- Grid.FEditKeyValue := Null;
- Grid.FEditText := '';
- Text := '';
- if Assigned(FDataList) then FDataList.KeyValue := Grid.FEditKeyValue;
English
