annotate scripts/gui/uipushtool.m @ 33645:42355b7ec5d7 bytecode-interpreter tip

maint: Merge default to bytecode-interpreter.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Tue, 04 Jun 2024 11:00:11 -0400
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: 26877
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/>.
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
7 ##
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
8 ## This file is part of Octave.
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
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: 23567
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
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: 23567
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.
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
14 ##
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
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.
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
19 ##
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
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: 23567
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 ########################################################################
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
25
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
26 ## -*- texinfo -*-
31664
505ed551e366 doc: Ensure DOCSTRING has an output when function returns a value (bug #61681)
Rik <rik@octave.org>
parents: 30875
diff changeset
27 ## @deftypefn {} {@var{hui} =} uipushtool ()
505ed551e366 doc: Ensure DOCSTRING has an output when function returns a value (bug #61681)
Rik <rik@octave.org>
parents: 30875
diff changeset
28 ## @deftypefnx {} {@var{hui} =} uipushtool (@var{property}, @var{value}, @dots{})
505ed551e366 doc: Ensure DOCSTRING has an output when function returns a value (bug #61681)
Rik <rik@octave.org>
parents: 30875
diff changeset
29 ## @deftypefnx {} {@var{hui} =} uipushtool (@var{parent})
505ed551e366 doc: Ensure DOCSTRING has an output when function returns a value (bug #61681)
Rik <rik@octave.org>
parents: 30875
diff changeset
30 ## @deftypefnx {} {@var{hui} =} uipushtool (@var{parent}, @var{property}, @var{value}, @dots{})
20597
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
31 ##
23271
cc9dcadcef6b Only return a handle from ui* functions if nargout > 0 (bug #49751).
Rik <rik@octave.org>
parents: 23220
diff changeset
32 ## Create a uipushtool object.
20597
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
33 ##
20716
1ecee53513d7 doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents: 20715
diff changeset
34 ## uipushtools are buttons that appear on a figure toolbar. The button is
20768
7655b399abff eliminate trailing whitespace in source files we maintain
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
35 ## created with a border that is shown when the user hovers over the button.
20716
1ecee53513d7 doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents: 20715
diff changeset
36 ## An image can be set using the cdata property.
20597
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
37 ##
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
38 ## If @var{parent} is omitted then a uipushtool for the current figure is
20716
1ecee53513d7 doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents: 20715
diff changeset
39 ## created. If no figure is available, a new figure is created first. If a
1ecee53513d7 doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents: 20715
diff changeset
40 ## figure is available, but does not contain a uitoolbar, a uitoolbar will be
1ecee53513d7 doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents: 20715
diff changeset
41 ## created.
20597
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
42 ##
23567
71bfd507663c doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents: 23396
diff changeset
43 ## If @var{parent} is given then a uipushtool is created on the @var{parent}
71bfd507663c doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents: 23396
diff changeset
44 ## uitoolbar.
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20615
diff changeset
45 ##
20716
1ecee53513d7 doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents: 20715
diff changeset
46 ## Any provided property value pairs will override the default values of the
1ecee53513d7 doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents: 20715
diff changeset
47 ## created uipushtool object.
20597
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
48 ##
26877
83774c2a1b92 doc: Place cross-reference from list of graphics object properties back to object (bug #46076).
Rik <rik@octave.org>
parents: 26376
diff changeset
49 ## The full list of properties is documented at @ref{Uipushtool Properties}.
20615
93d96da9ff3e Update uiXXXXX documentation for autogenerated properties
John Donoghue
parents: 20597
diff changeset
50 ##
23271
cc9dcadcef6b Only return a handle from ui* functions if nargout > 0 (bug #49751).
Rik <rik@octave.org>
parents: 23220
diff changeset
51 ## The optional return value @var{hui} is a graphics handle to the created
23567
71bfd507663c doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents: 23396
diff changeset
52 ## uipushtool object.
23271
cc9dcadcef6b Only return a handle from ui* functions if nargout > 0 (bug #49751).
Rik <rik@octave.org>
parents: 23220
diff changeset
53 ##
20597
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
54 ## Examples:
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
55 ##
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
56 ## @example
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
57 ## @group
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
58 ## % create figure without a default toolbar
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
59 ## f = figure ("toolbar", "none");
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
60 ## % create empty toolbar
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
61 ## t = uitoolbar (f);
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
62 ## % create a 19x19x3 black square
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
63 ## img=zeros(19,19,3);
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
64 ## % add pushtool button to toolbar
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
65 ## b = uipushtool (t, "cdata", img);
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
66 ## @end group
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
67 ## @end example
7890893a0e69 Add uiXXXX documentation (Bug #46076)
John Donoghue <john.donoghue@ieee.org>
parents: 19833
diff changeset
68 ## @seealso{figure, uitoolbar, uitoggletool}
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
69 ## @end deftypefn
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
70
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
71 function hui = uipushtool (varargin)
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
72
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
73 [h, args] = __uiobject_split_args__ ("uipushtool", varargin,
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
74 {"uitoolbar"}, 0);
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
75 if (isempty (h))
13726
5a2734f26dbc Create uitoolbar only when necessary.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
76 h = findobj (gcf, "-depth", 1, "type", "uitoolbar");
5a2734f26dbc Create uitoolbar only when necessary.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
77 if (isempty (h))
5a2734f26dbc Create uitoolbar only when necessary.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
78 h = uitoolbar ();
5a2734f26dbc Create uitoolbar only when necessary.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
79 else
5a2734f26dbc Create uitoolbar only when necessary.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
80 h = h(1);
5a2734f26dbc Create uitoolbar only when necessary.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
81 endif
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
82 endif
23396
945b53af4655 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 23271
diff changeset
83
23271
cc9dcadcef6b Only return a handle from ui* functions if nargout > 0 (bug #49751).
Rik <rik@octave.org>
parents: 23220
diff changeset
84 htmp = __go_uipushtool__ (h, args{:});
23396
945b53af4655 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 23271
diff changeset
85
23271
cc9dcadcef6b Only return a handle from ui* functions if nargout > 0 (bug #49751).
Rik <rik@octave.org>
parents: 23220
diff changeset
86 if (nargout > 0)
cc9dcadcef6b Only return a handle from ui* functions if nargout > 0 (bug #49751).
Rik <rik@octave.org>
parents: 23220
diff changeset
87 hui = htmp;
cc9dcadcef6b Only return a handle from ui* functions if nargout > 0 (bug #49751).
Rik <rik@octave.org>
parents: 23220
diff changeset
88 endif
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
89
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
90 endfunction