home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17308 < prev    next >
Encoding:
Text File  |  1992-12-13  |  3.5 KB  |  138 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!haven.umd.edu!ames!agate!rsoft!mindlink!a133
  3. From: Duane_Eddingfield@mindlink.bc.ca (Duane Eddingfield)
  4. Subject: Re: Multiple Windows
  5. Organization: MIND LINK! - British Columbia, Canada
  6. Date: Sun, 13 Dec 1992 19:44:30 GMT
  7. Message-ID: <18453@mindlink.bc.ca>
  8. Sender: news@deep.rsoft.bc.ca (Usenet)
  9. Lines: 127
  10.  
  11. > Erik Funkenbusch writes:
  12. >
  13. > Msg-ID: <8771@orbit.cts.com>
  14. > Posted: 11 Dec 92 10:05:03 GMT
  15. >
  16. > Org.  : People-Net [pnet51], Minneapolis, MN.
  17. >
  18. > Is there an easier way of telling which Window a Window pointer is pointing
  19. > without resorting to the UserData field?
  20. >
  21. > I have an application where i have several windows that open up.  Rather
  22. > than
  23. > calling a different IDCMP Dispatch function for each window, i used unique
  24. > gadget ID's for every gadget in the program, even if they have different
  25. > windows.
  26. >
  27. > My problem here is that i'd rather use a program like GadToolsBox to design
  28. > everything, and GadToolsBox defaults each gadget id to 0 for each new
  29. > window.
  30. > Sure, i can modify the generated source, but then if i modify my
  31. > GadToolsBox
  32. > image and regenerate i need to make these modifications again.
  33. >
  34. > I can use the STart ID field in the window data requester, however this
  35. > means
  36. > that i have to know how many gadgets are in the other windows, and heaven
  37. > help
  38. > me if i add more to a previous window..
  39. >
  40. > So, my solution would be to have my IDCMP Dispatch routine know which
  41. > window
  42. > it's dealing with and handle the appropriate gadget based on that.
  43. >
  44. > I can think of only one way to legally do this, and that's use the UserData
  45. > field to point to a window number or something.  Is there an easier way?
  46. >
  47. > As a side note, has anyone else noticed that GadtoolsBox 1.3 doesn't
  48. > generate
  49. > the proper IDCMP flags for gadgets when you start adding a lot of windows?
  50. >
  51. > .---------------------------------------------------------------------------
  52. > --.
  53. > | UUCP: {crash tcnet petrus quest}!orbit!pnet51!chucks | Amiga, IBM, and
  54. > any  |
  55. > | ARPA: crash!orbit!pnet51!chucks@nosc.mil             | system you let me
  56. > |
  57. > | INET: chucks@pnet51.orb.mn.org                       | get my grubby mind
  58. > |
  59. > |------------------------------------------------------| into.
  60. > |
  61. > | Programmer at large, employment options welcome, inquire within.
  62. > |
  63.  
  64.  
  65. Here is a solution a friend of mine came up with. Part of this is seudo-code
  66. but I'm sure you can figure those parts out:
  67.  
  68.  
  69. main()
  70. {
  71. struct Window *currentWindow, *windows[NUMBER_OF_WINDOWS];
  72. ULONG motherSignal, sigmask = NULL; /* IDCMP signal mask */
  73.  
  74. /*
  75.  * loop to open the windows
  76.  */
  77. for(     ...each window gets opened in turn...    )
  78. {
  79. /*
  80.  * open a window
  81.  */
  82. if(window = openAWindow(...))
  83. {
  84. /*
  85.  * set up IDCMP signal for this window
  86.  */
  87. signal = (1L << window->UserPort->mp_SigBit);
  88.  
  89. /*
  90.  * OR this window's signal into the mother of all signals
  91.  */
  92. motherSignal |= doc->signal;
  93.  
  94. }
  95. }
  96.  
  97. /*
  98.  * wait for activity in one of your windows
  99.  */
  100. signal = Wait(sigmask);
  101.  
  102. /*
  103.  * find out which window got the signal
  104.  */
  105. for(k = 0; k < NUMBER_OF_WINDOWS; k++)
  106. {
  107. if(windows[k] == NULL)
  108. {
  109. continue;
  110. }
  111. else if(signal & windows[k]->signal)
  112. {
  113. currentWindow = windows[k];
  114. break;
  115. }
  116. }
  117.  
  118. ABORT = handleIDCMP(currentWindow);
  119.  
  120. /*
  121.  * After you're done with a particular window, clear it's flag out
  122.  * of the mother of all signals.
  123.  */
  124.  clearSignalFlag(motherSignal, (*doc)->signal);
  125. }
  126.  
  127.  
  128. void clearSignalFlag(motherSignal, flag)
  129.  ULONG *motherSignal,
  130.   flag;
  131. {
  132. (*motherSignal) = (flag ^ (*motherSignal));
  133. } /* end of clearSignalFlag() */
  134.  
  135.  
  136. Hope this helps.
  137.  
  138.