annotate scripts/gui/dialog.m @ 22787:fadaacb3d816

dialog.m: Overhaul function. * dialog.m: Add additional calling form to docstring. Write code in docstring using Octave conventions. Add seealso references to other dialog functions. Don't set "visible", "on" since Matlab doesn't bother. Always return the handle h as output. Add single BIST test just to mark function as tested.
author Rik <rik@octave.org>
date Thu, 17 Nov 2016 10:39:05 -0800
parents 3a2b891d0b33
children ef4d915df748
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
1 ## Copyright (C) 2016 John Donoghue
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
2 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
3 ## This file is part of Octave.
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
4 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22299
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22299
diff changeset
8 ## (at your option) any later version.
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
9 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22299
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22299
diff changeset
13 ## GNU General Public License for more details.
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
14 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
18
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
19 ## -*- texinfo -*-
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
20 ## @deftypefn {} {@var{h} =} dialog ()
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
21 ## @deftypefnx {} {@var{h} =} dialog ("@var{property}", @var{value}, @dots{})
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
22 ##
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
23 ## Create an empty modal dialog window to which other uicontrols can be added.
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
24 ##
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 21937
diff changeset
25 ## The dialog box is a figure object with properties as recommended for a
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 21937
diff changeset
26 ## dialog box.
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
27 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
28 ## The default properties differing from a figure are:
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
29 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
30 ## @table @asis
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
31 ## @item buttondownfcn
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
32 ## @code{if isempty (allchild(gcbf)), close (gcbf), endif}
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
33 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
34 ## @item colormap
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
35 ## []
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
36 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
37 ## @item color
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
38 ## defaultuicontrolbackgroundcolor
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
39 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
40 ## @item dockcontrols
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
41 ## off
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
42 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
43 ## @item handlevisibility
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
44 ## callback
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
45 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
46 ## @item integerhandle
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
47 ## off
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
48 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
49 ## @item inverthardcopy
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
50 ## off
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
51 ##
21937
55f7de37b618 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21825
diff changeset
52 ## @item menubar
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
53 ## none
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
54 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
55 ## @item numbertitle
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
56 ## off
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
57 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
58 ## @item paperpositionmode
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
59 ## auto
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
60 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
61 ## @item resize
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
62 ## off
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
63 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
64 ## @item windowstyle
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
65 ## modal
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
66 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
67 ## @end table
21937
55f7de37b618 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21825
diff changeset
68 ##
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
69 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
70 ## Multiple property-value pairs may be specified for the dialog object, but
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
71 ## they must appear in pairs.
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
72 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
73 ## The return value @var{h} is a graphics handle to the created figure.
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
74 ##
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
75 ## Example:
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
76 ##
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
77 ## @example
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
78 ## @group
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
79 ## ## create an empty dialog window titled "Dialog Example"
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
80 ## h = dialog ("name", "Dialog Example");
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
81 ##
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
82 ## ## create a button (default style)
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
83 ## b = uicontrol (h, "string", "OK",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
84 ## "position", [10 10 150 40],
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
85 ## "callback", "delete (gcf)");
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
86 ##
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
87 ## ## wait for dialog to resume or close
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
88 ## uiwait (h);
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
89 ## @end group
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
90 ## @end example
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
91 ##
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
92 ## @seealso{errordlg, msgbox, questdlg, warndlg, figure, uiwait}
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
93 ## @end deftypefn
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
94
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
95 ## Author: jdonoghue
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
96
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
97 function h = dialog (varargin)
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
98
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
99 h = figure ( ...
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
100 "buttondownfcn", "if isempty (allchild (gcbf)), close (gcbf), endif",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
101 "color", get (0,"defaultuicontrolbackgroundcolor"),
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
102 "colormap", [],
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
103 "dockcontrols", "off",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
104 "handlevisibility", "callback",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
105 "integerhandle", "off",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
106 "inverthardcopy", "off",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
107 "menubar", "none",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
108 "numbertitle", "off",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
109 "paperpositionmode", "auto",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
110 "resize", "off",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
111 "toolbar", "none",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
112 "windowstyle", "modal",
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
113 varargin{:});
21937
55f7de37b618 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21825
diff changeset
114
21825
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
115 endfunction
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
116
f1f17f13b3b9 Add dialog function (Bug #48136)
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
117
22787
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
118 ## No BIST tests. This function just dispatches to figure().
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
119 %!assert (1)
fadaacb3d816 dialog.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
120