annotate scripts/gui/uibuttongroup.m @ 25054:6652d3823428 stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Mar 2018 09:19:05 -0400
parents 194eb4bd202b
children 5ca8abb27644
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1 ## Copyright (C) 2016-2018 Andrew Thornton
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
2 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
3 ## This file is part of Octave.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24478
diff changeset
5 ## Octave is free software: you can redistribute it and/or modify it
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24478
diff changeset
7 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 21824
diff changeset
8 ## (at your option) any later version.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
9 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 21824
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 21824
diff changeset
13 ## GNU General Public License for more details.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
14 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24478
diff changeset
17 ## <https://www.gnu.org/licenses/>.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
18
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
19 ## -*- texinfo -*-
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
20 ## @deftypefn {} {@var{hui} =} uibuttongroup (@var{property}, @var{value}, @dots{})
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
21 ## @deftypefnx {} {@var{hui} =} uibuttongroup (@var{parent}, @var{property}, @var{value}, @dots{})
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
22 ## @deftypefnx {} {} uibuttongroup (@var{h})
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
23 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
24 ## Create a uibuttongroup object and return a handle to it.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
25 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
26 ## uibuttongroups are used to create group uicontrols.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
27 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
28 ## If @var{parent} is omitted then a uibuttongroup for the current figure is
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
29 ## created. If no figure is available, a new figure is created first.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
30 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
31 ## If @var{parent} is given then a uibuttongroup relative to @var{parent} is
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
32 ## created.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
33 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
34 ## Any provided property value pairs will override the default values of the
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
35 ## created uibuttongroup object.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
36 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
37 ## Uibuttongroup properties are documented at @ref{Uibuttongroup Properties}.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
38 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
39 ## Examples:
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
40 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
41 ## @example
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
42 ## @group
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
43 ## % create figure and panel on it
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
44 ## f = figure;
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
45 ## % create a button group
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
46 ## gp = uibuttongroup (f, "Position", [ 0 0.5 1 1])
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
47 ## % create a buttons in the group
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
48 ## b1 = uicontrol (gp, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
49 ## "string", "Choice 1", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
50 ## "Position", [ 10 150 100 50 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
51 ## b2 = uicontrol (gp, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
52 ## "string", "Choice 2", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
53 ## "Position", [ 10 50 100 30 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
54 ## % create a button not in the group
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
55 ## b3 = uicontrol (f, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
56 ## "string", "Not in the group", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
57 ## "Position", [ 10 50 100 50 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
58 ## @end group
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
59 ## @end example
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
60 ## @seealso{figure, uipanel}
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
61 ## @end deftypefn
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
62
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
63 ## Author: zeripath
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
64
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
65 function hui = uibuttongroup (varargin)
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
66
24478
59041be1994b Use new function isgraphics to simplify m-files.
Rik <rik@octave.org>
parents: 24423
diff changeset
67 if (nargin == 1 && isgraphics (varargin{1}, "uibuttongroup"))
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
68 error ("uibuttongroup: focusing not implemented yet");
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
69 endif
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
70
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
71 [h, args] = __uiobject_split_args__ ("uibuttongroup", varargin,
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
72 {"figure", "uipanel", "uibuttongroup"});
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
73 hui = __go_uibuttongroup__ (h, args{:});
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
74
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
75 endfunction
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
76
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
77 %!demo
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
78 %! f = figure;
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
79 %! gp = uibuttongroup (f, "Position", [ 0 0.5 1 1], ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
80 %! "selectionchangedfcn", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
81 %! @(x, y) display (['Selection Changed: ' get(y.NewValue, 'String')]));
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
82 %! b1 = uicontrol (gp, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
83 %! "string", "Choice 1", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
84 %! "Position", [ 10 150 100 50 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
85 %! b2 = uicontrol (gp, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
86 %! "string", "Choice 2", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
87 %! "Position", [ 10 50 100 30 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
88 %! b3 = uicontrol (f, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
89 %! "string", "Not in the group", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
90 %! "Position", [ 10 50 100 50 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
91 %! disp (['Current selected: ' get(get(gp, 'selectedobject'), 'String')]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
92 %! pause (0.5);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
93 %! disp (['Select None']);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
94 %! set (gp, 'selectedobject', []);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
95 %! pause (0.1);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
96 %! disp (['Current selected: ' get(get(gp, 'selectedobject'), 'String')]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
97 %! pause (0.5);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
98 %! disp (['Select b1']);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
99 %! set (gp, 'selectedobject', b1);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
100 %! disp (['Current selected: ' get(get(gp, 'selectedobject'), 'String')]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
101
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
102 ## Uncertain if tests can be performed
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
103 %!assert (1)