annotate libgui/graphics/Figure.cc @ 30398:d4d83344d653 stable

maint: style check C++ files in src/ and libgui/ ahead of 7.1 release. * ButtonGroup.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, Figure.h, FigureWindow.cc, GenericEventNotify.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Menu.cc, Object.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, RadioButtonControl.cc, SliderControl.cc, Table.cc, Table.h, TextControl.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, annotation-dialog.cc, qt-graphics-toolkit.cc, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-model.cc, gui-preferences-dw.h, gui-preferences-ed.h, gui-preferences-global.h, gui-settings.h, interpreter-qobject.cc, led-indicator.cc, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, octave-qscintilla.cc, octave-qscintilla.h, main-window.cc, main-window.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, octave-qtutils.h, qt-interpreter-events.cc, release-notes.cc, resource-manager.cc, set-path-dialog.cc, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.cc, tab-bar.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, workspace-model.cc, workspace-view.cc, mkoctfile.in.cc, octave-config.in.cc: Style check C++ files in src/ and libgui/ ahead of 7.1 release.
author Rik <rik@octave.org>
date Mon, 29 Nov 2021 15:58:51 -0800
parents 6ea4a84df9c7
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27929
diff changeset
3 // Copyright (C) 2011-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
27 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <QAction>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <QActionEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QApplication>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
33 #include <QClipboard>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #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
35 #include <QFileDialog>
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
36 #include <QFileInfo>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include <QFrame>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
38 #include <QImage>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include <QMainWindow>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include <QMenu>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include <QMenuBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include <QMessageBox>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include <QtDebug>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include <QTimer>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include <QToolBar>
25886
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
46 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
47 # include <QWindow>
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
48 # include <QScreen>
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
49 #endif
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 #include "Canvas.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 #include "Container.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 #include "Figure.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 #include "FigureWindow.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
55 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
57 #include "gui-preferences-global.h"
27417
f844b1f03dcc update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
58 #include "qt-interpreter-events.h"
f844b1f03dcc update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
59
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
60 #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
61 #include "unwind-prot.h"
20085
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20079
diff changeset
62 #include "utils.h"
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
63 #include "version.h"
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
64
27417
f844b1f03dcc update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
65 #include "builtin-defun-decls.h"
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
66 #include "interpreter.h"
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
67
29992
6ea4a84df9c7 rename QtHandles namespace to octave
John W. Eaton <jwe@octave.org>
parents: 29896
diff changeset
68 namespace octave
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
71 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
72
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
73 static QRect
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
74 boundingBoxToRect (const Matrix& bb)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
75 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
76 QRect r;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
78 if (bb.numel () == 4)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
79 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
80 r = QRect (octave::math::round (bb(0)), octave::math::round (bb(1)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
81 octave::math::round (bb(2)), octave::math::round (bb(3)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
82 if (! r.isValid ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
83 r = QRect ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
84 }
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
85
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
86 return r;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
87 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
89 static QImage
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
90 pointer_to_qimage (const Matrix& cdata)
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
91 {
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
92 QImage retval (cdata.rows (), cdata.columns (), QImage::Format_ARGB32);
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
93 QColor tmp ("White");
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
94 QColor black ("Black");
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
95 QColor white ("White");
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
96 for (octave_idx_type ii = 0; ii < cdata.rows (); ii++)
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
97 for (octave_idx_type jj = 0; jj < cdata.columns (); jj++)
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
98 {
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
99 if (cdata(ii, jj) == 1.0)
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
100 tmp = black;
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
101 else if (cdata(ii, jj) == 2.0)
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
102 tmp = white;
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
103 else
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
104 tmp.setAlpha (0);
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
105
27107
6bc32e6a1b4f Restore hability to compile with Qt < 5.6 (bug #56376)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
106 retval.setPixel (jj, ii, tmp.rgba ());
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
107 }
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
108
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
109 return retval;
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
110 }
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
111
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
112 Figure *
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
113 Figure::create (octave::base_qobject& oct_qobj, octave::interpreter& interp,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
114 const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
115 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
116 return new Figure (oct_qobj, interp, go, new FigureWindow ());
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
117 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
119 Figure::Figure (octave::base_qobject& oct_qobj, octave::interpreter& interp,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
120 const graphics_object& go, FigureWindow *win)
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
121 : Object (oct_qobj, interp, go, win), m_blockUpdates (false),
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
122 m_figureToolBar (nullptr), m_menuBar (nullptr), m_innerRect (),
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
123 m_outerRect (), m_previousHeight (0), m_resizable (true)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
124 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
125 m_container = new Container (win, oct_qobj, interp);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
126 win->setCentralWidget (m_container);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127
29896
0dd2742601e4 fix wring connection of interpreter events in QtHandles
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29542
diff changeset
128 connect (m_container, QOverload<const octave::fcn_callback&>::of (&Container::interpreter_event),
0dd2742601e4 fix wring connection of interpreter events in QtHandles
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29542
diff changeset
129 this, QOverload<const octave::fcn_callback&>::of (&Figure::interpreter_event));
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
130
29896
0dd2742601e4 fix wring connection of interpreter events in QtHandles
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29542
diff changeset
131 connect (m_container, QOverload<const octave::meth_callback&>::of (&Container::interpreter_event),
0dd2742601e4 fix wring connection of interpreter events in QtHandles
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29542
diff changeset
132 this, QOverload<const octave::meth_callback&>::of (&Figure::interpreter_event));
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
133
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
134 figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
135
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
136 // Adjust figure position
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
137 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
138 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
139
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
140 set_geometry (m_innerRect);
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
141
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
142 // Menubar
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
143 m_menuBar = new MenuBar (win);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
144 win->setMenuBar (m_menuBar);
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
145 m_menuBar->addReceiver (this);
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
146 m_menuBar->setStyleSheet (m_menuBar->styleSheet () + global_menubar_style);
27478
9e526393d80a reduced vertical space in gui with responsive toolbar buttons (bug #53902)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27417
diff changeset
147
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
148
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
149 // Status bar
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
150 m_statusBar = win->statusBar ();
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
151 m_statusBar->setVisible (false);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
152
25951
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
153 if (fp.toolbar_is ("figure")
26338
358bed84511b Display figure toolbar correctly (bug #55350).
Rik <rik@octave.org>
parents: 26130
diff changeset
154 || (fp.toolbar_is ("auto") && fp.menubar_is ("figure")))
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
155 showFigureStatusBar (true);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
156
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
157 // Enable mouse tracking unconditionally
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
158 enableMouseTracking ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
159
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
160 // When this constructor gets called all properties are already
27929
265b386f8b20 maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents: 27923
diff changeset
161 // set, even non default. We force "update" here to get things right.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
163 // Figure title
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
164 update (figure::properties::ID_NUMBERTITLE);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
165
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
166 // Decide what keyboard events we listen to
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
167 m_container->canvas (m_handle)->setEventMask (0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
168 update (figure::properties::ID_KEYPRESSFCN);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
169 update (figure::properties::ID_KEYRELEASEFCN);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
170
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
171 // modal style
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
172 update (figure::properties::ID_WINDOWSTYLE);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
174 // Handle resizing constraints
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
175 update (figure::properties::ID_RESIZE);
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
176
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
177 // Custom pointer data
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
178 update (figure::properties::ID_POINTERSHAPECDATA);
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
179
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
180 // Visibility
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
181 update (figure::properties::ID_VISIBLE);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
182
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
183 connect (this, &Figure::asyncUpdate, this, &Figure::updateContainer);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
184
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
185 // Register for the signal that indicates when a window has moved
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
186 // to a different screen
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
187 connect (win, &FigureWindow::figureWindowShown,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
188 this, &Figure::figureWindowShown);
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
189
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
190 win->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
191 m_container->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
192 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
193
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
194 Figure::~Figure (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
195 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
196
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
197 QString
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
198 Figure::fileName (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
199 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
200 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
201
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
202 octave::autolock guard (gh_mgr.graphics_lock ());
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
203
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
204 const figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
205
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
206 std::string name = fp.get_filename ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
207
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
208 return QString::fromStdString (name);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
209 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
210
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
211 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
212 Figure::setFileName (const QString& name)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
213 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
214 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
215
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
216 octave::autolock guard (gh_mgr.graphics_lock ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
218 figure::properties& fp = properties<figure> ();
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
219
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
220 fp.set_filename (name.toStdString ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
221 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
222
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
223 MouseMode
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
224 Figure::mouseMode (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
225 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
226 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
227
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
228 octave::autolock guard (gh_mgr.graphics_lock ());
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
229
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
230 const figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
231
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
232 std::string mode = fp.get___mouse_mode__ ();
20537
d0f886a030b7 Use "update" method to initialize Qt Figures (cleanup + bug #46086)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20531
diff changeset
233
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
234 if (mode == "zoom")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
235 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
236 octave_scalar_map zm = fp.get___zoom_mode__ ().scalar_map_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
237
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
238 std::string direction = zm.getfield ("Direction").string_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
239
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23800
diff changeset
240 mode += ' ' + direction;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
241 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
242
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
243 if (mode == "rotate")
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
244 return RotateMode;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
245 else if (mode == "zoom in")
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
246 return ZoomInMode;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
247 else if (mode == "zoom out")
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
248 return ZoomOutMode;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
249 else if (mode == "pan")
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
250 return PanMode;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
251 else if (mode == "text")
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
252 return TextMode;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
253
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
254 return NoMode;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
255 }
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
256
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
257 void
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
258 Figure::set_geometry (QRect r)
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
259 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
260 QMainWindow *win = qWidget<QMainWindow> ();
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
261
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
262 if (! m_resizable)
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
263 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
264 win->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
265 win->setFixedSize (QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
266 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
267
26821
f9b10a8a7c93 Allow changing the position of a maximized/fullscreen Qt figure.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26820
diff changeset
268 // Unlock window if it is maximized or full-screen
f9b10a8a7c93 Allow changing the position of a maximized/fullscreen Qt figure.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26820
diff changeset
269 int state = win->windowState ();
f9b10a8a7c93 Allow changing the position of a maximized/fullscreen Qt figure.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26820
diff changeset
270 if (state == Qt::WindowFullScreen || state == Qt::WindowMaximized)
f9b10a8a7c93 Allow changing the position of a maximized/fullscreen Qt figure.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26820
diff changeset
271 win->setWindowState (Qt::WindowNoState);
f9b10a8a7c93 Allow changing the position of a maximized/fullscreen Qt figure.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26820
diff changeset
272
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
273 win->setGeometry (r);
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
274
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
275 if (! m_resizable)
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
276 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
277 win->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
278 win->setFixedSize(win->size ());
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
279 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
280 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
281
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
282 Container *
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
283 Figure::innerContainer (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
284 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
285 return m_container;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
286 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
287
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
288 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
289 Figure::redraw (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
290 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
291 Canvas *canvas = m_container->canvas (m_handle);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
292
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
293 if (canvas)
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
294 canvas->redraw ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
295
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
296 for (auto *qobj : qWidget<QWidget> ()->findChildren<QObject *> ())
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
297 {
26816
92ecc4a97b5c Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26520
diff changeset
298 if (qobj->objectName () == "UIPanel"
92ecc4a97b5c Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26520
diff changeset
299 || qobj->objectName () == "UIButtonGroup"
26820
0a383bddfb40 Also update uitbale position when figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26816
diff changeset
300 || qobj->objectName () == "UIControl"
0a383bddfb40 Also update uitbale position when figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26816
diff changeset
301 || qobj->objectName () == "UITable")
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
302 {
26816
92ecc4a97b5c Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26520
diff changeset
303 Object *obj = Object::fromQObject (qobj);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
304
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
305 if (obj)
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
306 obj->slotRedraw ();
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
307 }
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
308 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
309 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
310
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
311 void
25799
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
312 Figure::show (void)
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
313 {
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
314 QWidget *win = qWidget<QWidget> ();
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
315
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
316 win->activateWindow ();
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
317 win->raise ();
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
318 }
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
319
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
320 void
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
321 Figure::print (const QString& file_cmd, const QString& term)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
322 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
323 Canvas *canvas = m_container->canvas (m_handle);
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
324
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
325 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
326 canvas->print (file_cmd, term);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
327 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
328
23535
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
329 uint8NDArray
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
330 Figure::slotGetPixels (void)
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
331 {
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
332 uint8NDArray retval;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
333 Canvas *canvas = m_container->canvas (m_handle);
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
334
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
335 if (canvas)
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
336 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
337 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
338
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
339 gh_mgr.process_events ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
340 octave::autolock guard (gh_mgr.graphics_lock ());
23535
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
341 retval = canvas->getPixels ();
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
342 }
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
343
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
344 return retval;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
345 }
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
346
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
347 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
348 Figure::beingDeleted (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
349 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
350 Canvas *canvas = m_container->canvas (m_handle.value (), false);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
351
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
352 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
353 canvas->blockRedraw (true);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
354
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
355 m_container->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
356 qWidget<FigureWindow> ()->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
357 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
358
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
359 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
360 Figure::update (int pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
361 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
362 if (m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
363 return;
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
364
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
365 figure::properties& fp = properties<figure> ();
24687
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
366
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
367 if (fp.is___printing__ ())
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
368 return;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24687
diff changeset
369
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
370 QMainWindow *win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
371
25044
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24691
diff changeset
372 // If the window doesn't exist, there's nothing we can do.
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24691
diff changeset
373 if (! win)
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24691
diff changeset
374 return;
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24691
diff changeset
375
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
376 m_blockUpdates = true;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24687
diff changeset
377
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
378 switch (pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
379 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
380 case figure::properties::ID_POSITION:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
381 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
382 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
383 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
384 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
385
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
386 for (auto *tb : win->findChildren<QToolBar *> ())
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
387 if (! tb->isHidden ())
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
388 toffset += tb->sizeHint ().height ();
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
389
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
390 if (! m_menuBar->isHidden ())
22370
0a2961d5893c Fix calculation of window height in Qt, FLTK (bug #48833, bug #48522).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
391 toffset += m_menuBar->sizeHint ().height ();
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
392
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
393 if (! m_statusBar->isHidden ())
22370
0a2961d5893c Fix calculation of window height in Qt, FLTK (bug #48833, bug #48522).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
394 boffset += m_statusBar->sizeHint ().height ();
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
395
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
396 set_geometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
397 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
398 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
399
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
400 case figure::properties::ID_NAME:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
401 case figure::properties::ID_NUMBERTITLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
402 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
403 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
404
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
405 case figure::properties::ID_VISIBLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
406 if (fp.is_visible ())
24687
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
407 {
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
408 QTimer::singleShot (0, win, &QMainWindow::show);
24687
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
409 if (! fp.is___gl_window__ ())
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
410 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
411 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
412
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
413 octave::autolock guard (gh_mgr.graphics_lock ());
24687
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
414 fp.set ("__gl_window__", "on");
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
415 }
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24687
diff changeset
416 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
417 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
418 win->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
419 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
420
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
421 case figure::properties::ID_RESIZE:
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
422 if (fp.is_resize ())
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
423 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
424 win->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
425 win->setFixedSize (QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
426 m_resizable = true;
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
427 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
428 else
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
429 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
430 win->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
431 win->setFixedSize(win->size ());
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
432 m_resizable = false;
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
433 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
434 break;
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
435
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
436 case figure::properties::ID_MENUBAR:
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
437 case figure::properties::ID_TOOLBAR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
438 if (fp.toolbar_is ("none"))
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
439 showFigureStatusBar (false);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
440 else if (fp.toolbar_is ("figure"))
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
441 showFigureStatusBar (true);
26338
358bed84511b Display figure toolbar correctly (bug #55350).
Rik <rik@octave.org>
parents: 26130
diff changeset
442 else // "auto"
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
443 showFigureStatusBar (fp.menubar_is ("figure"));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
444 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
445
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
446 case figure::properties::ID_KEYPRESSFCN:
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23535
diff changeset
447 if (fp.get_keypressfcn ().isempty ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
448 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
449 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
450 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
451 // Signal the change to uipanels as well
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
452 for (auto *qobj : qWidget<QWidget> ()->findChildren<QObject *> ())
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
453 {
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
454 if (qobj->objectName () == "UIPanel")
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
455 {
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
456 Object *obj = Object::fromQObject (qobj);
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
457
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
458 if (obj)
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
459 {
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
460 if (fp.get_keypressfcn ().isempty ())
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
461 obj->innerContainer ()->canvas (m_handle)->
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
462 clearEventMask (Canvas::KeyPress);
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
463 else
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
464 obj->innerContainer ()->canvas (m_handle)->
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
465 addEventMask (Canvas::KeyPress);
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
466 }
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
467 }
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
468 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
469 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
470
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
471 case figure::properties::ID_KEYRELEASEFCN:
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23535
diff changeset
472 if (fp.get_keyreleasefcn ().isempty ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
473 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
474 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
475 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
476 break;
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
477 // Signal the change to uipanels as well
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
478 for (auto *qobj : qWidget<QWidget> ()->findChildren<QObject *> ())
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
479 {
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
480 if (qobj->objectName () == "UIPanel")
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
481 {
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
482 Object *obj = Object::fromQObject (qobj);
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
483
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
484 if (obj)
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
485 {
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
486 if (fp.get_keypressfcn ().isempty ())
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
487 obj->innerContainer ()->canvas (m_handle)->
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
488 clearEventMask (Canvas::KeyRelease);
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
489 else
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
490 obj->innerContainer ()->canvas (m_handle)->
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
491 addEventMask (Canvas::KeyRelease);
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
492 }
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
493 }
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
494 }
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27107
diff changeset
495 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
496
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
497 case figure::properties::ID_WINDOWSTYLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
498 if (fp.windowstyle_is ("modal"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
499 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
500 bool is_visible = win->isVisible ();
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
501
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
502 // if window is already visible, need to hide and reshow it in order to
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
503 // make it use the modal settings
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
504 if (is_visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
505 win->setVisible (false);
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
506
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
507 win->setWindowModality (Qt::ApplicationModal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
508 win->setVisible (is_visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
509 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
510 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
511 win->setWindowModality (Qt::NonModal);
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
512
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
513 break;
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
514
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
515 case figure::properties::ID_POINTERSHAPECDATA:
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
516 m_pointer_cdata =
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
517 pointer_to_qimage (fp.get_pointershapecdata ().matrix_value ());
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
518 if (fp.get_pointer () != "custom")
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
519 break;
27107
6bc32e6a1b4f Restore hability to compile with Qt < 5.6 (bug #56376)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
520 OCTAVE_FALLTHROUGH;
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
521
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
522 case figure::properties::ID_POINTER:
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
523 case figure::properties::ID_POINTERSHAPEHOTSPOT:
25852
f6537847b043 ginput.m: temporarily disable mouse tools in Qt toolkit (bug #51452)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25799
diff changeset
524 case figure::properties::ID___MOUSE_MODE__:
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
525 case figure::properties::ID___ZOOM_MODE__:
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
526 m_container->canvas (m_handle)->setCursor (mouseMode (),
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
527 fp.get_pointer (),
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
528 m_pointer_cdata,
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
529 fp.get_pointershapehotspot ()
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26902
diff changeset
530 .matrix_value());
25852
f6537847b043 ginput.m: temporarily disable mouse tools in Qt toolkit (bug #51452)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25799
diff changeset
531 break;
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
532
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
533 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
534 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
535 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
536
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
537 m_blockUpdates = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
538 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
540 void
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
541 Figure::showFigureStatusBar (bool visible)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
542 {
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
543 if (m_statusBar
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
544 && (! m_statusBar->isHidden ()) != visible)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
545 {
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
546 int dy = m_statusBar->sizeHint ().height ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
547 QRect r = qWidget<QWidget> ()->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
548
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
549 if (! visible)
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
550 r.adjust (0, 0, 0, -dy);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
551 else
26902
cb5c1ea2062c Fix regression with toolbar and status bar visibility (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26884
diff changeset
552 r.adjust (0, 0, 0, dy);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
554 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
555 set_geometry (r);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
556 m_statusBar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
557 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
558
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
559 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
560 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
561 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
562
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
563 void
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
564 Figure::updateFigureHeight (int dh)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
565 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
566 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
567
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
568 octave::autolock guard (gh_mgr.graphics_lock ());
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
569 graphics_object go = object ();
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
570
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
571 if (go.valid_object () && dh != 0)
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
572 {
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
573 QRect r = qWidget<QWidget> ()->geometry ();
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
574
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
575 r.adjust (0, dh, 0, 0);
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
576
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
577 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
578 set_geometry (r);
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
579 m_blockUpdates = false;
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
580
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
581 updateBoundingBox (false);
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
582 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
583 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
584
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
585 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
586 Figure::updateStatusBar (ColumnVector pt)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
587 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
588 if (! m_statusBar->isHidden ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
589 m_statusBar->showMessage (QString ("(%1, %2)")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
590 .arg (pt(0), 0, 'g', 5)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
591 .arg (pt(1), 0, 'g', 5));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
592 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
593
27376
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
594 void
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
595 Figure::do_connections (const QObject *receiver, const QObject * /* emitter */)
27376
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
596 {
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
597 Object::do_connections (receiver);
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
598 Object::do_connections (receiver, m_container->canvas (m_handle));
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
599 }
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
600
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
601 QWidget *
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
602 Figure::menu (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
603 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
604 return qWidget<QMainWindow> ()->menuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
605 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
606
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
607 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
608 Figure::updateBoundingBox (bool internal, int flags)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
609 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
610 QWidget *win = qWidget<QWidget> ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
611 Matrix bb (1, 4);
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
612 std::string prop;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
614 if (internal)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
615 {
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
616 prop = "position";
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
617 QRect r = m_innerRect;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
618
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
619 if (flags & UpdateBoundingBoxPosition)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
620 r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
621 if (flags & UpdateBoundingBoxSize)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
622 r.setSize (m_container->size ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
623
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
624 if (r.isValid () && r != m_innerRect)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
625 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
626 m_innerRect = r;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
627
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
628 bb(0) = r.x ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
629 bb(1) = r.y ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
630 bb(2) = r.width ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
631 bb(3) = r.height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
632 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
633 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
634 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
635 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
636 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
637 {
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
638 prop = "outerposition";
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
639 QRect r = m_outerRect;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
640
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
641 if (flags & UpdateBoundingBoxPosition)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
642 r.moveTopLeft (win->pos ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
643 if (flags & UpdateBoundingBoxSize)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
644 r.setSize (win->frameGeometry ().size ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
645
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
646 if (r.isValid () && r != m_outerRect)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
647 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
648 m_outerRect = r;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
649
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
650 bb(0) = r.x ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
651 bb(1) = r.y ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
652 bb(2) = r.width ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
653 bb(3) = r.height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
654 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
655 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
656 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
657 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
658
26469
bf835b1d04b1 Don't use C++ callbacks to notify position changes from Qt figures (bug #48519)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
659 figure::properties& fp = properties<figure> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
660
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
661 emit gh_set_event (m_handle, prop, fp.bbox2position (bb), false,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
662 prop == "position");
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
663 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
664
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
665 bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
666 Figure::eventNotifyBefore (QObject *obj, QEvent *xevent)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
667 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
668 if (! m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
669 {
24465
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
670 // Clicking the toolbar or the menubar makes this figure current
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
671 if (xevent->type () == QEvent::MouseButtonPress)
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
672 {
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
673 figure::properties& fp = properties<figure> ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
674
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
675 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
676
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
677 graphics_object root = gh_mgr.get_object (0);
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
678
24465
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
679 if (fp.get_handlevisibility () == "on")
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
680 root.set ("currentfigure",
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
681 fp.get___myhandle__ ().as_octave_value ());
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
682 }
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
683
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
684 if (obj == m_container)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
685 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
686 // Do nothing...
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
687 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
688 else if (obj == m_menuBar)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
689 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
690 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
691 {
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
692 case QEvent::ActionAdded:
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
693 case QEvent::ActionChanged:
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
694 case QEvent::ActionRemoved:
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
695 m_previousHeight = m_menuBar->sizeHint ().height ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
696
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
697 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
698 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
699 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
700 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
701 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
702 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
703 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
704 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
705 case QEvent::Close:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
706 xevent->ignore ();
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
707 emit gh_callback_event (m_handle, "closerequestfcn");
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
708 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
709
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
710 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
711 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
712 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
713 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
714 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
715
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
716 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
717 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
718
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
719 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
720 Figure::eventNotifyAfter (QObject *watched, QEvent *xevent)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
721 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
722 if (! m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
723 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
724 if (watched == m_container)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
725 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
726 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
727
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
728 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
729 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
730 case QEvent::Resize:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
731 updateBoundingBox (true, UpdateBoundingBoxSize);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
732 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
733
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
734 case QEvent::ChildAdded:
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23224
diff changeset
735 if (dynamic_cast<QChildEvent *> (xevent)->child
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
736 ()->isWidgetType())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
737 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
738 octave::autolock guard (gh_mgr.graphics_lock ());
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
739 update (figure::properties::ID_TOOLBAR);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
740
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
741 enableMouseTracking ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
742 }
23800
2fdc65c031b5 Add break or continue statements to prevent implicit fall-through in case statements.
Rik <rik@octave.org>
parents: 23795
diff changeset
743 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
744
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
745 case QEvent::ChildRemoved:
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23224
diff changeset
746 if (dynamic_cast<QChildEvent *> (xevent)->child
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
747 ()->isWidgetType())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
748 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
749 octave::autolock guard (gh_mgr.graphics_lock ());
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
750 update (figure::properties::ID_TOOLBAR);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
751 }
23800
2fdc65c031b5 Add break or continue statements to prevent implicit fall-through in case statements.
Rik <rik@octave.org>
parents: 23795
diff changeset
752 break;
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
753
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
754 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
755 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
756 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
757 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
758 else if (watched == m_menuBar)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
759 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
760 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
761 {
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
762 case QEvent::ActionAdded:
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
763 case QEvent::ActionChanged:
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
764 case QEvent::ActionRemoved:
23224
73f7ef7169ac Make uimenu "Position" property Matlab-compatible (bug #50369).
Rik <rik@octave.org>
parents: 23223
diff changeset
765 // The menubar may have been resized if no action is visible
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
766 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
767 QAction *a = dynamic_cast<QActionEvent *> (xevent)->action ();
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
768 int currentHeight = m_menuBar->sizeHint ().height ();
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
769 if (currentHeight != m_previousHeight
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
770 && ! a->isSeparator ())
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
771 updateFigureHeight (m_previousHeight - currentHeight);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
772 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
773 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
774
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
775 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
776 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
777 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
778 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
779 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
780 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
781 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
782 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
783 case QEvent::Move:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
784 updateBoundingBox (false, UpdateBoundingBoxPosition);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
785 updateBoundingBox (true, UpdateBoundingBoxPosition);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
786 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
787
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
788 case QEvent::Resize:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
789 updateBoundingBox (false, UpdateBoundingBoxSize);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
790 break;
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
791
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
792 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
793 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
794 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
795 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
796 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
797 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
798
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
799 void
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
800 Figure::addCustomToolBar (QToolBar *bar, bool visible, bool isdefault)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
801 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
802 QMainWindow *win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
803
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
804 if (isdefault)
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
805 m_figureToolBar = bar;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26821
diff changeset
806
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
807 if (! visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
808 win->addToolBar (bar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
809 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
810 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
811 QSize sz = bar->sizeHint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
812 QRect r = win->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
813
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
814 r.adjust (0, -sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
815
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
816 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
817 set_geometry (r);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
818 win->addToolBarBreak ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
819 win->addToolBar (bar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
820 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
821
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
822 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
823 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
824 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
825
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
826 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
827 Figure::showCustomToolBar (QToolBar *bar, bool visible)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
828 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
829 QMainWindow *win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
830
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
831 if ((! bar->isHidden ()) != visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
832 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
833 QSize sz = bar->sizeHint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
834 QRect r = win->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
835
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
836 if (visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
837 r.adjust (0, -sz.height (), 0, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
838 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
839 r.adjust (0, sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
840
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
841 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
842 set_geometry (r);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
843 bar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
844 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
845
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
846 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
847 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
848 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
849
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
850 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
851 Figure::updateContainer (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
852 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
853 redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
854 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
855
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
856 void
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
857 Figure::figureWindowShown ()
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
858 {
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
859 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
860 QWindow *window = qWidget<QMainWindow> ()->windowHandle ();
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
861 QScreen *screen = window->screen ();
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
862
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
863 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
864
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
865 octave::autolock guard (gh_mgr.graphics_lock ());
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
866
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
867 figure::properties& fp = properties<figure> ();
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
868 fp.set___device_pixel_ratio__ (screen->devicePixelRatio ());
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
869
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
870 connect (window, &QWindow::screenChanged, this, &Figure::screenChanged);
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
871 #endif
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
872 }
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
873
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
874 void
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
875 Figure::screenChanged (QScreen *screen)
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
876 {
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
877 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
878 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
879
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
880 octave::autolock guard (gh_mgr.graphics_lock ());
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
881
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
882 figure::properties& fp = properties<figure> ();
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
883 double old_dpr = fp.get___device_pixel_ratio__ ();
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
884 double new_dpr = screen->devicePixelRatio ();
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
885 if (old_dpr != new_dpr)
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
886 {
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
887 fp.set___device_pixel_ratio__ (new_dpr);
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
888
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
889 // For some obscure reason, changing the __device_pixel_ratio__ property
27929
265b386f8b20 maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents: 27923
diff changeset
890 // from the GUI thread does not necessarily trigger a redraw. Force it.
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
891 redraw ();
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
892 }
26882
7a6366dbe77e avoid unused parameter warning
John W. Eaton <jwe@octave.org>
parents: 26520
diff changeset
893 #else
7a6366dbe77e avoid unused parameter warning
John W. Eaton <jwe@octave.org>
parents: 26520
diff changeset
894 octave_unused_parameter (screen);
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
895 #endif
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
896 }
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
897
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
898 void
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
899 Figure::enableMouseTracking (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
900 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
901 // Enable mouse tracking on every widgets
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
902 m_container->setMouseTracking (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
903 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
904 for (auto *w : m_container->findChildren<QWidget *> ())
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
905 w->setMouseTracking (true);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
906 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
907
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
908 }