📄 generatormessagesgrid.pas
字号:
//Handles the scrolling of the grid.
procedure ModifyScrollBar(ScrollBar, ScrollCode, Pos: Cardinal;
UseRightToLeft: Boolean);
//Selects whole rows when this option is set.
procedure MoveRowSelection(NewCurrent: TGMGridCoord;
MoveAnchor: Boolean);
//Calculates the column to move a column to and handles the needed
//horizontal scrolling of the grid.
procedure MoveAndScroll(Mouse, CellHit: Integer;
var DrawInfo: TGridDrawInfo;
var Axis: TGridAxisDrawInfo; Scrollbar: Integer;
const MousePt: TPoint);
//Sets the focus inside the grid to another cell.
procedure MoveCurrent(ACol, ARow: Integer; MoveAnchor, Show: Boolean);
//Changes the visible part by scrolling it to the specified cell.
procedure MoveTopLeft(ALeft, ATop: Integer);
//Shows the new selection of cells within the grid.
procedure SelectionMoved(const OldSel: TGMGridRect);
//Scrolls the shown part of the grid by the specified number of pixels.
procedure ScrollDataInfo(DX, DY: Integer; var DrawInfo: TGridDrawInfo);
//Called when the grid is scrolled to update the view.
procedure TopLeftMoved(const OldTopLeft: TGMGridCoord);
//Reflects the current position in the scroll bars.
procedure UpdateScrollPos;
//Sets the maximum range of the scroll bars.
procedure UpdateScrollRange;
//Sets the minimum size of a column to show all of its visible content.
procedure AutoColSizing(ACol: TGMColumnShowed);
//Moves a column to another position.
procedure MoveColumn(FromIndex, ToIndex: Integer);
//Searches the next message whose text of a field starts with the text.
function DoQuickSearch(const Search: String; OriginalStartIndex: Integer;
Field: TGMColumnShowed;
RestartSearch: Boolean): Boolean;
//Returns the field shown in the specified column.
function GetColumn(Index: Integer): TGMColumnShowed;
//Returns the width of columns showing the specified field.
function GetColWidths(Field: TGMColumnShowed): Integer;
//Returns the height of a row showing the data.
function GetRowHeights(Index: Integer): Integer;
//Returns the current selection rectangle.
function GetSelection: TGMGridRect;
//Calculates the number of the currently (even partly) visible columns.
function GetVisibleColCount: Integer;
//Calculates the number of (even partly) visible rows.
function GetVisibleRowCount: Integer;
//Returns the width of the specified column.
function GetWidthOfCol(Index: Integer): Integer;
//Sets the border style of the component.
procedure SetBorderStyle(Value: TBorderStyle);
//Focuses the specified column in the current row.
procedure SetCol(Value: Integer);
//Changes the number of shown columns in the grid.
procedure SetColCount(Value: Integer);
//Sets the field to be shown in the specified column.
procedure SetColumn(Index: Integer; Value: TGMColumnShowed);
//Sets the widths of all columns showing the specified field.
procedure SetColWidths(Field: TGMColumnShowed; Value: Integer);
//Sets the widths of all columns to the specified value.
procedure SetDefaultColumnWidth(Value: Integer);
//Sets the first column to be currently shown in the visible area.
procedure SetLeftCol(Value: Integer);
//Sets the options of the grid.
procedure SetOptions(Value: TGMGridOptions);
//Sets the pop-up menu of the component.
procedure SetPopupMenu(Value: TPopupMenu);
//Focuses the specified row in the current column.
procedure SetRow(Value: Integer);
//Changes the number of rows in the grid.
procedure SetRowCount(Value: Integer);
//Sets the height of the rows showing the data.
procedure SetRowHeight(Value: Integer);
//Sets which of the scroll bars should be shown in the component.
procedure SetScrollBars(Value: TScrollStyle);
//Sets the current selection rectangle inside the grid.
procedure SetSelection(Value: TGMGridRect);
//Sets whether and how the titles of the columns should be shown.
procedure SetShowTitle(Value: TShowTitle);
//Sets the height of the row showing the titles of the columns.
procedure SetTitleHeight(Value: Integer);
//Sets the first row to be currently shown in the visible area.
procedure SetTopRow(Value: Integer);
//Reads the widths of the columns from the resource stream.
procedure ReadColWidths(Reader: TReader);
//Reads the heights of the rows from the resource stream.
procedure ReadRowHeights(Reader: TReader);
//Writes the widths of the columns into the resource stream.
procedure WriteColWidths(Writer: TWriter);
//Writes the heights of the rows into the resource stream.
procedure WriteRowHeights(Writer: TWriter);
//Called when the popup menu pops up.
procedure NotifyPopUp(Sender: TObject);
//Called when a new column is added via the popup menu.
procedure NotifyAddColumn(Sender: TObject);
//Called when the shown field of a column is changed via the popup menu.
procedure NotifyChangeColumnTypToTag(Sender: TObject);
//Called when sub menu of the options within the popup menu is shown.
procedure NotifyPopUpOptions(Sender: TObject);
//Called when an option of the grid is toggled via the popup menu.
procedure NotifyChangeOptionByTag(Sender: TObject);
//Called when the mode of the title row is toggled via the popup menu.
procedure NotifyChangeTitleRow(Sender: TObject);
//Called when the last column is hidden via the popup menu.
procedure NotifyDeleteColumn(Sender: TObject);
//Called when the font used within the grid is changed via the popup menu.
// procedure NotifyChangeFont(Sender: TObject);
//Called when the canceling of the current mode is requested.
procedure CMCancelMode(var Msg: TMessage); message CM_CANCELMODE;
//Called when the visual 3D state of the component is changed.
procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
//Called during designing state to determine active areas within the grid.
procedure CMDesignHitTest(var Msg: TCMDesignHitTest);
message CM_DESIGNHITTEST;
//Called when the grid is made visible or hidden.
procedure CMShowingChanged(var Message: TMessage);
message CM_SHOWINGCHANGED;
//Called when the canceling of the current mode is requested.
procedure WMCancelMode(var Msg: TWMCancelMode); message WM_CANCELMODE;
//Returns the kind of keys interpreted by the component.
procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
//Called when the component is scrolled horizontally.
procedure WMHScroll(var Msg: TWMHScroll); message WM_HSCROLL;
//Called when the focus leaves the component.
procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS;
//Called to check whether the mouse pointer is above a hot spot.
procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
//Called to set the appearance of the mouse pointer as it moves.
procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;
//Called when the component is focused.
procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS;
//Called when the size of the component is changed.
procedure WMSize(var Msg: TWMSize); message WM_SIZE;
//Called to scroll the component or to abort the quick search.
procedure WMTimer(var Msg: TWMTimer); message WM_TIMER;
//Called when the component is scrolled vertically.
procedure WMVScroll(var Msg: TWMVScroll); message WM_VSCROLL;
protected
//Defines additional properties to be saved into the resource stream.
procedure DefineProperties(Filer: TFiler); override;
//Called during design time to synchronize the designer with the component.
procedure UpdateDesigner;
//Sets properties of the component to be created.
procedure CreateParams(var Params: TCreateParams); override;
//Allows the navigation in the grid with the special keys.
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
//Starts a quick search in the current column if the option is enabled.
procedure KeyPress(var Key: Char); override;
//Called when a mouse button is pressed.
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
//Handles selecting cells and moving and resizing colums when the the mouse
//pointer is moved inside the component while a button is pressed.
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
//Finishes selecting cells or moving columns when a mouse button is
//released.
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
//Ignores double click messages, events will be called in MouseDown.
procedure DblClick; override;
//Handles the scrolling with the mouse wheel.
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
override;
//Handles the scrolling with the mouse wheel.
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
override;
//Handles the event when the user clicks the title of a column.
procedure FixedClick(ACol: Integer);
//Handles the event when the user double clicks the title of a column.
procedure FixedDblClick(ACol: Integer);
//Stops the current quick search when the focus leaves the component.
procedure DoExit; override;
//Checks whether a cell can be selected.
function SelectCell(ACol, ARow: Integer): Boolean; virtual;
//Called after the number of columns or rows in the grid has been changed.
procedure SizeChanged(OldColCount, OldRowCount: Integer); dynamic;
//Checks during design time whether the mouse pointer is above a hot spot.
function Sizing(X, Y: Integer): Boolean;
//Handles the event when the grid is scrolled.
procedure TopLeftChanged; dynamic;
//Handles the scrolling of the grid while selecting a range of cells.
procedure TimedScroll(Direction: TGridScrollDirection); dynamic;
//Handles the change in the width (or shown field) of a column.
procedure ColWidthsChanged; dynamic;
//Handles the change in the height of the rows.
procedure RowHeightChanged; dynamic;
//Paints the cell as a title of a column.
procedure PaintColumnTitle(ACol: Integer; ARect: TRect);
//Paints the grid.
procedure Paint; override;
property HitTest: TPoint read FHitTest;
public
//Creates and initializes the component.
constructor Create(AOwner: TComponent); override;
//Makes sure the currently selected cell is visible.
procedure ShowCurrent;
//Return the cell below the specified coordinates in the grid.
function MouseCoord(X, Y: Integer): TGMGridCoord;
//Determines the field shown in the specified column.
function GetFieldByColumn(ACol: Integer;
var Field: TGMColumnShowed): Boolean;
//Returns the number of fixed rows in the grid, either 0 or 1.
function GetFixedRows: Integer;
//Returns the width of a column by its index.
function GetColumnWidthByIndex(Col: Integer): Integer;
//Creates a default pop up menu for the grid to set its options.
procedure CreatePopupMenu;
//Sets the primary sort order for the grid.
procedure SortListBy(Field: TGMColumnShowed; Descending: Boolean = False);
//Sets the whole sort order of the grid.
procedure SetSortOrder(const Order: array of TGMSortOrder);
//Returns the current sorting order of the grid.
function GetSortOrder(var Order: TGMSortOrders): Integer;
//Sorts the list by its current sort order.
procedure SortList;
//Fills the grid with a new content.
procedure SetListContent(MessageList: TGeneratorMessageList;
MessageDescriptions: TMessageDescriptionsList;
const ShownIndices: array of Integer);
//Returns a messages by the row showing it within the grid.
procedure ReadMessage(Row: Integer; var Result: TGeneratorMessage);
//Returns the texts of the columns in the specified row separated by #9.
function GetTabulatedRowText(Row: Integer): String;
property Canvas;
property Col: Integer read FCurrent.X write SetCol;
property Columns[Index: Integer]: TGMColumnShowed read GetColumn
write SetColumn;
property ColWidths[Field: TGMColumnShowed]: Integer read GetColWidths
write SetColWidths;
property GridHeight: Integer read GetGridHeight;
property GridWidth: Integer read GetGridWidth;
property LeftCol: Integer read FTopLeft.X write SetLeftCol;
property Row: Integer read FCurrent.Y write SetRow;
property Selection: TGMGridRect read GetSelection write SetSelection;
property TitleHeight: Integer read FTitleHeight write SetTitleHeight;
property ShowTitle: TShowTitle read FShowTitle write SetShowTitle;
property TopRow: Integer read FTopLeft.Y write SetTopRow;
property VisibleColCount: Integer read GetVisibleColCount;
property VisibleRowCount: Integer read GetVisibleRowCount;
published
property Align;
property Anchors;
property BiDiMode;
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle
default bsSingle;
property Color default clWindow;
property ColCount: Integer read FColCount write SetColCount default 6;
property Constraints;
property Ctl3D;
property DefaultColumnWidth: Integer read FDefaultColumnWidth
write SetDefaultColumnWidth
default 35;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property Options: TGMGridOptions read FOptions write SetOptions;
property ParentBiDiMode;
property ParentColor default False;
property ParentCtl3D;
property ParentFont;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -