annotate libgui/graphics/Figure.cc @ 22323:bac0d6f07a3e

maint: Update copyright notices for 2016.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Aug 2016 01:05:19 -0400
parents 278fc29b69ca
children 0a2961d5893c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
3 Copyright (C) 2011-2016 Michael Goffioul
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
5 This file is part of Octave.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
8 under the terms of the GNU General Public License as published by the
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10 option) any later version.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
15 for more details.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
18 along with Octave; see the file COPYING. If not, see
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
19 <http://www.gnu.org/licenses/>.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
24 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include <QAction>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <QActionEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <QActionGroup>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <QApplication>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
31 #include <QClipboard>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QEvent>
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
33 #include <QFileDialog>
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
34 #include <QFileInfo>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <QFrame>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
36 #include <QImage>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include <QMainWindow>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include <QMenu>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include <QMenuBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include <QMessageBox>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include <QtDebug>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include <QTimer>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include <QToolBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include "Canvas.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 #include "Container.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 #include "Figure.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 #include "FigureWindow.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 #include "MouseModeActionGroup.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
50 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
52 #include "file-ops.h"
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
53 #include "unwind-prot.h"
20085
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20079
diff changeset
54 #include "utils.h"
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
55 #include "version.h"
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
56
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
57 #include "octave-qt-link.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
58
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
59 #include "builtin-defun-decls.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
60
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
66 static bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
67 hasUiControlChildren (const figure::properties& fp)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 {
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
69 gh_manager::auto_lock lock;
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
70
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 graphics_object go (gh_manager::get_object (kids(i)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 if (go && (go.isa ("uicontrol") || go.isa ("uipanel")
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
78 || go.isa ("uibuttongroup")))
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
79 return true;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
85 static bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
86 hasUiMenuChildren (const figure::properties& fp)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 {
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
88 gh_manager::auto_lock lock;
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
89
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 graphics_object go (gh_manager::get_object (kids(i)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 if (go && go.isa ("uimenu"))
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
97 return true;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
103 static QRect
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
104 boundingBoxToRect (const Matrix& bb)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 QRect r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 if (bb.numel () == 4)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
110 r = QRect (octave::math::round (bb(0)), octave::math::round (bb(1)),
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
111 octave::math::round (bb(2)), octave::math::round (bb(3)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 if (! r.isValid ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 r = QRect ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 return r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
119 Figure*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
120 Figure::create (const graphics_object& go)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 return new Figure (go, new FigureWindow ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 Figure::Figure (const graphics_object& go, FigureWindow* win)
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
126 : Object (go, win), m_blockUpdates (false), m_figureToolBar (0),
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
127 m_menuBar (0), m_innerRect (), m_outerRect (), m_mouseModeGroup (0)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 m_container = new Container (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 win->setCentralWidget (m_container);
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
131
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
134 // Status bar
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
135 m_statusBar = win->statusBar ();
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
136 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
138 // Toolbar and menubar
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
139 createFigureToolBarAndMenuBar ();
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
140 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
141
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
142 if (fp.toolbar_is ("figure") ||
20013
08fae2e963fb Fix toolbar and menubar interaction at figure initialization (bug #44686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20007
diff changeset
143 (fp.toolbar_is ("auto") && fp.menubar_is ("figure") &&
08fae2e963fb Fix toolbar and menubar interaction at figure initialization (bug #44686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20007
diff changeset
144 ! hasUiControlChildren (fp)))
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
145 {
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
146 toffset += m_figureToolBar->sizeHint ().height ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
147 boffset += m_statusBar->sizeHint ().height ();
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
148 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149 else
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
150 {
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
151 m_figureToolBar->hide ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
152 m_statusBar->hide ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
153 }
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
154
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 if (fp.menubar_is ("figure") || hasUiMenuChildren (fp))
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
156 toffset += m_menuBar->sizeHint ().height () + 1;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 m_menuBar->hide ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
163 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
164
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
165 // Enable mouse tracking unconditionally
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
166 enableMouseTracking ();
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
167
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
168 // When this constructor gets called all properties are already
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
169 // set, even non default. We force "update" here to get things right.
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
170
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
171 // Figure title
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
172 update (figure::properties::ID_NUMBERTITLE);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
174 // Decide what keyboard events we listen to
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
175 m_container->canvas (m_handle)->setEventMask (0);
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
176 update (figure::properties::ID_KEYPRESSFCN);
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
177 update (figure::properties::ID_KEYRELEASEFCN);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
179 // modal style
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
180 update (figure::properties::ID_WINDOWSTYLE);
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
181
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
182 // Visibility
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
183 update (figure::properties::ID_VISIBLE);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
184
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185 connect (this, SIGNAL (asyncUpdate (void)),
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186 this, SLOT (updateContainer (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 win->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189 m_container->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 Figure::~Figure (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
194 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
195
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
196 static std::string
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
197 mouse_mode_to_string (MouseMode mode)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
198 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
199 switch (mode)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
200 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
201 case NoMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
202 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
203
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
204 case RotateMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
205 return "rotate";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
206
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
207 case ZoomInMode:
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
208 return "zoom in";
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
209
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
210 case ZoomOutMode:
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
211 return "zoom out";
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
212
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
213 case PanMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
214 return "pan";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
215
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
216 case TextMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
217 return "text";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
218
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
219 case SelectMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
220 return "select";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
221
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
222 default:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
223 break;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
224 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
225
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
226 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
227 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
228
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
229 static MouseMode
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
230 mouse_mode_from_string (const std::string& mode)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
231 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
232 if (mode == "none")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
233 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
234 else if (mode == "rotate")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
235 return RotateMode;
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
236 else if (mode == "zoom in")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
237 return ZoomInMode;
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
238 else if (mode == "zoom out")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
239 return ZoomOutMode;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
240 else if (mode == "pan")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
241 return PanMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
242 else if (mode == "text")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
243 return TextMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
244 else if (mode == "select")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
245 return SelectMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
246 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
247 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
248 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
249
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
250 QString
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
251 Figure::fileName (void)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
252 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
253 gh_manager::auto_lock lock;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
254
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
255 const figure::properties& fp = properties<figure> ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
256
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
257 std::string name = fp.get_filename ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
258
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
259 return QString::fromStdString (name);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
260 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
261
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
262 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
263 Figure::setFileName (const QString& name)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
264 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
265 gh_manager::auto_lock lock;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
266
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
267 figure::properties& fp = properties<figure> ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
268
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
269 fp.set_filename (name.toStdString ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
270 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
271
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
272 MouseMode
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
273 Figure::mouseMode (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
274 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
275 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
276
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
277 const figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
278
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
279 std::string mode = fp.get___mouse_mode__ ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
280
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
281 if (mode == "zoom")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
282 {
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
283 octave_scalar_map zm = fp.get___zoom_mode__ ().scalar_map_value ();
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
284
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
285 std::string direction = zm.getfield ("Direction").string_value ();
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
286
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
287 mode += " " + direction;
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
288 }
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
289
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
290 return mouse_mode_from_string (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
291 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
292
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
293 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
294 Figure::createFigureToolBarAndMenuBar (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
295 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
298 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
299 m_figureToolBar->setMovable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300 m_figureToolBar->setFloatable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
301
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
302 m_mouseModeGroup = new MouseModeActionGroup (win);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
303 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)),
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
304 SLOT (setMouseMode (MouseMode)));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
305 m_figureToolBar->addActions (m_mouseModeGroup->actions ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
306
20007
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20006
diff changeset
307 QAction *toggle_axes = m_figureToolBar->addAction (tr ("Axes"));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
308 connect (toggle_axes, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
309 this, SLOT (toggleAxes (void)));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
310
20007
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20006
diff changeset
311 QAction *toggle_grid = m_figureToolBar->addAction (tr ("Grid"));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
312 connect (toggle_grid, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
313 this, SLOT (toggleGrid (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
314
20007
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20006
diff changeset
315 QAction *auto_axes = m_figureToolBar->addAction (tr ("Autoscale"));
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
316 connect (auto_axes, SIGNAL (triggered (void)),
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
317 this, SLOT (autoAxes (void)));
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
318
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
319 m_menuBar = new MenuBar (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
320 win->setMenuBar (m_menuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
321
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
322 QMenu* fileMenu = m_menuBar->addMenu (tr ("&File"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
323 fileMenu->menuAction ()->setObjectName ("builtinMenu");
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
324 fileMenu->addAction (tr ("&Save"), this, SLOT (fileSaveFigure (bool)));
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
325 fileMenu->addAction (tr ("Save &As"), this, SLOT (fileSaveFigureAs (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 fileMenu->addSeparator ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327 fileMenu->addAction (tr ("&Close Figure"), this,
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21301
diff changeset
328 SLOT (fileCloseFigure (void)), Qt::CTRL | Qt::Key_W);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330 QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
331 editMenu->menuAction ()->setObjectName ("builtinMenu");
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
332 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (bool)),
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21301
diff changeset
333 Qt::CTRL | Qt::Key_C);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
334 editMenu->addSeparator ();
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
335 editMenu->addActions (m_mouseModeGroup->actions ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 helpMenu->menuAction ()->setObjectName ("builtinMenu");
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
339 helpMenu->addAction (tr ("About Octave"), this,
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
340 SLOT (helpAboutOctave (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
342 m_menuBar->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
343 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
344
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
345 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
346 Figure::updateFigureToolBarAndMenuBar (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
347 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
348 if (m_mouseModeGroup)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
349 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
350 m_blockUpdates = true;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
351 m_mouseModeGroup->setMode (mouseMode ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
352 m_blockUpdates = false;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
353 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
354 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
355
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
356 Container*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
357 Figure::innerContainer (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
358 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
359 return m_container;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
360 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
361
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
362 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
363 Figure::redraw (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
364 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
365 Canvas* canvas = m_container->canvas (m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
366
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
367 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
368 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 canvas->redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
370 //canvas->setMouseMode (RotateMode);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
371 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
372
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
373 foreach (QFrame* frame,
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents: 21782
diff changeset
374 qWidget<QWidget> ()->findChildren<QFrame*> ())
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
375 {
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents: 21782
diff changeset
376 if (frame->objectName () == "UIPanel" || frame->objectName () == "UIButtonGroup") {
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents: 21782
diff changeset
377 Object* obj = Object::fromQObject (frame);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
378
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents: 21782
diff changeset
379 if (obj)
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents: 21782
diff changeset
380 obj->slotRedraw ();
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents: 21782
diff changeset
381 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
382 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
383
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
384 updateFigureToolBarAndMenuBar ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
385 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
386
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
387 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
388 Figure::print (const QString& file_cmd, const QString& term)
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
389 {
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
390 Canvas* canvas = m_container->canvas (m_handle);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
391
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
392 if (canvas)
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
393 canvas->print (file_cmd, term);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
394 }
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
395
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
396 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
397 Figure::beingDeleted (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
398 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
399 Canvas* canvas = m_container->canvas (m_handle.value (), false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
400
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
401 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
402 canvas->blockRedraw (true);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
403
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
404 m_menuBar->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
405 m_container->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
406 qWidget<FigureWindow> ()->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
407 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
408
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
409 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
410 Figure::update (int pId)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
411 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
412 if (m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
414
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
415 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
416 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
417
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
418 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
420 switch (pId)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
421 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422 case figure::properties::ID_POSITION:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
423 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
424 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
425 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
426 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
427
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
428 foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
429 if (! tb->isHidden ())
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
430 toffset += tb->sizeHint ().height ();
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
431
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
432 if (! m_menuBar->isHidden ())
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
433 toffset += m_menuBar->sizeHint ().height () + 1;
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
434
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
435 if (! m_statusBar->isHidden ())
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
436 boffset += m_statusBar->sizeHint ().height () + 1;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
437
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
438 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
439 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
440 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
441
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
442 case figure::properties::ID_NAME:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
443 case figure::properties::ID_NUMBERTITLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
444 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
445 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
446
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
447 case figure::properties::ID_VISIBLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
448 if (fp.is_visible ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
449 QTimer::singleShot (0, win, SLOT (show ()));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
450 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
451 win->hide ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
452 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
453
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
454 case figure::properties::ID_TOOLBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
455 if (fp.toolbar_is ("none"))
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
456 showFigureToolBar (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
457 else if (fp.toolbar_is ("figure"))
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
458 showFigureToolBar (true);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
459 else // "auto"
19977
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
460 showFigureToolBar (! hasUiControlChildren (fp) &&
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
461 fp.menubar_is ("figure"));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
462 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
463
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
464 case figure::properties::ID_MENUBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
465 showMenuBar (fp.menubar_is ("figure"));
19977
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
466 if (fp.toolbar_is ("auto"))
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
467 showFigureToolBar (fp.menubar_is ("figure"));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
469
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
470 case figure::properties::ID_KEYPRESSFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
471 if (fp.get_keypressfcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
472 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
473 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
474 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
475 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
476
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
477 case figure::properties::ID_KEYRELEASEFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
478 if (fp.get_keyreleasefcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
479 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
480 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
481 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
482 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
483
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
484 case figure::properties::ID_WINDOWSTYLE:
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
485 if (fp.windowstyle_is ("modal"))
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
486 {
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
487 bool is_visible = win->isVisible ();
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
488
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
489 // if window is already visible, need to hide and reshow it in order to
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
490 // make it use the modal settings
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
491 if (is_visible)
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
492 win->setVisible (false);
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
493
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
494 win->setWindowModality (Qt::ApplicationModal);
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
495 win->setVisible (is_visible);
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
496 }
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
497 else
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
498 win->setWindowModality (Qt::NonModal);
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
499
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
500 break;
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
501
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
502 default:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
505
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
506 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
508
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
509 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
510 Figure::showFigureToolBar (bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
511 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
512 if ((! m_figureToolBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
513 {
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
514 int dy1 = m_figureToolBar->sizeHint ().height ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
515 int dy2 = m_statusBar->sizeHint ().height ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
516 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
517
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518 if (! visible)
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
519 r.adjust (0, dy1, 0, -dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
520 else
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
521 r.adjust (0, -dy1, 0, dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
522
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
523 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
525 m_figureToolBar->setVisible (visible);
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
526 m_statusBar->setVisible (visible);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
527 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
528
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
529 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
530 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
531 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
532
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
533 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
534 Figure::showMenuBar (bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
535 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
536 int h1 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
537
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
538 foreach (QAction* a, m_menuBar->actions ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539 if (a->objectName () == "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 a->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542 int h2 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
544 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545 visible = hasUiMenuChildren (properties<figure> ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
546
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
547 if ((! m_menuBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
548 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
549 int dy = qMax (h1, h2) + 1;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
550 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
551
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
552 //qDebug () << "Figure::showMenuBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553 if (! visible)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
554 r.adjust (0, dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
555 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
556 r.adjust (0, -dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
557 //qDebug () << "Figure::showMenuBar(adjusted):" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
558
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
559 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
560 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
561 m_menuBar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
562 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
563
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
564 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
565 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
566 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
567
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
568 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
569 Figure::updateMenuBar (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
570 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
571 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
572 graphics_object go = object ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
573
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
574 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
575 showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
576 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
577
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
578 void
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
579 Figure::updateStatusBar (ColumnVector pt)
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
580 {
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
581 if (! m_statusBar->isHidden ())
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
582 m_statusBar->showMessage (QString ("(%1, %2)")
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
583 .arg (pt(0), 0, 'g', 5)
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
584 .arg (pt(1), 0, 'g', 5));
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
585 }
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
586
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
587 QWidget*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
588 Figure::menu (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
590 return qWidget<QMainWindow> ()->menuBar ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
591 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
592
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
593 struct UpdateBoundingBoxData
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
594 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
595 Matrix m_bbox;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
596 bool m_internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
597 graphics_handle m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
598 Figure* m_figure;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
599 };
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
600
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
601 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
602 Figure::updateBoundingBoxHelper (void* data)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
603 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
604 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
605
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
606 UpdateBoundingBoxData* d = reinterpret_cast<UpdateBoundingBoxData*> (data);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607 graphics_object go = gh_manager::get_object (d->m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
608
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
609 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
610 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
611 figure::properties& fp = Utils::properties<figure> (go);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
612
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613 fp.set_boundingbox (d->m_bbox, d->m_internal, false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
614 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
615
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
616 delete d;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
617 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
618
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
619 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
620 Figure::updateBoundingBox (bool internal, int flags)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
621 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
622 QWidget* win = qWidget<QWidget> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
623 Matrix bb (1, 4);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
624
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
625 if (internal)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
626 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
627 QRect r = m_innerRect;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
628
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629 if (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630 r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
631 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
632 r.setSize (m_container->size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
633
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
634 if (r.isValid () && r != m_innerRect)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
635 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
636 m_innerRect = r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
637
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
638 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
639 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
641 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
642 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
643 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
644 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
645 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
646 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
648 QRect r = m_outerRect;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
650 if (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
651 r.moveTopLeft (win->pos ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
652 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
653 r.setSize (win->frameGeometry ().size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
654
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18612
diff changeset
655 if (r.isValid () && r != m_outerRect)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
656 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
657 m_outerRect = r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
658
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
659 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
660 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
661 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
662 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
663 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
664 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
665 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
666 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
667
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
668 UpdateBoundingBoxData* d = new UpdateBoundingBoxData ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
669
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
670 d->m_bbox = bb;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
671 d->m_internal = internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
672 d->m_handle = m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
673 d->m_figure = this;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
674
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
675 gh_manager::post_function (Figure::updateBoundingBoxHelper, d);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
676 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
677
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
678 bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
679 Figure::eventNotifyBefore (QObject* obj, QEvent* xevent)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
680 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
681 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
682 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
683 if (obj == m_container)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
684 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
685 // Do nothing...
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
686 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
687 else if (obj == m_menuBar)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
688 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
689 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
690 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
691 case QEvent::ActionRemoved:
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
692 {
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
693 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
694
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
695 if (! a->isSeparator ()
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
696 && a->objectName () != "builtinMenu")
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
697 updateMenuBar ();
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
698 }
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
699 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
700
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
701 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
702 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
703 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
704 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
705 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
706 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
707 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
708 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
709 case QEvent::Close:
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
710 xevent->ignore ();
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
711 gh_manager::post_callback (m_handle, "closerequestfcn");
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
712 return true;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
713
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
714 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
715 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
716 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
717 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
718 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
719
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
720 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
721 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
722
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
723 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
724 Figure::eventNotifyAfter (QObject* watched, QEvent* xevent)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
725 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
726 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
727 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
728 if (watched == m_container)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
729 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
730 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
731 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
732 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
733 updateBoundingBox (true, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
734 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
735
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
736 case QEvent::ChildAdded:
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
737 if (dynamic_cast<QChildEvent*> (xevent)->child
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
738 ()->isWidgetType())
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
739 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
740 gh_manager::auto_lock lock;
20524
88459dd6780f Fix inconsistent toolbar state after creating an uicontrol (bug #46025)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20504
diff changeset
741 update (figure::properties::ID_TOOLBAR);
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
742
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
743 enableMouseTracking ();
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
744 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
745
20595
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
746 case QEvent::ChildRemoved:
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
747 if (dynamic_cast<QChildEvent*> (xevent)->child
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
748 ()->isWidgetType())
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
749 {
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
750 gh_manager::auto_lock lock;
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
751 update (figure::properties::ID_TOOLBAR);
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
752 }
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
753
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
754 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
755 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
756 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
757 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
758 else if (watched == m_menuBar)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
759 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
760 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
761 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
762 case QEvent::ActionAdded:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
763 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
764 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
765
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
766 if (! a->isSeparator ()
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
767 && a->objectName () != "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
768 updateMenuBar ();
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
769 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
770 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
771
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
772 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
773 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
774 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
775 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
776 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
777 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
778 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
779 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
780 case QEvent::Move:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
781 updateBoundingBox (false, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
782 updateBoundingBox (true, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
783 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
784
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
785 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
786 updateBoundingBox (false, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
787 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
788
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
789 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
790 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
791 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
792 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
793 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
794 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
795
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
796 void
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
797 Figure::helpAboutOctave (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
798 {
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
799 std::string message
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
800 = octave_name_version_copyright_copying_warranty_and_bugs (true);
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
801
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
802 QMessageBox::about (qWidget<QMainWindow> (), tr ("About Octave"),
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
803 QString::fromStdString (message));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
804 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
805
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
806 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
807 Figure::setMouseMode (MouseMode mode)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
808 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
809 if (m_blockUpdates)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
810 return;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
811
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
812 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
813
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
814 figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
815
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
816 fp.set___mouse_mode__ (mouse_mode_to_string (mode));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
817
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
818 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
819
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
820 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
821 canvas->setCursor (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
822 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
823
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
824 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
825 Figure::fileSaveFigure (bool prompt)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
826 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
827 QString file = fileName ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
828
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
829 if (file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
830 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
831 prompt = true;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
832
19723
c9dc27cad3c0 Use default format of PDF for saving Qt plots.
Rik <rik@octave.org>
parents: 19722
diff changeset
833 file = "untitled.pdf";
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
834 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
835
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
836 if (prompt || file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
837 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
838 QFileInfo finfo (file);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
839
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
840 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
841 tr ("Save Figure As"),
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
842 finfo.absoluteFilePath (), 0, 0,
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
843 QFileDialog::DontUseNativeDialog);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
844 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
845
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
846 if (! file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
847 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
848 QFileInfo finfo (file);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
849
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
850 setFileName (finfo.absoluteFilePath ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
851
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
852 octave_link::post_event (this, &Figure::save_figure_callback,
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
853 file.toStdString ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
854 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
855 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
856
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
857 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
858 Figure::save_figure_callback (const std::string& file)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
859 {
20242
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
860 figure::properties& fp = properties<figure> ();
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
861 octave_value fnum = fp.get___myhandle__ ().as_octave_value ();
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
862
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
863 Ffeval (ovl ("print", fnum, file));
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
864 }
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
865
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
866 void
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
867 Figure::copy_figure_callback (const std::string& format)
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
868 {
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
869 std::string msg;
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
870
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
871 std::string file = octave::sys::tempnam ("", "oct-", msg) + "." + format;
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
872
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
873 if (file.empty ())
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
874 {
20085
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20079
diff changeset
875 // Report error?
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
876 return;
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
877 }
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
878
20242
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
879 save_figure_callback (file);
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
880
20113
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20085
diff changeset
881 octave_link::copy_image_to_clipboard (file);
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
882 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
883
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
884 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
885 Figure::fileSaveFigureAs (void)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
886 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
887 fileSaveFigure (true);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
888 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
889
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
890 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
891 Figure::fileCloseFigure (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
892 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
893 qWidget<QMainWindow> ()->close ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
894 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
895
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
896 void
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
897 Figure::editCopy (bool /* choose_format */)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
898 {
20114
5f0cb9bb6a50 use png instead of jpg as default format for copying plots to clipboard
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
899 QString format = "png";
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
900
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
901 #if 0
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
902
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
903 // FIXME: allow choice of image formats.
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
904
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
905 if (choose_format)
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
906 {
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
907 QFileInfo finfo (file);
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
908
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
909 format = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
910 tr ("Save Figure As"),
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
911 finfo.absoluteFilePath (), 0, 0,
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
912 QFileDialog::DontUseNativeDialog);
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
913 }
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
914 #endif
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
915
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
916 octave_link::post_event (this, &Figure::copy_figure_callback,
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
917 format.toStdString ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
918 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
919
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
920 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
921 Figure::addCustomToolBar (QToolBar* bar, bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
922 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
923 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
924
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
925 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
926 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
927 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
928 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
929 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
930 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
931 //qDebug () << "Figure::addCustomToolBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
932
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
933 r.adjust (0, -sz.height (), 0, 0);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
934
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
935 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
936 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
937 win->addToolBarBreak ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
938 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
939 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
940
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
941 //qDebug () << "Figure::addCustomToolBar:" << win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
942 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
943 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
944 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
945
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
946 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
947 Figure::showCustomToolBar (QToolBar* bar, bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
948 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
949 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
950
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
951 if ((! bar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
952 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
953 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
954 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
955
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
956 if (visible)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
957 r.adjust (0, -sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
958 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
959 r.adjust (0, sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
960
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
961 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
962 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
963 bar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
964 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
965
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
966 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
967 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
968 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
969
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
970 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
971 Figure::updateContainer (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
972 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
973 redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
974 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
975
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
976 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
977 Figure::toggleAxes (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
978 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
979 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
980
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
981 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
982 canvas->toggleAxes (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
983 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
984
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
985 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
986 Figure::toggleGrid (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
987 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
988 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
989
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
990 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
991 canvas->toggleGrid (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
992 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
993
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
994 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
995 Figure::autoAxes (void)
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
996 {
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
997 Canvas* canvas = m_container->canvas (m_handle);
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
998
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
999 if (canvas)
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
1000 canvas->autoAxes (m_handle);
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
1001 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
1002
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1003 void
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1004 Figure::enableMouseTracking (void)
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1005 {
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1006 // Enable mouse tracking on every widgets
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1007 m_container->setMouseTracking (true);
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1008 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1009 foreach (QWidget* w, m_container->findChildren<QWidget*> ())
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1010 { w->setMouseTracking (true); }
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1011 }
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1012
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1013 }; // namespace QtHandles