Mercurial > octave
annotate libgui/graphics/qt-graphics-toolkit.cc @ 27318:ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
* __init_qt__.cc (__init__): Move qt_graphics_toolkit object to GUI
application thread.
* qt-graphics-toolkit.h, qt-graphics-toolkit.cc
(qt_graphics_toolkit::m_factory): Delete data member and all use.
(qt_graphics_toolkit::create_object_signal): Rename from createObject.
Eliminate pointer to qt_graphics_toolkit argument.
(qt_graphics_toolkit::create_object): New slot, adapted from
ObjectFactory::createObject slot.
* ObjectFactory.h, ObjectFactory.cc: Delete.
* libgui/graphics/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Aug 2019 14:28:48 -0500 |
parents | 718116e9c7d3 |
children | 6b2d20317b26 |
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 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26276
diff
changeset
|
3 Copyright (C) 2011-2019 Michael Goffioul |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
5 This file is part of Octave. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23829
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23829
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
10 (at your option) any later version. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
15 GNU General Public License for more details. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23829
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21699
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
21912
d92dcbcd7691
prefer C++ wrappers for C standard headers in C++ code
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
27 #include <cstdint> |
d92dcbcd7691
prefer C++ wrappers for C standard headers in C++ code
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
28 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #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
|
30 #include <QFontMetrics> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QThread> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
33 #include "ButtonGroup.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
34 #include "CheckBoxControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
35 #include "ContextMenu.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
36 #include "EditControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
37 #include "Figure.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
38 #include "ListBoxControl.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "Logger.h" |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
40 #include "Menu.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "Object.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "ObjectProxy.h" |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
43 #include "Panel.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
44 #include "PopupMenuControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
45 #include "PushButtonControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
46 #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
|
47 #include "QtHandlesUtils.h" |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
48 #include "RadioButtonControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
49 #include "SliderControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
50 #include "Table.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
51 #include "TextControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
52 #include "ToggleButtonControl.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
53 #include "ToggleTool.h" |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
54 #include "ToolBar.h" |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
55 #include "qt-graphics-toolkit.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 |
27303
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27254
diff
changeset
|
57 #include "event-manager.h" |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
58 #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
|
59 #include "interpreter.h" |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27254
diff
changeset
|
60 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 //#if INTPTR_MAX == INT32_MAX |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 //# define OCTAVE_PTR_TYPE octave_uint32 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 //# define OCTAVE_INTPTR_TYPE uint32_t |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 //# define OCTAVE_PTR_SCALAR uint32_scalar_value |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 //#else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 # define OCTAVE_PTR_TYPE octave_uint64 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 # define OCTAVE_INTPTR_TYPE uint64_t |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 # define OCTAVE_PTR_SCALAR uint64_scalar_value |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 //#endif |
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 namespace QtHandles |
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 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
74 static std::string |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
75 toolkitObjectProperty (const graphics_object& go) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
76 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
77 if (go.isa ("figure")) |
23829
01899bdd2a3a
Eliminate unnecessary std::string ("...") constructor calls when "..." suffices.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
78 return "__plot_stream__"; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
79 else if (go.isa ("uicontrol") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
80 || go.isa ("uipanel") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
81 || go.isa ("uibuttongroup") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
82 || go.isa ("uimenu") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
83 || go.isa ("uicontextmenu") |
26112
36e0e5b428e7
Implement uitable (patch #9084)
Andrew Thornton <art27@cantab.net>
parents:
25799
diff
changeset
|
84 || go.isa ("uitable") |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
85 || go.isa ("uitoolbar") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
86 || go.isa ("uipushtool") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
87 || go.isa ("uitoggletool")) |
23829
01899bdd2a3a
Eliminate unnecessary std::string ("...") constructor calls when "..." suffices.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
88 return "__object__"; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
89 else |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
90 qCritical ("QtHandles::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
|
91 "of type %s", go.type ().c_str ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
93 return ""; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
94 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
96 qt_graphics_toolkit::qt_graphics_toolkit (octave::interpreter& interp) |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
97 : QObject (), base_graphics_toolkit ("qt"), m_interpreter (interp) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
98 { |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
99 // 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
|
100 // 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
|
101 // 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
|
102 // (where they are actually created and displayed). |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
104 connect (this, SIGNAL (create_object_signal (double)), |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
105 this, SLOT (create_object (double))); |
27316
22265a75be74
eliminate static instance of Qt graphics ObjectFactory class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
106 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
108 bool |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
109 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
|
110 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
111 if (go.isa ("figure") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
112 || go.isa ("uicontrol") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
113 || go.isa ("uipanel") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
114 || go.isa ("uibuttongroup") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
115 || go.isa ("uimenu") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
116 || go.isa ("uicontextmenu") |
26112
36e0e5b428e7
Implement uitable (patch #9084)
Andrew Thornton <art27@cantab.net>
parents:
25799
diff
changeset
|
117 || go.isa ("uitable") |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
118 || go.isa ("uitoolbar") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
119 || go.isa ("uipushtool") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
120 || go.isa ("uitoggletool")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
121 { |
26276
5535267e88ba
Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26112
diff
changeset
|
122 // 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
|
123 // 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
|
124 // re-lock it. |
5535267e88ba
Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26112
diff
changeset
|
125 gh_manager::unlock (); |
5535267e88ba
Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26112
diff
changeset
|
126 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
127 Logger::debug ("qt_graphics_toolkit::initialize %s from thread %08x", |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
128 go.type ().c_str (), QThread::currentThreadId ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
130 ObjectProxy *proxy = new ObjectProxy (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
131 graphics_object gObj (go); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
133 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
|
134 gObj.get_properties ().set (toolkitObjectProperty (go), tmp); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
136 emit create_object_signal (go.get_handle ().value ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
138 return true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
139 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
141 return false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
142 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
144 void |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
145 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
|
146 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
147 // Rule out obvious properties we want to ignore. |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
148 if (pId == figure::properties::ID___PLOT_STREAM__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
149 || pId == uicontrol::properties::ID___OBJECT__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
150 || pId == uipanel::properties::ID___OBJECT__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
151 || pId == uibuttongroup::properties::ID___OBJECT__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
152 || pId == uimenu::properties::ID___OBJECT__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
153 || pId == uicontextmenu::properties::ID___OBJECT__ |
26112
36e0e5b428e7
Implement uitable (patch #9084)
Andrew Thornton <art27@cantab.net>
parents:
25799
diff
changeset
|
154 || pId == uitable::properties::ID___OBJECT__ |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
155 || pId == uitoolbar::properties::ID___OBJECT__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
156 || pId == uipushtool::properties::ID___OBJECT__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
157 || pId == uitoggletool::properties::ID___OBJECT__ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
158 || pId == base_properties::ID___MODIFIED__) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
159 return; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
161 Logger::debug ("qt_graphics_toolkit::update %s(%d) from thread %08x", |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
162 go.type ().c_str (), pId, QThread::currentThreadId ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
164 ObjectProxy *proxy = toolkitObjectProxy (go); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
166 if (proxy) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
167 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
168 if (go.isa ("uicontrol") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
169 && pId == uicontrol::properties::ID_STYLE) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
170 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
171 // 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
|
172 // associated with the octave graphics_object |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
174 finalize (go); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
175 initialize (go); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
176 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
177 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
178 proxy->update (pId); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
179 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
180 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
182 void |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
183 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
|
184 { |
26276
5535267e88ba
Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26112
diff
changeset
|
185 // 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
|
186 // 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
|
187 // re-lock it. |
5535267e88ba
Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26112
diff
changeset
|
188 gh_manager::unlock (); |
5535267e88ba
Make creation and destruction of Qt widgets synchronous (bug #55526)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26112
diff
changeset
|
189 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
190 Logger::debug ("qt_graphics_toolkit::finalize %s from thread %08x", |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
191 go.type ().c_str (), QThread::currentThreadId ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
193 ObjectProxy *proxy = toolkitObjectProxy (go); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
195 if (proxy) |
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 proxy->finalize (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
198 delete proxy; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
200 graphics_object gObj (go); |
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 gObj.get_properties ().set (toolkitObjectProperty (go), Matrix ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
203 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
204 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
206 void |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
207 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
|
208 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
209 if (go.get_properties ().is_visible ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
210 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
211 ObjectProxy *proxy = toolkitObjectProxy (go); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
213 if (proxy) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
214 proxy->redraw (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
215 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
216 } |
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 void |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
219 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
|
220 { |
d04b74f5d02e
make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
221 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
|
222 { |
d04b74f5d02e
make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
223 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
|
224 |
d04b74f5d02e
make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
225 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
|
226 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
|
227 } |
d04b74f5d02e
make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
228 } |
d04b74f5d02e
make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
229 |
d04b74f5d02e
make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
230 void |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
231 qt_graphics_toolkit::print_figure (const graphics_object& go, |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
232 const std::string& term, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
233 const std::string& file_cmd, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
234 const std::string& /*debug_file*/) const |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
235 { |
24687
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
236 ObjectProxy *proxy = toolkitObjectProxy (go); |
19681
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
237 |
24687
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
238 if (proxy) |
8b935067a257
Allow printing without updating qt visible or invisible figures (bug #52940).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
239 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
|
240 QString::fromStdString (term)); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
241 } |
19681
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
242 |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
243 uint8NDArray |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
244 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
|
245 { |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
246 uint8NDArray retval; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
247 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24687
diff
changeset
|
248 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
|
249 { |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
250 ObjectProxy *proxy = toolkitObjectProxy (go); |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
251 |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
252 if (proxy) |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
253 retval = proxy->get_pixels (); |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
254 } |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
255 |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
256 return retval; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
257 } |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
258 |
27254
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
259 Matrix |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
260 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
|
261 { |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
262 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
|
263 |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
264 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
|
265 { |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
266 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
|
267 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
|
268 { |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
269 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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
275 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
|
276 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
|
277 |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
278 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
|
279 { |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
280 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
|
281 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
|
282 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
|
283 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
|
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 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
|
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 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
|
288 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
|
289 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
|
290 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
|
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 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
|
293 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
|
294 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
|
295 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
|
296 } |
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 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
|
299 // 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
|
300 // 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
|
301 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
|
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 } |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
304 } |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
305 |
e3d886685813
Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
306 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
|
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 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
309 Object* |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
310 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
|
311 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
312 ObjectProxy *proxy = toolkitObjectProxy (go); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
314 if (proxy) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
315 return proxy->object (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
317 return nullptr; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
318 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
320 ObjectProxy* |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
321 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
|
322 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
323 if (go) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
324 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
325 octave_value ov = go.get (toolkitObjectProperty (go)); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23535
diff
changeset
|
327 if (ov.is_defined () && ! ov.isempty ()) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
328 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
329 OCTAVE_INTPTR_TYPE ptr = ov.OCTAVE_PTR_SCALAR ().value (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
331 return reinterpret_cast<ObjectProxy *> (ptr); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
332 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
333 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
335 return nullptr; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
336 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
338 void |
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
339 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
|
340 { |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27254
diff
changeset
|
341 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
|
342 |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27254
diff
changeset
|
343 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
|
344 } |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27254
diff
changeset
|
345 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
346 void |
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27316
diff
changeset
|
347 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
|
348 { |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27254
diff
changeset
|
349 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
|
350 |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27254
diff
changeset
|
351 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
|
352 } |
27318
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
353 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
354 void |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
355 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
|
356 { |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
357 gh_manager::auto_lock lock; |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
358 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
359 graphics_object go (gh_manager::get_object (graphics_handle (handle))); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
360 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
361 if (go.valid_object ()) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
362 { |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
363 if (go.get_properties ().is_beingdeleted ()) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
364 qWarning ("qt_graphics_toolkit::create_object: object is being deleted"); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
365 else |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
366 { |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
367 ObjectProxy *proxy = qt_graphics_toolkit::toolkitObjectProxy (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
368 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
369 if (proxy) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
370 { |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
371 Logger::debug ("qt_graphics_toolkit::create_object: " |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
372 "create %s from thread %08x", |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
373 go.type ().c_str (), QThread::currentThreadId ()); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
374 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
375 Object *obj = nullptr; |
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 if (go.isa ("figure")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
378 obj = Figure::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
379 else if (go.isa ("uicontrol")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
380 { |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
381 uicontrol::properties& up = |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
382 Utils::properties<uicontrol> (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
383 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
384 if (up.style_is ("pushbutton")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
385 obj = PushButtonControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
386 else if (up.style_is ("edit")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
387 obj = EditControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
388 else if (up.style_is ("checkbox")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
389 obj = CheckBoxControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
390 else if (up.style_is ("radiobutton")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
391 obj = RadioButtonControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
392 else if (up.style_is ("togglebutton")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
393 obj = ToggleButtonControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
394 else if (up.style_is ("text")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
395 obj = TextControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
396 else if (up.style_is ("popupmenu")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
397 obj = PopupMenuControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
398 else if (up.style_is ("slider")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
399 obj = SliderControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
400 else if (up.style_is ("listbox")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
401 obj = ListBoxControl::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
402 } |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
403 else if (go.isa ("uibuttongroup")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
404 obj = ButtonGroup::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
405 else if (go.isa ("uipanel")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
406 obj = Panel::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
407 else if (go.isa ("uimenu")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
408 obj = Menu::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
409 else if (go.isa ("uicontextmenu")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
410 obj = ContextMenu::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
411 else if (go.isa ("uitable")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
412 obj = Table::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
413 else if (go.isa ("uitoolbar")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
414 obj = ToolBar::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
415 else if (go.isa ("uipushtool")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
416 obj = PushTool::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
417 else if (go.isa ("uitoggletool")) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
418 obj = ToggleTool::create (go); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
419 else |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
420 qWarning ("qt_graphics_toolkit::create_object: unsupported type '%s'", |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
421 go.type ().c_str ()); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
422 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
423 if (obj) |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
424 { |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
425 proxy->setObject (obj); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
426 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
427 connect (obj, |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
428 SIGNAL (interpreter_event (const octave::fcn_callback&)), |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
429 this, |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
430 SLOT (interpreter_event (const octave::fcn_callback&))); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
431 |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
432 connect (obj, |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
433 SIGNAL (interpreter_event (const octave::meth_callback&)), |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
434 this, |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
435 SLOT (interpreter_event (const octave::meth_callback&))); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
436 } |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
437 } |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
438 else |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
439 qWarning ("qt_graphics_toolkit::create_object: no proxy for handle %g", |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
440 handle); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
441 } |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
442 } |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
443 else |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
444 qWarning ("qt_graphics_toolkit::create_object: invalid object for handle %g", |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
445 handle); |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
446 } |
ae53e56e16f2
eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
447 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 }; |