Advanced Features


Introduction

This section covers some of the advanced features provided by the EditTable and related widgets.

User-defined or Automatic Annotation

Row/column annotations can be user-defined or automatically labelled with numeric or alphabetic sequences. Columns can be annotated in spreadsheet fashion with character strings that are automatically generated in alphabetical order (A, B, C,..., AA, AB, etc.). Rows can be annotated automatically with sequential integers or any of the other supported data types (float, character, etc.). The application can apply the annotation value for a column or row as it is being created or after it is created.


Table with auto annotation


Table with user-defined annotation


Intercell Grid Separators

For more visually sophisticated displays, EditTable lets you add grid line separators with specifiable features such as:


Figure 2: Cells With/Without Grid Line Separators


Micro-formatting

EditTable supports color or text font changes at the row level, column level, or cell-by-cell. This provides a way to highlight important data such as totals or constraints so that it stands out in the table. Individual cells can contain multiple lines of data, if desired.


Figure 3: Varied Text Fonts and Multi-line Cells


Row/Column Freezing

EditTable allows freezing of any sequential or nonsequential group of rows and/or columns. Freezing causes the rows or columns to remain fixed in the same position so that they do not scroll with the rest of the table. Frozen rows can be placed at the top or bottom of the table; frozen columns at the left or right. Cells in a frozen column can still be selected and edited, if desired. Frozen rows or columns can be unfrozen when desired.


Figure 4: Example of Frozen Columns and/or Rows


Row/Column visibility and partial displays

To provide additional control over data presentation, EditTable allows the visibility of any column or row to be selectively turned on or off. Columns or rows that are turned off disappear completely from the display but remain active in the background until turned on again.

EditTable also lets you decide whether to display or not display the data in columns that are only partially visible in the viewing area. This feature is valuable for financial displays or other applications where a partial display of prices or other data could lead to misquotes or other potential misinterpretation.


Figure 5: Columns With/Without Displayed Data


Free-style Selection

EditTable lets users select any combination of columns, rows, or individual cells - whether or not the selected components are adjacent. Selections can be extended indefinitely to add rows, columns, or cells to the initially selected area. Selected rows, columns, or cells can be set off by a special background color and/or a highlighted border of a specified thickness and color. Selected columns, rows, and cells can be cut, copied, or pasted as a group.


Figure 6: Row, Column, and Random Selections


Horizontal Columns

The columns in a table can be oriented vertically or horizontally. Vertical is the standard orientation, but in some applications a horizontal orientation may be useful. When the columns are oriented horizontally, the cells in a column are drawn from left to right and the column annotation appears on the left or the right of the column. All column and row operations work the same, regardless of column orientation.

Icon Selection and Display

EditTable lets you superimpose an icon or pixmap as the background for any range of cells. This can include company logos or special pictorial elements that can be more easily interpreted than raw data. An XWD image, X bitmap, or other bitmapped symbol can be converted to a pixmap and inserted into a cell. The application can dynamically control the use of bitmapped symbols as background for table cells.


Figure 7: Example of Pixmap Background


Cell Validation and Locking

EditTable includes advanced input validation features. For example, you could trap input that does not match the default data type and display a warning dialog for users. Additionally, you can check that data is within specified ranges. Validation can occur immediately on a cell-by-cell basis or for the entire table. The application can allow the change, prohibit the change, or substitute its own value.

EditTable also supports read-only protection of cells, so that the user can be locked out of certain rows, columns, or individual cells. Since the widget notifies the application of cursor movement, it can flag any situation where the user tries to edit read-only cells.


Cell Attributes

Attributes such as cell foreground and background, pixmap and font can be set on a cell basis. A set of functions, such as XintEditTableSetCellForeground or XintEditTableSetCellBackground are provided to set those attributes for a cell or a block of cells. This information is stored inside the table. For large tables or when memory usage is a concern, the callback XmNcellAttributesCallback can be used to provide cell attributes directly at cell repaint time. For example this feature can be used to set the cell color when it is a function of the data, row or column number.

To make a cell flash for a period of time, use function XintEditTableCellFlash.

A function, XintEditTableSetCellDisplayAttributes can be used to update the foreground, background and data content of a range of cells in one atomic operation.


Displaying composite data (pointer data type)

EditTable provides a pointer data type that lets you set up specific columns in a table so they receive application-defined data (structures, arrays, or other tables). This allows you to display composite items such as date and time or a value calculated as the result of operations on another table. For example, the date may be derived from an array {1993, Dec, 15} but displayed in an alternate format (12-15-93). The application uses a callback to handle the formatting process.

User-defined data formatting

EditTable provides another callback feature that lets users select their own custom formatting for data columns. For example, the application might store the data 123456.78 as data type "double," but display it with dollar signs and commas so that the data reads: $123,456.78


Figure 8: Pointer Type Data in User-Formatted Display


Cell Spanning

EditTable provides a method to allow cells to span more than one row/column location in both the row and column directions. This span can be applied to all of the cells in the table, or a subset of the table locations.

Importing Data from ASCII Files

EditTable provides a mechanism for populating tables with data contained in ASCII files. The widget provides both a resource and a function for reading delimited ASCII files into a table. Both tab-separated and comma-separated (CSV) files can be read directly into the table. Each line in the ASCII file corresponds to a row in the table. The cell contents of a row correspond to the file entries between delimiters. Incoming data for a cell is converted to the specified column data type as the file is being read; if this conversion fails, the cell is left unchanged. Controls are provided for specifying alternative field delimiters. It is also possible to cause EditTable to use the first column of the file as the row annotation; similarly the first row of the file can be used as the column annotation.

Interactive Move, Copy, Resize

EditTable provides a set of actions for interactively moving, copying and resizing rows, columns and cells. The move and copy actions let users reposition rows and columns within the table by selecting them and dragging them to the desired location using a mouse. Resizing is similar in that the user drags the row, column, or cell boundary until it becomes the desired size. EditTable supplies functions for inquiring the cell height and width after interactive resizing.

You can specify the cursor type displayed during these operation. Additionally, you can show either the contents of the cells being moved or just an outline of the cells. In either case, you can specify the line style and the color of the outline of the cells which the user is dragging. The application can also specify a callback to be invoked after the cells have been resized or dragged to their new location.


Multiple Output Formats

EditTable provides several hardcopy and exchange formats for output. You can output an entire table or a range of cells in these formats:


Motif Drag and Drop

EditTable supports full Motif drag and drop functionality (Note: drag and drop is not supported under X11R4/Motif1.1). One can drag and drop cells from a table into another table, from a text widget into a table, etc. If you are using ChartObject, it is also possible to drag and drop data from a table to a chart and from a chart to a table.

EditObject action MotifStartDrag controls the drag operation. It is connected using the following translation:

     <Btn2Down>: MotifStartDrag()

There is no specific action defined for dropping objects. The drop operation is activated automatically on a button release.

Drag and Drop operations can be disabled by setting EditObject resources XmNallowDrag and XmNallowDrop to False. Also, callback XmNdragDropCallback is invoked on both drag and drop operations and can be used to selectively enable or disable either drag or drop operations. This callback can also be used to modify the type of drag and drop operation (copy/move/link) and modify the index or count of the cells being dragged.

The following table summarizes the default behavior for drag and drop. Note: if there is a key sequence in the translation, it is important that the keys remain pressed until the drag and drop operation has been completed and the button has been released.

Key SequenceDrag SourceDrop SiteDescription
<Btn2Down>EditTableEditTableCopies the selected cells from the source table to the destination table.
<Btn2Down>EditTableChart objectThe data contained in the selected cells is copied into the chart object (move option is disabled for the EditTable widget).
Ctrl <Btn2Down>EditTableChart objectThe data contained in the selected cells is copied into the chart object.
Ctrl Shift <Btn2Down>EditTableChart objectThe data contained in the selected cells is copied into the chart object and a link is made between the table and the chart.
<Btn2Down>Chart objectEditTableThe data contained in the chart is moved to the table at the location specified by the pointer.
Ctrl <Btn2Down>Chart objectEditTableThe data contained in the chart is copied to the table at the location specified by the pointer.
Ctrl Shift <Btn2Down>Chart objectEditTableThe data contained in the chart is copied to the table at the location specified by the pointer. A link is established between the chart and the table.
<Btn2Down>Motif TextEditTableContent of the Text widget is copied into the specified table cell.


DataObject Connection

The ChartObject library provides a library of data objects called DataObject library. This library defines the model component of the ChartObject Model View Controller architecture. When used in conjunction with ChartObject, EditTable can become another view of the data by associating a Data object to the EditTable widget using function XintEditTableAssociateData. The figure below illustrates an example where a chart object and an EditTable widget are both associated with the same data object.



Figure 9: Multiple Views of a Data Object