Mercurial > octave
annotate scripts/gui/uifigure.m @ 31237:e3016248ca5d
uifigure.m: Call set () only if varargin is not empty (bug #63088)
* uifigure.m: Call set () only if varargin is not empty.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Wed, 21 Sep 2022 09:55:32 -0400 |
parents | f44e19671777 |
children | 597f3ee61a48 |
rev | line source |
---|---|
31005 | 1 ######################################################################## |
2 ## | |
3 ## Copyright (C) 2022 The Octave Project Developers | |
4 ## | |
5 ## See the file COPYRIGHT.md in the top-level directory of this | |
6 ## distribution or <https://octave.org/copyright/>. | |
7 ## | |
8 ## This file is part of Octave. | |
9 ## | |
10 ## Octave is free software: you can redistribute it and/or modify it | |
11 ## under the terms of the GNU General Public License as published by | |
12 ## the Free Software Foundation, either version 3 of the License, or | |
13 ## (at your option) any later version. | |
14 ## | |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ## GNU General Public License for more details. | |
19 ## | |
20 ## You should have received a copy of the GNU General Public License | |
21 ## along with Octave; see the file COPYING. If not, see | |
22 ## <https://www.gnu.org/licenses/>. | |
23 ## | |
24 ######################################################################## | |
25 | |
26 ## -*- texinfo -*- | |
27 ## @deftypefn {} {@var{h} =} uifigure () | |
28 ## @deftypefnx {} {@var{h} =} uifigure ("@var{property}", @var{value}, @dots{}) | |
29 ## Create a new figure window for applications. | |
30 ## | |
31 ## Multiple property-value pairs may be specified for the figure object, but | |
32 ## they must occur in pairs. | |
33 ## | |
34 ## The return value @var{h} is a graphics handle to the created figure object. | |
35 ## | |
36 ## Programming Note: The full list of properties is documented at | |
37 ## @ref{Figure Properties}. This function differs from @code{figure} in that | |
38 ## the created figure is optimized for application development, rather than | |
39 ## plotting. This means features such as menubars and toolbars are turned off. | |
40 ## @seealso{uipanel, uibuttongroup} | |
41 ## @end deftypefn | |
42 | |
43 ## FIXME: This is not a perfect replica of a Matlab uifigure object because | |
44 ## some ordinary figure object properties are exposed (e.g., the "PaperXXX" | |
45 ## properties). In addition, the following properties are missing: | |
46 ## "AutoResizeChildren", "Icon", "Scrollable". | |
47 | |
48 function h = uifigure (varargin) | |
49 | |
50 if (mod (nargin, 2) != 0) | |
51 error ("uifigure: PROPERTY/VALUE parameters must occur in pairs"); | |
52 endif | |
53 | |
54 h = __go_figure__ (NaN, "handlevisibility", "off", | |
55 "numbertitle", "off", "integerhandle", "off", | |
31021
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
56 "menubar", "none", "toolbar", "none"); |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
57 |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
58 ## Add uifigure-specific properties on top of regular figure graphics object |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
59 ## FIXME: There is no implementation behind these properties. |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
60 addproperty ("AutoResizeChildren", h, "boolean", "on"); |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
61 addproperty ("Scrollable", h, "boolean", "off"); |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
62 |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
63 ## Apply any overrides. |
31237
e3016248ca5d
uifigure.m: Call set () only if varargin is not empty (bug #63088)
John Donoghue <john.donoghue@ieee.org>
parents:
31021
diff
changeset
|
64 if (! isempty (varargin)) |
e3016248ca5d
uifigure.m: Call set () only if varargin is not empty (bug #63088)
John Donoghue <john.donoghue@ieee.org>
parents:
31021
diff
changeset
|
65 set (h, varargin{:}); |
e3016248ca5d
uifigure.m: Call set () only if varargin is not empty (bug #63088)
John Donoghue <john.donoghue@ieee.org>
parents:
31021
diff
changeset
|
66 endif |
31005 | 67 |
68 endfunction | |
69 | |
70 | |
71 %!test | |
72 %! hf = uifigure ("visible", "off"); | |
73 %! unwind_protect | |
74 %! assert (isfigure (hf)); | |
31021
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
75 %! assert (get (hf, {"numbertitle", "menubar", "scrollable"}), |
f44e19671777
uifgure.m: Add additional uifigure-specific properties for Matlab compatibility.
Rik <rik@octave.org>
parents:
31005
diff
changeset
|
76 %! {"off", "none", "off"}); |
31005 | 77 %! unwind_protect_cleanup |
78 %! close (hf); | |
79 %! end_unwind_protect | |
80 | |
81 %!error <parameters must occur in pairs> uifigure ("PROP1") |