虚表 —— 单元格图片文本竖向排版

光庆 7月前 677

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.setColumnType( 2,6/*_vlistEx_ColType_OwnerDraw*/ );
mainForm.vlist.ownerDraw = function (row,col,hdc,x,y,w,h,param){
        var p = godking.paint.fromHdc(hdc);
        p.drawImageF(x+10,y+10,w-20,h-30,mainForm.vlist.getRowData(row).头像,,true);
        var color = mainForm.vlist.selIndex===row?0xFF0000FF:0xFFFF0000;
	    p.drawTextF(x,y+h-20,w,20,param,::LOGFONT(name="宋体";h=12;color=color;brush=null),0/*格式*/,1/*水平*/,1/*垂直*/)
        p.close();
        return true;    
}
mainForm.show();
win.loopMessage();


最新回复 (1)
  • playboyeve 7月前
    0 引用 2
返回