Exemplo n.º 1
0
//画list
//listbox:listbox指针
void listbox_draw_list(_listbox_obj *listbox)
{
	u16 i;
	u16 endx=0;
	u16 tempcolor;	  
 	_listbox_list * listx;		   
 	endx=listbox->left+listbox->width-1; //条目显示结束x坐标
	if(listbox->scbv->totalitems>listbox->scbv->itemsperpage)endx-=LBOX_SCB_WIDTH;//需要滚动条了.
	gui_fill_rectangle(listbox->left,listbox->top,endx-listbox->left+1,listbox->height,listbox->lbkcolor);//清空为底色.	
	listx=list_search(listbox->list,listbox->scbv->topitem);//得到顶部list信息(curitem在listbox中用于记录顶部index)
	for(i=0;i<listbox->scbv->itemsperpage;i++)//显示条目
	{	
		if((listbox->scbv->topitem+i)==listbox->selindex)//此项为选中项目
		{
			gui_fill_rectangle(listbox->left,listbox->top+i*gui_phy.listheight,endx-listbox->left+1,gui_phy.listheight,listbox->lnselbkcolor);//填充底色
			listbox->fname=listx->name;//获得当前选中的条目的名字
			listbox->namelen=strlen((const char*)listbox->fname)*listbox->font/2;//名字的总长度
			listbox->curnamepos=0;
			tempcolor=listbox->lnselcolor;
		}else tempcolor=listbox->lncolor;																						    
		gui_show_ptstr(listbox->left,listbox->top+i*gui_phy.listheight+(gui_phy.listheight-listbox->font)/2,endx,gui_phy.lcdheight,0,tempcolor,listbox->font,listx->name,1);
		if(listx->nextlist==0)break;
		listx=listx->nextlist;
 	}
}
Exemplo n.º 2
0
//画出窗口
//windowx:窗口指针
void window_draw(_window_obj *windowx)
{
    u8 winclosebtnsize = 0;	//关闭按钮的尺寸
    if(windowx == NULL) {
        return;    //无效,直接退出
    }
    if(windowx->type & (1 << 0)) { //圆角窗,仿android的时候,不支持按钮(放了难看)
        gui_draw_arcrectangle(windowx->left, windowx->top, windowx->width, windowx->captionheight, windowx->arcwinr, 1, windowx->captionbkcu, windowx->captionbkcd);									//画出标题栏
        gui_fill_rectangle(windowx->left, windowx->top + windowx->captionheight - windowx->arcwinr, windowx->arcwinr, windowx->arcwinr, windowx->captionbkcd);											//把下部分不需要的半圆形的部分填充掉1
        gui_fill_rectangle(windowx->left + windowx->width - windowx->arcwinr, windowx->top + windowx->captionheight - windowx->arcwinr, windowx->arcwinr, windowx->arcwinr, windowx->captionbkcd);			//把下部分不需要的半圆形的部分填充掉2

        gui_draw_arcrectangle(windowx->left, windowx->top + windowx->captionheight, windowx->width, windowx->height - windowx->captionheight, windowx->arcwinr, 1, windowx->windowbkc, windowx->windowbkc); //填充空白部分
        gui_fill_rectangle(windowx->left, windowx->top + windowx->captionheight, windowx->arcwinr, windowx->arcwinr, windowx->windowbkc);																//把上部分不需要的半圆形的部分填充掉1
        gui_fill_rectangle(windowx->left + windowx->width - windowx->arcwinr, windowx->top + windowx->captionheight, windowx->arcwinr, windowx->arcwinr, windowx->windowbkc);								//把上部分不需要的半圆形的部分填充掉2
        gui_draw_arcrectangle(windowx->left, windowx->top, windowx->width, windowx->height, windowx->arcwinr, 0, ARC_WIN_RIM_COLOR, ARC_WIN_RIM_COLOR); //画边框										//画出标题栏
    } else {	//方角窗
        //填充内部
        gui_fill_rectangle(windowx->left, windowx->top, windowx->width, windowx->captionheight / 2, windowx->captionbkcu); //填充上半部分
        gui_fill_rectangle(windowx->left, windowx->top + windowx->captionheight / 2, windowx->width, windowx->captionheight / 2, windowx->captionbkcd); //填充下半部分
        gui_fill_rectangle(windowx->left, windowx->top + windowx->captionheight - 1, windowx->width, windowx->height - windowx->captionheight, windowx->windowbkc); //填充内部
        //画边框
        gui_draw_rectangle(windowx->left, windowx->top, windowx->width, windowx->height, STD_WIN_RIM_OUTC); //画外框
        gui_draw_rectangle(windowx->left + 1, windowx->top + 1, windowx->width - 2, windowx->height - 2, STD_WIN_RIM_MIDC); //画中间框
        gui_draw_rectangle(windowx->left + 2, windowx->top + windowx->captionheight - 1, windowx->width - 4, windowx->height - windowx->captionheight - 1, STD_WIN_RIM_INC); //画内框
        if(windowx->type & (1 << 7)) {
            btn_draw(windowx->closebtn);//有按钮的时候需要画按钮.
            winclosebtnsize = WIN_BTN_SIZE;
        }
    }
    if(windowx->type & (1 << 5)) {
        gui_show_strmid(windowx->left, windowx->top, windowx->width, windowx->captionheight, windowx->captioncolor, windowx->font, windowx->caption);    //显示标题
    } else {
        gui_show_ptstr(windowx->left + WIN_BTN_OFFSIDE, windowx->top + (windowx->captionheight - windowx->font) / 2, windowx->left + windowx->width - 2 * WIN_BTN_OFFSIDE - winclosebtnsize, windowx->top + windowx->captionheight, 0, windowx->captioncolor, windowx->font, windowx->caption, 1);    //靠左显示caption
    }
}
Exemplo n.º 3
0
//检查	
//listbox:listbox指针
//in_key:输入按键指针
//返回值:未用到				   
u8 listbox_check(_listbox_obj * listbox,void * in_key)
{
	_in_obj *key=(_in_obj*)in_key;
	_listbox_list * listx;
	u16 endx;//条目显示区的尾端.	
	u16 tempindex;
	u16 i;	   
	u16 lastindex; 
	static u8 scrollbarflag=0;//scrollbar标记
	switch(key->intype)
	{
		case IN_TYPE_TOUCH:	//触摸屏按下了
 			if(listbox!=NULL)//listbox非空
			{
				endx=listbox->left+listbox->width-1;		  
				if(listbox->scbv->totalitems>listbox->scbv->itemsperpage)//有滚动条
				{ 
					endx-=LBOX_SCB_WIDTH;
					if(listbox->top<=key->y&&key->y<=(listbox->top+listbox->height)&&listbox->left<=key->x&&key->x<=(endx+LBOX_SCB_WIDTH))//在有效区域内(SCB+条目区域)
					{
						//在滚动条范围之内.
						if((listbox->top<=key->y&&key->y<=(listbox->top+listbox->height)&&endx<=key->x&&key->x<=(endx+LBOX_SCB_WIDTH))||scrollbarflag==1)
						{
							if(listbox->sta&(1<<6))break;		//是从list区划过来的,直接不执行
							scrollbarflag=1;					//标记scrollbar模式
							tempindex=listbox->scbv->topitem;
							key->x=listbox->scbv->left+1;		//强制让x坐标在scrollbar里面
							scrollbar_check(listbox->scbv,in_key);//滚动条检测
							if(tempindex!=listbox->scbv->topitem)listbox_draw_list(listbox);
							listbox->sta|=1<<7;
							break;
						}
					}else scrollbarflag=0;
					if((listbox->sta&0xc0)==(1<<7))//上次操作仅仅是在滚动条区域内
					{
						listbox->sta=0;
						scrollbar_check(listbox->scbv,in_key);//滚动条检测					
					} 
				}
				tempindex=listbox->sta&0x3f;//得到当前sta种的位置
				if(listbox->top<=key->y&&key->y<=(listbox->top+listbox->height)&&listbox->left<=key->x&&key->x<(endx))//在items区域内
				{
					//itemperpage最大不能超过64!(按20一个index设计,这样64个list可以支持到64*20=1280垂直像素的屏)
					for(i=0;i<listbox->scbv->itemsperpage;i++)//找到当前触屏按下的坐标在listbox种的index
					{
						if(key->y<=(listbox->top+(i+1)*gui_phy.listheight)&&key->y>=(listbox->top+i*gui_phy.listheight))break;
					}
					if((listbox->sta&(1<<6))==0)//编号还无效
					{
						listbox->sta|=1<<6;	//标记有效
						listbox->sta|=i;	//记录编号
					}else if((listbox->sta&(1<<7))==0)//还不是滑动
					{
						if(listbox->scbv->totalitems<=listbox->scbv->itemsperpage)break;//没滚动条,滑动无效
						if(gui_disabs(i,(listbox->sta&0x3f))>1)	listbox->sta|=1<<7;//滑动距离大于1个条目的间隙 标记滑动
					}
					if((listbox->sta&0xc0)==0xc0)//是滑动
					{
						lastindex=listbox->scbv->topitem; 
						if(tempindex>i)//减少了
						{
							listbox->sta&=0xc0;//清空上次的
							listbox->sta|=i;//记录最近的index号	    
							listbox->scbv->topitem+=tempindex-i;    
							if(listbox->scbv->topitem>=(listbox->scbv->totalitems-listbox->scbv->itemsperpage))listbox->scbv->topitem=listbox->scbv->totalitems-listbox->scbv->itemsperpage;
						}else if(i>tempindex)//增加了
						{
							listbox->sta&=0xc0;//清空上次的
							listbox->sta|=i;//记录最近的index号
							i-=tempindex;				  
							if(listbox->scbv->topitem>=i)listbox->scbv->topitem-=i;
							else listbox->scbv->topitem=0;						
 						}else break;
						if(listbox->scbv->topitem!=lastindex)listbox_draw_listbox(listbox);//重画listbox
					}
				}else //按键松开了,或者滑出了
				{
					if(listbox->sta&(1<<7))//滑动
					{
						listbox->sta=0;										 
						listbox->oldtime=GUI_TIMER_10MS;//记录当前时间
						listbox->curnamepos=0;//清零
					}else if(listbox->sta&(1<<6))//单点按下
					{
						listbox->dbclick=0;			//双击标记清零
						if((listbox->scbv->topitem+tempindex)==listbox->selindex)
						{
							listbox->dbclick|=1<<7;	//标记双击了
							listbox_2click_hook(listbox);//执行双击钩子函数
						}else if((listbox->scbv->topitem+tempindex)<listbox->scbv->totalitems) //重新选择新的选项
						{		 
							if((listbox->selindex<(listbox->scbv->topitem+listbox->scbv->itemsperpage))&&(listbox->selindex>=listbox->scbv->topitem))//老的selindex在屏幕范围内
							{
								i=listbox->selindex-listbox->scbv->topitem;//老编号
								listx=list_search(listbox->list,listbox->selindex);//得到listindex的名字
								gui_fill_rectangle(listbox->left,listbox->top+i*gui_phy.listheight,endx-listbox->left+1,gui_phy.listheight,listbox->lbkcolor);//恢复底色
								gui_show_ptstr(listbox->left,listbox->top+i*gui_phy.listheight+(gui_phy.listheight-listbox->font)/2,endx,gui_phy.lcdheight,0,listbox->lncolor,listbox->font,listx->name,1);//显示名字
							}
							listbox->selindex=listbox->scbv->topitem+tempindex; 
							listx=list_search(listbox->list,listbox->selindex);//得到listindex的名字
							gui_fill_rectangle(listbox->left,listbox->top+tempindex*gui_phy.listheight,endx-listbox->left+1,gui_phy.listheight,listbox->lnselbkcolor);//填充选中后的底色
							gui_show_ptstr(listbox->left,listbox->top+tempindex*gui_phy.listheight+(gui_phy.listheight-listbox->font)/2,endx,gui_phy.lcdheight,0,listbox->lnselcolor,listbox->font,listx->name,1);//显示名字
							listbox->fname=listx->name;//获得当前选中的条目的名字
							listbox->namelen=strlen((const char*)listbox->fname)*listbox->font/2;//名字的总长度
						}
						listbox->sta=0;	  
 						listbox->oldtime=GUI_TIMER_10MS;//记录当前时间
						listbox->curnamepos=0;
					}else
					{
						if(gui_disabs(listbox->oldtime,GUI_TIMER_10MS)>=5)//超过50ms了.
						{	  
							if(listbox->selindex>=listbox->scbv->topitem&&listbox->selindex<(listbox->scbv->topitem+listbox->scbv->itemsperpage))//选中条目在当前的显示范围内
	 						{	 
								i=endx-listbox->left;//得到显示文字区域的长度
								if(i<listbox->namelen)//小于文字长度,就是不能够一次显示的
								{
 		 							tempindex=listbox->selindex-listbox->scbv->topitem;
									gui_fill_rectangle(listbox->left,listbox->top+tempindex*gui_phy.listheight,endx-listbox->left+1,gui_phy.listheight,listbox->lnselbkcolor);//填充选中后的底色
		 							gui_show_ptstr(listbox->left,listbox->top+tempindex*gui_phy.listheight+(gui_phy.listheight-listbox->font)/2,endx,gui_phy.lcdheight,listbox->curnamepos,listbox->lnselcolor,listbox->font,listbox->fname,1);//显示名字
									listbox->curnamepos++;
									if(listbox->curnamepos+i>listbox->namelen+i/4)listbox->curnamepos=0;//循环显示	
								}
							} 
							listbox->oldtime=GUI_TIMER_10MS;//记录当前时间
						}
					}
				}
			}
 			break;
		case IN_TYPE_KEY:	//按键数据
			break;
		case IN_TYPE_JOYPAD://手柄数据
			break;
		case IN_TYPE_MOUSE:	//鼠标数据
			break;
		default:
			break;
	}
	return 0;
}