EditTable Callbacks


Defined Callbacks

The following callbacks are defined by an EditTable widget.

NameStructureReason
XmNcellAttributesCallbackXintEditTableCell-
AttributesCallbackStruct
XintCR_CELL_RESIZE
XintCR_COLUMN_RESIZE
XintCR_DISPLAY_CELL
Xint_ROW_RESIZE
XmNcellWidgetDisplay-
Callback
XintEditTableCell-
WidgetCallbackStruct
XintCR_QUERY_CELL_WIDGET
XintCR_UPDATE_CELL_WIDGET
XmNcheckEditModeCallbackXintEditTableCheckEdit-
ModeCallbackStruct
XintCR_CHECK_EDIT_MODE
XmNcolumnCallbackXintEditTableOperation-
CallbackStruct
XintCR_DELETE_COLUMN
XintCR_INSERT_COLUMN
XintCR_SELECT_COLUMN
XmNdoubleClickCallbackXintEditTableDouble-
ClickCallbackStruct
XintCR_DOUBLE_CLICK
XmNdragCallbackXintEditTable-
DragCallbackStruct
XintCR_CELL_MOVE
XintCR_CELL_RESIZE
XintCR_CELL_COPY
XintCR_COLUMN_MOVE
XintCR_COLUMN_RESIZE
XintCR_COLUM_COPY
XintCR_ROW_MOVE
XintCR_ROW_RESIZE
XintCR_ROW_COPY
XmNdragDropCallbackXintEditTableDrag-
DropCallbackStruct
XintCR_DRAG
XintCR_DROP
XmNeditAnnotationCallbackXintEditTableEdit-
AnnotationCallbackStruct
XintCR_EDIT_COLUMN_AN-
NOTATION
XintCR_EDIT_ROW_ANNOTATION
XmNformatCellCallbackXintEditTable-
FormatCellCallbackStruct
XintCR_DISPLAY_CELL
XintCR_CALCULATE_CELL_WIDTH
XintCR_CALCULATE_CELL_HEIGHT
XmNformatColumn-
AnnotationCallback
XintEditTable-
FormatAnnotation-
CallbackStruct
XintCR_GET_COLUMN_ANNOTATION
XmNformatRow-
AnnotationCallback
XintEditTable-
FormatAnnotation-
CallbackStruct
XintCR_GET_ROW_ANNOTATION
XmNrowCallbackXintEditTable-
OperationCallbackStruct
XintCR_DELETE_ROW
XintCR_INSERT_ROW
XintCR_SELECT_ROW
XmNselectCellCallbackXintEditTable-
OperationCallbackStruct
XintCR_SELECT_CELL
XmNtraverseCellCallbackXintEditTable-
TraverseCellCallbackStruct
XintCR_TRAVERSE_CELL_DOWN
XintCR_TRAVERSE_CELL_LEFT
XintCR_TRAVERSE_CELL_RIGHT
XintCR_TRAVERSE_CELL_UP
XintCR_TRAVERSE_CELL_POINTER
XintCR_TRAVERSE_CELL_FO-
CUS_IN
XmNvalidateValueCallbackXintEditTableValidate-
ValueCallbackStruct
XintCR_VALIDATE_VALUE


XintEditTableCellAttributesCallbackStruct

The following table lists the members of the callback structure, XintEditTableCellAttributesCallbackStruct, used by the EditTable widget for callback XmNCellAttributesCallback.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the event that triggered the callback.
introwIndicates the row number of the selected cell.
intcolumnIndicates the column number of the selected cell.
intalignmentText alignment constant in the cell.
PixelbackgroundCell background color.
PixelforegroundCell foreground color.
intfont_table_indexIndex to the font table. If there is no font table added to EditTable, the index will have no effect. To add font table, see the resource XmNfontTable.

The reason will be set to one of the following defined constants.

Defined ConstantDescription
XintCR_CELL_RESIZEIndicates that the end user has performed a cell resize operation.
XintCR_COLUMN_RESIZEIndicates that the end user has performed a column resize operation.
XintCR_ROW_RESIZEIndicates that the end user has performed a row resize operation.
XintCR_DISPLAY_CELLThe cell is about to be displayed on the screen. Allows the programmer to set the cell attributes before the cell is displayed.


XintEditTableCellWidgetCallbackStruct

The following ordered table lists the members of the callback structure, XintEditTableCellWidgetCallbackStruct, used by the EditTable widget for callback XmNcellWidgetDisplayCallback.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the event that triggered the callback.
introwIndicates the row number of the selected cell.
intcolumnIndicates the column number of the selected cell.
WidgetwidgetID of the Widget In a Cell.
XintCellWidgetResources *resourcesPoints to the resources that may be set automatically on the widget.
BooleandoitIndicates whether or not the resources defined above will be set on the widget before it is drawn. This value is initialized to the setting of resource XmNcellWidgetSetResources.

The reason member will be set to one of the following defined constants.

Defined ConstantDescription
XintCR_QUERY_CELL_WIDGETThe column width or row height was set to 0 (for auto calculate). Allows the programmer to set the resources on the widget so that proper cell size can be calculated.
XintCR_UPDATE_CELL_WIDGETThe widget is about to be drawn on the virtual screen. Allows the programmer to set the resources on this widget before it is drawn.

Structure XintCellWidgetResources is defined as follows.

     typedef struct {
                     String     string;
                     String     font;
                     Pixel      background;
                     Pixel      foreground;
                     int        alignment;
                     int        sensitive;
     } XintCellWidgetResources;

Where:

MemberDescription
stringFormat of the display string for the cell value.
fontX window font name for the display string.
backgroundCell background color.
foregroundCell foreground color.
alignmentMotif alignment constant for the cell.
sensitiveCell read-only.

If the XmNcellWidgetSetResources constraint resource is set to True, primitive widgets, such as labels and buttons, do not require a callback. Their resources will be set correctly.

In other cases, such as inserting toggle buttons or option menus, a callback is required. Inside this callback the application should extract the current cell contents, then set the widget state and graphic resources accordingly. When the state of a widget in a cell is changed (for example, an option menu is changed to a new selection), the application should update the cell contents. A cell is identified by its location. If a widget is used for more than one cell, the cell location can be obtained by using function XintEditTableGetCellPointerPosition.

The doit member will be set to the value of the constraint resource, XmNcellWidgetSetResources, before the callback is called.


XintEditTableCheckEditModeCallbackStruct

The following ordered table lists the members of the callback structure, XintEditTableCheckEditModeCallbackStruct, used by the EditTable widget for the check edit mode callback.

Data TypeMemberDescription
intreasonSet to XintCR_CHECK_EDIT_MODE.
XEvent *eventPoints to the event that triggered the callback.
intcolumnIndicates the column containing the cell to be edited.
introwIndicates the row containing the cell to be edited.
intcolumn_edit_modeIndicates the edit mode of column containing the cell to be edited.
BooleandoitIndicates whether the cell is editable (used only when the column containing the cell is editable).

The column_edit_mode member will be set to one of the following:

Defined ConstantDescription
XintCOLUMN_EDITABLEIndicates that the column containing the cell is editable.
XintCOLUMN_NON_EDITABLEIndicates that the column containing the cell is not editable.

The doit flag is used when column_edit_mode has the value XintCOLUMN_EDITABLE. The associated action routine sets this flag to True before the callback list is invoked. A callback procedure should set this flag to False if the cell (in an editable column) should not be enabled for editing. When column_edit_mode has the value XintCOLUMN_NON_EDITABLE the cell selected for editing always is non-editable.


XintEditTableDoubleClickCallbackStruct

The following ordered table lists the members of the callback structure, XintEditTableDoubleClickCallbackStruct, used by the EditTable widget for callback XmNdoubleClickCallback.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the event that triggered the callback.
intcolumnIndicates the column number where the button was pressed.
introwIndicates the row number where the button was pressed.


XintEditTableDragCallbackStruct

The following ordered table lists the members of the callback structure, XintEditTableDragCallbackStruct, used by the EditTable widget for callback XmNdragCallback.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the event that triggered the callback.
intsrc_columnSource column index (set if a column or cell operation).
intsrc_rowSource row index (set if a row or cell operation).
intcurrent_columnDestination column index (set if a column or cell operation).
intcurrent_rowDestination row index (set if a row or cell operation).
BooleandoitSet to False to cancel move, resize or copy operation.

The reason member will be set to one of the following defined constants:

Defined ConstantDescription
XintCR_CELL_MOVEIndicates that the end user has performed a cell move operation (moving the content of a cell into another).
XintCR_CELL_RESIZEIndicates that the end user has performed a cell resize operation.
XintCR_CELL_COPYIndicates that the end user has performed a cell copy operation.
XintCR_COLUMN_FREEZEIndicates that the end user has performed a column move operation into a frozen column.
XintCR_COLUMN_MOVEIndicates that the end user has performed a column move operation.
XintCR_COLMUN_RELEASEIndicates that the end user has performed a column move operation from a frozen column.
XintCR_COLUMN_RESIZEIndicates that the end user has performed a column resize operation.
XintCR_COLUMN_COPYIndicates that the end user has performed a column copy operation.
XintCR_ROW_FREEZEIndicates that the end user has performed a row move operation into a frozen row.
XintCR_ROW_MOVEIndicates that the end user has performed a row move operation.
XintCR_ROW_RELEASEIndicates that the end user has performed a row move operation from a frozen row.
XintCR_ROW_RESIZEIndicates that the end user has performed a row resize operation.
XintCR_ROW_COPYIndicates that the end user has performed a row copy operation.


XintEditTableDragDropCallbackStruct

Callback XmNdragDropCallback is defined by the EditObject class to support Motif drag and drop operations. The EditTable class redefines a new callback structure, XintEditTableDragDropCallbackStruct, that is passed when this callback is invoked for an EditTable widget.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the XEvent that triggered the callback.
ObjectobjectGraphic object being dragged or dropped to. This field is NULL if drag or drop is not from or to a graphic object.
intoperationThis field is 0 on a drag. On a drop, it can be set to XintDROP_COPY, XintDROP_MOVE or XintDROP_LINK. You can modify this field on a drop to change the operation.
Atom *atomsArray of source or destination atoms supported.
intatom_countSize of array atoms.
intx,yLocation of the pointer where drag started or drop occcured.
introw_startOn drag, starting index of the row that is dragged. On drop, row index where the cursor is located and where the cells will be dropped. You can modify this field on a drag or drop operation.
introw_countOn drag, number of rows being dragged. On drop, this field is not used. You can modify this field on a drag operation.
intcolumn_startOn drag, starting index of the column that is dragged. On drop, column index where the cursor is located and where the cells will be dropped. You can modify this field on a drag or drop operation.
intcolumn_countOn drag, number of columns being dragged. On drop, this field is not used. You can modify this field on a drag operation.
BooleandoitSet to False to cancel the drag or drop operation.


XintEditTableEditAnnotationCallbackStruct

The following ordered table lists the members of the callback structure, XintEditTableEditAnnotationCallbackStruct, used by the EditTable widget for the edit annotation callback.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the event that triggered the callback.
introwIndicates the row containing the annotation to be edited.
intcolumnIndicates the column containing the annotation to be edited.
Booleanif_autoIndicates whether the annotation selected for editing is editable.

The reason member will be set to one of the following defined constants:

Defined ConstantDescription
XintCR_EDIT_COLUMN_ANNOTATIONIndicates that the end user has selected a column annotation for editing.
XintCR_EDIT_ROW_ANNOTATIONIndicates that the end user has selected a row annotation for editing.

When the if_auto flag is True, it indicates that the annotation selected for editing was generated automatically by the EditTable widget. If the annotation was generated by the EditTable widget, then it cannot be edited by the application or the end user.


XintEditTableFormatAnnotationCallbackStruct

The following table lists the members of the callback structure XintEditTableFormatAnnotationCallbackStruct, used by the EditTable widget for the format column annotation callback and format row annotation callback.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the XEvent that triggered the callback.
introwThe row index. If the callback is to format column annotation, the row index will always be 1.
intcolumnThe column index. If the callback is to format row annotation, the column index will always be 1.
char *annotation_stringThe annotation string to be displayed in the column/row. EditTable will make a copy of the string.

The reason member will be set to one of the following defined constants:

Defined ConstantDescription
XintCR_GET_COLUMN_ANNOTATIONIndicates that EditTable is about to display the column annotation.
XintCR_GET_ROW_ANNOTATIONIndicates that EditTable is about to display the row annotation.


XintEditTableFormatCellCallbackStruct

The following ordered table lists the members of the callback structure XintEditTableFormatCellCallbackStruct, used by the EditTable widget for allowing the application to define its own mechanism to format a cell before display.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPointer to the XEvent that triggered the callback.
introwThe index of the row of the cell to be formatted.
intcolumnThe index of the column of the cell to be formatted.
intcolumn_data_typeThe column data type for that cell.
XintCellValuecell_valueA Union containing the cell value.
char *display_stringreturns the string to display in that cell.
Booleanto_be_freedif Set to True, string display_string will be freed by the widget after it has been used. This member is initialized to False, which corresponds to the case where display_string is allocated statically by the application.

The reason member will be set to one of the following defined constants:

Defined ConstantsDescription
XintCR_DISPLAY_CELLFormatting is needed to display the cell content.
XintCR_CALCULATE_CELL_WIDTHFormatting is needed to calculate the width of the cell.
XintCR_CALCULATE_CELL_HEIGHTFormatting is needed to calculate the height of the cell.

Union XintCellValue is defined as follows

   typedef union {
                  short short_value;
	          int integer_value;
	          long long_value;
	          float float_value;
	          double double_value;
	          char *string_value;
	          XtPointer pointer_value;
   } XintCellValue;


XintEditTableOperationCallbackStruct

The following ordered table lists the members of the callback structure, XintEditTableOperationCallbackStruct, used by the EditTable widget for the column, row, and select cell callbacks.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPointer to the XEvent that triggered the callback.
intcolumn_startIndicates the first column involved in the operation.
introw_startIndicates the first row involved in the operation.
intcolumn_countIndicates the number of columns involved in the operation.
introw_countIndicates the number of rows involved in the operation.
BooleandoitIndicates whether the associated action should be executed (used only for delete row and for delete column operations).

The reason member will be set to one of the following defined constants:

Defined ConstantDescription
XintCR_DELETE_COLUMNIndicates that a column will be deleted if the doit flag is set to True.
XintCR_INSERT_COLUMNIndicates that one or more columns will be inserted.
XintCR_SELECT_COLUMNIndicates that one or more columns have been selected.
XintCR_DELETE_ROWIndicates that a row will be deleted if the doit flag is set to True.
XintCR_INSERT_ROWIndicates that one or more rows will be inserted.
XintCR_SELECT_ROWIndicates that one or more rows have been selected.
XintCR_SELECT_CELLIndicates that one or more cells have been selected.

The doit flag is used for the row delete and column delete operations. The associated action routine sets this flag to True before the callback list is invoked. A callback procedure should set this flag to False if the row or column should not be deleted by the action routine.


XintEditTableTraverseCellCallbackStruct

The following ordered table lists the members of the callback structure, XintEditTableTraverseCellCallbackStruct, used by the EditTable widget for the traverse cell callback.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the event that triggered the callback.
introwIndicates the row number of the cell where the cell pointer is currently located.
intcolumnIndicates the column number of the cell where the cell pointer is currently located.
intnext_rowIndicates the row number of the cell that the cell pointer will enter.
intnext_columnIndicates the column number of the cell that the cell pointer will enter.
intnumber_of_columnsIndicates the number of columns in the table.
intnumber_of_rowsIndicates the number of rows in the table.

The reason member will be set to one of the following defined constants:

Defined ConstantDescription
XintCR_TRAVERSE_CELL_DOWNIndicates that the cell has been entered from the cell above.
XintCR_TRAVERSE_CELL_LEFTIndicates that the cell has been entered from the cell on the left.
XintCR_TRAVERSE_CELL_RIGHTIndicates that the cell has been entered from the cell on the right.
XintCR_TRAVERSE_CELL_UPIndicates that the cell has been entered from the cell below.
XintCR_TRAVERSE_CELL_POINTERIndicates that the cell has been entered with a pointer selection.
XintCR_TRAVERSE_CELL_FOCUS_INIndicates that the cell has been entered because the focus was brought back to the table.


XintEditTableValidateValueCallbackStruct

The following ordered table lists the members of the callback structure XintEditTable-ValidateValueCallbackStruct, used by the EditTable widget for the validate value callback.

Data TypeMemberDescription
intreasonSet to XintCR_VALIDATE_VALUE.
XEvent *eventPoints to the event that triggered the callback.
introwIndicates the row number of the cell whose value needs to be validated.
intcolumnIndicates the column number of the cell whose value needs to be validated.
intcolumn_data_typeIndicates the data type of the cell whose value needs to be validated.
char *formatA character string containing the (C language) format descriptor for the cell whose value needs to be validated.
char *old_value_stringA character string containing the value of the cell before it was changed.
char *new_value_stringA character string containing the value of the cell after it was changed.
Booleanto_be_freedSet to True if you want EditTable to free the string specified in new_value_string after it has been used.
XintCellValuecell_valuePointer to the new cell value.
BooleandoitIndicates whether the cell's value should be changed to the new value.

The associated action routine sets the doit flag to True before the callback list is invoked. To cancel the editing and restore the old cell value, simply set the doit flag to False. To overwrite the user entry and specify a new cell value you have two options. The first solution is to replace member new_value_string with your own string. In this case, if you have allocated the new value string dynamically, you may want to set to_be_freed to True so that it is deallocated by the table after it is no longer needed. The second solution is to replace directly member cell_value with the new cell value.


Check Edit Mode Callback

This type of callback is called by the EditTableEditCell action routine when a cell has been selected for editing. The callback structure, XintEditTableCheckEditModeCallbackStruct, will contain the edit mode of the column containing the cell. This callback should determine whether the cell can be edited by the user and set the doit flag to False if the cell should not be edited. If the cell is in a non-editable column, the setting of the doit flag is ignored by the action routine and the cell will not be editable. This callback can be used by the application to display a message so that the user will know that the selected cell cannot be edited. Another application for this callback is implementing non-editable cells in an editable column.

Column Callback

This type of callback is called by the EditTableEndSelect, AnnotationEndSelect, EditTableDeleteColumns, and EditTableInsertColumns action routines. The callback is called after the action occurs, except for EditTableDeleteColumns where it is called before. The callback structure, XintEditTableOperationCallbackStruct, will contain the indices of the column(s) being operated on. The callback structure also contains the doit flag which is initialized to True by the EditTableDeleteColumns action procedure. If you do not want to delete the selected column(s), then set the doit flag to False.

Double Click Callback

This type of callback is called when the user double clicks on a cell. No action is connected to this callback. The callback structure is XintEditTableDoubleClickCallback. The code of the Button used for the double click can be found in the XEvent structure. The callback structure, XintEditTableDragCallbackStruct, will contain the indices of the source and destination cells, rows or columns. The callback structure also contains the doit flag which is initialized to True. If you do not want to delete the selected column(s), then set the doit flag to False. A number of resources, XmNdragForeground, XmNdragCursorType, XmNdragGridLineStyle and XmNdrawShowCellContent is provided to customize the appearance of the cell, row or column being dragged.

Drag Callback

This type of callback is called by the AnnotationEndDrag and EditTableEndDrag action routines before a Copy, Move or Resize operation action occurs on a cell, row or column. This type of callback only allows the manipulation of cells, rows or columns locally. EditObject callback XmNdragDropCallback provides full Motif Drag and Drop functionality. See the EditTable Widget manual, Chapter 1 and the
EditObject reference section for more information on Motif Drag and Drop support.

Edit Annotation Callback

This type of callback is called by the AnnotationEdit action routine so that the callback list can implement row annotation editing operations and column annotation editing operations. The callback structure, XintEditTableEditAnnotationCallbackStruct, will indicate whether the user has selected a row annotation or a column annotation and it will specify the location of the annotation selected. The callback structure will also indicate whether or not the annotation selected was generated automatically by the EditTable widget. If the annotation was generated by the widget, then it cannot be edited, and the application should display a message to that effect.

Format Cell Callback

This type of callback is called each time the EditTable needs to display a cell when the column format specifier for that cell is set to NULL or the data type is XintTYPE_POINTER. This callback allows the application to provide custom formats or to format complex data types that are stored in the pointer format.

Row Callback

This type of callback is called by the EditTableEndSelect, AnnotationEndSelect, EditTableCopyRow, EditTableDeleteRows, and EditTableInsertRows action routines. The callback is called after the action occurs, except for EditTableDeleteRows where it is called after. The callback structure, XintEditTableOperationCallbackStruct, will contain the indices of the row(s) being operated on. The callback structure also contains the doit flag which is initialized to True by the EditTableDeleteRows action procedure. If you do not want to delete the selected row(s), then set the doit flag to False.

Select Cell Callback

This type of callback is called by the EditTableEndSelect action routine after the user has selected one or more cells in the table. The callback structure, XintEditTableOperationCallbackStruct, will contain the indices of the cell(s) selected.

Traverse Cell Callback

This type of callback is called by the EditTable widget whenever the user moves the cell pointer to a new cell using the keyboard. The action routine, EditTableEnterCell, calls this type of callback so that the callback procedures can determine whether the cell should be entered. The callback structure, XintEditTableTraverseCellCallbackStruct, will contain the indices of the cell to which the user wants to traverse. The callback procedure can change the indices of the cell to be traversed to so that the action procedure moves the cursor to a different cell. Using this mechanism, the application can control how the user traverses through a table, skipping over irrelevant cells.

Validate Value Callback

This type of callback is called by the EditTableConfirmEdit action procedure or when the user terminates editing by leaving a cell. It gives the application programmer the ability to check the new cell content before it is stored into the table. The callback structure, XintEditTableValidateValueCallbackStruct, will contain the location of the cell being edited as well as the old and new values of the cell. The callback structure also contains the doit flag which is initialized to True by the EditTableConfirmEdit action procedure. If you do not want the EditTableConfirmEdit action procedure to change the value, then set the doit flag to False. Alternatively, you can leave the doit flag set to True and substitute a different value for the new value so that the action procedure will change the cell's value to the application specified value.