|
@@ -686,41 +686,6 @@ var sheetCommonObj = {
|
|
|
//sheet.setCellType(row, col,this.getSelectButton(header.headerWidth),GC.Spread.Sheets.SheetArea.viewport);
|
|
|
},
|
|
|
|
|
|
- paintCusButtonImage:function(ctx, value, x, y, w, h, style, options){
|
|
|
- if (options.sheet.getActiveRowIndex() == options.row && options.sheet.getActiveColumnIndex() == options.col) {
|
|
|
- var image = document.getElementById('f_btn'), imageMagin = 3;
|
|
|
- var imageHeight = 15;
|
|
|
- var imageWidth = 25;
|
|
|
- var imageX = x + w - imageWidth - imageMagin, imageY = y + h / 2 - imageHeight / 2;
|
|
|
- ctx.save();
|
|
|
- /* 2020-12-16 这里原先是还原背景色的,发现不需要了,先观察
|
|
|
- if (style.backColor) {
|
|
|
- ctx.fillStyle = style.backColor;
|
|
|
- ctx.fillRect(x, y, w, h);
|
|
|
- }
|
|
|
- */
|
|
|
- ctx.drawImage(image, imageX, imageY, imageWidth, imageHeight);
|
|
|
- ctx.beginPath();
|
|
|
- ctx.arc(imageX + imageWidth / 2, imageY + imageHeight / 2, 1, 0, 360, false);
|
|
|
- ctx.arc(imageX + imageWidth / 2 - 4, imageY + imageHeight / 2, 1, 0, 360, false);
|
|
|
- ctx.arc(imageX + imageWidth / 2 + 4, imageY + imageHeight / 2, 1, 0, 360, false);
|
|
|
- ctx.fillStyle = "black";//填充颜色,默认是黑色
|
|
|
- ctx.fill();//画实心圆
|
|
|
- ctx.closePath();
|
|
|
- ctx.restore();
|
|
|
- w = w - imageWidth - imageMagin;
|
|
|
- //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
|
|
|
- if (style.hAlign == 0) {
|
|
|
- if (value) {
|
|
|
- let textWidth = ctx.measureText(value).width;
|
|
|
- let spaceWidth = w;
|
|
|
- if (spaceWidth < textWidth) {
|
|
|
- style.hAlign = 2;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
getCusButtonCellType: function (callback, readOnly = false, ostyle) {
|
|
|
var ns = GC.Spread.Sheets;
|
|
|
|
|
@@ -730,7 +695,39 @@ var sheetCommonObj = {
|
|
|
CusButtonCellType.prototype = new ns.CellTypes.Text();
|
|
|
CusButtonCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
|
|
|
if (!readOnly) {
|
|
|
- sheetCommonObj.paintCusButtonImage(ctx, value, x, y, w, h, style, options);
|
|
|
+ if (options.sheet.getActiveRowIndex() == options.row && options.sheet.getActiveColumnIndex() == options.col) {
|
|
|
+ var image = document.getElementById('f_btn'), imageMagin = 3;
|
|
|
+ var imageHeight = 15;
|
|
|
+ var imageWidth = 25;
|
|
|
+ var imageX = x + w - imageWidth - imageMagin, imageY = y + h / 2 - imageHeight / 2;
|
|
|
+ ctx.save();
|
|
|
+ /* 2020-12-16 这里原先是还原背景色的,发现不需要了,先观察
|
|
|
+ if (style.backColor) {
|
|
|
+ ctx.fillStyle = style.backColor;
|
|
|
+ ctx.fillRect(x, y, w, h);
|
|
|
+ }
|
|
|
+ */
|
|
|
+ ctx.drawImage(image, imageX, imageY, imageWidth, imageHeight);
|
|
|
+ ctx.beginPath();
|
|
|
+ ctx.arc(imageX + imageWidth / 2, imageY + imageHeight / 2, 1, 0, 360, false);
|
|
|
+ ctx.arc(imageX + imageWidth / 2 - 4, imageY + imageHeight / 2, 1, 0, 360, false);
|
|
|
+ ctx.arc(imageX + imageWidth / 2 + 4, imageY + imageHeight / 2, 1, 0, 360, false);
|
|
|
+ ctx.fillStyle = "black";//填充颜色,默认是黑色
|
|
|
+ ctx.fill();//画实心圆
|
|
|
+ ctx.closePath();
|
|
|
+ ctx.restore();
|
|
|
+ w = w - imageWidth - imageMagin;
|
|
|
+ //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
|
|
|
+ if (style.hAlign == 0) {
|
|
|
+ if (value) {
|
|
|
+ let textWidth = ctx.measureText(value).width;
|
|
|
+ let spaceWidth = w;
|
|
|
+ if (spaceWidth < textWidth) {
|
|
|
+ style.hAlign = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (ostyle) gljUtil.setProperty(style, ostyle);
|
|
|
GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
|