void set_type_cb(OptionStructure *opt, int type, void *data) { int i, nmrows, nscols; char *rowlabels[MAX_SET_COLS]; Leval_ui *ui = (Leval_ui *) data; nmrows = TableGetNrows(ui->mw); nscols = settype_cols(type); if (nmrows > nscols) { TableDeleteRows(ui->mw, nmrows - nscols); } else if (nmrows < nscols) { if (ui->gr) { Grace *grace = grace_from_quark(ui->gr); for (i = 0; i < nscols; i++) { rowlabels[i] = copy_string(NULL, dataset_col_name(grace, i)); rowlabels[i] = concat_strings(rowlabels[i], " = "); } } TableAddRows(ui->mw, nscols - nmrows); TableSetRowLabels(ui->mw, rowlabels); } TableUpdateVisibleRowsCols(ui->mw); }
void create_datasetprop_popup(Widget but, void *data) { set_wait_cursor(); if (tui.top == NULL) { Widget menubar, menupane, fr; int i, j; char *rowlabels[MAX_SET_COLS]; char *collabels[DATA_STAT_COLS] = {"Min", "at", "Max", "at", "Mean", "Stdev"}; int column_widths[DATA_STAT_COLS] = {12, 6, 12, 6, 12, 12}; GraceApp *gapp = (GraceApp *) data; tui.top = CreateDialogForm(app_shell, "Data set statistics"); menubar = CreateMenuBar(tui.top); ManageChild(menubar); AddDialogFormChild(tui.top, menubar); tui.sel = CreateGraphSetSelector(tui.top, "Data sets:", LIST_TYPE_SINGLE); AddDialogFormChild(tui.top, tui.sel->frame); AddStorageChoiceCB(tui.sel->set_sel, changetypeCB, tui.sel); menupane = CreateMenu(menubar, "File", 'F', FALSE); CreateMenuCloseButton(menupane, tui.top); menupane = CreateMenu(menubar, "Help", 'H', TRUE); CreateMenuHelpButton(menupane, "On data sets", 's', tui.top, "doc/UsersGuide.html#data-sets"); for (i = 0; i < MAX_SET_COLS; i++) { rowlabels[i] = copy_string(NULL, dataset_col_name(gapp->grace, i)); for (j = 0; j < DATA_STAT_COLS; j++) { tui.rows[i][j] = NULL; } } fr = CreateFrame(tui.top, "Statistics"); tui.mw = CreateTable("mw", fr, MAX_SET_COLS, DATA_STAT_COLS, MAX_SET_COLS, 4); TableDataSetPropInit(tui.mw); TableSetColLabels(tui.mw, collabels); TableSetColWidths(tui.mw, column_widths); TableSetDefaultColAlignment(tui.mw, ALIGN_END); TableSetDefaultColLabelAlignment(tui.mw, ALIGN_CENTER); TableSetRowLabels(tui.mw, rowlabels); TableSetDefaultRowLabelWidth(tui.mw, 3); TableSetDefaultRowLabelAlignment(tui.mw, ALIGN_CENTER); TableUpdateVisibleRowsCols(tui.mw); AddTableEnterCellCB(tui.mw, enterCB, NULL); AddDialogFormChild(tui.top, fr); ManageChild(tui.top); } RaiseWindow(GetParent(tui.top)); unset_wait_cursor(); }
void create_leval_frame(Widget but, void *data) { Quark *gr = (Quark *) data; if (!gr) { return; } set_wait_cursor(); levalui.gr = gr; if (levalui.top == NULL) { int i; Widget fr, rc1; int nscols; char *rows[MAX_SET_COLS][1]; char **cells[MAX_SET_COLS]; char *rowlabels[MAX_SET_COLS]; int column_widths[1] = {50}; int column_maxlengths[1] = {256}; Grace *grace = grace_from_quark(gr); levalui.top = CreateDialogForm(app_shell, "Load & evaluate"); fr = CreateFrame(levalui.top, "Parameter mesh ($t)"); AddDialogFormChild(levalui.top, fr); rc1 = CreateHContainer(fr); levalui.start = CreateTextItem(rc1, 10, "Start at:"); levalui.stop = CreateTextItem(rc1, 10, "Stop at:"); levalui.npts = CreateTextItem(rc1, 6, "Length:"); levalui.set_type = CreateSetTypeChoice(levalui.top, "Set type:"); AddDialogFormChild(levalui.top, levalui.set_type->menu); AddOptionChoiceCB(levalui.set_type, set_type_cb, (void *) &levalui); nscols = 2; for (i = 0; i < nscols; i++) { rowlabels[i] = copy_string(NULL, dataset_col_name(grace, i)); rowlabels[i] = concat_strings(rowlabels[i], " = "); if (i == 0) { rows[i][0] = "$t"; } else { rows[i][0] = ""; } cells[i] = &rows[i][0]; } levalui.mw = CreateTable("mw", levalui.top, nscols, 1, MAX_SET_COLS, 1); TableLevalInit(levalui.mw); TableSetColWidths(levalui.mw, column_widths); TableSetColMaxlengths(levalui.mw, column_maxlengths); TableSetRowLabels(levalui.mw, rowlabels); TableSetDefaultRowLabelWidth(levalui.mw, 6); TableSetDefaultRowLabelAlignment(levalui.mw, ALIGN_CENTER); TableSetCells(levalui.mw, cells); TableUpdateVisibleRowsCols(levalui.mw); AddTableLeaveCellCB(levalui.mw, leaveCB, &levalui); CreateAACDialog(levalui.top, levalui.mw, leval_aac_cb, &levalui); } RaiseWindow(GetParent(levalui.top)); unset_wait_cursor(); }
void update_ssd_ui(SSDataUI *ui, Quark *q) { if (ui && q) { int i, nc, nr, new_nc, new_nr, ncols, nrows, nfixed_cols; int delta_nc, delta_nr; int *maxlengths; char **rowlabels, **collabels; if (ui->q != q) { TableDeselectAllCells(ui->mw); } ui->q = q; ncols = ssd_get_ncols(q); nrows = ssd_get_nrows(q); new_nc = ncols + EXTRA_SS_COLS; new_nr = nrows + EXTRA_SS_ROWS; if (ssd_is_indexed(q)) { nfixed_cols = 1; } else { nfixed_cols = 0; } nr = TableGetNrows(ui->mw); nc = TableGetNcols(ui->mw); delta_nr = new_nr - nr; delta_nc = new_nc - nc; if (delta_nr > 0) { TableAddRows(ui->mw, delta_nr); } else if (delta_nr < 0) { TableDeleteRows(ui->mw, -delta_nr); } rowlabels = xmalloc(new_nr*sizeof(char *)); for (i = 0; i < new_nr; i++) { char buf[32]; sprintf(buf, "%d", i + 1); rowlabels[i] = copy_string(NULL, buf); } TableSetRowLabels(ui->mw, rowlabels); for (i = 0; i < new_nr; i++) { xfree(rowlabels[i]); } xfree(rowlabels); maxlengths = xmalloc(new_nc*SIZEOF_INT); collabels = xmalloc(new_nc*sizeof(char *)); for (i = 0; i < new_nc; i++) { ss_column *col = ssd_get_col(q, i); if (col && col->format == FFORMAT_STRING) { maxlengths[i] = STRING_CELL_WIDTH; } else { maxlengths[i] = 2*CELL_WIDTH; } if (col && !string_is_empty(col->label)) { collabels[i] = copy_string(NULL, col->label); } else { unsigned int coli; char buf[32]; coli = i; sprintf(buf, "%c", coli%26 + 'A'); while ((coli /= 26)) { memmove(&buf[1], buf, strlen(buf) + 1); buf[0] = coli%26 + 'A' - 1; } collabels[i] = copy_string(NULL, buf); } } if (delta_nc > 0) { TableAddCols(ui->mw, delta_nc); } else if (delta_nc < 0) { TableDeleteCols(ui->mw, -delta_nc); } TableSetColMaxlengths(ui->mw, maxlengths); TableSetColLabels(ui->mw, collabels); TableSetFixedCols(ui->mw, nfixed_cols); TableUpdateVisibleRowsCols(ui->mw); xfree(maxlengths); for (i = 0; i < new_nc; i++) { xfree(collabels[i]); } xfree(collabels); UpdateColChoice(ui->col_sel, q); } }
void create_fonttool(TextStructure *cstext_parent) { static fonttool_ui *ui = NULL; if (ui == NULL) { ui = xmalloc(sizeof(fonttool_ui)); memset(ui, 0, sizeof(fonttool_ui)); ui->fonttool_panel = CreateDialog(app_shell, "Font tool"); ui->font_select = CreateFontChoice(ui->fonttool_panel, "Font:"); FormAddVChild(ui->fonttool_panel, ui->font_select->menu); ui->font_table = CreateTable("fontTable", ui->fonttool_panel, FONT_TOOL_ROWS, FONT_TOOL_COLS, 8, 16); TableFontInit(ui->font_table); TableSetDefaultColWidth(ui->font_table, 2); TableSetDefaultColAlignment(ui->font_table, ALIGN_BEGINNING); TableUpdateVisibleRowsCols(ui->font_table); AddTableDrawCellCB(ui->font_table, DrawCB, ui); AddTableEnterCellCB(ui->font_table, EnterCB, ui); AddOptionChoiceCB(ui->font_select, update_fonttool_cb, ui); FormAddVChild(ui->fonttool_panel, ui->font_table); ui->cstext = CreateCSText(ui->fonttool_panel, "CString:"); AddTextValidateCB(ui->cstext, EditStringCB, ui); ui->aac_buts = CreateAACDialog(ui->fonttool_panel, ui->cstext->form, fonttool_aac_cb, ui); FormFixateVChild(ui->cstext->form); update_fonttool_cb(NULL, 0, ui); } if (cstext_parent == ui->cstext) { /* avoid recursion */ return; } ui->cstext_parent = cstext_parent; if (ui->cstext_parent == NULL) { TextSetString(ui->cstext, ""); WidgetSetSensitive(ui->aac_buts[0], FALSE); WidgetSetSensitive(ui->aac_buts[1], FALSE); } else { char *s = TextGetString(ui->cstext_parent); int pos = TextGetCursorPos(ui->cstext_parent); TextSetString(ui->cstext, s); TextSetCursorPos(ui->cstext, pos); xfree(s); WidgetSetSensitive(ui->aac_buts[0], TRUE); WidgetSetSensitive(ui->aac_buts[1], TRUE); } DialogRaise(ui->fonttool_panel); }