1 ## Copyright (C) 2012 Michael Goffioul
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {[@var{p}, @var{args}] =} __uiobject_split_args__ (@var{who}, @var{args}, @var{parent_type}, @var{use_gcf})
25 function [parent, args] = __uiobject_split_args__ (who, in_args, parent_type = {}, use_gcf = 1)
31 if (! isempty (in_args))
32 if (ishandle (in_args{1}))
35 elseif (! ischar (in_args{1}))
36 error ("%s: invalid parent handle.", who);
39 args = in_args(offset:end);
42 if (rem (length (args), 2))
43 error ("%s: expecting PROPERTY/VALUE pairs", who);
47 i = find (strcmpi (args(1:2:end), "parent"), 1, "first");
48 if (! isempty (i) && length (args) >= 2*i)
50 if (! ishandle (parent))
51 error ("%s: invalid parent handle.", who);
53 args([2*i-1, 2*i]) = [];
57 if (! isempty (parent))
58 if (! isempty (parent_type) && isempty (find (strcmpi (get (parent, "type"), parent_type))))
59 error ("%s: invalid parent, the parent type must be: %s", ...
60 who, sprintf ("%s, ", parent_type{:})(1:end-2));