Ejemplo n.º 1
0
/*
 * 创建一个部件,作为滚动条的容器
 * 再创建一个部件,作为滚动条
 * 限制滚动条的移动范围
 * */
static void 
ScrollBar_Init( LCUI_Widget *widget )
{
	LCUI_ScrollBar *scrollbar;
	
	scrollbar = Widget_Create_PrivData(widget, sizeof(LCUI_ScrollBar));
	scrollbar->data.max_num = 100;
	scrollbar->data.current_num = 100;
	scrollbar->data.max_size = 100;
	scrollbar->data.current_size = 100;
	scrollbar->direction = 0;
	scrollbar->callback_func = NULL;
	
	scrollbar->widget = Create_Widget("button");
	/* 禁用部件的自动尺寸调整 */
	Widget_AutoSize( scrollbar->widget, FALSE, 0 );
	
	Widget_Container_Add( widget, scrollbar->widget );
	Set_Widget_Size( scrollbar->widget, "100%", "100%" );
	Limit_Widget_Pos( scrollbar->widget, Pos(0,0), Pos(0,0) ); 
	Set_Widget_Border( widget, RGB(100,100,100), Border(1,1,1,1) );
	Set_Widget_Padding( widget, Padding(1,1,1,1) );
	Set_Widget_Backcolor( widget, RGB(200,200,200) );
	Set_Widget_BG_Mode( widget, BG_MODE_FILL_BACKCOLOR );
	Show_Widget( scrollbar->widget );
	Widget_Drag_Event_Connect( scrollbar->widget, ScrollBar_Drag );
}
Ejemplo n.º 2
0
static LCUI_BOOL Widget_ComputeStaticSize(LCUI_Widget w, float *width,
					  float *height)
{
	LCUI_WidgetBoxModelRec *box = &w->box;
	LCUI_WidgetStyle *style = &w->computed_style;

	/* If it is non-static layout */
	if (style->display == SV_NONE || style->position == SV_ABSOLUTE) {
		return FALSE;
	}
	if (Widget_HasParentDependentWidth(w)) {
		/* Compute the full size of child widget */
		Widget_AutoSize(w);
		/* Recompute the actual size of child widget later */
		Widget_AddTask(w, LCUI_WTASK_RESIZE);
	}
	/* If its width is a percentage, it ignores the effect of its outer
	 * and inner spacing on the static width. */
	if (Widget_CheckStyleType(w, key_width, scale)) {
		if (style->box_sizing == SV_BORDER_BOX) {
			*width = box->border.x + box->border.width;
		} else {
			*width = box->content.x + box->content.width;
			*width -= box->content.x - box->border.x;
		}
		*width -= box->outer.x - box->border.x;
	} else if (box->outer.width <= 0) {
		return FALSE;
	} else {
		*width = box->outer.x + box->outer.width;
	}
	if (Widget_CheckStyleType(w, key_height, scale)) {
		if (style->box_sizing == SV_BORDER_BOX) {
			*height = box->border.y + box->border.height;
		} else {
			*height = box->content.y + box->content.height;
			*height -= box->content.y - box->border.y;
		}
		*height -= box->outer.y - box->border.y;
	} else if (box->outer.height <= 0) {
		return FALSE;
	} else {
		*height = box->outer.y + box->outer.height;
	}
	return TRUE;
}
Ejemplo n.º 3
0
/*---------------------------- Private -------------------------------*/
static void 
Label_Init(LCUI_Widget *widget)
/* 功能:初始化label部件数据 */
{
	LCUI_Label *label;
	/* label部件不需要焦点 */
	widget->focus = FALSE;
	label = Widget_Create_PrivData( widget, sizeof(LCUI_Label) );
	label->auto_size = TRUE;
	/* 初始化文本图层 */
	TextLayer_Init( &label->layer ); 
	/* 启用多行文本显示 */
	TextLayer_Multiline( &label->layer, TRUE );
	Widget_AutoSize( widget, FALSE, 0 );
	/* 启用样式标签的支持 */
	TextLayer_Using_StyleTags( &label->layer, TRUE );
}