annotate libgui/graphics/Figure.cc @ 26130:5b5122fea9e9

Remove confusing Select button from figure toolbar (bug #55057). Re-instate and connect to plotedit function when available. * Figure.h: Remove SelectMode from MouseMode enum. * Figure.cc (mouse_mode_to_string, mouse_mode_from_string): Remove cases for decoding SelectMode. * MouseModeActionGroup.cc (MouseModeActionGroup): Remove creation of Select button from constructor. * MouseModeActionGroup.cc (actionToggled, setMode): Remove special code for SelectMode to cancel all other button highlighting.
author Rik <rik@octave.org>
date Fri, 23 Nov 2018 21:30:53 -0800
parents 17b13616590d
children 358bed84511b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25044
diff changeset
3 Copyright (C) 2011-2018 Michael Goffioul
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
5 This file is part of Octave.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24465
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22744
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24465
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22744
diff changeset
10 (at your option) any later version.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22744
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22744
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22744
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22744
diff changeset
15 GNU General Public License for more details.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24465
diff changeset
19 <https://www.gnu.org/licenses/>.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
24 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include <QAction>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <QActionEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <QActionGroup>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <QApplication>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
31 #include <QClipboard>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QEvent>
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
33 #include <QFileDialog>
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
34 #include <QFileInfo>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <QFrame>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
36 #include <QImage>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include <QMainWindow>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include <QMenu>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include <QMenuBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include <QMessageBox>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include <QtDebug>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include <QTimer>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include <QToolBar>
25886
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
44 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
45 # include <QWindow>
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
46 # include <QScreen>
d3f5d021255d Allow building with Qt4 again (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25884
diff changeset
47 #endif
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 #include "Canvas.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 #include "Container.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 #include "Figure.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 #include "FigureWindow.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 #include "MouseModeActionGroup.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
54 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
56 #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
57 #include "unwind-prot.h"
20085
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20079
diff changeset
58 #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
59 #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
60
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
61 #include "octave-qt-link.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
62
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
63 #include "builtin-defun-decls.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
64
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
68 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
69
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
70 static bool
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
71 hasUiControlChildren (const figure::properties& fp)
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 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
74
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
75 Matrix kids = fp.get_all_children ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
77 for (int i = 0; i < kids.numel (); i++)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
78 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
79 graphics_object go (gh_manager::get_object (kids(i)));
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
80
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
81 if (go && (go.isa ("uicontrol") || go.isa ("uipanel")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
82 || go.isa ("uibuttongroup")))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
83 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
84 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
86 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
87 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
88
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
89 static QRect
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
90 boundingBoxToRect (const Matrix& bb)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
91 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
92 QRect r;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
94 if (bb.numel () == 4)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
95 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
96 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
97 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
98 if (! r.isValid ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
99 r = QRect ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
100 }
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
101
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
102 return r;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
103 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
105 Figure*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
106 Figure::create (const graphics_object& go)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
107 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
108 return new Figure (go, new FigureWindow ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
109 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
111 Figure::Figure (const graphics_object& go, FigureWindow *win)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23793
diff changeset
112 : Object (go, win), m_blockUpdates (false), m_figureToolBar (nullptr),
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23793
diff changeset
113 m_menuBar (nullptr), m_innerRect (), m_outerRect (),
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
114 m_mouseModeGroup (nullptr), m_previousHeight (0), m_resizable (true)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
115 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
116 m_container = new Container (win);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
117 win->setCentralWidget (m_container);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
119 figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
120
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
121 // Register for the signal that indicates when a window has moved
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
122 // to a different screen
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
123 connect (win, SIGNAL (figureWindowShown ()),
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
124 this, SLOT (figureWindowShown ()));
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
125
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
126 // Status bar
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
127 m_statusBar = win->statusBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
128 int boffset = 0;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
129
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
130 // Toolbar and menubar
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
131 createFigureToolBarAndMenuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
132 int toffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
25951
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
134 if (fp.toolbar_is ("figure")
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
135 || (fp.toolbar_is ("auto") && fp.menubar_is ("figure")
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
136 && ! hasUiControlChildren (fp)))
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
137 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
138 toffset += m_figureToolBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
139 boffset += m_statusBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
140 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
141 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
142 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
143 m_figureToolBar->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
144 m_statusBar->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
145 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
146
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
147 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
148 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
149
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
150 set_geometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
151
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
152 // Enable mouse tracking unconditionally
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
153 enableMouseTracking ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
154
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
155 // When this constructor gets called all properties are already
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
156 // 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
157
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
158 // Figure title
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
159 update (figure::properties::ID_NUMBERTITLE);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
160
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
161 // Decide what keyboard events we listen to
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
162 m_container->canvas (m_handle)->setEventMask (0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
163 update (figure::properties::ID_KEYPRESSFCN);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
164 update (figure::properties::ID_KEYRELEASEFCN);
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 // modal style
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
167 update (figure::properties::ID_WINDOWSTYLE);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
169 // Handle resizing constraints
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
170 update (figure::properties::ID_RESIZE);
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
171
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
172 // Visibility
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
173 update (figure::properties::ID_VISIBLE);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
174
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
175 connect (this, SIGNAL (asyncUpdate (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
176 this, SLOT (updateContainer (void)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
177
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
178 win->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
179 m_container->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
180 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
181
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
182 Figure::~Figure (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
183 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
185 static std::string
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
186 mouse_mode_to_string (MouseMode mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
187 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
188 switch (mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
189 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
190 case NoMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
191 return "none";
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 case RotateMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
194 return "rotate";
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
195
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
196 case ZoomInMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
197 return "zoom in";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
198
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
199 case ZoomOutMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
200 return "zoom out";
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
202 case PanMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
203 return "pan";
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
205 case TextMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
206 return "text";
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 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
209 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
210 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
211
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
212 return "none";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
213 }
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
214
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
215 static MouseMode
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
216 mouse_mode_from_string (const std::string& mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
217 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
218 if (mode == "none")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
219 return NoMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
220 else if (mode == "rotate")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
221 return RotateMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
222 else if (mode == "zoom in")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
223 return ZoomInMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
224 else if (mode == "zoom out")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
225 return ZoomOutMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
226 else if (mode == "pan")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
227 return PanMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
228 else if (mode == "text")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
229 return TextMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
230 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
231 return NoMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
232 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
233
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
234 QString
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
235 Figure::fileName (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
236 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
237 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
238
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
239 const figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
240
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
241 std::string name = fp.get_filename ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
242
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
243 return QString::fromStdString (name);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
244 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
246 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
247 Figure::setFileName (const QString& name)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
248 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
249 gh_manager::auto_lock lock;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
250
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
251 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
252
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
253 fp.set_filename (name.toStdString ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
254 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
255
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
256 MouseMode
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
257 Figure::mouseMode (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
258 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
259 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
260
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
261 const figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
262
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
263 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
264
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
265 if (mode == "zoom")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
266 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
267 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
268
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
269 std::string direction = zm.getfield ("Direction").string_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
270
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23800
diff changeset
271 mode += ' ' + direction;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
272 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
273
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
274 return mouse_mode_from_string (mode);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
275 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
276
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
277 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
278 Figure::createFigureToolBarAndMenuBar (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
279 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
280 QMainWindow *win = qWidget<QMainWindow> ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
281
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
282 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
283 m_figureToolBar->setMovable (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
284 m_figureToolBar->setFloatable (false);
21996
d6370831d37f Set Qt Figure window modal/normal state based on WindowStyle (Bug #48160)
John Donoghue <john.donoghue@ieee.org>
parents: 21916
diff changeset
285
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
286 m_mouseModeGroup = new MouseModeActionGroup (win);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
287 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
288 SLOT (setMouseMode (MouseMode)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
289 m_figureToolBar->addActions (m_mouseModeGroup->actions ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
290
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
291 QAction *toggle_axes = m_figureToolBar->addAction (tr ("Axes"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
292 connect (toggle_axes, SIGNAL (triggered (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
293 this, SLOT (toggleAxes (void)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
294
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
295 QAction *toggle_grid = m_figureToolBar->addAction (tr ("Grid"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
296 connect (toggle_grid, SIGNAL (triggered (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
297 this, SLOT (toggleGrid (void)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
298
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
299 QAction *auto_axes = m_figureToolBar->addAction (tr ("Autoscale"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
300 connect (auto_axes, SIGNAL (triggered (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
301 this, SLOT (autoAxes (void)));
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
302
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
303 m_menuBar = new MenuBar (win);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
304 win->setMenuBar (m_menuBar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
305 m_menuBar->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
306 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
307
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
308 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
309 Figure::updateFigureToolBarAndMenuBar (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
310 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
311 if (m_mouseModeGroup)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
312 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
313 m_blockUpdates = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
314 m_mouseModeGroup->setMode (mouseMode ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
315 m_blockUpdates = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
316 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
317 }
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
318
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
319 void
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
320 Figure::set_geometry (QRect r)
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
321 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
322 QMainWindow *win = qWidget<QMainWindow> ();
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
323
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
324 if (! m_resizable)
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
325 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
326 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
327 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
328 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
329
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
330 win->setGeometry (r);
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
331
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
332 if (! m_resizable)
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
333 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
334 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
335 win->setFixedSize(win->size ());
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
336 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
337 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
339 Container*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
340 Figure::innerContainer (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
341 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
342 return m_container;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
343 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
344
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
345 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
346 Figure::redraw (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
347 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
348 Canvas *canvas = m_container->canvas (m_handle);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
349
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
350 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
351 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
352 canvas->redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
353 //canvas->setMouseMode (RotateMode);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
354 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
355
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
356 foreach (QFrame *frame,
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
357 qWidget<QWidget> ()->findChildren<QFrame*> ())
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
358 {
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
359 if (frame->objectName () == "UIPanel"
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
360 || frame->objectName () == "UIButtonGroup")
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
361 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
362 Object *obj = Object::fromQObject (frame);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
363
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
364 if (obj)
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
365 obj->slotRedraw ();
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
366 }
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
367 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
368
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
369 updateFigureToolBarAndMenuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
370 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
371
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
372 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
373 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
374 {
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
375 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
376
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
377 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
378 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
379 }
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
380
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
381 void
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
382 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
383 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
384 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
385
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
386 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
387 canvas->print (file_cmd, term);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
388 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
389
23535
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
390 uint8NDArray
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
391 Figure::slotGetPixels (void)
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
392 {
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
393 uint8NDArray retval;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
394 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
395
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
396 if (canvas)
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
397 {
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
398 gh_manager::process_events ();
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
399 gh_manager::auto_lock lock;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
400 retval = canvas->getPixels ();
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
401 }
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
402
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
403 return retval;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
404 }
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
405
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
406 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
407 Figure::beingDeleted (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
408 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
409 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
410
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
411 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
412 canvas->blockRedraw (true);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
414 m_menuBar->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
415 m_container->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
416 qWidget<FigureWindow> ()->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
417 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
418
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
419 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
420 Figure::update (int pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
421 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
422 if (m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
423 return;
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
424
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
425 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
426
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
427 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
428 return;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24687
diff changeset
429
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
430 QMainWindow *win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
431
25044
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24691
diff changeset
432 // 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
433 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
434 return;
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24691
diff changeset
435
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
436 m_blockUpdates = true;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24687
diff changeset
437
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
438 switch (pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
439 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
440 case figure::properties::ID_POSITION:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
441 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
442 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
443 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
444 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
445
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
446 foreach (QToolBar *tb, win->findChildren<QToolBar*> ())
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
447 if (! tb->isHidden ())
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
448 toffset += tb->sizeHint ().height ();
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
449
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
450 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
451 toffset += m_menuBar->sizeHint ().height ();
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
452
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
453 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
454 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
455
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
456 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
457 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
458 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
459
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
460 case figure::properties::ID_NAME:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
461 case figure::properties::ID_NUMBERTITLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
462 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
463 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
464
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
465 case figure::properties::ID_VISIBLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
466 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
467 {
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
468 QTimer::singleShot (0, win, SLOT (show ()));
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
469 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
470 {
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
471 gh_manager::auto_lock lock;
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
472 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
473 }
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24687
diff changeset
474 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
475 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
476 win->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
477 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
478
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
479 case figure::properties::ID_RESIZE:
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
480 if (fp.is_resize ())
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
481 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
482 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
483 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
484 m_resizable = true;
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
485 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
486 else
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
487 {
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
488 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
489 win->setFixedSize(win->size ());
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
490 m_resizable = false;
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
491 }
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
492 break;
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
493
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
494 case figure::properties::ID_TOOLBAR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
495 if (fp.toolbar_is ("none"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
496 showFigureToolBar (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
497 else if (fp.toolbar_is ("figure"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
498 showFigureToolBar (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
499 else // "auto"
25951
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
500 showFigureToolBar (! hasUiControlChildren (fp)
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
501 && fp.menubar_is ("figure"));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
502 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
503
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
504 case figure::properties::ID_MENUBAR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
505 if (fp.toolbar_is ("auto"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
506 showFigureToolBar (fp.menubar_is ("figure"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
507 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
508
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
509 case figure::properties::ID_KEYPRESSFCN:
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23535
diff changeset
510 if (fp.get_keypressfcn ().isempty ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
511 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
512 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
513 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
514 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
515
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
516 case figure::properties::ID_KEYRELEASEFCN:
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23535
diff changeset
517 if (fp.get_keyreleasefcn ().isempty ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
518 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
519 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
520 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
521 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
522
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
523 case figure::properties::ID_WINDOWSTYLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
524 if (fp.windowstyle_is ("modal"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
525 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
526 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
527
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
528 // 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
529 // make it use the modal settings
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
530 if (is_visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
531 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
532
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
533 win->setWindowModality (Qt::ApplicationModal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
534 win->setVisible (is_visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
535 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
536 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
537 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
538
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
539 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
540
25852
f6537847b043 ginput.m: temporarily disable mouse tools in Qt toolkit (bug #51452)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25799
diff changeset
541 case figure::properties::ID___MOUSE_MODE__:
f6537847b043 ginput.m: temporarily disable mouse tools in Qt toolkit (bug #51452)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25799
diff changeset
542 m_container->canvas (m_handle)->setCursor (mouseMode ());
f6537847b043 ginput.m: temporarily disable mouse tools in Qt toolkit (bug #51452)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25799
diff changeset
543 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
544
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
545 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
546 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
547 }
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 m_blockUpdates = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
550 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
551
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
552 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
553 Figure::showFigureToolBar (bool visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
554 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
555 if ((! m_figureToolBar->isHidden ()) != visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
556 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
557 int dy1 = m_figureToolBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
558 int dy2 = m_statusBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
559 QRect r = qWidget<QWidget> ()->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
560
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
561 if (! visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
562 r.adjust (0, dy1, 0, -dy2);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
563 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
564 r.adjust (0, -dy1, 0, dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
565
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
566 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
567 set_geometry (r);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
568 m_figureToolBar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
569 m_statusBar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
570 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
571
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
572 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
573 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
574 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
575
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
576 void
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
577 Figure::updateFigureHeight (int dh)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
578 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
579 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
580 graphics_object go = object ();
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
581
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
582 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
583 {
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
584 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
585
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
586 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
587
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
588 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
589 set_geometry (r);
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
590 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
591
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
592 updateBoundingBox (false);
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
593 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
594 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
595
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
596 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
597 Figure::updateStatusBar (ColumnVector pt)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
598 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
599 if (! m_statusBar->isHidden ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
600 m_statusBar->showMessage (QString ("(%1, %2)")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
601 .arg (pt(0), 0, 'g', 5)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
602 .arg (pt(1), 0, 'g', 5));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
603 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
604
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
605 QWidget*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
606 Figure::menu (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
607 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
608 return qWidget<QMainWindow> ()->menuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
609 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
610
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
611 struct UpdateBoundingBoxData
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
612 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
613 Matrix m_bbox;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
614 bool m_internal;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
615 graphics_handle m_handle;
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
616 Figure *m_figure;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
617 };
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 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
620 Figure::updateBoundingBoxHelper (void *data)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
621 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
622 gh_manager::auto_lock lock;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
623
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
624 UpdateBoundingBoxData *d = reinterpret_cast<UpdateBoundingBoxData *> (data);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
625 graphics_object go = gh_manager::get_object (d->m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
626
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
627 if (go.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
628 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
629 figure::properties& fp = Utils::properties<figure> (go);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
630
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
631 fp.set_boundingbox (d->m_bbox, d->m_internal, false);
25995
17b13616590d Backout cset b57b7f3f5e61 (bug #44776)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25952
diff changeset
632
17b13616590d Backout cset b57b7f3f5e61 (bug #44776)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25952
diff changeset
633 if (d->m_internal)
17b13616590d Backout cset b57b7f3f5e61 (bug #44776)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25952
diff changeset
634 emit d->m_figure->asyncUpdate ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
635 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
636
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
637 delete d;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
638 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
639
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
640 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
641 Figure::updateBoundingBox (bool internal, int flags)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
642 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
643 QWidget *win = qWidget<QWidget> ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
644 Matrix bb (1, 4);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
645
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
646 if (internal)
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 QRect r = m_innerRect;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
650 if (flags & UpdateBoundingBoxPosition)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
651 r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
652 if (flags & UpdateBoundingBoxSize)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
653 r.setSize (m_container->size ());
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 if (r.isValid () && r != m_innerRect)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
656 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
657 m_innerRect = r;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
658
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
659 bb(0) = r.x ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
660 bb(1) = r.y ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
661 bb(2) = r.width ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
662 bb(3) = r.height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
663 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
664 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
665 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
666 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
667 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
668 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
669 QRect r = m_outerRect;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
670
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
671 if (flags & UpdateBoundingBoxPosition)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
672 r.moveTopLeft (win->pos ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
673 if (flags & UpdateBoundingBoxSize)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
674 r.setSize (win->frameGeometry ().size ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
675
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
676 if (r.isValid () && r != m_outerRect)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
677 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
678 m_outerRect = r;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
679
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
680 bb(0) = r.x ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
681 bb(1) = r.y ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
682 bb(2) = r.width ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
683 bb(3) = r.height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
684 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
685 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
686 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
687 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
688
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
689 UpdateBoundingBoxData *d = new UpdateBoundingBoxData ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
690
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
691 d->m_bbox = bb;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
692 d->m_internal = internal;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
693 d->m_handle = m_handle;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
694 d->m_figure = this;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
695
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
696 gh_manager::post_function (Figure::updateBoundingBoxHelper, d);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
697 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
698
24435
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
699 void
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
700 Figure::close_figure_callback (void)
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
701 {
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
702 figure::properties& fp = properties<figure> ();
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
703 octave_value fnum = fp.get___myhandle__ ().as_octave_value ();
24446
4ca5c9f899d3 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 24435
diff changeset
704
24435
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
705 Ffeval (ovl ("close", fnum));
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
706 }
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
707
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
708 bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
709 Figure::eventNotifyBefore (QObject *obj, QEvent *xevent)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
710 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
711 if (! m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
712 {
24465
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
713 // 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
714 if (xevent->type () == QEvent::MouseButtonPress)
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
715 {
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
716 figure::properties& fp = properties<figure> ();
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
717 graphics_object root = gh_manager::get_object (0);
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
718 if (fp.get_handlevisibility () == "on")
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
719 root.set ("currentfigure",
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
720 fp.get___myhandle__ ().as_octave_value ());
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
721 }
1b4c4d6ead56 Make mouse clicks update currentfigure (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24446
diff changeset
722
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
723 if (obj == m_container)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
724 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
725 // Do nothing...
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
726 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
727 else if (obj == m_menuBar)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
728 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
729 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
730 {
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
731 case QEvent::ActionAdded:
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
732 case QEvent::ActionChanged:
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
733 case QEvent::ActionRemoved:
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
734 m_previousHeight = m_menuBar->sizeHint ().height ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
735
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
736 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
737 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
738 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
739 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
740 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
741 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
742 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
743 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
744 case QEvent::Close:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
745 xevent->ignore ();
24435
e7624c23b101 Make use of "close" function to close Qt figures (bug #52698).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24210
diff changeset
746 octave_link::post_event (this, &Figure::close_figure_callback);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
747 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
748
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
749 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
750 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
751 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
752 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
753 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
754
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
755 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
756 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
757
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
758 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
759 Figure::eventNotifyAfter (QObject *watched, QEvent *xevent)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
760 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
761 if (! m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
762 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
763 if (watched == m_container)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
764 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
765 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
766 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
767 case QEvent::Resize:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
768 updateBoundingBox (true, UpdateBoundingBoxSize);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
769 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
770
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
771 case QEvent::ChildAdded:
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23224
diff changeset
772 if (dynamic_cast<QChildEvent *> (xevent)->child
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
773 ()->isWidgetType())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
774 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
775 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
776 update (figure::properties::ID_TOOLBAR);
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 enableMouseTracking ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
779 }
23800
2fdc65c031b5 Add break or continue statements to prevent implicit fall-through in case statements.
Rik <rik@octave.org>
parents: 23795
diff changeset
780 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
782 case QEvent::ChildRemoved:
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23224
diff changeset
783 if (dynamic_cast<QChildEvent *> (xevent)->child
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
784 ()->isWidgetType())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
785 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
786 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
787 update (figure::properties::ID_TOOLBAR);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
788 }
23800
2fdc65c031b5 Add break or continue statements to prevent implicit fall-through in case statements.
Rik <rik@octave.org>
parents: 23795
diff changeset
789 break;
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
790
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
791 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
792 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
793 }
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 else if (watched == m_menuBar)
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 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
798 {
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
799 case QEvent::ActionAdded:
22744
2df51376f587 Correctly handle visibility of custom menu items (bug #49529)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22721
diff changeset
800 case QEvent::ActionChanged:
25878
bb4af245dff7 Use uimenu objects for default menus in Qt toolkit
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25852
diff changeset
801 case QEvent::ActionRemoved:
23224
73f7ef7169ac Make uimenu "Position" property Matlab-compatible (bug #50369).
Rik <rik@octave.org>
parents: 23223
diff changeset
802 // 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
803 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
804 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
805 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
806 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
807 && ! a->isSeparator ())
25888
6109f302cf43 Fix regression with "menubar" figure property handling (bug #54678)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25886
diff changeset
808 updateFigureHeight (m_previousHeight - currentHeight);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
809 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
810 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
811
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
812 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
813 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
814 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
815 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
816 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
817 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
818 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
819 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
820 case QEvent::Move:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
821 updateBoundingBox (false, UpdateBoundingBoxPosition);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
822 updateBoundingBox (true, UpdateBoundingBoxPosition);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
823 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
824
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
825 case QEvent::Resize:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
826 updateBoundingBox (false, UpdateBoundingBoxSize);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
827 break;
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
828
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
829 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
830 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
831 }
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 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
834 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
835
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
836 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
837 Figure::setMouseMode (MouseMode mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
838 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
839 if (m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
840 return;
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
841
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
842 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
843
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
844 figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
845
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
846 fp.set___mouse_mode__ (mouse_mode_to_string (mode));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
847
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
848 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
849
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
850 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
851 canvas->setCursor (mode);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
852 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
853
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
854 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
855 Figure::addCustomToolBar (QToolBar *bar, bool visible)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
856 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
857 QMainWindow *win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
858
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
859 if (! visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
860 win->addToolBar (bar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
861 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
862 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
863 QSize sz = bar->sizeHint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
864 QRect r = win->geometry ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
865 //qDebug () << "Figure::addCustomToolBar:" << r;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
866
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
867 r.adjust (0, -sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
868
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
869 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
870 set_geometry (r);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
871 win->addToolBarBreak ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
872 win->addToolBar (bar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
873 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
874
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
875 //qDebug () << "Figure::addCustomToolBar:" << win->geometry ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
876 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
877 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
878 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
879
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
880 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
881 Figure::showCustomToolBar (QToolBar *bar, bool visible)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
882 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
883 QMainWindow *win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
884
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
885 if ((! bar->isHidden ()) != visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
886 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
887 QSize sz = bar->sizeHint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
888 QRect r = win->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
889
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
890 if (visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
891 r.adjust (0, -sz.height (), 0, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
892 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
893 r.adjust (0, sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
894
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
895 m_blockUpdates = true;
25929
ea5182364e5f Implement "resize" property for Qt figures (bug #54774)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25889
diff changeset
896 set_geometry (r);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
897 bar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
898 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
899
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
900 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
901 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
902 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
903
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
904 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
905 Figure::updateContainer (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
906 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
907 redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
908 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
909
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
910 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
911 Figure::toggleAxes (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
912 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
913 Canvas *canvas = m_container->canvas (m_handle);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
914
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
915 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
916 canvas->toggleAxes (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
917 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
918
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
919 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
920 Figure::toggleGrid (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
921 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
922 Canvas *canvas = m_container->canvas (m_handle);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
923
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
924 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
925 canvas->toggleGrid (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
926 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
927
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
928 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
929 Figure::autoAxes (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
930 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
931 Canvas *canvas = m_container->canvas (m_handle);
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
932
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
933 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
934 canvas->autoAxes (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
935 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
936
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
937 void
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
938 Figure::figureWindowShown ()
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
939 {
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
940 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
941 QWindow* window = qWidget<QMainWindow> ()->windowHandle ();
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
942 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
943
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
944 gh_manager::auto_lock lock;
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
945
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
946 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
947 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
948
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
949 connect (window, SIGNAL (screenChanged (QScreen*)),
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
950 this, SLOT (screenChanged (QScreen*)));
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
951
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
952 #endif
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
953 }
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
954
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
955 void
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
956 Figure::screenChanged (QScreen* screen)
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
957 {
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
958 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
959 gh_manager::auto_lock lock;
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
960
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
961 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
962 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
963 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
964 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
965 {
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
966 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
967
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
968 // For some obscure reason, changing the __device_pixel_ratio__ property
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
969 // from the GUI thread does not necessarily trigger a redraw. Force it.
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
970 redraw ();
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25888
diff changeset
971 }
25884
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
972 #endif
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
973 }
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
974
4e108574385c Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents: 25878
diff changeset
975 void
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
976 Figure::enableMouseTracking (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
977 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
978 // Enable mouse tracking on every widgets
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
979 m_container->setMouseTracking (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
980 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
981 foreach (QWidget *w, m_container->findChildren<QWidget*> ())
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
982 w->setMouseTracking (true);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
983 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
984
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
985 }