summaryrefslogtreecommitdiff
path: root/modules/graphics/macros/createLayoutOptions.sci
blob: 079fa5178aaa476343b7435a80f576d38d7a484c (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
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
//
//

function ret = createLayoutOptions(constType, varargin)
    [lhs,rhs]=argn(0)

    if rhs < 1 then
        error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected."), "createLayoutOptions", 1));
    end

    ret = [];
    if constType == "nolayout" | constType == "none" then
        ret = tlist(["OptNoLayout"]);
    elseif constType == "border" then
        arg1 = [0 0]

        //hpad, vpad
        if size(varargin) > 0 then
            arg1 = varargin(1);
            if typeof(arg1) <> "constant" | size(arg1, "*") <> 2 then
                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 2));
            end
        end

        ret = tlist(["OptBorder","padding"], arg1);
    elseif constType == "grid" then
        arg1 = [0 0];
        arg2 = [0 0];

        if size(varargin) > 0 then
            arg1 = varargin(1);
            if typeof(arg1) <> "constant" | size(arg1, "*") <> 2 then
                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 2));
            end
        end

        if size(varargin) > 1 then
            arg2 = varargin(2);
            if typeof(arg2) <> "constant" | size(arg2, "*") <> 2 then
                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 3));
            end
        end
        ret = tlist(["OptGrid","grid","padding"], arg1, arg2);
    elseif constType == "gridbag" then
        ret = tlist(["OptGridBag"]);
    else
        error(999, msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "createLayoutOptions", 1, "none/nolayout, border, grid, gridbag"));
    end
endfunction