home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDMEVACC.C
< prev
next >
Wrap
Text File
|
1990-08-28
|
3KB
|
97 lines
/*
sdmevacc.c 11/28/89
% sedmev_acceptoffer
Extracted by Ted from sed mouse handlers that Joe wrote.
Standard functions for handling the tricky business of accepting
mouse offer messages.
C-scape 3.2
Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
1/04/90 jmd re-vised, removed jump window, split files
1/24/90 ted added sedmev_greedyclip function.
3/03/90 ted/pmcm Added support for sed_FindField -2 return in case of protected fields.
3/28/90 jmd ansi-fied
5/12/90 jmd greedyclip now returns an int
8/27/90 ted Added code to stash next field for mev win instead of
actually setting it here.
*/
#include <stdio.h>
#include "cscape.h"
#include "scancode.h"
/* -------------------------------------------------------------------------- */
int sedmev_acceptoffer(sed_type sed, mev_struct *mev, boolean goanyway)
/*
Accepts a mouse offer message, generating a request to the current window
to become the new current window.
Returns the number of the field under the mouse.
If no field is under the mouse and the goanyway flag is set, the offer
is accepted and -1 is returned.
If no field is under the mouse and the goanyway flag is not set, the offer
is not accepted and -2 is returned.
'goanyway' flag to go even if no field is under mouse
*/
{
int fld;
ocbox mbox;
/* Figure out where in the selected sed we want to jump to */
mbox.toprow = mbox.botrow = mev_GetRow(mev) + sed_GetYoffset(sed);
mbox.leftcol = mbox.rightcol = mev_GetCol(mev) + sed_GetXoffset(sed);
if ((fld = sed_FindField(sed, &mbox, OAK_DOWN)) >= 0) {
if (fld != sed_GetFieldNo(sed)) {
win_SetNextChild(sed, fld);
}
}
else if (!goanyway) {
/* Mouse isn't over a field, ignore it unless goanyway flag is set */
mev_ClearEvent(mev);
return(-2);
}
/* Don't clear mev event - accept the offer, make the request */
/* If no unprotected field is under the mouse but we're going anyway, return -1 */
return((fld < 0) ? -1 : fld);
}
/* -------------------------------------------------------------------------- */
int sedmev_greedyclip(sed_type sed, mev_struct *mev)
{
opbox bbox;
/* If the event is inside our window or border, return MOU_HERE. */
bord_GetPixBox(sed, &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(sed, FALSE);
}
else {
if (!win_GetDebounced(sed)) {
win_SetDebounced(sed, TRUE);
/* Mouse has been clicked outside the window; return
MOU_THERE so that the popup can be removed */
return(MOU_THERE);
}
}
}
return(MOU_IGNORE);
}
/* -------------------------------------------------------------------------- */