annotate libgui/graphics/Figure.cc @ 20559:88459dd6780f

Fix inconsistent toolbar state after creating an uicontrol (bug #46025) * Figure.cc (Figure::eventNotifyAfter): when a child has been created, use update method to properly decide whether to show the toolbar.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sun, 27 Sep 2015 17:12:29 +0200
parents b6ae0ef9327e
children dcfbf4c1c3c8
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
20038
f0e61a67ad9f Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents: 20002
diff changeset
3 Copyright (C) 2011-2015 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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #include <config.h>
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>
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
31 #include <QClipboard>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QEvent>
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
33 #include <QFileDialog>
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
34 #include <QFileInfo>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <QFrame>
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
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
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
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: 20113
diff changeset
53 #include "unwind-prot.h"
20120
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20114
diff changeset
54 #include "utils.h"
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
55
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
56 #include "octave-qt-link.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
57
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
58 #include "builtin-defun-decls.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
59
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
20038
f0e61a67ad9f Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents: 20002
diff changeset
63 #define ABOUT_TEXT "<b>QtHandles</b> - a Qt-based toolkit for <a href=\"http://www.octave.org\">Octave</a>.<br><br>Copyright (C) 2011-2015 Michael Goffioul"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
67 static bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
68 hasUiControlChildren (const figure::properties& fp)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 {
19989
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19905
diff changeset
70 gh_manager::auto_lock lock;
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19905
diff changeset
71
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 graphics_object go (gh_manager::get_object (kids(i)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 if (go && (go.isa ("uicontrol") || go.isa ("uipanel")
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
79 || go.isa ("uibuttongroup")))
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
80 return true;
18498
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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
86 static bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
87 hasUiMenuChildren (const figure::properties& fp)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 {
19989
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19905
diff changeset
89 gh_manager::auto_lock lock;
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19905
diff changeset
90
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 graphics_object go (gh_manager::get_object (kids(i)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 if (go && go.isa ("uimenu"))
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
98 return true;
18498
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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
104 static QRect
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
105 boundingBoxToRect (const Matrix& bb)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 QRect r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 if (bb.numel () == 4)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 r = QRect (xround (bb(0)), xround (bb(1)),
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 xround (bb(2)), xround (bb(3)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 if (! r.isValid ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 r = QRect ();
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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 return r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
120 Figure*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
121 Figure::create (const graphics_object& go)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 return new Figure (go, new FigureWindow ());
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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 Figure::Figure (const graphics_object& go, FigureWindow* win)
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
127 : Object (go, win), m_blockUpdates (false), m_figureToolBar (0),
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
128 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
129 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 m_container = new Container (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 win->setCentralWidget (m_container);
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
132
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
135 // Enable mouse tracking
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
136 m_container->setMouseTracking (true);
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
137 foreach (QWidget* w, m_container->findChildren<QWidget*> ())
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
138 { w->setMouseTracking (true); }
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
139
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
140 // Status bar
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
141 m_statusBar = win->statusBar ();
20539
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
142 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
144 // Toolbar and menubar
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
145 createFigureToolBarAndMenuBar ();
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
146 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
147
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20149
diff changeset
148 if (fp.toolbar_is ("figure") ||
20048
08fae2e963fb Fix toolbar and menubar interaction at figure initialization (bug #44686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20042
diff changeset
149 (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: 20042
diff changeset
150 ! hasUiControlChildren (fp)))
20539
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
151 {
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
152 toffset += m_figureToolBar->sizeHint ().height ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
153 boffset += m_statusBar->sizeHint ().height ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
154 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 else
20539
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
156 {
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
157 m_figureToolBar->hide ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
158 m_statusBar->hide ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
159 }
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
160
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 if (fp.menubar_is ("figure") || hasUiMenuChildren (fp))
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
162 toffset += m_menuBar->sizeHint ().height () + 1;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 m_menuBar->hide ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 //qDebug () << "Figure::Figure:" << m_innerRect;
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
170 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171 //qDebug () << "Figure::Figure(adjusted)" << m_innerRect.adjusted (0, -offset, 0, 0);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 int eventMask = 0;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 if (! fp.get_keypressfcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176 eventMask |= Canvas::KeyPress;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 if (! fp.get_keyreleasefcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178 eventMask |= Canvas::KeyRelease;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179 m_container->canvas (m_handle)->setEventMask (eventMask);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180
18646
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
181 if (! fp.get_windowbuttonmotionfcn ().is_empty ())
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
182 {
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
183 m_container->setMouseTracking (true);
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
184 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
185 }
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
186
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 connect (this, SIGNAL (asyncUpdate (void)),
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 this, SLOT (updateContainer (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190 if (fp.is_visible ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191 QTimer::singleShot (0, win, SLOT (show ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193 win->hide ();
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 win->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
196 m_container->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
198
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199 Figure::~Figure (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
203 static std::string
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
204 mouse_mode_to_string (MouseMode mode)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
205 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
206 switch (mode)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
207 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
208 case NoMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
209 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
210
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
211 case RotateMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
212 return "rotate";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
213
19901
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
214 case ZoomInMode:
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
215 return "zoom in";
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
216
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
217 case ZoomOutMode:
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
218 return "zoom out";
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
219
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
220 case PanMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
221 return "pan";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
222
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
223 case TextMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
224 return "text";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
225
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
226 case SelectMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
227 return "select";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
228
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
229 default:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
230 break;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
231 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
232
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
233 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
234 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
235
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
236 static MouseMode
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
237 mouse_mode_from_string (const std::string& mode)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
238 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
239 if (mode == "none")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
240 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
241 else if (mode == "rotate")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
242 return RotateMode;
19901
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
243 else if (mode == "zoom in")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
244 return ZoomInMode;
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
245 else if (mode == "zoom out")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
246 return ZoomOutMode;
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
247 else if (mode == "pan")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
248 return PanMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
249 else if (mode == "text")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
250 return TextMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
251 else if (mode == "select")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
252 return SelectMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
253 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
254 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
255 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
256
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
257 QString
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
258 Figure::fileName (void)
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
259 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
260 gh_manager::auto_lock lock;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
261
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
262 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: 19715
diff changeset
263
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
264 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: 19715
diff changeset
265
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
266 return QString::fromStdString (name);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
267 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
268
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
269 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
270 Figure::setFileName (const QString& name)
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
271 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
272 gh_manager::auto_lock lock;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
273
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
274 figure::properties& fp = properties<figure> ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
275
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
276 fp.set_filename (name.toStdString ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
277 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
278
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
279 MouseMode
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
280 Figure::mouseMode (void)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
281 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
282 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
283
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
284 const figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
285
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
286 std::string mode = fp.get___mouse_mode__ ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
287
19901
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
288 if (mode == "zoom")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
289 {
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
290 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: 19757
diff changeset
291
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
292 std::string direction = zm.getfield ("Direction").string_value ();
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
293
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
294 mode += " " + direction;
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20149
diff changeset
295 }
19901
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19757
diff changeset
296
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
297 return mouse_mode_from_string (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
298 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
299
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
300 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
301 Figure::createFigureToolBarAndMenuBar (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
302 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
303 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
304
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
305 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
306 m_figureToolBar->setMovable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
307 m_figureToolBar->setFloatable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
308
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
309 m_mouseModeGroup = new MouseModeActionGroup (win);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
310 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)),
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
311 SLOT (setMouseMode (MouseMode)));
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
312 m_figureToolBar->addActions (m_mouseModeGroup->actions ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
313
20042
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20041
diff changeset
314 QAction *toggle_axes = m_figureToolBar->addAction (tr ("Axes"));
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
315 connect (toggle_axes, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
316 this, SLOT (toggleAxes (void)));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
317
20042
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20041
diff changeset
318 QAction *toggle_grid = m_figureToolBar->addAction (tr ("Grid"));
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
319 connect (toggle_grid, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
320 this, SLOT (toggleGrid (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
321
20042
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20041
diff changeset
322 QAction *auto_axes = m_figureToolBar->addAction (tr ("Autoscale"));
19905
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
323 connect (auto_axes, SIGNAL (triggered (void)),
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
324 this, SLOT (autoAxes (void)));
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
325
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 m_menuBar = new MenuBar (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327 win->setMenuBar (m_menuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
328
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329 QMenu* fileMenu = m_menuBar->addMenu (tr ("&File"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330 fileMenu->menuAction ()->setObjectName ("builtinMenu");
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
331 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: 19715
diff changeset
332 fileMenu->addAction (tr ("Save &As"), this, SLOT (fileSaveFigureAs (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
333 fileMenu->addSeparator ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
334 fileMenu->addAction (tr ("&Close Figure"), this,
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
335 SLOT (fileCloseFigure (void)), Qt::CTRL|Qt::Key_W);
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* editMenu = m_menuBar->addMenu (tr ("&Edit"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 editMenu->menuAction ()->setObjectName ("builtinMenu");
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
339 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (bool)),
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
340 Qt::CTRL|Qt::Key_C);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341 editMenu->addSeparator ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
342 editMenu->addActions (m_mouseModeGroup->actions ());
18498
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 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
345 helpMenu->menuAction ()->setObjectName ("builtinMenu");
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
346 helpMenu->addAction (tr ("&About QtHandles"), this,
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
347 SLOT (helpAboutQtHandles (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
348 helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
349
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
350 m_menuBar->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
351 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
352
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
353 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
354 Figure::updateFigureToolBarAndMenuBar (void)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
355 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
356 if (m_mouseModeGroup)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
357 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
358 m_blockUpdates = true;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
359 m_mouseModeGroup->setMode (mouseMode ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
360 m_blockUpdates = false;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
361 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
362 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
363
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
364 Container*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
365 Figure::innerContainer (void)
18498
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 return m_container;
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
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
370 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
371 Figure::redraw (void)
18498
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 Canvas* canvas = m_container->canvas (m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
374
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
375 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
376 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377 canvas->redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
378 //canvas->setMouseMode (RotateMode);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
379 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
380
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
381 foreach (QFrame* frame,
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
382 qWidget<QWidget> ()->findChildren<QFrame*> ("UIPanel"))
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
383 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
384 Object* obj = Object::fromQObject (frame);
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 if (obj)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
387 obj->slotRedraw ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
388 }
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
389
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
390 updateFigureToolBarAndMenuBar ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
391 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
392
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
393 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
394 Figure::print (const QString& file_cmd, const QString& term)
19715
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
395 {
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
396 Canvas* canvas = m_container->canvas (m_handle);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
397
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
398 if (canvas)
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
399 canvas->print (file_cmd, term);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
400 }
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
401
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
402 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
403 Figure::beingDeleted (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
404 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
405 Canvas* canvas = m_container->canvas (m_handle.value (), false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
406
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
407 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
408 canvas->blockRedraw (true);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
409
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
410 m_menuBar->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
411 m_container->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
412 qWidget<FigureWindow> ()->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
414
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
415 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
416 Figure::update (int pId)
18498
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 if (m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
420
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
421 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
423
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
424 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
425
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426 switch (pId)
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 case figure::properties::ID_POSITION:
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
429 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
430 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
431 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
432 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
433
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
434 foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
435 if (! tb->isHidden ())
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
436 toffset += tb->sizeHint ().height ();
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
437
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
438 if (! m_menuBar->isHidden ())
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
439 toffset += m_menuBar->sizeHint ().height () + 1;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
440
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
441 if (! m_statusBar->isHidden ())
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
442 boffset += m_statusBar->sizeHint ().height () + 1;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
443
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
444 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
445 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
446 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
447
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
448 case figure::properties::ID_NAME:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
449 case figure::properties::ID_NUMBERTITLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
450 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
451 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
452
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
453 case figure::properties::ID_VISIBLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
454 if (fp.is_visible ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
455 QTimer::singleShot (0, win, SLOT (show ()));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
456 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
457 win->hide ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
458 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
459
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
460 case figure::properties::ID_TOOLBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
461 if (fp.toolbar_is ("none"))
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
462 showFigureToolBar (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
463 else if (fp.toolbar_is ("figure"))
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
464 showFigureToolBar (true);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
465 else // "auto"
20012
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20002
diff changeset
466 showFigureToolBar (! hasUiControlChildren (fp) &&
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20002
diff changeset
467 fp.menubar_is ("figure"));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
469
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
470 case figure::properties::ID_MENUBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
471 showMenuBar (fp.menubar_is ("figure"));
20012
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20002
diff changeset
472 if (fp.toolbar_is ("auto"))
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20002
diff changeset
473 showFigureToolBar (fp.menubar_is ("figure"));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
474 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
475
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
476 case figure::properties::ID_KEYPRESSFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
477 if (fp.get_keypressfcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
478 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
479 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
480 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
481 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
482
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
483 case figure::properties::ID_KEYRELEASEFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
484 if (fp.get_keyreleasefcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
485 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
486 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
487 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
488 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
489
18646
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
490 case figure::properties::ID_WINDOWBUTTONMOTIONFCN:
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
491 {
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
492 bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty ();
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
493
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
494 m_container->canvas (m_handle)->enableCurrentPointUpdates (hasCallback);
18646
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
495 }
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
496 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
497
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
498 default:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
499 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
500 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
501
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
502 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
505 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
506 Figure::showFigureToolBar (bool visible)
18498
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 if ((! m_figureToolBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
509 {
20539
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
510 int dy1 = m_figureToolBar->sizeHint ().height ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
511 int dy2 = m_statusBar->sizeHint ().height ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
512 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
513
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
514 if (! visible)
20539
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
515 r.adjust (0, dy1, 0, -dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
516 else
20539
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
517 r.adjust (0, -dy1, 0, dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
519 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
520 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
521 m_figureToolBar->setVisible (visible);
20539
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20305
diff changeset
522 m_statusBar->setVisible (visible);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
523 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
525 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
526 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
527 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
528
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
529 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
530 Figure::showMenuBar (bool visible)
18498
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 int h1 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
533
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
534 foreach (QAction* a, m_menuBar->actions ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
535 if (a->objectName () == "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
536 a->setVisible (visible);
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 int h2 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541 visible = hasUiMenuChildren (properties<figure> ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543 if ((! m_menuBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
544 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545 int dy = qMax (h1, h2) + 1;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
546 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
547
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
548 //qDebug () << "Figure::showMenuBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
549 if (! visible)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
550 r.adjust (0, dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
551 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
552 r.adjust (0, -dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553 //qDebug () << "Figure::showMenuBar(adjusted):" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
554
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
555 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
556 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
557 m_menuBar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
558 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
559
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
560 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
561 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
562 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
563
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
564 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
565 Figure::updateMenuBar (void)
18498
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 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
568 graphics_object go = object ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
569
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
570 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
571 showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
572 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
573
20305
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
574 void
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
575 Figure::updateStatusBar (ColumnVector pt)
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
576 {
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
577 if (! m_statusBar->isHidden ())
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
578 m_statusBar->showMessage (QString ("(%1, %2)")
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
579 .arg (pt(0), 0, 'g', 5)
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
580 .arg (pt(1), 0, 'g', 5));
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
581 }
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20277
diff changeset
582
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
583 QWidget*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
584 Figure::menu (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
585 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
586 return qWidget<QMainWindow> ()->menuBar ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
587 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
588
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589 struct UpdateBoundingBoxData
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
590 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
591 Matrix m_bbox;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
592 bool m_internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
593 graphics_handle m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
594 Figure* m_figure;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
595 };
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
596
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
597 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
598 Figure::updateBoundingBoxHelper (void* data)
18498
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 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
601
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
602 UpdateBoundingBoxData* d = reinterpret_cast<UpdateBoundingBoxData*> (data);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
603 graphics_object go = gh_manager::get_object (d->m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
604
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
605 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
606 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607 figure::properties& fp = Utils::properties<figure> (go);
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 fp.set_boundingbox (d->m_bbox, d->m_internal, false);
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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
612 delete d;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
614
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
615 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
616 Figure::updateBoundingBox (bool internal, int flags)
18498
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 QWidget* win = qWidget<QWidget> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
619 Matrix bb (1, 4);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
620
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
621 if (internal)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
622 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
623 QRect r = m_innerRect;
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 (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
626 r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
627 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
628 r.setSize (m_container->size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630 if (r.isValid () && r != m_innerRect)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
631 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
632 m_innerRect = r;
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 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
635 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
636 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
637 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
638 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
639 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
641 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
642 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
643 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
644 QRect r = m_outerRect;
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 if (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647 r.moveTopLeft (win->pos ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
648 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649 r.setSize (win->frameGeometry ().size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
650
18712
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18646
diff changeset
651 if (r.isValid () && r != m_outerRect)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
652 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
653 m_outerRect = r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
654
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
655 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
656 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
657 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
658 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
659 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
660 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
661 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
662 }
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 UpdateBoundingBoxData* d = new UpdateBoundingBoxData ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
665
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
666 d->m_bbox = bb;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
667 d->m_internal = internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
668 d->m_handle = m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
669 d->m_figure = this;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
670
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
671 gh_manager::post_function (Figure::updateBoundingBoxHelper, d);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
672 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
673
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
674 bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
675 Figure::eventNotifyBefore (QObject* obj, QEvent* xevent)
18498
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 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
678 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
679 if (obj == m_container)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
680 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
681 // Do nothing...
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
682 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
683 else if (obj == m_menuBar)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
684 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
685 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
686 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
687 case QEvent::ActionRemoved:
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
688 {
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
689 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
690
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
691 if (! a->isSeparator ()
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
692 && a->objectName () != "builtinMenu")
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
693 updateMenuBar ();
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
694 }
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
695 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
696
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
697 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
698 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
699 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
700 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
701 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
702 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
703 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
704 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
705 case QEvent::Close:
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
706 xevent->ignore ();
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
707 gh_manager::post_callback (m_handle, "closerequestfcn");
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
708 return true;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
709
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
710 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
711 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
712 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
713 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
714 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
715
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
716 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
717 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
718
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
719 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
720 Figure::eventNotifyAfter (QObject* watched, QEvent* xevent)
18498
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 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
723 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
724 if (watched == m_container)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
725 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
726 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
727 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
728 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
729 updateBoundingBox (true, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
730 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
731
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
732 case QEvent::ChildAdded:
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
733 if (dynamic_cast<QChildEvent*> (xevent)->child
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
734 ()->isWidgetType())
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
735 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
736 gh_manager::auto_lock lock;
20559
88459dd6780f Fix inconsistent toolbar state after creating an uicontrol (bug #46025)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20539
diff changeset
737 update (figure::properties::ID_TOOLBAR);
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
738 }
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
739
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
740 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
741 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
742 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
743 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
744 else if (watched == m_menuBar)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
745 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
746 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
747 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
748 case QEvent::ActionAdded:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
749 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
750 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
751
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
752 if (! a->isSeparator ()
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
753 && a->objectName () != "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
754 updateMenuBar ();
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
755 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
756 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
757
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
758 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
759 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
760 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
761 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
762 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
763 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
764 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
765 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
766 case QEvent::Move:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
767 updateBoundingBox (false, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
768 updateBoundingBox (true, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
769 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
770
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
771 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
772 updateBoundingBox (false, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
773 break;
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
774
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
775 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
776 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
777 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
778 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
779 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
780 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
782 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
783 Figure::helpAboutQtHandles (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
784 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
785 QMessageBox::about (qWidget<QMainWindow> (), tr ("About QtHandles"),
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
786 ABOUT_TEXT);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
787 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
788
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
789 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
790 Figure::setMouseMode (MouseMode mode)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
791 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
792 if (m_blockUpdates)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
793 return;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
794
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
795 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
796
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
797 figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
798
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
799 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: 19659
diff changeset
800
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
801 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
802
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
803 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
804 canvas->setCursor (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
805 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
806
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
807 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
808 Figure::fileSaveFigure (bool prompt)
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
809 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
810 QString file = fileName ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
811
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
812 if (file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
813 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
814 prompt = true;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
815
19757
c9dc27cad3c0 Use default format of PDF for saving Qt plots.
Rik <rik@octave.org>
parents: 19756
diff changeset
816 file = "untitled.pdf";
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
817 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
818
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
819 if (prompt || file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
820 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
821 QFileInfo finfo (file);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
822
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
823 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
824 tr ("Save Figure As"),
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
825 finfo.absoluteFilePath (), 0, 0,
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
826 QFileDialog::DontUseNativeDialog);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
827 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
828
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
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: 19715
diff changeset
830 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
831 QFileInfo finfo (file);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
832
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
833 setFileName (finfo.absoluteFilePath ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
834
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
835 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: 19715
diff changeset
836 file.toStdString ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
837 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
838 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
839
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
840 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
841 Figure::save_figure_callback (const std::string& file)
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
842 {
20277
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20216
diff changeset
843 figure::properties& fp = properties<figure> ();
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20216
diff changeset
844 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: 20216
diff changeset
845
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20216
diff changeset
846 Ffeval (ovl ("print", fnum, file));
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
847 }
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
848
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
849 void
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
850 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: 20113
diff changeset
851 {
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
852 std::string msg;
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
853
20120
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20114
diff changeset
854 std::string file = octave_tempnam ("", "oct-", msg) + "." + format;
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
855
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
856 if (file.empty ())
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
857 {
20120
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20114
diff changeset
858 // Report error?
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
859 return;
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
860 }
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
861
20277
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20216
diff changeset
862 save_figure_callback (file);
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
863
20148
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20120
diff changeset
864 octave_link::copy_image_to_clipboard (file);
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
865 }
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20149
diff changeset
866
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
867 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
868 Figure::fileSaveFigureAs (void)
19719
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
869 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
870 fileSaveFigure (true);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
871 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19715
diff changeset
872
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
873 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
874 Figure::fileCloseFigure (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
875 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
876 qWidget<QMainWindow> ()->close ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
877 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
878
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
879 void
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
880 Figure::editCopy (bool /* choose_format */)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
881 {
20149
5f0cb9bb6a50 use png instead of jpg as default format for copying plots to clipboard
John W. Eaton <jwe@octave.org>
parents: 20148
diff changeset
882 QString format = "png";
20114
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
883
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
884 #if 0
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
885
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
886 // FIXME: allow choice of image formats.
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
887
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
888 if (choose_format)
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
889 {
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
890 QFileInfo finfo (file);
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
891
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
892 format = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
893 tr ("Save Figure As"),
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
894 finfo.absoluteFilePath (), 0, 0,
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
895 QFileDialog::DontUseNativeDialog);
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
896 }
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
897 #endif
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
898
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
899 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: 20113
diff changeset
900 format.toStdString ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
901 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
902
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
903 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
904 Figure::addCustomToolBar (QToolBar* bar, bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
905 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
906 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
907
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
908 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
909 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
910 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
911 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
912 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
913 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
914 //qDebug () << "Figure::addCustomToolBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
915
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
916 r.adjust (0, -sz.height (), 0, 0);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
917
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
918 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
919 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
920 win->addToolBarBreak ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
921 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
922 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
923
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
924 //qDebug () << "Figure::addCustomToolBar:" << win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
925 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
926 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
927 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
928
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
929 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
930 Figure::showCustomToolBar (QToolBar* bar, bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
931 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
932 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
933
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
934 if ((! bar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
935 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
936 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
937 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
938
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
939 if (visible)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
940 r.adjust (0, -sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
941 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
942 r.adjust (0, sz.height (), 0, 0);
18498
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 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
945 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
946 bar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
947 m_blockUpdates = false;
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 updateBoundingBox (false);
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 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
952
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
953 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
954 Figure::updateContainer (void)
18498
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 redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
957 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
958
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
959 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
960 Figure::toggleAxes (void)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
961 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
962 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
963
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
964 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
965 canvas->toggleAxes (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
966 }
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20149
diff changeset
967
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
968 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
969 Figure::toggleGrid (void)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
970 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
971 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
972
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
973 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
974 canvas->toggleGrid (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
975 }
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20149
diff changeset
976
20002
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
977 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19990
diff changeset
978 Figure::autoAxes (void)
19905
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
979 {
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
980 Canvas* canvas = m_container->canvas (m_handle);
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
981
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
982 if (canvas)
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
983 canvas->autoAxes (m_handle);
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19901
diff changeset
984 }
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20149
diff changeset
985
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
986 }; // namespace QtHandles