Mercurial > octave
annotate scripts/gui/uibuttongroup.m @ 21824:6780a8657be3
Implement uibuttongroup (bug #47513)
* doc/interpreter/genpropdoc.m: Wire in uibuttongroup documentation creation
* doc/interpreter/gui.txi: Add documentation node for uibuttongroup
* doc/interpreter/module.mk: Wire in uibuttongroup documentation creation
* doc/interpreter/plot.txi: Add documentation node for uibuttongroup
* libgui/graphics/__init_qt__.cc (__init__): Set default styling for uibuttongroup
* libgui/graphics/Backend.cc (toolkitObjectProperty): Add uibuttongroup
* libgui/graphics/Backend.cc (Backend::initialize): Add uibuttongroup
* libgui/graphics/Backend.cc (Backend::update): Add uibuttongroup
* libgui/graphics/ButtonControl.cc (ButtonControl::update): Catch forced uncheck of selected button in buttongroup
* libgui/graphics/Canvas.cc (Canvas::select_object): Allow uibuttongroup to be selected like uicontrol or uipanel
* libgui/graphics/Figure.cc (hasUiControlChildren): Ensure that uibuttongroup is known to have children
* libgui/graphics/module.mk: Wire in ButtonGroup
* libgui/graphics/ObjectFactory.cc (ObjectFactory::createObject): Create ButtonGroup for uibuttongroup
* libgui/graphics/QtHandlesUtils.cc (computeFont<uibuttongroup>): Make computeFont template for uibuttongroup
* libgui/graphics/RadioButtonControl.cc (RadioButtonControl::RadioButtonControl): On creation of button add to ButtonGroup
* libgui/graphics/ToggleButtonControl.cc (ToggleButtonControl::ToggleButtonControl): On creation of button add to ButtonGroup
* libinterp/corefcn/gl-render.cc (opengl_renderer::draw): Allow uibuttongroup to be drawn
* libinterp/corefcn/gl-render.cc (opengl_renderer::draw_uibuttongroup): Method to draw uibuttongroup
* libinterp/corefcn/gl-render.h (opengl_renderer::draw_uibuttongroup): Method to draw uibuttongroup
* libinterp/corefcn/graphics.cc (lookup_object_name): Wire in uibuttongroup
* libinterp/corefcn/graphics.cc (make_graphics_object_from_type): Wire in uibuttongroup
* libinterp/corefcn/graphics.cc (property_list::set): Wire in uibuttongroup
* libinterp/corefcn/graphics.cc (property_list::lookup): Wire in uibuttongroup
* libinterp/corefcn/graphics.cc (uibuttongroup::properties::get_boundingbox uibuttongroup::properties::set_units uibuttongroup::properties::update_units uibuttongroup::properties::set_fontunits uibuttongroup::properties::update_fontunits uibuttongroup::properties::get_fontsize_points uibuttongroup::properties::set_selectedobject): Add property methods for uibuttongroup
* libinterp/corefcn/graphics.in.h: Add uibuttongroup
* scripts/gui/module.mk: Wire in uibuttongroup script
* scripts/help/__unimplemented__.m: Remove uibuttongroup from unimplemented
* libgui/graphics/ButtonGroup.cc: Add QT toolkit ButtonGroup object
* libgui/graphics/ButtonGroup.h: Add QT toolkit ButtonGroup object
* scripts/gui/uibuttongroup.m: Create uibuttongroup script
author | Andrew Thornton <art27@cantab.net> |
---|---|
date | Thu, 05 May 2016 20:03:26 +0100 |
parents | |
children | 3a2b891d0b33 3ac9f9ecfae5 |
rev | line source |
---|---|
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
1 ## Copyright (C) 2016 Andrew Thornton |
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 ## |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
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 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
8 ## your option) any later version. |
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 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
13 ## General Public License for more details. |
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 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
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 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
67 if (nargin == 1 && ishandle (varargin{1}) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
68 && strcmpi (get (varargin{1}, "type"), "uibuttongroup")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
69 error ("uibuttongroup: focusing not implemented yet"); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
70 endif |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
71 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
72 [h, args] = __uiobject_split_args__ ("uibuttongroup", varargin, |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
73 {"figure", "uipanel", "uibuttongroup"}); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
74 hui = __go_uibuttongroup__ (h, args{:}); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
75 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
76 endfunction |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
77 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
78 %!demo |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
79 %! f = figure; |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
80 %! gp = uibuttongroup (f, "Position", [ 0 0.5 1 1], ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
81 %! "selectionchangedfcn", ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
82 %! @(x, y) display (['Selection Changed: ' get(y.NewValue, 'String')])); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
83 %! b1 = uicontrol (gp, "style", "radiobutton", ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
84 %! "string", "Choice 1", ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
85 %! "Position", [ 10 150 100 50 ]); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
86 %! b2 = uicontrol (gp, "style", "radiobutton", ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
87 %! "string", "Choice 2", ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
88 %! "Position", [ 10 50 100 30 ]); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
89 %! b3 = uicontrol (f, "style", "radiobutton", ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
90 %! "string", "Not in the group", ... |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
91 %! "Position", [ 10 50 100 50 ]); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
92 %! disp (['Current selected: ' get(get(gp, 'selectedobject'), 'String')]); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
93 %! pause (0.5); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
94 %! disp (['Select None']); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
95 %! set (gp, 'selectedobject', []); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
96 %! pause (0.1); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
97 %! disp (['Current selected: ' get(get(gp, 'selectedobject'), 'String')]); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
98 %! pause (0.5); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
99 %! disp (['Select b1']); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
100 %! set (gp, 'selectedobject', b1); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
101 %! disp (['Current selected: ' get(get(gp, 'selectedobject'), 'String')]); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
102 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
103 ## Uncertain if tests can be performed |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
104 %!assert (1) |