Example #1
0
File: event.c Project: aem3372/LCUI
/** 解除事件连接 */
int $(Unbind)( LCUI_EventBox box, int handler_id )
{
	int i, n;
	LCUI_RBTreeNode *node;
	LCUI_EventSlot *slot;
	LCUI_EventHandler *handler;

	if( !(node = RBTree_Search(&box->event_handler, handler_id)) ) {
		return -1;
	}
	if( !(node = RBTree_Search(&box->event_slot, (int)(node->data))) ) {
		return -2;
	}
	slot = (LCUI_EventSlot*)node->data;
	LinkedList_Goto( &slot->handlers, 0 );
	n = LinkedList_GetTotal( &slot->handlers );
	for( i=0; i<n; ++i ) {
		handler = (LCUI_EventHandler*)LinkedList_Get( &slot->handlers );
		if( handler->id == handler_id ) {
			LinkedList_Delete( &slot->handlers );
			RBTree_Erase( &box->event_handler, handler_id );
			return 0;
		}
		LinkedList_ToNext( &slot->handlers );
	}
	return -3;
}
Example #2
0
File: event.c Project: aem3372/LCUI
/** 直接将事件发送至事件处理器进行处理 */
int $(Send)( LCUI_EventBox box, const char *name, void *data )
{
	int i, n;
	LCUI_Event event;
	LCUI_RBTreeNode *node;
	LCUI_EventSlot *slot;
	LCUI_EventHandler *handler;
	
	if( !(node = RBTree_CustomSearch(&box->event_name, (const void*)name)) ) {
		return -1;
	}
	if( !(node = RBTree_Search(&box->event_slot, node->key)) ) {
		return -2;
	}
	slot = (LCUI_EventSlot*)node->data;
	event.id = slot->id;
	event.name = slot->name;
	event.data = data;
	event.destroy_data = NULL;
	n = LinkedList_GetTotal( &slot->handlers );
	LinkedList_Goto( &slot->handlers, 0 );
	for( i=0; i<n; ++i ) {
		handler = (LCUI_EventHandler*)LinkedList_Get( &slot->handlers );
		handler->func( &event, handler->func_data );
		LinkedList_ToNext( &slot->handlers );
	}
	return 0;
}
Example #3
0
/** 获取指定按键的状态数据 */
static key_state* KeyStateRecord_FindData( int key_code )
{
	int i, n;
	key_state* data_ptr;

	n = LinkedList_GetTotal( &key_state_record );
	for( i=0; i<n; ++i ) {
		data_ptr = (key_state*)LinkedList_Get( &key_state_record );
		if( data_ptr && data_ptr->key_code == key_code ) {
			return data_ptr;
		}
		LinkedList_ToNext( &key_state_record );
	}
	return NULL;
}
Example #4
0
/** 退出所有主循环 */
static void LCUIApp_QuitAllMainLoop(void)
{
	LCUI_MainLoop loop;
	int n = LinkedList_GetTotal( &MainApp.loop_list );
	LinkedList_Goto( &MainApp.loop_list, 0 );
	while( n-- ) {
		loop = (LCUI_MainLoop)LinkedList_Get( &MainApp.loop_list );
		if( !loop ) {
			break;
		}
		loop->state = STATE_EXITED;
		LinkedList_ToNext( &MainApp.loop_list );
	}
	LCUICond_Broadcast( &MainApp.loop_cond );
}
Example #5
0
/** 停用设备处理模块 */
void LCUIModule_Device_End(void)
{
	int n, i;
	DeviceData *data_ptr;
	
	LCUIMutex_Lock( &list_mutex );
	n = LinkedList_GetTotal( &dev_list );
	for( i=0; i<n; ++i ) {
		data_ptr = (DeviceData*)LinkedList_Get( &dev_list );
		if( !data_ptr ) {
			break;
		}
		if( data_ptr->exit ) {
			data_ptr->exit();
		}
		LinkedList_ToNext( &dev_list );
	}
	LCUIMutex_Unlock( &list_mutex );
}
Example #6
0
/** 更新数据 */
void TextLayer_Update( LCUI_TextLayer* layer, LinkedList *rect_list )
{
	if( layer->task.update_bitmap ) {
		TextLayer_InvalidateAllRowRect( layer );
		TextLayer_ReloadCharBitmap( layer );
		TextLayer_InvalidateAllRowRect( layer );
		layer->task.update_bitmap = FALSE;
		layer->task.redraw_all = TRUE;
	}

	if( layer->task.update_typeset ) {
		TextLayer_TextTypeset( layer, layer->task.typeset_start_row );
		layer->task.update_typeset = FALSE;
		layer->task.typeset_start_row = 0;
	}

	/* 如果坐标偏移量有变化,记录各个文本行区域 */
	if( layer->new_offset_x != layer->offset_x
	 || layer->new_offset_y != layer->offset_y ) {
		TextLayer_InvalidateAllRowRect( layer );
		layer->offset_x = layer->new_offset_x;
		layer->offset_y = layer->new_offset_y;
		TextLayer_InvalidateAllRowRect( layer );
		layer->task.redraw_all = TRUE;
	}
	
	if( rect_list ) {
		int n;
		void *data_ptr;

		n = LinkedList_GetTotal( &layer->dirty_rect );
		LinkedList_Goto( &layer->dirty_rect, 0 );
		/* 转移脏矩形记录,供利用 */
		while(n--) {
			data_ptr = LinkedList_Get( &layer->dirty_rect );
			LinkedList_AddDataCopy( rect_list, data_ptr );
			LinkedList_ToNext( &layer->dirty_rect );
		}
	 } 
}
Example #7
0
/** 从程序任务队列中删除有指定回调函数的任务 */
int LCUI_RemoveTask( CallBackFunc task_func, LCUI_BOOL need_lock )
{
	int n;
	LCUI_Task *exist_task;

	if( need_lock ) {
		LCUIMutex_Lock( &MainApp.task_list_mutex );
	}
	n = LinkedList_GetTotal( &MainApp.task_list );
	for ( ; n>0; --n ) {
		exist_task = (LCUI_Task*)LinkedList_Get( &MainApp.task_list );
		if( exist_task && exist_task->func == task_func ) {
			LinkedList_Delete( &MainApp.task_list );
		} else {
			LinkedList_ToNext( &MainApp.task_list );
		}
	}
	if( need_lock ) {
		LCUIMutex_Unlock( &MainApp.task_list_mutex );
	}
	return n;
}
Example #8
0
/** 清除已记录的无效矩形 */
void TextLayer_ClearInvalidRect( LCUI_TextLayer *layer )
{
	int n;
	LCUI_Rect *rect_ptr;
	LCUI_Graph invalid_graph;

	if( !layer->is_using_buffer ) {
		DirtyRectList_Destroy( &layer->dirty_rect );
		DirtyRectList_Init( &layer->dirty_rect );
		return;
	}

	n = LinkedList_GetTotal( &layer->dirty_rect );
	LinkedList_Goto( &layer->dirty_rect, 0 );
	while(n--) {
		rect_ptr = (LCUI_Rect*)LinkedList_Get( &layer->dirty_rect );
		Graph_Quote( &invalid_graph, &layer->graph, rect_ptr );
		Graph_FillAlpha( &invalid_graph, 0 );
		LinkedList_ToNext( &layer->dirty_rect );
	}
	DirtyRectList_Destroy( &layer->dirty_rect );
	DirtyRectList_Init( &layer->dirty_rect );
}