x.js 4.53 KB
Newer Older
Scott Sun's avatar
Scott Sun committed
1
ar plugin = require('topsin.gengui');
Scott Sun's avatar
Scott Sun committed
2

Scott Sun's avatar
s  
Scott Sun committed
3
var gui = plugin.newGui(plugin.__dirname);
Scott Sun's avatar
Scott Sun committed
4

Scott Sun's avatar
s  
Scott Sun committed
5 6 7 8 9
function gen() {
    this.PAUSE = function () {
        console.log("pause");
    }
}
Scott Sun's avatar
Scott Sun committed
10

Scott Sun's avatar
Scott Sun committed
11
gui.setLang("zhcn"); // zhcn, zhtw, en
Scott Sun's avatar
Scott Sun committed
12

Scott Sun's avatar
Scott Sun committed
13
r = gui.showForm({
Scott Sun's avatar
s  
Scott Sun committed
14 15
    title: "注册账号",
    size: [600, 400],
Scott Sun's avatar
Scott Sun committed
16
    ui: [{
Scott Sun's avatar
Scott Sun committed
17
        type: 'ScrollArea',
Scott Sun's avatar
Scott Sun committed
18
        property: { widget_resizable: true, frame_shape: 'NoFrame', align: 'Top' },
Scott Sun's avatar
Scott Sun committed
19 20
        child: {
            type: 'VBoxLayout',
Scott Sun's avatar
Scott Sun committed
21 22 23 24 25 26 27 28 29 30 31 32 33
            property: { margin: 2, spacing: 20, align: 'Top' },
            pack: { stretch: 0 },
            child: [
                {
                    type: "FormGridLayout",
                    property: { columns: 1, label_alignment: 'Top | Right', margin: 10, spacing: 20 },
                    pack: { stretch: 0 },
                    child: [
                        {
                            name: 'username',
                            type: 'LineEdit',
                            pack: { label: "用户名" },
                            property: { enabled: true }
Scott Sun's avatar
Scott Sun committed
34
                        },
Scott Sun's avatar
Scott Sun committed
35 36 37 38 39
                        {
                            name: 'password',
                            type: 'LineEdit',
                            pack: { label: "密码" },
                            property: { echo_mode: "password" }
Scott Sun's avatar
Scott Sun committed
40
                        },
Scott Sun's avatar
Scott Sun committed
41 42 43 44 45 46 47 48 49 50 51
                        {
                            name: 'sex',
                            type: 'ComboBox',
                            property: {
                                enabled: true, item_list: [
                                    { name: "male", icon: "male", text: "男", text_zhcn: "男", text_zhtw: "男" },
                                    { name: "female", icon: "female", text: "女", text_zhcn: "女", text_zhtw: "女" },
                                    { name: "hideyoshi", icon: "circle-thin", text: "Hideyoshi", text_zhcn: "秀吉", text_tw: "秀吉" }
                                ]
                            },
                            pack: { label: '性别' }
Scott Sun's avatar
Scott Sun committed
52
                        },
Scott Sun's avatar
Scott Sun committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
                        {
                            name: 'table',
                            type: 'TableView',
                            property: {},
                            pack: { label: '性别' },
                            initCallback: function (obj, self) {
                                obj.setHeaderItem(
                                    [
                                        {},
                                        { name: 'analysis_item', display: 'Analysis Item', resizeMode: 'ResizeToContents', displayRole: '$analysis_item' },
                                        { name: 'analysis_result', display: 'Analysis Result', resizeMode: 'ResizeToContents', displayRole: '$analysis_result' },
                                        { name: 'result', display: 'Result', resizeMode: 'ResizeToContents', displayRole: '$result' },
                                        { name: 'standard', display: 'Standard', resizeMode: 'ResizeToContents', displayRole: '$standard' },
                                        { name: 'remark', display: 'Remark', resizeMode: 'ResizeToContents', displayRole: '$remark', editRole: '$remark', flagsRole: 'ItemIsEditable|ItemIsEnabled|ItemIsSelectable' }
                                    ]
                                );
                                obj.setDataKeyList(["id", "analysis_item", "analysis_result", "result", "standard", "remark"]);
                                obj.setPrimaryKey("id");
                            },
                            setter: function (obj, value, self) {
                                if (value != null) {
                                    obj.loadData(value);
                                } else {
                                    obj.clearData();
                                }
                            }
Scott Sun's avatar
Scott Sun committed
79
                        }
Scott Sun's avatar
Scott Sun committed
80 81 82
                    ]
                }
            ]
Scott Sun's avatar
Scott Sun committed
83
        }
Scott Sun's avatar
Scott Sun committed
84
    }],
Scott Sun's avatar
s  
Scott Sun committed
85 86 87 88 89
    data: {
        username: "elder",
        password: "nαive!",
        sex: "male"
    },
Scott Sun's avatar
Scott Sun committed
90
    includehide: false,
Scott Sun's avatar
Scott Sun committed
91 92
    buttons: [
        {
Scott Sun's avatar
s  
Scott Sun committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
            stock: "ok",
            sensitive: true,
            command: function (data) {

            }
        },
        {
            stock: "cancel",
            sensitive: true,
            command: function (ddata) {

            }
        },
        {
            stock: "help",
            sensitive: true,
            command: function (data) {
                console.log(data);
            }
        }
    ],
Scott Sun's avatar
Scott Sun committed
114
    hook: function (data) { },
Scott Sun's avatar
s  
Scott Sun committed
115
    gen: new gen()
Scott Sun's avatar
Scott Sun committed
116
});
Scott Sun's avatar
Scott Sun committed
117

Scott Sun's avatar
Scott Sun committed
118
console.log(r);