home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDMOUCKF.C
< prev
next >
Wrap
Text File
|
1990-09-24
|
4KB
|
136 lines
/*
sdmouckf.c
% sedmou_ClickField
12/23/89 by Ted.
The "click field" mouse handler.
Jumps to a field when a mouse button is clicked over the field.
Doesn't jump to the sed when a button is clicked in it but in no field.
If the field is in a different sed, and both seds have mouse handlers,
then the first sed is exited and control is passed to the new sed.
C-scape 3.2
Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
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 mouse handlers now return ints
8/17/90 ted Changed references from sed_SetMouseCode to kb_Stuff.
9/24/90 ted Cancelled the click if GotoField was not successful.
*/
#include <stdio.h>
#include "cscape.h"
#include "scancode.h" /* for MOU codes */
int sedmou_ClickField(sed_type sed, 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 fld;
ocbox mbox;
switch (msg) {
case MEV_STARTOFFER: /* we're not the current window */
win_SetDebounced(sed, mev_IsButtonDown(mev));
/* no break, fall through */
case MEV_OFFER: /* we're not the current window */
/* If button pressed accept the event */
if (!mev_IsButtonDown(mev)) {
win_SetDebounced(sed, FALSE);
mev_ClearEvent(mev); /* Don't accept it */
}
else { /* button pressed */
if (win_GetDebounced(sed)) {
mev_ClearEvent(mev); /* Don't accept it */
}
else {
win_SetDebounced(sed, TRUE);
/* Accept the offer */
if (sedmev_acceptoffer(sed, mev, FALSE) != -2) {
/* Set our mousecode to tell us that the mouse was clicked
when our field function is eventually called. */
kb_Stuff(MOU_CLICK);
}
/* We don't care what code we return because we accepted the
offer, which means the REQUEST message gets to decide what
to return from this particular kb_Read call */
}
}
break;
case MEV_ENDOFFER: /* we're not the current window */
break;
case MEV_REQUEST: /* we're the current window;
another window was selected by the mouse. */
winmev_grantrequest(sed, mev);
/* Return MOU_THERE as a scancode to kb_Read to tell the sed
about the request so it can exit */
return(MOU_THERE);
case MEV_STARTEVENT:
win_SetDebounced(sed, mev_IsButtonDown(mev));
/* no break, fall through */
case MEV_EVENT: /* we're the current window */
/* Test if event occurred (button pressed) */
if (!mev_IsButtonDown(mev)) {
win_SetDebounced(sed, FALSE);
}
else {
if (!win_GetDebounced(sed)) {
win_SetDebounced(sed, TRUE);
mbox.toprow = mbox.botrow = mev_GetRow(mev) + sed_GetYoffset(sed);
mbox.leftcol = mbox.rightcol = mev_GetCol(mev) + sed_GetXoffset(sed);
/* sed_FindField finds the best field in the given box */
if ((fld = sed_FindField(sed, &mbox, OAK_DOWN)) >= 0) {
if (fld != sed_GetFieldNo(sed)) {
if (sed_GotoField(sed, fld) != SED_MOVED) {
break; /* If GotoField fails, don't click */
}
}
/* Set our mousecode to tell us that the mouse was clicked
when our field function is eventually called. */
kb_Stuff(MOU_CLICK);
/* Return MOU_HERE as a scancode to kb_Read to tell the sed
there was an event in it, but possibly in a new field,
so it can re-enter in the new field */
return(MOU_HERE);
}
}
}
break;
case MEV_ENDEVENT: /* we're the current window */
break;
}
return(MOU_IGNORE); /* Ignore this mouse event */
}