📄 easygrid_0811.pas
字号:
X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
// 没有处理鼠标右键
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure AdjustSize(Index, Amount: Longint; Rows: Boolean); reintroduce; dynamic;
function BoxRect(ALeft, ATop, ARight, ABottom: Longint): TRect;
procedure DoExit; override;
function CanEditAcceptKey(Key: Char): Boolean; dynamic;
function CanGridAcceptKey(Key: Word; Shift: TShiftState): Boolean; dynamic;
function CanEditModify: Boolean; dynamic;
function CanEditShow: Boolean; virtual;
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
function GetEditText(ACol, ARow: Longint): string; dynamic;
// 把 InplaceEditor 的内容回传给 Cell
procedure SetEditText(ACol, ARow: Longint; Value: string); dynamic;
function GetEditMask(ACol, ARow: Longint): string; dynamic;
function GetEditLimit: Integer; dynamic;
function GetGridWidth: Integer;
function GetGridHeight: Integer;
procedure HideEditor;
procedure ShowEditor;
//procedure ShowDBEditor;
// 显示 InplaceEditor 并把 Char 发送给 InplaceEditor
procedure ShowEditorChar(Ch: Char);
procedure InvalidateEditor;
// 画 Cell 背景与边框(如果有边框)
procedure DrawCell(ACol, ARow: Longint; TextRect, ClipR: TRect;
AState: TEasyGridDrawState); virtual;
function GetCellOutText(CurCol,CurRow:Integer):String;
procedure DefineProperties(Filer: TFiler); override;
procedure MoveColRow(ACol, ARow: Longint; MoveAnchor, Show: Boolean);
function SelectCell(ACol, ARow: Longint): Boolean; virtual;
procedure SizeChanged(OldColCount, OldRowCount: Longint); dynamic;
// 根据当前鼠标位置判断能否处于 Sizing 状态
function Sizing(X, Y: Integer): Boolean;
procedure ScrollData(DX, DY: Integer);
procedure TopLeftChanged; dynamic;
procedure TimedScroll(Direction: TEasyGridScrollDirection); dynamic;
procedure Paint; override;
function GetCellRect(ACol,ARow:Integer):TRect;
procedure ResizeDBGrid;
procedure MoveDBGrid(const DrawInfo: TEasyGridDrawInfo);
procedure ColWidthsChanged; dynamic;
procedure RowHeightsChanged; dynamic;
procedure UpdateDesigner;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
property Col: Longint read FCurrent.X write SetCol;
property Color default clWindow;
property ColCount: Longint read FColCount write SetColCount default 5;
//property CellProp[I,J:Integer]: PCellInfo read GetCellProperty write SetCellProperty;
property ColWidths[Index: Longint]: Integer read GetColWidths write SetColWidths;
property DefaultColWidth: Integer read FDefaultColWidth write SetDefaultColWidth default 80;
property DefaultDrawing: Boolean read FDefaultDrawing write FDefaultDrawing default True;
property DefaultRowHeight: Integer read FDefaultRowHeight write SetDefaultRowHeight default 30;
property EditorMode: Boolean read FEditorMode write SetEditorMode;
property FixedLineColor: TColor read FFixedLineColor write SetFixedLineColor default clBlack;
property ClientLineColor: TColor read FClientLineColor write SetClientLineColor default clSilver;
property FixedCols: Integer read FFixedCols write SetFixedCols default 0;
property FixedRows: Integer read FFixedRows write SetFixedRows default 0;
property GridHeight: Integer read GetGridHeight;
property GridLineWidth: Integer read FGridLineWidth write SetGridLineWidth default 1;
property GridWidth: Integer read GetGridWidth;
property HitTest: TPoint read FHitTest;
property InplaceEditor: TInplaceEdit read FInplaceEdit;
property LeftCol: Longint read FTopLeft.X write SetLeftCol;
property Options: TEasyGridOptions read FOptions write SetOptions
default [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine,
goRangeSelect];
property ParentColor default False;
property Row: Longint read FCurrent.Y write SetRow;
property RowCount: Longint read FRowCount write SetRowCount default 5;
property RowHeights[Index: Longint]: Integer read GetRowHeights write SetRowHeights;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssBoth;
property Selection: TGridRect read GetSelection write SetSelection;
property ColCanSizes[Index: Longint]: Boolean read GetColCanSizes write SetColCanSizes;
property RowCanSizes[Index: Longint]: Boolean read GetRowCanSizes write SetRowCanSizes;
property TabStops[Index: Longint]: Boolean read GetTabStops write SetTabStops;
property TopRow: Longint read FTopLeft.Y write SetTopRow;
property VisibleColCount: Integer read GetVisibleColCount;
property VisibleRowCount: Integer read GetVisibleRowCount;
property TabStop default True;
property GridCanCopyMove: Boolean read FGridCanCopyMove write FGridCanCopyMove default True;
property GridCanFill: Boolean read FGridCanFill write FGridCanFill default True;
property ShowPopup: Boolean read FShowPopup write FShowPopup default True;
property AutoUpdate: Boolean read FAutoUpdate write SetAutoUpdate default True;
property AlwaysDrawFocus: Boolean read FAlwaysDrawFocus write FAlwaysDrawFocus default False;
property ClientSizeable: Boolean read FClientSizeable write FClientSizeable default False;
property ShowColTitle: Boolean read FShowColTitle write SetColTitle default True;
property ShowRowTitle: Boolean read FShowRowTitle write SetRowTitle default True;
property TitleColor: TColor read FTitleColor write SetTitleColor default clBtnFace;
property HighLightColor: TColor read FHighLightColor write SetHighLightColor default clBlack;
property HighLightTextColor: TColor read FHighLightTextColor write SetHighLightTextColor default clWhite;
property FocusedTitleColor: TColor read FFocusedTitleColor write SetFocusedTitleColor default clBlack;
property Aligns[ACol, ARow: Integer]: TAlignMode read GetAlignMode write SetAlignMode;
property ForeTexts[ACol, ARow: Integer]: string read GetForeText write SetForeText;
property BackTexts[ACol, ARow: Integer]: string read GetBackText write SetBackText;
property Colors[ACol, ARow: Integer]: TColor read GetColors write SetColors;
property Merges[ACol, ARow: Integer]: PGridRect read GetMerges;
property Cells[ACol,ARow:Integer]:PCellInfo read GetCell;
property DBGrids[ACol,ARow:Integer]:TDrawDBGrid read GetDrawDBGrid;
property DBGridsCount:Integer read GetDBGridsCount write FDBGridsCount;
property CellDataStyle: TDataStyle read FDataStyle write SetCellDataStyle default dsText;
property CellAlignMode: TAlignMode read FAlignMode write SetCellAlignMode default taTopLeft;
property CellShowForeText: Boolean read FShowForeText write SetCellShowForeText default True;
property CellLock:Boolean read FCellLock write SetCellLock default False;
property CellReadOnly: Boolean read FReadOnly write SetCellReadOnly default False;
property CellAutoWordBreak: Boolean read FAutoWordBreak write SetCellAutoWordBreak default True;
property CellLineWidth: Integer read FCellLineWidth write SetCellLineWidth default 1;
property CellPenStyle: TPenStyle read FCellPenStyle write SetCellPenStyle default psSolid;
property CellAllowNegative: Boolean read FAllowNegative write SetCellAllowNegative default True;
property CellTrailingZero: Boolean read FTrailingZero write SetCellTrailingZero default False;
property CellZeroNull: Boolean read FZeroNull write SetCellZeroNull default True;
property CellThousandSep: Boolean read FThousandSep write SetCellThousandSep default True;
property CellMaxLength: Integer read FMaxLength write SetCellMaxLength default 255;
property CellIntLength: Integer read FIntLength write SetCellIntLength default 3;
property CellDecLength: Integer read FDecLength write SetCellDecLength default 2;
property CellColor: TColor read FColor write SetCellColor default clWhite;
property CellFontSize: Integer read FFontSize write SetCellFontSize default 9;
property CellFontColor: TColor read FFontColor write SetCellFontColor default clBlack;
property CellFontStyle: TFontStyles read FFontStyle write SetCellFontStyle default [];
property RunMode: TRunMode read FRunMode write SetRunMode; // add by liuzhigang in 2004.07.29
property DataSource: TDataSource read GetDataSource write SetDataSource;
public
EasyGridPopup: TPopupMenu; // 弹出式菜单
EasyGridPageInfo: TEasyGridPageInfo; // 页面设置信息
PageDrawInfoList: TPageDrawInfoList; // 页面打印绘画信息
FormCellProp: TFormCellProp; // 单元格属性设置窗口指针
FormPreview: TFormPreview; // 打印预览窗口指针
FormPageSetup: TFormPageSetup; // 打印页面设置窗口指针
FormCellField: TFormCellField;
// 构造函数
constructor Create(AOwner: TComponent); override;
// 析构函数
destructor Destroy; override;
// 计算网格的物理坐标(相对于 Grid 的左上角)
function CellRect(ACol, ARow: Longint): TRect;
// 计算物理坐标对应的网格的坐标
procedure MouseToCell(X, Y: Integer; var ACol, ARow: Longint);
// 强制更新 ARect 区域(Grid 坐标)
procedure InvalidateRect(ARect: TGridRect);
// 更新整个 Grid
procedure InvalidateGrid;
// 刷新一个 Cell ( Grid 坐标单位)
procedure InvalidateCell(ACol, ARow: Longint);
// 刷新一列 ( Grid 坐标单位)
procedure InvalidateCol(ACol: Longint);
// 刷新一行 ( Grid 坐标单位)
procedure InvalidateRow(ARow: Longint);
// 合并网格
procedure SetMerges(AMergeRect: TRect; WantPrompt: Boolean = False);
// 拆分网格
procedure DeleteMerges(AMergeRect: TRect);
// 把一个范围内的 Cells 恢复到缺省状态
procedure RestoreCells(DestRestoreRect: TRect);
// 清除一个范围内的 Cells 的文本
procedure ClearCells(DestClearRect: TRect);
// 拷贝一个范围内的 Cells 内容到剪贴板中
procedure CopyCells(DestCopyRect: TRect);
// 拷贝一个范围内的 Cells 内容到剪贴板中并清除 Cells 内容
procedure CutCells(DestCutRect: TRect);
// 填充网格内容
procedure FillCells(SrcRect: TRect; Offset: Integer; FillStyle: TFillStyle);
// 从剪贴板中粘贴 Cells 内容到一个范围内
procedure PasteCells(DestPasteCoord: TPoint);
// 设置某一行的 Cell 属性值
procedure SetColProperty(ColIndex: Integer; PropertyName: TPropertyName; Value: Pointer);
// 设置某一行的 Cell 属性值
procedure SetRowProperty(RowIndex: Integer; PropertyName: TPropertyName; Value: Pointer);
// 设置某个范围内的 Cell 属性值
procedure SetRangeProperty(Range: TRect; PropertyName: TPropertyName; Value: Pointer);
// 设置整个 Grid 的 Cell 属性值
procedure SetGridProperty(PropertyName: TPropertyName; Value: Pointer);
// 清空剪贴板内容
procedure ClearClipBoard;
// 打开剪贴板
procedure OpenClipBoard;
// 关闭剪贴板
procedure CloseClipBoard;
// 判断剪贴板是否可用
function ClipBoardAvailable: Boolean;
// 向右插入一个网格
procedure InsertCellRight(InsertRect: TRect);
// 向下插入一个网格
procedure InsertCellDown(InsertRect: TRect);
// 插入一行
procedure InsertRow(InsertRect: TRect);
// 插入一列
procedure InsertCol(InsertRect: TRect);
// 向右删除一个网格
procedure DeleteCellRight(DeleteRect: TRect);
// 向下删除一个网格
procedure DeleteCellDown(DeleteRect: TRect);
// 删除一行
procedure DeleteRow(DeleteRect: TRect);
// 删除一列
procedure DeleteCol(DeleteRect: TRect);
// 显示设置单元格属性窗口
procedure SetCellProp(DefaultPage: Integer = -1);
// 显示设置单元格字段窗口
procedure SetCellField(DefaultPage: Integer = -1);
procedure SetCellNull(DefaultPage: Integer = -1);
procedure SetCellPicture(DefaultPage: Integer = -1);
procedure SetCellDBGrid(DefaultPage: Integer = -1);
// 把 Grid 保存到文件中
procedure SaveToFile(FileName: string);
// 把 Grid 保存到文件流中
procedure SaveToStream(FileStream: TStream);
// 从文件中读出 Grid 内容
procedure LoadFromFile(FileName: string);
// 从文件流中读出 Grid 内容
procedure LoadFromStream(FileStream: TStream);
// 打印 Grid
procedure Print;
// 打印 Grid 页
procedure PrintPage(DrawCanvas: TCanvas; DrawRect: TRect; PageIndex: Integer;
Printing: Boolean);
// 显示打印对话框
procedure PrintDialog;
// 显示打印预览窗口
procedure Preview;
// 显示打印机设置对话框
function PrinterSetup: Boolean;
// 显示页面设置对话框
procedure PageSetup;
end;
TEasyGrid = class(TCustomEasyGrid)
public
property Canvas;
property Col;
property ColWidths;
property Aligns;
property ForeTexts;
property BackTexts;
property Colors;
property Merges;
property Cells;
property EditorMode;
property GridHeight;
property GridWidth;
property LeftCol;
property Selection;
property Row;
property RowHeights;
property ColCanSizes;
property RowCanSizes;
property TabStops;
property TopRow;
////////////////////////////////////////////
property RunMode; // add by liuzhigang in 2004.07.29
{ Public declarations }
published
property Align;
property AlwaysDrawFocus;
property Anchors;
property AutoUpdate;
property BiDiMode;
property BorderStyle;
property ClientSizeable;
property CellDataStyle;
property CellAlignMode;
property CellShowForeText;
property CellReadOnly;
property CellAutoWordBreak;
property CellLineWidth;
property CellPenStyle;
property CellAllowNegative;
property CellTrailingZero;
property CellZeroNull;
property CellThousandSep;
property CellMaxLength;
property CellIntLength;
property CellDecLength;
property CellColor;
property CellFontSize;
property CellFontColor;
property CellFontStyle;
property Color;
property ColCount;
property Constraints;
property Ctl3D;
property DefaultColWidth;
property DefaultRowHeight;
property DefaultDrawing;
property DragCursor;
property DragKind;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -