Пример #1
0
static void 
_Start_DragEvent( LCUI_Widget *widget, LCUI_MouseEvent *event )
{
	drag_event.cursor_pos = event->global_pos;
	/* 用全局坐标减去部件的全局坐标,得到偏移坐标 */ 
	__offset_pos = Pos_Sub( event->global_pos, Get_Widget_Global_Pos( widget ) );
	/* 得出部件的新全局坐标 */
	drag_event.new_pos = Pos_Sub( event->global_pos, __offset_pos );
	drag_event.first_click = 1;
	drag_event.end_click = 0;
	/* 处理部件的拖动事件 */
	Handle_Event( &widget->event, EVENT_DRAG );
}
Пример #2
0
static void Move_Window(LCUI_Widget *titlebar, LCUI_DragEvent *event)
/* 功能:处理鼠标移动事件 */
{
    LCUI_Pos pos;
    LCUI_Widget *window;
    if(event->first_click == 0 ) {
        window = titlebar->parent;
        pos = event->new_pos;
        if(window != NULL) {
            /* 减去在窗口中的相对坐标, 得出窗口位置 */
            pos = Pos_Sub(pos, Get_Widget_Pos(titlebar));
            if(window->parent != NULL) {
                pos = Pos_Sub(pos, Get_Widget_Global_Pos(window->parent));
            }
            /* 移动窗口的位置 */
            Move_Widget(window, pos);
        }
    }
}
Пример #3
0
static void 
ScrollBar_Drag( LCUI_Widget *widget, LCUI_DragEvent *event )
{
	static LCUI_Pos pos, offset;
	static LCUI_ScrollBar *scrollbar;
	
	if( !widget->parent ) {
		return;
	}
	
	scrollbar = Get_Widget_PrivData( widget->parent );
	pos = Get_Widget_Global_Pos( widget );
	offset = Pos_Sub( event->new_pos, pos ); 
	pos = Pos_Add( pos, offset ); 
	pos = GlobalPos_ConvTo_RelativePos( widget, pos );
	
	Move_ScrollBar( widget, pos );
	/* 若函数指针有效,则调用回调函数 */
	if( scrollbar->callback_func ) {
		scrollbar->callback_func( scrollbar->data, scrollbar->arg );
	}
}
Пример #4
0
static void * Handle_TouchScreen_Input ()
/* 功能:处理触屏输入 */
{
	char *tsdevice;
	struct ts_sample samp;
	int button, x, y, ret;
	LCUI_MouseEvent event;
	
	char str[100];
	while (LCUI_Active()) {
		if (LCUI_Sys.ts.status != INSIDE) {
			tsdevice = getenv("TSLIB_TSDEVICE");
			if( tsdevice != NULL ) {
				LCUI_Sys.ts.td = ts_open(tsdevice, 0);
			} else {
				tsdevice = TS_DEV;
			}
			LCUI_Sys.ts.td = ts_open (tsdevice, 0);
			if (!LCUI_Sys.ts.td) { 
				sprintf (str, "ts_open: %s", tsdevice);
				perror (str);
				LCUI_Sys.ts.status = REMOVE;
				break;
			}

			if (ts_config (LCUI_Sys.ts.td)) {
				perror ("ts_config");
				LCUI_Sys.ts.status = REMOVE;
				break;
			}
			LCUI_Sys.ts.status = INSIDE;
		}

		/* 开始获取触屏点击处的坐标 */ 
		ret = ts_read (LCUI_Sys.ts.td, &samp, 1); 
		if (ret < 0) {
			perror ("ts_read");
			continue;
		}

		if (ret != 1) {
			continue;
		}
		x = samp.x;
		y = samp.y;
		
		if (x > Get_Screen_Width ()) {
			x = Get_Screen_Width ();
		}
		if (y > Get_Screen_Height ()) {
			y = Get_Screen_Height ();
		}
		if (x < 0) {
			x = 0;
		}
		if (y < 0) {
			y = 0;
		}
		/* 设定游标位置 */ 
		Set_Cursor_Pos (Pos(x, y));
		
		event.global_pos.x = x;
		event.global_pos.y = y;
		/* 获取当前鼠标指针覆盖到的部件的指针 */
		event.widget = Get_Cursor_Overlay_Widget();
		/* 如果有覆盖到的部件,就需要计算鼠标指针与部件的相对坐标 */
		if(event.widget != NULL) {
			event.pos.x = x - Get_Widget_Global_Pos(event.widget).x;
			event.pos.y = y - Get_Widget_Global_Pos(event.widget).y;
		} else {/* 否则,和全局坐标一样 */
			event.pos.x = x;
			event.pos.y = y;
		}
		if (samp.pressure > 0) {
			button = 1; 
		} else {
			button = 0; 
		}
			/* 处理鼠标事件 */
		Handle_Mouse_Event(button, &event); 
		//printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
	}
	if(LCUI_Sys.ts.status == INSIDE) {
		ts_close(LCUI_Sys.ts.td); 
	}
	LCUI_Sys.ts.status = REMOVE;
	thread_exit (NULL);
}