Exemplo n.º 1
0
/*
	绘制一个按钮的弹起效果
*/
BUTTON* BUTTON_draw_release_effect(BUTTON* pButton)
{
	U16 fontWidth = FONT_get_string_width(pButton->content, FontFormat.fontType);				//获得字符串的宽度
	U16 fontHigh  = FONT_get_lib_info(FontFormat.fontType)->fontHigh;                           //获得字体的高度
	
	U32 oldColor; 		//旧颜色
	U32 oldBackColor;   //新颜色
	
	U16 xStart;
	U16 yStart;
	
	pButton->buttonWidth = fontWidth > pButton->buttonWidth ? fontWidth : pButton->buttonWidth;
	pButton->buttonHigh = fontHigh > pButton->buttonHigh ? fontHigh :pButton-> buttonHigh;
	
	//如果指定的位置导致按钮会被显示在屏幕外面,则不显示,并返回0
	if(pButton->xStart+pButton->buttonWidth > SCREEN_SIZE_X || pButton->yStart + pButton->buttonHigh > SCREEN_SIZE_Y)
		return null;
	
	LCD_draw_rectangle(pButton->xStart, pButton->yStart, 
						pButton->buttonWidth, 
							pButton->buttonHigh, 
								pButton->buttonColor);
	
	oldColor = LCD_set_font_color(pButton->fontColor);  				//设置新颜色,保存旧颜色
	oldBackColor = LCD_set_font_backColor(pButton->buttonColor);		//设置新背景色,保存旧背景色
	xStart = pButton->xStart + (pButton->buttonWidth - fontWidth)/2;    			//获得字体的x起始显示位置
	yStart = pButton->yStart + (pButton->buttonHigh - fontHigh)/2;				//获得字体的y起始显示位置
	
	LCD_printf(xStart, yStart, pButton->content);       //显示文字
	LCD_set_font_backColor(oldBackColor);				//恢复原来的字体背景色
	LCD_set_font_color(oldColor);                       //恢复原来的字体颜色
	
	return pButton;	
}
Exemplo n.º 2
0
/*
	只重新绘制一个Button,这个Button必须是曾经绘制会过的
*/
BUTTON* BUTTON_redraw_button(BUTTON *pButton)
{
	U16 fontWidth = FONT_get_string_width(pButton->content, FontFormat.fontType);				//获得字符串的宽度
	U16 fontHigh  = FONT_get_lib_info(FontFormat.fontType)->fontHigh;                           //获得字体的高度
	
	U32 oldColor; 		//旧颜色
	U32 oldBackColor;   //新颜色
	U16 xStart;
	U16 yStart;
	
	LCD_draw_rectangle(pButton->xStart, pButton->yStart, 
						pButton->buttonWidth, 
							pButton->buttonHigh, 
								pButton->buttonColor);
	
	oldColor = LCD_set_font_color(pButton->fontColor);  				//设置新颜色,保存旧颜色
	oldBackColor = LCD_set_font_backColor(pButton->buttonColor);		//设置新背景色,保存旧背景色
	
	xStart = pButton->xStart + (pButton->buttonWidth - fontWidth)/2;    			//获得字体的x起始显示位置
	yStart = pButton->yStart + (pButton->buttonHigh - fontHigh)/2;				//获得字体的y起始显示位置
	
	LCD_printf(xStart, yStart, pButton->content);       //显示文字
	LCD_set_font_backColor(oldBackColor);								//恢复原来的字体背景色
	LCD_set_font_color(oldColor);                       //恢复原来的字体颜色

	return pButton;										//返回这个按键
}
Exemplo n.º 3
0
int show_progress( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow )
{
#if 0
	char prstr[50];
	
	if(dltotal<spdsize[speed])
	{
		return 0;
	}
	
	LCD_draw_rectangle (7,7,111,17, LCD_PIXEL_ON,LCD_PIXEL_OFF);
	LCD_draw_fill_rect (7,7,(int)((dlnow/dltotal)*111.0),17,LCD_PIXEL_ON);
	sprintf(prstr,"%d%%",(int)(dlnow*100.0/dltotal));
	LCD_draw_Istring(45, 9, prstr);
	LCD_update();
#endif
	return 0;
}
Exemplo n.º 4
0
/*
	按照pButton描述的方式显示一个button
		在函数执行过程中,带入的按键的宽和高可能会被改变
			当文字要求的宽度或高度大于按钮提供的宽度或高度时,按钮的宽度或高度会增加到文字的宽度或高度
		在函数执行过程中,按键的xStart和yStart属性会被初始化
		如果函数成功的将按钮绘制到屏幕上,则同时将该按钮添加到按钮链表中
		函数可能会绘制按键失败:	按键的要求宽度或高度与其显示位置的综合使按钮显示在了屏幕之外.
*/
BUTTON* BUTTON_draw_button(U32 xStart, U32 yStart, BUTTON *pButton)
{
	U16 fontWidth = FONT_get_string_width(pButton->content, FontFormat.fontType);				//获得字符串的宽度
	U16 fontHigh  = FONT_get_lib_info(FontFormat.fontType)->fontHigh;                           //获得字体的高度
	
	U32 oldColor; 		//旧颜色
	U32 oldBackColor;   //新颜色

	pButton->xStart = xStart;
	pButton->yStart = yStart;
	//pButton->buttonWidth = fontWidth > pButton->buttonWidth ? fontWidth + 10: pButton->buttonWidth;
	//pButton->buttonHigh = fontHigh > pButton->buttonHigh ? fontHigh + 10:pButton-> buttonHigh;
	
	//如果指定的位置导致按钮会被显示在屏幕外面,则不显示,并返回0
	if(pButton->xStart+pButton->buttonWidth > SCREEN_SIZE_X || pButton->yStart + pButton->buttonHigh > SCREEN_SIZE_Y)
		return null;
	
	LCD_draw_rectangle(xStart, yStart, 
						pButton->buttonWidth, 
							pButton->buttonHigh, 
								pButton->buttonColor);
	
	oldColor = LCD_set_font_color(pButton->fontColor);  				//设置新颜色,保存旧颜色
	oldBackColor = LCD_set_font_backColor(pButton->buttonColor);		//设置新背景色,保存旧背景色
	
	xStart = xStart + (pButton->buttonWidth - fontWidth)/2;    			//获得字体的x起始显示位置
	yStart = yStart + (pButton->buttonHigh - fontHigh)/2;				//获得字体的y起始显示位置
	
	LCD_printf(xStart, yStart, pButton->content);       //显示文字
	LCD_set_font_backColor(oldBackColor);								//恢复原来的字体背景色
	LCD_set_font_color(oldColor);                       //恢复原来的字体颜色

	//如果显示成功,则将该按键加入到按键链表中
	if(PButtonList == null)
		BUTTON_init();
	
	BTNLIST_insert_button(pButton, PButtonList);
	
	return pButton;										//返回这个按键
}
Exemplo n.º 5
0
/******************************************************
* 函数名:Palette_draw_point
* 描述  :在LCD指定位置画一个大点(包含四个小点)
* 输入  : Xpos		--X方向位置
Ypos		--Y方向位置
* 输出  :无
* 举例  :Palette_draw_point(100,100);
* 注意  :该函数是 "触摸画板应用实例" 专用函数
*********************************************************/    
void Palette_draw_point(uint16_t Xpos,uint16_t Ypos)
{
    static u16 Pen_color=0;
    u16 Tmp_xpos = 240-Xpos;
    if(Ypos<40)
    {
        if(Tmp_xpos>30)
            Pen_color =(Tmp_xpos<60)?Green:(Tmp_xpos<90)?Blue:(Tmp_xpos<120)?Red:(Tmp_xpos<150)?Red:(Tmp_xpos<180)?Blue:(Tmp_xpos<210)?Black:(Tmp_xpos<240)?Red:Blue;
        else
        {
            LCD_draw_rectangle(0,40,240,280,White);
            return;
        }
    }
    else
    {
        
        LCD_Draw_ColorPoint(240-Xpos,Ypos,Pen_color);//中心点 
        LCD_Draw_ColorPoint(240-(Xpos+1),Ypos,Pen_color);
        LCD_Draw_ColorPoint(240-Xpos,Ypos+1,Pen_color);
        LCD_Draw_ColorPoint(240-(Xpos+1),Ypos+1,Pen_color);
    }	
}