home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!haven.umd.edu!ames!agate!rsoft!mindlink!a133
- From: Duane_Eddingfield@mindlink.bc.ca (Duane Eddingfield)
- Subject: Re: Multiple Windows
- Organization: MIND LINK! - British Columbia, Canada
- Date: Sun, 13 Dec 1992 19:44:30 GMT
- Message-ID: <18453@mindlink.bc.ca>
- Sender: news@deep.rsoft.bc.ca (Usenet)
- Lines: 127
-
- > Erik Funkenbusch writes:
- >
- > Msg-ID: <8771@orbit.cts.com>
- > Posted: 11 Dec 92 10:05:03 GMT
- >
- > Org. : People-Net [pnet51], Minneapolis, MN.
- >
- > Is there an easier way of telling which Window a Window pointer is pointing
- > without resorting to the UserData field?
- >
- > I have an application where i have several windows that open up. Rather
- > than
- > calling a different IDCMP Dispatch function for each window, i used unique
- > gadget ID's for every gadget in the program, even if they have different
- > windows.
- >
- > My problem here is that i'd rather use a program like GadToolsBox to design
- > everything, and GadToolsBox defaults each gadget id to 0 for each new
- > window.
- > Sure, i can modify the generated source, but then if i modify my
- > GadToolsBox
- > image and regenerate i need to make these modifications again.
- >
- > I can use the STart ID field in the window data requester, however this
- > means
- > that i have to know how many gadgets are in the other windows, and heaven
- > help
- > me if i add more to a previous window..
- >
- > So, my solution would be to have my IDCMP Dispatch routine know which
- > window
- > it's dealing with and handle the appropriate gadget based on that.
- >
- > I can think of only one way to legally do this, and that's use the UserData
- > field to point to a window number or something. Is there an easier way?
- >
- > As a side note, has anyone else noticed that GadtoolsBox 1.3 doesn't
- > generate
- > the proper IDCMP flags for gadgets when you start adding a lot of windows?
- >
- > .---------------------------------------------------------------------------
- > --.
- > | UUCP: {crash tcnet petrus quest}!orbit!pnet51!chucks | Amiga, IBM, and
- > any |
- > | ARPA: crash!orbit!pnet51!chucks@nosc.mil | system you let me
- > |
- > | INET: chucks@pnet51.orb.mn.org | get my grubby mind
- > |
- > |------------------------------------------------------| into.
- > |
- > | Programmer at large, employment options welcome, inquire within.
- > |
-
-
- Here is a solution a friend of mine came up with. Part of this is seudo-code
- but I'm sure you can figure those parts out:
-
-
- main()
- {
- struct Window *currentWindow, *windows[NUMBER_OF_WINDOWS];
- ULONG motherSignal, sigmask = NULL; /* IDCMP signal mask */
-
- /*
- * loop to open the windows
- */
- for( ...each window gets opened in turn... )
- {
- /*
- * open a window
- */
- if(window = openAWindow(...))
- {
- /*
- * set up IDCMP signal for this window
- */
- signal = (1L << window->UserPort->mp_SigBit);
-
- /*
- * OR this window's signal into the mother of all signals
- */
- motherSignal |= doc->signal;
-
- }
- }
-
- /*
- * wait for activity in one of your windows
- */
- signal = Wait(sigmask);
-
- /*
- * find out which window got the signal
- */
- for(k = 0; k < NUMBER_OF_WINDOWS; k++)
- {
- if(windows[k] == NULL)
- {
- continue;
- }
- else if(signal & windows[k]->signal)
- {
- currentWindow = windows[k];
- break;
- }
- }
-
- ABORT = handleIDCMP(currentWindow);
-
- /*
- * After you're done with a particular window, clear it's flag out
- * of the mother of all signals.
- */
- clearSignalFlag(motherSignal, (*doc)->signal);
- }
-
-
- void clearSignalFlag(motherSignal, flag)
- ULONG *motherSignal,
- flag;
- {
- (*motherSignal) = (flag ^ (*motherSignal));
- } /* end of clearSignalFlag() */
-
-
- Hope this helps.
-
-