home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
DEMO
/
RIM22
/
MACROS
/
MOUSE.RM
< prev
next >
Wrap
Text File
|
1993-11-14
|
4KB
|
146 lines
/*
** Macro module: mouse.rm - Mouse handling
**
** Copyright (C) 1993 Brian L. Smith
** Copyright (C) 1993 RimStar Technology, Inc.
** All rights reserved internationally.
** Unlicensed use is a violation of applicable laws.
**
** This source code is provided to licensed users of RimStar's products
** for the purpose of allowing the user to customize and/or enhance RimStar's
** products. The source code remains the property of the copyright holders
** with all rights reserved internationally.
** Any modifications to the source code are considered derivative works and
** all rights thereto are reserved to the copyright holders except
** that the purchaser may use the derivitive work in the same manner
** as permitted by the license governing the unmodified product.
** Distribution in any manner of any part of the original source code,
** whether in source or object form, is expressly prohibited without the
** express written permission of the copyright holders.
**
*/
#define INCL_EVENT
#define INCL_MOUSE
#include "macro.h"
extern int cxChar;
extern int cyChar;
int
MouEvent(USHORT event, PMOUSEINFO pInfo) {
static int B1LastX, B1LastY;
int type;
switch ( pInfo->usEvent ) {
case WM_MOUSEMOVE: /* this event only gen'd if a button is down */
if ( !(pInfo->usButtonState & MOU_BUTTON1) )
return 0; /* Not button 1 - so ignore */
if ( ((B1LastX - pInfo->x) & 0x7FFF) > cxChar/2 ||
((B1LastY - pInfo->y) & 0x7FFF) > cyChar/2
) {
B1LastX = pInfo->x;
B1LastY = pInfo->y;
if ( !MarkQuerySelType() ) { /* Begin selection */
if ( !pInfo->usShiftState )
MarkBeginSel(SELECT_NORMAL);
else if ( pInfo->usShiftState & CTRL_DOWN )
MarkBeginSel(SELECT_COLUMN);
else if ( pInfo->usShiftState & SHIFT_DOWN )
MarkBeginSel(SELECT_LINE);
else if ( pInfo->usShiftState & ALT_DOWN )
MarkBeginSel(SELECT_EXCLUSIVE);
} else
MovToMouse();
}
break;
case WM_BUTTON1DOWN: /* All button down events capture the mouse */
MovToMouse();
B1LastX = pInfo->x;
B1LastY = pInfo->y;
break;
case WM_BEGINSELECT:
#if 0
/* WM_BEGINSELECT comes a bit to late for our liking
** so we have chosen to detect selection using
** WM_MOUSEMOVE instead.
*/
/*
** Start a selection if there is none,
** else move to mouse (extends/contracts selection)
*/
MovToMouse();
if ( !MarkQuerySelType() ) {
if ( !pInfo->usShiftState )
MarkBeginSel(SELECT_EXCLUSIVE);
else if ( pInfo->usShiftState & CTRL_DOWN )
MarkBeginSel(SELECT_COLUMN);
else if ( pInfo->usShiftState & SHIFT_DOWN )
MarkBeginSel(SELECT_LINE);
else if ( pInfo->usShiftState & ALT_DOWN )
MarkBeginSel(SELECT_NORMAL);
}
#endif
break;
case WM_BUTTON2DOWN:
if ( !(type = MarkQuerySelType()) ) /* No selection in progress */
break;
if ( pInfo->usButtonState & MOU_BUTTON1 ) {
switch ( type ) {
case SELECT_EXCLUSIVE: /* Convert from Exculsive to Column marking */
MarkColumn();
break;
case SELECT_COLUMN: /* Change from Column to Line marking */
MarkLine();
break;
case SELECT_LINE: /* Convert from Line to Normal(stream) marking */
MarkNormal();
break;
case SELECT_NORMAL: /* Convert from Normal to Exclusive marking */
MarkExclusive();
break;
} /* end switch */
} else
MarkRemoveSel();
break;
case WM_BUTTON1DBLCLK:
/* If in error output window jump to error */
if ( (BufQueryFlags() & BUFFER_TYPE) == BUFTYPE_TEMP )
ErrJumpToError();
break;
case WM_ENDSELECT: /* User released button to end selection */
/* If you wanted a selection to be closed
** when the mouse is released you could process
** this message
*/
case WM_BUTTON1UP:
case WM_BUTTON2UP:
case WM_BUTTON2DBLCLK:
case WM_BUTTON3DOWN:
case WM_BUTTON3UP:
case WM_BUTTON3DBLCLK:
case WM_BUTTON1CLICK:
case WM_BUTTON2CLICK:
case WM_BUTTON3CLICK:
case WM_BEGINDRAG:
case WM_ENDDRAG:
case WM_SINGLESELECT:
case WM_OPEN: /* Generated after a double-click of button 1 */
case WM_CONTEXTMENU:
default:
return 0;
} /* end switch */
return 1;
} /* end MouEvent */
/*
** End macro: mouse.rm
*/