cmake build system: visiblity support for clang
[supercollider.git] / SCClassLibrary / Common / GUI / PlusGUI / Collections / StringPlusGUI.sc
blobe632292b0d2411978d47430f8fa1b0b8d916e2b6
1 + String {
2         newTextWindow { arg title="Untitled", makeListener=false;
3                 Document.new(title, this, makeListener);
4         }
6         openTextFile{ arg selectionStart=0, selectionLength=0;
7                 if(Document.implementationClass.notNil) {
8                         Document.open(this.absolutePath , selectionStart, selectionLength);
9                 } {
10                         this.openOS;
11                 }
12         }
13         openHTMLFile{ arg selectionStart=0, selectionLength=0;
14                 if (Platform.openHTMLFileAction.notNil) {
15                         Platform.openHTMLFileAction.value(this, selectionStart, selectionLength)
16                 } {
17                         this.openTextFile(selectionStart, selectionLength)
18                 }
19         }
21         openDocument {
22                 if(Document.implementationClass.notNil) {
23                         Document.open(this);
24                 } {
25                         this.openOS;
26                 }
27         }
28 //      *fromUser { arg prompt="Enter string :", default="";
29 //              _GetStringFromUser
30 //              ^this.primitiveFailed
31 //      }
34         draw {
35                 this.drawAtPoint(Point(0,0), Font.default, Color.black);
36         }
37         drawAtPoint { arg point, font, color;
38                 if(GUI.id === \qt)
39                         { QPen.stringAtPoint( this, point, font, color ) }
40                         { this.prDrawAtPoint( point, font, color ) };
41         }
42         drawInRect { arg rect, font, color;
43                 if(GUI.id === \qt)
44                         { QPen.stringInRect( this, rect, font, color ) }
45                         { this.prDrawInRect( rect, font, color ) }
46         }
47         prDrawAtPoint { arg point, font, color;
48                 _String_DrawAtPoint
49                 ^this.primitiveFailed
50         }
51         prDrawInRect { arg rect, font, color;
52                 _String_DrawInRect
53                 ^this.primitiveFailed
54         }
55         drawCenteredIn { arg rect, font, color;
56                 if(GUI.id === \qt)
57                         { QPen.stringCenteredIn( this, rect, font, color ) }
58                         { this.drawAtPoint(this.bounds( font ).centerIn(rect), font, color) };
59         }
60         drawLeftJustIn { arg rect, font, color;
61                 var pos, bounds;
62                 if(GUI.id === \qt)
63                         { QPen.stringLeftJustIn( this, rect, font, color ) }
64                         {
65                                 bounds = this.bounds( font );
66                                 pos = bounds.centerIn(rect);
67                                 pos.x = rect.left + 2;
68                                 this.drawAtPoint(pos, font, color);
69                         };
70         }
71         drawRightJustIn { arg rect, font, color;
72                 var pos, bounds;
73                 if(GUI.id === \qt)
74                         { QPen.stringRightJustIn( this, rect, font, color ) }
75                         {
76                                 bounds = this.bounds( font );
77                                 pos = bounds.centerIn(rect);
78                                 pos.x = rect.right - 2 - bounds.width;
79                                 this.drawAtPoint(pos, font, color);
80                         };
81         }
83         bounds { arg font;
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
92                 },{
93                         ^GUI.stringBounds(this, font)
94                 });
95         }
96         prBounds { arg rect, font;
97                 _String_GetBounds
98                 ^this.primitiveFailed
99         }
102         findHelpFile {
103                 ^SCDoc.findHelpFile(this);
104         }
106         findHelpFileOrElse {
107                 this.findHelpFile;
108         }
110         openHelpFile {
111                 if (Platform.openHelpFileAction.notNil) {
112                         Platform.openHelpFileAction.value(this)
113                 } {
114                         HelpBrowser.openHelpFor(this);
115                 }
116         }