import win.ui;
import console;
/*DSG{{*/
var winform = win.form(text="批量生成按钮实例";right=759;bottom=469)
winform.add(
custom={cls="custom";text="自定义控件";left=10;top=10;right=749;bottom=455;z=1}
)
/*}}*/
//aardio批量生成按钮实例
import win.ui.css;
var css =win.ui.css();
import godking.message;
//做3个按钮,第1个,右1,下1
//得到第一个按钮位置,左右上下间距
left,right,top,bottom = 58,178,36,88
toRight = 130
toBottom = 72
rows,cols = 5,5
buttonTab = {}; //批量生成位置
for(i=1;rows;1){ //行
for(j=1;cols;1){ //列
table.push(buttonTab,{
left+(j-1)*toRight,right+(j-1)*toRight,
top+(i-1)*toBottom,bottom+(i-1)*toBottom
})
}
}
//console.dump(buttonTab)
for(i=1;rows*cols;1){ //动态生成控件
left,right,top,bottom = table.unpack(buttonTab[i]);
//winform.add(
winform.custom.addCtrl(
['button'+i]={cls="plus";text="按钮"++i;
left=left;top=top;right=right;
bottom=bottom;z=1};
)
winform.custom["button"+i].border={radius=30}; //顺序
winform.custom["button"+i].skin(css.primary); //css
winform.custom['button'+i].oncommand = function(id,event){
winform.msgOk(owner.text)
}
}
winform.show();
win.loopMessage();