var plugin = require('topsin.gengui');
var gui = plugin.newGui(plugin.__dirname);

var headers = [
  {},
  { 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' }
];
var item_list =  [
    { name: "male", icon: "male", text: "男", text_zhcn: "男", text_zhtw: "男" },
    { name: "female", icon: "female", text: "女", text_zhcn: "女", text_zhtw: "女" },
  ];
r = gui.showForm({
  title: "BUG#10475",
  size: '600x400',
  items: {
    type: 'ScrollArea',
    property: { widget_resizable: true, frame_shape: 'NoFrame', align: 'Top' },
    child: {
      type: 'VBoxLayout',
      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 }
            },
            {
              name: 'password',
              type: 'LineEdit',
              pack: { label: "密码" },
              property: { echo_mode: "password" }
            },
            {
              name: 'sex',
              type: 'ComboBox',
              property: {
                enabled: true, item_list:item_list
              },
              pack: { label: '性别' }
            },
            {
              name: 'table',
              type: 'TableView',
              property: {},
              pack: { label: '性别' },
              initCallback: function (obj, self) {
                obj.setHeaderItem(headers);
                obj.setDataKeyList(["id", "analysis_item", "analysis_result", "result", "standard", "remark"]);
                obj.setPrimaryKey("id");
              }
            }
          ]
        }
      ]
    }
  }
});

print(JSON.stringify(r, null, '  '));
