annotate scripts/plot/util/private/__add_default_menu__.m @ 30999:fef2957c38ec

Deprecate uimenu properties "label" and "callback" (bug #62443) Replace "label" property with "text". Replace "callback" property with "menuselectedfcn". Both old properties are hidden, but continue to exist and work as before to support old code. * NEWS.8.md: Announce deprecation. * graphics.in.h (uimenu::BEGIN_PROPERTIES): Mark "callback" property with "hgs" for hidden, get, set routines. Mark "label" property with "hgs". * graphics.in.h (uimenu::get_callback, uimenu::set_callback): New functions which simply relay calls to "get_menuselectedfcn" and "set_menuselectedfcn". * Menu.cc (Menu::actionTriggered, Menu::actionHovered): Replace "callback" with "menuselectedfcn" in gh_callback_event calls. * __init_fltk__.cc (script_cb): Rename "execute_callback" to "execute_menuselectedfcn". * __init_fltk__.cc (update_menuselectedfcn): Rename function from "update_callback". Rename "get_callback" to "get_menuselectedfcn". * __init_fltk__.cc (add_to_uimenu): Rename "update_callback" to "update_menuselectedfcn". * __init_fltk__.cc (uimenu_update): Rename "ID_CALLBACK" to "ID_MENUSELECTEDFCN". * uimenu.m: Update documentation to use "menuselectedfcn" and "text". Update demos and BIST tests to use new property names. * __add_default_menu__.m: Update code to use "menuselectedfcn" and "text".
author Rik <rik@octave.org>
date Sat, 14 May 2022 19:06:56 -0700
parents 796f54d4ddbf
children c8ad083a5802
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30379
diff changeset
3 ## Copyright (C) 2010-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27554
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
7 ##
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
8 ## This file is part of Octave.
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24210
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24210
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
14 ##
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
19 ##
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24210
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
25
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
26 ## -*- texinfo -*-
28920
601b6c7728ed maint: match names in documentation to input parameters in function.
Rik <rik@octave.org>
parents: 28594
diff changeset
27 ## @deftypefn {} {} __add_default_menu__ (@var{hf})
601b6c7728ed maint: match names in documentation to input parameters in function.
Rik <rik@octave.org>
parents: 28594
diff changeset
28 ## @deftypefnx {} {} __add_default_menu__ (@var{hf}, @var{hmenu})
601b6c7728ed maint: match names in documentation to input parameters in function.
Rik <rik@octave.org>
parents: 28594
diff changeset
29 ## @deftypefnx {} {} __add_default_menu__ (@var{hf}, @var{hmenu}, @var{htb})
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25878
diff changeset
30 ## Add default menu and listeners to figure.
25948
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
31 ##
28920
601b6c7728ed maint: match names in documentation to input parameters in function.
Rik <rik@octave.org>
parents: 28594
diff changeset
32 ## @var{hf} is a figure handle.
601b6c7728ed maint: match names in documentation to input parameters in function.
Rik <rik@octave.org>
parents: 28594
diff changeset
33 ## @var{hmenu} is a uimenu handle.
601b6c7728ed maint: match names in documentation to input parameters in function.
Rik <rik@octave.org>
parents: 28594
diff changeset
34 ## @var{htb} is a uitoolbar handle.
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19883
diff changeset
35 ##
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19883
diff changeset
36 ## All uimenu handles have their @qcode{"HandleVisibility"} property set to
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19883
diff changeset
37 ## @qcode{"off"}.
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
38 ## @end deftypefn
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
39
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
40 function __add_default_menu__ (hf, hmenu = [], htb = [])
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
41
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
42 ## Gnuplot doesn't handle uimenu and uitoolbar objects
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
43 if (strcmp (graphics_toolkit (), "gnuplot"))
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
44 return;
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
45 endif
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
46
25948
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
47 ## Create
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25878
diff changeset
48 if (isempty (hmenu))
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
49 ## File menu
26904
d7856bf83781 Improve new figure creation time by 50%.
Rik <rik@octave.org>
parents: 26902
diff changeset
50 hui = uimenu (hf, "label", "&File", "tag", "__default_menu__File", ...
d7856bf83781 Improve new figure creation time by 50%.
Rik <rik@octave.org>
parents: 26902
diff changeset
51 "handlevisibility", "off");
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
52 uimenu (hui, "label", "&Open...", "menuselectedfcn", @open_cb, ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
53 "accelerator", "o");
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
54 uimenu (hui, "label", "&Save", "menuselectedfcn", {@save_cb, "save"}, ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
55 "accelerator", "s");
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
56 uimenu (hui, "label", "Save &As...", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
57 "menuselectedfcn", {@save_cb, "saveas"}, ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
58 "accelerator", "S");
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
59 uimenu (hui, "label", "&Close", "menuselectedfcn", @close_cb, ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
60 "accelerator", "w", "separator", "on");
25948
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
61 hmenu(1) = hui;
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
62
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
63 ## Edit menu
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
64 hui = uimenu (hf, "label", "&Edit", "handlevisibility", "off", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
65 "tag", "__default_menu__Edit");
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
66 uimenu (hui, "label", "&New Figure", "menuselectedfcn", "figure ();", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
67 "accelerator", "n");
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
68 uimenu (hui, "label", "&Duplicate Figure",
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
69 "menuselectedfcn", "copyobj (gcbf (), groot ());", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
70 "accelerator", "d");
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
71 uimenu (hui, "label", "Clea&r Figure",
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
72 "menuselectedfcn", "clf (gcbf ());");
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
73 uimenu (hui, "label", "Reset Figure",
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
74 "menuselectedfcn", "reset (gcbf ());");
27554
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
75 uimenu (hui, "label", "Copy Figure to Clipboard", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
76 "menuselectedfcn", @clipboard_cb, "separator", "on", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
77 "accelerator", "c");
25948
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
78 hmenu(2) = hui;
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
79
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
80 ## Tools menu
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
81 hui = uimenu (hf, "label", "&Tools", "handlevisibility", "off", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
82 "tag", "__default_menu__Tools");
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
83 uimenu (hui, "label", "Toggle &grid on all axes", "tag", "toggle", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
84 "menuselectedfcn", @grid_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
85 uimenu (hui, "label", "Show grid on all axes", "tag", "on", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
86 "menuselectedfcn", @grid_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
87 uimenu (hui, "label", "Hide grid on all axes", "tag", "off", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
88 "menuselectedfcn", @grid_cb);
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
89 uimenu (hui, "label", "Auto&scale all axes",
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
90 "menuselectedfcn", @autoscale_cb);
25948
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
91
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
92 hui2 = uimenu (hui, "label", "GUI &Mode (on all axes)");
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
93 uimenu (hui2, "label", "Pan x and y", "tag", "pan_on", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
94 "menuselectedfcn", @guimode_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
95 uimenu (hui2, "label", "Pan x only", "tag", "pan_xon", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
96 "menuselectedfcn", @guimode_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
97 uimenu (hui2, "label", "Pan y only", "tag", "pan_yon", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
98 "menuselectedfcn", @guimode_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
99 uimenu (hui2, "label", "Disable pan and rotate", "tag", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
100 "no_pan_rotate", "menuselectedfcn", @guimode_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
101 uimenu (hui2, "label", "Rotate on", "tag", "rotate3d", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
102 "menuselectedfcn", @guimode_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
103 uimenu (hui2, "label", "Enable mousezoom", "tag", "zoom_on", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
104 "menuselectedfcn", @guimode_cb);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
105 uimenu (hui2, "label", "Disable mousezoom", "tag", "zoom_off", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
106 "menuselectedfcn", @guimode_cb);
25948
700b3f415ebe maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25888
diff changeset
107 hmenu(3) = hui;
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
108
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
109 ## Default toolbar
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
110 init_mouse_tools (hf);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
111 htb = uitoolbar (hf, "tag", "__default_toolbar__", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
112 "handlevisibility", "off", "visible", "off");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
113
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
114 ht(1) = uitoggletool (htb, "tooltipstring", "Pan", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
115 "tag", "__default_button_pan__", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
116 "__named_icon__", "figure-pan");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
117 ht(2) = uitoggletool (htb, "tooltipstring", "Rotate", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
118 "tag", "__default_button_rotate__", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
119 "__named_icon__", "figure-rotate");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
120
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
121 ht(3) = uitoggletool (htb, "tooltipstring", "Zoom In", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
122 "tag", "__default_button_zoomin__", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
123 "__named_icon__", "figure-zoom-in", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
124 "separator", "on");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
125 ht(4) = uitoggletool (htb, "tooltipstring", "Zoom Out", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
126 "tag", "__default_button_zoomout__", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
127 "__named_icon__", "figure-zoom-out");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
128 uipushtool (htb, "tooltipstring", "Automatic limits for current axes", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
129 "clickedcallback", @auto_cb, ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
130 "__named_icon__", "figure-zoom-original");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
131
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
132 ht(5) = uitoggletool (htb, "tooltipstring", "Insert Text", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
133 "tag", "__default_button_text__", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
134 "separator", "on", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
135 "__named_icon__", "figure-text");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
136
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
137 uipushtool (htb, "tooltipstring", "Toggle current axes visibility", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
138 "clickedcallback", @axes_cb, "separator", "on", ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
139 "__named_icon__", "figure-axes");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
140 uipushtool (htb, "tooltipstring", "Toggle current axes grid visibility", ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
141 "clickedcallback", @grid_cb, ...
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
142 "__named_icon__", "figure-grid");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
143
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
144 set (ht(1), "oncallback", {@mouse_tools_cb, ht, "pan"}, ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
145 "offcallback", {@mouse_tools_cb, ht, "pan"});
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
146 set (ht(2), "oncallback", {@mouse_tools_cb, ht, "rotate"}, ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
147 "offcallback", {@mouse_tools_cb, ht, "rotate"});
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
148 set (ht(3), "oncallback", {@mouse_tools_cb, ht, "zoomin"}, ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
149 "offcallback", {@mouse_tools_cb, ht, "zoomin"});
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
150 set (ht(4), "oncallback", {@mouse_tools_cb, ht, "zoomout"}, ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
151 "offcallback", {@mouse_tools_cb, ht, "zoomout"});
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
152 set (ht(5), "oncallback", {@mouse_tools_cb, ht, "text"}, ...
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
153 "offcallback", {@mouse_tools_cb, ht, "text"});
17136
e4968b4613a5 Overhaul default menubar (still not perfect).
Rik <rik@octave.org>
parents: 14868
diff changeset
154 endif
e4968b4613a5 Overhaul default menubar (still not perfect).
Rik <rik@octave.org>
parents: 14868
diff changeset
155
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
156 if (! exist ("ht", "var"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
157 ht = get (htb, "children")(end:-1:1);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
158 istoggletool = strcmp (get (ht, "type"), "uitoggletool");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
159 ht(! istoggletool) = [];
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
160 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
161
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
162 ## Add/Restore figure listeners
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
163 toggle_visibility_cb (hf, [], hmenu, htb);
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
164 addlistener (hf, "menubar", {@toggle_visibility_cb, hmenu, htb});
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
165 addlistener (hf, "toolbar", {@toggle_visibility_cb, hmenu, htb});
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
166 addlistener (hf, "__mouse_mode__", {@mouse_tools_cb, ht, "mode"});
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
167 addlistener (hf, "__zoom_mode__", {@mouse_tools_cb, ht, "mode"});
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
168
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
169 endfunction
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
170
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
171 function toggle_visibility_cb (hf, ~, hmenu, htb)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
172
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
173 menu_state = ifelse (strcmp (get (hf, "menubar"), "figure"), "on", "off");
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
174 toolbar_state = "on";
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
175 if (strcmp (get (hf, "toolbar"), "auto"))
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
176 toolbar_state = menu_state;
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
177 elseif (strcmp (get (hf, "toolbar"), "none"))
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
178 toolbar_state = "off";
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25878
diff changeset
179 endif
26995
ab5bfee22d18 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 26904
diff changeset
180
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
181 set (hmenu, "visible", menu_state);
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
182 set (htb, "visible", toolbar_state);
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
183
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25878
diff changeset
184 endfunction
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21385
diff changeset
185
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
186 function open_cb (~, ~)
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
187 [filename, filedir] = uigetfile ({"*.ofig;*.fig", "Figure Files"}, ...
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
188 "Open Figure");
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
189 if (filename != 0)
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
190 fname = fullfile (filedir, filename);
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
191 openfig (fname);
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
192 endif
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
193 endfunction
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
194
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
195 function save_cb (h, ~, action)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
196
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
197 hfig = gcbf ();
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
198 fname = get (hfig, "filename");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
199
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
200 if (strcmp (action, "save"))
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
201 if (isempty (fname))
24202
014f47089682 make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
202 __save_as__ (hfig);
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
203 else
24202
014f47089682 make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
204 saveas (hfig, fname);
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
205 endif
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
206 elseif (strcmp (action, "saveas"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
207 __save_as__ (hfig, fname);
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
208 endif
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
209
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
210 endfunction
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
211
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
212 function __save_as__ (hf, fname = "")
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
213
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
214 if (! isempty (fname))
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
215 def = fname;
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
216 else
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
217 def = fullfile (pwd (), "untitled.ofig");
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
218 endif
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
219 filter = {"*.ofig", "Octave Figure";
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
220 "*.eps", "Encapsulated PostScript";
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
221 "*.pdf", "Portable Document Format";
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
222 "*.ps", "PostScript";
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
223 "*.svg", "Scalable Vector Graphics";
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
224 "*.gif", "GIF Image";
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
225 "*.jpg", "JPEG Image";
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
226 "*.png", "Portable Network Graphics Image";
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
227 "*.tiff", "TIFF Image"};
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
228 ## Reorder filters to have current first
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
229 [~, ~, ext] = fileparts (def);
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
230 idx = strcmp (filter(:,1), ["*" tolower(ext)]);
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
231 filter = [filter(idx,:); filter(! idx,:)];
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21385
diff changeset
232
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
233 [filename, filedir, filteridx] = uiputfile (filter, "Save Figure", def);
24202
014f47089682 make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
234
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
235 if (filename != 0)
24202
014f47089682 make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
236 fname = fullfile (filedir, filename);
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
237 [~, ~, ext] = fileparts (fname);
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
238 if (filteridx > rows (filter))
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
239 ## "All Files" option
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
240 if (isempty (ext))
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
241 fmt = "";
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
242 else
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
243 fmt = ext(2:end);
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
244 endif
24202
014f47089682 make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
245 else
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
246 fmt = filter{filteridx,1}(3:end);
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
247 if (isempty (ext))
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
248 fname = [fname "." fmt];
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
249 endif
24202
014f47089682 make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
250 endif
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
251 set (hf, "filename", fname);
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
252 saveas (hf, fname, fmt);
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
253 endif
28945
6e460773bdda maint: Use newlines after "function" and before "endfunction" for clarity.
Rik <rik@octave.org>
parents: 28920
diff changeset
254
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
255 endfunction
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
256
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
257 function close_cb (~, ~)
28335
6c2366242767 Improve implementation of default File menu for plots (bug #58397)
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
258 close (gcbf ());
24589
9b36fc7bd002 __add_default_menu__.m: Don't close the wrong figure if File->Close used in FLTK.
Rik <rik@octave.org>
parents: 24534
diff changeset
259 endfunction
9b36fc7bd002 __add_default_menu__.m: Don't close the wrong figure if File->Close used in FLTK.
Rik <rik@octave.org>
parents: 24534
diff changeset
260
19883
65e6207f7ae4 Fix FLTK Edit uimenu to use new pan/rotate3d fcns and mousewheelzoom property.
Stefan Mahr <dac922@gmx.de>
parents: 19742
diff changeset
261 function [hax, fig] = __get_axes__ (h)
18965
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
262 ## Get parent figure
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
263 fig = ancestor (h, "figure");
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
264
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
265 ## Find all axes which aren't legends
18967
69658bd9952b __add_default_menu__.m: Fix bug that findobj is missing HLIST
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18965
diff changeset
266 hax = findobj (fig, "type", "axes", "-not", "tag", "legend");
18965
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
267 endfunction
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
268
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
269 function autoscale_cb (h, ~)
18965
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
270 hax = __get_axes__ (h);
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
271 arrayfun (@(h) axis (h, "auto"), hax);
18968
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18967
diff changeset
272 drawnow ();
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
273 endfunction
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
274
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
275 function init_mouse_tools (hf)
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
276 set (hf, "__pan_mode__", struct ("Enable", "off",
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
277 "Motion", "both",
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
278 "FigureHandle", hf),
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
279 "__rotate_mode__", struct ("Enable", "off",
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
280 "RotateStyle", "box",
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
281 "FigureHandle", hf),
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
282 "__zoom_mode__", struct ("Enable", "off",
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
283 "Motion", "both",
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
284 "Direction", "in",
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
285 "FigureHandle", hf));
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
286 endfunction
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21385
diff changeset
287
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
288 function guimode_cb (h, ~)
28945
6e460773bdda maint: Use newlines after "function" and before "endfunction" for clarity.
Rik <rik@octave.org>
parents: 28920
diff changeset
289
19883
65e6207f7ae4 Fix FLTK Edit uimenu to use new pan/rotate3d fcns and mousewheelzoom property.
Stefan Mahr <dac922@gmx.de>
parents: 19742
diff changeset
290 [hax, fig] = __get_axes__ (h);
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
291 id = get (h, "tag");
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
292 switch (id)
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
293 case "pan_on"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
294 pan (fig, "on");
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
295 case "pan_xon"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
296 pan (fig, "xon");
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
297 case "pan_yon"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
298 pan (fig, "yon");
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
299 case "rotate3d"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
300 rotate3d (fig, "on");
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
301 case "no_pan_rotate"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
302 pan (fig, "off");
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
303 rotate3d (fig, "off");
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
304 case "zoom_on"
19883
65e6207f7ae4 Fix FLTK Edit uimenu to use new pan/rotate3d fcns and mousewheelzoom property.
Stefan Mahr <dac922@gmx.de>
parents: 19742
diff changeset
305 arrayfun (@(h) set (h, "mousewheelzoom", 0.05), hax);
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
306 case "zoom_off"
19883
65e6207f7ae4 Fix FLTK Edit uimenu to use new pan/rotate3d fcns and mousewheelzoom property.
Stefan Mahr <dac922@gmx.de>
parents: 19742
diff changeset
307 arrayfun (@(h) set (h, "mousewheelzoom", 0.0), hax);
17136
e4968b4613a5 Overhaul default menubar (still not perfect).
Rik <rik@octave.org>
parents: 14868
diff changeset
308 endswitch
28945
6e460773bdda maint: Use newlines after "function" and before "endfunction" for clarity.
Rik <rik@octave.org>
parents: 28920
diff changeset
309
11349
4a3258b1448f Add default menu for fltk backend figures
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
310 endfunction
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
311
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
312 function mouse_tools_cb (h, ~, htools, typ = "")
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
313
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
314 persistent recursion = false;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
315
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
316 if (! recursion)
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
317 recursion = true;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
318
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
319 hf = gcbf ();
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
320
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
321 if (strcmp (typ, "mode"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
322 ## The mouse mode has been changed from outside this callback,
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
323 ## change the buttons state accordingly
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
324 mode = get (hf, "__mouse_mode__");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
325 state = "on";
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
326
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
327 switch (mode)
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
328 case "zoom"
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
329 zm = get (hf, "__zoom_mode__");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
330 if (strcmp (zm.Direction, "in"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
331 htool = htools(3);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
332 else
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
333 htool = htools(4);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
334 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
335 case "pan"
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
336 htool = htools(1);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
337 case "rotate"
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
338 htool = htools(2);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
339 case "text"
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
340 htool = htools(5);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
341 case "none"
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
342 state = "off";
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
343 htool = htools;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
344 endswitch
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
345
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
346 set (htool, "state", state);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
347 if (strcmp (state, "on"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
348 set (htools(htools != htool), "state", "off");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
349 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
350
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
351 else
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
352 ## Update the mouse mode according to the button state
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
353 state = get (h, "state");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
354
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
355 switch (typ)
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
356 case {"zoomin", "zoomout"}
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
357 prop = "__zoom_mode__";
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
358 val = get (hf, prop);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
359
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
360 if (strcmp (state, "on"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
361 if (strcmp (typ, "zoomin"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
362 val.Direction = "in";
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
363 else
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
364 val.Direction = "out";
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
365 endif
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
366 set (hf, "__mouse_mode__", "zoom");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
367 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
368 val.Enable = state;
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
369 set (hf, prop, val);
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
370
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
371 case {"pan", "rotate"}
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
372 prop = ["__", typ, "_mode__"];
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
373 val = get (hf, prop);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
374 if (strcmp (state, "on"))
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
375 set (hf, "__mouse_mode__", typ);
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
376 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
377 val.Enable = state;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
378 set (hf, prop, val);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
379
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
380 case {"text", "select"}
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
381 if (strcmp (state, "on"))
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
382 set (hf, "__mouse_mode__", typ);
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
383 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
384 endswitch
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
385
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
386 if (strcmp (state, "on"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
387 set (htools(htools != h), "state", "off");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
388 elseif (! any (strcmp (get (htools, "state"), "on")))
28336
391a9d85e59d __add_default_menu__.m: Clean-up code.
Rik <rik@octave.org>
parents: 28335
diff changeset
389 set (hf, "__mouse_mode__", "none");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
390 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
391 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
392
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
393 recursion = false;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
394 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
395
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
396 endfunction
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
397
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
398 function axes_cb (h, ~)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
399
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
400 hax = get (gcbf (), "currentaxes");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
401 if (! isempty (hax))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
402 if (strcmp (get (hax, "visible"), "on"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
403 set (hax, "visible", "off");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
404 else
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
405 set (hax, "visible", "on");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
406 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
407 endif
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
408
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
409 endfunction
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
410
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
411 function grid_cb (h, ~)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
412
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
413 hax = get (gcbf (), "currentaxes");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
414 if (! isempty (hax))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
415 if (strcmp (get (hax, "xgrid"), "on") && strcmp (get (hax, "ygrid"), "on"))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
416 grid (hax, "off");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
417 else
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26869
diff changeset
418 grid (hax, "on");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
419 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
420 endif
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
421
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
422 endfunction
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
423
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
424 function auto_cb (h, ~)
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
425 hax = get (gcbf (), "currentaxes");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
426 if (! isempty (hax))
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
427 axis (hax, "auto");
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
428 endif
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
429 endfunction
27554
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
430
28594
6e8d14f4fb2f Restore operation of Figure graphics callbacks (bug #58821).
Rik <rik@octave.org>
parents: 28336
diff changeset
431 function clipboard_cb (h, ~)
28945
6e460773bdda maint: Use newlines after "function" and before "endfunction" for clarity.
Rik <rik@octave.org>
parents: 28920
diff changeset
432
27554
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
433 hf = gcbf ();
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
434 fname = tempname ();
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
435 props = {"inverthardcopy", "paperposition", "paperpositionmode"};
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
436 values = get (hf, props);
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
437 set (hf, "inverthardcopy", "off", "paperpositionmode", "auto");
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
438 unwind_protect
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
439 print ("-r0", "-dpng", "-svgconvert", fname);
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
440 __event_manager_copy_image_to_clipboard__ (fname);
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
441 unwind_protect_cleanup
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
442 set (hf, props, values);
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
443 end_unwind_protect
28945
6e460773bdda maint: Use newlines after "function" and before "endfunction" for clarity.
Rik <rik@octave.org>
parents: 28920
diff changeset
444
27554
d0f778462a51 Restore hability to copy figure to clipboard (bug #55970)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26995
diff changeset
445 endfunction