annotate scripts/gui/guihandles.m @ 33617:ec2635a02328 bytecode-interpreter tip

maint: Merge default to bytecode-interpreter.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 21 May 2024 18:29:03 +0200
parents 2e484f9f1f18
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
3 ## Copyright (C) 2012-2024 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
7 ##
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
8 ## This file is part of Octave.
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
14 ##
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
19 ##
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
25
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
27 ## @deftypefn {} {@var{hdata} =} guihandles (@var{h})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
28 ## @deftypefnx {} {@var{hdata} =} guihandles
17485
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
29 ## Return a structure of object handles for the figure associated with
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
30 ## handle @var{h}.
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
31 ##
17485
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
32 ## If no handle is specified the current figure returned by @code{gcf} is used.
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17122
diff changeset
33 ##
17485
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
34 ## The fieldname for each entry of @var{hdata} is taken from the @qcode{"tag"}
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
35 ## property of the graphic object. If the tag is empty then the handle is not
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
36 ## returned. If there are multiple graphic objects with the same tag then
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
37 ## the entry in @var{hdata} will be a vector of handles. @code{guihandles}
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
38 ## includes all possible handles, including those for
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
39 ## which @qcode{"HandleVisibility"} is @qcode{"off"}.
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
40 ## @seealso{guidata, findobj, findall, allchild}
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
41 ## @end deftypefn
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
42
17485
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
43 function hdata = guihandles (h)
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
44
17485
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
45 if (nargin == 1)
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 23220
diff changeset
46 if (! ishghandle (h))
17485
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
47 error ("guidata: H must be a valid object handle");
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
48 endif
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
49 h = ancestor (h, "figure");
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
50 if (isempty (h))
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
51 error ("guidata: no ancestor figure of H found");
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
52 endif
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
53 else
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
54 h = gcf ();
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
55 endif
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
56
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
57 hdata = __make_guihandles_struct__ (h, []);
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
58
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
59 endfunction
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
60
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
61 function hdata = __make_guihandles_struct__ (h, hdata)
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
62
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
63 tag = get (h, "tag");
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
64 if (! isempty (tag))
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
65 if (isfield (hdata, tag))
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
66 hdata.(tag) = [hdata.(tag), h];
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
67 else
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
68 try
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
69 hdata.(tag) = h;
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
70 catch
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
71 end_try_catch
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
72 endif
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
73 endif
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
74
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
75 kids = allchild (h);
17485
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
76 for hkid = kids'
edd15fceff14 guihandles.m: Overhaul function.
Rik <rik@octave.org>
parents: 17338
diff changeset
77 hdata = __make_guihandles_struct__ (hkid, hdata);
13699
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
78 endfor
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
79
dd9b32af0a01 Implement guidata/guihandles.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
80 endfunction