annotate scripts/gui/waitbar.m @ 21819:972a06f5fa02

Clarify docs for waitbar (bug #48094) * waitbar.m: Add see also for delete. Explain what a waitbar is. Clarify that HWBAR is the same as H.
author Lachlan Andrew <lachlanbis@gmail.com>
date Fri, 03 Jun 2016 12:59:50 +1000
parents ffad2baa90f7
children 1c4cd12987f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19594
diff changeset
1 ## Copyright (C) 2012-2015 John W. Eaton
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 ## This file is part of Octave.
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## your option) any later version.
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ## General Public License for more details.
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20716
diff changeset
20 ## @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
21 ## @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
22 ## @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
23 ## @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
24 ## @deftypefnx {} {} waitbar (@var{frac})
21819
972a06f5fa02 Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21758
diff changeset
25 ## @deftypefnx {} {} waitbar (@var{frac}, @var{h})
972a06f5fa02 Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21758
diff changeset
26 ## @deftypefnx {} {} waitbar (@var{frac}, @var{h}, @var{msg})
972a06f5fa02 Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21758
diff changeset
27 ## 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
28 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14313
diff changeset
29 ## 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
30 ## [0, 1].
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
31 ##
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 ## 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
33 ##
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
34 ## 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
35 ## @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
36 ## 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
37 ## function handle @var{fcn}.
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
38 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
39 ## The appearance of the waitbar figure window can be configured by passing
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
40 ## @var{prop}/@var{val} pairs to the function.
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18578
diff changeset
41 ##
13832
2e4252228f73 waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents: 13822
diff changeset
42 ## 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
43 ## 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
44 ## 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
45 ## of the specific waitbar to modify.
21819
972a06f5fa02 Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21758
diff changeset
46 ##
972a06f5fa02 Clarify docs for waitbar (bug #48094)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21758
diff changeset
47 ## @seealso{delete}
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 ## @end deftypefn
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 ## Author: jwe
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
52 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
53
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
54 persistent curr_waitbar;
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
55
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
56 if (nargin < 1)
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
57 print_usage ();
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
58 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
60 frac = varargin{1};
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
61 varargin(1) = [];
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
63 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
64 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
65 endif
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
66
13821
4d1927edf194 waitbar: use previous bar if nargin == 1, not nargout == 1
John W. Eaton <jwe@octave.org>
parents: 13818
diff changeset
67 ## Use existing waitbar if it still points to a valid graphics handle.
4d1927edf194 waitbar: use previous bar if nargin == 1, not nargout == 1
John W. Eaton <jwe@octave.org>
parents: 13818
diff changeset
68 if (nargin == 1 && ishandle (curr_waitbar))
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
69 hf = curr_waitbar;
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
70 else
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
71 hf = false;
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
72 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
74 if (! isempty (varargin) && isnumeric (varargin{1}))
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
75 hf = varargin{1};
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
76 varargin(1) = [];
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
77 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
78 error ("waitbar: H must be a handle to a waitbar object");
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
80 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
82 msg = false;
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
83
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
84 if (! isempty (varargin))
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
85 msg = varargin{1};
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
86 varargin(1) = [];
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
87 if (! (ischar (msg) || iscellstr (msg)))
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
88 error ("waitbar: MSG must be a character string or cell array of strings");
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
90 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
92 if (rem (numel (varargin), 2) != 0)
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
93 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
94 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
96 if (hf)
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
97 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
98 ## 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
99 ax = gd(1);
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
100 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
101
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
102 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
103
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
104 if (ischar (msg) || iscellstr (msg))
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
105 th = get (ax, "title");
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
106 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
107 ## 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
108 if (iscellstr (msg))
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18578
diff changeset
109 msg = msg(:);
14238
1facbe04b00c Fix regression in 9fc597693b0b preventing updating of waitbar text string.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
110 endif
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
111 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
112 if (! all (cmp(:)))
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
113 set (th, "string", msg);
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
114 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
116 else
17203
efd8963f925f waitbar.m: Fix 2nd window pop-up when using gnuplot (bug #35773).
Rik <rik@octave.org>
parents: 17141
diff changeset
117 ## 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
118 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
119
18495
1ec884e5ff00 waitbar.m: Force pixel units for waitbar figure (bug #41645).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17744
diff changeset
120 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
121 "position", [250, 500, 400, 100],
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
122 "numbertitle", "off",
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
123 "menubar", "none", "toolbar", "none",
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
124 "integerhandle", "off",
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
125 "handlevisibility", "callback",
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
126 "tag", "waitbar");
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
127
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
128 ax = axes ("parent", hf,
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
129 "xtick", [], "ytick", [],
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
130 "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
131 "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
132
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
133 ## Add createcancelbtn property
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
134 addproperty ("createcancelbtn", hf, "figurebuttondownfcn");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
135 addlistener (hf, "createcancelbtn", {@updatecancelbutton, ax});
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
136
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
137 if (! isempty (varargin))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
138 set (hf, varargin{:});
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
139 endif
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
140
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
141 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
142
13da13e1e17f waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents: 17122
diff changeset
143 ## Cache the axes and patch handles.
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
144 set (hf, "__guidata__", [ax hp]);
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
145
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
146 if (! (ischar (msg) || iscellstr (msg)))
13822
38e3bfc4e076 provide default message for waitbar
John W. Eaton <jwe@octave.org>
parents: 13821
diff changeset
147 msg = "Please wait...";
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
148 endif
13822
38e3bfc4e076 provide default message for waitbar
John W. Eaton <jwe@octave.org>
parents: 13821
diff changeset
149 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
150
18578
02a61d7c2de0 waitbar.m: Fix regression of plots openin in waitbar window (bug #41914).
Rik <rik@octave.org>
parents: 17744
diff changeset
151 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
152 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
154 drawnow ();
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
156 if (nargout > 0)
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
157 h = hf;
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 endif
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
160 ## If there were no errors, update current waitbar.
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
161 curr_waitbar = hf;
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
162
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 endfunction
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
165 function updatecancelbutton (hf, dummy, hax)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21580
diff changeset
166
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
167 if (! strcmpi (get (hf, "__graphics_toolkit__"), "qt"))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
168 return
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
169 endif
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
170
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
171 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
172 cb = get (hf, "createcancelbtn");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
173 if (! isempty (cb))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
174 if (isempty (hbtn))
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 21385
diff changeset
175 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
176 fpos = get (hf, "position");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
177 set (hax, "units", "pixels");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
178 apos = get (hax, "position");
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
179
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
180 fpos (2) -= 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
181 fpos (4) += 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
182 apos (2) += 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
183 set (hf, "position", fpos);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
184 set (hax, "position", apos, "units", units);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
185
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
186 hbtn = uicontrol ("style", "pushbutton", "string", "Cancel", ...
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
187 "position", [fpos(3)-100 10 60 25],...
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
188 "callback", cb, "parent", hf);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
189 else
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
190 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
191 endif
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
192 elseif (! isempty (hbtn))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
193 delete (hbtn);
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 21385
diff changeset
194 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
195 fpos = get (hf, "position");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
196 set (hax, "units", "pixels");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
197 apos = get (hax, "position");
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
198
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
199 fpos (2) += 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
200 fpos (4) -= 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
201 apos (2) -= 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
202 set (hf, "position", fpos);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
203 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
204 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21580
diff changeset
205
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
206 endfunction
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
207
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
208
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
210 %! h = waitbar (0, '0.00%');
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211 %! 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
212 %! waitbar (i, h, sprintf ('%.2f%%', 100*i));
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
213 %! end
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
214 %! close (h);
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
215
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
216 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
217 %! h = waitbar (0, 'please wait...');
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
218 %! for i = 0:0.01:0.6
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
219 %! waitbar (i);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
220 %! end
14112
6e9fee72a01c Add missing ";" to line in waitbar.m demo.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 13847
diff changeset
221 %! i = 0.3;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
222 %! 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
223 %! pause (0.5);
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
224 %! 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
225 %! waitbar (i, h);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
226 %! end
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
227 %! 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
228 %! pause (1);
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
229 %! for i = i:0.003:0.8
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
230 %! waitbar (i, h, 'just a little longer now');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
231 %! end
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
232 %! 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
233 %! waitbar (i, h, 'please don''t be impatient');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
234 %! end
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
235 %! close (h);
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
236
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
237 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
238 %! h1 = waitbar (0, 'Waitbar #1');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
239 %! h2 = waitbar (0, 'Waitbar #2');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
240 %! 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
241 %! 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
242 %! set (h2, 'position', h2pos);
13832
2e4252228f73 waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents: 13822
diff changeset
243 %! pause (0.5);
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
244 %! for i = 1:4
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
245 %! waitbar (i/4, h1);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
246 %! pause (0.5);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
247 %! waitbar (i/4, h2);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
248 %! pause (0.5);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
249 %! end
13832
2e4252228f73 waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents: 13822
diff changeset
250 %! pause (0.5);
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
251 %! close (h1);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
252 %! close (h2);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
253
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
254 %!demo
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
255 %! clf ();
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
256 %! niter = 9;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
257 %! l = 1;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
258 %! xx = [0 l];
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
259 %! yy = [0 0];
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
260 %! hli = plot (xx, yy);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
261 %!
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
262 %! disp ("Push the cancel to stop the process.");
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
263 %! hf = waitbar(0,"0","Name","Building Koch curve ...",...
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
264 %! "createcancelbtn", "setappdata (gcbf,'interrupt', true)");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
265 %! for ii = 1:niter
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
266 %! ## Check cancel request
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
267 %! if (! ishandle (hf))
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
268 %! break;
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
269 %! elseif (getappdata (hf, "interrupt"))
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
270 %! delete (hf);
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
271 %! break;
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
272 %! else
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
273 %! 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
274 %! endif
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
275 %!
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
276 %! ## Increasingly lengthy computation
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
277 %! l /= 3;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
278 %! theta = angle (complex (diff (xx), diff (yy)));
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
279 %!
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
280 %! 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
281 %! 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
282 %! 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
283 %! 1 1 1 1];
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
284 %! tmp = arrayfun (xy, theta, xx(1:end-1), yy(1:end-1),
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
285 %! "uniformoutput", false);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
286 %!
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
287 %! tmp = cell2mat (tmp);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
288 %! 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
289 %! yy = [tmp(2,:) yy(end)];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
290 %! 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
291 %! drawnow ();
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
292 %! pause (0.5);
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
293 %! endfor
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
294 %!
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
295 %! if (ishandle (hf))
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
296 %! delete (hf);
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
297 %! endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
298
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
299 ## 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
300 %!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
301 %!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
302 %!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
303 %!error <invalid number of property/value pairs> waitbar (0.5, "msg", "Name")
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
304