/*ARGSUSED*/ Widget _XmCreateTab(Widget parent, String name, /* unused */ ArgList arglist, Cardinal argcount) { static XrmQuark quarks[] = {0, 0, 0, 0, 0}; XmTabList tl = (XmTabList)parent; XrmQuark qarg; float value = 0.0; unsigned char units = XmPIXELS; XmOffsetModel model = XmABSOLUTE; unsigned char alignment = XmALIGNMENT_BEGINNING; char *decimal = "."; XmTab tab, start; int i; /* Init quark list */ if (quarks[0] == 0) { quarks[0] = XrmPermStringToQuark(XmNtabValue); quarks[1] = XrmPermStringToQuark(XmNunitType); quarks[2] = XrmPermStringToQuark(XmNoffsetModel); quarks[3] = XrmPermStringToQuark(XmNalignment); quarks[4] = XrmPermStringToQuark(XmNdecimal); } /* Get arguments from arglist */ for (i = 0; i < argcount; i++) { qarg = XrmStringToQuark(arglist[i].name); if (qarg == quarks[0]) value = (float)arglist[i].value; else if (qarg == quarks[1]) units = (unsigned char)arglist[i].value; else if (qarg == quarks[2]) model = (XmOffsetModel)arglist[i].value; else if (qarg == quarks[3]) alignment = (unsigned char)arglist[i].value; else if (qarg == quarks[4]) decimal = (char *)arglist[i].value; } tab = XmTabCreate(value, units, model, alignment, decimal); if (_XmTabLCount(tl) == 0) { _XmTabLStart(tl) = tab; _XmTabPrev(tab) = tab; _XmTabNext(tab) = tab; } else { start = _XmTabLStart(tl); _XmTabNext(tab) = start; _XmTabPrev(tab) = _XmTabPrev(start); _XmTabNext(_XmTabPrev(start)) = tab; _XmTabPrev(start) = tab; } _XmTabLCount(tl)++; return((Widget)NULL); }
int main(int argc, char **argv) { Widget toplevel, one, d; XtAppContext app; XmFontList fontlist; XmString xms; Arg args[10]; XmTab tabs[MAX_COLUMNS]; XmTabList tablist; XmRendition renditions[MAX_COLUMNS]; XmRenderTable rendertable; XmStringTable xmstring_table; int xmstring_count; Pixel pixels[MAX_COLUMNS]; int n, i; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, NULL, NULL); d = XmGetXmDisplay(XtDisplay(toplevel)); XtAddCallback(d, XmNnoFontCallback, NoFontCB, NULL); XtAddCallback(d, XmNnoRenditionCallback, NoRenditionCB, NULL); /* Create some colors */ for (i = 0 ; i < MAX_COLUMNS ; i++) { pixels[i] = ConvertStringToPixel (toplevel, rendition_data[i].color) ; } /* Create tab stops for columnar output */ for (i = 0 ; i < MAX_COLUMNS ; i++) { tabs[i] = XmTabCreate ((float) 1.5, XmINCHES, ((i == 0) ? XmABSOLUTE : XmRELATIVE), XmALIGNMENT_BEGINNING, ".") ; } /* Create a tablist table which contains the tabs */ tablist = XmTabListInsertTabs (NULL, tabs, XtNumber (tabs), 0) ; /* Create some multi-font/color renditions, and use the tablist */ /* This will be inherited if we use it on the first rendition */ for (i = 0 ; i < MAX_COLUMNS ; i++) { n = 0 ; if (i == 0) { XtSetArg (args[n], XmNtabList, tablist); n++; } XtSetArg (args[n], XmNrenditionForeground, pixels[i]); n++; XtSetArg (args[n], XmNfontName, rendition_data[i].font); n++; XtSetArg (args[n], XmNfontType, XmFONT_IS_FONT); n++; renditions[i] = XmRenditionCreate (toplevel, rendition_data[i].tag, args, n); } /* Create the Render Table */ rendertable = XmRenderTableAddRenditions (NULL, renditions, XtNumber (renditions), XmMERGE_NEW) ; /* Create the multi-column data for the list */ xmstring_table = CreateListData(&xmstring_count) ; xms = xmstring_table[0]; for (i=1; i<xmstring_count; i++) { XmString s, x; s = XmStringSeparatorCreate(); x = XmStringConcat(xms, s); xms = XmStringConcat(x, xmstring_table[i]); } one = XtVaCreateManagedWidget("One", xmLabelWidgetClass, toplevel, XmNalignment, XmALIGNMENT_BEGINNING, XmNrenderTable, rendertable, XmNlabelString, xms, NULL); XtRealizeWidget(toplevel); #if 0 /* Note: the following values are the result of * querying the current geometry. */ { static XtWidgetGeometry Expected[] = { {CWWidth | CWHeight , 0, 0, 112, 58, 0,0,0}, /* One */ }; /* toplevel should be replaced with to correct applicationShell */ PrintDetails(toplevel, Expected); } #endif LessTifTestMainLoop(toplevel); exit(0); }