Mercurial > hg > octave-nkf
annotate libgui/graphics/Figure.cc @ 20223:08fae2e963fb
Fix toolbar and menubar interaction at figure initialization (bug #44686)
* Figure.cc (Figure::Figure): when toolbar property is "auto", only show it if
the menubar is also shown.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Wed, 01 Apr 2015 23:03:04 +0200 |
parents | 8d0860d5fd5a |
children | 2d638e67aeef |
rev | line source |
---|---|
18566
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 |
20213
f0e61a67ad9f
Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents:
20176
diff
changeset
|
3 Copyright (C) 2011-2015 Michael Goffioul |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
5 This file is part of Octave. |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
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:
18566
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:
18566
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:
18566
diff
changeset
|
10 option) any later version. |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
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:
18566
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:
18566
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:
18566
diff
changeset
|
15 for more details. |
18566
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 |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
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:
18566
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
18566
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> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QEvent> |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
32 #include <QFileDialog> |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
33 #include <QFileInfo> |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <QFrame> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include <QMainWindow> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include <QMenu> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include <QMenuBar> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include <QMessageBox> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include <QtDebug> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include <QTimer> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include <QToolBar> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "Canvas.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "Container.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "Figure.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "FigureWindow.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 #include "MouseModeActionGroup.h" |
18573
fb96b7f55242
rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents:
18569
diff
changeset
|
48 #include "QtHandlesUtils.h" |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
50 #include "octave-qt-link.h" |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
51 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
52 #include "builtin-defun-decls.h" |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
53 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 |
20213
f0e61a67ad9f
Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents:
20176
diff
changeset
|
57 #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" |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
61 static bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
62 hasUiControlChildren (const figure::properties& fp) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 { |
20163
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
20079
diff
changeset
|
64 gh_manager::auto_lock lock; |
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
20079
diff
changeset
|
65 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 Matrix kids = fp.get_all_children (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 for (int i = 0; i < kids.numel (); i++) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 graphics_object go (gh_manager::get_object (kids(i))); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 if (go && (go.isa ("uicontrol") || go.isa ("uipanel") |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
73 || go.isa ("uibuttongroup"))) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
74 return true; |
18566
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 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
80 static bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
81 hasUiMenuChildren (const figure::properties& fp) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 { |
20163
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
20079
diff
changeset
|
83 gh_manager::auto_lock lock; |
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
20079
diff
changeset
|
84 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 Matrix kids = fp.get_all_children (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 for (int i = 0; i < kids.numel (); i++) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 graphics_object go (gh_manager::get_object (kids(i))); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 if (go && go.isa ("uimenu")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
92 return true; |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 return false; |
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 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
98 static QRect |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
99 boundingBoxToRect (const Matrix& bb) |
18566
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 QRect r; |
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 if (bb.numel () == 4) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 r = QRect (xround (bb(0)), xround (bb(1)), |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 xround (bb(2)), xround (bb(3))); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 if (! r.isValid ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 r = QRect (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 } |
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 return r; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
114 Figure* |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
115 Figure::create (const graphics_object& go) |
18566
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 new Figure (go, new FigureWindow ()); |
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 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 Figure::Figure (const graphics_object& go, FigureWindow* win) |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
121 : Object (go, win), m_blockUpdates (false), m_figureToolBar (0), |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
122 m_menuBar (0), m_innerRect (), m_outerRect (), m_mouseModeGroup (0) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 m_container = new Container (win); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 win->setCentralWidget (m_container); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 figure::properties& fp = properties<figure> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 createFigureToolBarAndMenuBar (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 int offset = 0; |
20223
08fae2e963fb
Fix toolbar and menubar interaction at figure initialization (bug #44686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20217
diff
changeset
|
132 if (fp.toolbar_is ("figure") || |
08fae2e963fb
Fix toolbar and menubar interaction at figure initialization (bug #44686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20217
diff
changeset
|
133 (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:
20217
diff
changeset
|
134 ! hasUiControlChildren (fp))) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 offset += m_figureToolBar->sizeHint ().height (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 m_figureToolBar->hide (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 if (fp.menubar_is ("figure") || hasUiMenuChildren (fp)) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 offset += m_menuBar->sizeHint ().height () + 1; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 m_menuBar->hide (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 //qDebug () << "Figure::Figure:" << m_innerRect; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 //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
|
149 win->setWindowTitle (Utils::fromStdString (fp.get_title ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 int eventMask = 0; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 if (! fp.get_keypressfcn ().is_empty ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 eventMask |= Canvas::KeyPress; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 if (! fp.get_keyreleasefcn ().is_empty ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 eventMask |= Canvas::KeyRelease; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 m_container->canvas (m_handle)->setEventMask (eventMask); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 |
18760
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
158 if (! fp.get_windowbuttonmotionfcn ().is_empty ()) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
159 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
160 m_container->setMouseTracking (true); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
161 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
162 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
163 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 connect (this, SIGNAL (asyncUpdate (void)), |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 this, SLOT (updateContainer (void))); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 if (fp.is_visible ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 QTimer::singleShot (0, win, SLOT (show ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 win->hide (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 win->addReceiver (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 m_container->addReceiver (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 Figure::~Figure (void) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
180 static std::string |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
181 mouse_mode_to_string (MouseMode mode) |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
182 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
183 switch (mode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
184 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
185 case NoMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
186 return "none"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
187 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
188 case RotateMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
189 return "rotate"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
190 |
20074
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
191 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
192 return "zoom in"; |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
193 |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
194 case ZoomOutMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
195 return "zoom out"; |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
196 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
197 case PanMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
198 return "pan"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
199 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
200 case TextMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
201 return "text"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
202 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
203 case SelectMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
204 return "select"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
205 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
206 default: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
207 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
208 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
209 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
210 return "none"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
211 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
212 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
213 static MouseMode |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
214 mouse_mode_from_string (const std::string& mode) |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
215 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
216 if (mode == "none") |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
217 return NoMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
218 else if (mode == "rotate") |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
219 return RotateMode; |
20074
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
220 else if (mode == "zoom in") |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
221 return ZoomInMode; |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
222 else if (mode == "zoom out") |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
223 return ZoomOutMode; |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
224 else if (mode == "pan") |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
225 return PanMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
226 else if (mode == "text") |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
227 return TextMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
228 else if (mode == "select") |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
229 return SelectMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
230 else |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
231 return NoMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
232 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
233 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
234 QString |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
235 Figure::fileName (void) |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
236 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
237 gh_manager::auto_lock lock; |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
238 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
239 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:
19882
diff
changeset
|
240 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
241 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:
19882
diff
changeset
|
242 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
243 return QString::fromStdString (name); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
244 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
245 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
246 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
247 Figure::setFileName (const QString& name) |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
248 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
249 gh_manager::auto_lock lock; |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
250 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
251 figure::properties& fp = properties<figure> (); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
252 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
253 fp.set_filename (name.toStdString ()); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
254 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
255 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
256 MouseMode |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
257 Figure::mouseMode (void) |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
258 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
259 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
260 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
261 const figure::properties& fp = properties<figure> (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
262 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
263 std::string mode = fp.get___mouse_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
264 |
20074
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
265 if (mode == "zoom") |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
266 { |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
267 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:
19926
diff
changeset
|
268 |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
269 std::string direction = zm.getfield ("Direction").string_value (); |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
270 |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
271 mode += " " + direction; |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
272 } |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19926
diff
changeset
|
273 |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
274 return mouse_mode_from_string (mode); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
275 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
276 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
277 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
278 Figure::createFigureToolBarAndMenuBar (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 QMainWindow* win = qWidget<QMainWindow> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 m_figureToolBar->setMovable (false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 m_figureToolBar->setFloatable (false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
286 m_mouseModeGroup = new MouseModeActionGroup (win); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
287 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)), |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
288 SLOT (setMouseMode (MouseMode))); |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
289 m_figureToolBar->addActions (m_mouseModeGroup->actions ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
290 |
20217
8d0860d5fd5a
Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents:
20216
diff
changeset
|
291 QAction *toggle_axes = m_figureToolBar->addAction (tr ("Axes")); |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
292 connect (toggle_axes, SIGNAL (triggered (void)), |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
293 this, SLOT (toggleAxes (void))); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
294 |
20217
8d0860d5fd5a
Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents:
20216
diff
changeset
|
295 QAction *toggle_grid = m_figureToolBar->addAction (tr ("Grid")); |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
296 connect (toggle_grid, SIGNAL (triggered (void)), |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
297 this, SLOT (toggleGrid (void))); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 |
20217
8d0860d5fd5a
Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents:
20216
diff
changeset
|
299 QAction *auto_axes = m_figureToolBar->addAction (tr ("Autoscale")); |
20079
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
300 connect (auto_axes, SIGNAL (triggered (void)), |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
301 this, SLOT (autoAxes (void))); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
302 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 m_menuBar = new MenuBar (win); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 win->setMenuBar (m_menuBar); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 QMenu* fileMenu = m_menuBar->addMenu (tr ("&File")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 fileMenu->menuAction ()->setObjectName ("builtinMenu"); |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
308 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:
19882
diff
changeset
|
309 fileMenu->addAction (tr ("Save &As"), this, SLOT (fileSaveFigureAs (void))); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 fileMenu->addSeparator (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
311 fileMenu->addAction (tr ("&Close Figure"), this, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
312 SLOT (fileCloseFigure (void)), Qt::CTRL|Qt::Key_W); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 editMenu->menuAction ()->setObjectName ("builtinMenu"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (void)), |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
317 Qt::CTRL|Qt::Key_C)->setEnabled (false); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 editMenu->addAction (tr ("Cu&t"), this, SLOT (editCut (void)), |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
319 Qt::CTRL|Qt::Key_X)->setEnabled (false); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 editMenu->addAction (tr ("&Paste"), this, SLOT (editPaste(void)), |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
321 Qt::CTRL|Qt::Key_V)->setEnabled (false); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 editMenu->addSeparator (); |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
323 editMenu->addActions (m_mouseModeGroup->actions ()); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 helpMenu->menuAction ()->setObjectName ("builtinMenu"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 helpMenu->addAction (tr ("&About QtHandles"), this, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
328 SLOT (helpAboutQtHandles (void))); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void))); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 m_menuBar->addReceiver (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
334 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
335 Figure::updateFigureToolBarAndMenuBar (void) |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
336 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
337 if (m_mouseModeGroup) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
338 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
339 m_blockUpdates = true; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
340 m_mouseModeGroup->setMode (mouseMode ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
341 m_blockUpdates = false; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
342 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
343 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
344 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
345 Container* |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
346 Figure::innerContainer (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 return m_container; |
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 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
351 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
352 Figure::redraw (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
353 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 Canvas* canvas = m_container->canvas (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 if (canvas) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 canvas->redraw (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 //canvas->setMouseMode (RotateMode); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 foreach (QFrame* frame, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
363 qWidget<QWidget> ()->findChildren<QFrame*> ("UIPanel")) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 Object* obj = Object::fromQObject (frame); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 if (obj) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
368 obj->slotRedraw (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 } |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
370 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
371 updateFigureToolBarAndMenuBar (); |
18566
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 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
374 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
375 Figure::print (const QString& file_cmd, const QString& term) |
19882
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19864
diff
changeset
|
376 { |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19864
diff
changeset
|
377 Canvas* canvas = m_container->canvas (m_handle); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19864
diff
changeset
|
378 |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19864
diff
changeset
|
379 if (canvas) |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19864
diff
changeset
|
380 canvas->print (file_cmd, term); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19864
diff
changeset
|
381 } |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19864
diff
changeset
|
382 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
383 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
384 Figure::beingDeleted (void) |
18566
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 Canvas* canvas = m_container->canvas (m_handle.value (), false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 if (canvas) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 canvas->blockRedraw (true); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 m_menuBar->removeReceiver (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 m_container->removeReceiver (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 qWidget<FigureWindow> ()->removeReceiver (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
396 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
397 Figure::update (int pId) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 if (m_blockUpdates) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 return; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 figure::properties& fp = properties<figure> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 QMainWindow* win = qWidget<QMainWindow> (); |
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 m_blockUpdates = true; |
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 switch (pId) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 case figure::properties::ID_POSITION: |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
410 { |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 //qDebug () << "Figure::update(position):" << m_innerRect; |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
413 int offset = 0; |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 foreach (QToolBar* tb, win->findChildren<QToolBar*> ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 if (! tb->isHidden ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 offset += tb->sizeHint ().height (); |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
418 if (! m_menuBar->isHidden ()) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
419 offset += m_menuBar->sizeHint ().height () + 1; |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 //qDebug () << "Figure::update(position)(adjusted):" << m_innerRect.adjusted (0, -offset, 0, 0); |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
421 win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0)); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 //qDebug () << "Figure::update(position): done"; |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
423 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
425 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 case figure::properties::ID_NAME: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 case figure::properties::ID_NUMBERTITLE: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
428 win->setWindowTitle (Utils::fromStdString (fp.get_title ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
430 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 case figure::properties::ID_VISIBLE: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 if (fp.is_visible ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
433 QTimer::singleShot (0, win, SLOT (show ())); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 else |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
435 win->hide (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
437 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 case figure::properties::ID_TOOLBAR: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 if (fp.toolbar_is ("none")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
440 showFigureToolBar (false); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 else if (fp.toolbar_is ("figure")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
442 showFigureToolBar (true); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
443 else // "auto" |
20186
5e6e0563388b
Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20176
diff
changeset
|
444 showFigureToolBar (! hasUiControlChildren (fp) && |
5e6e0563388b
Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20176
diff
changeset
|
445 fp.menubar_is ("figure")); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
447 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 case figure::properties::ID_MENUBAR: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 showMenuBar (fp.menubar_is ("figure")); |
20186
5e6e0563388b
Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20176
diff
changeset
|
450 if (fp.toolbar_is ("auto")) |
5e6e0563388b
Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20176
diff
changeset
|
451 showFigureToolBar (fp.menubar_is ("figure")); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
452 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
453 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 case figure::properties::ID_KEYPRESSFCN: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
455 if (fp.get_keypressfcn ().is_empty ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
456 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
457 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
460 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 case figure::properties::ID_KEYRELEASEFCN: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 if (fp.get_keyreleasefcn ().is_empty ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
463 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
464 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
465 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
467 |
18760
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
468 case figure::properties::ID_WINDOWBUTTONMOTIONFCN: |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
469 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
470 bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
471 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
472 m_container->setMouseTracking (hasCallback); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
473 foreach (QWidget* w, m_container->findChildren<QWidget*> ()) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
474 { w->setMouseTracking (hasCallback); } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
475 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
476 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
477 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
478 default: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 break; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
480 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
481 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 m_blockUpdates = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
485 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
486 Figure::showFigureToolBar (bool visible) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 if ((! m_figureToolBar->isHidden ()) != visible) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
489 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 int dy = m_figureToolBar->sizeHint ().height (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
491 QRect r = qWidget<QWidget> ()->geometry (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
492 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
493 if (! visible) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
494 r.adjust (0, dy, 0, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
495 else |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
496 r.adjust (0, -dy, 0, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
498 m_blockUpdates = true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 qWidget<QWidget> ()->setGeometry (r); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 m_figureToolBar->setVisible (visible); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 m_blockUpdates = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 updateBoundingBox (false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
504 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
506 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
507 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
508 Figure::showMenuBar (bool visible) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 int h1 = m_menuBar->sizeHint ().height (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 foreach (QAction* a, m_menuBar->actions ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 if (a->objectName () == "builtinMenu") |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 a->setVisible (visible); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 int h2 = m_menuBar->sizeHint ().height (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 if (! visible) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 visible = hasUiMenuChildren (properties<figure> ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 if ((! m_menuBar->isHidden ()) != visible) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
522 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 int dy = qMax (h1, h2) + 1; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 QRect r = qWidget<QWidget> ()->geometry (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 //qDebug () << "Figure::showMenuBar:" << r; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 if (! visible) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
528 r.adjust (0, dy, 0, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 else |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
530 r.adjust (0, -dy, 0, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 //qDebug () << "Figure::showMenuBar(adjusted):" << r; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 m_blockUpdates = true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 qWidget<QWidget> ()->setGeometry (r); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 m_menuBar->setVisible (visible); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 m_blockUpdates = false; |
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 updateBoundingBox (false); |
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 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
542 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
543 Figure::updateMenuBar (void) |
18566
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 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 graphics_object go = object (); |
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 if (go.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 showMenuBar (Utils::properties<figure> (go).menubar_is ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
552 QWidget* |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
553 Figure::menu (void) |
18566
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 return qWidget<QMainWindow> ()->menuBar (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 struct UpdateBoundingBoxData |
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 Matrix m_bbox; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 bool m_internal; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 graphics_handle m_handle; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
563 Figure* m_figure; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 }; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
566 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
567 Figure::updateBoundingBoxHelper (void* data) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
568 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
569 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
570 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
571 UpdateBoundingBoxData* d = reinterpret_cast<UpdateBoundingBoxData*> (data); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
572 graphics_object go = gh_manager::get_object (d->m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
573 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
574 if (go.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
575 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
576 figure::properties& fp = Utils::properties<figure> (go); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
577 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
578 fp.set_boundingbox (d->m_bbox, d->m_internal, false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
580 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
581 delete d; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
582 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
584 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
585 Figure::updateBoundingBox (bool internal, int flags) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
586 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 QWidget* win = qWidget<QWidget> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
588 Matrix bb (1, 4); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 if (internal) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 QRect r = m_innerRect; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 if (flags & UpdateBoundingBoxPosition) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 r.moveTopLeft (win->mapToGlobal (m_container->pos ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
596 if (flags & UpdateBoundingBoxSize) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 r.setSize (m_container->size ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 if (r.isValid () && r != m_innerRect) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 m_innerRect = r; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 bb(0) = r.x (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 bb(1) = r.y (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 bb(2) = r.width (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 bb(3) = r.height (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 return; |
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 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
612 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 QRect r = m_outerRect; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 if (flags & UpdateBoundingBoxPosition) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
616 r.moveTopLeft (win->pos ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 if (flags & UpdateBoundingBoxSize) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
618 r.setSize (win->frameGeometry ().size ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
619 |
18833
6113e0c6920b
maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents:
18760
diff
changeset
|
620 if (r.isValid () && r != m_outerRect) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
621 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 m_outerRect = r; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
624 bb(0) = r.x (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
625 bb(1) = r.y (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
626 bb(2) = r.width (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
627 bb(3) = r.height (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 return; |
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 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
633 UpdateBoundingBoxData* d = new UpdateBoundingBoxData (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 d->m_bbox = bb; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 d->m_internal = internal; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
637 d->m_handle = m_handle; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 d->m_figure = this; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 gh_manager::post_function (Figure::updateBoundingBoxHelper, d); |
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 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
643 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
644 Figure::eventNotifyBefore (QObject* obj, QEvent* xevent) |
18566
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 (! m_blockUpdates) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
647 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 if (obj == m_container) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
649 { |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 // Do nothing... |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
651 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 else if (obj == m_menuBar) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
653 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
654 switch (xevent->type ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
655 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
656 case QEvent::ActionRemoved: |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
657 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
658 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
659 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
660 if (! a->isSeparator () |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
661 && a->objectName () != "builtinMenu") |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
662 updateMenuBar (); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
663 } |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
664 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
665 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
666 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
667 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
668 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
669 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 else |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
671 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
672 switch (xevent->type ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
673 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
674 case QEvent::Close: |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
675 xevent->ignore (); |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
676 gh_manager::post_callback (m_handle, "closerequestfcn"); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
677 return true; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
678 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
679 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
680 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
681 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
682 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
683 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
684 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
685 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
688 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
689 Figure::eventNotifyAfter (QObject* watched, QEvent* xevent) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
691 if (! m_blockUpdates) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
692 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 if (watched == m_container) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
695 switch (xevent->type ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
696 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
697 case QEvent::Resize: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
698 updateBoundingBox (true, UpdateBoundingBoxSize); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
699 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
700 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
701 case QEvent::ChildAdded: |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
702 if (dynamic_cast<QChildEvent*> (xevent)->child |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
703 ()->isWidgetType()) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
704 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
705 gh_manager::auto_lock lock; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
706 const figure::properties& fp = properties<figure> (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
707 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
708 showFigureToolBar (! hasUiControlChildren (fp)); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
709 } |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
710 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
711 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
712 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
713 } |
18566
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 else if (watched == m_menuBar) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
716 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
717 switch (xevent->type ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
718 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
719 case QEvent::ActionAdded: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
720 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
721 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
722 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
723 if (! a->isSeparator () |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 && a->objectName () != "builtinMenu") |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 updateMenuBar (); |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
726 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
727 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
728 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
729 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
730 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
731 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
732 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
733 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
735 switch (xevent->type ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
736 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
737 case QEvent::Move: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
738 updateBoundingBox (false, UpdateBoundingBoxPosition); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
739 updateBoundingBox (true, UpdateBoundingBoxPosition); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
740 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
741 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
742 case QEvent::Resize: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
743 updateBoundingBox (false, UpdateBoundingBoxSize); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
744 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
745 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
746 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
747 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
748 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
749 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
750 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
751 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
753 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
754 Figure::helpAboutQtHandles (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
756 QMessageBox::about (qWidget<QMainWindow> (), tr ("About QtHandles"), |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
757 ABOUT_TEXT); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
758 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
759 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
760 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
761 Figure::setMouseMode (MouseMode mode) |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
762 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
763 if (m_blockUpdates) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
764 return; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
765 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
766 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
767 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
768 figure::properties& fp = properties<figure> (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
769 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
770 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:
19822
diff
changeset
|
771 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
772 Canvas* canvas = m_container->canvas (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
773 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
774 if (canvas) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
775 canvas->setCursor (mode); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
776 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
777 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
778 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
779 Figure::fileSaveFigure (bool prompt) |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
780 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
781 QString file = fileName (); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
782 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
783 if (file.isEmpty ()) |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
784 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
785 prompt = true; |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
786 |
19926
c9dc27cad3c0
Use default format of PDF for saving Qt plots.
Rik <rik@octave.org>
parents:
19925
diff
changeset
|
787 file = "untitled.pdf"; |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
788 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
789 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
790 if (prompt || file.isEmpty ()) |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
791 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
792 QFileInfo finfo (file); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
793 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
794 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (), |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
795 tr ("Save Figure As"), |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
796 finfo.absoluteFilePath (), 0, 0, |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
797 QFileDialog::DontUseNativeDialog); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
798 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
799 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
800 if (! file.isEmpty ()) |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
801 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
802 QFileInfo finfo (file); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
803 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
804 setFileName (finfo.absoluteFilePath ()); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
805 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
806 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:
19882
diff
changeset
|
807 file.toStdString ()); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
808 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
809 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
810 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
811 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
812 Figure::save_figure_callback (const std::string& file) |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
813 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
814 Ffeval (ovl ("print", file)); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
815 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
816 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
817 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
818 Figure::fileSaveFigureAs (void) |
19886
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
819 { |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
820 fileSaveFigure (true); |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
821 } |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19882
diff
changeset
|
822 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
823 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
824 Figure::fileCloseFigure (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
825 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
826 qWidget<QMainWindow> ()->close (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
827 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
828 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
829 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
830 Figure::editCopy (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
831 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
832 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
833 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
834 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
835 Figure::editCut (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
836 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
837 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
838 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
839 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
840 Figure::editPaste (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
841 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
842 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
843 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
844 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
845 Figure::addCustomToolBar (QToolBar* bar, bool visible) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
846 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
847 QMainWindow* win = qWidget<QMainWindow> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
848 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
849 if (! visible) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
850 win->addToolBar (bar); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
851 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
852 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
853 QSize sz = bar->sizeHint (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
854 QRect r = win->geometry (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
855 //qDebug () << "Figure::addCustomToolBar:" << r; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
856 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
857 r.adjust (0, -sz.height (), 0, 0); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
858 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
859 m_blockUpdates = true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
860 win->setGeometry (r); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
861 win->addToolBarBreak (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
862 win->addToolBar (bar); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
863 m_blockUpdates = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
864 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
865 //qDebug () << "Figure::addCustomToolBar:" << win->geometry (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
866 updateBoundingBox (false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
867 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
868 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
869 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
870 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
871 Figure::showCustomToolBar (QToolBar* bar, bool visible) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
872 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
873 QMainWindow* win = qWidget<QMainWindow> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
874 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
875 if ((! bar->isHidden ()) != visible) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
876 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
877 QSize sz = bar->sizeHint (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
878 QRect r = win->geometry (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
879 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
880 if (visible) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
881 r.adjust (0, -sz.height (), 0, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
882 else |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
883 r.adjust (0, sz.height (), 0, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
884 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
885 m_blockUpdates = true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
886 win->setGeometry (r); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
887 bar->setVisible (visible); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
888 m_blockUpdates = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
889 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
890 updateBoundingBox (false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
891 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
892 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
893 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
894 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
895 Figure::updateContainer (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
896 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
897 redraw (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
898 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
899 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
900 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
901 Figure::toggleAxes (void) |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
902 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
903 Canvas* canvas = m_container->canvas (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
904 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
905 if (canvas) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
906 canvas->toggleAxes (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
907 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
908 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
909 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
910 Figure::toggleGrid (void) |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
911 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
912 Canvas* canvas = m_container->canvas (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
913 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
914 if (canvas) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
915 canvas->toggleGrid (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
916 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
917 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
918 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
20164
diff
changeset
|
919 Figure::autoAxes (void) |
20079
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
920 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
921 Canvas* canvas = m_container->canvas (m_handle); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
922 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
923 if (canvas) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
924 canvas->autoAxes (m_handle); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
925 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
20074
diff
changeset
|
926 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
927 }; // namespace QtHandles |