2 newTextWindow { arg title="Untitled", makeListener=false;
3 Document.new(title, this, makeListener);
6 openTextFile{ arg selectionStart=0, selectionLength=0;
7 if(Document.implementationClass.notNil) {
8 Document.open(this.absolutePath , selectionStart, selectionLength);
13 openHTMLFile{ arg selectionStart=0, selectionLength=0;
14 if (Platform.openHTMLFileAction.notNil) {
15 Platform.openHTMLFileAction.value(this, selectionStart, selectionLength)
17 this.openTextFile(selectionStart, selectionLength)
22 if(Document.implementationClass.notNil) {
28 // *fromUser { arg prompt="Enter string :", default="";
30 // ^this.primitiveFailed
35 this.drawAtPoint(Point(0,0), Font.default, Color.black);
37 drawAtPoint { arg point, font, color;
39 { QPen.stringAtPoint( this, point, font, color ) }
40 { this.prDrawAtPoint( point, font, color ) };
42 drawInRect { arg rect, font, color;
44 { QPen.stringInRect( this, rect, font, color ) }
45 { this.prDrawInRect( rect, font, color ) }
47 prDrawAtPoint { arg point, font, color;
51 prDrawInRect { arg rect, font, color;
55 drawCenteredIn { arg rect, font, color;
57 { QPen.stringCenteredIn( this, rect, font, color ) }
58 { this.drawAtPoint(this.bounds( font ).centerIn(rect), font, color) };
60 drawLeftJustIn { arg rect, font, color;
63 { QPen.stringLeftJustIn( this, rect, font, color ) }
65 bounds = this.bounds( font );
66 pos = bounds.centerIn(rect);
67 pos.x = rect.left + 2;
68 this.drawAtPoint(pos, font, color);
71 drawRightJustIn { arg rect, font, color;
74 { QPen.stringRightJustIn( this, rect, font, color ) }
76 bounds = this.bounds( font );
77 pos = bounds.centerIn(rect);
78 pos.x = rect.right - 2 - bounds.width;
79 this.drawAtPoint(pos, font, color);
84 if(GUI.id === \swing,{
85 // since Swing is not in svn and can't be easily updated
86 // let's put this temporary hack/if-statement here
87 // rather than pollute everybody else's code with hacks/if-statements
88 font = font ?? { Font.default };
89 ^Rect(0, 0, this.size * font.size * 0.52146, font.size * 1.25)
90 // width in Helvetica approx = string size * font size * 0.52146
91 // 0.52146 is average of all 32-127 ascii characters widths
93 ^GUI.stringBounds(this, font)
96 prBounds { arg rect, font;
103 ^SCDoc.findHelpFile(this);
111 if (Platform.openHelpFileAction.notNil) {
112 Platform.openHelpFileAction.value(this)
114 HelpBrowser.openHelpFor(this);