annotate libgui/graphics/Figure.cc @ 22413:8758addcf265

maint: Remove ';' at end of namespace declaration. * Backend.h, BaseControl.cc, BaseControl.h, ButtonControl.h, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.h, SliderControl.cc, SliderControl.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.h, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, __init_qt__.cc, __init_qt__.h, octave-gui.cc, build-env.h, build-env.in.cc, jit-util.h: Remove ';' at end of namespace declaration.
author Rik <rik@octave.org>
date Wed, 31 Aug 2016 20:49:13 -0700
parents c69805d1fa64
children 48c00363dc74
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
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
3 Copyright (C) 2011-2016 Michael Goffioul
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
5 This file is part of Octave.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
8 under the terms of the GNU General Public License as published by the
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10 option) any later version.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
15 for more details.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
18 along with Octave; see the file COPYING. If not, see
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
19 <http://www.gnu.org/licenses/>.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
24 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include <QAction>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <QActionEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <QActionGroup>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <QApplication>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
31 #include <QClipboard>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QEvent>
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
33 #include <QFileDialog>
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
34 #include <QFileInfo>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <QFrame>
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
36 #include <QImage>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include <QMainWindow>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include <QMenu>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include <QMenuBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include <QMessageBox>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include <QtDebug>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include <QTimer>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include <QToolBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include "Canvas.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 #include "Container.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 #include "Figure.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 #include "FigureWindow.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 #include "MouseModeActionGroup.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
50 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
52 #include "file-ops.h"
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
53 #include "unwind-prot.h"
20085
c58cf3a65519 improve copy to clipboard code for Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20079
diff changeset
54 #include "utils.h"
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
55 #include "version.h"
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
56
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
57 #include "octave-qt-link.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
58
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
59 #include "builtin-defun-decls.h"
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
60
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
64 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
65
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
66 static bool
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
67 hasUiControlChildren (const figure::properties& fp)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
68 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
69 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
70
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
71 Matrix kids = fp.get_all_children ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
73 for (int i = 0; i < kids.numel (); i++)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
74 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
75 graphics_object go (gh_manager::get_object (kids(i)));
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
76
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
77 if (go && (go.isa ("uicontrol") || go.isa ("uipanel")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
78 || go.isa ("uibuttongroup")))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
79 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
80 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
82 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
83 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
84
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
85 static bool
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
86 hasUiMenuChildren (const figure::properties& fp)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
87 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
88 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
89
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
90 Matrix kids = fp.get_all_children ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
92 for (int i = 0; i < kids.numel (); i++)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
93 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
94 graphics_object go (gh_manager::get_object (kids(i)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
95
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
96 if (go && go.isa ("uimenu"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
97 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
98 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
99
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
100 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
101 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
103 static QRect
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
104 boundingBoxToRect (const Matrix& bb)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
105 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
106 QRect r;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
108 if (bb.numel () == 4)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
109 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
110 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
111 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
112 if (! r.isValid ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
113 r = QRect ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
114 }
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
115
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
116 return r;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
117 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
119 Figure*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
120 Figure::create (const graphics_object& go)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
121 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
122 return new Figure (go, new FigureWindow ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
123 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
125 Figure::Figure (const graphics_object& go, FigureWindow* win)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
126 : Object (go, win), m_blockUpdates (false), m_figureToolBar (0),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
127 m_menuBar (0), m_innerRect (), m_outerRect (), m_mouseModeGroup (0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
128 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
129 m_container = new Container (win);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
130 win->setCentralWidget (m_container);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
132 figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
133
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
134 // Status bar
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
135 m_statusBar = win->statusBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
136 int boffset = 0;
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 // Toolbar and menubar
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
139 createFigureToolBarAndMenuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
140 int toffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
142 if (fp.toolbar_is ("figure") ||
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
143 (fp.toolbar_is ("auto") && fp.menubar_is ("figure") &&
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
144 ! hasUiControlChildren (fp)))
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 toffset += m_figureToolBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
147 boffset += m_statusBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
148 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
149 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
150 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
151 m_figureToolBar->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
152 m_statusBar->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
153 }
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 if (fp.menubar_is ("figure") || hasUiMenuChildren (fp))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
156 toffset += m_menuBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
157 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
158 m_menuBar->hide ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
160 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
161 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
162
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
163 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
164
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
165 // Enable mouse tracking unconditionally
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
166 enableMouseTracking ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
167
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
168 // 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
169 // 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
170
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
171 // Figure title
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
172 update (figure::properties::ID_NUMBERTITLE);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
173
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
174 // Decide what keyboard events we listen to
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
175 m_container->canvas (m_handle)->setEventMask (0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
176 update (figure::properties::ID_KEYPRESSFCN);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
177 update (figure::properties::ID_KEYRELEASEFCN);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
178
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
179 // modal style
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
180 update (figure::properties::ID_WINDOWSTYLE);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
182 // Visibility
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
183 update (figure::properties::ID_VISIBLE);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
184
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
185 connect (this, SIGNAL (asyncUpdate (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
186 this, SLOT (updateContainer (void)));
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 win->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
189 m_container->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
190 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
191
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
192 Figure::~Figure (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
193 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
194 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
195
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
196 static std::string
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
197 mouse_mode_to_string (MouseMode mode)
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 switch (mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
200 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
201 case NoMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
202 return "none";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
203
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
204 case RotateMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
205 return "rotate";
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
206
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
207 case ZoomInMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
208 return "zoom in";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
209
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
210 case ZoomOutMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
211 return "zoom out";
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
212
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
213 case PanMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
214 return "pan";
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
216 case TextMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
217 return "text";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
218
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
219 case SelectMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
220 return "select";
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
221
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
222 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
223 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
224 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
225
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
226 return "none";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
227 }
20504
b6ae0ef9327e Display bottom Qt statusbar on figure based on "toolbar" property (bug #46025).
Rik <rik@octave.org>
parents: 20270
diff changeset
228
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
229 static MouseMode
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
230 mouse_mode_from_string (const std::string& mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
231 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
232 if (mode == "none")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
233 return NoMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
234 else if (mode == "rotate")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
235 return RotateMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
236 else if (mode == "zoom in")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
237 return ZoomInMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
238 else if (mode == "zoom out")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
239 return ZoomOutMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
240 else if (mode == "pan")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
241 return PanMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
242 else if (mode == "text")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
243 return TextMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
244 else if (mode == "select")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
245 return SelectMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
246 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
247 return NoMode;
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
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
250 QString
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
251 Figure::fileName (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
252 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
253 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
254
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
255 const figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
256
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
257 std::string name = fp.get_filename ();
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 return QString::fromStdString (name);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
260 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
261
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
262 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
263 Figure::setFileName (const QString& name)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
264 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
265 gh_manager::auto_lock lock;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
266
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
267 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
268
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
269 fp.set_filename (name.toStdString ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
270 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
271
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
272 MouseMode
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
273 Figure::mouseMode (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
274 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
275 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
276
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
277 const figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
278
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
279 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
280
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
281 if (mode == "zoom")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
282 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
283 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
284
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
285 std::string direction = zm.getfield ("Direction").string_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
286
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
287 mode += " " + direction;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
288 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
289
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
290 return mouse_mode_from_string (mode);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
291 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
293 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
294 Figure::createFigureToolBarAndMenuBar (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
295 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
296 QMainWindow* win = qWidget<QMainWindow> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
297
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
298 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
299 m_figureToolBar->setMovable (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
300 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
301
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
302 m_mouseModeGroup = new MouseModeActionGroup (win);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
303 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
304 SLOT (setMouseMode (MouseMode)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
305 m_figureToolBar->addActions (m_mouseModeGroup->actions ());
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 QAction *toggle_axes = m_figureToolBar->addAction (tr ("Axes"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
308 connect (toggle_axes, SIGNAL (triggered (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
309 this, SLOT (toggleAxes (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 QAction *toggle_grid = m_figureToolBar->addAction (tr ("Grid"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
312 connect (toggle_grid, SIGNAL (triggered (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
313 this, SLOT (toggleGrid (void)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
314
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
315 QAction *auto_axes = m_figureToolBar->addAction (tr ("Autoscale"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
316 connect (auto_axes, SIGNAL (triggered (void)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
317 this, SLOT (autoAxes (void)));
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20595
diff changeset
318
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
319 m_menuBar = new MenuBar (win);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
320 win->setMenuBar (m_menuBar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
321
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
322 QMenu* fileMenu = m_menuBar->addMenu (tr ("&File"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
323 fileMenu->menuAction ()->setObjectName ("builtinMenu");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
324 fileMenu->addAction (tr ("&Save"), this, SLOT (fileSaveFigure (bool)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
325 fileMenu->addAction (tr ("Save &As"), this, SLOT (fileSaveFigureAs (void)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
326 fileMenu->addSeparator ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
327 fileMenu->addAction (tr ("&Close Figure"), this,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
328 SLOT (fileCloseFigure (void)), Qt::CTRL | Qt::Key_W);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
329
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
330 QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
331 editMenu->menuAction ()->setObjectName ("builtinMenu");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
332 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (bool)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
333 Qt::CTRL | Qt::Key_C);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
334 editMenu->addSeparator ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
335 editMenu->addActions (m_mouseModeGroup->actions ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
337 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
338 helpMenu->menuAction ()->setObjectName ("builtinMenu");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
339 helpMenu->addAction (tr ("About Octave"), this,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
340 SLOT (helpAboutOctave (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 m_menuBar->addReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
343 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
344
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
345 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
346 Figure::updateFigureToolBarAndMenuBar (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
347 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
348 if (m_mouseModeGroup)
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 m_blockUpdates = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
351 m_mouseModeGroup->setMode (mouseMode ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
352 m_blockUpdates = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
353 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
354 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
355
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
356 Container*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
357 Figure::innerContainer (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
358 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
359 return m_container;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
360 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
361
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
362 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
363 Figure::redraw (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
364 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
365 Canvas* canvas = m_container->canvas (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
366
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
367 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
368 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
369 canvas->redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
370 //canvas->setMouseMode (RotateMode);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
371 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
372
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
373 foreach (QFrame* frame,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
374 qWidget<QWidget> ()->findChildren<QFrame*> ())
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
375 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
376 if (frame->objectName () == "UIPanel"
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
377 || frame->objectName () == "UIButtonGroup")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
378 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
379 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
380
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
381 if (obj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
382 obj->slotRedraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
383 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
384 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
385
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
386 updateFigureToolBarAndMenuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
387 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
388
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
389 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
390 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
391 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
392 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
393
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
394 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
395 canvas->print (file_cmd, term);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
396 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
397
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
398 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
399 Figure::beingDeleted (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
400 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
401 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
402
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
403 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
404 canvas->blockRedraw (true);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
405
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
406 m_menuBar->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
407 m_container->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
408 qWidget<FigureWindow> ()->removeReceiver (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
409 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
410
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
411 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
412 Figure::update (int pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
413 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
414 if (m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
415 return;
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
416
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
417 figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
418 QMainWindow* win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
420 m_blockUpdates = true;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
421
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
422 switch (pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
423 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
424 case figure::properties::ID_POSITION:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
425 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426 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
427 int toffset = 0;
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
428 int boffset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
429
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
430 foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
431 if (! tb->isHidden ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
432 toffset += tb->sizeHint ().height ();
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
433
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
434 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
435 toffset += m_menuBar->sizeHint ().height ();
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20524
diff changeset
436
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
437 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
438 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
439
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
440 win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
441 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
442 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
443
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
444 case figure::properties::ID_NAME:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
445 case figure::properties::ID_NUMBERTITLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
446 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
447 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
448
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
449 case figure::properties::ID_VISIBLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
450 if (fp.is_visible ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
451 QTimer::singleShot (0, win, SLOT (show ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
452 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
453 win->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
454 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
455
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
456 case figure::properties::ID_TOOLBAR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
457 if (fp.toolbar_is ("none"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
458 showFigureToolBar (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
459 else if (fp.toolbar_is ("figure"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
460 showFigureToolBar (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
461 else // "auto"
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
462 showFigureToolBar (! hasUiControlChildren (fp) &&
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
463 fp.menubar_is ("figure"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
464 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
465
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
466 case figure::properties::ID_MENUBAR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
467 showMenuBar (fp.menubar_is ("figure"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
468 if (fp.toolbar_is ("auto"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
469 showFigureToolBar (fp.menubar_is ("figure"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
470 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
471
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
472 case figure::properties::ID_KEYPRESSFCN:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
473 if (fp.get_keypressfcn ().is_empty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
474 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress);
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 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
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
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
479 case figure::properties::ID_KEYRELEASEFCN:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
480 if (fp.get_keyreleasefcn ().is_empty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
481 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
482 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
483 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
484 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
485
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
486 case figure::properties::ID_WINDOWSTYLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
487 if (fp.windowstyle_is ("modal"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
488 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
489 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
490
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
491 // 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
492 // make it use the modal settings
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
493 if (is_visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
494 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
495
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
496 win->setWindowModality (Qt::ApplicationModal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
497 win->setVisible (is_visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
498 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
499 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
500 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
501
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
502 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
503
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
504 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
505 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
506 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
508 m_blockUpdates = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
509 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
510
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
511 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
512 Figure::showFigureToolBar (bool visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
513 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
514 if ((! m_figureToolBar->isHidden ()) != visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
515 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
516 int dy1 = m_figureToolBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
517 int dy2 = m_statusBar->sizeHint ().height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
518 QRect r = qWidget<QWidget> ()->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
519
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
520 if (! visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
521 r.adjust (0, dy1, 0, -dy2);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
522 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
523 r.adjust (0, -dy1, 0, dy2);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
525 m_blockUpdates = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
526 qWidget<QWidget> ()->setGeometry (r);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
527 m_figureToolBar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
528 m_statusBar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
529 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
530
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
531 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
532 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
533 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
534
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
535 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
536 Figure::showMenuBar (bool visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
537 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
538 int h1 = m_menuBar->sizeHint ().height ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
540 foreach (QAction* a, m_menuBar->actions ())
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541 if (a->objectName () == "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542 a->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
544 int h2 = m_menuBar->sizeHint ().height ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
546 if (! visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
547 visible = hasUiMenuChildren (properties<figure> ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
548
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
549 if (! m_menuBar->isHidden ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
550 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
551 int dy = qMax (h1, h2);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
552 QRect r = qWidget<QWidget> ()->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
554 //qDebug () << "Figure::showMenuBar:" << r;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
555 if (! visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
556 r.adjust (0, dy, 0, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
557 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
558 r.adjust (0, -dy, 0, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
559 //qDebug () << "Figure::showMenuBar(adjusted):" << r;
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 m_blockUpdates = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
562 qWidget<QWidget> ()->setGeometry (r);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
563 m_menuBar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
564 m_blockUpdates = false;
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 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
567 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
568 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
569
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
570 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
571 Figure::updateMenuBar (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
572 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
573 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
574 graphics_object go = object ();
20270
062422f2e399 Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20242
diff changeset
575
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
576 if (go.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
577 showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
578 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
579
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
580 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
581 Figure::updateStatusBar (ColumnVector pt)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
582 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
583 if (! m_statusBar->isHidden ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
584 m_statusBar->showMessage (QString ("(%1, %2)")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
585 .arg (pt(0), 0, 'g', 5)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
586 .arg (pt(1), 0, 'g', 5));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
587 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
588
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
589 QWidget*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
590 Figure::menu (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
591 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
592 return qWidget<QMainWindow> ()->menuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
593 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
594
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
595 struct UpdateBoundingBoxData
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
596 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
597 Matrix m_bbox;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
598 bool m_internal;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
599 graphics_handle m_handle;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
600 Figure* m_figure;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
601 };
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
602
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
603 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
604 Figure::updateBoundingBoxHelper (void* data)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
605 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
606 gh_manager::auto_lock lock;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
608 UpdateBoundingBoxData* d = reinterpret_cast<UpdateBoundingBoxData*> (data);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
609 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
610
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
611 if (go.valid_object ())
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 figure::properties& fp = Utils::properties<figure> (go);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
614
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
615 fp.set_boundingbox (d->m_bbox, d->m_internal, false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
616 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
617
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
618 delete d;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
619 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
620
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
621 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
622 Figure::updateBoundingBox (bool internal, int flags)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
623 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
624 QWidget* win = qWidget<QWidget> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
625 Matrix bb (1, 4);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
626
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
627 if (internal)
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 QRect r = m_innerRect;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
631 if (flags & UpdateBoundingBoxPosition)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
632 r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
633 if (flags & UpdateBoundingBoxSize)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
634 r.setSize (m_container->size ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
635
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
636 if (r.isValid () && r != m_innerRect)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
637 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
638 m_innerRect = r;
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 bb(0) = r.x ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
641 bb(1) = r.y ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
642 bb(2) = r.width ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
643 bb(3) = r.height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
644 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
645 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
646 return;
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 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
649 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
650 QRect r = m_outerRect;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
651
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
652 if (flags & UpdateBoundingBoxPosition)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
653 r.moveTopLeft (win->pos ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
654 if (flags & UpdateBoundingBoxSize)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
655 r.setSize (win->frameGeometry ().size ());
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 if (r.isValid () && r != m_outerRect)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
658 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
659 m_outerRect = r;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
660
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
661 bb(0) = r.x ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
662 bb(1) = r.y ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
663 bb(2) = r.width ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
664 bb(3) = r.height ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
665 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
666 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
667 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
668 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
669
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
670 UpdateBoundingBoxData* d = new UpdateBoundingBoxData ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
671
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
672 d->m_bbox = bb;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
673 d->m_internal = internal;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
674 d->m_handle = m_handle;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
675 d->m_figure = this;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
676
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
677 gh_manager::post_function (Figure::updateBoundingBoxHelper, d);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
678 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
679
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
680 bool
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
681 Figure::eventNotifyBefore (QObject* obj, QEvent* xevent)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
682 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
683 if (! m_blockUpdates)
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 if (obj == m_container)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
686 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
687 // Do nothing...
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
688 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
689 else if (obj == m_menuBar)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
690 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
691 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
692 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
693 case QEvent::ActionRemoved:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
694 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
695 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
696
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
697 if (! a->isSeparator ()
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
698 && a->objectName () != "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
699 updateMenuBar ();
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
700 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
701 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
702
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
703 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
704 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
705 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
706 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
707 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
708 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
709 switch (xevent->type ())
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 case QEvent::Close:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
712 xevent->ignore ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
713 gh_manager::post_callback (m_handle, "closerequestfcn");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
714 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
715
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
716 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
717 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
718 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
719 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
720 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
721
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
722 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
723 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
724
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
725 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
726 Figure::eventNotifyAfter (QObject* watched, QEvent* xevent)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
727 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
728 if (! m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
729 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
730 if (watched == m_container)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
731 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
732 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
733 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
734 case QEvent::Resize:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
735 updateBoundingBox (true, UpdateBoundingBoxSize);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
736 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19955
diff changeset
737
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
738 case QEvent::ChildAdded:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
739 if (dynamic_cast<QChildEvent*> (xevent)->child
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
740 ()->isWidgetType())
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 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
743 update (figure::properties::ID_TOOLBAR);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
744
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
745 enableMouseTracking ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
746 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
747
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
748 case QEvent::ChildRemoved:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
749 if (dynamic_cast<QChildEvent*> (xevent)->child
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
750 ()->isWidgetType())
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 gh_manager::auto_lock lock;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
753 update (figure::properties::ID_TOOLBAR);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
754 }
21916
3a0c90b59584 Make qt figure window "Help" menu correspond to main window (bug #48223)
Mike Miller <mtmiller@octave.org>
parents: 21824
diff changeset
755
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
756 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
757 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
758 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
759 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
760 else if (watched == m_menuBar)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
761 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
762 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
763 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
764 case QEvent::ActionAdded:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
765 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
766 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
767
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
768 if (! a->isSeparator ()
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
769 && a->objectName () != "builtinMenu")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
770 updateMenuBar ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
771 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
772 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
773
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
774 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
775 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
776 }
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 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
779 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
780 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
781 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
782 case QEvent::Move:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
783 updateBoundingBox (false, UpdateBoundingBoxPosition);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
784 updateBoundingBox (true, UpdateBoundingBoxPosition);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
785 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
786
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
787 case QEvent::Resize:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
788 updateBoundingBox (false, UpdateBoundingBoxSize);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
789 break;
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
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 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
796 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
797
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
798 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
799 Figure::helpAboutOctave (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
800 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
801 std::string message
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
802 = octave_name_version_copyright_copying_warranty_and_bugs (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
803
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
804 QMessageBox::about (qWidget<QMainWindow> (), tr ("About Octave"),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
805 QString::fromStdString (message));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
806 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
807
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
808 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
809 Figure::setMouseMode (MouseMode mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
810 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
811 if (m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
812 return;
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
813
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
814 gh_manager::auto_lock lock;
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 figure::properties& fp = properties<figure> ();
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 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
819
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
820 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
821
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
822 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
823 canvas->setCursor (mode);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
824 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
825
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
826 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
827 Figure::fileSaveFigure (bool prompt)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
828 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
829 QString file = fileName ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
830
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
831 if (file.isEmpty ())
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 prompt = true;
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
834
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
835 file = "untitled.pdf";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
836 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
837
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
838 if (prompt || file.isEmpty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
839 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
840 QFileInfo finfo (file);
20242
4c2d39de1e96 Allow saving/copying other figures than the currentfigure (bug #45226)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
841
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
842 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
843 tr ("Save Figure As"),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
844 finfo.absoluteFilePath (), 0, 0,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
845 QFileDialog::DontUseNativeDialog);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
846 }
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
847
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
848 if (! file.isEmpty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
849 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
850 QFileInfo finfo (file);
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
851
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
852 setFileName (finfo.absoluteFilePath ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
853
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
854 octave_link::post_event (this, &Figure::save_figure_callback,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
855 file.toStdString ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
856 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
857 }
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
858
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
859 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
860 Figure::save_figure_callback (const std::string& file)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
861 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
862 figure::properties& fp = properties<figure> ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
863 octave_value fnum = fp.get___myhandle__ ().as_octave_value ();
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
864
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
865 Ffeval (ovl ("print", fnum, file));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
866 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
867
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
868 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
869 Figure::copy_figure_callback (const std::string& format)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
870 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
871 std::string msg;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
872
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
873 std::string file = octave::sys::tempnam ("", "oct-", msg) + "." + format;
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
874
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
875 if (file.empty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
876 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
877 // Report error?
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
878 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
879 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
880
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
881 save_figure_callback (file);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
882
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
883 octave_link::copy_image_to_clipboard (file);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
884 }
19685
7335cc071ab0 make save and saveas menu items work in Qt figure window
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
885
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
886 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
887 Figure::fileSaveFigureAs (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
888 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
889 fileSaveFigure (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
890 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
891
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
892 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
893 Figure::fileCloseFigure (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
894 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
895 qWidget<QMainWindow> ()->close ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
896 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
897
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
898 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
899 Figure::editCopy (bool /* choose_format */)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
900 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
901 QString format = "png";
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
902
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
903 #if 0
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
904
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
905 // FIXME: allow choice of image formats.
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
906
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
907 if (choose_format)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
908 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
909 QFileInfo finfo (file);
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
910
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
911 format = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
912 tr ("Save Figure As"),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
913 finfo.absoluteFilePath (), 0, 0,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
914 QFileDialog::DontUseNativeDialog);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
915 }
20079
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
916 #endif
27c0285828f8 make copying images to the clipboard work with Qt graphics
John W. Eaton <jwe@octave.org>
parents: 20078
diff changeset
917
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
918 octave_link::post_event (this, &Figure::copy_figure_callback,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
919 format.toStdString ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
920 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
921
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
922 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
923 Figure::addCustomToolBar (QToolBar* bar, bool visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
924 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
925 QMainWindow* win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
926
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
927 if (! visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
928 win->addToolBar (bar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
929 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
930 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
931 QSize sz = bar->sizeHint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
932 QRect r = win->geometry ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
933 //qDebug () << "Figure::addCustomToolBar:" << r;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
934
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
935 r.adjust (0, -sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
936
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
937 m_blockUpdates = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
938 win->setGeometry (r);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
939 win->addToolBarBreak ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
940 win->addToolBar (bar);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
941 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
942
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
943 //qDebug () << "Figure::addCustomToolBar:" << win->geometry ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
944 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
945 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
946 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
947
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
948 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
949 Figure::showCustomToolBar (QToolBar* bar, bool visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
950 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
951 QMainWindow* win = qWidget<QMainWindow> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
952
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
953 if ((! bar->isHidden ()) != visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
954 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
955 QSize sz = bar->sizeHint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
956 QRect r = win->geometry ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
957
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
958 if (visible)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
959 r.adjust (0, -sz.height (), 0, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
960 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
961 r.adjust (0, sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
962
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
963 m_blockUpdates = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
964 win->setGeometry (r);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
965 bar->setVisible (visible);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
966 m_blockUpdates = false;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
967
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
968 updateBoundingBox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
969 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
970 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
971
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
972 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
973 Figure::updateContainer (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
974 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
975 redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
976 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
977
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
978 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
979 Figure::toggleAxes (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
980 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
981 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
982
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
983 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
984 canvas->toggleAxes (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
985 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
986
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
987 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
988 Figure::toggleGrid (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
989 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
990 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
991
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
992 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
993 canvas->toggleGrid (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
994 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
995
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
996 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
997 Figure::autoAxes (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
998 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
999 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
1000
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1001 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1002 canvas->autoAxes (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1003 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20114
diff changeset
1004
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1005 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1006 Figure::enableMouseTracking (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1007 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1008 // Enable mouse tracking on every widgets
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1009 m_container->setMouseTracking (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1010 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1011 foreach (QWidget* w, m_container->findChildren<QWidget*> ())
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1012 { w->setMouseTracking (true); }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1013 }
20594
46edfbd31ad7 Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20537
diff changeset
1014
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
1015 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22370
diff changeset
1016