nick@deccan.dec.com (Nick Tsivranidis) (02/16/90)
I was under the impression that one could associate a client data field with a widget (ala Suntools). Is there such a thing? Client data is a piece of application data (normally a memory address) that one can associate with a widget. This provides for a convenient mapping between Widget space and Application space. Thanx in advance. - Nick -
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (02/21/90)
> I was under the impression that one could associate a client data > field with a widget (ala Suntools). Is there such a thing? There is no way to do this directly. You can, however, use the X Context Manager to associated data with a widget id. Kind of a hack, but it will work. See Gettys, Scheifler and Newman section 10.12. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
klee@wsl.dec.com (Ken Lee) (02/21/90)
In article <9002202051.AA24345@expo.lcs.mit.edu>, kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) writes: > > I was under the impression that one could associate a client data > > field with a widget (ala Suntools). Is there such a thing? > There is no way to do this directly. You can, however, use the X Context > Manager to associated data with a widget id. I think you mean that there is no way to do this with widgets that don't support it. You can, however, include a client data in widgets you write. I think all Motif widgets include a client data resource. Ken Lee DEC Western Software Laboratory, Palo Alto, Calif. Internet: klee@wsl.dec.com uucp: uunet!decwrl!klee
csvsj@garnet.berkeley.edu (Steve Jacobson) (02/22/90)
In article <9002202051.AA24345@expo.lcs.mit.edu> kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) writes: > >> I was under the impression that one could associate a client data >> field with a widget (ala Suntools). Is there such a thing? > >There is no way to do this directly. You can, however, use the X Context >Manager to associated data with a widget id. Kind of a hack, but it will work. > >See Gettys, Scheifler and Newman section 10.12. > > > Chris D. Peterson > MIT X Consortium > >Net: kit@expo.lcs.mit.edu >Phone: (617) 253 - 9608 >Address: MIT - Room NE43-213 Wait a second - we're talking about "client" data; not "server" data! This is a little bit more than "kind of a hack" :-). Clearly, client data belongs in the client, and not in the server. It probably wouldn't work, anyway, since programmers may wish to associate client data with unrealized widgets that don't have windows yet. A more reasonable hack uses the closure member of the callback structure to store client data. It is always possible to add a noop destroy callback to a widget and put the client data in the closure stucture member. As of X11R4, the intrinsic callback routines work correctly. You can use XtAddCallback() to set the client data value, XtGetValues() to retrieve the callback list (that you must then search to find the specific callback structure you're looking for) to look at the client data, and a XtGetValues() call, followed by a XtRemoveCallback() call, followed by a XtAddCallback() call to reset the client data. This is still a hack. It's more complicated than a hypothetical XtNclientData resource would be, and you have to be careful when you mess around with callbacks - one sloppy coding tactic and it's core dump city. I've never understood why the core widget class doesn't have a client data resource. I guess every X programmer who wants to use clent data can subclass all the widgets and do it themselves :-(.
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (02/22/90)
>> me > Setve me >>There is no way to do this directly. You can, however, use the X Context >>Manager to associated data with a widget id. Kind of a hack, but it will work. >> >>See Gettys, Scheifler and Newman section 10.12. >> >Wait a second - we're talking about "client" data; not "server" data! What has the server got to do with this? The X Context manager is handled entirely on the client side. >This is a little bit more than "kind of a hack" :-). Clearly, client data >belongs in the client, and not in the server. It probably wouldn't work, >anyway, since programmers may wish to associate client data with unrealized >widgets that don't have windows yet. True, of you do exactly what the manual says and use the window you will not be able to use this with unrealized widgets, but the "window" the context manager needs is really just a unique id that is the size of a window id. since both window id's and widget id's are unique and the same length... Like I said it is "kind of a hack". But there is no server interaction here at all. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
hvr@kimba.Sun.COM (Heather Rose) (02/27/90)
In article <8395@shlump.nac.dec.com> nick@deccan.dec.com (Nick Tsivranidis) writes: > > I was under the impression that one could associate a client data >field with a widget (ala Suntools). Is there such a thing? Client data >is a piece of application data (normally a memory address) that one can >associate with a widget. This provides for a convenient mapping between >Widget space and Application space. Thanx in advance. XView provides this (as did SunView). Here's a summary of how it works at the end of this message. Regards, Heather ---------------------------- int INSTANCE; main(){ Data data; data = (Data)malloc(DataSize); ... INSTANCE = xv_unique_key(); ... obj = xv_create(owner, OBJ_TYPE, ... XV_KEY_DATA, INSTANCE, data, ... NULL); ... xv_main_loop(frame); } callback_proc(obj, ...) ... data = (Data) xv_get(obj, XV_KEY_DATA, INSTANCE, NULL); ... }