Mercurial > octave-nkf
annotate 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 |
rev | line source |
---|---|
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1 ## Copyright (C) 2011 Michael Goffioul |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2 ## |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
4 ## |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
9 ## |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
14 ## |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
18 |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{p}, @var{args}] =} __uiobject_split_args__ (@var{who}, @var{args}, @var{parent_type}, @var{use_gcf}) |
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
21 ## @end deftypefn |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
22 |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
23 ## Author: goffioul |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
24 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
25 function [parent, args] = __uiobject_split_args__ (who, in_args, parent_type = {}, use_gcf = 1) |
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
26 |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
27 parent = []; |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
28 args = {}; |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
29 offset = 1; |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
30 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
31 if (! isempty (in_args)) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
32 if (ishandle (in_args{1})) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
33 parent = in_args{1}; |
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
34 offset = 2; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
35 elseif (! ischar (in_args{1})) |
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
36 error ("%s: invalid parent handle.", who); |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
37 endif |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
38 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
39 args = in_args(offset:end); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
40 endif |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
41 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
42 if (rem (length (args), 2)) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
43 error ("%s: expecting PROPERTY/VALUE pairs", who); |
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
44 endif |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
45 |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
46 if (! isempty (args)) |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
47 i = find (strcmpi (args(1:2:end), "parent"), 1, "first"); |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
48 if (! isempty (i) && length (args) >= 2*i) |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
49 parent = args{2*i}; |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
50 if (! ishandle (parent)) |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
51 error ("%s: invalid parent handle.", who); |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
52 endif |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
53 args([2*i-1, 2*i]) = []; |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
54 endif |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
55 endif |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
56 |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
57 if (! isempty (parent)) |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
58 if (! isempty (parent_type) && isempty (find (strcmpi (get (parent, "type"), parent_type)))) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
59 error ("%s: invalid parent, the parent type must be: %s", ... |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
60 who, sprintf ("%s, ", parent_type{:})(1:end-2)); |
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
61 endif |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13284
diff
changeset
|
62 elseif (use_gcf) |
13284
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
63 parent = gcf (); |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
64 endif |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
65 |
5ab9c721ce59
Add uicontrol and uipanel m-scripts.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
66 endfunction |