コード例 #1
0
/**************************** 私有函数 **********************************/
static void
Move_ScrollBar( LCUI_Widget *widget, LCUI_Pos new_pos )
{
	double scale;
	int size;
	LCUI_ScrollBar *scrollbar;
	//_DEBUG_MSG("new_pos: %d,%d\n", new_pos.x, new_pos.y);
	scrollbar = Widget_GetPrivData( widget->parent );
	/* 使该坐标在限制范围内 */
	new_pos = Widget_GetValidPos( widget, new_pos );
	/* 判断滚动条的方向 */
	if( scrollbar->direction == 0 ) { /* 纵向 */
		/* 先得到容器高度 */
		size = Widget_GetContainerHeight( widget->parent );
		//_DEBUG_MSG("1,size: %d\n", size);
		/* 减去自身高度 */
		size -= _Widget_GetHeight( widget );
		//_DEBUG_MSG("2,size: %d\n", size);
		/* 再用当前坐标除以size,得到比例 */
		scale = new_pos.y * 1.0 / size;
		//_DEBUG_MSG("%.2f = %d * 1.0 / %d\n", scale, new_pos.y, size);
		/* 将max_num乘以比例,得出current_num的值 */
		scrollbar->data.current_num = scale * scrollbar->data.max_num;
		//_DEBUG_MSG("current_num: %d, scale: %.2f, max_num: %d\n", 
		//scrollbar->data.current_num, scale, scrollbar->data.max_num);
	} else { /* 横向 */
		size = Widget_GetContainerWidth( widget->parent );
		size -= _Widget_GetWidth( widget );
		scale = new_pos.x * 1.0 / size;
		scrollbar->data.current_num = scale * scrollbar->data.max_num;
	}
	//_DEBUG_MSG("widget:%p, pos: %d,%d\n", widget, new_pos.x, new_pos.y);
	Widget_Move( widget, new_pos );
}
コード例 #2
0
ファイル: window.c プロジェクト: FrankHB/LCUI
static void Window_OnUpdate( LCUI_Widget *window )
{
	LCUI_Window *wnd;
	LCUI_Border border;
	char h_str[20];

	wnd = (LCUI_Window*)Widget_GetPrivateData( window );
	border = Border( 1, BORDER_STYLE_SOLID, RGB(200,200,200) );
	border.top_width = TOP_PANDDING;
	/* 若窗口已获得焦点 */
	if( Widget_GetFocus( window ) ) {
		border.top_color = wnd->theme_color;
		border.bottom_color = wnd->theme_color;
		border.left_color = wnd->theme_color;
		border.right_color = wnd->theme_color;
		Widget_SetShadow( window, BoxShadow(0,0,8,wnd->theme_color) );
	} else {
		Widget_SetShadow( window, BoxShadow(0,0,8,ARGB(120,200,200,200)) );
	}
	Widget_SetBorder( window, border );
	/* 更新窗口标题栏上的关闭按钮 */
	Widget_Update( wnd->btn_close );
	sprintf( h_str, "%dpx", Widget_GetContainerHeight(window)-35 );
	Widget_SetSize( wnd->client_area, "100%", h_str );
}
コード例 #3
0
static void 
ScrollBar_Update( LCUI_Widget *widget )
{
	static int pos, max_len;
	static double scale;
	static char scale_str[256];
	LCUI_ScrollBar *scrollbar;
	
	scrollbar = Widget_GetPrivData( widget );
	/* 计算比例,之后转换成字符串 */
	scale = scrollbar->data.current_size*1.0 / scrollbar->data.max_size; 
	sprintf( scale_str, "%.2lf%%", scale*100 );
	//_DEBUG_MSG("current_num: %d, max_num: %d\n", 
	//scrollbar->data.current_num, scrollbar->data.max_num);
	/* 判断滚动条的方向 */
	if( scrollbar->direction == 0 ) { /* 纵向 */
		Widget_SetSize( scrollbar->widget, NULL, scale_str );
		max_len = Widget_GetContainerHeight( widget );
		max_len -= _Widget_GetHeight( scrollbar->widget );
		Widget_LimitPos( scrollbar->widget, Pos(0,0), Pos( 0, max_len ) );
		
		scale = scrollbar->data.current_num*1.0 / scrollbar->data.max_num;
		pos = scale * max_len;
		//_DEBUG_MSG("num: %d / %d\n", 
		//scrollbar->data.current_num, scrollbar->data.max_num);
		//_DEBUG_MSG("ScrollBar_Update(), scale: %.2f\n", scale);
		//_DEBUG_MSG("ScrollBar_Update(), y: %d\n", pos);
		/* 移动滚动条 */
		Widget_Move( scrollbar->widget, Pos(0,pos) );
	} else { /* 横向 */ 
		Widget_SetSize( scrollbar->widget, scale_str, NULL );
		max_len = Widget_GetContainerWidth( widget );
		max_len -= _Widget_GetWidth( scrollbar->widget );
		Widget_LimitPos( scrollbar->widget, Pos(0,0), Pos(max_len,0) );
		scale = scrollbar->data.current_num*1.0 / scrollbar->data.max_num;
		pos = scale * max_len;
		//printf("ScrollBar_Update(), num: %d / %d\n", 
		//scrollbar->data.current_num, scrollbar->data.max_num);
		//printf("ScrollBar_Update(), scale: %.2f\n", scale);
		//printf("ScrollBar_Update(), x: %d\n", pos);
		Widget_Move( scrollbar->widget, Pos(pos, 0) );
	}
}