//u16 itot,u16 ipg, void test_scb(u16 x, u16 y, u16 width, u16 height, u8 type, u16 icur, u16 inbkcolor, u16 btncolor, u16 rimcolor) { _scrollbar_obj *tscb; tscb = scrollbar_creat(y, x, width, height, type); //创建滚动条 if(tscb == NULL) { return; //创建失败. } tscb->totalitems = 50; tscb->itemsperpage = 8; tscb->topitem = icur; tscb->inbkcolor = inbkcolor; tscb->btncolor = btncolor; tscb->rimcolor = rimcolor; scrollbar_draw_scrollbar(tscb);//画按钮 scrollbar_delete(tscb);//删除按钮 }
//创建listbox //top,left,width,height:坐标.及尺寸. //width的范围:必须大于等于LBOX_ITEM_HEIGHT //height的范围:必须是LBOX_ITEM_HEIGHT的整数倍. //type:bit7,用于是否显示滚动条,其他位保留. //font:字体类型 12/16表示字体为12*12或者16*16. _listbox_obj * listbox_creat(u16 left,u16 top,u16 width,u16 height,u8 type,u8 font) { _listbox_obj * listbox_crt; _scrollbar_obj * scb_crt; if(height%gui_phy.listheight)return NULL;//尺寸不合格 if(height<gui_phy.listheight||width<gui_phy.listheight)return NULL; //尺寸不合格 listbox_crt=(_listbox_obj*)gui_memin_malloc(sizeof(_listbox_obj));//分配内存 if(listbox_crt==NULL)return NULL; //内存分配不够. scb_crt=scrollbar_creat(left+width-LBOX_SCB_WIDTH,top,LBOX_SCB_WIDTH,height,0x80);//创建scrollbar. if(scb_crt==NULL)//内存分配不够. { gui_memin_free(listbox_crt); return NULL; } scb_crt->itemsperpage=height/gui_phy.listheight; //每页显示的条目数 listbox_crt->top=top; listbox_crt->left=left; listbox_crt->width=width; listbox_crt->height=height; listbox_crt->type=type; //类型 listbox_crt->sta=0; listbox_crt->id=0; listbox_crt->dbclick=0; //双击标志清零 listbox_crt->font=font; //字体大小 listbox_crt->selindex=0; //当前选中的索引 listbox_crt->lbkcolor=LBOX_DFT_LBKCOLOR; //内部背景色 listbox_crt->lnselcolor=LBOX_DFT_LSELCOLOR; //选中list后的字体颜色 listbox_crt->lnselbkcolor=LBOX_DFT_LSELBKCOLOR; //选中list后的背景色 listbox_crt->lncolor=LBOX_DFT_LNCOLOR; //未选中的list字体颜色 listbox_crt->rimcolor=LBOX_DFT_RIMCOLOR; //边框颜色 listbox_crt->fname=NULL; //名字为空 listbox_crt->namelen=0; //长度清零 listbox_crt->curnamepos=0; //当前位置清零 listbox_crt->oldtime=0; //时间清零 listbox_crt->scbv=scb_crt; //滚动条 listbox_crt->list=NULL; //无链表 return listbox_crt; }