Mercurial > octave
annotate libgui/graphics/Figure.cc @ 25103:078b795c5219 stable
maint: style check C++ ahead of 4.4 release.
* ButtonGroup.cc, Canvas.cc, Figure.cc, GLCanvas.cc, GLCanvas.h,
ListBoxControl.cc, ObjectProxy.cc, QTerminal.h, dialog.cc, documentation.cc,
files-dock-widget.cc, history-dock-widget.cc, file-editor-tab.cc,
file-editor.h, find-dialog.cc, marker.h, octave-qscintilla.cc,
octave-qscintilla.h, main-window.cc, webinfo.cc, resource-manager.h,
settings-dialog.cc, shortcut-manager.cc, shortcut-manager.h,
variable-editor.cc, workspace-view.cc, build-env.in.cc, __ilu__.cc, cellfun.cc,
data.cc, dirfns.cc, dynamic-ld.h, environment.cc, error.cc, fcn-info.cc,
gl-render.cc, gl2ps-print.cc, graphics.cc, graphics.in.h, help.cc,
interpreter.cc, load-path.cc, load-save.cc, ls-mat5.cc, mex.cc, oct-stream.cc,
oct-stream.h, qz.cc, sighandlers.cc, sparse-xpow.cc, svd.cc, symscope.h,
symtab.cc, symtab.h, sysdep.cc, url-handle-manager.h, utils.cc, variables.cc,
__init_fltk__.cc, __ode15__.cc, gzip.cc, ov-base.cc, ov-builtin.h, ov-cell.cc,
ov-class.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-java.cc, ov-re-diag.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc,
op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc,
op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcs-fcm.cc, op-fcs-fcs.cc,
op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc,
op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc,
op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc,
op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc,
op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc,
op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc,
op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc,
op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc,
bp-table.cc, comment-list.h, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, lex.h,
parse.h, pt-binop.h, pt-decl.h, pt-eval.cc, pt-jit.cc, pt-jit.h, pt-misc.h,
token.h, CMatrix.cc, CMatrix.h, CSparse.cc, CSparse.h, dMatrix.h, fCMatrix.cc,
fCMatrix.h, fMatrix.h, Faddeeva.cc, gepbalance.cc, hess.cc, oct-fftw.cc,
oct-fftw.h, file-stat.cc, lo-sysinfo.cc, action-container.h, f77-fcn.h,
lo-regexp.cc, oct-mutex.h, oct-shlib.cc:
Use Octave coding conventions in C++ files.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 03 Apr 2018 13:52:07 -0700 |
parents | 6652d3823428 |
children | d04b74f5d02e 7a507e71d922 |
rev | line source |
---|---|
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25044
diff
changeset
|
3 Copyright (C) 2011-2018 Michael Goffioul |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
5 This file is part of Octave. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24465
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22744
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24465
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22744
diff
changeset
|
10 (at your option) any later version. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22744
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22744
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22744
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22744
diff
changeset
|
15 GNU General Public License for more details. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24465
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include <QAction> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include <QActionEvent> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <QActionGroup> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <QApplication> |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
31 #include <QClipboard> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <QEvent> |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
33 #include <QFileDialog> |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
34 #include <QFileInfo> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include <QFrame> |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
36 #include <QImage> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include <QMainWindow> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include <QMenu> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include <QMenuBar> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include <QMessageBox> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include <QtDebug> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include <QTimer> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include <QToolBar> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "Canvas.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "Container.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 #include "Figure.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 #include "FigureWindow.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "MouseModeActionGroup.h" |
18505
fb96b7f55242
rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents:
18501
diff
changeset
|
50 #include "QtHandlesUtils.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
52 #include "file-ops.h" |
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
53 #include "unwind-prot.h" |
20085
c58cf3a65519
improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20079
diff
changeset
|
54 #include "utils.h" |
21916
3a0c90b59584
Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents:
21824
diff
changeset
|
55 #include "version.h" |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
56 |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
57 #include "octave-qt-link.h" |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
58 |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
59 #include "builtin-defun-decls.h" |
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
60 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
64 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
65 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
66 static bool |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
67 hasUiControlChildren (const figure::properties& fp) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
68 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
69 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
70 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
71 Matrix kids = fp.get_all_children (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
73 for (int i = 0; i < kids.numel (); i++) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
74 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
75 graphics_object go (gh_manager::get_object (kids(i))); |
19954
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
76 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
77 if (go && (go.isa ("uicontrol") || go.isa ("uipanel") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
78 || go.isa ("uibuttongroup"))) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
79 return true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
80 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
82 return false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
83 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
84 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
85 static bool |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
86 hasUiMenuChildren (const figure::properties& fp) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
87 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
88 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
89 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
90 Matrix kids = fp.get_all_children (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
92 for (int i = 0; i < kids.numel (); i++) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
93 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
94 graphics_object go (gh_manager::get_object (kids(i))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
95 |
22757
90281ac10fb4
maint: Trim trailing whitespace from files.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
96 if (go && go.isa ("uimenu") && |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
97 go.get ("visible").string_value () == "on") |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
98 return true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
99 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
100 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
101 return false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
102 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
104 static QRect |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
105 boundingBoxToRect (const Matrix& bb) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
106 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
107 QRect r; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
109 if (bb.numel () == 4) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
110 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
111 r = QRect (octave::math::round (bb(0)), octave::math::round (bb(1)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
112 octave::math::round (bb(2)), octave::math::round (bb(3))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
113 if (! r.isValid ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
114 r = QRect (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
115 } |
19954
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
116 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
117 return r; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
118 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
120 Figure* |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
121 Figure::create (const graphics_object& go) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
122 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
123 return new Figure (go, new FigureWindow ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
124 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
126 Figure::Figure (const graphics_object& go, FigureWindow *win) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23793
diff
changeset
|
127 : Object (go, win), m_blockUpdates (false), m_figureToolBar (nullptr), |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23793
diff
changeset
|
128 m_menuBar (nullptr), m_innerRect (), m_outerRect (), |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23793
diff
changeset
|
129 m_mouseModeGroup (nullptr) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
130 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
131 m_container = new Container (win); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
132 win->setCentralWidget (m_container); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
134 figure::properties& fp = properties<figure> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
135 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
136 // Status bar |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
137 m_statusBar = win->statusBar (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
138 int boffset = 0; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
139 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
140 // Toolbar and menubar |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
141 createFigureToolBarAndMenuBar (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
142 int toffset = 0; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
144 if (fp.toolbar_is ("figure") || |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
145 (fp.toolbar_is ("auto") && fp.menubar_is ("figure") && |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
146 ! hasUiControlChildren (fp))) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
147 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
148 toffset += m_figureToolBar->sizeHint ().height (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
149 boffset += m_statusBar->sizeHint ().height (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
150 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
151 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
152 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
153 m_figureToolBar->hide (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
154 m_statusBar->hide (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
155 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
156 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
157 if (fp.menubar_is ("figure") || hasUiMenuChildren (fp)) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
158 toffset += m_menuBar->sizeHint ().height (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
159 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
160 m_menuBar->hide (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
162 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
163 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
164 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
165 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
166 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
167 // Enable mouse tracking unconditionally |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
168 enableMouseTracking (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
169 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
170 // When this constructor gets called all properties are already |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
171 // set, even non default. We force "update" here to get things right. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
173 // Figure title |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
174 update (figure::properties::ID_NUMBERTITLE); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
175 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
176 // Decide what keyboard events we listen to |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
177 m_container->canvas (m_handle)->setEventMask (0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
178 update (figure::properties::ID_KEYPRESSFCN); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
179 update (figure::properties::ID_KEYRELEASEFCN); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
180 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
181 // modal style |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
182 update (figure::properties::ID_WINDOWSTYLE); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
184 // Visibility |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
185 update (figure::properties::ID_VISIBLE); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
186 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
187 connect (this, SIGNAL (asyncUpdate (void)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
188 this, SLOT (updateContainer (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
189 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
190 win->addReceiver (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
191 m_container->addReceiver (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
192 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
193 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
194 Figure::~Figure (void) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22413
diff
changeset
|
195 { } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
197 static std::string |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
198 mouse_mode_to_string (MouseMode mode) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
199 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
200 switch (mode) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
201 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
202 case NoMode: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
203 return "none"; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
204 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
205 case RotateMode: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
206 return "rotate"; |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20524
diff
changeset
|
207 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
208 case ZoomInMode: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
209 return "zoom in"; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
210 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
211 case ZoomOutMode: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
212 return "zoom out"; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
214 case PanMode: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
215 return "pan"; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
217 case TextMode: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
218 return "text"; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
219 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
220 case SelectMode: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
221 return "select"; |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
222 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
223 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
224 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
225 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
226 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
227 return "none"; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
228 } |
20504
b6ae0ef9327e
Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents:
20270
diff
changeset
|
229 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
230 static MouseMode |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
231 mouse_mode_from_string (const std::string& mode) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
232 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
233 if (mode == "none") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
234 return NoMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
235 else if (mode == "rotate") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
236 return RotateMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
237 else if (mode == "zoom in") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
238 return ZoomInMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
239 else if (mode == "zoom out") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
240 return ZoomOutMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
241 else if (mode == "pan") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
242 return PanMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
243 else if (mode == "text") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
244 return TextMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
245 else if (mode == "select") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
246 return SelectMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
247 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
248 return NoMode; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
249 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
250 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
251 QString |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
252 Figure::fileName (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
253 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
254 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
255 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
256 const figure::properties& fp = properties<figure> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
257 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
258 std::string name = fp.get_filename (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
259 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
260 return QString::fromStdString (name); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
261 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
263 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
264 Figure::setFileName (const QString& name) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
265 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
266 gh_manager::auto_lock lock; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
268 figure::properties& fp = properties<figure> (); |
20537
d0f886a030b7
Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
269 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
270 fp.set_filename (name.toStdString ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
271 } |
20594
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20537
diff
changeset
|
272 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
273 MouseMode |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
274 Figure::mouseMode (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
275 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
276 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
277 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
278 const figure::properties& fp = properties<figure> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
279 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
280 std::string mode = fp.get___mouse_mode__ (); |
20537
d0f886a030b7
Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
281 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
282 if (mode == "zoom") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
283 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
284 octave_scalar_map zm = fp.get___zoom_mode__ ().scalar_map_value (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
285 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
286 std::string direction = zm.getfield ("Direction").string_value (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
287 |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23800
diff
changeset
|
288 mode += ' ' + direction; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
289 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
291 return mouse_mode_from_string (mode); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
292 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
294 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
295 Figure::createFigureToolBarAndMenuBar (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
296 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
297 QMainWindow *win = qWidget<QMainWindow> (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
298 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
299 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
300 m_figureToolBar->setMovable (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
301 m_figureToolBar->setFloatable (false); |
21996
d6370831d37f
Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents:
21916
diff
changeset
|
302 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
303 m_mouseModeGroup = new MouseModeActionGroup (win); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
304 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
305 SLOT (setMouseMode (MouseMode))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
306 m_figureToolBar->addActions (m_mouseModeGroup->actions ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
307 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
308 QAction *toggle_axes = m_figureToolBar->addAction (tr ("Axes")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
309 connect (toggle_axes, SIGNAL (triggered (void)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
310 this, SLOT (toggleAxes (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
311 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
312 QAction *toggle_grid = m_figureToolBar->addAction (tr ("Grid")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
313 connect (toggle_grid, SIGNAL (triggered (void)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
314 this, SLOT (toggleGrid (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
315 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
316 QAction *auto_axes = m_figureToolBar->addAction (tr ("Autoscale")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
317 connect (auto_axes, SIGNAL (triggered (void)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
318 this, SLOT (autoAxes (void))); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20595
diff
changeset
|
319 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
320 m_menuBar = new MenuBar (win); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
321 win->setMenuBar (m_menuBar); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
322 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
323 QMenu *fileMenu = m_menuBar->addMenu (tr ("&File")); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
324 fileMenu->menuAction ()->setObjectName ("builtinMenu"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
325 fileMenu->addAction (tr ("&Save"), this, SLOT (fileSaveFigure (bool))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
326 fileMenu->addAction (tr ("Save &As"), this, SLOT (fileSaveFigureAs (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
327 fileMenu->addSeparator (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
328 fileMenu->addAction (tr ("&Close Figure"), this, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
329 SLOT (fileCloseFigure (void)), Qt::CTRL | Qt::Key_W); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
330 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
331 QMenu *editMenu = m_menuBar->addMenu (tr ("&Edit")); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
332 editMenu->menuAction ()->setObjectName ("builtinMenu"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
333 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (bool)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
334 Qt::CTRL | Qt::Key_C); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
335 editMenu->addSeparator (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
336 editMenu->addActions (m_mouseModeGroup->actions ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
338 QMenu *helpMenu = m_menuBar->addMenu (tr ("&Help")); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
339 helpMenu->menuAction ()->setObjectName ("builtinMenu"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
340 helpMenu->addAction (tr ("About Octave"), this, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
341 SLOT (helpAboutOctave (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
342 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
343 m_menuBar->addReceiver (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
344 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
345 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
346 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
347 Figure::updateFigureToolBarAndMenuBar (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
348 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
349 if (m_mouseModeGroup) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
350 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
351 m_blockUpdates = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
352 m_mouseModeGroup->setMode (mouseMode ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
353 m_blockUpdates = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
354 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
355 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
357 Container* |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
358 Figure::innerContainer (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
359 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
360 return m_container; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
361 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
363 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
364 Figure::redraw (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
365 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
366 Canvas *canvas = m_container->canvas (m_handle); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
367 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
368 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
369 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
370 canvas->redraw (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
371 //canvas->setMouseMode (RotateMode); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
372 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
373 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
374 foreach (QFrame *frame, |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
375 qWidget<QWidget> ()->findChildren<QFrame*> ()) |
23223
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
376 { |
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
377 if (frame->objectName () == "UIPanel" |
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
378 || frame->objectName () == "UIButtonGroup") |
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
379 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
380 Object *obj = Object::fromQObject (frame); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
381 |
23223
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
382 if (obj) |
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
383 obj->slotRedraw (); |
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
384 } |
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
385 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
386 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
387 updateFigureToolBarAndMenuBar (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
388 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
389 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
390 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
391 Figure::print (const QString& file_cmd, const QString& term) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
392 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
393 Canvas *canvas = m_container->canvas (m_handle); |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
394 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
395 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
396 canvas->print (file_cmd, term); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
397 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
398 |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
399 uint8NDArray |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
400 Figure::slotGetPixels (void) |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
401 { |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
402 uint8NDArray retval; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
403 Canvas *canvas = m_container->canvas (m_handle); |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
404 |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
405 if (canvas) |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
406 { |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
407 gh_manager::process_events (); |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
408 gh_manager::auto_lock lock; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
409 retval = canvas->getPixels (); |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
410 } |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
411 |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
412 return retval; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
413 } |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
414 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
415 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
416 Figure::beingDeleted (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
417 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
418 Canvas *canvas = m_container->canvas (m_handle.value (), false); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
419 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
420 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
421 canvas->blockRedraw (true); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
423 m_menuBar->removeReceiver (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
424 m_container->removeReceiver (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
425 qWidget<FigureWindow> ()->removeReceiver (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
426 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
428 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
429 Figure::update (int pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
430 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
431 if (m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
432 return; |
19681
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
433 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
434 figure::properties& fp = properties<figure> (); |
24687
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
435 |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
436 if (fp.is___printing__ ()) |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
437 return; |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24687
diff
changeset
|
438 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
439 QMainWindow *win = qWidget<QMainWindow> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 |
25044
b6aea95a7bf9
store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents:
24691
diff
changeset
|
441 // If the window doesn't exist, there's nothing we can do. |
b6aea95a7bf9
store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents:
24691
diff
changeset
|
442 if (! win) |
b6aea95a7bf9
store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents:
24691
diff
changeset
|
443 return; |
b6aea95a7bf9
store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents:
24691
diff
changeset
|
444 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
445 m_blockUpdates = true; |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24687
diff
changeset
|
446 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
447 switch (pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
448 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
449 case figure::properties::ID_POSITION: |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
450 { |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
452 int toffset = 0; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
453 int boffset = 0; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
455 foreach (QToolBar *tb, win->findChildren<QToolBar*> ()) |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
456 if (! tb->isHidden ()) |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
457 toffset += tb->sizeHint ().height (); |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
458 |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
459 if (! m_menuBar->isHidden ()) |
22370
0a2961d5893c
Fix calculation of window height in Qt, FLTK (bug #48833, bug #48522).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
460 toffset += m_menuBar->sizeHint ().height (); |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20524
diff
changeset
|
461 |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
462 if (! m_statusBar->isHidden ()) |
22370
0a2961d5893c
Fix calculation of window height in Qt, FLTK (bug #48833, bug #48522).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
463 boffset += m_statusBar->sizeHint ().height (); |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
464 |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
465 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset)); |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
466 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
467 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
468 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
469 case figure::properties::ID_NAME: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
470 case figure::properties::ID_NUMBERTITLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
471 win->setWindowTitle (Utils::fromStdString (fp.get_title ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
472 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
473 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
474 case figure::properties::ID_VISIBLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
475 if (fp.is_visible ()) |
24687
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
476 { |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
477 QTimer::singleShot (0, win, SLOT (show ())); |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
478 if (! fp.is___gl_window__ ()) |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
479 { |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
480 gh_manager::auto_lock lock; |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
481 fp.set ("__gl_window__", "on"); |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
482 } |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24687
diff
changeset
|
483 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
484 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
485 win->hide (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
486 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
487 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
488 case figure::properties::ID_TOOLBAR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
489 if (fp.toolbar_is ("none")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
490 showFigureToolBar (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
491 else if (fp.toolbar_is ("figure")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
492 showFigureToolBar (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
493 else // "auto" |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
494 showFigureToolBar (! hasUiControlChildren (fp) && |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
495 fp.menubar_is ("figure")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
496 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
497 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
498 case figure::properties::ID_MENUBAR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
499 showMenuBar (fp.menubar_is ("figure")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
500 if (fp.toolbar_is ("auto")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
501 showFigureToolBar (fp.menubar_is ("figure")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
502 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
503 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
504 case figure::properties::ID_KEYPRESSFCN: |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23535
diff
changeset
|
505 if (fp.get_keypressfcn ().isempty ()) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
506 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
507 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
508 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
509 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
510 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
511 case figure::properties::ID_KEYRELEASEFCN: |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23535
diff
changeset
|
512 if (fp.get_keyreleasefcn ().isempty ()) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
513 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
514 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
515 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
516 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
517 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
518 case figure::properties::ID_WINDOWSTYLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
519 if (fp.windowstyle_is ("modal")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
520 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
521 bool is_visible = win->isVisible (); |
21996
d6370831d37f
Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents:
21916
diff
changeset
|
522 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
523 // if window is already visible, need to hide and reshow it in order to |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
524 // make it use the modal settings |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
525 if (is_visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
526 win->setVisible (false); |
21996
d6370831d37f
Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents:
21916
diff
changeset
|
527 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
528 win->setWindowModality (Qt::ApplicationModal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
529 win->setVisible (is_visible); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
530 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
531 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
532 win->setWindowModality (Qt::NonModal); |
21996
d6370831d37f
Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents:
21916
diff
changeset
|
533 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
534 break; |
21996
d6370831d37f
Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents:
21916
diff
changeset
|
535 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
536 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
537 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
538 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
540 m_blockUpdates = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
541 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
543 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
544 Figure::showFigureToolBar (bool visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
545 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
546 if ((! m_figureToolBar->isHidden ()) != visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
547 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
548 int dy1 = m_figureToolBar->sizeHint ().height (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
549 int dy2 = m_statusBar->sizeHint ().height (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
550 QRect r = qWidget<QWidget> ()->geometry (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
552 if (! visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
553 r.adjust (0, dy1, 0, -dy2); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
554 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
555 r.adjust (0, -dy1, 0, dy2); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
557 m_blockUpdates = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
558 qWidget<QWidget> ()->setGeometry (r); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
559 m_figureToolBar->setVisible (visible); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
560 m_statusBar->setVisible (visible); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
561 m_blockUpdates = false; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
563 updateBoundingBox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
564 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
565 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
567 void |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
568 Figure::showMenuBar (bool visible, int h1) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
569 { |
22757
90281ac10fb4
maint: Trim trailing whitespace from files.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
570 // Get the height before and after toggling the visibility of builtin menus |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
571 if (h1 <= 0) |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
572 h1 = m_menuBar->sizeHint ().height (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
573 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
574 foreach (QAction *a, m_menuBar->actions ()) |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
575 if (a->objectName () == "builtinMenu") |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
576 a->setVisible (visible); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
577 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
578 int h2 = m_menuBar->sizeHint ().height (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
580 // Keep the menubar visible if it contains custom menus |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
581 if (! visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
582 visible = hasUiMenuChildren (properties<figure> ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 |
23793
2641a0196176
don't use bitwise xor operator for logical xor operation
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
584 if ((m_menuBar->isVisible () && ! visible) |
2641a0196176
don't use bitwise xor operator for logical xor operation
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
585 || (! m_menuBar->isVisible () && visible)) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
586 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
587 int dy = qMax (h1, h2); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
588 QRect r = qWidget<QWidget> ()->geometry (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
590 if (! visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
591 r.adjust (0, dy, 0, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
592 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
593 r.adjust (0, -dy, 0, 0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
595 m_blockUpdates = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
596 qWidget<QWidget> ()->setGeometry (r); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
597 m_menuBar->setVisible (visible); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
598 m_blockUpdates = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
599 } |
22721
0cd8a1c22f23
Let Qt menubar be restored after being hidden (bug #49529).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22417
diff
changeset
|
600 updateBoundingBox (false); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
601 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
603 void |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
604 Figure::updateMenuBar (int height) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
605 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
606 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
607 graphics_object go = object (); |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20242
diff
changeset
|
608 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
609 if (go.valid_object ()) |
22757
90281ac10fb4
maint: Trim trailing whitespace from files.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
610 showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"), |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
611 height); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
612 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
614 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
615 Figure::updateStatusBar (ColumnVector pt) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
616 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
617 if (! m_statusBar->isHidden ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
618 m_statusBar->showMessage (QString ("(%1, %2)") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
619 .arg (pt(0), 0, 'g', 5) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
620 .arg (pt(1), 0, 'g', 5)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
621 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
623 QWidget* |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
624 Figure::menu (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
625 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
626 return qWidget<QMainWindow> ()->menuBar (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
627 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
629 struct UpdateBoundingBoxData |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
630 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
631 Matrix m_bbox; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
632 bool m_internal; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
633 graphics_handle m_handle; |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
634 Figure *m_figure; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
635 }; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
637 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
638 Figure::updateBoundingBoxHelper (void *data) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
639 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
640 gh_manager::auto_lock lock; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
642 UpdateBoundingBoxData *d = reinterpret_cast<UpdateBoundingBoxData *> (data); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
643 graphics_object go = gh_manager::get_object (d->m_handle); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
644 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
645 if (go.valid_object ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
646 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
647 figure::properties& fp = Utils::properties<figure> (go); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
648 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
649 fp.set_boundingbox (d->m_bbox, d->m_internal, false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
650 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
651 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
652 delete d; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
653 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
654 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
655 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
656 Figure::updateBoundingBox (bool internal, int flags) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
657 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
658 QWidget *win = qWidget<QWidget> (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
659 Matrix bb (1, 4); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
660 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
661 if (internal) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
662 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
663 QRect r = m_innerRect; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
665 if (flags & UpdateBoundingBoxPosition) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
666 r.moveTopLeft (win->mapToGlobal (m_container->pos ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
667 if (flags & UpdateBoundingBoxSize) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
668 r.setSize (m_container->size ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
669 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
670 if (r.isValid () && r != m_innerRect) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
671 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
672 m_innerRect = r; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
674 bb(0) = r.x (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
675 bb(1) = r.y (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
676 bb(2) = r.width (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
677 bb(3) = r.height (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
678 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
679 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
680 return; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
681 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
682 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
683 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
684 QRect r = m_outerRect; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
685 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
686 if (flags & UpdateBoundingBoxPosition) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
687 r.moveTopLeft (win->pos ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
688 if (flags & UpdateBoundingBoxSize) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
689 r.setSize (win->frameGeometry ().size ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
690 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
691 if (r.isValid () && r != m_outerRect) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
692 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
693 m_outerRect = r; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
694 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
695 bb(0) = r.x (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
696 bb(1) = r.y (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
697 bb(2) = r.width (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
698 bb(3) = r.height (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
699 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
700 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
701 return; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
702 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
703 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
704 UpdateBoundingBoxData *d = new UpdateBoundingBoxData (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
706 d->m_bbox = bb; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
707 d->m_internal = internal; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
708 d->m_handle = m_handle; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
709 d->m_figure = this; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
710 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
711 gh_manager::post_function (Figure::updateBoundingBoxHelper, d); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
712 } |
20594
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20537
diff
changeset
|
713 |
24435
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
714 void |
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
715 Figure::close_figure_callback (void) |
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
716 { |
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
717 figure::properties& fp = properties<figure> (); |
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
718 octave_value fnum = fp.get___myhandle__ ().as_octave_value (); |
24446
4ca5c9f899d3
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
24435
diff
changeset
|
719 |
24435
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
720 Ffeval (ovl ("close", fnum)); |
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
721 } |
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
722 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
723 bool |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
724 Figure::eventNotifyBefore (QObject *obj, QEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
725 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
726 if (! m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
727 { |
24465
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
728 // Clicking the toolbar or the menubar makes this figure current |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
729 if (xevent->type () == QEvent::MouseButtonPress) |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
730 { |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
731 figure::properties& fp = properties<figure> (); |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
732 graphics_object root = gh_manager::get_object (0); |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
733 if (fp.get_handlevisibility () == "on") |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
734 root.set ("currentfigure", |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
735 fp.get___myhandle__ ().as_octave_value ()); |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
736 } |
1b4c4d6ead56
Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24446
diff
changeset
|
737 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
738 if (obj == m_container) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
739 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
740 // Do nothing... |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
741 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
742 else if (obj == m_menuBar) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
743 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
744 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
745 { |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
746 case QEvent::ActionChanged: |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
747 m_previousHeight = m_menuBar->sizeHint ().height (); |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
748 break; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
749 case QEvent::ActionRemoved: |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
750 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
751 QAction *a = dynamic_cast<QActionEvent *> (xevent)->action (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
753 if (! a->isSeparator () |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
754 && a->objectName () != "builtinMenu") |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 updateMenuBar (); |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
756 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
757 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
758 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
759 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
760 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
761 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
762 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
763 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
764 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
765 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
766 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
767 case QEvent::Close: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
768 xevent->ignore (); |
24435
e7624c23b101
Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24210
diff
changeset
|
769 octave_link::post_event (this, &Figure::close_figure_callback); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
770 return true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
771 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
772 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
773 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
774 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
775 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
776 } |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
777 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
778 return false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
779 } |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
780 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
781 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
782 Figure::eventNotifyAfter (QObject *watched, QEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
783 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
784 if (! m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
785 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
786 if (watched == m_container) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
787 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
788 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
789 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
790 case QEvent::Resize: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
791 updateBoundingBox (true, UpdateBoundingBoxSize); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
792 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19955
diff
changeset
|
793 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
794 case QEvent::ChildAdded: |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23224
diff
changeset
|
795 if (dynamic_cast<QChildEvent *> (xevent)->child |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
796 ()->isWidgetType()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
797 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
798 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
799 update (figure::properties::ID_TOOLBAR); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
800 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
801 enableMouseTracking (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
802 } |
23800
2fdc65c031b5
Add break or continue statements to prevent implicit fall-through in case statements.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
803 break; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
804 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
805 case QEvent::ChildRemoved: |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23224
diff
changeset
|
806 if (dynamic_cast<QChildEvent *> (xevent)->child |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
807 ()->isWidgetType()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
808 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
809 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
810 update (figure::properties::ID_TOOLBAR); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
811 } |
23800
2fdc65c031b5
Add break or continue statements to prevent implicit fall-through in case statements.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
812 break; |
21916
3a0c90b59584
Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents:
21824
diff
changeset
|
813 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
814 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
815 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
816 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
817 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
818 else if (watched == m_menuBar) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
819 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
820 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
821 { |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
822 case QEvent::ActionChanged: |
23224
73f7ef7169ac
Make uimenu "Position" property Matlab-compatible (bug #50369).
Rik <rik@octave.org>
parents:
23223
diff
changeset
|
823 // The menubar may have been resized if no action is visible |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
824 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
825 QAction *a = dynamic_cast<QActionEvent *> (xevent)->action (); |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
826 if (m_menuBar->sizeHint ().height () != m_previousHeight |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
827 && a->objectName () != "builtinMenu" |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
828 && ! a->isSeparator ()) |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
829 updateMenuBar (m_previousHeight); |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
830 } |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
831 break; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
832 case QEvent::ActionAdded: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
833 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
834 QAction *a = dynamic_cast<QActionEvent *> (xevent)->action (); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
835 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
836 if (! a->isSeparator () |
22744
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
837 && a->objectName () != "builtinMenu" |
2df51376f587
Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22721
diff
changeset
|
838 && a->isVisible ()) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
839 updateMenuBar (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
840 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
841 break; |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
842 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
843 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
844 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
845 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
846 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
847 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
848 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
849 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
850 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
851 case QEvent::Move: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
852 updateBoundingBox (false, UpdateBoundingBoxPosition); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
853 updateBoundingBox (true, UpdateBoundingBoxPosition); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
854 break; |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
855 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
856 case QEvent::Resize: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
857 updateBoundingBox (false, UpdateBoundingBoxSize); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
858 break; |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
859 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
860 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
861 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
862 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
863 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
864 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
865 } |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
866 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
867 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
868 Figure::helpAboutOctave (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
869 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
870 std::string message |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
871 = octave_name_version_copyright_copying_warranty_and_bugs (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
872 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
873 QMessageBox::about (qWidget<QMainWindow> (), tr ("About Octave"), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
874 QString::fromStdString (message)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
875 } |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
876 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
877 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
878 Figure::setMouseMode (MouseMode mode) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
879 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
880 if (m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
881 return; |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
882 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
883 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
884 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
885 figure::properties& fp = properties<figure> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
886 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
887 fp.set___mouse_mode__ (mouse_mode_to_string (mode)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
888 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
889 Canvas *canvas = m_container->canvas (m_handle); |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
890 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
891 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
892 canvas->setCursor (mode); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
893 } |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
894 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
895 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
896 Figure::fileSaveFigure (bool prompt) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
897 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
898 QString file = fileName (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
899 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
900 if (file.isEmpty ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
901 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
902 prompt = true; |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
903 |
24209
92acdcf72c46
use .ofig instead of .fig in "save as" figure menu
John W. Eaton <jwe@octave.org>
parents:
24203
diff
changeset
|
904 file = "untitled.ofig"; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
905 } |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
906 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
907 if (prompt || file.isEmpty ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
908 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
909 QFileInfo finfo (file); |
20242
4c2d39de1e96
Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
910 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
911 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
912 tr ("Save Figure As"), |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23793
diff
changeset
|
913 finfo.absoluteFilePath (), |
24209
92acdcf72c46
use .ofig instead of .fig in "save as" figure menu
John W. Eaton <jwe@octave.org>
parents:
24203
diff
changeset
|
914 tr ("Octave Figure File (*.ofig);;Vector Image Formats (*.eps *.epsc *.pdf *.svg *.ps *.tikz);;Bitmap Image Formats (*.gif *.jpg *.png *.tiff)"), |
24202
014f47089682
make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
915 nullptr, |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
916 QFileDialog::DontUseNativeDialog); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
917 } |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
918 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
919 if (! file.isEmpty ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
920 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
921 QFileInfo finfo (file); |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
922 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
923 setFileName (finfo.absoluteFilePath ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
924 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
925 octave_link::post_event (this, &Figure::save_figure_callback, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
926 file.toStdString ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
927 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
928 } |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
929 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
930 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
931 Figure::save_figure_callback (const std::string& file) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
932 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
933 figure::properties& fp = properties<figure> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
934 octave_value fnum = fp.get___myhandle__ ().as_octave_value (); |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
935 |
24202
014f47089682
make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
936 size_t flen = file.length (); |
014f47089682
make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
937 |
24210
d26b8f30ee4b
fix lengths in .ofig suffix comparison
John W. Eaton <jwe@octave.org>
parents:
24209
diff
changeset
|
938 if (flen > 5 && file.substr (flen-5) == ".ofig") |
24202
014f47089682
make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
939 Ffeval (ovl ("hgsave", fnum, file)); |
014f47089682
make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
940 else |
014f47089682
make .fig files the default for saving from figure menus
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
941 Ffeval (ovl ("print", fnum, file)); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
942 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
943 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
944 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
945 Figure::copy_figure_callback (const std::string& format) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
946 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
947 std::string msg; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
948 |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23800
diff
changeset
|
949 std::string file = octave::sys::tempnam ("", "oct-", msg) + '.' + format; |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
950 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
951 if (file.empty ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
952 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
953 // Report error? |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
954 return; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
955 } |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20114
diff
changeset
|
956 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
957 save_figure_callback (file); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
958 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
959 octave_link::copy_image_to_clipboard (file); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
960 } |
19685
7335cc071ab0
make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
961 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
962 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
963 Figure::fileSaveFigureAs (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
964 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
965 fileSaveFigure (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
966 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
967 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
968 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
969 Figure::fileCloseFigure (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
970 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
971 qWidget<QMainWindow> ()->close (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
972 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
973 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
974 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
975 Figure::editCopy (bool /* choose_format */) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
976 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
977 QString format = "png"; |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
978 |
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
979 #if 0 |
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
980 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
981 // FIXME: allow choice of image formats. |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
982 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
983 if (choose_format) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
984 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
985 QFileInfo finfo (file); |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
986 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
987 format = QFileDialog::getSaveFileName (qWidget<FigureWindow> (), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
988 tr ("Save Figure As"), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
989 finfo.absoluteFilePath (), 0, 0, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
990 QFileDialog::DontUseNativeDialog); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
991 } |
20079
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
992 #endif |
27c0285828f8
make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents:
20078
diff
changeset
|
993 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
994 octave_link::post_event (this, &Figure::copy_figure_callback, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
995 format.toStdString ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
996 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
997 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
998 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
999 Figure::addCustomToolBar (QToolBar *bar, bool visible) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1000 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1001 QMainWindow *win = qWidget<QMainWindow> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1002 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1003 if (! visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1004 win->addToolBar (bar); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1005 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1006 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1007 QSize sz = bar->sizeHint (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1008 QRect r = win->geometry (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1009 //qDebug () << "Figure::addCustomToolBar:" << r; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1010 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1011 r.adjust (0, -sz.height (), 0, 0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1012 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1013 m_blockUpdates = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1014 win->setGeometry (r); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1015 win->addToolBarBreak (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1016 win->addToolBar (bar); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1017 m_blockUpdates = false; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1018 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1019 //qDebug () << "Figure::addCustomToolBar:" << win->geometry (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1020 updateBoundingBox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1021 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1022 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1023 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1024 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1025 Figure::showCustomToolBar (QToolBar *bar, bool visible) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1026 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1027 QMainWindow *win = qWidget<QMainWindow> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1028 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1029 if ((! bar->isHidden ()) != visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1030 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1031 QSize sz = bar->sizeHint (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1032 QRect r = win->geometry (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1033 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1034 if (visible) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1035 r.adjust (0, -sz.height (), 0, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1036 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1037 r.adjust (0, sz.height (), 0, 0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1038 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1039 m_blockUpdates = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1040 win->setGeometry (r); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1041 bar->setVisible (visible); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1042 m_blockUpdates = false; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1043 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1044 updateBoundingBox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1045 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1046 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1047 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1048 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1049 Figure::updateContainer (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1050 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1051 redraw (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1052 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1053 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1054 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1055 Figure::toggleAxes (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1056 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1057 Canvas *canvas = m_container->canvas (m_handle); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
1058 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1059 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1060 canvas->toggleAxes (m_handle); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1061 } |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20114
diff
changeset
|
1062 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1063 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1064 Figure::toggleGrid (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1065 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1066 Canvas *canvas = m_container->canvas (m_handle); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
1067 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1068 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1069 canvas->toggleGrid (m_handle); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1070 } |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20114
diff
changeset
|
1071 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1072 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1073 Figure::autoAxes (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1074 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1075 Canvas *canvas = m_container->canvas (m_handle); |
19870
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
1076 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1077 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1078 canvas->autoAxes (m_handle); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1079 } |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20114
diff
changeset
|
1080 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1081 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1082 Figure::enableMouseTracking (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1083 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1084 // Enable mouse tracking on every widgets |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1085 m_container->setMouseTracking (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1086 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
1087 foreach (QWidget *w, m_container->findChildren<QWidget*> ()) |
23223
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
1088 w->setMouseTracking (true); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22370
diff
changeset
|
1089 } |
20594
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20537
diff
changeset
|
1090 |
22413
8758addcf265
maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
1091 } |