home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 20057 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  2.7 KB

  1. Xref: sparky comp.lang.c++:20057 comp.std.c++:2140
  2. Path: sparky!uunet!cimshop!davidm
  3. From: davidm@consilium.com (David S. Masterson)
  4. Newsgroups: comp.lang.c++,comp.std.c++
  5. Subject: Re: Callbacks -- suggested approaches??
  6. Message-ID: <DAVIDM.93Jan28111030@consilium.com>
  7. Date: 28 Jan 93 19:10:29 GMT
  8. References: <DAVIDM.93Jan25171343@consilium.com> <1k41efINN2oj@darkstar.UCSC.EDU>
  9. Sender: root@cimshop.UUCP
  10. Organization: Consilium Inc., Mountain View, California
  11. Lines: 47
  12. In-reply-to: spencer@cats.ucsc.edu's message of 26 Jan 93 18:55:11 GMT
  13. X-Posting-Software: GNUS 3.13  [ NNTP-based News Reader for GNU Emacs ]
  14.  
  15. >>>>> On 26 Jan 93 18:55:11 GMT, spencer@cats.ucsc.edu (Michael Spencer) said:
  16.  
  17. >                          WIDGET CALLBACKS
  18.  
  19. > Widgets which use callbacks are similarly easy. XSimple widgets attach their
  20. > own callback and pass to it a reference to a coder written Procedure. The
  21. > callback calls the Procedure and passes to it a Choice object which contains
  22. > the data needed to respond to the event.  For example, to activate a popup
  23. > dialog widget:
  24.  
  25. >           PopupYesno (parent, "Do it ?", YesnoProc);   // evoke popup
  26. >           void YesnoProc (Choice chose)    // coder written to handle event
  27. >                {
  28. >                if (chose.flag)
  29. >                     // do something
  30. >                else
  31. >                     // do something else
  32. >                }
  33.  
  34. > The coder written YesnoProc() defines what occurs based on the user's
  35. > election. Choice is an object (declared in XUTILS.H) which will hold any
  36. > information generated by any callback or event handler.
  37.  
  38. > BUT, the coder need not become involved in the sordid details of adding the
  39. > callback to the widget or extracting the relevant information from the
  40. > returned callback struct. That is done automatically and the relevant
  41. > information is passed via the Choice data members.
  42.  
  43. An interesting variation on the X-windows approach.  However, I see a few
  44. (what I would call) holes in what you've shown above:
  45.  
  46. 1.  I assume PopupYesno is an object.  If so, why isn't YesnoProc() a member
  47. function of the object?  Wouldn't that help for maintenance?
  48.  
  49. 2.  Your Choice object appears to carry a type flag.  Couldn't things be done
  50. virtually and eliminate this flag?
  51.  
  52. 3.  What if the information generated for a callback is not of type Choice?
  53. --
  54. ====================================================================
  55. David Masterson                    Consilium, Inc.
  56. (415) 691-6311                    640 Clyde Ct.
  57. davidm@consilium.com                Mtn. View, CA  94043
  58. ====================================================================
  59. "I'll put an end to the idea that a woman's body belongs to her . . . the
  60.  practice of abortion shall be exterminated with a strong hand."
  61. -- Adolf Hitler, _Mein Kampf_
  62.