add first version of gridbag layout, allow capability to launch many script via url 44/17844/1
Antoine ELIAS [Wed, 2 Mar 2016 16:43:51 +0000 (17:43 +0100)]
Change-Id: I4dbbe34e1282033f244578c05701f1a8f4b58be9

scilab/modules/graphic_objects/src/cpp/webutils.cpp
scilab/node/html/index.html
scilab/node/loader.sce
scilab/node/scilab_server.js

index 8c7b523..6cc419c 100644 (file)
@@ -918,9 +918,57 @@ void WebUtils::getUIGridBagGrid(int uid, std::vector<int>& vect)
 
 void WebUtils::setUIGridBag(int uid, std::string& str, bool append)
 {
+    int parent = getParent(uid);
     std::vector<int> grid;
     getUIGridBagGrid(uid, grid);
 
+    if (append == false)
+    {
+        str = "var __child__ = " + getElementById(uid);
+    }
+
+    str += "__child__.style.width = '100%';";
+    str += "__child__.style.position = 'inherit';";
+    str += "__child__.style.left = 'inherit';";
+    str += "__child__.style.bottom = 'inherit';";
+    str += "__child__.style.height = '100%';";
+    //we have to create a td with grid information and add it to the good cell ( or create if not exist ! )
+
+    //build td child
+    std::string td;
+    td = "var __td__ = " + createElement("TD");
+
+    std::string name("_" + std::to_string(grid[0]) + "_" + std::to_string(grid[1]));
+    td += "__td__.id = " + getIdString(uid, name) + ";";
+
+    if (grid[2] != 1)
+    {
+        td += "__td__.colSpan = '" + std::to_string(grid[2]) + "';";
+    }
+
+    if (grid[3] != 1)
+    {
+        td += "__td__.rowSpan = '" + std::to_string(grid[3]) + "';";
+    }
+
+    //td += "__td__.style.width = '100%';";
+    td += "__td__.appendChild(__child__);";
+
+    //build or get tr
+    name = "_" + std::to_string(grid[1]);
+    std::string tr;
+    tr = "var __tr__ = " + getElementById(parent, name);
+    tr += "if(__tr__ == null){";
+    tr += "";
+    tr += "__tr__ = " + createElement("TR");
+    tr += "__tr__.id = " + getIdString(parent, name) + ";";
+    tr += "var __table__ = " + getElementById(parent, "_table");
+    tr += "__table__.appendChild(__tr__);";
+    tr += "}";
+    tr += "__tr__.appendChild(__td__);";
+
+    str += td;
+    str += tr;
 }
 
 bool WebUtils::hasCallback(int uid)
index e4774ea..6b174d5 100644 (file)
@@ -34,7 +34,7 @@ body {
     width : 610px;
     height : 460px;
     margin : auto;
-    //border : 2px rgb(0,0,0) solid;
+    border : 2px rgb(0,0,0) solid;
     overflow : auto;
     text-align: left;
 }
index f15f8f3..97a9119 100644 (file)
@@ -1,4 +1,4 @@
-if 1 then
+if 0 then
     f1 = createWindow();
     f1.position(3:4) = [250, 100];
 
@@ -169,7 +169,7 @@ if 0 then
 end
 
 //gridbag
-if 0 then
+if 1 then
     f = createWindow();
     f.position = [200 200 200 100];
     f.layout = "gridbag";
@@ -189,35 +189,33 @@ if 0 then
         "backgroundcolor"     , [1 0 0] , ...
         "constraints"         , c);
 
-    if 0 then
-        c.grid = greenf_grid;
-        u_grid2 = uicontrol(f , ...
-            "style"               , "frame", ...
-            "backgroundcolor"     , [0 1 0], ...
-            "constraints"         , c);
-
-        c.grid = bluef_grid;
-        u_grid3 = uicontrol(f , ...
-            "style"               , "frame", ...
-            "backgroundcolor"     , [0 0 1], ...
-            "constraints"         , c);
-
-        c.grid = yelf_grid;
-        u_grid4 = uicontrol(f , ...
-            "style"               , "frame", ...
-            "backgroundcolor"     , [1 1 0], ...
-            "constraints"         , c);
-
-        c.grid = magf_grid;
-        u_grid5 = uicontrol(f , ...
-            "style"               , "frame", ...
-            "backgroundcolor"     , [1 0 1], ...
-            "constraints"         , c);
+    c.grid = greenf_grid;
+    u_grid2 = uicontrol(f , ...
+        "style"               , "frame", ...
+        "backgroundcolor"     , [0 1 0], ...
+        "constraints"         , c);
+
+    c.grid = bluef_grid;
+    u_grid3 = uicontrol(f , ...
+        "style"               , "frame", ...
+        "backgroundcolor"     , [0 0 1], ...
+        "constraints"         , c);
+
+    c.grid = yelf_grid;
+    u_grid4 = uicontrol(f , ...
+        "style"               , "frame", ...
+        "backgroundcolor"     , [1 1 0], ...
+        "constraints"         , c);
+
+    c.grid = magf_grid;
+    u_grid5 = uicontrol(f , ...
+        "style"               , "frame", ...
+        "backgroundcolor"     , [1 0 1], ...
+        "constraints"         , c);
        
-        c.grid = cyanf_grid;
-        u_grid1 = uicontrol(f , ...
-            "style"               , "frame", ...
-            "backgroundcolor"     , [0 1 1], ...
-            "constraints"         , c);
-    end
+    c.grid = cyanf_grid;
+    u_grid1 = uicontrol(f , ...
+        "style"               , "frame", ...
+        "backgroundcolor"     , [0 1 1], ...
+        "constraints"         , c);
 end
index fab9aea..800b825 100644 (file)
@@ -8,13 +8,20 @@ var client = require('socket.io-client');
 
 var fork = require('child_process').fork;
 
+
 server.listen(1337);
 
-app.get('/', function(req, res) {
+var script = '/loader';
+
+app.get("*", function(req, res) {
     res.sendFile(__dirname + '/html/index.html');
+    if(req.url != "/") {
+        script = req.url;
+    } else {
+        script = '/loader';
+    }
 });
 
-
 io.on('connection', function (socket) {
     //start process
     var child = fork('./scilab_process.js');
@@ -46,7 +53,7 @@ io.on('connection', function (socket) {
                 //send ready message to client
                 socket.emit('status', msg);
                 //send execution of initial script to scilab
-                prcSocket.emit('command', {data:"exec(getenv('SCIFILES') + '/loader.sce', -1);"});
+                prcSocket.emit('command', {data:"exec(getenv('SCIFILES') + '" + script + ".sce', -1);"});
             }
         });
     });