annotate libgui/graphics/Figure.cc @ 21724:aba2e6293dd8

use "#if ..." consistently instead of "#ifdef" and "#ifndef" * configure.ac, Doxyfile.in, make_int.cc, Backend.cc, BaseControl.cc, ButtonControl.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, FigureWindow.cc, GLCanvas.cc, KeyMap.cc, ListBoxControl.cc, Logger.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc, ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc, RadioButtonControl.cc, SliderControl.cc, TextControl.cc, TextEdit.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, __init_qt__.cc, annotation-dialog.cc, gl-select.cc, module.mk, color-picker.cc, dialog.cc, documentation-dock-widget.cc, files-dock-widget.cc, find-files-dialog.cc, find-files-model.cc, history-dock-widget.cc, liboctgui-build-info.in.cc, file-editor-tab.cc, file-editor.cc, find-dialog.cc, marker.cc, marker.h, octave-qscintilla.cc, octave-txt-lexer.cc, main-window.cc, octave-cmd.cc, octave-dock-widget.cc, octave-gui.cc, octave-interpreter.cc, octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc, settings-dialog.cc, shortcut-manager.cc, terminal-dock-widget.cc, thread-manager.cc, welcome-wizard.cc, workspace-model.cc, workspace-view.cc, build-env.in.cc, Cell.cc, __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, colloc.cc, comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, defaults.in.h, defun.cc, det.cc, dirfns.cc, display.cc, dlmread.cc, dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc, error.cc, errwarn.cc, event-queue.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, gripes.cc, hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, kron.cc, load-path.cc, load-save.cc, lookup.cc, ls-ascii-helper.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mex.h, mexproto.h, mgorth.cc, nproc.cc, oct-errno.in.cc, oct-fstrm.cc, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-iostrm.cc, oct-lvalue.cc, oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc, oct-stdstrm.h, oct-stream.cc, oct-strstrm.cc, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, procstream.cc, profiler.cc, psi.cc, pt-jit.cc, pt-jit.h, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sighandlers.h, siglist.c, siglist.h, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, text-renderer.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, txt-eng.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, xdiv.cc, xgl2ps.c, xnorm.cc, xpow.cc, zfstream.cc, zfstream.h, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, liboctinterp-build-info.in.cc, mkbuiltins, mkops, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-fcn.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc, ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ovl.cc, octave.cc, octave.h, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cdm-cm.cc, op-cdm-dm.cc, op-cdm-m.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cdm.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-dm.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-cdm.cc, op-dm-cm.cc, op-dm-dm.cc, op-dm-m.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc, op-fcdm-fcm.cc, op-fcdm-fdm.cc, op-fcdm-fm.cc, op-fcm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fdm.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fcdm.cc, op-fdm-fcm.cc, op-fdm-fdm.cc, op-fdm-fm.cc, op-float-conv.cc, op-fm-fcdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fdm.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-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int-conv.cc, op-m-cdm.cc, op-m-cm.cc, op-m-cs.cc, op-m-dm.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-pm-template.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, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, lex.ll, oct-parse.in.yy, pt-arg-list.cc, pt-array-list.cc, pt-assign.cc, pt-binop.cc, pt-bp.cc, pt-cbinop.cc, pt-cell.cc, pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc, pt-const.cc, pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc, pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-misc.cc, pt-pr-code.cc, pt-select.cc, pt-stmt.cc, pt-unop.cc, pt.cc, token.cc, Array-jit.cc, Array-tc.cc, version.cc, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MSparse-C.cc, MSparse-d.cc, MatrixType.cc, PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dim-vector.cc, dim-vector.h, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc, Faddeeva.cc, blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, lo-error.h, quit.cc, quit.h, liboctave-build-info.in.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, aepbalance.cc, chol.cc, eigs-base.cc, fEIG.cc, gepbalance.cc, hess.cc, lo-mappers.cc, lo-specfun.cc, lu.cc, oct-convn.cc, oct-fftw.cc, oct-norm.cc, oct-rand.cc, oct-spparms.cc, qr.cc, qrp.cc, randmtzig.cc, randpoisson.cc, schur.cc, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, svd.cc, mk-ops.awk, mx-defs.h, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-group.cc, oct-passwd.cc, oct-syscalls.cc, oct-time.cc, oct-uname.cc, pathlen.h, syswait.h, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c, glob-match.cc, kpse.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c, lo-cutils.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.cc, oct-mutex.cc, oct-rl-edit.c, oct-rl-edit.h, oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc, sparse-util.cc, statdefs.h, str-vec.cc, unwind-prot.cc, url-transfer.cc, acinclude.m4, display-available.c, display-available.h, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.in.cc, octave-config.in.cc, shared-fcns.h: Use "#if ..." consistently instead of "#ifdef" and "#ifndef".
author John W. Eaton <jwe@octave.org>
date Tue, 17 May 2016 12:09:30 -0400
parents 5b9868c2e212
children cb0fdd941d84
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
20003
f0e61a67ad9f Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents: 19967
diff changeset
3 Copyright (C) 2011-2015 Michael Goffioul
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
5 This file is part of Octave.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
8 under the terms of the GNU General Public License as published by the
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10 option) any later version.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
15 for more details.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
18 along with Octave; see the file COPYING. If not, see
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
19 <http://www.gnu.org/licenses/>.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
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"
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
55
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
56 #include "octave-qt-link.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
57
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
58 #include "builtin-defun-decls.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
59
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
20003
f0e61a67ad9f Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents: 19967
diff changeset
63 #define ABOUT_TEXT "<b>QtHandles</b> - a Qt-based toolkit for <a href=\"http://www.octave.org\">Octave</a>.<br><br>Copyright (C) 2011-2015 Michael Goffioul"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
67 static bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
68 hasUiControlChildren (const figure::properties& fp)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 {
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
70 gh_manager::auto_lock lock;
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
71
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 graphics_object go (gh_manager::get_object (kids(i)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 if (go && (go.isa ("uicontrol") || go.isa ("uipanel")
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
79 || go.isa ("uibuttongroup")))
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
80 return true;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
86 static bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
87 hasUiMenuChildren (const figure::properties& fp)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 {
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
89 gh_manager::auto_lock lock;
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
90
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 graphics_object go (gh_manager::get_object (kids(i)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 if (go && go.isa ("uimenu"))
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
98 return true;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
104 static QRect
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
105 boundingBoxToRect (const Matrix& bb)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 QRect r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 if (bb.numel () == 4)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 r = QRect (xround (bb(0)), xround (bb(1)),
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 xround (bb(2)), xround (bb(3)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 if (! r.isValid ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 r = QRect ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 return r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
120 Figure*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
121 Figure::create (const graphics_object& go)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 return new Figure (go, new FigureWindow ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 Figure::Figure (const graphics_object& go, FigureWindow* win)
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
127 : Object (go, win), m_blockUpdates (false), m_figureToolBar (0),
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
128 m_menuBar (0), m_innerRect (), m_outerRect (), m_mouseModeGroup (0)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 m_container = new Container (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 win->setCentralWidget (m_container);
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
132
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
135 // Status bar
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
136 m_statusBar = win->statusBar ();
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
137 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
139 // Toolbar and menubar
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
140 createFigureToolBarAndMenuBar ();
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
141 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
142
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
143 if (fp.toolbar_is ("figure") ||
20013
08fae2e963fb Fix toolbar and menubar interaction at figure initialization (bug #44686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20007
diff changeset
144 (fp.toolbar_is ("auto") && fp.menubar_is ("figure") &&
08fae2e963fb Fix toolbar and menubar interaction at figure initialization (bug #44686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20007
diff changeset
145 ! hasUiControlChildren (fp)))
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
146 {
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
147 toffset += m_figureToolBar->sizeHint ().height ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
148 boffset += m_statusBar->sizeHint ().height ();
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
149 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 else
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
151 {
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
152 m_figureToolBar->hide ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
153 m_statusBar->hide ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
154 }
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
155
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 if (fp.menubar_is ("figure") || hasUiMenuChildren (fp))
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
157 toffset += m_menuBar->sizeHint ().height () + 1;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 m_menuBar->hide ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
164 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
165
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
166 // Enable mouse tracking unconditionally
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
167 enableMouseTracking ();
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
168
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
169 // When this constructor gets called all properties are already
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
170 // set, even non default. We force "update" here to get things right.
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
171
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
172 // Figure title
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
173 update (figure::properties::ID_NUMBERTITLE);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
175 // Decide what keyboard events we listen to
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
176 m_container->canvas (m_handle)->setEventMask (0);
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
177 update (figure::properties::ID_KEYPRESSFCN);
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
178 update (figure::properties::ID_KEYRELEASEFCN);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
180 // Visibility
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
181 update (figure::properties::ID_VISIBLE);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
182
18612
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
183
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184 connect (this, SIGNAL (asyncUpdate (void)),
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185 this, SLOT (updateContainer (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 win->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 m_container->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191 Figure::~Figure (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
194
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
195 static std::string
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
196 mouse_mode_to_string (MouseMode mode)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
197 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
198 switch (mode)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
199 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
200 case NoMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
201 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
202
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
203 case RotateMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
204 return "rotate";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
205
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
206 case ZoomInMode:
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
207 return "zoom in";
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
208
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
209 case ZoomOutMode:
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
210 return "zoom out";
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
211
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
212 case PanMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
213 return "pan";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
214
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
215 case TextMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
216 return "text";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
217
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
218 case SelectMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
219 return "select";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
220
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
221 default:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
222 break;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
223 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
224
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
225 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
226 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
227
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
228 static MouseMode
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
229 mouse_mode_from_string (const std::string& mode)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
230 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
231 if (mode == "none")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
232 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
233 else if (mode == "rotate")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
234 return RotateMode;
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
235 else if (mode == "zoom in")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
236 return ZoomInMode;
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
237 else if (mode == "zoom out")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
238 return ZoomOutMode;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
239 else if (mode == "pan")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
240 return PanMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
241 else if (mode == "text")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
242 return TextMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
243 else if (mode == "select")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
244 return SelectMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
245 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
246 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
247 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
248
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
249 QString
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
250 Figure::fileName (void)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
251 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
252 gh_manager::auto_lock lock;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
253
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
254 const figure::properties& fp = properties<figure> ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
255
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
256 std::string name = fp.get_filename ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
257
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
258 return QString::fromStdString (name);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
259 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
260
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
261 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
262 Figure::setFileName (const QString& name)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
263 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
264 gh_manager::auto_lock lock;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
265
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
266 figure::properties& fp = properties<figure> ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
267
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
268 fp.set_filename (name.toStdString ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
269 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
270
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
271 MouseMode
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
272 Figure::mouseMode (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
273 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
274 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
275
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
276 const figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
277
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
278 std::string mode = fp.get___mouse_mode__ ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
279
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
280 if (mode == "zoom")
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
281 {
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
282 octave_scalar_map zm = fp.get___zoom_mode__ ().scalar_map_value ();
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
283
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
284 std::string direction = zm.getfield ("Direction").string_value ();
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
285
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
286 mode += " " + direction;
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
287 }
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19723
diff changeset
288
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
289 return mouse_mode_from_string (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
290 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
291
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
292 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
293 Figure::createFigureToolBarAndMenuBar (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
294 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
295 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
298 m_figureToolBar->setMovable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
299 m_figureToolBar->setFloatable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
301 m_mouseModeGroup = new MouseModeActionGroup (win);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
302 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)),
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
303 SLOT (setMouseMode (MouseMode)));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
304 m_figureToolBar->addActions (m_mouseModeGroup->actions ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
305
20007
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20006
diff changeset
306 QAction *toggle_axes = m_figureToolBar->addAction (tr ("Axes"));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
307 connect (toggle_axes, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
308 this, SLOT (toggleAxes (void)));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
309
20007
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20006
diff changeset
310 QAction *toggle_grid = m_figureToolBar->addAction (tr ("Grid"));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
311 connect (toggle_grid, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
312 this, SLOT (toggleGrid (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
313
20007
8d0860d5fd5a Mark GUI strings from Qt figure toolbar for translation.
Rik <rik@octave.org>
parents: 20006
diff changeset
314 QAction *auto_axes = m_figureToolBar->addAction (tr ("Autoscale"));
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
315 connect (auto_axes, SIGNAL (triggered (void)),
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
316 this, SLOT (autoAxes (void)));
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
317
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
318 m_menuBar = new MenuBar (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
319 win->setMenuBar (m_menuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
320
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
321 QMenu* fileMenu = m_menuBar->addMenu (tr ("&File"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
322 fileMenu->menuAction ()->setObjectName ("builtinMenu");
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
323 fileMenu->addAction (tr ("&Save"), this, SLOT (fileSaveFigure (bool)));
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
324 fileMenu->addAction (tr ("Save &As"), this, SLOT (fileSaveFigureAs (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325 fileMenu->addSeparator ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 fileMenu->addAction (tr ("&Close Figure"), this,
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21301
diff changeset
327 SLOT (fileCloseFigure (void)), Qt::CTRL | Qt::Key_W);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
328
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329 QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330 editMenu->menuAction ()->setObjectName ("builtinMenu");
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
331 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (bool)),
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21301
diff changeset
332 Qt::CTRL | Qt::Key_C);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
333 editMenu->addSeparator ();
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
334 editMenu->addActions (m_mouseModeGroup->actions ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
335
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337 helpMenu->menuAction ()->setObjectName ("builtinMenu");
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 helpMenu->addAction (tr ("&About QtHandles"), this,
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
339 SLOT (helpAboutQtHandles (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
340 helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
342 m_menuBar->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
343 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
344
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
345 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
346 Figure::updateFigureToolBarAndMenuBar (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
347 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
348 if (m_mouseModeGroup)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
349 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
350 m_blockUpdates = true;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
351 m_mouseModeGroup->setMode (mouseMode ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
352 m_blockUpdates = false;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
353 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
354 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
355
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
356 Container*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
357 Figure::innerContainer (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
358 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
359 return m_container;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
360 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
361
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
362 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
363 Figure::redraw (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
364 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
365 Canvas* canvas = m_container->canvas (m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
366
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
367 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
368 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 canvas->redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
370 //canvas->setMouseMode (RotateMode);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
371 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
372
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
373 foreach (QFrame* frame,
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
374 qWidget<QWidget> ()->findChildren<QFrame*> ("UIPanel"))
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
375 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
376 Object* obj = Object::fromQObject (frame);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
378 if (obj)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
379 obj->slotRedraw ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
380 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
381
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
382 updateFigureToolBarAndMenuBar ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
383 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
384
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
385 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
386 Figure::print (const QString& file_cmd, const QString& term)
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
387 {
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
388 Canvas* canvas = m_container->canvas (m_handle);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
389
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
390 if (canvas)
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
391 canvas->print (file_cmd, term);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
392 }
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
393
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
394 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
395 Figure::beingDeleted (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
396 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
397 Canvas* canvas = m_container->canvas (m_handle.value (), false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
398
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
399 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
400 canvas->blockRedraw (true);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
401
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
402 m_menuBar->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
403 m_container->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
404 qWidget<FigureWindow> ()->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
405 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
406
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
407 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
408 Figure::update (int pId)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
409 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
410 if (m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
411 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
412
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
414 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
415
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
416 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
417
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
418 switch (pId)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
420 case figure::properties::ID_POSITION:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
421 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422 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
423 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
424 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
425
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426 foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
427 if (! tb->isHidden ())
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
428 toffset += tb->sizeHint ().height ();
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
429
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
430 if (! m_menuBar->isHidden ())
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
431 toffset += m_menuBar->sizeHint ().height () + 1;
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
432
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
433 if (! m_statusBar->isHidden ())
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
434 boffset += m_statusBar->sizeHint ().height () + 1;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
435
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
436 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
437 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
438 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
439
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
440 case figure::properties::ID_NAME:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
441 case figure::properties::ID_NUMBERTITLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
442 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
443 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
444
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
445 case figure::properties::ID_VISIBLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
446 if (fp.is_visible ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
447 QTimer::singleShot (0, win, SLOT (show ()));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
448 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
449 win->hide ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
450 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
451
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
452 case figure::properties::ID_TOOLBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
453 if (fp.toolbar_is ("none"))
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
454 showFigureToolBar (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
455 else if (fp.toolbar_is ("figure"))
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
456 showFigureToolBar (true);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
457 else // "auto"
19977
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
458 showFigureToolBar (! hasUiControlChildren (fp) &&
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
459 fp.menubar_is ("figure"));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
460 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
461
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
462 case figure::properties::ID_MENUBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
463 showMenuBar (fp.menubar_is ("figure"));
19977
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
464 if (fp.toolbar_is ("auto"))
5e6e0563388b Handle "auto" value of figure "toolbar" property (bug #44573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19967
diff changeset
465 showFigureToolBar (fp.menubar_is ("figure"));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
466 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
467
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468 case figure::properties::ID_KEYPRESSFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
469 if (fp.get_keypressfcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
470 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
471 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
472 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
473 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
474
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
475 case figure::properties::ID_KEYRELEASEFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
476 if (fp.get_keyreleasefcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
477 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
478 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
479 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
480 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
481
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
482 default:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
483 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
484 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
485
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
486 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
487 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
488
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
489 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
490 Figure::showFigureToolBar (bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
492 if ((! m_figureToolBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
493 {
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
494 int dy1 = m_figureToolBar->sizeHint ().height ();
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
495 int dy2 = m_statusBar->sizeHint ().height ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
496 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
497
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
498 if (! visible)
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
499 r.adjust (0, dy1, 0, -dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
500 else
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
501 r.adjust (0, -dy1, 0, dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
502
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
505 m_figureToolBar->setVisible (visible);
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
506 m_statusBar->setVisible (visible);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
508
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
509 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
510 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
511 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
512
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
513 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
514 Figure::showMenuBar (bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
515 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
516 int h1 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
517
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518 foreach (QAction* a, m_menuBar->actions ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
519 if (a->objectName () == "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
520 a->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
521
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
522 int h2 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
523
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
525 visible = hasUiMenuChildren (properties<figure> ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
526
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
527 if ((! m_menuBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
528 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
529 int dy = qMax (h1, h2) + 1;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
530 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
531
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
532 //qDebug () << "Figure::showMenuBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
533 if (! visible)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
534 r.adjust (0, dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
535 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
536 r.adjust (0, -dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
537 //qDebug () << "Figure::showMenuBar(adjusted):" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
538
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541 m_menuBar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
544 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
546 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
547
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
548 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
549 Figure::updateMenuBar (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
550 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
551 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
552 graphics_object go = object ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
554 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
555 showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
556 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
557
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
558 void
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
559 Figure::updateStatusBar (ColumnVector pt)
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
560 {
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
561 if (! m_statusBar->isHidden ())
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
562 m_statusBar->showMessage (QString ("(%1, %2)")
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
563 .arg (pt(0), 0, 'g', 5)
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
564 .arg (pt(1), 0, 'g', 5));
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
565 }
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
566
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
567 QWidget*
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
568 Figure::menu (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
569 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
570 return qWidget<QMainWindow> ()->menuBar ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
571 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
572
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
573 struct UpdateBoundingBoxData
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
574 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
575 Matrix m_bbox;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
576 bool m_internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
577 graphics_handle m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
578 Figure* m_figure;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
579 };
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
580
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
581 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
582 Figure::updateBoundingBoxHelper (void* data)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
583 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
584 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
585
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
586 UpdateBoundingBoxData* d = reinterpret_cast<UpdateBoundingBoxData*> (data);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
587 graphics_object go = gh_manager::get_object (d->m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
588
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
590 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
591 figure::properties& fp = Utils::properties<figure> (go);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
592
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
593 fp.set_boundingbox (d->m_bbox, d->m_internal, false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
594 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
595
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
596 delete d;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
597 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
598
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
599 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
600 Figure::updateBoundingBox (bool internal, int flags)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
601 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
602 QWidget* win = qWidget<QWidget> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
603 Matrix bb (1, 4);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
604
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
605 if (internal)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
606 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607 QRect r = m_innerRect;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
608
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
609 if (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
610 r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
611 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
612 r.setSize (m_container->size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
614 if (r.isValid () && r != m_innerRect)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
615 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
616 m_innerRect = r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
617
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
618 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
619 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
620 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
621 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
622 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
623 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
624 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
625 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
626 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
627 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
628 QRect r = m_outerRect;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630 if (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
631 r.moveTopLeft (win->pos ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
632 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
633 r.setSize (win->frameGeometry ().size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
634
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18612
diff changeset
635 if (r.isValid () && r != m_outerRect)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
636 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
637 m_outerRect = r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
638
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
639 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
641 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
642 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
643 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
644 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
645 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
646 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
648 UpdateBoundingBoxData* d = new UpdateBoundingBoxData ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
650 d->m_bbox = bb;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
651 d->m_internal = internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
652 d->m_handle = m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
653 d->m_figure = this;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
654
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
655 gh_manager::post_function (Figure::updateBoundingBoxHelper, d);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
656 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
657
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
658 bool
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
659 Figure::eventNotifyBefore (QObject* obj, QEvent* xevent)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
660 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
661 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
662 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
663 if (obj == m_container)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
664 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
665 // Do nothing...
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
666 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
667 else if (obj == m_menuBar)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
668 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
669 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
670 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
671 case QEvent::ActionRemoved:
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
672 {
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
673 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
674
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
675 if (! a->isSeparator ()
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
676 && a->objectName () != "builtinMenu")
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
677 updateMenuBar ();
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
678 }
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
679 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
680
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
681 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
682 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
683 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
684 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
685 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
686 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
687 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
688 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
689 case QEvent::Close:
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
690 xevent->ignore ();
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
691 gh_manager::post_callback (m_handle, "closerequestfcn");
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
692 return true;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
693
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
694 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
695 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
696 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
697 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
698 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
699
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
700 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
701 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
702
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
703 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
704 Figure::eventNotifyAfter (QObject* watched, QEvent* xevent)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
705 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
706 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
707 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
708 if (watched == m_container)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
709 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
710 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
711 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
712 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
713 updateBoundingBox (true, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
714 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
715
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
716 case QEvent::ChildAdded:
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
717 if (dynamic_cast<QChildEvent*> (xevent)->child
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
718 ()->isWidgetType())
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
719 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
720 gh_manager::auto_lock lock;
20524
88459dd6780f Fix inconsistent toolbar state after creating an uicontrol (bug #46025)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20504
diff changeset
721 update (figure::properties::ID_TOOLBAR);
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
722
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
723 enableMouseTracking ();
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
724 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
725
20595
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
726 case QEvent::ChildRemoved:
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
727 if (dynamic_cast<QChildEvent*> (xevent)->child
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
728 ()->isWidgetType())
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
729 {
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
730 gh_manager::auto_lock lock;
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
731 update (figure::properties::ID_TOOLBAR);
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
732 }
99eb26310cb3 Update the state of the toolbar after ui* children have been removed
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20594
diff changeset
733
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
734 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
735 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
736 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
737 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
738 else if (watched == m_menuBar)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
739 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
740 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
741 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
742 case QEvent::ActionAdded:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
743 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
744 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
745
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
746 if (! a->isSeparator ()
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
747 && a->objectName () != "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
748 updateMenuBar ();
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
749 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
750 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
751
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
752 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
753 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
754 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
755 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
756 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
757 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
758 switch (xevent->type ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
759 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
760 case QEvent::Move:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
761 updateBoundingBox (false, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
762 updateBoundingBox (true, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
763 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
764
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
765 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
766 updateBoundingBox (false, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
767 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
768
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
769 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
770 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
771 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
772 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
773 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
774 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
775
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
776 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
777 Figure::helpAboutQtHandles (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
778 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
779 QMessageBox::about (qWidget<QMainWindow> (), tr ("About QtHandles"),
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
780 ABOUT_TEXT);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
782
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
783 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
784 Figure::setMouseMode (MouseMode mode)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
785 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
786 if (m_blockUpdates)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
787 return;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
788
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
789 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
790
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
791 figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
792
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
793 fp.set___mouse_mode__ (mouse_mode_to_string (mode));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
794
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
795 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
796
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
797 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
798 canvas->setCursor (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
799 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
800
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
801 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
802 Figure::fileSaveFigure (bool prompt)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
803 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
804 QString file = fileName ();
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
805
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
806 if (file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
807 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
808 prompt = true;
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
809
19723
c9dc27cad3c0 Use default format of PDF for saving Qt plots.
Rik <rik@octave.org>
parents: 19722
diff changeset
810 file = "untitled.pdf";
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
811 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
812
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
813 if (prompt || file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
814 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
815 QFileInfo finfo (file);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
816
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
817 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
818 tr ("Save Figure As"),
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
819 finfo.absoluteFilePath (), 0, 0,
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
820 QFileDialog::DontUseNativeDialog);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
821 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
822
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
823 if (! file.isEmpty ())
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
824 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
825 QFileInfo finfo (file);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
826
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
827 setFileName (finfo.absoluteFilePath ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
828
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
829 octave_link::post_event (this, &Figure::save_figure_callback,
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
830 file.toStdString ());
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
831 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
832 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
833
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
834 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
835 Figure::save_figure_callback (const std::string& file)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
836 {
20242
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
837 figure::properties& fp = properties<figure> ();
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
838 octave_value fnum = fp.get___myhandle__ ().as_octave_value ();
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
839
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
840 Ffeval (ovl ("print", fnum, file));
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
841 }
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
842
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
843 void
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
844 Figure::copy_figure_callback (const std::string& format)
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
845 {
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
846 std::string msg;
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
847
20085
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20079
diff changeset
848 std::string file = octave_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
849
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
850 if (file.empty ())
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
851 {
20085
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20079
diff changeset
852 // Report error?
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
853 return;
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
854 }
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
855
20242
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
856 save_figure_callback (file);
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
857
20113
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20085
diff changeset
858 octave_link::copy_image_to_clipboard (file);
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
859 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
860
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
861 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
862 Figure::fileSaveFigureAs (void)
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
863 {
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
864 fileSaveFigure (true);
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
865 }
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
866
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
867 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
868 Figure::fileCloseFigure (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
869 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
870 qWidget<QMainWindow> ()->close ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
871 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
872
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
873 void
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
874 Figure::editCopy (bool /* choose_format */)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
875 {
20114
5f0cb9bb6a50 use png instead of jpg as default format for copying plots to clipboard
John W. Eaton <jwe@octave.org>
parents: 20113
diff changeset
876 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
877
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
878 #if 0
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
879
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
880 // FIXME: allow choice of image formats.
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
881
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
882 if (choose_format)
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
883 {
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
884 QFileInfo finfo (file);
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
885
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
886 format = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
887 tr ("Save Figure As"),
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
888 finfo.absoluteFilePath (), 0, 0,
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
889 QFileDialog::DontUseNativeDialog);
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
890 }
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
891 #endif
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
892
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
893 octave_link::post_event (this, &Figure::copy_figure_callback,
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
894 format.toStdString ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
895 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
896
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
897 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
898 Figure::addCustomToolBar (QToolBar* bar, bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
899 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
900 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
901
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
902 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
903 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
904 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
905 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
906 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
907 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
908 //qDebug () << "Figure::addCustomToolBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
909
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
910 r.adjust (0, -sz.height (), 0, 0);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
911
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
912 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
913 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
914 win->addToolBarBreak ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
915 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
916 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
917
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
918 //qDebug () << "Figure::addCustomToolBar:" << win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
919 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
920 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
921 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
922
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
923 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
924 Figure::showCustomToolBar (QToolBar* bar, bool visible)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
925 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
926 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
927
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
928 if ((! bar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
929 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
930 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
931 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
932
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
933 if (visible)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
934 r.adjust (0, -sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
935 else
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
936 r.adjust (0, sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
937
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
938 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
939 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
940 bar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
941 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
942
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
943 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
944 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
945 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
946
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
947 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
948 Figure::updateContainer (void)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
949 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
950 redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
951 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
952
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
953 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
954 Figure::toggleAxes (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
955 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
956 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
957
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
958 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
959 canvas->toggleAxes (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
960 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
961
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
962 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
963 Figure::toggleGrid (void)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
964 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
965 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
966
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
967 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
968 canvas->toggleGrid (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
969 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
970
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
971 void
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
972 Figure::autoAxes (void)
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
973 {
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
974 Canvas* canvas = m_container->canvas (m_handle);
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
975
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
976 if (canvas)
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
977 canvas->autoAxes (m_handle);
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
978 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
979
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
980 void
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
981 Figure::enableMouseTracking (void)
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
982 {
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
983 // Enable mouse tracking on every widgets
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
984 m_container->setMouseTracking (true);
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
985 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
986 foreach (QWidget* w, m_container->findChildren<QWidget*> ())
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
987 { w->setMouseTracking (true); }
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
988 }
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
989
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
990 }; // namespace QtHandles