🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #38071

XView: Help w/ attaching client data

#38071
From: Barry A. Warsaw
Date: Wed, 14 Mar 1990 17:18
89 lines
4004 bytes
I'm trying to attach client data to PANEL_LIST type panel items in
XView, but I can't quite figure out how to set and later retrieve the
data in the notify procedure.

I'm creating the PANEL_LIST item like this:

	list = xv_create(panel, PANEL_LIST,
		PANEL_LIST_DISPLAY_ROWS,	4,
		PANEL_LIST_WIDTH,       	xv_col(panel, 20),
		PANEL_NOTIFY_PROC,      	selected_from_list,
		PANEL_CHOOSE_ONE,       	TRUE,
		PANEL_CHOOSE_NONE,      	TRUE,
		NULL);

and putting items into this list later (in a function other than the
one that creates the list):

	xv_set(list,
		PANEL_LIST_INSERT,  	0,
		PANEL_LIST_STRING,  	0, string_name,
		PANEL_LIST_CLIENT_DATA,	0, integer_value,
		NULL);

This xv_set is embedded in a function that is called an unknown number
of times, so any number of entries could be in the list.  When a
particular entry is selected, the function selected_from_list is
called as the notify proc:

	void selected_from_list(item, op, event)
	Panel_item  	item;
	Panel_list_op	op;
	Event       	*event;
		{
		...
		}

The item passed to the notify proc is *not* the PANEL_LIST item, it is
the PANEL_MESSAGE item corresponding to the entry in the list that was
selected.  The problem is that the client data is set on the
PANEL_LIST item, not the PANEL_MESSAGE item so there is no way to get
the client data inside the notify proc, without maintaining a bunch of
global variables (which defeats the purpose of using client data or
key data anyway) and brute-forcing the solution.  The problem is
really that there is not enough information passed to the notify
procedure to accomplish the desired task. These are the relevent
issues as I see it:

1) In the notify proc we can't find the row number corresponding to
the PANEL_MESSAGE item selected so that we could do an xv_get(list,
PANEL_LIST_CLIENT_DATA, row).  We have to brute-force to find the row
number of the selected item.  Something like PANEL_LIST_ROW_SELECTED
on the PANEL_LIST would do the trick.

2) Can't find the total number of rows in the PANEL_LIST item, so we
don't bomb out "for" loops when brute-force searching for the message
item.  We'd have to keep a global variable for this.  Something like
PANEL_LIST_ROWS_N would be needed.

3) Also in the notify proc, we can't find the PANEL_LIST item which
contains the PANEL_MESSAGE item selected, forcing me to keep "list"
around as a global variable.  Something like PANEL_LIST_PARENT_LIST
would be appropriate here.

4) The client data set on the list via PANEL_LIST_CLIENT_DATA could be
placed on the item's PANEL_CLIENT_DATA attribute so that it can be
retrieved in the notify proc.

5) Really, the parameters passed to the notify procedure are not the
right ones.  Ideally it should be passed the PANEL_LIST item
containing the selection, the row number of the selected item and a
pointer to the event, much like PANEL_CHOICE notification.

Any help or pointers are appreciated, but I'm really not interested in
brute-force or global variable solutions, unless this is the only way
to accomplish my goal.  In that case, I'll send an RFE to Sun.

BTW, for the record, I'm using the XView library from expo, with
patches 1 & 2 installed, on a Sun3/160C SunOS 4.0.3, under MIT Xsun
server release 4 and TWM window manager.

Thanks in advance.

-Barry

NAME: Barry A. Warsaw                USMAIL: National Institute of Standards
TELE: (301) 975-3460                         and Technology (formerly NBS)
UUCP: {...}!uunet!cme-durer!warsaw           Rm. B-124, Bldg. 220
ARPA: warsaw@cme.nist.gov                    Gaithersburg, MD 20899
Technical Details
Message-ID: <WARSAW.90Mar14121813@rtg.cme.nist.gov>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cme!durer!warsaw

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cme!durer!warsaw
From: warsaw@cme.nist.gov (Barry A. Warsaw)
Newsgroups: comp.windows.x
Subject: XView: Help w/ attaching client data
Message-ID: <WARSAW.90Mar14121813@rtg.cme.nist.gov>
Date: 14 Mar 90 17:18:13 GMT
Sender: news@cme.nist.gov
Organization: National Institute of Standards and Technology
Lines: 89