⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 devmouse.c

📁 the embedded GUI for SamSung s3c2410 cpu based board.is microwindows0.90
💻 C
📖 第 1 页 / 共 2 页
字号:
 * Set the cursor size and bitmaps. * * @param pcursor New mouse cursor. */voidGdSetCursor(PMWCURSOR pcursor){	int	bytes;	GdHideCursor(&scrdev);	curmaxx = curminx + pcursor->width - 1;	curmaxy = curminy + pcursor->height - 1;	curfg = GdFindColor(&scrdev, pcursor->fgcolor);	curbg = GdFindColor(&scrdev, pcursor->bgcolor);	bytes = MWIMAGE_SIZE(pcursor->width, pcursor->height) * sizeof(MWIMAGEBITS);	memcpy(cursorcolor, pcursor->image, bytes);	memcpy(cursormask, pcursor->mask, bytes);	GdShowCursor(&scrdev);}/** * Draw the mouse pointer.  Save the screen contents underneath * before drawing. Returns previous cursor state. * * @param psd Drawing surface. * @return 1 iff the cursor was visible, else <= 0 */intGdShowCursor(PSD psd){	MWCOORD 		x;	MWCOORD 		y;	MWPIXELVAL *	saveptr;	MWIMAGEBITS *	cursorptr;	MWIMAGEBITS *	maskptr;	MWIMAGEBITS 	curbit, cbits = 0, mbits = 0;	MWPIXELVAL 	oldcolor;	MWPIXELVAL 	newcolor;	int 		oldmode;	int		prevcursor = curvisible;	if(++curvisible != 1)		return prevcursor;	oldmode = gr_mode;	gr_mode = MWMODE_COPY;	saveptr = cursavbits;	cursavx = curminx;	cursavy = curminy;	cursavx2 = curmaxx;	cursavy2 = curmaxy;	cursorptr = cursorcolor;	maskptr = cursormask;	/*	 * Loop through bits, resetting to firstbit at end of each row	 */	curbit = 0;	for (y = curminy; y <= curmaxy; y++) {		if (curbit != MWIMAGE_FIRSTBIT) {			cbits = *cursorptr++;			mbits = *maskptr++;			curbit = MWIMAGE_FIRSTBIT;		}		for (x = curminx; x <= curmaxx; x++) {			if(x >= 0 && x < psd->xvirtres &&			   y >= 0 && y < psd->yvirtres) {				oldcolor = psd->ReadPixel(psd, x, y);				if (curbit & mbits) {					newcolor = (curbit&cbits)? curbg: curfg;					if (oldcolor != newcolor)						psd->DrawPixel(psd, x, y, newcolor);				}				*saveptr++ = oldcolor;			}			curbit = MWIMAGE_NEXTBIT(curbit);			if (!curbit) {	/* check > one MWIMAGEBITS wide*/				cbits = *cursorptr++;				mbits = *maskptr++;				curbit = MWIMAGE_FIRSTBIT;			}		}	}	gr_mode = oldmode;	return prevcursor;}/** * Restore the screen overwritten by the cursor. * * @param psd Drawing surface. * @return 1 iff the cursor was visible, else <= 0 */intGdHideCursor(PSD psd){	MWPIXELVAL *	saveptr;	MWCOORD 		x, y;	int 		oldmode;	int		prevcursor = curvisible;	if(curvisible-- <= 0)		return prevcursor;	oldmode = gr_mode;	gr_mode = MWMODE_COPY;	saveptr = cursavbits;	for (y = cursavy; y <= cursavy2; y++) {		for (x = cursavx; x <= cursavx2; x++) {			if(x >= 0 && x < psd->xvirtres &&			   y >= 0 && y < psd->yvirtres) {				psd->DrawPixel(psd, x, y, *saveptr++);			}		}	} 	gr_mode = oldmode;	return prevcursor;}/** * Check to see if the mouse pointer is about to be overwritten. * If so, then remove the cursor so that the graphics operation * works correctly.  If the cursor is removed, then this fact will * be remembered and a later call to GdFixCursor will restore it. * * @param psd Drawing surface.  If it is not onscreen, this call has * no effect. * @param x1 Left edge of rectangle to check. * @param y1 Top edge of rectangle to check. * @param x2 Right edge of rectangle to check. * @param y2 Bottom edge of rectangle to check. */voidGdCheckCursor(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2){	MWCOORD temp;	if (curvisible <= 0 || (psd->flags & PSF_SCREEN) == 0)		return;	if (x1 > x2) {		temp = x1;		x1 = x2;		x2 = temp;	}	if (y1 > y2) {		temp = y1;		y1 = y2;		y2 = temp;	}	if (x1 > curmaxx || x2 < curminx || y1 > curmaxy || y2 < curminy)		return;	GdHideCursor(psd);	curneedsrestore = TRUE;}/** * Redisplay the cursor if it was removed because of a graphics operation. * * @param psd Drawing surface.  If it is not onscreen, this call has * no effect. */voidGdFixCursor(PSD psd){	if (curneedsrestore && (psd->flags & PSF_SCREEN)) {		GdShowCursor(psd);		curneedsrestore = FALSE;	}}/* Input filter routines - global mouse filtering is cool */#define JITTER_SHIFT_BITS	2#define JITTER_DEPTH		(1 << (JITTER_SHIFT_BITS))static MWTRANSFORM g_trans;	/* current transform*/static struct {	int x;	int y;	int count;} jitter = { 0, 0, 0};/* set mouse transform, raw mode if no transform specified*/voidGdSetTransform(MWTRANSFORM *trans){	if (!(mousedev.flags & MOUSE_TRANSFORM))		return;	if (trans) {		g_trans = *trans;		/*memcpy(&g_trans, trans, sizeof(MWTRANSFORM));*/		mousedev.flags &= ~MOUSE_RAW;	} else		mousedev.flags |= MOUSE_RAW;}/* These are the mouse input filters */static intfilter_relative(int state, int thresh, int scale, int *xpos, int *ypos, int x,	int y){	int sign = 1;	if (state != 1)		return 0;	if (x < 0) {		sign = -1;		x = -x;	}	if (x > thresh)		x = thresh + (x - thresh) * scale;	x *= sign;	sign = 1;	if (y < 0) {		sign = -1;		y = -y;	}	if (y > thresh)		y = thresh + (y - thresh) * scale;	y *= sign;	*xpos = x;	*ypos = y;	return 0;}#if FLIP_MOUSE_IN_PORTRAIT_MODEstatic intfilter_relrotate(int state, int *xpos, int *ypos, int x, int y){	if (state == 3)		return 0;	switch (scrdev.portrait) {	case MWPORTRAIT_RIGHT:		*xpos += y;		*ypos -= x;		break;	case MWPORTRAIT_LEFT:		*xpos -= y;		*ypos += x;		break;	case MWPORTRAIT_DOWN:		*xpos += x;		*ypos -= y;		break;	default:		*xpos += x;		*ypos += y;	}	return 0;}static intfilter_absrotate(int state, int *xpos, int *ypos){	int x = *xpos;	int y = *ypos;	if (state == 3)		return 0;	switch (scrdev.portrait) {	case MWPORTRAIT_RIGHT:		*xpos = y;		*ypos = scrdev.xres - x - 1;		break;	case MWPORTRAIT_LEFT:		*xpos = scrdev.yres - y - 1;		*ypos = x;		break;	case MWPORTRAIT_DOWN:		*xpos = x;		*ypos = scrdev.yres - y - 1;		break;	default:		*xpos = x;		*ypos = y;	}	return 0;}#endif /* FLIP_MOUSE_IN_PORTRAIT_MODE*/static intfilter_transform(int state, int *xpos, int *ypos){	/* No transform data is available, just return the raw values */	if (state == 3) {		jitter.count = jitter.x = jitter.y = 0;		return 1;	} else if (state == 1)		return 1;	if (jitter.count == JITTER_DEPTH) {		jitter.x = jitter.x >> JITTER_SHIFT_BITS;		jitter.y = jitter.y >> JITTER_SHIFT_BITS;		/* No translation if transform not setup yet*/		if (g_trans.s && !(mousedev.flags & MOUSE_RAW)) {			*xpos = ((g_trans.a * jitter.x +				  g_trans.b * jitter.y +				  g_trans.c) / g_trans.s);			*ypos = ((g_trans.d * jitter.x +				  g_trans.e * jitter.y +				  g_trans.f) / g_trans.s);			jitter.count = jitter.x = jitter.y = 0;			return 1;		} else {			*xpos = jitter.x;			*ypos = jitter.y;			jitter.count = jitter.x = jitter.y = 0;			return 2;		}	}	jitter.x += *xpos;	jitter.y += *ypos;	++jitter.count;	return 0;		/* In other words, don't use the returned value */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -