The Table Objects: 4.2 Using a Table Object: Selecting Cells

Up: GEOS SDK TechDocs| Up | Prev: 4.1 Drawing Cells | Next: 4.3 Editing Cells
TableCellLocation, CellRange, MSG_TABLE_SELECT, MSG_TABLE_GET_CURRENT_SELECTION, MSG_TABLE_SET_CURRENT_SELECTION. MSG_TABLE_SET_ROW_RANGE_SELECTION

You can configure under what circumstances a Table object will select a cell by setting the TableColumnFlags for the various columns in the table. The TableColumnFlags determine what will constitute a "selection event", and what cells will be selected. When a selection event occurs, the Table object will send itself MSG_TABLE_SELECT. This message passes two arguments:

A TableCellLocation structure is used to specify a cell within the Table . It has the following definition:

typedef struct {
	word	TCL_row;
	word	TCL_column;
} TableCellLocation;
TCL _row
This is the cell's row. (The first row is row number zero, as always.)
TCL _column
This is the cell's column. (The first column is column number zero, as always.)

The default handler for this message causes an area of the table to be highlighted. The area is determined by the TCF_TRIT field of the TableColumnFlags record passed with the message. If you wish, you may intercept the message before it is handled by the default handler, and change the TCF_TRIT field in the passed TableColumnFlags ; this will change which cells will be highlighted by the default handler. For example, if you change the TCF_TRIT field to contain TRIT_NONE, then the default handler will not highlight any rows.

You can find out what cells, if any, are currently selected by sending MSG_TABLE_GET_CURRENT_SELECTION to the Table object. This message takes one argument, a pointer to a TableCellRange structure. The handler will fill in this structure with the currently selected range.

A TableCellRange structure is used to specify a range of cells. It has the following definition:

typedef struct {
	TableCellLocation				TCR_start;
	TableCellLocation				TCR_end;
} TableCellRange;
TCR _start
This TableCellLocation specifies the first cell in the selected range. (The TableCellLocation structure is described on A TableCellLocation structure is used to specify a cell within the Table. It has the following definition:.)
TCR _end
This TableCellLocation specifies the last cell in the selected range. (Note that this cell may be higher up in the Table then TCR _start ; the same range is defined, whichever order TCR _start and TCR _end appear in.)

Note that a TableCellRange forms a rectangle. You can change the selected cells at any time by sending MSG_TABLE_SET_CURRENT_SELECTION . This message is passed one argument, a TableCellRange structure; that structure specifies what the current selection should be. The Table object responds by changing the current selection but does not send a MSG_TABLE_SELECT . To cancel the current selection (and leave the Table with nothing selected), send MSG_TABLE_SET_CURRENT_SELECTION , and put the constant T_NONE_SELECTED in the TCR _start. TCL _column field of the passed TableCellRange structure. (If you do this, the other fields of the TableCellRange will be ignored.) Again, MSG_TABLE_SELECT is not sent in this case.

MSG_TABLE_SELECT

void	MSG_TABLE_SELECT(
        TableCellLocation		location,
        TableColumnFlags		tableColumnFlags);

The Table object sends this message to itself when the user selects one or more cells with a pointer object. (I.e. this message is generated through use of the pointer for Table selection, not when the selection changes through other means.) The TableColumnFlags of the various columns determine whether a particular mouse action is interpreted as a selection. If it is, the Table object sends itself this message, instructing itself to highlight the appropriate cells.

Source: A TableClass object.

Destination: The Table object sends this message to itself.

Parameters: location This is the selected cell; that is, the cell in which the pointer was when the column's selection criteria were met.

tableColumnFlags
This is a record of TableColumnFlags . The flags specify two things: They specify what criteria were used to determine that a selection had happened; and they specify (in the TCF_TRIT field) which cells should be highlighted.

Return: Nothing.

Structures: TableCellLocation (see A TableCellLocation structure is used to specify a cell within the Table. It has the following definition:) and TableColumnFlags (see The TableColumnFlags record has the following flags:).

Interception: You may intercept this. If you intercept this message, you can change which cells will be highlighted by changing the tableColumnFlags. TCF_TRIT field.

MSG_TABLE_GET_CURRENT_SELECTION

void	MSG_TABLE_GET_CURRENT_SELECTION(
        TableCellRange *		cellRange);

This message retrieves what cells are currently selected within a Table object

Source: Unrestricted.

Destination: Any TableClass object.

Parameters: cellRange A pointer to a TableCellRange structure.

Return: *cellRange will specify the first and last selected cells.

Structures: TableCellRange (described on A TableCellRange structure is used to specify a range of cells. It has the following definition:).

MSG_TABLE_SET_CURRENT_SELECTION

void	MSG_TABLE_SET_CURRENT_SELECTION(
        TableCellRange		cellRange);

This message changes what cells are currently selected within a Table object.

Source: Unrestricted.

Destination: Any TableClass object.

Parameters: cellRange A pointer to a TableCellRange structure, specifying what cells should be selected. (If cellRange. TCR _start. TCL _column = T_NONE_SELECTED, no cells will be selected.)

Return: Nothing.

Structures: TableCellRange (described on A TableCellRange structure is used to specify a range of cells. It has the following definition:).


Up: GEOS SDK TechDocs| Up | Prev: 4.1 Drawing Cells | Next: 4.3 Editing Cells