Uicontrols: add some layout and messagebox-like demos 00/18400/3
Clément DAVID [Fri, 29 Jul 2016 18:40:01 +0000 (20:40 +0200)]
Change-Id: I4995135aaee81c346c7fa76c33c1577190a9e0e3

scilab/modules/gui/demos/gui.dem.gateway.sce
scilab/modules/gui/demos/uicontrol_layout.dem.sce [new file with mode: 0644]
scilab/modules/gui/demos/uicontrol_messagebox.dem.sce [new file with mode: 0644]
scilab/modules/gui/help/en_US/uicontrol_properties.xml

index 4a387bb..2f68c11 100644 (file)
@@ -29,6 +29,12 @@ function subdemolist = demo_gateway()
     subdemolist = [ subdemolist ;
     _("Uicontrols rendering") ,  "usedeprecatedskin.dem.sce" ];
 
+    subdemolist = [ subdemolist ;
+    _("Uicontrols layout") ,  "uicontrol_layout.dem.sce" ];
+
+    subdemolist = [ subdemolist ;
+    _("Uicontrols messagebox-like") ,  "uicontrol_messagebox.dem.sce" ];
+
     subdemolist(:,2) = demopath + subdemolist(:,2);
 endfunction
 
diff --git a/scilab/modules/gui/demos/uicontrol_layout.dem.sce b/scilab/modules/gui/demos/uicontrol_layout.dem.sce
new file mode 100644 (file)
index 0000000..797c991
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Scilab Enterprises - Clement DAVID
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+// figure without extra bars
+f = figure("menubar_visible", "off", "toolbar_visible", "off", "infobar_visible", "off", "dockable", "off", "default_axes", "off", "visible", "off", "layout", "border");
+
+// a tab is a frame container
+tab = uicontrol(f, "style", "tab");
+
+// each frame below is a tab entry and as a distinct layout and specific options
+
+// a 2x3 grid layout
+layout_opt = createLayoutOptions("grid", [2,3]);
+frame3 = uicontrol(tab, "style", "frame", "string", "Grid layout", "layout", "grid", "layout_options", layout_opt);
+
+for i=1:prod(layout_opt.grid)
+    uicontrol(frame3, "style", "pushbutton", "string", "grid "+string(i));
+end
+
+// a gridbag layout with custom grid relative width and height
+frame2 = uicontrol(tab, "style", "frame", "string", "Gridbag layout", "layout", "gridbag");
+
+c = createConstraints("gridbag", [1, 1, 1, 3], [1,1], "both");
+uicontrol(frame2, "style", "pushbutton", "string", "Expandable", "constraints", c);
+c = createConstraints("gridbag", [1, 4, 1, 1], [2,1]);
+uicontrol(frame2, "style", "pushbutton", "string", "Much more stable on resize", "constraints", c);
+c = createConstraints("gridbag", [1, 5, 1, 1], [0.1,1], "horizontal");
+uicontrol(frame2, "style", "pushbutton", "string", "Horizontal fill in", "constraints", c);
+
+
+// a border layout
+frame1 = uicontrol(tab, "style", "frame", "string", "Border layout", "layout", "border");
+
+for n=["top" "left" "center" "right" "bottom"];
+    c = createConstraints("border", n);
+    uicontrol(frame1, "style", "pushbutton", "string", n, "constraints", c);
+end
+
+// display
+f.visible = "on";
diff --git a/scilab/modules/gui/demos/uicontrol_messagebox.dem.sce b/scilab/modules/gui/demos/uicontrol_messagebox.dem.sce
new file mode 100644 (file)
index 0000000..747e574
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Scilab Enterprises - Clement DAVID
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+// figure creation for a modal messagebox-like popup
+// the variable btn = Nan while open ; -1 if closed ; 0 if cancel ; 1 if OK
+// the variable data is used to store some output values
+data = grand(4,3,"uin",0,1)
+btn = %nan;
+
+f = figure("figure_name", gettext("Please fill the table"), "closerequestfcn", "btn=-1; close();", "callback_type", 10, "menubar_visible", "off", "toolbar_visible", "off", "infobar_visible", "off", "dockable", "off", "default_axes", "off", "visible", "off", "layout", "border");
+
+middle_frame = uicontrol(f, "style", "frame", "constraints", createConstraints("border", "center"));
+bottom_frame = uicontrol(f, "style", "frame", "constraints", createConstraints("border", "bottom"), "layout" , "gridbag");
+
+// the bottom buttons
+uicontrol(bottom_frame, "style", "pushbutton", "string", gettext("Ok"), "callback", "btn = 1; data=save_data(); close();", "callback_type", 10, "margin", [10 10 10 10]);
+uicontrol(bottom_frame, "style", "pushbutton", "string", gettext("Cancel"), "callback", "btn = 0; close();", "callback_type", 10, "margin", [10 10 10 10]);
+
+// add a label and a grid of checkboxes
+middle_frame.margins = [5 5 5 5];
+middle_frame.layout = "border"
+uicontrol(middle_frame, "style", "text", "string", "Please select the kind to use", "constraint", createConstraints("border", "top"));
+inner_frame = uicontrol(middle_frame, "style", "frame", "constraint", createConstraints("border", "center"), "layout", "grid", "layout_options", createLayoutOptions("grid", size(data)));
+d=data'
+for i=size(d, "*"):-1:1
+    uicontrol(inner_frame, "style", "checkbox", ...
+    "value", d(i), ...
+    "string", "validate "+string(i));
+end
+
+// callback used to store the updated values
+function d = save_data()
+    d = zeros(3,4);
+    for i=size(d, "*"):-1:1
+        d(i) = inner_frame.children(i).value;
+    end
+    d = d';
+endfunction
+
+// display the result before the edition
+disp(data, "before")
+
+// is modal but without burning the CPU
+f.visible = "on";
+while is_handle_valid(f),
+    sleep(100);
+end
+
+// display the edited result
+disp(data, "after edit")
index 0b4a715..bc63036 100644 (file)
                 <listitem>
                     <para>Scalar</para>
                     <para>The type of callback transmitted to the uicontrol (see example below).</para>
-                    <itemizedlist>
-                        <listitem>
-                            <para>
-                                <literal>-1</literal> none (callback deactivated)
-                            </para>
-                        </listitem>
-                        <listitem>
-                            <para>
-                                <literal>0</literal> (by default) or <literal>2</literal> a non prioritary, interruptible Scilab instruction
-                            </para>
-                            <para>
-                                <literal>10</literal> or <literal>12</literal> a prioritary, non-interruptible Scilab instruction
-                            </para>
-                        </listitem>
-                        <listitem>
-                            <para>
-                                <literal>1</literal> a C or a Fortran function
-                            </para>
-                        </listitem>
-                    </itemizedlist>
+                    <variablelist>
+                        <varlistentry>
+                            <term>
+                                <literal>-1</literal>
+                            </term>
+                            <listitem>
+                                <para>none (callback deactivated)</para>
+                            </listitem>
+                        </varlistentry>
+                        <varlistentry>
+                            <term>
+                                <literal>0</literal> (by default)
+                            </term>
+                            <listitem>
+                                <para>non prioritary (or interruptible) Scilab instructions</para>
+                            </listitem>
+                        </varlistentry>
+                        <varlistentry>
+                            <term>
+                                <literal>1</literal>
+                            </term>
+                            <listitem>
+                                <para>Cor a Fortran function</para>
+                            </listitem>
+                        </varlistentry>
+                        <varlistentry>
+                            <term>
+                                <literal>2</literal>
+                            </term>
+                            <listitem>
+                                <para>non prioritary (or interruptible) Scilab function</para>
+                            </listitem>
+                        </varlistentry>
+                        <varlistentry>
+                            <term>
+                                <literal>10</literal>
+                            </term>
+                            <listitem>
+                                <para>prioritary (or non-interruptible) Scilab instructions</para>
+                            </listitem>
+                        </varlistentry>
+                        <varlistentry>
+                            <term>
+                                <literal>12</literal>
+                            </term>
+                            <listitem>
+                                <para>prioritary (or non-interruptible) Scilab function</para>
+                            </listitem>
+                        </varlistentry>
+                    </variablelist>
                 </listitem>
             </varlistentry>
             <varlistentry>