Table widget

Convenience Routines
int XawTableAppendColumn()
int XawTableAppendRow()
void XawTableDeleteColumn()
void XawTableDeleteRow()
void XawTableDoLayout()
XtJustify XawTableGetColumnJustify()
int XawTableGetColumnPixelWidth()
int XawTableGetColumnWidth()
void XawTableGetEditPosition()
char *XawTableGetLabelByCell()
char *XawTableGetLabelByPosition()
void XawTableGetSize()
int XawTableInsertColumn()
int XawTableInsertRow()
Boolean XawTableIsEditManaged()
int XawTablePrependColumn()
int XawTablePrependRow()
Boolean XawTableSearchLabel()
int XawTableSetCellBackground()
int XawTableSetCellColours()
int XawTableSetCellDefaultColours()
int XawTableSetCellForeground()
void XawTableSetColumnJustify()
void XawTableSetColumnWidth()
void XawTableSetEdit()
int XawTableSetLabel()
int XawTableSetNewSize()
typedef Boolean (*XawTableProc)()
void XawTableUnsetEdit()
Boolean XawTableWalk()

Get table size


void XawTableGetSize (w, rows, columns)
     Widget w;
     int *rows;
     int *columns;
w Specifies the Table widget.
rows Specifies amount of rows in the table.
columns Specifies amount of columns in the table.

This routine returns row and column size of table.

Set new table size


int XawTableSetNewSize(w, rows, columns)
     Widget w;
     int    rows;
     int    columns;
w Specifies the Table widget.
rows Specifies new rows parameter for the table.
columns Specifies new columns parameter for the table.

This routine resets all table stuff by deleting all labels in cells and all information about ordering columns.
It invokes allowDeleteTable callback list to ask appication for allowance for deleting table. If any one in this callback list sets do_it to False, then deleting of table will be restricted and new table size will not be set. In other case deleteTable callback list will be invoke and createTable after creating table.
Use this routine if you are going to create a new table staff in old Table widget without deleting and recreating last one.

Add new row or column into the table


int XawTableAppendRow(w)
     Widget w;

int XawTableAppendColumn(w, width)
     Widget w;
     int    width;
w Specifies the Table widget.
width Specifies the width of new column.

These routines add new row/column to the head of table.


int XawTablePrependRow(w)
     Widget w;

int XawTablePrependColumn(w, width)
     Widget w;
     int    width;
w Specifies the Table widget.
width Specifies the width of new column.

These routines add new row/column to the tail of table.


int XawTableInsertRow(w, row)
     Widget w;
     int    row;

int XawTableInsertColumn(w, column, width)
     Widget w;
     int    column;
     int    width;
w Specifies the Table widget.
row
column
Specifies the number of row/column after which should insert new one.
width Specifies the width of new column.

These routines add new row/column to the table.

Notes
  • All of these ask allowAddRow or allowAddColumn callback list for an allowance to add new one to the table. If the value of do_it is set to False, then adding new stuff will be restricted.
  • Routines dealing with columns have additional parameter width against row routines.

    Delete row or column

    
    void XawTableDeleteRow(w, row)
         Widget w;
         int    row;
    
    void XawTableDeleteColumn(w, column)
         Widget w;
         int    column;
    
    w Specifies the Table widget.
    row
    column
    Specifies the number of row/column to be deleted.

    These routines delete row/column from the table.

    Get label from cell

    
    char *XawTableGetLabelByCell(cell)
         XawTableCell cell;
    
    cell Specifies the pointer to cell data. XawTableCell is opaque type, its definition is not available to programmer. See XawTableWalk() for comments how to get it.

    The routine gets label from cell specified with XawTableCell opague data type.

         
    
    char *XawTableGetLabelByPosition(w, row, column)
         Widget w;
         int row;
         int column;
    
    w Specifies the Table widget.
    row Specifies the number of row.
    column Specifies the number of column.

    The routine gets label from cell specified with row/column position.

    Set label into cell

    
    int XawTableSetLabel(w, row, column, label)
         Widget w;
         int    row;
         int    column;
         char  *label;
    
    w Specifies the Table widget.
    row Specifies the row number of cell.
    column Specifies the column number of cell.
    label Specifies the label to be set.

    The routine invoces changeCell callback list for an allowance to change label in cell. If the value of do_it is set to False, then the changing will be restricted. The routines return 0 if changing was successful.

    Bypass the table

    
    typedef Boolean (*XawTableProc)(Widget, int, int, 
                                   XawTableCell, XtPointer);
         Widget widget;
         int row;
         int column;
         XawTableCell cell;
         XtPointer client_data; 
    
    
    widget Specifies the Table widget.
    row Specifies the row number of processing cell.
    column Specifies the column number of processing cell.
    cell Specifies the pointer to opaque cell data of processing cell.
    client_data Specifies a piece of data defined by the application.

    This defines the type of user-supplied routine to be used as predicate procedure. The routine returns True or False depending on some characteristic of the cell.

    
    Boolean XawTableWalk(w, predicate, 
                         begin_row, end_row, 
                         begin_column, end_column, 
                         direction,
                         row, column, client_data)
         Widget w;
         XawTableProc predicate;
         int begin_row;
         int end_row;
         int begin_column;
         int end_column;
         int direction;
         int *row;            /* returned */
         int *column;         /* returned */
         XtPointer client_data;
    
    w Specifies the Table widget.
    predicate Specifies the predicate procedure that will be called for each processing cell.
    begin_row Specifies the number of first row to be processed.
    end_row Specifies the number of last row to be processed.
    begin_column Specifies the number of first column to be processed.
    end_column Specifies the number of last column to be processed.
    direction Specifies the route of bypass.
    This version has:
        XawTABLE_RIGHT_DOWN -running on row (left->right), on column (top->button)
        XawTABLE_DOWN_RIGHT -running on column (top->button), on row (left->right)
    row Specifies the row number of cell where the predicate procedure returns True.
    column Specifies the column number of cell where the predicate procedure returns True.
    client_data Specifies the client data as passed to predicate.

    This routine invoces the specified predicate procedure for each cell which row position is between begin_row, end_row inclusively and column position is between begin_column, end_column inclusively.
    If the predicate routine returns True, then XawTableWalk will finish the processing of table and will write current processing cell position in row and column.
    The routine returns True when the specified predicate procedure returns True and False vise versa.

    Search label

    
    Boolean XawTableSearchLabel (w, string, row, column)
         Widget w;
         char *string;
         int *row;
         int *column;
    
    w Specifies the Table widget.
    string Specifies the string for search.
    row Specifies the row number of first cell which has label equal to string.
    column Specifies the column number of first cell which has label equal to string.

    This routine bypasses all cells in table and compares labels of cellswith given string. The Boolean return value indicates whether there is a cell with such label. If it is True, then row and column specify position of the cell.

    Check edit cell

    
    Boolean XawTableIsEditManaged(w)
         Widget w;
    
    w Specifies the Table widget.

    Check whether on not a edit cell is on the screen.

    
    void XawTableGetEditPosition(w, row, column)
         Widget w;
         int *row;     /* returned */
         int *column;  /* returned */
    
    w Specifies the Table widget.
    row Specifies the row number of edit cell.
    column Specifies the column number of edit cell.

    Getting position of current edit cell.

    Manage edit cell

    
    void XawTableSetEdit(w, row, column)
         Widget w;
         int row;
         int column;
    
    w Specifies the Table widget.
    row Specifies the row position.
    column Specifies the column position..

    The routine assigns new position for edit cell.

    
    void XawTableUnsetEdit(w)
         Widget w;
    
    w Specifies the Table widget.

    The routine removes edit cell from screen.

    Set colors to cell

    
    int XawTableSetCellColours (w, row, column, foreground, background)
         Widget w;
         int    row;
         int    column;
         Pixel  foreground;
         Pixel  background;
    
    w Specifies the Table widget.
    row Specifies the row number of cell.
    column Specifies the column number of cell.
    foreground Specifies the pixel data to be set as foreground.
    background Specifies the pixel data to be set as background.

    The routine sets new foreground and background colors to cell.

    
    int XawTableSetCellBackground (w, row, column, background)
         Widget w;
         int    row;
         int    column;
         Pixel  background;
    
    w Specifies the Table widget.
    row Specifies the row number of cell.
    column Specifies the column number of cell.
    background Specifies the pixel data to be set as background.

    The routine sets new background color to cell.

    
    int XawTableSetCellForeground (w, row, column, foreground)
         Widget w;
         int    row;
         int    column;
         Pixel  foreground;
    
    w Specifies the Table widget.
    row Specifies the row number of cell.
    column Specifies the column number of cell.
    foreground Specifies the pixel data to be set as foreground.

    The routine sets new foreground color to cell.

    
    int XawTableSetCellDefaultColours (w, row, column)
         Widget w;
         int    row;
         int    column;
    
    w Specifies the Table widget.
    row Specifies the row number of cell.
    column Specifies the column number of cell.

    The routine forces the cell to use default background and foreground colors.

    Notes
  • All of these invoke changeCell callback list for an allowance to change colours. If the value of do_it is set to False, then the changing will be restricted.
  • The routines return 0 if changing was successful.

    Set and get column parameters

    
    void XawTableSetColumnJustify (w, column, justify)
         Widget    w;
         int       column;
         XtJustify justify;
    
    w Specifies the Table widget.
    column Specifies the column number of cell.
    justify Specifies the justify location of labels for all cells in the column.

    The routine sets justify location of label in cell for all ones in the column. If this routine have not been used for column, then value of justify resource of Table widget will define justify location of label.

    
    XtJustify XawTableGetColumnJustify (w, column)
         Widget    w;
         int       column;
    
    w Specifies the Table widget.
    column Specifies the column number of cell.

    The routine returns justify location of label in cell for all ones in the column (the value have been set by XawTableSetColumnJustify() or the value of justify resource of Table widget).

    
    void XawTableSetColumnWidth (w, column, width)
         Widget w;
         int    column;
         int    width;
    
    w Specifies the Table widget.
    column Specifies the column number of cell.
    width Specifies the width of column in unit defined by literal resource of Table widget.

    The routine sets width of column in literal or pixel unit depending on literal resource of Table widget.

    
    int XawTableGetColumnWidth (w, column)
         Widget w;
         int    column;
    
    w Specifies the Table widget.
    column Specifies the column number of cell.

    The routine returns width of column in literal or pixel unit depending on literal resource of Table widget (the value have been set by XawTableSetColumnWidth() or the value of defaultWidth resource of Table widget)

    
    int XawTableGetColumnPixelWidth (w, column)
         Widget w;
         int    column;
    
    w Specifies the Table widget.
    column Specifies the column number of cell.

    The routine returns width of column in pixel.

    Control layout

    To force or defer a re-layout of the Form, use XawTableDoLayout().
    
    void XawTableDoLayout (w, do_layout)
         Widget  w;
         Boolean do_layout;
    
    w Specifies the Table widget.
    do_layout Specifies whether the layout of the Table widget is enabled (True) or disabled (False)

    When making several changes to the column or the cells of a Table widget after the Table has been realized, it is a good idea to disable relayout until after all changes have been made.


    [ Xraw home ]   [ Xraw widget class hierarchy ]   [ Table widget ]


    Vladimir T. Romanovski
    romsky@hp1.oea.ihep.su