|
@@ -366,7 +366,7 @@ var sheetCommonObj = {
|
|
|
|
|
|
},
|
|
|
setSelectButton(row,col,sheet,header){
|
|
|
- let getSelectButton = function (cellWidth=100) {
|
|
|
+ /* let getSelectButton = function (cellWidth=100) {
|
|
|
function moreButton() {
|
|
|
|
|
|
}
|
|
@@ -439,8 +439,84 @@ var sheetCommonObj = {
|
|
|
}
|
|
|
};
|
|
|
return new selectButton();
|
|
|
+ };*/
|
|
|
+ sheet.setCellType(row, col,this.getSelectButton(header.headerWidth),GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ },
|
|
|
+ getSelectButton(cellWidth=100){
|
|
|
+
|
|
|
+ function moreButton() {
|
|
|
+
|
|
|
+ }
|
|
|
+ moreButton.prototype = new GC.Spread.Sheets.CellTypes.Button();
|
|
|
+ moreButton.prototype.paint = function (ctx, value, x, y, w, h, style, options){
|
|
|
+ GC.Spread.Sheets.CellTypes.Button.prototype.paint.call(this, ctx, value, x, y, w, h, style, options);
|
|
|
+ ctx.font = '14px Calibri';
|
|
|
+ let buttonW = cellWidth/5;
|
|
|
+ let endX = x+w-2;
|
|
|
+ if(value){
|
|
|
+ let textWidth = ctx.measureText(value).width;
|
|
|
+ let spaceWidth = cellWidth - buttonW;
|
|
|
+ let textEndX = x+textWidth+2;
|
|
|
+ if(spaceWidth<textWidth){
|
|
|
+ for(let i = value.length-1;i>1;i--){
|
|
|
+ let newValue = value.substr(0,i);
|
|
|
+ let newTestWidth = ctx.measureText(newValue).width;
|
|
|
+ if(spaceWidth>newTestWidth){
|
|
|
+ value = newValue;
|
|
|
+ textEndX = x+newTestWidth+2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ctx.fillText(value,textEndX,y+h-6);
|
|
|
+ }
|
|
|
+
|
|
|
+ //画三个点
|
|
|
+ ctx.save();
|
|
|
+ ctx.beginPath();
|
|
|
+ ctx.arc(endX-buttonW/2,y+h/2,1,0,360,false);
|
|
|
+ ctx.arc(endX-buttonW/2-4,y+h/2,1,0,360,false);
|
|
|
+ ctx.arc(endX-buttonW/2+4,y+h/2,1,0,360,false);
|
|
|
+ ctx.fillStyle="black";//填充颜色,默认是黑色
|
|
|
+ ctx.fill();//画实心圆
|
|
|
+ ctx.closePath();
|
|
|
+ ctx.restore();
|
|
|
+ };
|
|
|
+
|
|
|
+ moreButton.prototype.processMouseLeave= function (hitinfo) {
|
|
|
+ let newCell = new selectButton();
|
|
|
+ hitinfo.sheet.setCellType(hitinfo.row, hitinfo.col, newCell, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ hitinfo.sheet.getCell(hitinfo.row, hitinfo.col).locked(false);
|
|
|
+ };
|
|
|
+
|
|
|
+ function selectButton() {
|
|
|
+ }
|
|
|
+
|
|
|
+ selectButton.prototype = new GC.Spread.Sheets.CellTypes.Text();
|
|
|
+
|
|
|
+ selectButton.prototype.paint = function (ctx, value, x, y, w, h, style, options){
|
|
|
+ GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this,arguments);
|
|
|
+ };
|
|
|
+ selectButton.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
+ return {
|
|
|
+ x: x,
|
|
|
+ y: y,
|
|
|
+ row: context.row,
|
|
|
+ col: context.col,
|
|
|
+ cellStyle: cellStyle,
|
|
|
+ cellRect: cellRect,
|
|
|
+ sheetArea: context.sheetArea
|
|
|
+ };
|
|
|
+ };
|
|
|
+ selectButton.prototype.processMouseDown = function (hitinfo){
|
|
|
+ if(hitinfo.sheet.getCell(hitinfo.row,hitinfo.col).locked()!=true){
|
|
|
+ let b1 = new moreButton();
|
|
|
+ b1.marginLeft(cellWidth*4/5);
|
|
|
+ hitinfo.sheet.setCellType(hitinfo.row, hitinfo.col, b1, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ hitinfo.sheet.getCell(hitinfo.row, hitinfo.col).locked(true);
|
|
|
+ }
|
|
|
};
|
|
|
- sheet.setCellType(row, col,getSelectButton(header.headerWidth),GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ return new selectButton();
|
|
|
},
|
|
|
setReplaceButton(row,col,sheet){
|
|
|
let replaceButton = function(){
|