Class TCustomRBWDataGrid

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TCustomRBWDataGrid = class(TStringGrid)

Description

TCustomRBWDataGrid is the abstract ancestor of TRbwDataGrid and TRbwRowDataGrid.

Hierarchy

Overview

Fields

Private FBmpChecked: TBitMap;
Private FBmpDisabledChecked: TBitMap;
Private FBmpDisabledGrayed: TBitMap;
Private FBmpDisabledUnchecked: TBitMap;
Private FBmpGrayed: TBitMap;
Private FBmpUnchecked: TBitMap;
Private FButton: TButton;
Private FButtonClicked: TSetEditEvent;
Private FButtonColor: TColor;
Private FCanEditModify: boolean;
Private FCanSelect: boolean;
Private FChecked: array of array of TCheckBoxState;
Private FColWidths: TIntegerDynArray;
Private FCombo: TComboBox;
Private FdgColumn: integer;
Private FdgRow: integer;
Private FGridState: TRBWGridStates;
Private FOnColMoving: TCheckMoveEvent;
Private FOnColSize: TColSizeEvent;
Private FOnRowMoving: TCheckMoveEvent;
Private FOptions: TGridOptions;
Private FStateChanged: TChangeCheckEvent;
Private Updating: boolean;

Methods

Private procedure AdjustCheckedArray;
Private procedure AdjustControls;
Private function GetCellVisible(ACol, ARow: Integer): boolean;
Private function GetChecked(const ACol, ARow: integer): boolean;
Private function GetColCount: integer;
Private function GetState(const ACol, ARow: integer): TCheckBoxState;
Private function LocalizeString(ANumberString: string): string;
Private function LocalStrToFloat(S: string): Extended;
Private procedure SetCells(ACol, ARow: Integer; const Value: string);
Private procedure SetColCount(const Value: integer);
Private procedure SetChecked(const ACol, ARow: integer; const Value: boolean);
Private procedure SetControls(X, Y: integer);
Private procedure SetOptions(const Value: TGridOptions);
Private procedure SetState(const ACol, ARow: integer; const Value: TCheckBoxState);
Protected procedure BoundsChanged; override;
Protected procedure ButtonClicked(Sender: TObject);
Protected function CanEditModify: Boolean; override;
Protected function CheckColumnDrag(var Origin, Destination: Integer; const MousePt: TPoint): Boolean; override;
Protected function CheckRowDrag(var Origin, Destination: Integer; const MousePt: TPoint): Boolean; override;
Protected procedure Click; override;
Protected function CollectionItem(const ACol, ARow: Longint): TCustomRowOrColumn; virtual; abstract;
Protected procedure ColumnMoved(FromIndex, ToIndex: Longint); override;
Protected procedure ColWidthsChanged; override;
Protected procedure ComboChange(Sender: TObject);
Protected function CreateEditor: TInplaceEdit; override;
Protected procedure DoEnter; override;
Protected procedure DoExit; override;
Protected procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
Protected function GetCells(ACol, ARow: Integer): string;
Protected procedure Loaded; override;
Protected procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
Protected procedure MoveControls; virtual;
Protected procedure RowHeightsChanged; override;
Protected procedure RowMoved(FromIndex, ToIndex: Longint); override;
Protected function SelectCell(ACol, ARow: Longint): Boolean; override;
Protected procedure SetdgColumn(const Value: integer); virtual;
Protected procedure SetdgRow(const Value: integer); virtual;
Protected procedure SetEditText(ACol, ARow: Longint; const Value: WideString); override;
Protected procedure TopLeftChanged; override;
Public constructor Create(AOwner: TComponent); override;
Public procedure DeleteColumn(ACol: Longint); override;
Public procedure DeleteRow(ARow: Longint); override;
Public destructor Destroy; override;
Public procedure InsertColumn(ACol: Integer); virtual;
Public procedure InsertRow(ARow: Integer); virtual;

Properties

Public property Cells[ACol, ARow: Integer]: string read GetCells write SetCells;
Public property CellVisible[ACol, ARow: Integer]: boolean read GetCellVisible;
Public property Checked[const ACol, ARow: integer]: boolean read GetChecked write SetChecked;
Public property dgColumn: integer read FdgColumn write SetdgColumn;
Public property dgRow: integer read FdgRow write SetdgRow;
Public property GridState: TRBWGridStates read FGridState;
Public property State[const ACol, ARow: integer]: TCheckBoxState read GetState write SetState;
Published property ButtonColor: TColor read FButtonColor write FButtonColor;
Published property ColCount: integer read GetColCount write SetColCount;
Published property OnButtonClicked: TSetEditEvent read FButtonClicked write FButtonClicked;
Published property OnColMoving: TCheckMoveEvent read FOnColMoving write FOnColMoving;
Published property OnColSize: TColSizeEvent read FOnColSize write FOnColSize;
Published property OnRowMoving: TCheckMoveEvent read FOnRowMoving write FOnRowMoving;
Published property OnStateChanged: TChangeCheckEvent read FStateChanged write FStateChanged;
Published property Options: TGridOptions read FOptions write SetOptions default [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect];

Description

Fields

Private FBmpChecked: TBitMap;

FBmpChecked : TBitMap;

FBmpChecked is a bitmap that represents a checkbox that is checked and enabled.

Private FBmpDisabledChecked: TBitMap;

FBmpDisabledChecked : TBitMap;

FBmpDisabledChecked is a bitmap that represents a checkbox that is checked and disabled.

Private FBmpDisabledGrayed: TBitMap;

FBmpDisabledGrayed : TBitMap;

FBmpDisabledGrayed is a bitmap that represents a checkbox that is in a grayed or indeterminate state and disabled.

Private FBmpDisabledUnchecked: TBitMap;

FBmpDisabledUnchecked : TBitMap;

FBmpDisabledUnchecked is a bitmap that represents a checkbox that is unchecked and disabled.

Private FBmpGrayed: TBitMap;

FBmpGrayed : TBitMap;

FBmpGrayed is a bitmap that represents a checkbox that is in a grayed or indeterminate state and enabled.

Private FBmpUnchecked: TBitMap;

FBmpUnchecked : TBitMap;

FBmpUnchecked is a bitmap that represents a checkbox that is unchecked and enabled.

Private FButton: TButton;

FButton : TButton;

FButton is a TButton that can appear in a cell if the ButtonUsed of the column is True.

Private FButtonClicked: TSetEditEvent;

FButtonClicked : TSetEditEvent;

FButtonClicked stores the address of the event handler for the OnButtonClicked event.

Private FButtonColor: TColor;

FButtonColor : TColor;

FButtonColor controls the color of the button that can appear in a cell if ButtonUsed is true.

Private FCanEditModify: boolean;

FCanEditModify : boolean;

FCanEditModify is set in SetControls and is used as the return value or CanEditModify.

Private FCanSelect: boolean;

FCanSelect : boolean;

FCanSelect is set to inherited SelectCell(ACol, ARow) in SelectCell. It is then used in SetControls to control whether a button or a combobox can appear or to determine whether the state of a checkbox should be changed.

Private FChecked: array of array of TCheckBoxState;

FChecked : array of array of TCheckBoxState;;

FChecked stores a TCheckBoxState of all the cells in the grid. See State.

Private FColWidths: TIntegerDynArray;

FColWidths : TIntegerDynArray;

FColWidths is a local copy of the inherited ColWidths property. It is used in calling the OnColSize event.

Private FCombo: TComboBox;

FCombo : TComboBox;

FCombo is a TComboBox that can appear in a cell if the Format of the column is rcfCombo.

Private FdgColumn: integer;

FdgColumn : integer;

See dgColumn.

Private FdgRow: integer;

FdgRow : integer;

See dgRow.

Private FGridState: TRBWGridStates;

FGridState : TRBWGridStates;

see GridState

Private FOnColMoving: TCheckMoveEvent;

FOnColMoving : TCheckMoveEvent;

FOnColMoving stores the address of the event handler for the OnColMoving event.

Private FOnColSize: TColSizeEvent;

FOnColSize : TColSizeEvent;

FOnColSize stores the address of the event handler for the OnColSize event.

Private FOnRowMoving: TCheckMoveEvent;

FOnRowMoving : TCheckMoveEvent;

FOnRowMoving stores the address of the event handler for the OnRowMoving event.

Private FOptions: TGridOptions;

FOptions : TGridOptions;

TCustomRBWDataGrid has to remove goEditing from the inherited Options. FOptions is used to store a copy of the original Options that can include goEditing so the grid can behave properly.

Private FStateChanged: TChangeCheckEvent;

FStateChanged : TChangeCheckEvent;

FStateChanged stores the address of the event handler for the OnStateChanged event.

Private Updating: boolean;

Updating is used when the number of columns or rows is being changed to prevent infinite recursion. Updating : boolean;

Methods

Private procedure AdjustCheckedArray;

AdjustCheckedArray sets the length of FChecked and FColWidths.

Private procedure AdjustControls;

AdjustControls adjusts the size of FCombo and FButton.

Private function GetCellVisible(ACol, ARow: Integer): boolean;

See CellVisible;

Private function GetChecked(const ACol, ARow: integer): boolean;

See Checked.

Private function GetColCount: integer;

See ColCount.

Private function GetState(const ACol, ARow: integer): TCheckBoxState;

See State.

Private function LocalizeString(ANumberString: string): string;

LocalizeString replaces commas with periods if DecimalSeparator is a period. Otherwise it replaces periods with DecimalSeparator.

Private function LocalStrToFloat(S: string): Extended;

LocalStrToFloat converts S to a number after first calling LocalizeString on S.

Private procedure SetCells(ACol, ARow: Integer; const Value: string);

See Cells. SetCells calls inherited SetCells after first updating FCombo.

Private procedure SetColCount(const Value: integer);

See ColCount.

Private procedure SetChecked(const ACol, ARow: integer; const Value: boolean);

See Checked.

Private procedure SetControls(X, Y: integer);

SetControls sets the position and properties of FCombo and FButton.

Private procedure SetOptions(const Value: TGridOptions);

Sets the inherited version of Options as well as the local copy (FOptions).

Private procedure SetState(const ACol, ARow: integer; const Value: TCheckBoxState);

See State.

Protected procedure BoundsChanged; override;

If the combo box or button are visible, their positions are adjusted.

Protected procedure ButtonClicked(Sender: TObject);

ButtonClicked is the event handler of the FButton OnClick event. It calls OnButtonClicked.

Protected function CanEditModify: Boolean; override;

CanEditModify is used to determine whether the user can type in a cell.

Protected function CheckColumnDrag(var Origin, Destination: Integer; const MousePt: TPoint): Boolean; override;

CheckColumnDrag calls the inherited CheckColumnDrag and then OnColMoving.

Protected function CheckRowDrag(var Origin, Destination: Integer; const MousePt: TPoint): Boolean; override;

CheckRowDrag calls the inherited CheckRowDrag and then OnRowMoving.

Protected procedure Click; override;

Click calls inherited Click and MoveControls.

Protected function CollectionItem(const ACol, ARow: Longint): TCustomRowOrColumn; virtual; abstract;

CollectionItem returns the TCustomRowOrColumn for a cell.

Protected procedure ColumnMoved(FromIndex, ToIndex: Longint); override;

calls inherited ColumnMoved and then adjusts the Checked array.

Protected procedure ColWidthsChanged; override;

ColWidthsChanged calls inherited ColWidthsChanged and MoveControls. It also updates FColWidths.

Protected procedure ComboChange(Sender: TObject);

ComboChange is the event handler for the Combobox OnChange event.

Protected function CreateEditor: TInplaceEdit; override;

Creates the cell editor.

Protected procedure DoEnter; override;

DoEnter calls inherited DoEnter and removes goEditing from inherited Options if the cell represents a boolean.

Protected procedure DoExit; override;

DoExit hides the button and combobox and then checks the contents of the last active cell.

Protected procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;

Shows a check box if the Format is boolean. Disables editing of boolean cells.

Protected function GetCells(ACol, ARow: Integer): string;

See Cells

Protected procedure Loaded; override;

Set the FixedCols and Options when the grid is loaded.

Protected procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;

MouseDown shows the combo box or button and toggles Checked.

Protected procedure MoveControls; virtual;

If required, MoveControls moves FCombo or FButton to the current cell.

Protected procedure RowHeightsChanged; override;

RowHeightsChanged calls inherited RowHeightsChanged and MoveControls.

Protected procedure RowMoved(FromIndex, ToIndex: Longint); override;

Calls the inherited RowMoved and then adjusts Checked.

Protected function SelectCell(ACol, ARow: Longint): Boolean; override;

SelectCell prevents the user from editing cells if it is False. It also is sets the private variable FCanSelect which is then used in SetControls to control whether a button or a combobox can appear or to determine whether the state of a checkbox should be changed.

dgColumn and dgRow are set in SelectCell.

Protected procedure SetdgColumn(const Value: integer); virtual;

See dgColumn

Protected procedure SetdgRow(const Value: integer); virtual;

See dgRow

Protected procedure SetEditText(ACol, ARow: Longint; const Value: WideString); override;

Validate contents of the cell.

Protected procedure TopLeftChanged; override;

If the combo box or button is visible, their positions are adjusted.

Public constructor Create(AOwner: TComponent); override;

initializes grid.

Public procedure DeleteColumn(ACol: Longint); override;

DeleteColumn deletes the column in the grid specified by ACol. Checked is updated.

Public procedure DeleteRow(ARow: Longint); override;

DeleteRow deletes the row in the grid specified by ARow. Checked is updated.

Public destructor Destroy; override;

Destroy destroys the TCustomRBWDataGrid. Do not call Destroy. Call Free instead.

Public procedure InsertColumn(ACol: Integer); virtual;

Use InsertColumn to insert a column at position ACol.

Public procedure InsertRow(ARow: Integer); virtual;

Use InsertRow to insert a row at position ARow.

Properties

Public property Cells[ACol, ARow: Integer]: string read GetCells write SetCells;

Cells is the text in the cell designated by ACol, ARow.

Public property CellVisible[ACol, ARow: Integer]: boolean read GetCellVisible;

CellVisible is used to determine whether the cell designated by ACol and ARow is visible.

Public property Checked[const ACol, ARow: integer]: boolean read GetChecked write SetChecked;

Checked can only be true if a Format is boolean.

Public property dgColumn: integer read FdgColumn write SetdgColumn;

dgColumn is the last active column.

Public property dgRow: integer read FdgRow write SetdgRow;

dgRow is the last active row.

Public property GridState: TRBWGridStates read FGridState;

property GridState: TRBWGridStates read FGridState;

Read GridState to determine what the grid is doing.

Public property State[const ACol, ARow: integer]: TCheckBoxState read GetState write SetState;

State is the TCheckBoxState of the cell at ACol, ARow.

Published property ButtonColor: TColor read FButtonColor write FButtonColor;

ButtonColor is the color of the button

Published property ColCount: integer read GetColCount write SetColCount;

ColCount is the number of columns in the grid.

Published property OnButtonClicked: TSetEditEvent read FButtonClicked write FButtonClicked;

OnButtonClicked is called when a button is clicked in a cell.

Published property OnColMoving: TCheckMoveEvent read FOnColMoving write FOnColMoving;

OnColMoving is called when a column is moved.

Published property OnColSize: TColSizeEvent read FOnColSize write FOnColSize;

OnColSize is called when a column is resized.

Published property OnRowMoving: TCheckMoveEvent read FOnRowMoving write FOnRowMoving;

OnRowMoving is called when a row is moved.

Published property OnStateChanged: TChangeCheckEvent read FStateChanged write FStateChanged;

OnStateChanged is called when the TCheckBoxState of a cell is changed.

Published property Options: TGridOptions read FOptions write SetOptions default [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect];

Options reimplements TStringGrid.Options. A local copy of Options is stored in FOptions. Inherited Options is sometimes changed.


Generated by PasDoc 0.10.0 on 2006-10-31 09:56:43