## 4.37 Spread Sheet

The spread widget behaves like a two dimensional array of simplified input fields called cells. Cells can be left, right or center justified and can be displayed using different text properties. Rectanglar regions can be selected, sorted and charted. Contents of a spread sheet can be read from or exported to a text file (treated as a single string). Insertion/exporting is controled by the current tab and newline characters, the defaults are `\t` and `\n`.

### Widget Info

Symbolic widget type | EZ_WIDGET_SPREAD_SHEET
Default class name | "SpreadSheet"
Default instance name | "spreadSheet"

### Widget Interface Routines

`void EZ_SSheetGetSizes(EZ_Widget *ssheet, int *nrows, int *ncolumns);`

return the current effect size of the spread sheet. The effect size is the minimal rectangle which contains all nonempty cells.

`void EZ_SSheetSetFirstCell(EZ_Widget *ssheet, int row, int col);`

Set the the cell to be displayed at the upper left corner of the widget window.

`void EZ_SSheetSetTextProperty(EZ_Widget *ssheet, TextProperty *prop);`

set the default text property. Newly created cells will be displayed using this default text property.

`void EZ_SSheetSetHScrollbar(EZ_Widget *ssheet, EZ_Widget *hscrollbar);`

`void EZ_SSheetSetVScrollbar(EZ_Widget *ssheet, EZ_Widget *vscrollbar);`

set the horizontal/vertical scrollbar for the spread sheet.

`void EZ_SSheetHideColumns(EZ_Widget *ssheet, int from, int to);`

`void EZ_SSheetHideRows(EZ_Widget *ssheet, int from, int to);`

`void EZ_SSheetUnhideColumns(EZ_Widget *ssheet, int from, int to);`

`void EZ_SSheetUnhideRows(EZ_Widget *ssheet, int from, int to);`

hide/unhide the specified columns/rows. Hidden columns/rows will be displyed using a vertical/horizontal line of width 1.

`void EZ_SSheetSwapRow(EZ_Widget *ssheet, int r1, int r2);`

`void EZ_SSheetSwapColumn(EZ_Widget *ssheet, int c1, int c2);`

`void EZ_SSheetSwapCell(EZ_Widget *ssheet, int r1, int c1, int r2, int c2);`

Swap two rows/columns/cells.

`void EZ_SSheetClearRegion(EZ_Widget *ssheet, int r1, int c1, int r2, c2);`

clear the region inclusive.

`void EZ_SSheetCopyRegion(EZ_Widget *ssheet, int r1, int c1, int r2, int c2,`

`int r, int c, int delete);`

copy the region inclusive and paste it at . If `delete` is true, clear the region before pasting.

`void EZ_SSheetSortRegion(EZ_Widget *ssheet, int r1, int c1, int r2, int c2,`

`int keycolumn, int (*cmp)(CONST void *, CONST void *) );`

Sort the specified region according to cells in `keycolumn`, using the supplied comparision function `cmp`. Cells are treated as strings in comparision. If `cmp` is NULL, it sorts the `keycolumn` in lexical ascending order.

`void EZ_SSheetSortRegionRow(EZ_Widget *ssheet, int r1, int c1, int r2, int c2,`

`int keyrow, int (*cmp)(CONST void *, CONST void *) );`

`void EZ_SSheetSortColumns(EZ_Widget *ssheet, int r1, int c1, int r2, int c2,`

`int (*cmp)(CONST void *, CONST void *) );`

`void EZ_SSheetSortRows(EZ_Widget *ssheet, int r1, int c1, int r2, int c2,`

`int (*cmp)(CONST void *, CONST void *) );`

`void EZ_SSheetFindCell(EZ_Widget *ssheet, char *str, int *row, int *col);`

find the first cell which contain `str` as a substring, and return the row and column index of the cell. This function returns 1 if a match is found and returns 0 otherwise.

`void EZ_SSheetSetTabChar(EZ_Widget *ssheet, char tab, char newline);`

set the tab and line separator. They are used in `EZ_SSheetGetRegionString**` and `EZ_SSheetInsertRegionString**`. The default values are '
t' and '
n'.

`char *EZ_SSheetGetRegionString(EZ_Widget *ssheet, int r1, int c1, int r2, int c2);`

`char *EZ_SSheetGetRegionStringWithProperty(EZ_Widget *ssheet, int r1, int c1,`

`int r2, int c2, EZ_TextProperty ***prop);`

return the specified region as a single string. Columns and rows are separated using the current tab and newline character. The second function returns the associated text property also.

`char *EZ_SSheetInsertRegionString(EZ_Widget *ssheet, int r1, int c1, char *str)`;

`char *EZ_SSheetInsertRegionStringWithProperty(EZ_Widget *ssheet, int r1, int c1,`

`char *str, EZ_TextProperty **prop);`

Insert cells represented by `str` at location [r1 c1]. \verb=str= is parsed using the current tab and newline character. In the second version, inserted cells will be displayed using the associated text property.

`char *EZ_SSheetInsertRegionString(EZ_Widget *ssheet, int r1, int c1, char *str)`;

`char *EZ_SSheetInsertRegionStringWithProperty(EZ_Widget *ssheet, int r1, int c1,`

`char *str, EZ_TextProperty **prop);`

Insert cells represented by `str` at location [r1 c1]. \verb=str= is parsed using the current tab and newline character. In the second version, inserted cells will be displayed using the associated text property.

`int EZ_SSheetFindCursorCell(EZ_Widget *ssheet, int x, int y, int *row, int *col);`

Find and return the indices of the cell that contains the point (x,y). This function returns 0 if no cells are found.

`void EZ_SSheetHighlightRegion(EZ_Widget *ssheet, int r1, int c1, int r2, int c2);`

Highlight the specified region. If r1 < 0, clear the current highlighted region.

`int EZ_SSheetGetHighlightedRegion(EZ_Widget *ssheet, int *r1, int *c1, int *r2, int *c2);`

return the current highlight region. If no region is currently highlighted, returns 0.

`void EZ_SSheetGetActiveCell(EZ_Widget *ssheet, int *row, int *col, char **str);`

`void EZ_SSheetGetActiveCellWithProperty(EZ_Widget *ssheet, int *row, int *col,`

`char **str, EZ_TextProperty ***prop);`

return the indices of the current active cell. If `str` is not null, it returns the active cell content.

`void EZ_SSheetSetActiveCell(EZ_Widget *ssheet, int row, int col);`

set the current active cell.

`char *EZ_SSheetGetCell(EZ_Widget *ssheet, int row, int col);`

`char *EZ_SSheetGetCellWithProperty(EZ_Widget *ssheet, int row, int col, EZ_TextProperty *p);`

return the content of the specified cell.

`void EZ_SSheetDrawCell(EZ_Widget *ssheet, int row, int col, Drawable drawable,`

`int x, int y, int w, int h);`

draw the content of the specified cell in drawable. (x,y,w,h) specifies the rectangle to render the text into.

`void EZ_SSheetSetRegionJustification(EZ_Widget *ssheet, int r1, int c1,`

`int r2, int c2, int justification);`

justify the region. `justification` is one of `EZ_LEFT,EZ_RIGHT` or `EZ_CENTER`.

`void EZ_SSheetSetRegionProperty(EZ_Widget *ssheet, int r1, int c1,`

`int r2, int c2, EZ_TextProp *prop);`

set and redisplay the specified region using the specified text property.

`void EZ_SSheetMakeChart(EZ_Widget *ssheet, int r1, int c1, int r2, int c2,`

`EZ_SchartHandle handle, int kind, void *cdata, int cmode);`

`typedef int (*EZ_SChartHandle)(EZ_Widget *ss, void *chart, int r1, int c1,`

`int r2, int c2, int kind, void *data);`

`void EZ_SSheetDeleteChart(EZ_Widget *ssheet, EZ_Item *chart);` delete the specified chart.

`EZ_Item *EZ_SSheetGetActiveChart(EZ_Widget *ssheet);` return the currently selected chart.

`EZ_Item **EZ_SSheetGetAllCharts(EZ_Widget *ssheet, int *cnt);`

return the list of all charts and return the number of charts to `cnt`.

`void EZ_SSheetValidateCharts(EZ_Widget *ssheet, int r1, int c1, int r2, int c2);`

validate all charts whose definig region intersects to the specified region.

### Screenshot

### Resources

Config_Option | ResourceName | DefaultValue
EZ_CLASS | class | `"SpreadSheet"`
EZ_NAME | name | `"spreadSheet"`

EZ_X | x |
EZ_Y | y |
EZ_WIDTH | width |
EZ_HEIGHT | height |

EZ_LOCATION | location |
EZ_SIZE | size |
EZ_GEOMETRY | geometry |

EZ_WIDTH_HINT | widthHint |
EZ_HEIGHT_HINT | heightHint |
EZ_SIZE_HINT | sizeHint |

EZ_BORDER_WIDTH | borderWidth | `0`
EZ_BORDER_TYPE | borderType | `none`
EZ_FOCUS_PAD | focusPad | `2`

EZ_EXPAND | expand | `false`
EZ_PROPAGATE | propagate | `true`
EZ_TRANSIENT | transient | `false`

EZ_CURSOR | cursor | `"XC_C_PLUS"`
EZ_BUBBLE_STRING | bubbleString | `null`

EZ_CALLBACK | N/A | `null null`
EZ_MOTION_CALLBACK | N/A | `null null`
EZ_DESTROY_CALLBACK | N/A | `null null`
EZ_EVENT_HANDLER | N/A | `null null`

EZ_BACKGROUND | background | `"gray74`
EZ_BG_IMAGE_FILE | bgImageFile | `null`
EZ_BG_PIXMAP | N/A | `none`
EZ_SHAPED_WINDOW | shapedWindow | `false`
EZ_SHAPE_FILE | shapeFile | `NULL`
EZ_SHAPE_PIXMAP | N/A | `NULL`

EZ_BG_IMAGE_FILE_B | bgImageFileB | `null`
EZ_BG_PIXMAP_B | N/A | `none`
EZ_CLIENT_PTR_DATA | N/A | `null`
EZ_CLIENT_INT_DATA | clientIntData | `0`

EZ_DND_DRAG_CURSOR | dndDragCursor | `none`
EZ_DND_BUBBLE_STRING | dndBubbleString | `null`

EZ_BACKING_STORE | backingStore | `true`

EZ_SHEET_HEADER_SIZE | sheetHeaderSize | `32 16`
EZ_SHEET_CELL_SIZE | sheetCellSize | `96 24`

HTML Documentation Maintainance:`Arturo Espinosa <arturo@nuclecu.unam.mx>`