Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!jarthur!uunet!lll-winken!sun-barr!newstop!exodus!montagne.Eng.Sun.COM!brentb From: brentb@montagne.Eng.Sun.COM (Brent Browning) Newsgroups: comp.windows.open-look Subject: Re: Help! with scrolling lists and xv_create Message-ID: <14182@exodus.Eng.Sun.COM> Date: 29 May 91 22:49:18 GMT References: <1991May24.211132.10282@cci632.cci.com> <14063@exodus.Eng.Sun.COM> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 82 In article you write: > >Can someone post a an example of code to use PANEL_LIST_INSERT & >PANEL_LIST_DELETE? There are two problems: 1) intense flashing >and 2) after using PANEL_LIST_DELETE in descending order as suggested >in O'Reilly, I get bus errors. It sure would have been nice to have some sort of batching for scrolling lists - eh? XView doesn't really provide any support for this. The recommended way to do this is to set XV_SHOW to FALSE on the list, then do the update, the set XV_SHOW to TRUE. There are times that it is faster to just destroy the old list and then recreate it again. If you are using the instance pointers provided by gxv make sure you store the new handle back in the instance pointer. We do our batching as follows. We call a routine "list_add" that stores the string in a large dynamically allocated array. Then when we really want to do the list update we destroy the old list, create a new one (calling ..._list_create), then do the batch update in chunks with attr lists. Here's our function: char **String_list; /* Dynamically allocated array of strings */ /* * Insert internal list into scrolling list in chunks. */ void list_batch_insert(ip) ..._window_objects *ip; { int i = 0; void *attr_array[ATTR_STANDARD_SIZE]; void **attr_ptr; void **attr_end; /* * Destroy old list (faster than delete all entries) then * create a fresh one. */ xv_set(ip->list, XV_SHOW, FALSE, NULL); xv_destroy_safe(ip->list); ip->list = ..._window_list_create(ip, ip->controls); xv_set(ip->list, XV_SHOW, FALSE, NULL); attr_ptr = attr_array; attr_end = &attr_array[ATTR_STANDARD_SIZE - 20]; for (i = 0; i < Gfm_list_count; i++) { *attr_ptr++ = (void *) PANEL_LIST_INSERT; *attr_ptr++ = (void *) i; *attr_ptr++ = (void *) PANEL_LIST_STRING; *attr_ptr++ = (void *) i; *attr_ptr++ = (void *) String_list[i]; /* * Check for overflow or completion, if full terminate * the ATTR_LIST and set it on the scrolling list. */ if (attr_ptr >= attr_end || i >= Gfm_list_count - 1) { *attr_ptr = (void *) 0; xv_set(ip->list, ATTR_LIST, attr_array, NULL); attr_ptr = attr_array; } } /* * Select first item and make list visible */ xv_set(ip->list, PANEL_LIST_SELECT, 0, TRUE, XV_SHOW, TRUE, NULL); } -- Brent Browning Internet: brentb@Eng.Sun.COM Sun Microsystems, Inc UUCP: ...!sun!brentb 2550 Garcia Ave. MTV 01-40 Phone: (415) 336-5573 Mountain View, CA 94043