/** * 单选按钮组 * * Created by GUY on 2015/9/7. * @class BI.Segment * @extends BI.Widget */ BI.Segment = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.Segment.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-segment", items: [], height: 24 }); }, _init: function () { BI.Segment.superclass._init.apply(this, arguments); var self = this, o = this.options; this.buttonGroup = BI.createWidget({ element: this, type: "bi.button_group", value: o.value, items: BI.createItems(o.items, { type: "bi.segment_button", height: o.height - 2, whiteSpace: o.whiteSpace }), layout: [ { type: "bi.center" } ] }); this.buttonGroup.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); this.buttonGroup.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { self.fireEvent(BI.Segment.EVENT_CHANGE, value, obj); }); }, setValue: function (v) { this.buttonGroup.setValue(v); }, setEnabledValue: function (v) { this.buttonGroup.setEnabledValue(v); }, getValue: function () { return this.buttonGroup.getValue(); } }); BI.Segment.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.segment", BI.Segment);