WtTable Function
Modifies an XbaeMatrix class widget.
Usage
status = WtTable(function, widget[, parameters])
Input Parameters
function:
'AddColumns' — Add columns to the table. If this function is specified, also provide the following parameters:
position — The column before which new columns are added.
columns — Two-dimensional string array of column values.
num_columns — Number of columns to be added.
width — One-dimensional array of column widths.
labels — (optional) One-dimensional array of column labels.
max_lengths — (optional) One-dimensional array of column maximum lengths.
alignments — (optional) One-dimensional array of column alignments. Valid values are:
0 — Align cell contents to cell’s left edge (left justify).
1 — Center cell contents (center justify).
2 — Align cell contents to cell’s right edge (right justify).
label_alignments — (optional) One-dimensional array of column label alignments. Valid values are:
0 — Align cell contents to cell’s left edge (left justify).
1 — Center cell contents (center justify).
2 — Align cell contents to cell’s right edge (right justify).
colors — (optional) Two-dimensional array of column cell colors.
'AddRows' — Add rows to the table. If this function is specified, also provide the following parameters:
position — The row before which new rows are added.
rows — Two-dimensional string array of row values.
num_rows — Number of rows to be added.
labels — (optional) One-dimensional array of row labels.
colors — (optional) Two-dimensional array of row cell colors.
'DeleteCols' — Delete columns from the table. If this function is specified, also provide the following parameter:
position — The column at which to start deleting columns.
num_columns — Number of columns to delete.
'DeleteRows' — Delete rows from the table. If this function is specified, also provide the following parameter:
position — The row at which to start deleting rows.
num_rows — Number of rows to delete.
'DeselectAll' — Deselect all cells in the table.
'DeselectCell' — Deselect the specified cell in the table. If this function is specified, also provide the following parameter:
row — Row index of the cell to deselect.
column — Column index of the cell to deselect.
'DeselectCol' — Deselect the specified column in the table. If this function is specified, also provide the following parameter:
column — Index of column to deselect.
'DeselectRow' — Deselect the specified row in the table. If this function is specified, also provide the following parameter:
row — Index of row to deselect.
'SelectCell' — Select the specified cell in the table. If this function is specified, also provide the following parameters:
row — Row of the cell to select.
column — Column of the cell to select.
'SelectCol' — Select the specified column in the table. If this function is specified, also provide the following parameter:
column — Column to select.
'SelectRow' — Select the specified row in the table. If this function is specified, also provide the following parameter:
row — Row to deselect.
'EditCell' — Edit the specified cell in the table. If this function is specified, also provide the following parameters:
row — Row of the cell to edit.
column — Column of the cell to edit.
'CancelEdit' — Cancel the edit of the currently edited cell. If this function is specified, also provide the following parameter:
unmap — (optional) If specified and nonzero, the currently edited cell is unmapped.
'CommitEdit' — Commit the edit of the currently edited cell. If this function is specified, also provide the following parameter:
unmap — (optional) If specified and nonzero, the currently edited cell is unmapped.
'GetCell' — Get the value of a cell in the table. If this function is specified, also provide the following parameters:
row — Row of the cell to get.
column — Column of the cell to get. Returns the value of the specified cell.
'SetCell' — Set the value of a cell in the table. If this function is specified, also provide the following parameters:
row — Row of the cell to set.
column — Column of the cell to set.
value — New value of the specified cell.
'SetColor' — Set the color value for a cell in the table. If this function is specified, also provide the following parameters:
row — Row of the cell whose color you want to set.
column — Column of the cell whose color you want to set.
color — New colormap index of the specified cell.
'SetColColor' — Set the color value for a column in the table. If this function is specified, also provide the following parameters:
position — Column at which to start setting colors.
colors — Two-dimensional array of new colormap indexes for columns.
num_colors — The number of elements in the colors array.
'SetRowColor' — Set color value for a row in table. If ’SetRowColor’ is specified, also provide the following parameters:
position — Row at which to start setting colors.
colors — 2D array of new colortable indexes for rows.
num_colors — The number of colors in the colors array.
widget — Widget ID of the table (xbaeMatrix class) widget.
Discussion
The XbaeMatrix widget creates an editable 2D array of string data (cells) similar to a spreadsheet. All values must be converted to string type before being set with WtTable.
note | Rogue Wave has ported a subset of the Widget Toolbox (Wt) functionality that is available for Motif to Microsoft Windows. Because the Widget Toolbox under Windows is not a complete implementation, we recommend that Windows developers use the PV‑WAVE Widgets (Ww) layer or the VDA Tools when developing GUI applications. |
XbaeMatrix Widget Documentation
The Motif version of the XbaeMatrix widget was originally developed by Andrew Wason of Bellcore.
Complete documentation for the XbaeMatrix widget is available in the PostScript file matrix_motif.ps, which you can print on any PostScript printer. This file is in:
(UNIX) WAVE_DIR/docs/widgets
Where WAVE_DIR is the main PV‑WAVE directory.
Refer to this document for detailed information on the MbaeMatrix widget’s resources and callbacks.
XbaeMatrix Widget Callbacks
See Appendix B: Motif Callback Parameters in the PV‑WAVE Application Developer’s Guide for information on the required parameters for all widget callbacks. The XbaeMatrix widget’s callback routines and their parameters are documented in the file matrix_motif.ps and discussed in the previous section. Refer to that document for information on the table widget’s callbacks.
Example
Values in the table are modified (set) through a call to WtTable.
PRO ButtonCB, w, which
COMMON Widgets, table
; When a button is pressed, modify the table with a call to
; WtTable.
CASE which OF
1: PRINT, WtGet(table,'cells',Nrows = 2, Ncols = 3)
2: status = WtTable('SetCell', table, 0, 0, 'New Font')
ENDCASE
END
PRO LeaveCellCB, w, data, n, reason, event, r, c, value, doit
; This callback is called just before an edit to a cell is
; committed. For more information on XbaeMatrix widget
; callbacks and their parameters, see the previous section
; "XbaeMatrix Widget Callbacks".
PRINT, "leaveCellCallback ", r, c, value
END
PRO ModifyVerifyCB, w, data, n,reason, event, $
r, c, doit, ci, cn, sp, ep, txt, len, fmt
; This callback is called while a cell is being edited. For
; more information on XbaeMatrix widget callbacks and their
; parameters, see the previous section "XbaeMatrix Widget
; Callbacks".
print, "modifyVerifyCallback ", r, c, doit, $
ci, cn, sp, ep, txt, len, fmt
END
PRO Table
@wtxmclasses
@wtxmconsts
COMMON Widgets, table
; Initialize the Widgets Toolkit.
top = WwInit('table','Test', layout, /Vertical)
; Load color table.
loadct, 5
; Set cell contents, display table.
cells = [['Fonts','Size','Icons'], ['1.245','2.5','3.6']]
args = {, rows:2, columns:3, cells:cells, $
columnWidths:[10, 10, 10], $
columnLabels:['col1','col2','col3'],$
rowLabels:['row1','row2'], boldLabels:TRUE, $
colors:[[40, 50, 60], [100, 110, 120]], $
columnAlignments:[XmALIGNMENT_BEGINNING, $
XmALIGNMENT_CENTER, XmALIGNMENT_END]}
table = WtCreate('table', xbaeMatrixWidgetClass, $
layout, args)
status = WtAddCallback(table, "leaveCellCallback", $
'leaveCellCB')
status = WtAddCallback(table, "modifyVerifyCallback", $
'modifyVerifyCB')
buttons = WwButtonBox(layout, ['Get','Set'], 'ButtonCB')
status = WwSetValue(top, /Display)
WwLoop
END
See Also
For more information about how to write an application program based on the PV‑WAVE Widget Toolbox, refer to Using the Widget Toolbox in the PV‑WAVE Application Developer’s Guide.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.