2 newTextWindow { arg title="Untitled", makeListener=false;
3 Document.new(title, this, makeListener);
6 openHTMLFile{ arg selectionStart=0, selectionLength=0;
7 if (Platform.openHTMLFileAction.notNil) {
8 Platform.openHTMLFileAction.value(this, selectionStart, selectionLength)
10 this.openDocument(selectionStart, selectionLength)
14 openDocument { arg selectionStart=0, selectionLength=0;
16 if(Document.implementationClass.notNil) {
17 Document.open(this, selectionStart, selectionLength);
21 ideClass = \ScIDE.asClass;
22 if ( ideClass.notNil ) {
23 if ( this.endsWith(".sc") || this.endsWith(".scd") ) {
24 ideClass.open(this, selectionStart);
32 // *fromUser { arg prompt="Enter string :", default="";
34 // ^this.primitiveFailed
39 this.drawAtPoint(Point(0,0), Font.default, Color.black);
41 drawAtPoint { arg point, font, color;
43 { this.prDrawAtPoint( point, font, color ) }
44 { Pen.stringAtPoint( this, point, font, color ) }
46 drawInRect { arg rect, font, color;
48 { this.prDrawInRect( rect, font, color ) }
49 { Pen.stringInRect( this, rect, font, color ) }
51 prDrawAtPoint { arg point, font, color;
55 prDrawInRect { arg rect, font, color;
59 drawCenteredIn { arg rect, font, color;
61 { this.drawAtPoint(this.bounds( font ).centerIn(rect), font, color) }
62 { Pen.stringCenteredIn( this, rect, font, color ) }
64 drawLeftJustIn { arg rect, font, color;
68 bounds = this.bounds( font );
69 pos = bounds.centerIn(rect);
70 pos.x = rect.left + 2;
71 this.drawAtPoint(pos, font, color);
73 { Pen.stringLeftJustIn( this, rect, font, color ) }
75 drawRightJustIn { arg rect, font, color;
79 bounds = this.bounds( font );
80 pos = bounds.centerIn(rect);
81 pos.x = rect.right - 2 - bounds.width;
82 this.drawAtPoint(pos, font, color);
84 { Pen.stringRightJustIn( this, rect, font, color ) }
88 if(GUI.id === \swing,{
89 // since Swing is not in svn and can't be easily updated
90 // let's put this temporary hack/if-statement here
91 // rather than pollute everybody else's code with hacks/if-statements
92 font = font ?? { Font.default };
93 ^Rect(0, 0, this.size * font.size * 0.52146, font.size * 1.25)
94 // width in Helvetica approx = string size * font size * 0.52146
95 // 0.52146 is average of all 32-127 ascii characters widths
97 ^GUI.stringBounds(this, font)
100 prBounds { arg rect, font;
102 ^this.primitiveFailed
107 ^SCDoc.findHelpFile(this);
115 if (Platform.openHelpFileAction.notNil) {
116 Platform.openHelpFileAction.value(this)
118 HelpBrowser.openHelpFor(this);
124 openDocument { arg selectionStart=0, selectionLength=0;
125 ^this.asString.openDocument(selectionStart, selectionLength)