@doc hierarchy="GMLDOM">
Aspect for drawing auto-size textboxes
(c) SAP AG 2003-2006. All rights reserved.
Aspect Textbox for GmlDrawing;
inherit Polyshape;
//////////////////////////////////////////////////////////////////////////////////////
// PROPERTIES
<@doc>
Gets or sets the textbox's font size
The font size is expressed as a percentage of the default font size (e.g., 50 means half-size font, 200 means double-size font, etc.).
property fontSize = 90;
metadata for fontSize = {
editor: 'slider',
group: 'Drawing',
visible: 'HAS_ASPECT(data, "core.svg:Textbox")',
label: '#TEXT[XTIT_FONT_SIZE]',
min: 50,
max: 150,
step: 5,
minLabel: '#TEXT[XTIT_SMALL]',
maxLabel: '#TEXT[XTIT_BIG]',
format: function (v) { return v+'%'; },
priority: 600
}
<@doc>
Gets or sets the textbox's frame dash pattern
The ~dash property controls the pattern of dashes and gaps used to stroke the textbox frame.
The ~dash property value can be either 'none' (indicating that the frame is to be drawn solid),
or a list of whitespace-separated numbers that specify the lengths of alternating dashes and gaps.
property frameDash = 'none';
metadata for frameDash = {
editor: 'enum',
group: 'Drawing',
visible: 'HAS_ASPECT(data, "core.svg:Textbox")',
domain: 'none:#TEXT[XLST_SOLID];4 2:#TEXT[XLST_DASHED];2 3:#TEXT[XLST_DOTTED];8 3:#TEXT[XLST_LONG_DASH];6 4 2 4:#TEXT[XLST_DASH_DOT];6 4 2 4 2 4:#TEXT[XLST_DASH_DOT_DOT]',
label: '#TEXT[XFLD_FRAME_STYLE]',
priority: 500
}
<@doc type="Enum">
Gets or sets the textbox's alignment
The ~textAlign property values are defined by the following enumeration:
Value | Description
start | The textbox contents are aligned along the left margin
middle | The textbox contents are centered around the shape's middle
end | The textbox contents are aligned along the right margin
property textAlign = 'start';
metadata for textAlign = {
editor: 'enum',
group: 'Drawing',
visible: 'HAS_ASPECT(data, "core.svg:Textbox")',
domain: 'start:#TEXT[XLST_LEFT];middle:#TEXT[XLST_CENTER];end:#TEXT[XLST_RIGHT]',
label: '#TEXT[XFLD_TEXT_ALIGN]',
priority: 400
}
//////////////////////////////////////////////////////////////////////////////////////
// OVERRIDDEN PROPERTIES
override property fillColor = '#FFFFFF';
override property strokeColor = '#D4D0C8';
override property textColor = '#888888';
override static readonly property geometry = {
resizeMode: #[SVG_AUTO_SIZE],
rotateMode: #[SVG_ROTATE_FULL],
defWidth: 120,
defHeight: 30,
padding: [5,5,5,5]
};
override static readonly property frameParts = [
{type:'rect', x:'-@w/2', y:'-@h/2', width:'@w', height:'@h', fill:'@fillColor', stroke:'currentColor', 'stroke-dasharray':'@frameDash'}
];
override static readonly property bodyParts = [
{type:'text', mtext:'@notes', x:'(@textAlign=="start" ? 4-@w/2 : @textAlign=="end" ? @w/2-4 : 0)', 'font-size':'@fontSize+"%"', fill:'@textColor', stroke:'none', 'text-anchor':'@textAlign'}
];
//////////////////////////////////////////////////////////////////////////////////////
// OVERRIDES
override virtual method startRename()
var diag = this.diagram, ox=this.ox, oy=this.oy, os=this.os;
var cbox = diag.canvas.canvasToClient(ox+this.x1*os, oy+this.y1*os, this.w*os, this.h*os);
var cpos = diag.board.clientToBrowser({x:cbox.x, y:cbox.y});
var data = {
object: base,
graphic: this,
attr: 'notes',
multi: true,
bgcolor: base.@fillColor,
fgcolor: base.@textColor,
callback: diag.endRename,
delegate: diag,
x: cpos.x,
y: cpos.y,
w: MAX(cbox.w,200),
h: MAX(cbox.h,75)
};
diag.board.textedit.show(data);
end
override virtual method paint(prop)
this.supercall();
this.adjustTextbox();
end
override virtual method repaint(prop)
this.supercall();
if (prop == '@size' || prop == '@textAlign') {
var tnode=this.partNodes[1], tx=tnode.getAttribute('x');
for (var i=0, C=tnode.childNodes, len=C.length; i