home *** CD-ROM | disk | FTP | other *** search
- /*
- winmougt.c 12/05/90
-
- % winmou_GreedyTrack
- by Ted.
-
- The generic window greedy mouse handler.
- When a mouse button is clicked over the window, the stuffcode
- is set to MOU_CLICK.
-
- OWL 3.2
- Copyright (c) 1990 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 12/12/90 jmd added missing variable, bordobj.h
- */
-
- #include "oakhead.h"
- #include "odisp.h"
- #include "scancode.h" /* for MOU codes */
- #include "bordobj.h" /* for bord_GetPixBox */
-
- OSTATIC int winmev_greedyclip(win_type win, mev_struct *mev);
- /* -------------------------------------------------------------------------- */
-
- int winmou_GreedyTrack(win_type win, int msg, mev_struct *mev)
- /*
- Messages a mouse handler receives when its window is current
- MEV_REQUEST someone else wants to be it
- MEV_STARTEVENT current, mouse entered
- MEV_EVENT current, event in win
- MEV_ENDEVENT current, mouse left
- Messages a mouse handler receives when its window is not current
- MEV_STARTOFFER not current, mouse entered
- MEV_OFFER not current, event in win
- MEV_ENDOFFER not current, mouse left
- */
- {
- int ret;
-
- switch (msg) {
- case MEV_STARTCUR:
- /* Trap all mouse events while we're current */
- disp_TrapMouse(win);
- break;
-
- case MEV_STOPCUR:
- break;
-
- case MEV_STARTOFFER:
- case MEV_OFFER:
- case MEV_ENDOFFER:
- /* Only respond to offers if trapping is on */
- if (disp_IsTrappedMouse()) {
- /* If the event is inside our window or border do the normal thing;
- otherwise bail out of the window */
- if ((ret = winmev_greedyclip(win, mev)) == MOU_HERE) {
- return(winmou_Track(win, msg, mev));
- }
- else {
- /* Event is not in our win, but trapping is on, so one of our
- children must be current; the standard response for a click
- outside is to exit the child and ourselves */
- /* Mouse was outside the window; don't accept the offer, but
- if the mouse was clicked return MOU_THERE so that
- the popup will be removed */
- mev_ClearEvent(mev);
- return(ret);
- }
- }
- mev_ClearEvent(mev);
- break;
-
- case MEV_REQUEST: /* we're the current window so trapping must be on */
- return(winmou_Track(win, msg, mev));
-
- case MEV_STARTEVENT:
- win_SetDebounced(win, mev_IsButtonDown(mev));
- /* no break, fall through */
- case MEV_EVENT: /* we're the current window so trapping must be on */
- case MEV_ENDEVENT:
-
- /* If the event is inside our window or border do the normal thing;
- otherwise bail out of the window */
- if ((ret = winmev_greedyclip(win, mev)) == MOU_HERE) {
- return(winmou_Track(win, msg, mev));
- }
- else { /* Otherwise exit if button is clicked */
- return(ret);
- }
- }
- return(MOU_IGNORE); /* Ignore this mouse event */
- }
- /* -------------------------------------------------------------------------- */
-
- static int winmev_greedyclip(win_type win, mev_struct *mev)
- {
- opbox bbox;
-
- /* If the event is inside our window or border, return MOU_HERE. */
- bord_GetPixBox(win, &bbox);
- if (mev_GetX(mev) >= bbox.xmin && mev_GetY(mev) >= bbox.ymin &&
- mev_GetX(mev) < bbox.xmax && mev_GetY(mev) < bbox.ymax) {
-
- return(MOU_HERE);
- }
- else { /* Otherwise exit if button is clicked */
- if (!mev_IsButtonDown(mev)) {
- win_SetDebounced(win, FALSE);
- }
- else {
- if (!win_GetDebounced(win)) {
- win_SetDebounced(win, TRUE);
-
- /* Mouse has been clicked outside the window; return
- MOU_THERE so that the popup can be removed */
- return(MOU_THERE);
- }
- }
- }
- return(MOU_IGNORE);
- }
- /* -------------------------------------------------------------------------- */
-
-