|
@@ -102,6 +102,7 @@ export class STextItem extends SObjectItem {
|
|
this._text = str;
|
|
this._text = str;
|
|
this._font = new SFont("sans-serif", 12);
|
|
this._font = new SFont("sans-serif", 12);
|
|
this.height = 12;
|
|
this.height = 12;
|
|
|
|
+ this.isTransform = false;
|
|
} // Constructor
|
|
} // Constructor
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -137,10 +138,10 @@ export class STextItem extends SObjectItem {
|
|
}
|
|
}
|
|
if (this.borderStyle == SLineStyle.Dashed) {
|
|
if (this.borderStyle == SLineStyle.Dashed) {
|
|
painter.pen.lineDash = [
|
|
painter.pen.lineDash = [
|
|
- painter.toPx(this.lineWidth * 3),
|
|
|
|
- painter.toPx(this.lineWidth * 7)
|
|
|
|
|
|
+ this.lineWidth * 3,
|
|
|
|
+ this.lineWidth * 7
|
|
];
|
|
];
|
|
- painter.pen.lineWidth = painter.toPx(this.lineWidth);
|
|
|
|
|
|
+ painter.pen.lineWidth = this.lineWidth;
|
|
painter.brush.color = this.backgroundColor;
|
|
painter.brush.color = this.backgroundColor;
|
|
painter.pen.color = this.strokeColor;
|
|
painter.pen.color = this.strokeColor;
|
|
painter.drawRect(this.boundingRect());
|
|
painter.drawRect(this.boundingRect());
|
|
@@ -152,8 +153,8 @@ export class STextItem extends SObjectItem {
|
|
this._textArr.forEach((text: string, index: number) => {
|
|
this._textArr.forEach((text: string, index: number) => {
|
|
painter.drawText(
|
|
painter.drawText(
|
|
text,
|
|
text,
|
|
- 2,
|
|
|
|
- index * (this.font.size + 2) + 2,
|
|
|
|
|
|
+ (this.font.size / 4),
|
|
|
|
+ index * (this.font.size * 1.25) + (this.font.size / 4),
|
|
this.maxWidth
|
|
this.maxWidth
|
|
);
|
|
);
|
|
});
|
|
});
|
|
@@ -165,19 +166,22 @@ export class STextItem extends SObjectItem {
|
|
*/
|
|
*/
|
|
protected drawFormatText(): void {
|
|
protected drawFormatText(): void {
|
|
if (this._painter instanceof SPainter) {
|
|
if (this._painter instanceof SPainter) {
|
|
|
|
+ this._painter.save();
|
|
|
|
+ this._painter.font = this.font;
|
|
let textMaxWidth = 0;
|
|
let textMaxWidth = 0;
|
|
- let textHeight: number = this.font.size;
|
|
|
|
|
|
+ let fontSize: number = this.font.size;
|
|
this._textArr.forEach((text: string, index: number) => {
|
|
this._textArr.forEach((text: string, index: number) => {
|
|
let textWidth: number = this._painter
|
|
let textWidth: number = this._painter
|
|
- ? this._painter.textWidth(text) + 4
|
|
|
|
- : 4;
|
|
|
|
|
|
+ ? this._painter.textWidth(text) + (fontSize / 2)
|
|
|
|
+ : (fontSize / 2);
|
|
if (textWidth > textMaxWidth) {
|
|
if (textWidth > textMaxWidth) {
|
|
textMaxWidth = textWidth;
|
|
textMaxWidth = textWidth;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// 在绘制文本后计算文本的宽高
|
|
// 在绘制文本后计算文本的宽高
|
|
this.width = textMaxWidth;
|
|
this.width = textMaxWidth;
|
|
- this.height = (textHeight + 2) * this._textArr.length;
|
|
|
|
|
|
+ this.height = (fontSize * 1.25) * this._textArr.length + (fontSize / 8);
|
|
|
|
+ this._painter.restore();
|
|
}
|
|
}
|
|
} // Function drawFormatText()
|
|
} // Function drawFormatText()
|
|
|
|
|