annotate libgui/graphics/qt-graphics-toolkit.cc @ 31585:7d7e04fc21ba stable

uitable: Avoid crash with Boolean values (bug #63388). * libgui/graphics/qt-graphics-toolkit.cc (qt_graphics_toolkit::update): Redraw entire uitable on data update.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 29 Nov 2022 11:17:56 +0100
parents 796f54d4ddbf
children ca7d58406f82 c6d54dd31a7e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30398
diff changeset
3 // Copyright (C) 2011-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21699
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
27 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
21912
d92dcbcd7691 prefer C++ wrappers for C standard headers in C++ code
John W. Eaton <jwe@octave.org>
parents: 21824
diff changeset
30 #include <cstdint>
d92dcbcd7691 prefer C++ wrappers for C standard headers in C++ code
John W. Eaton <jwe@octave.org>
parents: 21824
diff changeset
31
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QApplication>
27254
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
33 #include <QFontMetrics>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include <QThread>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
36 #include "ButtonGroup.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
37 #include "CheckBoxControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
38 #include "ContextMenu.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
39 #include "EditControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
40 #include "Figure.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
41 #include "ListBoxControl.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include "Logger.h"
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
43 #include "Menu.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include "Object.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include "ObjectProxy.h"
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
46 #include "Panel.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
47 #include "PopupMenuControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
48 #include "PushButtonControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
49 #include "PushTool.h"
27254
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
50 #include "QtHandlesUtils.h"
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
51 #include "RadioButtonControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
52 #include "SliderControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
53 #include "Table.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
54 #include "TextControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
55 #include "ToggleButtonControl.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
56 #include "ToggleTool.h"
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
57 #include "ToolBar.h"
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
58 #include "qt-graphics-toolkit.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
60 #include "octave-qobject.h"
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
61
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
62 #include "event-manager.h"
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
63 #include "graphics.h"
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
64 #include "interpreter.h"
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
65
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 //#if INTPTR_MAX == INT32_MAX
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 //# define OCTAVE_PTR_TYPE octave_uint32
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 //# define OCTAVE_INTPTR_TYPE uint32_t
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 //# define OCTAVE_PTR_SCALAR uint32_scalar_value
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 //#else
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 # define OCTAVE_PTR_TYPE octave_uint64
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 # define OCTAVE_INTPTR_TYPE uint64_t
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 # define OCTAVE_PTR_SCALAR uint64_scalar_value
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 //#endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
29992
6ea4a84df9c7 rename QtHandles namespace to octave
John W. Eaton <jwe@octave.org>
parents: 29602
diff changeset
76 namespace octave
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
79 static std::string
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
80 toolkitObjectProperty (const graphics_object& go)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
81 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
82 if (go.isa ("figure"))
23829
01899bdd2a3a Eliminate unnecessary std::string ("...") constructor calls when "..." suffices.
Rik <rik@octave.org>
parents: 23795
diff changeset
83 return "__plot_stream__";
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
84 else if (go.isa ("uicontrol")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
85 || go.isa ("uipanel")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
86 || go.isa ("uibuttongroup")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
87 || go.isa ("uimenu")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
88 || go.isa ("uicontextmenu")
26112
36e0e5b428e7 Implement uitable (patch #9084)
Andrew Thornton <art27@cantab.net>
parents: 25799
diff changeset
89 || go.isa ("uitable")
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
90 || go.isa ("uitoolbar")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
91 || go.isa ("uipushtool")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
92 || go.isa ("uitoggletool"))
23829
01899bdd2a3a Eliminate unnecessary std::string ("...") constructor calls when "..." suffices.
Rik <rik@octave.org>
parents: 23795
diff changeset
93 return "__object__";
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
94 else
29992
6ea4a84df9c7 rename QtHandles namespace to octave
John W. Eaton <jwe@octave.org>
parents: 29602
diff changeset
95 qCritical ("octave::qt_graphics_toolkit: no __object__ property known for object "
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
96 "of type %s", go.type ().c_str ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
98 return "";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
99 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
101 qt_graphics_toolkit::qt_graphics_toolkit (octave::interpreter& interp,
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
102 octave::base_qobject& oct_qobj)
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
103 : QObject (), base_graphics_toolkit ("qt"), m_interpreter (interp),
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
104 m_octave_qobj (oct_qobj)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
105 {
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
106 // Implemented with a signal/slot connection in order to properly
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
107 // cross from the interpreter thread (where requests to create
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
108 // graphics object are initiated) to the GUI application thread
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
109 // (where they are actually created and displayed).
28395
a379987a74b0 Make sure Objects and their proxy are initialized synchronously (bug #55225)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27935
diff changeset
110 // We need to make sure the GUI Object and its proxy are properly
a379987a74b0 Make sure Objects and their proxy are initialized synchronously (bug #55225)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27935
diff changeset
111 // created before the initialize method returns, so we use a
a379987a74b0 Make sure Objects and their proxy are initialized synchronously (bug #55225)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27935
diff changeset
112 // BlockingQueuedConnection. After the signal is emitted, the interpreter
a379987a74b0 Make sure Objects and their proxy are initialized synchronously (bug #55225)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27935
diff changeset
113 // thread is locked until the slot has returned.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
115 connect (this, &qt_graphics_toolkit::create_object_signal,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
116 this, &qt_graphics_toolkit::create_object,
28395
a379987a74b0 Make sure Objects and their proxy are initialized synchronously (bug #55225)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27935
diff changeset
117 Qt::BlockingQueuedConnection);
27316
22265a75be74 eliminate static instance of Qt graphics ObjectFactory class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
118 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
120 bool
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
121 qt_graphics_toolkit::initialize (const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
122 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
123 if (go.isa ("figure")
28474
4539c931734a Stop error when deleting uicontrol "frame" objects (bug #58544).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 28395
diff changeset
124 || (go.isa ("uicontrol") && go.get ("style").string_value () != "frame")
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
125 || go.isa ("uipanel")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
126 || go.isa ("uibuttongroup")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
127 || go.isa ("uimenu")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
128 || go.isa ("uicontextmenu")
26112
36e0e5b428e7 Implement uitable (patch #9084)
Andrew Thornton <art27@cantab.net>
parents: 25799
diff changeset
129 || go.isa ("uitable")
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
130 || go.isa ("uitoolbar")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
131 || go.isa ("uipushtool")
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
132 || go.isa ("uitoggletool"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
133 {
28474
4539c931734a Stop error when deleting uicontrol "frame" objects (bug #58544).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 28395
diff changeset
134 // FIXME: We need to unlock the mutex here but we have no way to know
26276
5535267e88ba Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26112
diff changeset
135 // if it was previously locked by this thread, and thus if we should
5535267e88ba Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26112
diff changeset
136 // re-lock it.
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
137
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
138 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
139
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
140 gh_mgr.unlock ();
26276
5535267e88ba Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26112
diff changeset
141
29602
767cda46e091 qt-graphics-toolkit.cc: Use correct format specifier for "void *" type.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29542
diff changeset
142 Logger::debug ("qt_graphics_toolkit::initialize %s from thread %p",
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
143 go.type ().c_str (), QThread::currentThreadId ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
145 ObjectProxy *proxy = new ObjectProxy ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
146 graphics_object gObj (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
148 OCTAVE_PTR_TYPE tmp (reinterpret_cast<OCTAVE_INTPTR_TYPE> (proxy));
23070
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
149 gObj.get_properties ().set (toolkitObjectProperty (go), tmp);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
151 emit create_object_signal (go.get_handle ().value ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
153 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
154 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
156 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
157 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
159 void
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
160 qt_graphics_toolkit::update (const graphics_object& go, int pId)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
161 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
162 // Rule out obvious properties we want to ignore.
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
163 if (pId == figure::properties::ID___PLOT_STREAM__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
164 || pId == uicontrol::properties::ID___OBJECT__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
165 || pId == uipanel::properties::ID___OBJECT__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
166 || pId == uibuttongroup::properties::ID___OBJECT__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
167 || pId == uimenu::properties::ID___OBJECT__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
168 || pId == uicontextmenu::properties::ID___OBJECT__
26112
36e0e5b428e7 Implement uitable (patch #9084)
Andrew Thornton <art27@cantab.net>
parents: 25799
diff changeset
169 || pId == uitable::properties::ID___OBJECT__
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
170 || pId == uitoolbar::properties::ID___OBJECT__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
171 || pId == uipushtool::properties::ID___OBJECT__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
172 || pId == uitoggletool::properties::ID___OBJECT__
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
173 || pId == base_properties::ID___MODIFIED__)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
174 return;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175
29602
767cda46e091 qt-graphics-toolkit.cc: Use correct format specifier for "void *" type.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29542
diff changeset
176 Logger::debug ("qt_graphics_toolkit::update %s(%d) from thread %p",
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
177 go.type ().c_str (), pId, QThread::currentThreadId ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
179 ObjectProxy *proxy = toolkitObjectProxy (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
181 if (proxy)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
182 {
31585
7d7e04fc21ba uitable: Avoid crash with Boolean values (bug #63388).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
183 if ((go.isa ("uicontrol")
7d7e04fc21ba uitable: Avoid crash with Boolean values (bug #63388).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
184 && pId == uicontrol::properties::ID_STYLE)
7d7e04fc21ba uitable: Avoid crash with Boolean values (bug #63388).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
185 || (go.isa ("uitable")
7d7e04fc21ba uitable: Avoid crash with Boolean values (bug #63388).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
186 && pId == uitable::properties::ID_DATA))
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
187 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
188 // Special case: we need to recreate the control widget
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
189 // associated with the octave graphics_object
31585
7d7e04fc21ba uitable: Avoid crash with Boolean values (bug #63388).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
190 // FIXME: For uitable, it would only be necessary to recreate
7d7e04fc21ba uitable: Avoid crash with Boolean values (bug #63388).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
191 // the table widget if the type of the displayed values changes
7d7e04fc21ba uitable: Avoid crash with Boolean values (bug #63388).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
192 // between Boolean and non-Boolean (bug #63388).
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
194 finalize (go);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
195 initialize (go);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
196 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
197 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
198 proxy->update (pId);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
199 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
200 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
202 void
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
203 qt_graphics_toolkit::finalize (const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
204 {
26276
5535267e88ba Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26112
diff changeset
205 // FIXME: We need to unlock the mutex here but we have no way to know if
5535267e88ba Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26112
diff changeset
206 // if it was previously locked by this thread, and thus if we should
5535267e88ba Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26112
diff changeset
207 // re-lock it.
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
208
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
209 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
210
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
211 gh_mgr.unlock ();
26276
5535267e88ba Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26112
diff changeset
212
29602
767cda46e091 qt-graphics-toolkit.cc: Use correct format specifier for "void *" type.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29542
diff changeset
213 Logger::debug ("qt_graphics_toolkit::finalize %s from thread %p",
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
214 go.type ().c_str (), QThread::currentThreadId ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
216 ObjectProxy *proxy = toolkitObjectProxy (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
218 if (proxy)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
219 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
220 proxy->finalize ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
221 delete proxy;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
223 graphics_object gObj (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
225 gObj.get_properties ().set (toolkitObjectProperty (go), Matrix ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
226 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
227 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
229 void
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
230 qt_graphics_toolkit::redraw_figure (const graphics_object& go) const
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
231 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
232 if (go.get_properties ().is_visible ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
233 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
234 ObjectProxy *proxy = toolkitObjectProxy (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
235
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
236 if (proxy)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
237 proxy->redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
238 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
239 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
240
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
241 void
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
242 qt_graphics_toolkit::show_figure (const graphics_object& go) const
25799
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
243 {
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
244 if (go.get_properties ().is_visible ())
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
245 {
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
246 ObjectProxy *proxy = toolkitObjectProxy (go);
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
247
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
248 if (proxy)
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
249 proxy->show ();
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
250 }
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
251 }
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
252
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
253 void
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
254 qt_graphics_toolkit::print_figure (const graphics_object& go,
27935
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
255 const std::string& term,
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
256 const std::string& file_cmd,
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
257 const std::string& /*debug_file*/) const
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
258 {
24687
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
259 ObjectProxy *proxy = toolkitObjectProxy (go);
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
260
24687
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
261 if (proxy)
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
262 proxy->print (QString::fromStdString (file_cmd),
8b935067a257 Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24534
diff changeset
263 QString::fromStdString (term));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
264 }
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
265
23535
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
266 uint8NDArray
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
267 qt_graphics_toolkit::get_pixels (const graphics_object& go) const
23535
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
268 {
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
269 uint8NDArray retval;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
270
24798
45470049a43f Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24687
diff changeset
271 if (go.isa ("figure"))
23535
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
272 {
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
273 ObjectProxy *proxy = toolkitObjectProxy (go);
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
274
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
275 if (proxy)
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
276 retval = proxy->get_pixels ();
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
277 }
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
278
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
279 return retval;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
280 }
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
281
27254
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
282 Matrix
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
283 qt_graphics_toolkit::get_text_extent (const graphics_object& go) const
27254
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
284 {
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
285 Matrix ext (1, 4, 0.0);
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
286
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
287 if (go.isa ("uicontrol"))
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
288 {
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
289 octave_value str = go.get ("string");
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
290 if (! str.isempty ())
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
291 {
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
292 const uicontrol::properties& up =
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
293 dynamic_cast<const uicontrol::properties&> (go.get_properties ());
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
294 Matrix bb = up.get_boundingbox (false);
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
295 QFont font = Utils::computeFont<uicontrol> (up, bb(3));
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
296 QFontMetrics fm (font);
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
297
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
298 QString s;
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
299 QSize sz;
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
300
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
301 if (str.is_string ())
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
302 {
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
303 s = QString::fromStdString (str.string_value ());
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
304 sz = fm.size (Qt::TextSingleLine, s);
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
305 ext(2) = sz.width ();
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
306 ext(3) = sz.height ();
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
307 }
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
308 else if (str.iscellstr ())
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
309 {
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
310 string_vector sv = str.string_vector_value ();
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
311 double wd = 0.0;
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
312 double hg = 0.0;
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
313 for (octave_idx_type ii = 0; ii < sv.numel (); ii++)
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
314 {
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
315 s = QString::fromStdString (sv(ii));
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
316 sz = fm.size (Qt::TextSingleLine, s);
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
317 wd = std::max (wd, static_cast<double> (sz.width ()));
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
318 hg = std::max (hg, static_cast<double> (sz.height ()));
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
319 }
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
320
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
321 ext(2) = wd;
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
322 // FIXME: Find a better way to determine the height of e.g.
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
323 // listbox uicontrol objects
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
324 ext(3) = hg * sv.numel ();
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
325 }
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
326 }
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
327 }
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
328
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
329 return ext;
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
330 }
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
331
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
332 Object *
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
333 qt_graphics_toolkit::toolkitObject (const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
334 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
335 ObjectProxy *proxy = toolkitObjectProxy (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
337 if (proxy)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
338 return proxy->object ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
339
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23577
diff changeset
340 return nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
341 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
342
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
343 ObjectProxy *
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
344 qt_graphics_toolkit::toolkitObjectProxy (const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
345 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
346 if (go)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
347 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
348 octave_value ov = go.get (toolkitObjectProperty (go));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
349
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23535
diff changeset
350 if (ov.is_defined () && ! ov.isempty ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
351 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
352 OCTAVE_INTPTR_TYPE ptr = ov.OCTAVE_PTR_SCALAR ().value ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
353
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
354 return reinterpret_cast<ObjectProxy *> (ptr);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
355 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
356 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
357
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23577
diff changeset
358 return nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
359 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
360
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
361 void
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
362 qt_graphics_toolkit::interpreter_event (const octave::fcn_callback& fcn)
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
363 {
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
364 octave::event_manager& evmgr = m_interpreter.get_event_manager ();
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
365
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
366 evmgr.post_event (fcn);
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
367 }
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
368
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
369 void
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
370 qt_graphics_toolkit::interpreter_event (const octave::meth_callback& meth)
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
371 {
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
372 octave::event_manager& evmgr = m_interpreter.get_event_manager ();
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
373
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
374 evmgr.post_event (meth);
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
375 }
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
376
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
377 void
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
378 qt_graphics_toolkit::create_object (double handle)
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
379 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
380 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
381
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
382 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
383
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
384 graphics_object go (gh_mgr.get_object (graphics_handle (handle)));
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
385
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
386 if (! go.valid_object ())
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
387 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
388 qWarning ("qt_graphics_toolkit::create_object: invalid object for handle %g",
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
389 handle);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
390 return;
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
391 }
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
392
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
393 if (go.get_properties ().is_beingdeleted ())
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
394 {
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
395 qWarning ("qt_graphics_toolkit::create_object: object is being deleted");
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
396 return;
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
397 }
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
398
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
399 ObjectProxy *proxy = qt_graphics_toolkit::toolkitObjectProxy (go);
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
400
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
401 if (! proxy)
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
402 {
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
403 qWarning ("qt_graphics_toolkit::create_object: no proxy for handle %g",
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
404 handle);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
405 return;
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
406 }
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
407
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
408 Logger::debug ("qt_graphics_toolkit::create_object: "
29602
767cda46e091 qt-graphics-toolkit.cc: Use correct format specifier for "void *" type.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29542
diff changeset
409 "create %s from thread %p",
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
410 go.type ().c_str (), QThread::currentThreadId ());
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
411
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
412 Object *obj = nullptr;
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
413
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
414 if (go.isa ("figure"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
415 obj = Figure::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
416 else if (go.isa ("uicontrol"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
417 {
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
418 uicontrol::properties& up =
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
419 Utils::properties<uicontrol> (go);
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
420
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
421 if (up.style_is ("pushbutton"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
422 obj = PushButtonControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
423 else if (up.style_is ("edit"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
424 obj = EditControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
425 else if (up.style_is ("checkbox"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
426 obj = CheckBoxControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
427 else if (up.style_is ("radiobutton"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
428 obj = RadioButtonControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
429 else if (up.style_is ("togglebutton"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
430 obj = ToggleButtonControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
431 else if (up.style_is ("text"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
432 obj = TextControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
433 else if (up.style_is ("popupmenu"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
434 obj = PopupMenuControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
435 else if (up.style_is ("slider"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
436 obj = SliderControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
437 else if (up.style_is ("listbox"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
438 obj = ListBoxControl::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
439 }
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
440 else if (go.isa ("uibuttongroup"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
441 obj = ButtonGroup::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
442 else if (go.isa ("uipanel"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
443 obj = Panel::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
444 else if (go.isa ("uimenu"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
445 obj = Menu::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
446 else if (go.isa ("uicontextmenu"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
447 obj = ContextMenu::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
448 else if (go.isa ("uitable"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
449 obj = Table::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
450 else if (go.isa ("uitoolbar"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
451 obj = ToolBar::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
452 else if (go.isa ("uipushtool"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
453 obj = PushTool::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
454 else if (go.isa ("uitoggletool"))
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
455 obj = ToggleTool::create (m_octave_qobj, m_interpreter, go);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
456 else
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
457 qWarning ("qt_graphics_toolkit::create_object: unsupported type '%s'",
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
458 go.type ().c_str ());
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
459
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
460 if (obj)
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
461 {
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
462 proxy->setObject (obj);
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
463 obj->do_connections (this);
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
464 }
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
465 }
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
466
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
467 void qt_graphics_toolkit::gh_callback_event (const graphics_handle& h,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
468 const std::string& nm)
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
469 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
470 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
471
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
472 gh_mgr.post_callback (h, nm);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
473 }
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
474
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
475 void qt_graphics_toolkit::gh_callback_event (const graphics_handle& h,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
476 const std::string& nm,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
477 const octave_value& data)
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
478 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
479 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
480
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
481 gh_mgr.post_callback (h, nm, data);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
482 }
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
483
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
484 void qt_graphics_toolkit::gh_set_event (const graphics_handle& h,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
485 const std::string& nm,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
486 const octave_value& value)
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
487 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
488 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
489
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
490 gh_mgr.post_set (h, nm, value);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
491 }
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
492
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
493 void qt_graphics_toolkit::gh_set_event (const graphics_handle& h,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
494 const std::string& nm,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
495 const octave_value& value,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
496 bool notify_toolkit)
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
497 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
498 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
499
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
500 gh_mgr.post_set (h, nm, value, notify_toolkit);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
501 }
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
502
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
503 void qt_graphics_toolkit::gh_set_event (const graphics_handle& h,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
504 const std::string& nm,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
505 const octave_value& value,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
506 bool notify_toolkit,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
507 bool redraw_figure)
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
508 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
509 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
510
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
511 gh_mgr.post_set (h, nm, value, notify_toolkit, redraw_figure);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
512 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
513 };