1 ## Copyright (C) 2010-2012 Kai Habel
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} {} __add_default_menu__ (@var{fig})
21 ## Add default menu to figure. All uimenu handles have
22 ## set their property "handlevisibility" to "off".
27 function __add_default_menu__ (fig)
30 obj = findall (fig, "label", "&File", "tag", "__default_menu__");
31 if (length (obj) == 0)
32 __f = uimenu (fig, "label", "&File", "handlevisibility", "off", "tag", "__default_menu__");
33 sa = uimenu (__f, "label", "Save &As", "handlevisibility", "off",
34 "callback", @save_cb);
35 sv = uimenu (__f, "label", "&Save", "handlevisibility", "off",
36 "callback", @save_cb);
37 cl = uimenu (__f, "label", "&Close", "handlevisibility", "off",
38 "callback", "close(gcf)");
40 __e = uimenu (fig, "label", "&Edit", "handlevisibility", "off");
41 gr = uimenu (__e, "label", "&Grid", "handlevisibility", "off",
42 "callback", @grid_cb);
43 as = uimenu (__e, "label", "Auto&scale", "handlevisibility", "off",
44 "callback", @autoscale_cb);
45 gm = uimenu (__e, "label", "GUI &Mode", "handlevisibility", "off");
46 gm2 = uimenu (gm, "label", "Pan+Zoom", "handlevisibility", "off",
47 "callback", @guimode_cb);
48 gm3 = uimenu (gm, "label", "Rotate+Zoom", "handlevisibility", "off",
49 "callback", @guimode_cb);
50 gmn = uimenu (gm, "label", "None", "handlevisibility", "off",
51 "callback", @guimode_cb);
52 __h = uimenu (fig, "label", "&Help", "handlevisibility", "off");
53 ab = uimenu (__h, "label", "A&bout", "handlevisibility", "off", "enable", "off");
56 error ("expecting figure handle", "handlevisibility", "off");
61 function grid_cb (h, e)
63 drawnow; # should not be required
66 function save_cb (h, e)
67 lbl = get (gcbo, "label");
68 if (strcmp (lbl, "&Save"))
69 fname = get (gcbo, "userdata");
75 elseif (strcmp (lbl, "Save &As"))
80 function __save_as__ (caller)
82 [filename, filedir] = uiputfile ({"*.pdf;*.ps;*.gif;*.png;*.jpg","Supported Graphic Formats"},
86 fname = strcat (filedir, filesep, filename);
87 obj = findall ("label", "&Save");
89 set (obj(1), "userdata", fname);
91 saveas (caller, fname);
95 function autoscale_cb (h, e)
97 drawnow; #should not be required
100 function guimode_cb (h, e)
101 lbl = get(h, "label");
102 if (strncmp(lbl, "Pan+Zoom", 8))
104 elseif (strncmp(lbl, "Rotate+Zoom", 11))
106 elseif (strncmp(lbl, "None", 4))