Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: denault@wirth.ifa.hawaii.EDU (Anthony Denault) Newsgroups: comp.windows.x Subject: Re: Help with XView`s PANEL_LIST Message-ID: <9101222032.AA00452@wirth.ifa.hawaii.edu> Date: 22 Jan 91 20:32:36 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 84 > 1. I'm xv_create(ing) a PANEL_LIST. Whenever I insert or delete items, >it appears as if OW redraws the entire list. This causes a "flashing" >that is very annoying (especially since I update the list frequently). >I'm hoping that there is a way around this... Any clues? I got this function from the net. Original author is not knowned. It sets the contents of a scrolling list from a list of string in an argc-style parameter. Since it update the entire list at once, there is no "flashing" for each insert or delete. (There is only 1 re-draw of the list). /*---------------------------------------------------------------------------- * scrolling_list_update: * * Given a scrolling list and an argv-style array of strings, * update the contents of the scrolling list. *---------------------------------------------------------------------------- */ void scrolling_list_update(list, argc, argv) Xv_opaque list; int argc; char **argv; { register int i, j; char **avlist; int rows = xv_get(list, PANEL_LIST_NROWS); /* * Copy the string information to an avlist. */ if (argc > 0) { /* * Allocate memory for the list and fill it in. */ avlist = (char **) malloc((argc + 3) * sizeof (char *)); avlist[0] = (char *) PANEL_LIST_STRINGS; for (i = 0; i < argc; i++) avlist[i + 1] = argv[i]; avlist[++i] = (char *) NULL; /* NULL-terminate strings */ avlist[++i] = (char *) NULL; /* NULL-terminate avlist */ /* * Set the scrolling list and free the avlist. */ xv_set(list, ATTR_LIST, avlist, NULL); free((char *) avlist); } /* * This should not be necessary, but ... clear any entries * in excess of the new entries. */ if (rows > argc) { /* * Set up an avlist with PANEL_LIST_DELETE,index pairs. The * panel entries are deleted from bottom (high index) to * top (low index) which might reduce copying of entries. */ avlist = (char **) malloc(((rows-argc)*2+1) * sizeof (char *)); for (j = 0, i = rows - 1; i >= argc; i--) { avlist[j++] = (char *) PANEL_LIST_DELETE; avlist[j++] = (char *) i; } avlist[j] = (char *) NULL; /* NULL-terminate avlist */ /* * Delete the excess entries and free the avlist. */ xv_set(list, ATTR_LIST, avlist, NULL); free((char *) avlist); } } -------------------------------------------------------------------- Tony /------------------------------------------------------------------------\ | Tony Denault, Institute for Astronomy, | denault@uhifa.ifa.hawaii.edu | | 2680 Woodlawn Drive, Honolulu, HI 96789 | (808) 956-6097 | \------------------------------------------------------------------------/