import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=849;bottom=578;border="thin")
mainForm.add(
vlist={cls="vlistEx";left=10;top=10;right=840;bottom=570;db=1;dl=1;dr=1;dt=1;edge=1;transparent=1;z=1}
)
/*}}*/
import inet.http
import godking.paint
var img = inet.http.get("https://hbimg.huaban.com/5474bb263043fd356007ccf2812b15299bf5a09924821-HT7Aen_fw658");
var bmps = godking.paint.splitImage(img,3,3,10,10,10,10);
var t = {fields={"序号","姓名","年龄","地址","身份证"}};
for(i=1;100;1){
var tt={};
tt["序号"]="[@rowindex]"; // 行序号标记是不允许编辑修改的
tt["姓名"]=math.random(1000,9999)+"姓名";
tt["年龄"]=math.random(10,99);
tt["地址"]=math.random(1000,9999)+"地址";
tt["身份证"]=math.random(1000,9999)+"身份证";
tt["头像"]=bmps[math.random(1,9)];
..table.push(t,tt);
}
mainForm.vlist.setTable(t,,100,1);
mainForm.vlist.setHeaderHeight(50);
mainForm.vlist.headerAlign = 1;
mainForm.vlist.setRowHeight(100);
mainForm.vlist.fillParent();
mainForm.vlist.textColor = 0x0000FF;
mainForm.vlist.selectedTextColor = 0xFF0000;
mainForm.vlist.onDrawCellBg = function(row,col,hdc,rect,bkcolor,text){
if col===2 {
..gdi.fillRect(hdc,0xFFFFFF,rect);
return true;
}
}
/***
mainForm.vlist.onDrawCellRect = function(row,col,hdc,rect,bkcolor,text,font,colalign){
if col===2 {
font.color = ..gdi.argbReverse(font.color);
var p = godking.paint.fromHdc(hdc);
p.drawImage(rect.left+10,rect.top,rect.right-10,rect.bottom-30,mainForm.vlist.getRowData(row).头像,,true);
p.drawText(rect.left,rect.bottom-30,rect.right,rect.bottom,text,font,0,1,0);
p.close()
return true;
}
}
***/
mainForm.vlist.onDrawCellRect = function(row,col,hdc,rect,bkcolor,text,font,colalign){
if col===2 {
var p = godking.paint.fromHdc(hdc);
p.drawImage(rect.left+20,rect.top+20,rect.right-20,rect.bottom-30,mainForm.vlist.getRowData(row).头像,,true);
p.close();
rect.top = rect.bottom-30;
..gdi.drawTextCenter(hdc,font,text,rect);
return true;
}
}
mainForm.show();
win.loopMessage();