1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2008 - INRIA - Vincent COUVERT
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12// This test check save and load functions used with uicontrols
13// The following functions are tested:
14//  - SCI/modules/graphics/macros/%h_save.sci
15//  - SCI/modules/graphics/macros/%h_load.sci
16// Create an uimenu
17f = scf(0);
18h = uicontrol("parent", f, "style", "frame"); // Default style is pushbutton
19// Change value of each property to be sure it is saved and loaded correctly
20h.backgroundcolor = [0 0 0]; // Default is [0.6 0.6 0.6]
21h.enable = "off"; // Default is "on"
22h.fontangle = "italic"; // Default is "normal"
23h.fontname = "arial"; // Default is "helvetica"
24h.fontsize = 20; // Default is 10
25h.fontunits = "pixels"; // Default is "points"
26h.fontweight = "bold"; // Default is "normal"
27h.foregroundcolor = [1 1 1]; // Default is [0 0 0]
28h.horizontalalignment = "right"; // Default is "center"
29h.listboxtop = 1; // Default is []
30h.max = 10; // Default is 1
31h.min = 5; // Default is 0
32h.position = [100 100 200 200]; // Default is [20 20 80 40]
33h.relief = "sunken"; // Default is "ridge" for frames
34h.sliderstep = [1 2]; // Default is [0.01,0.1]
35h.string = "titi"; // Default is ""
36h.tooltipstring = "Tooltip"; // Default is ""
37h.units = "points"; // Default is pixels
38h.value = 10; // Default is []
39h.verticalalignment = "top"; // Default is "center"
40h.visible = "off"; // Default is "on"
41h.callback = "disp(1)"; // Default is ""
42h.callback_type = 1; // Default is 0
43h.user_data = list("hello", "Scilab", 5);
44h.tag = "My uimenu tag"; // Default is ""
45// Save figure contents
46save(TMPDIR + "/uicontrol.scg", "h");
47hsaved = h;
48clear h;
49// Load saved handle
50load(TMPDIR + "/uicontrol.scg");
51// Check if properties are equal
52if or(h.style<>hsaved.style) then bugmes();quit;end
53if or(h.backgroundcolor<>hsaved.backgroundcolor) then bugmes();quit;end
54if or(h.enable<>hsaved.enable) then bugmes();quit;end
55if or(h.fontangle<>hsaved.fontangle) then bugmes();quit;end
56if or(h.fontname<>hsaved.fontname) then bugmes();quit;end
57//if or(h.fontsize<>hsaved.fontsize) then bugmes();quit;end // TODO FIX ME !!
58if or(h.fontunits<>hsaved.fontunits) then bugmes();quit;end
59if or(h.fontweight<>hsaved.fontweight) then bugmes();quit;end
60if or(h.foregroundcolor<>hsaved.foregroundcolor) then bugmes();quit;end
61if or(h.horizontalalignment<>hsaved.horizontalalignment) then bugmes();quit;end
62if or(h.listboxtop<>hsaved.listboxtop) then bugmes();quit;end
63if or(h.max<>hsaved.max) then bugmes();quit;end
64if or(h.min<>hsaved.min) then bugmes();quit;end
65if abs(sum(h.position-hsaved.position)) > 4 then bugmes();quit;end // TODO FIX ME !! Can have a difference of 1 (point or pixel) when getting position
66if or(h.relief<>hsaved.relief) then bugmes();quit;end
67if or(h.sliderstep<>hsaved.sliderstep) then bugmes();quit;end
68if or(h.string<>hsaved.string) then bugmes();quit;end
69if or(h.tooltipstring<>hsaved.tooltipstring) then bugmes();quit;end
70if or(h.units<>hsaved.units) then bugmes();quit;end
71if or(h.value<>hsaved.value) then bugmes();quit;end
72if or(h.verticalalignment<>hsaved.verticalalignment) then bugmes();quit;end
73if or(h.visible<>hsaved.visible) then bugmes();quit;end
74if or(h.callback<>hsaved.callback) then bugmes();quit;end
75if or(h.callback_type<>hsaved.callback_type) then bugmes();quit;end
76if or(h.user_data<>hsaved.user_data) then bugmes();quit;end
77if or(h.tag<>hsaved.tag) then bugmes();quit;end
78