Exemplo n.º 1
0
static void 
TextBox_TextLayer_Click( LCUI_Widget *widget, LCUI_WidgetEvent *event )
{
	static LCUI_Pos pos;
	static LCUI_TextBox *tb;
	static LCUI_TextLayer *layer;
	
	/* 保存当前已获得焦点的部件 */
	active_textbox = widget;
	layer = TextBox_GetTextLayer( widget );
	tb = Widget_GetPrivData( active_textbox );
	if( tb->show_placeholder ) {
		pos.x = pos.y = 0;
	} else {
		/* 全局坐标转换成相对坐标 */
		pos = GlobalPos_ConvTo_RelativePos( tb->text, event->drag.cursor_pos );
	}
	//printf("pos: %d,%d\n", pos.x, pos.y);
	/* 根据像素坐标,设定文本光标的位置 */
	TextLayer_Cursor_SetPixelPos( layer, pos );
	/* 获取光标的当前位置 */
	pos = TextLayer_Cursor_GetPos( layer );
	/* 主要是调用该函数更新当前文本浏览区域,以使光标处于显示区域内 */
	TextBox_Cursor_Move( widget, pos );
}
Exemplo n.º 2
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 );
	}
}
Exemplo n.º 3
0
static void 
ScrollBar_Drag( LCUI_Widget *widget, LCUI_WidgetEvent *event )
{
	static LCUI_Pos pos, offset;
	static LCUI_ScrollBar *scrollbar;
	if( !widget->parent ) {
		return;
	}
	
	scrollbar = Widget_GetPrivData( widget->parent );
	pos = Widget_GetGlobalPos( widget );
	offset = Pos_Sub( event->drag.new_pos, pos ); 
	pos = Pos_Add( pos, offset ); 
	pos = GlobalPos_ConvTo_RelativePos( widget, pos );
	
	Move_ScrollBar( widget, pos );
	/* 若函数指针有效,则调用回调函数 */
	if( scrollbar->callback_func ) {
		//_DEBUG_MSG("current_num: %d, max_num: %d\n", 
		//scrollbar->data.current_num, scrollbar->data.max_num);
		scrollbar->callback_func( scrollbar->data, scrollbar->arg );
	}
}