Mercurial > octave
annotate scripts/gui/waitbar.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 0a5b15007766 |
children | a40c0b7aa376 |
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 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3 ## Copyright (C) 2012-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
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/>. |
13803 | 7 ## |
8 ## This file is part of Octave. | |
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 |
13803 | 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. |
13803 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
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. |
13803 | 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 | |
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 ######################################################################## |
13803 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
27 ## @deftypefn {} {@var{h} =} waitbar (@var{frac}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
28 ## @deftypefnx {} {@var{h} =} waitbar (@var{frac}, @var{msg}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
29 ## @deftypefnx {} {@var{h} =} waitbar (@dots{}, "createcancelbtn", @var{fcn}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
30 ## @deftypefnx {} {@var{h} =} waitbar (@dots{}, @var{prop}, @var{val}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
31 ## @deftypefnx {} {} waitbar (@var{frac}) |
21819
972a06f5fa02
Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
32 ## @deftypefnx {} {} waitbar (@var{frac}, @var{h}) |
972a06f5fa02
Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
33 ## @deftypefnx {} {} waitbar (@var{frac}, @var{h}, @var{msg}) |
972a06f5fa02
Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
34 ## Return a handle @var{h} to a new progress indicator ("waitbar") object. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14313
diff
changeset
|
35 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14313
diff
changeset
|
36 ## The waitbar is filled to fraction @var{frac} which must be in the range |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
37 ## [0, 1]. |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
38 ## |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
39 ## The optional message @var{msg} is centered and displayed above the waitbar. |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
40 ## |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
41 ## A cancel button can be added to the bottom of the waitbar using the |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20715
diff
changeset
|
42 ## @qcode{"createcancelbtn"} property of waitbar figures. The action to be |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
43 ## executed when the user presses the button is specified using a string or |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
44 ## function handle @var{fcn}. |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
45 ## |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
46 ## The appearance of the waitbar figure window can be configured by passing |
28733
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
27923
diff
changeset
|
47 ## @var{prop}/@var{val} pairs to the function. The full list of properties is |
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
27923
diff
changeset
|
48 ## documented at @ref{Figure Properties}. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18578
diff
changeset
|
49 ## |
13832
2e4252228f73
waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents:
13822
diff
changeset
|
50 ## When called with a single input the current waitbar, if it exists, is |
2e4252228f73
waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents:
13822
diff
changeset
|
51 ## updated to the new value @var{frac}. If there are multiple outstanding |
21819
972a06f5fa02
Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
52 ## waitbars they can be updated individually by passing the handle @var{h} |
13832
2e4252228f73
waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents:
13822
diff
changeset
|
53 ## of the specific waitbar to modify. |
21819
972a06f5fa02
Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
54 ## |
972a06f5fa02
Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
55 ## @seealso{delete} |
13803 | 56 ## @end deftypefn |
57 | |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
58 function h = waitbar (varargin) |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
59 |
13806 | 60 persistent curr_waitbar; |
61 | |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
62 if (nargin < 1) |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
63 print_usage (); |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
64 endif |
13803 | 65 |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
66 frac = varargin{1}; |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
67 varargin(1) = []; |
13803 | 68 |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
69 if (! (isnumeric (frac) && isscalar (frac) && frac >= 0 && frac <= 1)) |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
70 error ("waitbar: FRAC must be between 0 and 1"); |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
71 endif |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
72 |
13821
4d1927edf194
waitbar: use previous bar if nargin == 1, not nargout == 1
John W. Eaton <jwe@octave.org>
parents:
13818
diff
changeset
|
73 ## Use existing waitbar if it still points to a valid graphics handle. |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
74 if (nargin == 1 && ishghandle (curr_waitbar)) |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
75 hf = curr_waitbar; |
13806 | 76 else |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
77 hf = false; |
13806 | 78 endif |
13803 | 79 |
13817
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
80 if (! isempty (varargin) && isnumeric (varargin{1})) |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
81 hf = varargin{1}; |
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
82 varargin(1) = []; |
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
83 if (! isfigure (hf) || ! strcmp (get (hf, "tag"), "waitbar")) |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
84 error ("waitbar: H must be a handle to a waitbar object"); |
13803 | 85 endif |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
86 endif |
13803 | 87 |
13817
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
88 msg = false; |
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
89 |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
90 if (! isempty (varargin)) |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
91 msg = varargin{1}; |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
92 varargin(1) = []; |
13847
9fc597693b0b
allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents:
13832
diff
changeset
|
93 if (! (ischar (msg) || iscellstr (msg))) |
9fc597693b0b
allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents:
13832
diff
changeset
|
94 error ("waitbar: MSG must be a character string or cell array of strings"); |
13803 | 95 endif |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
96 endif |
13803 | 97 |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
98 if (rem (numel (varargin), 2) != 0) |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
99 error ("waitbar: invalid number of property/value pairs"); |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
100 endif |
13803 | 101 |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
102 if (hf) |
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
103 gd = get (hf, "__guidata__"); |
17141
13da13e1e17f
waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents:
17122
diff
changeset
|
104 ## Get the cached handles. |
13da13e1e17f
waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents:
17122
diff
changeset
|
105 ax = gd(1); |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
106 hp = gd(2); |
17141
13da13e1e17f
waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents:
17122
diff
changeset
|
107 |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
108 set (hp, "xdata", [0; frac; frac; 0]); |
17141
13da13e1e17f
waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents:
17122
diff
changeset
|
109 |
13847
9fc597693b0b
allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents:
13832
diff
changeset
|
110 if (ischar (msg) || iscellstr (msg)) |
13806 | 111 th = get (ax, "title"); |
112 curr_msg = get (th, "string"); | |
14238
1facbe04b00c
Fix regression in 9fc597693b0b preventing updating of waitbar text string.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
113 ## graphics handles always store data as column vectors |
1facbe04b00c
Fix regression in 9fc597693b0b preventing updating of waitbar text string.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
114 if (iscellstr (msg)) |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18578
diff
changeset
|
115 msg = msg(:); |
14238
1facbe04b00c
Fix regression in 9fc597693b0b preventing updating of waitbar text string.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
116 endif |
13847
9fc597693b0b
allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents:
13832
diff
changeset
|
117 cmp = strcmp (msg, curr_msg); |
14238
1facbe04b00c
Fix regression in 9fc597693b0b preventing updating of waitbar text string.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
118 if (! all (cmp(:))) |
13806 | 119 set (th, "string", msg); |
120 endif | |
13803 | 121 endif |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
122 else |
17203
efd8963f925f
waitbar.m: Fix 2nd window pop-up when using gnuplot (bug #35773).
Rik <rik@octave.org>
parents:
17141
diff
changeset
|
123 ## Save and restore current figure |
efd8963f925f
waitbar.m: Fix 2nd window pop-up when using gnuplot (bug #35773).
Rik <rik@octave.org>
parents:
17141
diff
changeset
|
124 cf = get (0, "currentfigure"); |
efd8963f925f
waitbar.m: Fix 2nd window pop-up when using gnuplot (bug #35773).
Rik <rik@octave.org>
parents:
17141
diff
changeset
|
125 |
18495
1ec884e5ff00
waitbar.m: Force pixel units for waitbar figure (bug #41645).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
126 hf = figure ("units", "pixels", |
1ec884e5ff00
waitbar.m: Force pixel units for waitbar figure (bug #41645).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
127 "position", [250, 500, 400, 100], |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
128 "numbertitle", "off", |
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
129 "menubar", "none", "toolbar", "none", |
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
130 "integerhandle", "off", |
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
131 "handlevisibility", "callback", |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
132 "tag", "waitbar"); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
133 |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
134 ax = axes ("parent", hf, |
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
135 "xtick", [], "ytick", [], |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
136 "xlim", [0, 1], "ylim", [0, 1], |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
137 "position", [0.1, 0.3, 0.8, 0.2]); |
13821
4d1927edf194
waitbar: use previous bar if nargin == 1, not nargout == 1
John W. Eaton <jwe@octave.org>
parents:
13818
diff
changeset
|
138 |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
139 ## Add createcancelbtn property |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
140 addproperty ("createcancelbtn", hf, "figurebuttondownfcn"); |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
141 ## FIXME: Can't add listener because of bug #55963. |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
142 #addlistener (hf, "createcancelbtn", {@updatecancelbutton, ax}); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
143 |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
144 if (! isempty (varargin)) |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
145 set (hf, varargin{:}); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
146 endif |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
147 |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
148 ## Add listener and create cancel button only after setting properties |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
149 ## which could change "createcancelbtn" property (bug #55963). |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
150 addlistener (hf, "createcancelbtn", {@updatecancelbutton, ax}); |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
151 if (any (strcmp ("createcancelbtn", varargin))) |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
152 updatecancelbutton (hf, [], ax); |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
153 endif |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
154 |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
155 hp = patch (ax, [0; frac; frac; 0], [0; 0; 1; 1], [0, 0.35, 0.75]); |
17141
13da13e1e17f
waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents:
17122
diff
changeset
|
156 |
13da13e1e17f
waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents:
17122
diff
changeset
|
157 ## Cache the axes and patch handles. |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
158 set (hf, "__guidata__", [ax, hp]); |
13806 | 159 |
13847
9fc597693b0b
allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents:
13832
diff
changeset
|
160 if (! (ischar (msg) || iscellstr (msg))) |
13822
38e3bfc4e076
provide default message for waitbar
John W. Eaton <jwe@octave.org>
parents:
13821
diff
changeset
|
161 msg = "Please wait..."; |
13806 | 162 endif |
13822
38e3bfc4e076
provide default message for waitbar
John W. Eaton <jwe@octave.org>
parents:
13821
diff
changeset
|
163 title (ax, msg); |
17203
efd8963f925f
waitbar.m: Fix 2nd window pop-up when using gnuplot (bug #35773).
Rik <rik@octave.org>
parents:
17141
diff
changeset
|
164 |
18578
02a61d7c2de0
waitbar.m: Fix regression of plots openin in waitbar window (bug #41914).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
165 set (0, "currentfigure", cf); |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
166 endif |
13803 | 167 |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
168 drawnow (); |
13803 | 169 |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
170 if (nargout > 0) |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
171 h = hf; |
13803 | 172 endif |
173 | |
13806 | 174 ## If there were no errors, update current waitbar. |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
175 curr_waitbar = hf; |
13806 | 176 |
13803 | 177 endfunction |
178 | |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
179 function updatecancelbutton (hf, ~, hax) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
180 |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
181 if (! strcmp (get (hf, "__graphics_toolkit__"), "qt")) |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
182 return; |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
183 endif |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
184 |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
185 hbtn = findobj (hf, "type", "uicontrol", "-and", "style", "pushbutton"); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
186 cb = get (hf, "createcancelbtn"); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
187 if (! isempty (cb)) |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
188 if (isempty (hbtn)) |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
189 units = get (hax, "units"); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
190 fpos = get (hf, "position"); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
191 set (hax, "units", "pixels"); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
192 apos = get (hax, "position"); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
193 |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
194 fpos(2) -= 40; |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
195 fpos(4) += 40; |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
196 apos(2) += 40; |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
197 set (hf, "position", fpos); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
198 set (hax, "position", apos, "units", units); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
199 |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
200 hbtn = uicontrol (hf, "style", "pushbutton", "string", "Cancel", ... |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
201 "position", [fpos(3)-100, 10, 60, 25], ... |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
202 "callback", cb); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
203 else |
21385
89fa0694aa2e
Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
204 set (hbtn, "callback", cb); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
205 endif |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
206 elseif (! isempty (hbtn)) |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
207 delete (hbtn); |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
208 units = get (hax, "units"); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
209 fpos = get (hf, "position"); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
210 set (hax, "units", "pixels"); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
211 apos = get (hax, "position"); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
212 |
26989
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
213 fpos(2) += 40; |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
214 fpos(4) -= 40; |
a7ad08ed3cb7
waitbar.m: Fix hang when using "createcancelbtn" property (bug #55963).
Rik <rik@octave.org>
parents:
26617
diff
changeset
|
215 apos(2) -= 40; |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
216 set (hf, "position", fpos); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
217 set (hax, "position", apos, "units", units); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
218 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
219 |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
220 endfunction |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
221 |
13817
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
222 |
13803 | 223 %!demo |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
224 %! h = waitbar (0, '0.00%'); |
13803 | 225 %! for i = 0:0.01:1 |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
226 %! waitbar (i, h, sprintf ('%.2f%%', 100*i)); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
227 %! if (strcmp (graphics_toolkit (), "qt")) |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
228 %! pause (0.01); |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
229 %! endif |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21819
diff
changeset
|
230 %! endfor |
13806 | 231 %! close (h); |
232 | |
233 %!demo | |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
234 %! h = waitbar (0, 'please wait...'); |
13818
a05e5db7b94e
have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents:
13817
diff
changeset
|
235 %! for i = 0:0.01:0.6 |
13817
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
236 %! waitbar (i); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
237 %! if (strcmp (graphics_toolkit (), "qt")) |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
238 %! pause (0.01); |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
239 %! endif |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21819
diff
changeset
|
240 %! endfor |
14112
6e9fee72a01c
Add missing ";" to line in waitbar.m demo.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
13847
diff
changeset
|
241 %! i = 0.3; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
242 %! waitbar (i, h, 'don''t you hate taking a step backward?'); |
13832
2e4252228f73
waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents:
13822
diff
changeset
|
243 %! pause (0.5); |
13818
a05e5db7b94e
have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents:
13817
diff
changeset
|
244 %! for i = i:0.005:0.7 |
a05e5db7b94e
have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents:
13817
diff
changeset
|
245 %! waitbar (i, h); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
246 %! if (strcmp (graphics_toolkit (), "qt")) |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
247 %! pause (0.01); |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
248 %! endif |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21819
diff
changeset
|
249 %! endfor |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
250 %! waitbar (i, h, 'or stalling?'); |
13832
2e4252228f73
waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents:
13822
diff
changeset
|
251 %! pause (1); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
252 %! for i = i:0.003:0.85 |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
253 %! waitbar (i, h, 'just a little longer now'); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
254 %! if (strcmp (graphics_toolkit (), "qt")) |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
255 %! pause (0.01); |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
256 %! endif |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21819
diff
changeset
|
257 %! endfor |
13818
a05e5db7b94e
have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents:
13817
diff
changeset
|
258 %! for i = i:0.001:1 |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
259 %! waitbar (i, h, 'please don''t be impatient'); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
260 %! if (strcmp (graphics_toolkit (), "qt")) |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
261 %! pause (0.01); |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
262 %! endif |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21819
diff
changeset
|
263 %! endfor |
13806 | 264 %! close (h); |
265 | |
266 %!demo | |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
267 %! h1 = waitbar (0, 'Waitbar #1'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
268 %! h2 = waitbar (0, 'Waitbar #2'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
269 %! h2pos = get (h2, 'position'); |
14249
27abe77158d6
Changes to allow plot demos to be converted and run by Matlab.
Ben Abbott <bpabbott@mac.com>
parents:
14245
diff
changeset
|
270 %! h2pos(1) = h2pos(1) + (h2pos(3) + 50); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
271 %! set (h2, 'position', h2pos); |
13832
2e4252228f73
waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents:
13822
diff
changeset
|
272 %! pause (0.5); |
13817
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
273 %! for i = 1:4 |
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
274 %! waitbar (i/4, h1); |
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
275 %! pause (0.5); |
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
276 %! waitbar (i/4, h2); |
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
277 %! pause (0.5); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21819
diff
changeset
|
278 %! endfor |
13832
2e4252228f73
waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents:
13822
diff
changeset
|
279 %! pause (0.5); |
13817
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
280 %! close (h1); |
b3e1f9ae64dc
waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents:
13816
diff
changeset
|
281 %! close (h2); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
282 |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
283 %!demo |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
284 %! clf (); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
285 %! niter = 7; |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
286 %! l = 1; |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
287 %! xx = [0 l]; |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
288 %! yy = [0 0]; |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
289 %! hli = plot (xx, yy); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
290 %! pos1 = get (gcf, "position"); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
291 %! |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
292 %! disp ("Push the <cancel> button to stop the process."); |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
293 %! hf = waitbar (0,"0","Name","Building Koch curve ...",... |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
294 %! "createcancelbtn", "setappdata (gcbf,'interrupt', true)"); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
295 %! |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
296 %! pos2 = get (hf, "position"); |
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
297 %! set (hf, "position", [pos1(1)+(pos1(3)-pos2(3))/2, pos1(2)+pos1(4), pos2(3:4)]); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
298 %! |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
299 %! for ii = 1:niter |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
300 %! ## Check cancel request |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
301 %! if (! ishghandle (hf)) |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
302 %! break; |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
303 %! elseif (getappdata (hf, "interrupt")) |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
304 %! delete (hf); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
305 %! break; |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
306 %! else |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
307 %! waitbar (ii/niter, hf, sprintf ("Step %d/%d", ii, niter)); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
308 %! endif |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
309 %! |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
310 %! ## Increasingly lengthy computation |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
311 %! l /= 3; |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
312 %! theta = angle (complex (diff (xx), diff (yy))); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
313 %! |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
314 %! xy = @(th, x0, y0) [cos(th) -sin(th) x0 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
315 %! sin(th) cos(th) y0] * [0 l l*3/2 2*l; |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
316 %! 0 0 l*(3)^.5/2 0; |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
317 %! 1 1 1 1]; |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
318 %! tmp = arrayfun (xy, theta, xx(1:end-1), yy(1:end-1), |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
319 %! "uniformoutput", false); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
320 %! |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
321 %! tmp = cell2mat (tmp); |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
322 %! xx = [tmp(1,:) xx(end)]; |
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
323 %! yy = [tmp(2,:) yy(end)]; |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
324 %! set (hli, "xdata", xx, "ydata", yy); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
325 %! drawnow (); |
26015
2e97124a71da
waitbar.m: Redo %!demos to be slower with qt toolkit and display better (bug #54935).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
326 %! pause (0.75); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
327 %! endfor |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20271
diff
changeset
|
328 %! |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
329 %! if (ishghandle (hf)) |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
330 %! delete (hf); |
20271
ae68b331d6e4
waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20173
diff
changeset
|
331 %! endif |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
332 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
333 ## Test input validation |
13805
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
334 %!error <FRAC must be between 0 and 1> waitbar (-0.5) |
b3cdef33ac0e
waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents:
13803
diff
changeset
|
335 %!error <FRAC must be between 0 and 1> waitbar (1.5) |
13813
72875370e2d1
allow waitbar test to succeed even if figure 1 exists
John W. Eaton <jwe@octave.org>
parents:
13806
diff
changeset
|
336 %!error <MSG must be a character string> waitbar (0.5, struct ()) |
17447
359366a4994f
waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents:
17203
diff
changeset
|
337 %!error <invalid number of property/value pairs> waitbar (0.5, "msg", "Name") |