comparison scripts/plot/private/__uiobject_split_args__.m @ 13703:22ce748da25f

Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool. * graphics.h.in (uicontextmenu, uitoolbar, uipushtool, uitoggletool): New graphic object classes. (uicontrol::properties::cdata): Allow "single" and "uint8" data. * graphics.cc (uitoolbar): New class implementation. * gl-render.cc (opengl_renderer::draw): Skip new object types. * plot/private/__uiobject_split_args__.m: Don't use varargin. Add parent_type and use_gcf arguments. Check that number of arguments is a multiple of 2. * plot/uicontrol.m: Adapt call to __uiobject_split_args__. * plot/uipanel.m: Likewise. * plot/uimenu.m: Rewrite to use __uiobject_split_args__. * plot/uicontextmenu.m: New file. * plot/uitoolbar.m: Likewise. * plot/uipushtool.m: Likewise. * plot/uitoggletool.m: Likewise. * plot/modules.mk (plot_FCN_FILES): Add uicontextmenu.m, uitoolbar.m, uipushtool.m and uitoggletool.m.
author Michael Goffioul <michael.goffioul@gmail.com>
date Fri, 14 Oct 2011 23:19:06 +0100
parents 5ab9c721ce59
children 9cae456085c2
comparison
equal deleted inserted replaced
13702:c7fac37a2afc 13703:22ce748da25f
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see 16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {[@var{p}, @var{args}] =} __uiobject_split_args__ (@var{who}, @dots{}) 20 ## @deftypefn {Function File} {[@var{p}, @var{args}] =} __uiobject_split_args__ (@var{who}, @var{args}, @var{parent_type}, @var{use_gcf})
21 ## @end deftypefn 21 ## @end deftypefn
22 22
23 ## Author: goffioul 23 ## Author: goffioul
24 24
25 function [parent, args] = __uiobject_split_args__ (who, varargin) 25 function [parent, args] = __uiobject_split_args__ (who, in_args, parent_type = {}, use_gcf = 1)
26 26
27 parent = []; 27 parent = [];
28 args = {}; 28 args = {};
29 offset = 1; 29 offset = 1;
30 30
31 if (nargin > 1) 31 if (! isempty (in_args))
32 if (ishandle (varargin{1})) 32 if (ishandle (in_args{1}))
33 parent = varargin{1}; 33 parent = in_args{1};
34 offset = 2; 34 offset = 2;
35 elseif (! ischar (varargin{1})) 35 elseif (! ischar (in_args{1}))
36 error ("%s: invalid parent handle.", who); 36 error ("%s: invalid parent handle.", who);
37 endif 37 endif
38 38
39 if (nargin > offset) 39 args = in_args(offset:end);
40 args = varargin(offset:end); 40 endif
41 endif 41
42 if (rem (length (args), 2))
43 error ("%s: expecting PROPERTY/VALUE pairs", who);
42 endif 44 endif
43 45
44 if (! isempty (args)) 46 if (! isempty (args))
45 i = find (strcmpi (args(1:2:end), "parent"), 1, "first"); 47 i = find (strcmpi (args(1:2:end), "parent"), 1, "first");
46 if (! isempty (i) && length (args) >= 2*i) 48 if (! isempty (i) && length (args) >= 2*i)
51 args([2*i-1, 2*i]) = []; 53 args([2*i-1, 2*i]) = [];
52 endif 54 endif
53 endif 55 endif
54 56
55 if (! isempty (parent)) 57 if (! isempty (parent))
56 if (isempty (find (strcmpi (get (parent, "type"), {"figure", "uipanel", "uibuttongroup"})))) 58 if (! isempty (parent_type) && isempty (find (strcmpi (get (parent, "type"), parent_type))))
57 error ("%s: invalid parent, the parent must be a figure, uipanel or uibuttongroup handle", who); 59 error ("%s: invalid parent, the parent type must be: %s", ...
60 who, sprintf ("%s, ", parent_type{:})(1:end-2));
58 endif 61 endif
59 else 62 elseif (use_gcf)
60 parent = gcf (); 63 parent = gcf ();
61 endif 64 endif
62 65
63 endfunction 66 endfunction