annotate libgui/graphics/Figure.cc @ 19715:35bca657d74d

printing for Qt plot widget (bug #42537) * Backend.h, Backend.cc (Backend::print_figure): New function. * Canvas.h, Canvas.cc (Canvas::print): New function. * Figure.h, Figure.cc (Figure:print): New function. * Object.h, Object.cc (Object::slotPrint, Object::print): New functions. * ObjectProxy.h, ObjectProxy.cc (ObjectProxy::print): New function. (ObjectProxy::sendPrint): New signal. (ObjectProxy::init): Connect sendPrint signal to slotPrint slot of current object.
author John W. Eaton <jwe@octave.org>
date Sun, 08 Feb 2015 16:25:06 -0500
parents dfea01b3425f
children 7335cc071ab0
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
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
3 Copyright (C) 2011-2014 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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #include <config.h>
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>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <QEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QFrame>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <QMainWindow>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include <QMenu>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <QMenuBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include <QMessageBox>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include <QtDebug>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include <QTimer>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include <QToolBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include "Canvas.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include "Container.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "Figure.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include "FigureWindow.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #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
46 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
51 #define ABOUT_TEXT "<b>QtHandles</b> - a Qt-based toolkit for <a href=\"http://www.octave.org\">Octave</a>.<br><br>Copyright (C) 2011-2014 Michael Goffioul"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 static bool hasUiControlChildren (const figure::properties& fp)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 graphics_object go (gh_manager::get_object (kids(i)));
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 if (go && (go.isa ("uicontrol") || go.isa ("uipanel")
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
64 || go.isa ("uibuttongroup")))
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
65 return true;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 static bool hasUiMenuChildren (const figure::properties& fp)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 Matrix kids = fp.get_all_children ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 for (int i = 0; i < kids.numel (); i++)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 graphics_object go (gh_manager::get_object (kids(i)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 if (go && go.isa ("uimenu"))
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
80 return true;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 static QRect boundingBoxToRect (const Matrix& bb)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 QRect r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 if (bb.numel () == 4)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 r = QRect (xround (bb(0)), xround (bb(1)),
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 xround (bb(2)), xround (bb(3)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 if (! r.isValid ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 r = QRect ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 return r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 Figure* Figure::create (const graphics_object& go)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 return new Figure (go, new FigureWindow ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 Figure::Figure (const graphics_object& go, FigureWindow* win)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
107 : Object (go, win), m_blockUpdates (false), m_figureToolBar (0),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
108 m_menuBar (0), m_innerRect (), m_outerRect (),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
109 m_mouseModeGroup (0)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 m_container = new Container (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 win->setCentralWidget (m_container);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 createFigureToolBarAndMenuBar ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 int offset = 0;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 if (fp.toolbar_is ("figure")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 || (fp.toolbar_is ("auto") && ! hasUiControlChildren (fp)))
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 offset += m_figureToolBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 m_figureToolBar->hide ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124 if (fp.menubar_is ("figure") || hasUiMenuChildren (fp))
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 offset += m_menuBar->sizeHint ().height () + 1;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 m_menuBar->hide ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 //qDebug () << "Figure::Figure:" << m_innerRect;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 //qDebug () << "Figure::Figure(adjusted)" << m_innerRect.adjusted (0, -offset, 0, 0);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137 int eventMask = 0;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 if (! fp.get_keypressfcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139 eventMask |= Canvas::KeyPress;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140 if (! fp.get_keyreleasefcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 eventMask |= Canvas::KeyRelease;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 m_container->canvas (m_handle)->setEventMask (eventMask);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143
18646
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
144 if (! fp.get_windowbuttonmotionfcn ().is_empty ())
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
145 {
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
146 m_container->setMouseTracking (true);
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
147 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
148 }
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
149
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 connect (this, SIGNAL (asyncUpdate (void)),
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 this, SLOT (updateContainer (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 if (fp.is_visible ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154 QTimer::singleShot (0, win, SLOT (show ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 win->hide ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 win->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 m_container->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 Figure::~Figure (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
166 static std::string mouse_mode_to_string (MouseMode mode)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
167 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
168 switch (mode)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
169 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
170 case NoMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
171 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
172
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
173 case RotateMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
174 return "rotate";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
175
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
176 case ZoomMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
177 return "zoom";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
178
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
179 case PanMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
180 return "pan";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
181
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
182 case TextMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
183 return "text";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
184
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
185 case SelectMode:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
186 return "select";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
187
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
188 default:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
189 break;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
190 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
191
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
192 return "none";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
193 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
194
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
195 static MouseMode mouse_mode_from_string (const std::string& mode)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
196 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
197 if (mode == "none")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
198 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
199 else if (mode == "rotate")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
200 return RotateMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
201 else if (mode == "zoom")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
202 return ZoomMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
203 else if (mode == "pan")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
204 return PanMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
205 else if (mode == "text")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
206 return TextMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
207 else if (mode == "select")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
208 return SelectMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
209 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
210 return NoMode;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
211 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
212
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
213 MouseMode Figure::mouseMode (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
214 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
215 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
216
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
217 const figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
218
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
219 std::string mode = fp.get___mouse_mode__ ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
220
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
221 return mouse_mode_from_string (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
222 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
223
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224 void Figure::createFigureToolBarAndMenuBar (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
225 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
226 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
227
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228 m_figureToolBar = win->addToolBar (tr ("Figure ToolBar"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
229 m_figureToolBar->setMovable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230 m_figureToolBar->setFloatable (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
231
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
232 m_mouseModeGroup = new MouseModeActionGroup (win);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
233 connect (m_mouseModeGroup, SIGNAL (modeChanged (MouseMode)),
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
234 SLOT (setMouseMode (MouseMode)));
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
235 m_figureToolBar->addActions (m_mouseModeGroup->actions ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
236
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
237 QAction *toggle_axes = m_figureToolBar->addAction ("Axes");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
238 connect (toggle_axes, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
239 this, SLOT (toggleAxes (void)));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
240
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
241 QAction *toggle_grid = m_figureToolBar->addAction ("Grid");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
242 connect (toggle_grid, SIGNAL (triggered (void)),
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
243 this, SLOT (toggleGrid (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
244
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245 m_menuBar = new MenuBar (win);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
246 win->setMenuBar (m_menuBar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
247
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
248 QMenu* fileMenu = m_menuBar->addMenu (tr ("&File"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
249 fileMenu->menuAction ()->setObjectName ("builtinMenu");
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
250 fileMenu->addAction (tr ("&New Figure"), this, SLOT (fileNewFigure (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
251 fileMenu->addAction (tr ("&Open..."))->setEnabled (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
252 fileMenu->addSeparator ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
253 fileMenu->addAction (tr ("&Save"))->setEnabled (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
254 fileMenu->addAction (tr ("Save &As"))->setEnabled (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
255 fileMenu->addSeparator ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
256 fileMenu->addAction (tr ("&Close Figure"), this,
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
257 SLOT (fileCloseFigure (void)), Qt::CTRL|Qt::Key_W);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
258
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
259 QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
260 editMenu->menuAction ()->setObjectName ("builtinMenu");
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
261 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (void)),
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
262 Qt::CTRL|Qt::Key_C)->setEnabled (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
263 editMenu->addAction (tr ("Cu&t"), this, SLOT (editCut (void)),
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
264 Qt::CTRL|Qt::Key_X)->setEnabled (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
265 editMenu->addAction (tr ("&Paste"), this, SLOT (editPaste(void)),
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
266 Qt::CTRL|Qt::Key_V)->setEnabled (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
267 editMenu->addSeparator ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
268 editMenu->addActions (m_mouseModeGroup->actions ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
269
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
270 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
271 helpMenu->menuAction ()->setObjectName ("builtinMenu");
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
272 helpMenu->addAction (tr ("&About QtHandles"), this,
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
273 SLOT (helpAboutQtHandles (void)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
274 helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void)));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
275
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
276 m_menuBar->addReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
277 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
278
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
279 void Figure::updateFigureToolBarAndMenuBar (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
280 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
281 if (m_mouseModeGroup)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
282 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
283 m_blockUpdates = true;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
284 m_mouseModeGroup->setMode (mouseMode ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
285 m_blockUpdates = false;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
286 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
287 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
288
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
289 Container* Figure::innerContainer (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
290 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
291 return m_container;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
293
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
294 void Figure::redraw (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
295 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296 Canvas* canvas = m_container->canvas (m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
298 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
299 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300 canvas->redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
301 //canvas->setMouseMode (RotateMode);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
302 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
303
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
304 foreach (QFrame* frame,
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
305 qWidget<QWidget> ()->findChildren<QFrame*> ("UIPanel"))
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
306 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
307 Object* obj = Object::fromQObject (frame);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
308
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
309 if (obj)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
310 obj->slotRedraw ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
311 }
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
312
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
313 updateFigureToolBarAndMenuBar ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
314 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
315
19715
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
316 void Figure::print (const QString& file_cmd, const QString& term)
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
317 {
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
318 Canvas* canvas = m_container->canvas (m_handle);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
319
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
320 if (canvas)
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
321 canvas->print (file_cmd, term);
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
322 }
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
323
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
324 void Figure::beingDeleted (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 Canvas* canvas = m_container->canvas (m_handle.value (), false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
328 if (canvas)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329 canvas->blockRedraw (true);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
331 m_menuBar->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
332 m_container->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
333 qWidget<FigureWindow> ()->removeReceiver (this);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
334 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
335
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336 void Figure::update (int pId)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 if (m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
339 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
340
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341 figure::properties& fp = properties<figure> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
342 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
343
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
344 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
345
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
346 switch (pId)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
347 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
348 case figure::properties::ID_POSITION:
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
349 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
350 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
351 //qDebug () << "Figure::update(position):" << m_innerRect;
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
352 int offset = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
353
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
354 foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
355 if (! tb->isHidden ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
356 offset += tb->sizeHint ().height ();
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
357 if (! m_menuBar->isHidden ())
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
358 offset += m_menuBar->sizeHint ().height () + 1;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
359 //qDebug () << "Figure::update(position)(adjusted):" << m_innerRect.adjusted (0, -offset, 0, 0);
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
360 win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
361 //qDebug () << "Figure::update(position): done";
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
362 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
363 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
364 case figure::properties::ID_NAME:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
365 case figure::properties::ID_NUMBERTITLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
366 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
367 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
368 case figure::properties::ID_VISIBLE:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 if (fp.is_visible ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
370 QTimer::singleShot (0, win, SLOT (show ()));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
371 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
372 win->hide ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
373 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
374 case figure::properties::ID_TOOLBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
375 if (fp.toolbar_is ("none"))
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
376 showFigureToolBar (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377 else if (fp.toolbar_is ("figure"))
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
378 showFigureToolBar (true);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
379 else // "auto"
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
380 showFigureToolBar (! hasUiControlChildren (fp));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
381 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
382 case figure::properties::ID_MENUBAR:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
383 showMenuBar (fp.menubar_is ("figure"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
384 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
385 case figure::properties::ID_KEYPRESSFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
386 if (fp.get_keypressfcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
387 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
388 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
389 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
390 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
391 case figure::properties::ID_KEYRELEASEFCN:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
392 if (fp.get_keyreleasefcn ().is_empty ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
393 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
394 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
395 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
396 break;
18646
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
397 case figure::properties::ID_WINDOWBUTTONMOTIONFCN:
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
398 {
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
399 bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty ();
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
400
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
401 m_container->setMouseTracking (hasCallback);
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
402 foreach (QWidget* w, m_container->findChildren<QWidget*> ())
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
403 { w->setMouseTracking (hasCallback); }
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
404 }
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
405 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
406 default:
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
407 break;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
408 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
409
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
410 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
411 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
412
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413 void Figure::showFigureToolBar (bool visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
414 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
415 if ((! m_figureToolBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
416 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
417 int dy = m_figureToolBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
418 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
420 if (! visible)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
421 r.adjust (0, dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
423 r.adjust (0, -dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
424
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
425 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
427 m_figureToolBar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
428 m_blockUpdates = false;
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 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
431 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
432 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
433
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
434 void Figure::showMenuBar (bool visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
435 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
436 int h1 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
437
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
438 foreach (QAction* a, m_menuBar->actions ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
439 if (a->objectName () == "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
440 a->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
441
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
442 int h2 = m_menuBar->sizeHint ().height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
443
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
444 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
445 visible = hasUiMenuChildren (properties<figure> ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
446
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
447 if ((! m_menuBar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
448 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
449 int dy = qMax (h1, h2) + 1;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
450 QRect r = qWidget<QWidget> ()->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
451
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
452 //qDebug () << "Figure::showMenuBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
453 if (! visible)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
454 r.adjust (0, dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
455 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
456 r.adjust (0, -dy, 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
457 //qDebug () << "Figure::showMenuBar(adjusted):" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
458
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
459 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
460 qWidget<QWidget> ()->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
461 m_menuBar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
462 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
463
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
464 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
465 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
466 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
467
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468 void Figure::updateMenuBar (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
469 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
470 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
471 graphics_object go = object ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
472
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
473 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
474 showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
475 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
476
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
477 QWidget* Figure::menu (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
478 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
479 return qWidget<QMainWindow> ()->menuBar ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
480 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
481
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
482 struct UpdateBoundingBoxData
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
483 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
484 Matrix m_bbox;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
485 bool m_internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
486 graphics_handle m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
487 Figure* m_figure;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
488 };
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
489
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
490 void Figure::updateBoundingBoxHelper (void* data)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
492 gh_manager::auto_lock lock;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
493
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
494 UpdateBoundingBoxData* d = reinterpret_cast<UpdateBoundingBoxData*> (data);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
495 graphics_object go = gh_manager::get_object (d->m_handle);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
496
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
497 if (go.valid_object ())
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
498 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
499 figure::properties& fp = Utils::properties<figure> (go);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
500
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
501 //qDebug ("Figure::updateBoundingBoxHelper: internal=%d, bbox=[%g %g %g %g]",
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
502 // d->m_internal, d->m_bbox(0), d->m_bbox(1), d->m_bbox(2), d->m_bbox(3));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503 fp.set_boundingbox (d->m_bbox, d->m_internal, false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
505 if (d->m_internal)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
506 emit d->m_figure->asyncUpdate ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
508
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
509 delete d;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
510 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
511
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
512 void Figure::updateBoundingBox (bool internal, int flags)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
513 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
514 QWidget* win = qWidget<QWidget> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
515 Matrix bb (1, 4);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
516
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
517 if (internal)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
519 QRect r = m_innerRect;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
520
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
521 if (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
522 r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
523 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524 r.setSize (m_container->size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
525
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
526 if (r.isValid () && r != m_innerRect)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
527 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
528 //qDebug() << "inner rect changed:" << m_innerRect << "->>" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
529 m_innerRect = r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
530
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
531 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
532 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
533 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
534 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
535 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
536 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
537 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
538 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541 QRect r = m_outerRect;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543 if (flags & UpdateBoundingBoxPosition)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
544 r.moveTopLeft (win->pos ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545 if (flags & UpdateBoundingBoxSize)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
546 r.setSize (win->frameGeometry ().size ());
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
547
18712
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18646
diff changeset
548 if (r.isValid () && r != m_outerRect)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
549 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
550 //qDebug() << "outer rect changed:" << m_outerRect << "->>" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
551 m_outerRect = r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
552
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553 bb(0) = r.x ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
554 bb(1) = r.y ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
555 bb(2) = r.width ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
556 bb(3) = r.height ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
557 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
558 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
559 return;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
560 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
561
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
562 UpdateBoundingBoxData* d = new UpdateBoundingBoxData ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
563
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
564 d->m_bbox = bb;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
565 d->m_internal = internal;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
566 d->m_handle = m_handle;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
567 d->m_figure = this;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
568
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
569 //qDebug ("Figure::updateBoundingBox: internal=%d, bbox=[%g %g %g %g]",
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
570 // d->m_internal, d->m_bbox(0), d->m_bbox(1), d->m_bbox(2), d->m_bbox(3));
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
571 gh_manager::post_function (Figure::updateBoundingBoxHelper, d);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
572 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
573
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
574 bool Figure::eventNotifyBefore (QObject* obj, QEvent* xevent)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
575 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
576 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
577 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
578 if (obj == m_container)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
579 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
580 // Do nothing...
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
581 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
582 else if (obj == m_menuBar)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
583 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
584 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
585 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
586 case QEvent::ActionRemoved:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
587 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
588 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
590 if (! a->isSeparator ()
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
591 && a->objectName () != "builtinMenu")
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
592 updateMenuBar ();
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
593 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
594 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
595 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
596 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
597 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
598 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
599 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
600 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
601 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
602 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
603 case QEvent::Close:
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
604 xevent->ignore ();
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
605 gh_manager::post_callback (m_handle, "closerequestfcn");
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
606 return true;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
607 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
608 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
609 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
610 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
611 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
612
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613 return false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
614 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
615
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
616 void Figure::eventNotifyAfter (QObject* watched, QEvent* xevent)
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
617 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
618 if (! m_blockUpdates)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
619 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
620 if (watched == m_container)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
621 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
622 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
623 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
624 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
625 updateBoundingBox (true, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
626 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
627 case QEvent::ChildAdded:
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
628 if (dynamic_cast<QChildEvent*> (xevent)->child
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
629 ()->isWidgetType())
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
630 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
631 gh_manager::auto_lock lock;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
632 const figure::properties& fp = properties<figure> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
633
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
634 showFigureToolBar (! hasUiControlChildren (fp));
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
635 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
636 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
637 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
638 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
639 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640 else if (watched == m_menuBar)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
641 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
642 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
643 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
644 case QEvent::ActionAdded:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
645 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
646 QAction* a = dynamic_cast<QActionEvent*> (xevent)->action ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
648 if (! a->isSeparator ()
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649 && a->objectName () != "builtinMenu")
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
650 updateMenuBar ();
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
651 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
652 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
653 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
654 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
655 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
656 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
657 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
658 {
19657
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19655
diff changeset
659 switch (xevent->type ())
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
660 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
661 case QEvent::Move:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
662 updateBoundingBox (false, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
663 updateBoundingBox (true, UpdateBoundingBoxPosition);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
664 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
665 case QEvent::Resize:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
666 updateBoundingBox (false, UpdateBoundingBoxSize);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
667 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
668 default:
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
669 break;
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
670 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
671 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
672 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
673 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
674
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
675 void Figure::helpAboutQtHandles (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
676 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
677 QMessageBox::about (qWidget<QMainWindow> (), tr ("About QtHandles"),
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
678 ABOUT_TEXT);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
679 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
680
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
681 void Figure::setMouseMode (MouseMode mode)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
682 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
683 if (m_blockUpdates)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
684 return;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
685
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
686 gh_manager::auto_lock lock;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
687
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
688 figure::properties& fp = properties<figure> ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
689
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
690 fp.set___mouse_mode__ (mouse_mode_to_string (mode));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
691
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
692 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
693
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
694 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
695 canvas->setCursor (mode);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
696 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
697
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
698 void Figure::fileNewFigure (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
699 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
700 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
701
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
702 void Figure::fileCloseFigure (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
703 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
704 qWidget<QMainWindow> ()->close ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
705 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
706
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
707 void Figure::editCopy (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
708 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
709 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
710
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
711 void Figure::editCut (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
712 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
713 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
714
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
715 void Figure::editPaste (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
716 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
717 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
718
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
719 void Figure::addCustomToolBar (QToolBar* bar, bool visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
720 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
721 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
722
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
723 if (! visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
724 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
725 else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
726 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
727 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
728 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
729 //qDebug () << "Figure::addCustomToolBar:" << r;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
730
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
731 r.adjust (0, -sz.height (), 0, 0);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
732
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
733 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
734 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
735 win->addToolBarBreak ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
736 win->addToolBar (bar);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
737 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
738
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
739 //qDebug () << "Figure::addCustomToolBar:" << win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
740 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
741 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
742 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
743
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
744 void Figure::showCustomToolBar (QToolBar* bar, bool visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
745 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
746 QMainWindow* win = qWidget<QMainWindow> ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
747
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
748 if ((! bar->isHidden ()) != visible)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
749 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
750 QSize sz = bar->sizeHint ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
751 QRect r = win->geometry ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
752
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
753 if (visible)
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
754 r.adjust (0, -sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
755 else
19655
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19650
diff changeset
756 r.adjust (0, sz.height (), 0, 0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
757
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
758 m_blockUpdates = true;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
759 win->setGeometry (r);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
760 bar->setVisible (visible);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
761 m_blockUpdates = false;
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
762
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
763 updateBoundingBox (false);
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
764 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
765 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
766
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
767 void Figure::updateContainer (void)
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
768 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
769 redraw ();
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
770 }
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
771
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
772 void Figure::toggleAxes (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
773 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
774 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
775
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
776 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
777 canvas->toggleAxes (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
778 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
779
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
780 void Figure::toggleGrid (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
781 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
782 Canvas* canvas = m_container->canvas (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
783
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
784 if (canvas)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
785 canvas->toggleGrid (m_handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
786 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19659
diff changeset
787
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
788 }; // namespace QtHandles