[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

For most GadTools programs, gt_getimsg() and gt_replyimsg() work perfectly
well.  In rare cases an application may find they pose a bit of a problem.
A typical case is when all messages are supposed to go through a
centralized replymsg() that cannot be converted to a gt_replyimsg().
Since calls to GT_GetIMsg() and GT_ReplyIMsg() must be paired, there would
be a problem.

For such cases, the gt_filterimsg() and gt_postfilterimsg() functions are
available.  These functions allow getmsg() and replymsg() to be used in a
way that is compatible with GadTools.

    Warning:
    --------
    These functions are for specialized use only and will not be used by
    the majority of applications.  See gt_getimsg() and
    gt_replyimsg() for standard message handling.


    struct IntuiMessage *GT_FilterIMsg( struct IntuiMessage *imsg );
    struct IntuiMessage *GT_PostFilterIMsg( struct IntuiMessage *imsg );

The gt_filterimsg() function should be called right after getmsg().  it
takes a pointer to the original intuimessage and, if the message applies
to a GadTools gadget, returns either a modified IntuiMessage or a NULL.  A
NULL return signifies that the message was consumed by a GadTools gadget
(and not needed by the application).

The gt_postfilterimsg() function should be called before replying to any
message modified by gt_filterimsg().  it takes a pointer to the modified
version of an intuimessage obtained with gt_filterimsg() and returns a
pointer to the original IntuiMessage.

The typical calling sequence for a program that uses these functions, is
to call getmsg() to get the intuimessage.  then, if the message applies to
a window which contains GadTools gadgets, call gt_filterimsg().  any
message returned by GT_FilterIMsg() should be used like a message returned
from gt_getimsg().

When done with the message, the application must call gt_postfilterimsg()
to perform any clean up necessitated by the previous call to
gt_filterimsg().  in all cases, the application must then reply the
original intuimessage using replymsg().  this is true even for consumed
messages as these are not replied by GadTools.  For example, the
application could use code such as this:

    /* port is a message port receiving different messages */
    /* gtwindow is the window that contains GadTools gadgets */

    imsg = GetMsg(port);

    /* Is this the window with GadTools gadgets? */
    if (imsg->IDCMPWindow == gtwindow)
        {
        /* Filter the message and see if action is needed */
        if (gtimsg = GT_FilterIMsg(imsg))
            {
            switch (gtimsg->Class)
                {
                /* Act depending on the message */
                ...
                }
            /* Clean up the filtered message.  The return value is not */
            /* needed since we already have a pointer to the original  */
            /* message.                                                */
            GT_PostFilterIMsg(gtimsg);
            }
        }
    /* other stuff can go here */
    ReplyMsg(imsg);

You should not make any assumptions about the contents of the unfiltered
intuimessage (imsg in the above example).  only two things are guaranteed:
the unfiltered IntuiMessage must be replied to and the unfiltered
IntuiMessage (if it produces anything when passed through gt_filterimsg())
will produce a meaningful GadTools IntuiMessage like those described in
the section on the different kinds of gadgets.  the relationship between
the unfiltered and filtered messages are expected to change in the future.
See the section on documented side-effects for more information.