Ejemplo n.º 1
0
static LCUI_BOOL MouseProc( void )
{
#ifdef USE_THIS_CODE
	LCUI_Pos pos;
	POINT new_pos;

	/* 获取鼠标坐标 */
	GetCursorPos( &new_pos );
	/* 转换成相对于窗口客户区的坐标 */
	ScreenToClient( Win32_GetSelfHWND(), &new_pos );
	if (new_pos.x > LCUIDisplay_GetWidth() ) {
		new_pos.x = LCUIDisplay_GetWidth();
	}
	if( new_pos.y > LCUIDisplay_GetHeight() ) {
		new_pos.y = LCUIDisplay_GetHeight();
	}
	new_pos.x = new_pos.x<0 ? 0:new_pos.x;
	new_pos.y = new_pos.y<0 ? 0:new_pos.y;
	LCUICursor_GetPos( &pos );
	if( pos.x == new_pos.x && pos.y == new_pos.y ) {
		return FALSE;
	}
	pos.x = new_pos.x;
	pos.y = new_pos.y;
	/* 更新鼠标游标的位置 */
	LCUICursor_SetPos( pos );
	LCUI_PostMouseMoveEvent( pos );
#endif
	return TRUE;
}
Ejemplo n.º 2
0
/*
 * 功能:用于对LCUI进行初始化操作
 * 说明:每个使用LCUI实现图形界面的程序,都需要先调用此函数进行LCUI的初始化
 * */
int LCUI_Init(void)
{
	if( System.is_inited ) {
		return -1;
	}
	System.is_inited = TRUE;
	System.func_atexit = NULL;
	System.exit_code = 0;
	System.state = STATE_ACTIVE;
	System.main_tid = LCUIThread_SelfID();
	LCUI_ShowCopyrightText();
	LCUIApp_Init();
	/* 初始化各个模块 */
	LCUI_InitEvent();
	LCUI_InitFont();
	LCUI_InitTimer();
	LCUI_InitDevice();
	LCUI_InitKeyboard();
	LCUI_InitMouse();
	LCUI_InitCursor();
	LCUI_InitWidget();
	LCUI_InitDisplay();
	{
		LCUI_Pos pos;
		pos.x = LCUIDisplay_GetWidth()/2;
		pos.y = LCUIDisplay_GetHeight()/2;
		/* 让鼠标游标居中显示 */
		LCUICursor_SetPos( pos );
		LCUICursor_Show();
	}
	return 0;
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: yydaor/LCUI
/* 
 * 功能:用于对LCUI进行初始化操作 
 * 说明:每个使用LCUI实现图形界面的程序,都需要先调用此函数进行LCUI的初始化
 * */
LCUI_API int
LCUI_Init( int mode, void *arg )
{
	int temp;
	/* 如果LCUI没有初始化过 */
	if( !LCUI_Sys.init ) {
		LCUI_Sys.init = TRUE;
		LCUI_Sys.state = ACTIVE;
		srand(time(NULL));
		LCUI_ShowCopyrightText();
		
		LCUI_Sys.mode = mode;
#ifdef LCUI_BUILD_IN_WIN32
		Win32_LCUI_Init((HINSTANCE)arg );
#endif
		LCUIAppList_Init();
		/* 注册程序 */
		temp = LCUIAppList_Add();
		if(temp != 0) {
			printf(APP_ERROR_REGISTER_ERROR);
			abort();
		}
		/* 初始化各个模块 */
		LCUIModule_Thread_Init();
		LCUIModule_Event_Init();
		LCUIModule_IME_Init();
		LCUIModule_Font_Init();
		LCUIModule_Timer_Init();
		LCUIModule_Device_Init();
		LCUIModule_Keyboard_Init();
		LCUIModule_Mouse_Init();
		LCUIModule_TouchScreen_Init();
		LCUIModule_Video_Init();
		LCUIModule_Cursor_Init();
		LCUIModule_Widget_Init();
		/* 让鼠标游标居中显示 */
		LCUICursor_SetPos( LCUIScreen_GetCenter() );  
		LCUICursor_Show();
	} else {
		temp = LCUIAppList_Add();
		if(temp != 0) {
			printf(APP_ERROR_REGISTER_ERROR);
			abort();
		}
	}
	/* 注册默认部件类型 */
	Register_DefaultWidgetType();
	return 0;
}
Ejemplo n.º 4
0
static LCUI_BOOL MouseProc( void )
{
	static int  tmp;
	static char buf[6];
	static fd_set readfds;
	static struct timeval tv;
	static LCUI_Pos pos;

	if (mouse.state == STATE_REMOVE || mouse.fd < 0) {
		return FALSE;
	}
	/* 设定select等待I/o的最长时间 */
	tv.tv_sec = 0;
	tv.tv_usec = 0;

	FD_ZERO (&readfds);
	FD_SET (mouse.fd, &readfds);

	tmp = select (mouse.fd+1, &readfds, NULL, NULL, &tv);
	if (tmp == 0) {
		//printf("Time out!\n");
		return FALSE;
	}
	if ( !FD_ISSET (mouse.fd, &readfds) ) {
		return FALSE;
	}
	tmp = read (mouse.fd, buf, 6);
	if (tmp <= 0){
		if (tmp < 0) {
			mouse.state = STATE_REMOVE;
		}
		return FALSE;
	}

	LCUICursor_GetNewPos( &pos );
	pos.x += buf[1];
	pos.y -= buf[2];
	if( pos.x > LCUIScreen_GetWidth() ) {
		pos.x = LCUIScreen_GetWidth();
	}
	if( pos.y > LCUIScreen_GetHeight() ) {
		pos.y = LCUIScreen_GetHeight();
	}
	pos.x = pos.x<0 ? 0:pos.x;
	pos.y = pos.y<0 ? 0:pos.y;
	/* 应用鼠标游标的位置变更 */
	LCUICursor_SetPos( pos );
	LCUI_PostMouseMoveEvent( pos );
	switch ( buf[0]&0x07 ) {
	    case 1:		/* 鼠标左键被按下 */
		LCUI_PostMouseDownEvent( LCUIKEY_LEFTBUTTON );
		LCUI_PostMouseUpEvent( LCUIKEY_RIGHTBUTTON );
		break;
	    case 2:		/* 鼠标右键被按下 */
		LCUI_PostMouseDownEvent( LCUIKEY_RIGHTBUTTON );
		LCUI_PostMouseUpEvent( LCUIKEY_LEFTBUTTON );
		break;
	    case 3:		/* 鼠标左右键被按下 */
		LCUI_PostMouseDownEvent( LCUIKEY_RIGHTBUTTON );
		LCUI_PostMouseDownEvent( LCUIKEY_LEFTBUTTON );
		break;
	    default:		/* 默认是释放的 */
		LCUI_PostMouseUpEvent( LCUIKEY_RIGHTBUTTON );
		LCUI_PostMouseUpEvent( LCUIKEY_LEFTBUTTON );
		break;
	}
	return TRUE;
}