[comp.windows.open-look] Interaction of two ScrollingLists

conrad@jupiter.ucsc.edu (Al Conrad, x3208) (03/21/91)

When I create two ScrollingLists with OLIT, I find that selecting in
one deselects in the other.  Annoying at best.  Does anyone know
how to turn this off?

Also, the OL style guide (page 8-1) says that a level 1 implementation
supports exclusive scrolling lists.  In fact on, page 8-3 it says that
exclusive scrolling lists are "perhaps the most common".  Yet, OLIT
only supports nonexclusive scrolling lists.  My stile guide is a
little old (8/31/89).  Have things changed?

Thanks!

Al Conrad

PS - I've been using wcl to simultaneoulsy develop both a motif and OLIT
     version of my application.  Until I got to scrolling lists, it was
     pretty even in the pros and cons department.  The OL scrolling lists,
     however, are very cumbersome compared to motif's.

aim@Corp.Sun.COM (Amy) (03/26/91)

>>From owner-openlook@uunet.uu.net Thu Mar 21 07:05:41 1991
>>To: openlook@uunet.UU.NET
>>Path: unify!csusac!ucdavis!ucbvax!agate!darkstar!jupiter.ucsc.edu
>>Newsgroups: comp.windows.open-look
>>Subject: Interaction of two ScrollingLists
>>Sender: usenet@darkstar.ucsc.edu
>>Organization: University of California, Santa Cruz
>>Lines: 18
>>
>>When I create two ScrollingLists with OLIT, I find that selecting in
>>one deselects in the other.  Annoying at best.  Does anyone know
>>how to turn this off?
>>
>>Also, the OL style guide (page 8-1) says that a level 1 implementation
>>supports exclusive scrolling lists.  In fact on, page 8-3 it says that
>>exclusive scrolling lists are "perhaps the most common".  Yet, OLIT
>>only supports nonexclusive scrolling lists.  My stile guide is a
>>little old (8/31/89).  Have things changed?

Which version of OLIT are you running?  The scrollingList from
Release4 of AT&T's OPEN LOOK toolkit does support exclusive scrolling
Lists...but as you'll see from the program below, it's up to the
programmer to implement this behavior...(by setting/unsetting the
"attr" field in the OlListItem structure)....(I agree that.it would be 
nice if the list handled this for you though.)

Regards,
Amy Moore
aim@sun.com


/**********************************************************************/
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xol/OpenLook.h>
#include <Xol/ScrollingL.h>
#include <Xol/Form.h>



static 	char *liststring[] = { "PresidentsDay" , "St.PatricksDay",
	"Easter", "MemorialDay","4th of July", "LaborDay", "Halloween",
	"Thanksgiving", "Hanakuh","Christmas","NewYearsEve"};

static char *mnemonic_char[] = {'P','S','E','M','4','L','H','T','a','C','N'};



static OlListToken	(*ListAddItem)();
static void 		(*ListTouchItem)();
static void		(*ListViewItem)();

/********************************************************************
 * makeCurrentCB:  Callback called when the user selects one of the
 *		   items in the ScrollingList.  Note it is UP TO THE
 *		   application to make the item appear "current"
 *		   (indented) by setting the attr field in the 
 *		   OlListItem structure to be OL_LIST_ATTR_CURRENT.
 *		   as well as making the previously selected item
 *		   no longer appear selected.
 *******************************************************************/
void
makeCurrentCB(w, clientData, callData)
Widget w;
XtPointer clientData, callData;
{
	OlListItem* new_item = OlListItemPointer(callData);
	OlListItem* prev_item;
	OlListToken token = (OlListToken) callData;
	static OlListToken selectedtoken;

	if (selectedtoken != token)
		{
		printf("Item selected: %s\n", new_item->label);
	
		/*
		* Mark the item as selected or current by setting a bit
		* in its attribute field.  Notify the widget that we have
		* touched an item.
		*/
		new_item->attr |= OL_LIST_ATTR_CURRENT;
		(*ListTouchItem)(w, token);
	
		(*ListViewItem)(w, token);

		/*
		 * If there was a previously selected item, unselect by
		 * clearing the CURRENT attribute bit.   Again, since we have
		 * modified an item, we must notify the widget.
		 */		
		if (selectedtoken != 0)
			{
			prev_item = OlListItemPointer(selectedtoken);
			prev_item->attr &= ~OL_LIST_ATTR_CURRENT;
			(*ListTouchItem)(w, selectedtoken);
			}
		/*
		 * Keep track of currently selected item in list
		 */
		selectedtoken = token;
		}
}
/***************************************************************************/	

main(argc, argv)
int argc;
char **argv;
{
	Widget toplevel, form, list;
	OlListItem *listitem;
	int i;


	toplevel = OlInitialize(argv[0], "Test", NULL,
						0, &argc, argv);

	form = XtVaCreateManagedWidget("form",
				formWidgetClass,
				toplevel,
				NULL);

	/*
	 * Create ScrollingList
	 */	
	list = XtVaCreateManagedWidget("list", 
				scrollingListWidgetClass, 
				form,
				XtNviewHeight,	(XtArgVal)5,
				XtNselectable,	(XtArgVal)True,
				NULL);
	/*
	 * Get routines to manipulate the ScrollingList
	 */
	XtVaGetValues(list,
				XtNapplAddItem,    (XtArgVal)&ListAddItem,
				XtNapplTouchItem,  (XtArgVal)&ListTouchItem,
				XtNapplViewItem,   (XtArgVal)&ListViewItem,
				NULL);

	/*
	 * Malloc up space for listitem data.
	 */
	listitem = 
		(OlListItem *)XtMalloc(XtNumber(liststring)*sizeof(OlListItem));

	/*
	 * Create list items one by one and add them to list
	 */
	for(i=0; i < XtNumber(liststring) ;i++) {
	   	listitem[i].label_type = (OlDefine) OL_STRING;
	   	listitem[i].label= XtNewString(liststring[i]);
	   	listitem[i].attr = 0;
	  	listitem[i].mnemonic = mnemonic_char[i];
	   	(*ListAddItem) (list, NULL, NULL, listitem[i]); 
	   }


	XtAddCallback(list, XtNuserMakeCurrent, makeCurrentCB, NULL);

	XtRealizeWidget(toplevel);

	XtMainLoop();

}
/********************************END EXAMPLE*******************************/