/*ARGSUSED*/ static void CommandCallback( Widget w, /* unused */ XtPointer cl_data, XtPointer call_data ) { XmCommandWidget client_data = (XmCommandWidget) cl_data ; XmCommandCallbackStruct cb; char *str; /****************/ cb.reason = XmCR_COMMAND_CHANGED; cb.event = ((XmAnyCallbackStruct *) call_data)->event ; /* get char* string from text and convert to XmString type */ str = XmTextFieldGetString (client_data->selection_box.text); cb.value = XmStringGenerate(str, XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL); XtFree (str); cb.length = XmStringLength (cb.value); XtCallCallbackList ((Widget) client_data, client_data->command.value_changed_callback, &cb); XmStringFree (cb.value); return ; }
/* ** CreateListData(): routine to convert the ** poem into an array of compound strings */ XmStringTable CreateListData (int *count) { XmStringTable table = (XmStringTable) 0 ; int line = 0 ; int column = 0 ; int index = 0 ; XmString entry ; XmString row =NULL; XmString tmp =NULL; XmString tab; tab = XmStringComponentCreate (XmSTRING_COMPONENT_TAB, 0, NULL); while (poem[index] != (char *) 0) { /* create a compound string, using the rendition tag */ entry = XmStringGenerate ((XtPointer) poem[index], NULL, XmCHARSET_TEXT, rendition_data[column].tag) ; if (row != (XmString)NULL) { tmp = XmStringConcat (row, tab) ; XmStringFree (row) ; row = XmStringConcatAndFree (tmp, entry) ; } else { row = entry ; } ++column ; if (column == MAX_COLUMNS) { if (table == (XmStringTable) 0) { table = (XmStringTable) XtMalloc((unsigned) 1 * sizeof (XmString)) ; } else { table = (XmStringTable) XtRealloc((char *) table, (unsigned) (line + 1) * sizeof (XmString)) ; } table[line++] = row ; row = (XmString) 0 ; column = 0 ; } index++ ; } XmStringFree (tab) ; table[line] = (XmString) 0 ; *count = line ; return table ; }
static void build_menu(Widget widget, XtPointer clientdata, XtPointer call_data) { WidgetList children,wlist; Cardinal nchildren; const SANE_Device **list; Widget push; XmString str; char action[256]; int rc,i; /* del old */ XtVaGetValues(widget, XtNchildren,&children, XtNnumChildren,&nchildren, NULL); wlist = malloc(sizeof(Widget*)*nchildren); memcpy(wlist,children,sizeof(Widget*)*nchildren); for (i = 0; i < nchildren; i++) XtDestroyWidget(wlist[i]); free(wlist); /* create new */ if (SANE_STATUS_GOOD != (rc = sane_init(NULL,NULL))) { fprintf(stderr,"sane_init: %s\n",sane_strstatus(rc)); goto done; } sane_get_devices(&list,0); if (NULL == list[0]) goto done; for (i = 0; list[i] != NULL; i++) { if (debug) fprintf(stderr,"sane dev: %s | %s | %s | %s\n", list[i]->name, list[i]->vendor, list[i]->model, list[i]->type); str = XmStringGenerate((char*)list[i]->model, NULL, XmMULTIBYTE_TEXT, NULL); push = XtVaCreateManagedWidget(list[i]->name, xmPushButtonWidgetClass,widget, XmNlabelString,str, NULL); XmStringFree(str); sprintf(action,"Scan(%s)",list[i]->name); XtAddCallback(push,XmNactivateCallback,action_cb,strdup(action)); } done: sane_exit(); }
void main(int argc, char **argv) { XmStringTable ColumnDetails; int i,j; Cardinal n; Arg args[MAX_ARGS]; int test_num; char test_char; char ContainerName[NAME_LEN + 1]; Pixmap CollapsedStatePixmap, ExpandedStatePixmap; ContainerName[0] = '\0'; test_num = 0; test_char = '\0'; CommonTestInit(argc, argv); if (UserData != NULL) { if (strcmp(UserData, "a") == 0) test_num = 1; else if (strcmp(UserData, "b") == 0) test_num = 2; else if (strcmp(UserData, "c") == 0) test_num = 3; else if (strcmp(UserData, "d") == 0) test_num = 4; test_char = *UserData; free(UserData); } sprintf(ContainerName, "Container3%c", test_char); CollapsedStatePixmap = XCreatePixmapFromBitmapData(display, rootWindow, collapsedState_bits, collapsedState_width, collapsedState_height, CommonGetColor("black"), CommonGetColor("white"), XDefaultDepth(display, XDefaultScreen(display))); ExpandedStatePixmap = XCreatePixmapFromBitmapData(display, rootWindow, expandedState_bits, expandedState_width, expandedState_height, CommonGetColor("white"), CommonGetColor("black"), XDefaultDepth(display, XDefaultScreen(display))); ColumnHeadings = (XmStringTable) XtMalloc(NUM_COL * sizeof(XmString)); for (i = 0; i < NUM_COL; i++) ColumnHeadings[i] = XmStringGenerate(ColumnHeadingText[i], NULL, XmCHARSET_TEXT, NULL); n = 0; XtSetArg(args[n], XmNentryViewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNlayoutType, XmOUTLINE); n++; XtSetArg(args[n], XmNautomaticSelection, XmNO_AUTO_SELECT); n++; XtSetArg(args[n], XmNdetailColumnHeading, ColumnHeadings); n++; XtSetArg(args[n], XmNdetailColumnHeadingCount, NUM_COL); n++; XtSetArg(args[n], XmNdetailOrderCount, NUM_COL-1); n++; XtSetArg(args[n], XmNcollapsedStatePixmap, CollapsedStatePixmap); n++; XtSetArg(args[n], XmNexpandedStatePixmap, ExpandedStatePixmap); n++; Container3 = XmCreateContainer(Shell1, ContainerName, args, n); XtManageChild(Container3); EntryDetails = (XmStringTable *) XtMalloc(NUM_OBJ * sizeof(XmStringTable)); for (i = 0; i < NUM_OBJ; i++) { ColumnDetails = (XmStringTable)XtMalloc((NUM_COL-1) * sizeof(XmString)); ColumnDetails[0] = XmStringGenerate(FullTitleText[i], NULL, XmCHARSET_TEXT, NULL); ColumnDetails[1] = XmStringGenerate(FlavorText[i], NULL, XmCHARSET_TEXT, NULL); ColumnDetails[2] = XmStringGenerate(AgeText[i], NULL, XmCHARSET_TEXT, NULL); EntryDetails[i] = ColumnDetails; } n = 0; XtSetArg(args[n], XmNx, 100); n++; XtSetArg(args[n], XmNy, 100); n++; XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[0]); n++; IconGad1 = XmCreateIconGadget(Container3, "IconGad1", args, n); XtManageChild(IconGad1); n = 0; XtSetArg(args[n], XmNx, 200); n++; XtSetArg(args[n], XmNy, 200); n++; XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[1]); n++; IconGad2 = XmCreateIconGadget(Container3, "IconGad2", args, n); XtManageChild(IconGad2); n = 0; XtSetArg(args[n], XmNx, 300); n++; XtSetArg(args[n], XmNy, 100); n++; XtSetArg(args[n], XmNentryViewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[2]); n++; IconGad3 = XmCreateIconGadget(Container3, "IconGad3", args, n); XtManageChild(IconGad3); n = 0; XtSetArg(args[n], XmNx, 50); n++; XtSetArg(args[n], XmNy, 400); n++; XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[3]); n++; IconGad4 = XmCreateIconGadget(Container3, "IconGad4", args, n); XtManageChild(IconGad4); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetail, EntryDetails[4]); n++; IconGad31 = XmCreateIconGadget(Container3, "IconGad31", args, n); XtManageChild(IconGad31); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetail, EntryDetails[5]); n++; IconGad32 = XmCreateIconGadget(Container3, "IconGad32", args, n); XtManageChild(IconGad32); n = 0; XtSetArg(args[n], XmNentryParent, IconGad32); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNentryViewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetail, EntryDetails[6]); n++; IconGad321 = XmCreateIconGadget(Container3, "IconGad321", args, n); XtManageChild(IconGad321); n = 0; XtSetArg(args[n], XmNentryParent, IconGad321); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNentryViewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetail, EntryDetails[7]); n++; IconGad3211 = XmCreateIconGadget(Container3, "IconGad3211", args, n); XtManageChild(IconGad3211); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetail, EntryDetails[8]); n++; IconGad33 = XmCreateIconGadget(Container3, "IconGad33", args, n); XtManageChild(IconGad33); for (i = 0; i < NUM_OBJ; i++) { ColumnDetails = EntryDetails[i]; for (j = 0; j < NUM_COL-1; j++) XmStringFree(ColumnDetails[j]); XtFree((XtPointer)ColumnDetails); } XtFree((XtPointer)EntryDetails); XtRealizeWidget(Shell1); CommonPause(); if ((test_num == 1) || (test_num == 2)) { CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); for (i = 0; i < NUM_COL; i++) XmStringFree(ColumnHeadings[i]); XtFree((XtPointer)ColumnHeadings); } if (test_num == 3) { CommonPause(); for (i = 0; i < NUM_COL; i++) XmStringFree(ColumnHeadings[i]); XtFree((XtPointer)ColumnHeadings); } XtAppMainLoop(app_context); }
void main(int argc, char **argv) { Widget Container5, *IconGad; int i, num_obj; Cardinal n; Arg args[MAX_ARGS]; char test_char; int test_num; char ContainerName[NAME_LEN + 1]; ContainerName[0] = '\0'; test_char = '\0'; test_num = 0; CommonTestInit(argc, argv); num_obj = 10; if (UserData != NULL) { if (strcmp(UserData, "a") == 0) { num_obj = 4; test_num = 1; } if (strcmp(UserData, "b") == 0) { num_obj = 5; test_num = 2; } if (strcmp(UserData, "c") == 0) { num_obj = 9; test_num = 3; } if (strcmp(UserData, "d") == 0) { num_obj = 20; test_num = 4; } if (strcmp(UserData, "e") == 0) { num_obj = 4; test_num = 5; } test_char = *UserData; free(UserData); } sprintf(ContainerName, "Container5%c", test_char); n = 0; Container5 = XmCreateContainer(Shell1, ContainerName, args, n); XtManageChild(Container5); XtRealizeWidget(Shell1); CommonPause(); /* Add a bunch of Icon Gadgets */ IconGad = (Widget*) XtMalloc(NUM_OBJ*sizeof(Widget)); for (i = 0; i < num_obj; i++) { char IconName[20] ; XmString icon_name; n = 0 ; sprintf(IconName, "IconGad%d", i); icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); XtSetArg(args[n], XmNlabelString, icon_name); n++; IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n); XtManageChild(IconGad[i]); XmStringFree(icon_name); } CommonPause(); if (test_num == 0 || test_num == 1) { /* Set the Spatial Style to None */ n = 0; XtSetArg(args[n], XmNspatialStyle, XmNONE); n++; XtSetValues(Container5, args, n); CommonPause(); /* Unmanage all the children - Change the ResizeModel - and Remanage */ XtUnmanageChildren(IconGad, num_obj); n = 0; XtSetArg(args[n], XmNspatialStyle, XmGRID); n++; XtSetArg(args[n], XmNspatialResizeModel, XmGROW_BALANCED); n++; XtSetValues(Container5, args, n); XtManageChildren(IconGad, num_obj); CommonPause(); } if (test_num == 2) { int new_obj; /* Test the different ResizeModel - Start by adding children with grow_balanced, then add with grow_major and then grow_minor. */ new_obj = 4; for (i = num_obj; i < (num_obj+new_obj); i++) { char IconName[20] ; XmString icon_name; n = 0 ; sprintf(IconName, "IconGad%d", i); icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); XtSetArg(args[n], XmNlabelString, icon_name); n++; IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n); XmStringFree(icon_name); } XtManageChildren(&IconGad[num_obj], new_obj); num_obj = num_obj + new_obj; CommonPause(); new_obj = 5; n = 0; XtSetArg(args[n], XmNspatialResizeModel, XmGROW_MAJOR); n++; XtSetValues(Container5, args, n); for (i = num_obj; i < (num_obj+new_obj); i++) { char IconName[20] ; XmString icon_name; n = 0 ; sprintf(IconName, "IconGad%d", i); icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); XtSetArg(args[n], XmNlabelString, icon_name); n++; IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n); XmStringFree(icon_name); } XtManageChildren(&IconGad[num_obj], new_obj); num_obj = num_obj + new_obj; CommonPause(); n = 0; XtSetArg(args[n], XmNspatialResizeModel, XmGROW_MINOR); n++; XtSetValues(Container5, args, n); for (i = num_obj; i < (num_obj+new_obj); i++) { char IconName[20] ; XmString icon_name; n = 0 ; sprintf(IconName, "IconGad%d", i); icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); XtSetArg(args[n], XmNlabelString, icon_name); n++; IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n); XmStringFree(icon_name); } XtManageChildren(&IconGad[num_obj], new_obj); num_obj = num_obj + new_obj; } if (test_num == 3) { char IconName[20]; XmString icon_name; /* Change the spatialStyle to GRID */ n = 0; XtSetArg(args[n], XmNspatialStyle, XmGRID); n++; XtSetValues(Container5, args, n); CommonPause(); /* Test the spatialIncludeModel Add some children and check where they go */ i = num_obj; n = 0 ; sprintf(IconName, "IconGad%d", i); icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); XtSetArg(args[n], XmNlabelString, icon_name); n++; IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n); XmStringFree(icon_name); XtManageChild(IconGad[i]); CommonPause(); /* set the spatialIncludeModel to FIRST_FIT */ n = 0; XtSetArg(args[n], XmNspatialIncludeModel, XmFIRST_FIT); n++; XtSetValues(Container5, args, n); i = num_obj + 1; n = 0 ; sprintf(IconName, "IconGad%d", i); icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); XtSetArg(args[n], XmNlabelString, icon_name); n++; IconGad[i] = XmCreateIconGadget(Container5, IconName, args, n); XmStringFree(icon_name); XtManageChild(IconGad[i]); } CommonPause(); XtAppMainLoop(app_context); }
int main(int argc, char **argv) { Widget ScrollWin, Container, *IconGad; int i; Cardinal n; Arg args[MAX_ARGS]; Dimension x_size, y_size; CommonTestInit(argc, argv); n = 0; XtSetArg( args[n], XmNx, 20 ); n++; ScrollWin = XmCreateScrolledWindow(Shell1, "ScrollWin7", args, n); XtManageChild(ScrollWin); XtSetArg(args[n], XmNselectionPolicy, XmMULTIPLE_SELECT); n++; XtSetArg(args[n], XmNspatialStyle, XmNONE ); n++; Container = XmCreateContainer(ScrollWin, "Container7", args, n); XtManageChild(Container); /* Add a bunch of Icon Gadgets */ IconGad = (Widget*) XtMalloc(NUM_ELEMS * sizeof(Widget)); /* Put some pixmaps in the Container */ for (i = 0; i < NUM_PIXMAP; i++) { char IconName[20] ; XmString icon_name; Pixmap pixmap; n = 0 ; sprintf(IconName, "IconGad%d", i); icon_name = XmStringGenerate(IconName, NULL, XmCHARSET_TEXT, NULL); /* make icons from pixmap files */ pixmap = XmGetPixmap(screen, BitmapPaths[i], BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); if (!pixmap) { printf("Can't make pixmap for file %s!\n", BitmapPaths[i]); exit(1); } XtSetArg(args[n], XmNx, PIXEL_X(i) ); n++; XtSetArg(args[n], XmNy, PIXEL_Y(i) ); n++; XtSetArg(args[n], XmNlabelString, icon_name); n++; XtSetArg(args[n], XmNlargeIconPixmap, pixmap); n++; IconGad[i] = XmCreateIconGadget(Container, IconName, args, n); XtManageChild(IconGad[i]); XmStringFree(icon_name); } /* Put some labels in the Container */ for (i = NUM_PIXMAP; i < NUM_ELEMS; i++) { char LabelName[20] ; XmString label_name; n = 0 ; sprintf(LabelName, "LabelName%d", i); label_name = XmStringGenerate(LabelName, NULL, XmCHARSET_TEXT, NULL); XtSetArg(args[n], XmNx, PIXEL_X(i) ); n++; XtSetArg(args[n], XmNy, PIXEL_Y(i) ); n++; XtSetArg(args[n], XmNlabelString, label_name); n++; XtSetArg(args[n], XmNlabelType, XmSTRING); n++; IconGad[i] = XmCreateIconGadget(Container, LabelName, args, n); XtManageChild(IconGad[i]); XmStringFree(label_name); } XtRealizeWidget(Shell1); /* Find out the default size for X and Y */ n = 0; XtSetArg( args[n], XmNwidth, &x_size ); n++; XtSetArg( args[n], XmNheight, &y_size ); n++; XtGetValues( ScrollWin, args, n ); /************************* * Assertions begin */ /* Assertions 1 and 2 */ n = 0; XtSetArg( args[n], XmNwidth, 175 ); n++; XtSetValues( ScrollWin, args, n ); CommonPause(); RestoreXY( ScrollWin, x_size, y_size ); UnselectAll( Container ); /* Assertions 3 and 4 */ n = 0; XtSetArg( args[n], XmNwidth, 400 ); n++; XtSetValues( ScrollWin, args, n ); CommonPause(); RestoreXY( ScrollWin, x_size, y_size ); UnselectAll( Container ); /* Assertions 5 and 6 */ n = 0; XtSetArg( args[n], XmNheight, 400 ); n++; XtSetValues( ScrollWin, args, n ); CommonPause(); RestoreXY( ScrollWin, x_size, y_size ); UnselectAll( Container ); /* Assertions 7 and 8 */ CommonPause(); XtAppMainLoop(app_context); for ( i=0; i < NUM_ELEMS; i++ ) XtDestroyWidget( IconGad[i] ); XtDestroyWidget( Container ); XtDestroyWidget( ScrollWin ); XtFree( (char *)IconGad ); }
/****************************************************************************** * Function: int FormatChunksToXmString () * * Parameters: * *ret_list may be NULL when called * * Returns: 0 if successful, -1 if errors * * errno Values: * * Purpose: Take some rich text chunks and turn it into an XmString. * ******************************************************************************/ static int FormatChunksToXmString( DtHelpDispAreaStruct *pDAS, Boolean free_flag, void **title_chunks, XmString *ret_title, XmFontList *ret_list, Boolean *ret_mod ) { int result = 0; int i; long j; int quarkCount; long chunkType; long myIdx; _DtCvPointer fontPtr; char *charSet; const char *strChunk; char buffer[16]; _DtHelpFontHints fontSpecs; XmFontContext fontContext; XmString partTitle; XmString newTitle; XrmQuark charSetQuark; XrmName myCharSetQuarks[20]; XrmName xrmName[_CEFontAttrNumber]; Boolean myMore; /* * Initialize the pointers. */ *ret_title = NULL; *ret_mod = False; if (title_chunks == NULL) return -1; /* * initialize the font context */ _DtHelpCeCopyDefFontAttrList(&fontSpecs); if ( NULL != *ret_list ) { if (XmFontListInitFontContext (&fontContext, *ret_list) == False) result = -1; else { XFontStruct *myFontStruct; /* * quarkize all the character sets found. */ quarkCount = 0; do { myMore = XmFontListGetNextFont (fontContext, &charSet, &myFontStruct); if (myMore) { myCharSetQuarks[quarkCount++] = XrmStringToQuark (charSet); XtFree (charSet); } } while (myMore); XmFontListFreeFontContext (fontContext); } } /* if NULL != *ret_list */ else { /* if NULL == *ret_list */ quarkCount = 0; myCharSetQuarks[0] = 0; } /* * Build the XrmString based on the segments. * The format of the returned information is * 'DT_HELP_CE_CHARSET locale string' * 'DT_HELP_CE_FONT_PTR fontptr string' * 'DT_HELP_CE_SPC spc' * 'DT_HELP_CE_STRING string' - uses last specified * charset/font_ptr. * * The order and manner in which the title_chunks are processed * is known and depended upon in several locations. * Do not change this without changing the other locations. * See the _DtHelpFormatxxx() routines and the ones that * create the title_chunk arrays in FormatSDL.c and FormatCCDF.c */ myIdx = __DtHelpDefaultFontIndexGet(pDAS); _DtHelpCopyDefaultList(xrmName); for (i = 0; result == 0 && title_chunks[i] != DT_HELP_CE_END; i++) { /* * create a string for the char set and a quark for it. */ chunkType = (long) title_chunks[i++]; /* * i now points to the first value after the type */ if (chunkType & DT_HELP_CE_CHARSET) { char *charSet; char *lang = (char *) title_chunks[i]; /* * test to see if the locale is in a lang.codeset form */ if (_DtHelpCeStrchr(lang, ".", 1, &charSet) == 0) { *charSet = '\0'; charSet++; } else { charSet = lang; lang = NULL; } /* * resolve/load the font for the default fonts */ _DtHelpDAResolveFont(pDAS, lang, charSet, fontSpecs, &fontPtr); myIdx = (long) fontPtr; if (lang != NULL) { charSet--; *charSet = '.'; } if (free_flag) free(title_chunks[i]); /* * move the i to point to the string. */ i++; } else if (chunkType & DT_HELP_CE_FONT_PTR) { /* * get the default font for the language and code set. */ (void) __DtHelpFontCharSetQuarkGet(pDAS, (long)title_chunks[i], &xrmName[_DT_HELP_FONT_CHAR_SET]); (void) __DtHelpFontLangQuarkGet(pDAS, (long)title_chunks[i], &xrmName[_DT_HELP_FONT_LANG_TER]); (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx); /* * move the i to point to the string. */ i++; } /* * the i point spc or string. */ if (chunkType & DT_HELP_CE_SPC) { j = (long) title_chunks[i]; strChunk = _DtHelpDAGetSpcString(pDAS->spc_chars[j].spc_idx); fontPtr = pDAS->spc_chars[j].font_ptr; /* * get the default font for the language and code set. */ (void) __DtHelpFontCharSetQuarkGet(pDAS, (long)fontPtr, &xrmName[_DT_HELP_FONT_CHAR_SET]); (void) __DtHelpFontLangQuarkGet(pDAS, (long)fontPtr, &xrmName[_DT_HELP_FONT_LANG_TER]); (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx); } else /* if (chunkType & _DT_HELP_CE_STRING) */ strChunk = (char *) title_chunks[i]; sprintf(buffer, "%ld", myIdx); charSetQuark = XrmStringToQuark(buffer); j = 0; while (j < quarkCount && myCharSetQuarks[j] != charSetQuark) j++; /* * If we didn't find a matching character set, * add it to the list. */ if (j >= quarkCount) { /* Copy the input list so XmFontListAppendEntry can mangle it. */ /* But only do it once! */ if (False == *ret_mod) *ret_list = XmFontListCopy(*ret_list); if (myIdx < 0) { XFontSet fontSet = __DtHelpFontSetGet(pDAS->font_info, myIdx); XmFontListEntry fontEntry; fontEntry = XmFontListEntryCreate (buffer, XmFONT_IS_FONTSET, (XtPointer) fontSet); *ret_list = XmFontListAppendEntry (*ret_list, fontEntry); XmFontListEntryFree (&fontEntry); } else { XFontStruct *fontStruct = __DtHelpFontStructGet(pDAS->font_info, myIdx); XmFontListEntry fontEntry; fontEntry = XmFontListEntryCreate (buffer, XmFONT_IS_FONT, (XtPointer) fontStruct); *ret_list = XmFontListAppendEntry (*ret_list, fontEntry); XmFontListEntryFree (&fontEntry); } *ret_mod = True; if (*ret_list == NULL) result = -1; myCharSetQuarks[quarkCount++] = charSetQuark; } /* * add this segment to the XmString. */ if (result == 0) { if (*ret_title == NULL) *ret_title = XmStringGenerate ((char *) strChunk, buffer, XmCHARSET_TEXT, NULL); else { partTitle = XmStringGenerate ((char *) strChunk, buffer, XmCHARSET_TEXT, NULL); newTitle = XmStringConcat (*ret_title, partTitle); XmStringFree (*ret_title); XmStringFree (partTitle); *ret_title = newTitle; } /* * if a newline was specified, * replace it with a blank. */ if (*ret_title != NULL && (chunkType & DT_HELP_CE_NEWLINE)) { partTitle = XmStringGenerate (" ", buffer, XmCHARSET_TEXT, NULL); newTitle = XmStringConcat (*ret_title, partTitle); XmStringFree (*ret_title); XmStringFree (partTitle); *ret_title = newTitle; } if (*ret_title == NULL) result = -1; } if (free_flag && (chunkType & DT_HELP_CE_STRING)) free(title_chunks[i]); } /* * deallocate the memory. */ if (free_flag) free(title_chunks); return result; }
void main(int argc, char **argv) { int i,j; Cardinal n; XmString Label; Arg args[MAX_ARGS]; int test_num; char test_char; char ContainerName[NAME_LEN + 1]; ContainerName[0] = '\0'; test_num = 0; test_char = '\0'; CommonTestInit(argc, argv); if (UserData != NULL) { if (strcmp(UserData, "a") == 0) test_num = 1; else if (strcmp(UserData, "b") == 0) test_num = 2; else if (strcmp(UserData, "c") == 0) test_num = 3; else if (strcmp(UserData, "d") == 0) test_num = 4; test_char = *UserData; free(UserData); } sprintf(ContainerName, "Container4%c", test_char); /* * Create a main window */ n = 0; XtSetArg(args[n], XmNborderWidth, 2); n++; MainW1 = XmCreateMainWindow(Shell1, "MainW1", args, n); XtManageChild(MainW1); /* * Create a menu bar with a pulldown menu for interacting with the * clipboard */ n = 0; menubar1 = XmCreateMenuBar(MainW1, "menubar1", args, n); XtManageChild(menubar1); n = 0; pulldown1 = XmCreatePulldownMenu(menubar1, "pulldown1", args, n); Label = XmStringCreate("Edit", XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(args[n], XmNlabelString, Label); n++; XtSetArg(args[n], XmNsubMenuId, pulldown1); n++; menu_btn1 = XmCreateCascadeButton(menubar1, "menu_btn1", args, n); XtManageChild(menu_btn1); XmStringFree(Label); n = 0; Label = XmStringCreate("Cut", XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, Label); n++; XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; CutPB1 = XmCreatePushButtonGadget(pulldown1, "CutPB1", args, n); XtManageChild(CutPB1); XmStringFree(Label); n = 0; Label = XmStringCreate("Copy", XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, Label); n++; XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; CopyPB1 = XmCreatePushButtonGadget(pulldown1, "CopyPB1", args, n); XtManageChild(CopyPB1); XmStringFree(Label); n = 0; Label = XmStringCreate("Copy Link", XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, Label); n++; XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; CopyLinkPB1 = XmCreatePushButtonGadget(pulldown1, "CopyLinkPB1", args, n); XtManageChild(CopyLinkPB1); XmStringFree(Label); n = 0; Label = XmStringCreate("Paste", XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, Label); n++; XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; PastePB1 = XmCreatePushButtonGadget(pulldown1, "PastePB1", args, n); XtManageChild(PastePB1); XmStringFree(Label); n = 0; Label = XmStringCreate("Paste Link", XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, Label); n++; XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; PasteLinkPB1= XmCreatePushButtonGadget(pulldown1, "PasteLinkPB1", args, n); XtManageChild(PasteLinkPB1); XmStringFree(Label); /* * Create the container */ ColumnHeadings = (XmStringTable) XtMalloc(NUM_COL * sizeof(XmString)); for (i = 0; i < NUM_COL; i++) ColumnHeadings[i] = XmStringGenerate(ColumnHeadingText[i], NULL, XmCHARSET_TEXT, NULL); n = 0; XtSetArg(args[n], XmNdetailColumnHeading, ColumnHeadings); n++; XtSetArg(args[n], XmNdetailColumnHeadingCount, NUM_COL); n++; XtSetArg(args[n], XmNdetailOrderCount, NUM_COL-1); n++; Container4 = XmCreateContainer(MainW1, ContainerName, args, n); XtManageChild(Container4); XtAddCallback(Container4, XmNdefaultActionCallback, PrintChildrenCB, NULL); XtAddCallback(Container4, XmNconvertCallback, ConvertCB, NULL); XtAddCallback(Container4, XmNdestinationCallback, DestinationCB, NULL); XtAddCallback(CutPB1, XmNactivateCallback, CutCB, (XtPointer) Container4); XtAddCallback(CopyPB1, XmNactivateCallback, CopyCB, (XtPointer)Container4); XtAddCallback(CopyLinkPB1, XmNactivateCallback, CopyLinkCB, (XtPointer) Container4); XtAddCallback(PastePB1, XmNactivateCallback, PasteCB, (XtPointer) Container4); XtAddCallback(PasteLinkPB1, XmNactivateCallback, PasteLinkCB, (XtPointer) Container4); for (i=0; i<NUM_COL; i++) XmStringFree(ColumnHeadings[i]); XtFree((XtPointer) ColumnHeadings); EntryDetails = (XmStringTable *) XtMalloc(NUM_OBJ * sizeof(XmStringTable)); for (i = 0; i < NUM_OBJ; i++) { ColumnHeadings = (XmStringTable)XtMalloc((NUM_COL-1) * sizeof(XmString)); ColumnHeadings[0] = XmStringGenerate(FullTitleText[i], NULL, XmCHARSET_TEXT, NULL); ColumnHeadings[1] = XmStringGenerate(FlavorText[i], NULL, XmCHARSET_TEXT, NULL); ColumnHeadings[2] = XmStringGenerate(AgeText[i], NULL, XmCHARSET_TEXT, NULL); EntryDetails[i] = ColumnHeadings; } n = 0; XtSetArg(args[n], XmNx, 100); n++; XtSetArg(args[n], XmNy, 100); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[0]); n++; IconGad1 = XmCreateIconGadget(Container4, "IconGad1", args, n); XtManageChild(IconGad1); n = 0; XtSetArg(args[n], XmNx, 200); n++; XtSetArg(args[n], XmNy, 200); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[1]); n++; IconGad2 = XmCreateIconGadget(Container4, "IconGad2", args, n); XtManageChild(IconGad2); n = 0; XtSetArg(args[n], XmNx, 300); n++; XtSetArg(args[n], XmNy, 100); n++; XtSetArg(args[n], XmNviewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[2]); n++; IconGad3 = XmCreateIconGadget(Container4, "IconGad3", args, n); XtManageChild(IconGad3); n = 0; XtSetArg(args[n], XmNx, 50); n++; XtSetArg(args[n], XmNy, 400); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[3]); n++; IconGad4 = XmCreateIconGadget(Container4, "IconGad4", args, n); XtManageChild(IconGad4); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetail, EntryDetails[4]); n++; IconGad31 = XmCreateIconGadget(Container4, "IconGad31", args, n); XtManageChild(IconGad31); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[5]); n++; IconGad32 = XmCreateIconGadget(Container4, "IconGad32", args, n); XtManageChild(IconGad32); n = 0; XtSetArg(args[n], XmNentryParent, IconGad32); n++; XtSetArg(args[n], XmNviewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[6]); n++; IconGad321 = XmCreateIconGadget(Container4, "IconGad321", args, n); XtManageChild(IconGad321); n = 0; XtSetArg(args[n], XmNentryParent, IconGad321); n++; XtSetArg(args[n], XmNviewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[7]); n++; IconGad3211 = XmCreateIconGadget(Container4, "IconGad3211", args, n); XtManageChild(IconGad3211); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[8]); n++; IconGad33 = XmCreateIconGadget(Container4, "IconGad33", args, n); XtManageChild(IconGad33); n = 0; XtSetArg(args[n], XmNx, 70); n++; XtSetArg(args[n], XmNy, 420); n++; XtSetArg(args[n], XmNviewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[9]); n++; IconGad5 = XmCreateIconGadget(Container4, "IconGad5", args, n); XtManageChild(IconGad5); XmMainWindowSetAreas(MainW1, menubar1, NULL, NULL, NULL, Container4); for (i = 0; i < NUM_OBJ; i++) { ColumnHeadings = EntryDetails[i]; for (j = 0; j < NUM_COL-1; j++) XmStringFree(ColumnHeadings[j]); XtFree((XtPointer)ColumnHeadings); } XtFree((XtPointer)EntryDetails); XtRealizeWidget(Shell1); CommonPause(); CommonPause(); XmContainerRelayout(Container4); CommonPause(); if ((test_num == 1) || (test_num == 2)) { TestContainerReorder(); CommonPause(); } /* * Create another Container for UTM testing */ CreateAnotherContainer(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); XtAppMainLoop(app_context); }
/*ARGSUSED*/ void _XmCommandReturn( Widget wid, XEvent *event, String *params, /* unused */ Cardinal *numParams ) /* unused */ { XmCommandWidget w = (XmCommandWidget) wid ; XmCommandCallbackStruct cb; XmString tmpXmString; String tmpString; Arg argv[5] ; Cardinal argc ; int count ; /****************/ /* if an error has been sent to the history list, remove it now */ if (w->command.error) { XmListDeletePos (w->selection_box.list, 0); /* delete error msg */ XmListDeletePos (w->selection_box.list, 0); /* delete blank line */ w->command.error = FALSE; XmListSetBottomPos (w->selection_box.list, 0); } /* update the history: - get text, check null/empty */ /* - create XmString from text */ /* - increment local list count */ /* - add to history list */ /* - delete first element if too */ /* many items (maxItemCount) */ /* - position list to end */ /* - reset selection list ptr */ /* - reset command to "" */ tmpString = XmTextFieldGetString (w->selection_box.text); if ((tmpString == NULL) || (strcmp(tmpString, "") == 0)) { if (tmpString) XtFree(tmpString); return; } argc = 0 ; XtSetArg( argv[argc], XmNitemCount, &count) ; ++argc ; XtGetValues( SB_List( w), argv, argc) ; /* if already at max items, remove first item in list */ if (count >= w->command.history_max_items) { XmListDeletePos (w->selection_box.list, 1); if (w->selection_box.list_selected_item_position > 0) w->selection_box.list_selected_item_position--; } tmpXmString = XmStringGenerate(tmpString, XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL); XmListAddItemUnselected (w->selection_box.list, tmpXmString, 0); XmListSetBottomPos (w->selection_box.list, 0); XmTextFieldSetString (w->selection_box.text, ""); /* call the users command entered callback */ cb.reason = XmCR_COMMAND_ENTERED; cb.event = event; cb.value = tmpXmString; cb.length = XmStringLength (tmpXmString); XtCallCallbackList ((Widget) w, w->command.callback, &cb); XmStringFree (tmpXmString); XtFree (tmpString); return ; }
void main(int argc, char **argv) { XmStringTable ColumnHeadings; int i,j; Cardinal n; Arg args[MAX_ARGS]; int test_num; char test_char; char ContainerName[NAME_LEN + 1]; Pixmap CollapsedStatePixmap, ExpandedStatePixmap; WidgetList SelectedObjects; unsigned int SelectedObjectCount; ContainerName[0] = '\0'; test_num = 0; test_char = '\0'; CommonTestInit(argc, argv); if (UserData != NULL) { if (strcmp(UserData, "a") == 0) test_num = 1; else if (strcmp(UserData, "b") == 0) test_num = 2; else if (strcmp(UserData, "c") == 0) test_num = 3; else if (strcmp(UserData, "d") == 0) test_num = 4; else if (strcmp(UserData, "e") == 0) test_num = 5; else if (strcmp(UserData, "f") == 0) test_num = 6; else if (strcmp(UserData, "g") == 0) test_num = 7; else if (strcmp(UserData, "h") == 0) test_num = 8; else if (strcmp(UserData, "j") == 0) test_num = 9; else if (strcmp(UserData, "k") == 0) test_num = 10; else if (strcmp(UserData, "l") == 0) test_num = 11; else if (strcmp(UserData, "m") == 0) test_num = 12; else if (strcmp(UserData, "n") == 0) test_num = 13; else if (strcmp(UserData, "z") == 0) test_num = 26; test_char = *UserData; free(UserData); } sprintf(ContainerName, "Container1%c", test_char); CollapsedStatePixmap = XCreatePixmapFromBitmapData(display, rootWindow, collapsedState_bits, collapsedState_width, collapsedState_height, CommonGetColor("black"), CommonGetColor("white"), XDefaultDepth(display, XDefaultScreen(display))); ExpandedStatePixmap = XCreatePixmapFromBitmapData(display, rootWindow, expandedState_bits, expandedState_width, expandedState_height, CommonGetColor("white"), CommonGetColor("black"), XDefaultDepth(display, XDefaultScreen(display))); ColumnHeadings = (XmStringTable) XtMalloc(NUM_COL * sizeof(XmString)); for (i = 0; i < NUM_COL; i++) ColumnHeadings[i] = XmStringGenerate(ColumnHeadingText[i], NULL, XmCHARSET_TEXT, NULL); n = 0; /* Don't want to set the following resources for Container1l test */ if (test_num != 11) { XtSetArg(args[n], XmNdetailColumnHeading, ColumnHeadings); n++; XtSetArg(args[n], XmNdetailColumnHeadingCount, NUM_COL); n++; } XtSetArg(args[n], XmNcollapsedStatePixmap, CollapsedStatePixmap); n++; XtSetArg(args[n], XmNexpandedStatePixmap, ExpandedStatePixmap); n++; Container1 = XmCreateContainer(Shell1, ContainerName, args, n); XtManageChild(Container1); XtAddCallback(Container1, XmNdefaultActionCallback, DefaultActionCB, NULL); XtAddCallback(Container1, XmNselectionCallback, SelectCB, NULL); XtAddCallback(Container1, XmNoutlineChangedCallback, OutlineCB, NULL); for (i = 0; i < NUM_COL; i++) XmStringFree(ColumnHeadings[i]); XtFree((XtPointer)ColumnHeadings); EntryDetails = (XmStringTable *) XtMalloc(NUM_OBJ * sizeof(XmStringTable)); for (i = 0; i < NUM_OBJ; i++) { ColumnHeadings = (XmStringTable)XtMalloc((NUM_COL-1) * sizeof(XmString)); ColumnHeadings[0] = XmStringGenerate(FullTitleText[i], NULL, XmCHARSET_TEXT, NULL); ColumnHeadings[1] = XmStringGenerate(FlavorText[i], NULL, XmCHARSET_TEXT, NULL); ColumnHeadings[2] = XmStringGenerate(AgeText[i], NULL, XmCHARSET_TEXT, NULL); EntryDetails[i] = ColumnHeadings; } n = 0; /* Don't want to set the following resource for Container1m test*/ if (test_num != 12) XtSetArg(args[n], XmNvisualEmphasis, XmSELECTED); n++; XtSetArg(args[n], XmNx, 100); n++; XtSetArg(args[n], XmNy, 100); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[0]); n++; IconGad1 = XmCreateIconGadget(Container1, "IconGad1", args, n); XtManageChild(IconGad1); n = 0; XtSetArg(args[n], XmNx, 200); n++; XtSetArg(args[n], XmNy, 200); n++; XtSetArg(args[n], XmNwidth, 50); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[1]); n++; IconGad2 = XmCreateIconGadget(Container1, "IconGad2", args, n); XtManageChild(IconGad2); n = 0; XtSetArg(args[n], XmNx, 300); n++; XtSetArg(args[n], XmNy, 100); n++; XtSetArg(args[n], XmNviewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[2]); n++; IconGad3 = XmCreateIconGadget(Container1, "IconGad3", args, n); XtManageChild(IconGad3); n = 0; XtSetArg(args[n], XmNx, 50); n++; XtSetArg(args[n], XmNy, 400); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[3]); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; IconGad4 = XmCreateIconGadget(Container1, "IconGad4", args, n); XtManageChild(IconGad4); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[4]); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; IconGad31 = XmCreateIconGadget(Container1, "IconGad31", args, n); XtManageChild(IconGad31); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[5]); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; IconGad32 = XmCreateIconGadget(Container1, "IconGad32", args, n); XtManageChild(IconGad32); n = 0; XtSetArg(args[n], XmNentryParent, IconGad32); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[6]); n++; XtSetArg(args[n], XmNviewType, XmLARGE_ICON); n++; IconGad321 = XmCreateIconGadget(Container1, "IconGad321", args, n); XtManageChild(IconGad321); n = 0; XtSetArg(args[n], XmNentryParent, IconGad321); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[7]); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; IconGad3211 = XmCreateIconGadget(Container1, "IconGad3211", args, n); XtManageChild(IconGad3211); n = 0; XtSetArg(args[n], XmNentryParent, IconGad3); n++; XtSetArg(args[n], XmNviewType, XmSMALL_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[8]); n++; IconGad33 = XmCreateIconGadget(Container1, "IconGad33", args, n); XtManageChild(IconGad33); /**** Create only widgets when needed, because automation is realizing and managing all created widgets. When we use R6, try that again. n = 0; XtSetArg(args[n], XmNx, 70); n++; XtSetArg(args[n], XmNy, 420); n++; XtSetArg(args[n], XmNviewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNdetailCount, NUM_COL-1); n++; XtSetArg(args[n], XmNdetail, EntryDetails[9]); n++; IconGad5 = XmCreateIconGadget(Container1, "IconGad5", args, n); for (i = 0; i < NUM_OBJ; i++) { ****/ IconGad5 = (Widget) 0; for (i = 0; i < NUM_OBJ-1; i++) { ColumnHeadings = EntryDetails[i]; for (j = 0; j < NUM_COL-1; j++) XmStringFree(ColumnHeadings[j]); XtFree((XtPointer)ColumnHeadings); } /**** XtFree((XtPointer)EntryDetails); ****/ XtRealizeWidget(Shell1); CommonPause(); CommonPause(); if (test_num == 1) { CommonPause(); } if (test_num == 2) { CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); CommonPause(); n = 0; XtSetArg(args[n], XmNselectedObjectCount, &SelectedObjectCount); n++; XtSetArg(args[n], XmNselectedObjects, &SelectedObjects); n++; XtGetValues(Container1, args, n); printf("SelectedObjectCount from GetValues: %d\n", SelectedObjectCount); printf("SelectedObjects from GetValues: "); for (i = 0; i < SelectedObjectCount; i++) printf("%s ", XtName(SelectedObjects[i])); printf("\n"); CommonPause(); } if (test_num == 3) { CommonPause(); CommonPause(); CommonPause(); CommonPause(); } if (test_num == 4) { CommonPause(); } if (test_num == 5) { CommonPause(); CommonPause(); CommonPause(); CommonPause(); } if (test_num == 6) { CommonPause(); CommonPause(); CommonPause(); CommonPause(); } if (test_num == 7) { CommonPause(); CommonPause(); CommonPause(); } if (test_num == 8) { CommonPause(); CommonPause(); } if (test_num == 9) { CommonPause(); CommonPause(); } if (test_num == 10) { CommonPause(); CommonPause(); } if (test_num == 11) { CommonPause(); CommonPause(); CommonPause(); } if (test_num == 12) { CommonPause(); CommonPause(); CommonPause(); } if (test_num == 26) { n = 0; XtSetArg(args[n], XmNentryViewType, XmLARGE_ICON); n++; XtSetArg(args[n], XmNlayoutType, XmOUTLINE); n++; XtSetValues(Container1, args, n); CommonPause(); CommonPause(); CommonPause(); } CommonPause(); XtAppMainLoop(app_context); }
void main( int argc, char *argv[] ) { Widget Form, RowColumn, ToggleB[NUM_FONTS], PushB; Arg args[25]; int n, i; XmString tmp_string; char buffer[25]; CommonTestInit( argc, argv ); n = 0; XtSetArg( args[n], XmNallowShellResize, True ); n++; XtSetValues( Shell1, args, n ); n = 0; Form = XmCreateForm( Shell1, "Form", args, n ); XtManageChild( Form ); n = 0; XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ); n++; XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ); n++; XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ); n++; XtSetArg( args[n], XmNresizeWidth, True ); n++; XtSetArg( args[n], XmNcolumns, 48 ); n++; XtSetArg( args[n], XmNrows, 4 ); n++; XtSetArg( args[n], XmNvalue, string1 ); n++; XtSetArg( args[n], XmNeditMode, XmMULTI_LINE_EDIT ); n++; XtSetArg( args[n], XmNfontList, CommonGetFontList("6x12")); n++; Text1 = XmCreateScrolledText( Form, "Text1", args, n ); XtManageChild( Text1 ); n = 0; XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++; XtSetArg( args[n], XmNtopWidget, Text1 ); n++; XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ); n++; XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ); n++; XtSetArg( args[n], XmNradioBehavior, True ); n++; RowColumn = XmCreateRowColumn( Form, "RowColumn", args, n ); XtManageChild( RowColumn ); for ( i = 0; i < NUM_FONTS; i++ ) { tmp_string = XmStringGenerate( font_names[i], XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL ); n = 0; XtSetArg( args[n], XmNlabelString, tmp_string ); n++; XtSetArg( args[n], XmNselectColor, CommonGetColor("green")); n++; if ( i == 0 ) { XtSetArg( args[n], XmNset, True ); n++; } sprintf( buffer, "ToggleB%d", i ); ToggleB[i] = XmCreateToggleButton( RowColumn, buffer, args, n ); XtAddCallback( ToggleB[i], XmNvalueChangedCallback, SetNewFont, (XtPointer)font_names[i] ); XmStringFree( tmp_string ); } XtManageChildren( ToggleB, NUM_FONTS ); tmp_string = XmStringGenerate( "Reset String", XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL ); n = 0; XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++; XtSetArg( args[n], XmNtopWidget, RowColumn ); n++; XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ); n++; XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ); n++; XtSetArg( args[n], XmNlabelString, tmp_string ); n++; PushB = XmCreatePushButton( RowColumn, "PushB", args, n ); XtManageChild( PushB ); XtAddCallback( PushB, XmNactivateCallback, ResetString, Text1 ); XtRealizeWidget( Shell1 ); CommonPause(); /* * Shrink the width of the Text widget. */ n = 0; XtSetArg( args[n], XmNcolumns, 20 ); n++; XtSetArg( args[n], XmNresizeWidth, False ); n++; XtSetValues( Text1, args, n ); CommonPause(); CommonPause(); XtAppMainLoop( app_context ); }