EditTable Widget WebFAQ - Q23


/*********************************************************
Suppose you are adding an Oval on top of the EditTable
within the upper-left 4X4 cells.
*********************************************************/
  :
static Object oval_obj;

  :
  :
static Widget
CreateTargetWidgets(parent, arg, n)
Widget parent;
ArgList arg;
int n;
{
  XtTranslations translations;
  XintRectangle rect_size;


  int i, j, nrows, *data;

  XtSetArg(arg[n], XmNwidth,  400); n++;
  XtSetArg(arg[n], XmNheight, 400); n++;
  Scroll = XtCreateWidget("Scroll", xintScrollWidgetClass, parent, arg, n);

  translations = XtParseTranslationTable(annotation_translations);

  Table = XtVaCreateWidget("Table", xintEditTableWidgetClass, Scroll,
                   XmNtitleString, "XintEditTable Example\nObject ontop of Table",
                   XmNtitleShadowType, XintSHADOW_IN,
                   XmNtitleBackground, XintLoadColor(XtDisplay(parent), "cyan"),
                   XmNdefaultColumnDataType, XintTYPE_INTEGER,
                   XmNdefaultColumnDataFormat, "%d",
                   XmNgridLineStyle, XintGRID_LINE_SHADOW_OUT,
                   XmNcolumnAnnotationTranslations, translations,
                   XmNrowAnnotationTranslations, translations,

                   NULL);

  rect_size.x1 = 1.0;
  rect_size.y1 = 1.0;
  rect_size.x2 = 5.0;
  rect_size.y2 = 5.0;
  n = 0;
  XtSetArg(arg[n], XmNrectangle, &rect_size); n++;
  XtSetArg(arg[n], XmNlineThickness, 4); n++;
  XtSetArg(arg[n], XmNcolor, XintLoadColor(XtDisplay(Table),"red")); n++;
  oval_obj = XintCreateOval(Table, "OvalObject", arg, n);

  XtVaGetValues(Table, XmNnumberOfRows,    &nrows,
                       XmNnumberOfColumns, &ncols, NULL);

  data = (int *) XtMalloc(nrows * sizeof(int));
  for (i = 1; i <= ncols; i++) { for (j="1;" j <="nrows;" j++) data[j 1]="i" * j; XintEditTableFillColumnData(Table, i, (XtPointer) data); } XtFree(data); XtManageChild(Scroll); XtManageChild(Table); return Scroll; } : : 

Click here for the Image
Back to EditTable FAQ

© INT 1996.