📄 inon0.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1997 - 1999 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* INON0.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the PtInRect, XYInRect, VectSetup & */
/* VectRestore functions. */
/* */
/* AUTHOR */
/* */
/* Robert G. Burrill, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* BobB 11/16/99 Got rid of ANSI compiler warnings */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
void (*origFiller)(); /* pointer for original filler */\
int orgPenFlags; /* original ports pen flags*/\
/* Function PtInRect determines whether the specified point, fpTESTPT, with
added sizX and sizY, is in the specified rectangle argRect, and returns a
TRUE if it is or FALSE if is not. */
int PtInRect(point *fpTESTPT, rect *argRect, int sizX, int sizY)
{
rect trivRect; /* temp trivial check rect */
rect tempR;
short tempX;
short tempY;
PtRslt = 0; /* initialize test result */
/* Set up test rectangle. In order to match the pen, we follow the same
rectangle fill rules. This means that an even sized pen will have
the "extra" size at the right and maximum sides. */
if (globalLevel > 0)
{
/* convert from user to global */
U2GP(fpTESTPT->X, fpTESTPT->Y, &tempX, &tempY, 1);
}
else
{
tempX = fpTESTPT->X;
tempY = fpTESTPT->Y;
/* Thin lines still count as a pixel sized line, so adjust fudge accordingly */
if(sizX < 1) sizX = 1;
if(sizY < 1) sizY = 1;
}
/* for consistency, do exactly what CenterRect does */
PtTstR.Xmin = tempX - (sizX >> 1);
PtTstR.Ymin = tempY - (sizY >> 1);
PtTstR.Xmax = PtTstR.Xmin + sizX;
PtTstR.Ymax = PtTstR.Ymin + sizY;
if(argRect == 0) return(0); /* exit if no trivial check */
tempR = *argRect;
if (globalLevel > 0)
{
/* convert from user to global */
U2GR(tempR, &trivRect, 0);
}
else
{
trivRect = tempR;
}
PtTstR.Xmax--; /* we are checking the test rect "area" */
PtTstR.Ymax--; /* so decrement Xmax and Ymax */
if ((PtTstR.Xmax >= trivRect.Xmin) && (PtTstR.Xmin < trivRect.Xmax) &&
(PtTstR.Ymax >= trivRect.Ymin) && (PtTstR.Ymin < trivRect.Ymax))
{
PtTstR.Xmax++; /* put back Xmax and Ymax to the */
PtTstR.Ymax++; /* undecremented test rect */
PtRslt = 1; /* set true flag */
}
return(PtRslt);
}
/* Function XYInRect determines whether the position X,Y is included within the
specified rectangle argRect, and returns a TRUE if it is or FALSE if is not. */
int XYInRect(int valX, int valY, rect *varR)
{
if ((valX >= varR->Xmin) && (valX <= varR->Xmax) &&
(valY >= varR->Ymin) && (valY <= varR->Ymax))
{
return(1);
}
return(0);
}
/* Function VectSetup is an internal function that sets the primitive vectors. */
void VectSetup(void)
{
void mwRectInList();
origFiller = grafPort.portMap->prFill; /* save orig filler pointer */
grafPort.portMap->prFill = mwRectInList; /* new filler */
orgPenFlags = grafPort.pnFlags; /* save orig pen flags */
if (!(grafPort.pnFlags & pnSizeFlg))
{ /* Force lines to go wide so that they will call filler */
grafPort.pnSize.X = 1; /* modifies shadow port ONLY! */
grafPort.pnSize.Y = 1;
grafPort.pnFlags |= pnSizeFlg;
SETLINESTYLE(grafPort.pnFlags);
}
return;
}
/* Function VectRestore is an internal function that restores the original
primitive vectors. */
void VectRestore(void)
{
if (!(orgPenFlags & pnSizeFlg))
{ /* Force lines to go wide so that they will call filler */
grafPort.pnSize.X = 0; /* modifies shadow port ONLY! */
grafPort.pnSize.Y = 0;
grafPort.pnFlags = orgPenFlags;
SETLINESTYLE(grafPort.pnFlags);
}
grafPort.portMap->prFill = origFiller; /* new filler */
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -