home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
NOTEPAD2.ZIP
/
MMOUSE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-08
|
4KB
|
112 lines
/*
* mmouse.c -- Mouse management
*
* Created by Microsoft Corporation, 1989
*/
#define INCL_WIN
#include <os2.h>
#include "mtypes.h"
#include "mfuncs.h"
/* public function
*
* VOID MouseInit(PED ped)
*
* Initializes the mouse manager.
*/
public VOID MouseInit(PED ped)
{
ped->fMouseDown = ped->fMouseScroll = FALSE;
}
/* public function
*
* VOID ProcessMouse (PED ped, USHORT nMessage, SHORT x, SHORT y)
*
* Responds to any mouse message (from WM_MOUSEFIRST to WM_MOUSELAST) sent
* to the MLE window procedure. x and y are the SIGNED low and high words
* of mparam1, respectively.
*
* This routine also receives WM_TIMER messages from the TID_MOUSESCROLL
* timer, which is responsible for autoscroll when the mouse is dragged out of
* the window.
*
* Except for buttons 1 and 2 and mouse movement, all mouse messages are
* ignored.
*/
public VOID ProcessMouse (PED ped, USHORT nMessage, SHORT x, SHORT y)
{
BOOL fOutside;
fOutside = ((x <= 0) ||
(y <= 0) ||
(x >= (SHORT) ped->rclWnd.xRight-1) ||
(y >= (SHORT) ped->rclWnd.yTop-1));
switch (nMessage) {
case WM_BUTTON2DOWN: // right button sets focus only
WinSetFocus(HWND_DESKTOP, ped->hwnd);
break;
case WM_BUTTON1DOWN:
ped->fMouseDown = TRUE;
WinSetFocus(HWND_DESKTOP, ped->hwnd);
WinSetCapture(HWND_DESKTOP, ped->hwnd);
DispSetCursorXY(ped,x,y,WinGetKeyState(HWND_DESKTOP,VK_SHIFT)<0,
FALSE);
break;
case WM_BUTTON1UP:
if (ped->fMouseDown) {
ped->fMouseDown = FALSE;
WinSetCapture (HWND_DESKTOP, NULL);
}
if (ped->fMouseScroll) {
ped->fMouseScroll = !(WinStopTimer((HAB)NULL,
ped->hwnd, TID_MOUSESCROLL));
}
break;
case WM_TIMER:
if (! ped->fMouseDown)
return;
// otherwise fall through
case WM_MOUSEMOVE:
if (!ped->fMouseDown) {
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP,
fOutside ? SPTR_ARROW : SPTR_TEXT,
FALSE));
}
if (ped->fMouseDown) { // dragging cursor
DispSetCursorXY(ped, x, y, TRUE, FALSE);
if (fOutside != ped->fMouseScroll) {
// If we moved into or out of the window, start or stop
// the scroll timer. If we succeed, record the change
// in ped; otherwise, we'll try
// again the next time we get this message.
if (fOutside) {
ped->fMouseScroll = WinStartTimer((HAB)NULL, ped->hwnd,
TID_MOUSESCROLL, (USHORT) WinQuerySysValue(
HWND_DESKTOP, SV_SCROLLRATE));
} else {
ped->fMouseScroll = !(WinStopTimer((HAB)NULL,
ped->hwnd, TID_MOUSESCROLL));
}
}
}
break;
case WM_BUTTON1DBLCLK: // select a word
DispSetCursorXY(ped,x,y,WinGetKeyState(HWND_DESKTOP,VK_SHIFT)<0,
TRUE);
break;
}
}