Xcos: updated TKSCALE simulation function 33/14333/6
Vladislav TRUBKIN [Fri, 4 Apr 2014 08:01:48 +0000 (10:01 +0200)]
(slider and legend are at the same frame).

Change-Id: I0c38a9d9b52b271e9d231bb8be54e04b5c3527e2

scilab/modules/helptools/images/TKSCALE_en_US.zcos.png
scilab/modules/scicos_blocks/macros/Sources/tkscaleblk.sci
scilab/modules/xcos/examples/sources_pal/en_US/TKSCALE_en_US.zcos

index 0d715e6..7d84d7b 100644 (file)
Binary files a/scilab/modules/helptools/images/TKSCALE_en_US.zcos.png and b/scilab/modules/helptools/images/TKSCALE_en_US.zcos.png differ
index bad00cc..8a27d79 100644 (file)
 function block=tkscaleblk(block,flag)
     if flag == 1 then
         // Output update
-        slider = findobj("Tag", block.label + "#slider");
+        slider = get(block.uid + "#slider");
+
         if slider <> [] then
             // calculate real value
-            value = (block.rpar(1) + block.rpar(2) - slider.value) / block.rpar(3);
+            value = (block.rpar(1) + block.rpar(2) + get(slider,"value")) / block.rpar(3);
 
-            w = slider.parent;
+            w = get(block.uid);
             if w <> [] then
-                w.info_message = string(value);
+                set(w, "info_message", string(value));
             end
 
             block.outptr(1) = value;
@@ -38,44 +39,68 @@ function block=tkscaleblk(block,flag)
         // Initialization
 
         // if already exists (stopped) then reuse
-        f = findobj("Tag", block.label);
+        f = get(block.uid);
         if f <> [] then
             return;
         end
 
-        f = figure("Tag", block.label, "Figure_name", "TK Source: " + block.label);
-
-        // delete standard menus
-        delmenu(f.figure_id, gettext("&File"));
-        delmenu(f.figure_id, gettext("&Tools"));
-        delmenu(f.figure_id, gettext("&Edit"));
-        delmenu(f.figure_id, gettext("&?"));
-        toolbar(f.figure_id, "off");
+        f = figure("Figure_name", "TK Source: " + block.label, ...
+        "dockable", "off", ...
+        "infobar_visible" , "on", ...
+        "toolbar", "none", ...
+        "menubar_visible", "off", ...
+        "menubar", "none", ...
+        "backgroundcolor", [1 1 1], ...
+        "default_axes", "off", ...
+        "figure_size", [180 350], ...
+        "layout", "border", ...
+        "figure_position", [40 40], ...
+        "Tag", block.uid);
 
-        f.position = [0 0 80 200];
+        frame_slider = uicontrol(f, ...
+        "style", "frame", ...
+        "constraints", createConstraints("border", "left", [180, 0]), ...
+        "border", createBorder("line", "lightGray", 1), ...
+        "backgroundcolor", [1 1 1], ...
+        "layout", "gridbag");
 
         // slider
         bounds = block.rpar(1:2);
         initial = mean(bounds);
-        uicontrol(f, "Style", "slider", "Tag", block.label + "#slider", ..
-        "Min", bounds(1), "Max", bounds(2), "Value", initial, ..
-        "Position", [0 0 20 200], "SliderStep", [block.rpar(3) 2*block.rpar(3)]);
+        uicontrol(frame_slider, ...
+        "Style", "slider", ...
+        "Tag", block.uid + "#slider", ...
+        "Min", bounds(1), ...
+        "Max", bounds(2), ...
+        "Value", initial, ...
+        "Position", [0 0 10 20], ...
+        "SliderStep", [block.rpar(3) 2*block.rpar(3)]);
+
+        frame_label = uicontrol(frame_slider, ...
+        "style", "frame", ...
+        "constraints", createConstraints("border", "right"), ...
+        "backgroundcolor", [1 1 1], ...
+        "layout", "gridbag");
 
         // labels
-        labels = string([bounds(2)                  ;..
-        mean([bounds(2) initial])  ;..
-        initial                    ;..
-        mean([bounds(1) initial])  ;..
+        labels = string([bounds(2) ; ...
+        mean([bounds(2) initial])  ; ...
+        initial                    ; ...
+        mean([bounds(1) initial])  ; ...
         bounds(1)]);
-        labels = strcat(labels, "<br /><br /><br />");
-        uicontrol(f, "Style", "text", "String", labels(1), ..
-        "Position", [30  0 50 200]);
+        labels = "<html>" + strcat(labels, "<br /><br /><br />") + "</html>";
+
+        uicontrol(frame_label, ...
+        "Style", "text", ...
+        "String", labels(1), ...
+        "FontWeight", "bold", ...
+        "backgroundcolor", [1 1 1]);
 
         // update default value
         block.outptr(1) = initial / block.rpar(3);
     elseif flag == 5 then
         // Ending
-        f = findobj("Tag", block.label);
+        f = get(block.uid);
         if f <> [] then
             close(f);
         end
index 2d978d7..c15e5e0 100644 (file)
Binary files a/scilab/modules/xcos/examples/sources_pal/en_US/TKSCALE_en_US.zcos and b/scilab/modules/xcos/examples/sources_pal/en_US/TKSCALE_en_US.zcos differ