Last active
March 27, 2019 22:13
-
-
Save Foadsf/4076d4bb629577529b7fc9b778e65534 to your computer and use it in GitHub Desktop.
The famous uititle from Enrico Segre (emeritus Scilab contributor) reborn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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