annotate scripts/gui/waitbar.m @ 20716:1ecee53513d7

doc: Peridodic grammar check of documentation. * diffeq.txi, numbers.txi, symtab.cc, urlwrite.cc, mget.m, uicontextmenu.m, uicontrol.m, uipanel.m, uipushtool.m, uitoggletool.m, uitoolbar.m, waitbar.m, hsv2rgb.m, beep.m, textread.m, odeget.m, integrate_adaptive.m, integrate_const.m, annotation.m, surfnorm.m: Peridodic grammar check of documentation.
author Rik <rik@octave.org>
date Wed, 18 Nov 2015 17:24:47 -0800
parents 5b7643257978
children 516bb87ea72e
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 -*-
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
20 ## @deftypefn {Function File} {@var{h} =} waitbar (@var{frac})
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
21 ## @deftypefnx {Function File} {@var{h} =} waitbar (@var{frac}, @var{msg})
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
22 ## @deftypefnx {Function File} {@var{h} =} waitbar (@dots{}, "createcancelbtn", @var{fcn}, @dots{})
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
23 ## @deftypefnx {Function File} {@var{h} =} waitbar (@dots{}, @var{prop}, @var{val}, @dots{})
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
24 ## @deftypefnx {Function File} {} waitbar (@var{frac})
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
25 ## @deftypefnx {Function File} {} waitbar (@var{frac}, @var{hwbar})
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
26 ## @deftypefnx {Function File} {} waitbar (@var{frac}, @var{hwbar}, @var{msg})
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14313
diff changeset
27 ## Return a handle @var{h} to a new waitbar object.
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
2e4252228f73 waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents: 13822
diff changeset
44 ## waitbars they can be updated individually by passing the handle @var{hwbar}
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.
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 ## @end deftypefn
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 ## Author: jwe
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
50 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
51
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
52 persistent curr_waitbar;
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
53
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
54 if (nargin < 1)
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
55 print_usage ();
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
56 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
58 frac = varargin{1};
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
59 varargin(1) = [];
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
61 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
62 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
63 endif
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
64
13821
4d1927edf194 waitbar: use previous bar if nargin == 1, not nargout == 1
John W. Eaton <jwe@octave.org>
parents: 13818
diff changeset
65 ## 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
66 if (nargin == 1 && ishandle (curr_waitbar))
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
67 hf = curr_waitbar;
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
68 else
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
69 hf = false;
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
70 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
72 if (! isempty (varargin) && isnumeric (varargin{1}))
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
73 hf = varargin{1};
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
74 varargin(1) = [];
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
75 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
76 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
77 endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
78 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
80 msg = false;
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
81
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
82 if (! isempty (varargin))
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
83 msg = varargin{1};
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
84 varargin(1) = [];
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
85 if (! (ischar (msg) || iscellstr (msg)))
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
86 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
87 endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
88 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
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 (rem (numel (varargin), 2) != 0)
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
91 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
92 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
94 if (hf)
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
95 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
96 ## 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
97 ax = gd(1);
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
98 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
99
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
100 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
101
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
102 if (ischar (msg) || iscellstr (msg))
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
103 th = get (ax, "title");
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
104 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
105 ## 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
106 if (iscellstr (msg))
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18578
diff changeset
107 msg = msg(:);
14238
1facbe04b00c Fix regression in 9fc597693b0b preventing updating of waitbar text string.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
108 endif
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
109 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
110 if (! all (cmp(:)))
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
111 set (th, "string", msg);
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
112 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
114 else
17203
efd8963f925f waitbar.m: Fix 2nd window pop-up when using gnuplot (bug #35773).
Rik <rik@octave.org>
parents: 17141
diff changeset
115 ## 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
116 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
117
18495
1ec884e5ff00 waitbar.m: Force pixel units for waitbar figure (bug #41645).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17744
diff changeset
118 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
119 "position", [250, 500, 400, 100],
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
120 "numbertitle", "off",
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
121 "menubar", "none", "toolbar", "none",
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
122 "integerhandle", "off",
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
123 "handlevisibility", "callback",
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
124 "tag", "waitbar");
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
125
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
126 ax = axes ("parent", hf,
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
127 "xtick", [], "ytick", [],
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
128 "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
129 "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
130
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
131 ## Add createcancelbtn property
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
132 addproperty ("createcancelbtn", hf, "figurebuttondownfcn");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
133 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
134
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
135 if (! isempty (varargin))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
136 set (hf, varargin{:});
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
137 endif
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
138
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
139 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
140
13da13e1e17f waitbar.m: Cache axes and patch handles in figure's __guidata__.
Philipp Kutin <philipp.kutin@gmail.com>
parents: 17122
diff changeset
141 ## Cache the axes and patch handles.
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
142 set (hf, "__guidata__", [ax hp]);
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
143
13847
9fc597693b0b allow waitbar message to be a cellstr object
John W. Eaton <jwe@octave.org>
parents: 13832
diff changeset
144 if (! (ischar (msg) || iscellstr (msg)))
13822
38e3bfc4e076 provide default message for waitbar
John W. Eaton <jwe@octave.org>
parents: 13821
diff changeset
145 msg = "Please wait...";
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
146 endif
13822
38e3bfc4e076 provide default message for waitbar
John W. Eaton <jwe@octave.org>
parents: 13821
diff changeset
147 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
148
18578
02a61d7c2de0 waitbar.m: Fix regression of plots openin in waitbar window (bug #41914).
Rik <rik@octave.org>
parents: 17744
diff changeset
149 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
150 endif
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
152 drawnow ();
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 if (nargout > 0)
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
155 h = hf;
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 endif
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
158 ## If there were no errors, update current waitbar.
17447
359366a4994f waitbar.m: Use Octave coding conventions.
Rik <rik@octave.org>
parents: 17203
diff changeset
159 curr_waitbar = hf;
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
160
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 endfunction
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
163 function updatecancelbutton (hf, dummy, hax)
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
164 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
165 return
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
166 endif
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
167
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
168 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
169 cb = get (hf, "createcancelbtn");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
170 if (! isempty (cb))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
171 if (isempty (hbtn))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
172 units = get (hax, "units");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
173 fpos = get (hf, "position");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
174 set (hax, "units", "pixels");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
175 apos = get (hax, "position");
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
176
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
177 fpos (2) -= 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
178 fpos (4) += 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
179 apos (2) += 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
180 set (hf, "position", fpos);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
181 set (hax, "position", apos, "units", units);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
182
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
183 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
184 "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
185 "callback", cb, "parent", hf);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
186 else
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
187 set (hbtn, "callback", cb)
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
188 endif
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
189 elseif (! isempty (hbtn))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
190 delete (hbtn);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
191 units = get (hax, "units");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
192 fpos = get (hf, "position");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
193 set (hax, "units", "pixels");
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
194 apos = get (hax, "position");
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
195
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
196 fpos (2) += 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
197 fpos (4) -= 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
198 apos (2) -= 40;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
199 set (hf, "position", fpos);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
200 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
201 endif
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
202 endfunction
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
203
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
204
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
205 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
206 %! h = waitbar (0, '0.00%');
13803
a2e158c3451f provide the waitbar function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 %! 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
208 %! 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
209 %! end
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
210 %! close (h);
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
211
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
212 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
213 %! h = waitbar (0, 'please wait...');
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
214 %! for i = 0:0.01:0.6
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
215 %! waitbar (i);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
216 %! end
14112
6e9fee72a01c Add missing ";" to line in waitbar.m demo.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 13847
diff changeset
217 %! i = 0.3;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
218 %! 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
219 %! pause (0.5);
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
220 %! 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
221 %! waitbar (i, h);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
222 %! end
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
223 %! 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
224 %! pause (1);
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
225 %! 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
226 %! 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
227 %! end
13818
a05e5db7b94e have some fun with waitbar demo #2
John W. Eaton <jwe@octave.org>
parents: 13817
diff changeset
228 %! 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
229 %! 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
230 %! end
13806
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
231 %! close (h);
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
232
a73c0811d2fa more updates for waitbar
John W. Eaton <jwe@octave.org>
parents: 13805
diff changeset
233 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
234 %! h1 = waitbar (0, 'Waitbar #1');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
235 %! h2 = waitbar (0, 'Waitbar #2');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
236 %! 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
237 %! 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
238 %! set (h2, 'position', h2pos);
13832
2e4252228f73 waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents: 13822
diff changeset
239 %! pause (0.5);
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
240 %! for i = 1:4
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
241 %! waitbar (i/4, h1);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
242 %! pause (0.5);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
243 %! waitbar (i/4, h2);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
244 %! pause (0.5);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
245 %! end
13832
2e4252228f73 waitbar.m: Eliminate docstring reference to waitbar(frac,msg)
Rik <octave@nomad.inbox5.com>
parents: 13822
diff changeset
246 %! pause (0.5);
13817
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
247 %! close (h1);
b3e1f9ae64dc waitbar.m: More improvements.
Rik <octave@nomad.inbox5.com>
parents: 13816
diff changeset
248 %! close (h2);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
249
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
250 %!demo
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
251 %! clf ();
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
252 %! niter = 9;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
253 %! l = 1;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
254 %! xx = [0 l];
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
255 %! yy = [0 0];
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
256 %! hli = plot (xx, yy);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
257 %!
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
258 %! disp ("Push the cancel to stop the process.")
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
259 %! 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
260 %! "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
261 %! for ii = 1:niter
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
262 %! ## Check cancel request
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
263 %! if (! ishandle (hf))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
264 %! break
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
265 %! elseif (getappdata (hf, "interrupt"))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
266 %! delete (hf)
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
267 %! break
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
268 %! else
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
269 %! 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
270 %! endif
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
271 %!
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
272 %! ## Increasingly lengthy computation
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
273 %! l /= 3;
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
274 %! theta = angle (complex (diff (xx), diff (yy)));
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 %! 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
277 %! 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
278 %! 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
279 %! 1 1 1 1];
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
280 %! 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
281 %! "uniformoutput", false);
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 %! tmp = cell2mat (tmp);
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
284 %! 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
285 %! yy = [tmp(2,:) yy(end)];
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
286 %! set (hli, "xdata", xx, "ydata", yy)
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
287 %! drawnow ();
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
288 %! pause (0.5)
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
289 %! endfor
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20271
diff changeset
290 %!
20271
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
291 %! if (ishandle (hf))
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
292 %! delete (hf)
ae68b331d6e4 waitbar.m: add support for "createcancelbtn" property (bug #45364)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20173
diff changeset
293 %! endif
13805
b3cdef33ac0e waitbar.m: Update docstring. Only return output handle h if requested.
Rik <octave@nomad.inbox5.com>
parents: 13803
diff changeset
294
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
295 ## 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
296 %!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
297 %!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
298 %!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
299 %!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
300