summaryrefslogtreecommitdiff
path: root/js/Misc/TEXT_f.js
blob: 36ae5150abdf7575845c139741bf7a3ecd3e19c6 (plain)
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
/* autogenerated from "macros/Misc/TEXT_f.sci" */
function TEXT_f() {
    TEXT_f.prototype.define = function TEXT_f() {
        this.font = 2;
        this.siz = 1;
        this.model = scicos_model();
        this.model.sim = new ScilabString(["text"]);
        this.model.rpar = new ScilabString(["Text"]);
        this.model.ipar = new ScilabDouble([this.font],[this.siz]);
        var exprs = [["Text"],[string(this.font)],[string(this.siz)]];
        this.graphics = scicos_graphics();
        this.graphics.orig = new ScilabDouble([0,0]);
        this.graphics.sz = new ScilabDouble([2,1]);
        this.graphics.exprs = new ScilabDouble(exprs);
        this.x = mlist(["Text","graphics","model","void","gui"],this.graphics,this.model," ","TEXT_f");
        return new TextBlock(this.x);
    }
    TEXT_f.prototype.details = function TEXT_f() {
        return this.x;
    }
    TEXT_f.prototype.get = function TEXT_f() {
        var options = {
            txt:["Text",this.txt],
            font:["Font number",this.font],
            siz:["Font size",this.siz],
        }
        return options;
    }
    TEXT_f.prototype.set = function TEXT_f() {
        var orig = this.graphics.orig;
        var exprs = this.graphics.exprs;
        if (size(exprs,"*")==1) {
            var exprs = [[exprs],["3"],["1"]];
        }
        while (true) {
            var ok = true;
            this.txt = arguments[0]["txt"];
            this.font = parseFloat(arguments[0]["font"]);
            this.siz = parseFloat(arguments[0]["siz"]);
            if (!ok) {
                break;
            }
            if (this.font<=0||this.font>6) {
                message("Font number must be greater than 0 and less than 7");
                throw "user error";
                var ok = false;
            }
            if (this.siz<0) {
                message("Font size must be positive");
                throw "user error";
                var ok = false;
            }
            if (ok) {
                this.graphics.exprs = new ScilabDouble(exprs);
                var gh_winpal = gca();
                var default_font_style = gh_winpal.font_style;
                var default_font_size = gh_winpal.font_size;
                var default_font_color = gh_winpal.font_color;
                gh_winpal.font_style = this.font;
                gh_winpal.font_size = this.siz;
                var r = xstringl(0,0,exprs[1-1],evstr(exprs[2-1]),evstr(exprs[3-1]));
                gh_winpal.font_style = default_font_style;
                gh_winpal.font_size = default_font_size;
                gh_winpal.font_color = default_font_color;
                var sz = r.slice(3-1,4);
                this.graphics.sz = new ScilabDouble(sz);
                this.x.graphics = this.graphics;
                var ipar = [[this.font],[this.siz]];
                this.model.rpar = new ScilabDouble([this.txt]);
                this.model.ipar = new ScilabDouble(ipar);
                this.x.model = this.model;
                break;
            }
        }
        return new TextBlock(this.x);
    }
}