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

📄 event.c

📁 microwindows上的修改的GUI
💻 C
字号:
/*
 *  Event Handler for emGUI
 *
 *
 *  COPYRIGHT (c) 2001 - 2010.
 *  emTech System Corporation.
 *
 *  The license and distribution terms for this file may be
 *  found in found in the file LICENSE.
 */

/*	Huangf emcore@263.net
 */
#include "emGUI.h"

#include <stdlib.h>

static unsigned32 _previousbutton;

void EventInitialize()
{
}

void SysHandleEvent()
{
	while(1){
		if (SysGetEvent(50)){
			SysSendAppMessage();
		}
	}
}

void AppHandleEvent(Application *app)
{
	int 		x, y, button;
	Window    	*wnd;
	
	int			type;
	unsigned16	msg;
	unsigned16  nParam;
	unsigned32	lParam;
	RECT		rect;
		
	type 	= app->msgBuf[0];
	switch(type){
		case EVS_MOUSE:
			x 		= app->msgBuf[1];
			y 		= app->msgBuf[2];
			button 	= app->msgBuf[3];
			wnd  	= FindWindow(
				app,
				x,
				y
			);

			if (wnd == NULL){
				/*  cannot find window */
				return;
			}
			
			if ((button & BUTTON_LEFT) == (_previousbutton & BUTTON_LEFT)){
				msg = MOUSEMOVE;
			}
			else{
				if (_previousbutton & BUTTON_LEFT){
					msg = LBUTTONUP;
				}
				else{
					msg = LBUTTONDOWN;
				}
			}
			_previousbutton = button;

			nParam			= button;	/*  current button status */
			lParam			= (x << 16) | (y & 0x0000FFFF);
			
			break;
			
		case EVS_SYSTEM:
			wnd 			= (WndID)app->msgBuf[1];
			msg				= (app->msgBuf[2] >> 16);
			nParam			= (app->msgBuf[2] & 0x0000FFFF);
			lParam			= (app->msgBuf[3]);
			
			if (wnd == NULL){
				/*  Application message */
				if (app->appProc){
					app->appProc(
						app,
						msg,
						nParam,
						lParam
					);
				}
				return;
			}

			switch(msg){
				case WM_PAINT:
					wnd->paint_count--;
					if (wnd->paint_count){
						return;
					}
					
					rect.left 	= wnd->invalid_l;
					rect.top  	= wnd->invalid_t;
					rect.right 	= wnd->invalid_r;
					rect.bottom = wnd->invalid_b;
					wnd->invalid_l = 0;
					wnd->invalid_t = 0;
					wnd->invalid_r = 0;
					wnd->invalid_b = 0;
					nParam = 0;
					lParam = (unsigned32)&rect;
					break;
			}
			
		default:
			return;
		/*  add other event here*/
	}
	
	wnd->wndProc(
		wnd,			/*  wndID */
		msg,			/*  message */
		nParam,			/*  parameter 1 */
		lParam			/*  parameter 2 */
	);
}

⌨️ 快捷键说明

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