1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
+ String {
newTextWindow { arg title="Untitled", makeListener=false;
Document.new(title, this, makeListener);
}
openHTMLFile{ arg selectionStart=0, selectionLength=0;
var webView;
if (Platform.openHTMLFileAction.notNil) {
Platform.openHTMLFileAction.value(this, selectionStart, selectionLength);
^this
};
webView = \QWebView.asClass;
if (webView.notNil) {
webView = webView.new;
webView.url_(this);
webView.front;
^this;
};
this.openDocument(selectionStart, selectionLength)
}
openDocument { arg selectionStart=0, selectionLength=0;
var ideClass;
if(Document.implementationClass.notNil) {
Document.open(this, selectionStart, selectionLength);
^this
};
this.openOS
}
draw {
this.drawAtPoint(Point(0,0), Font.default, Color.black);
}
drawAtPoint { arg point, font, color;
Pen.stringAtPoint( this, point, font, color )
}
drawInRect { arg rect, font, color;
Pen.stringInRect( this, rect, font, color )
}
prDrawAtPoint { arg point, font, color;
_String_DrawAtPoint
^this.primitiveFailed
}
prDrawInRect { arg rect, font, color;
_String_DrawInRect
^this.primitiveFailed
}
drawCenteredIn { arg rect, font, color;
Pen.stringCenteredIn( this, rect, font, color )
}
drawLeftJustIn { arg rect, font, color;
var pos, bounds;
Pen.stringLeftJustIn( this, rect, font, color )
}
drawRightJustIn { arg rect, font, color;
var pos, bounds;
Pen.stringRightJustIn( this, rect, font, color )
}
bounds { arg font;
if(GUI.id === \swing,{
// since Swing is not in svn and can't be easily updated
// let's put this temporary hack/if-statement here
// rather than pollute everybody else's code with hacks/if-statements
font = font ?? { Font.default };
^Rect(0, 0, this.size * font.size * 0.52146, font.size * 1.25)
// width in Helvetica approx = string size * font size * 0.52146
// 0.52146 is average of all 32-127 ascii characters widths
},{
^GUI.stringBounds(this, font)
});
}
prBounds { arg rect, font;
_String_GetBounds
^this.primitiveFailed
}
findHelpFile {
^SCDoc.findHelpFile(this);
}
findHelpFileOrElse {
this.findHelpFile;
}
help {
if (Platform.openHelpFileAction.notNil) {
Platform.openHelpFileAction.value(this)
} {
HelpBrowser.openHelpFor(this);
}
}
}
+ Symbol {
openDocument { arg selectionStart=0, selectionLength=0;
^this.asString.openDocument(selectionStart, selectionLength)
}
}
|