Skip to content

Instantly share code, notes, and snippets.

@Foadsf
Last active March 27, 2019 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Foadsf/4076d4bb629577529b7fc9b778e65534 to your computer and use it in GitHub Desktop.
Save Foadsf/4076d4bb629577529b7fc9b778e65534 to your computer and use it in GitHub Desktop.
The famous uititle from Enrico Segre (emeritus Scilab contributor) reborn
function t = uititle(h, text, relpos)
pos = h.Position;
select relpos
case "r"
pos(3) = 2 * pos(3);
lay_opt = createLayoutOptions("grid", [1,2]);
case "t"
pos(4) = 2 * pos(4);
lay_opt = createLayoutOptions("grid", [2,1]);
case "l"
pos(3) = 2 * pos(3);
lay_opt = createLayoutOptions("grid", [1,2]);
case "b"
pos(4) = 2 * pos(4);
lay_opt = createLayoutOptions("grid", [2,1]);
else
error("Wrong relative position");
end
f = uicontrol("style", "frame", "position", pos, "layout", "grid")
set(f, "layout_options", lay_opt);
c = createConstraints("grid");
if relpos == "r" | relpos == "b" then
t = uicontrol(f, "style", "text", "string", text, "horizontalalignment", "center",...
"constraints", c);
h.parent = f;
else
h.parent = f;
t = uicontrol(f, "style", "text", "string", text, "horizontalalignment", "center",...
"constraints", c);
end
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment