|
@@ -1067,7 +1067,6 @@ const SpreadJsObj = {
|
|
|
*/
|
|
|
getImageButtonCellType: function () {
|
|
|
let hover = 1, active = 2;
|
|
|
- const indent = 10;
|
|
|
const ImageCellType = function (){};
|
|
|
ImageCellType.prototype = new spreadNS.CellTypes.Text();
|
|
|
const proto = ImageCellType.prototype;
|
|
@@ -1091,22 +1090,40 @@ const SpreadJsObj = {
|
|
|
};
|
|
|
proto.paint = function (canvas, value, x, y, w, h, style, options) {
|
|
|
const img = this.getImage(options.sheet, options.row, options.col);
|
|
|
- if (img) {
|
|
|
- if (style.backColor) {
|
|
|
- canvas.save();
|
|
|
- canvas.fillStyle = style.backColor;
|
|
|
- canvas.fillRect(x, y, indent + img.width, h);
|
|
|
- canvas.restore();
|
|
|
+ const col = options.sheet.zh_setting.cols[options.col];
|
|
|
+ const indent = col.indent ? col.indent : 10;
|
|
|
+ if (style.hAlign === spreadNS.HorizontalAlign.right) {
|
|
|
+ if (img) {
|
|
|
+ if (style.backColor) {
|
|
|
+ canvas.save();
|
|
|
+ canvas.fillStyle = style.backColor;
|
|
|
+ canvas.fillRect(x + w - indent - img.width, y, img.width, h);
|
|
|
+ canvas.restore();
|
|
|
+ }
|
|
|
+ canvas.drawImage(img, x + w - indent - img.width, y + (h - img.height) / 2);
|
|
|
+ w = w - indent - img.width;
|
|
|
}
|
|
|
- canvas.drawImage(img, x + 10, y + (h - img.height) / 2);
|
|
|
- if (style.hAlign !== spreadNS.HorizontalAlign.left) {
|
|
|
- style.hAlign = spreadNS.HorizontalAlign.left;
|
|
|
+ // Drawing Text
|
|
|
+ spreadNS.CellTypes.Text.prototype.paint.apply(this, [canvas, value, x, y, w, h, style, options]);
|
|
|
+ } else {
|
|
|
+ if (img) {
|
|
|
+ if (style.backColor) {
|
|
|
+ canvas.save();
|
|
|
+ canvas.fillStyle = style.backColor;
|
|
|
+ canvas.fillRect(x, y, indent + img.width, h);
|
|
|
+ canvas.restore();
|
|
|
+ }
|
|
|
+ canvas.drawImage(img, x + 10, y + (h - img.height) / 2);
|
|
|
+ if (style.hAlign !== spreadNS.HorizontalAlign.left) {
|
|
|
+ style.hAlign = spreadNS.HorizontalAlign.left;
|
|
|
+ }
|
|
|
+ x = x + indent + img.width;
|
|
|
+ w = w - indent - img.width;
|
|
|
}
|
|
|
- x = x + indent + img.width;
|
|
|
- w = w - indent - img.width;
|
|
|
+ // Drawing Text
|
|
|
+ spreadNS.CellTypes.Text.prototype.paint.apply(this, [canvas, value, x, y, w, h, style, options]);
|
|
|
}
|
|
|
- // Drawing Text
|
|
|
- spreadNS.CellTypes.Text.prototype.paint.apply(this, [canvas, value, x, y, w, h, style, options]);
|
|
|
+
|
|
|
};
|
|
|
/**
|
|
|
* 获取点击信息
|