Mercurial > octave
annotate libgui/graphics/BaseControl.cc @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 6ea4a84df9c7 |
children | ca7d58406f82 c6d54dd31a7e |
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:
29992
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:
21301
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 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <QEvent> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QKeyEvent> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <QMouseEvent> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <QWidget> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "BaseControl.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "ContextMenu.h" |
18505
fb96b7f55242
rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents:
18501
diff
changeset
|
37 #include "QtHandlesUtils.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
39 #include "graphics.h" |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
40 #include "interpreter.h" |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
41 |
29992
6ea4a84df9c7
rename QtHandles namespace to octave
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
42 namespace octave |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
45 static void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
46 updatePalette (const uicontrol::properties& props, QWidget *w) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
47 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
48 QPalette p = w->palette (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
50 if (props.style_is ("edit") |
22616
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
51 || props.style_is ("listbox")) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
52 { |
28251
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
53 Matrix bg_color = props.get_backgroundcolor_rgb (); |
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
54 // Matlab compatibility: Default color is ignored, and rendered as |
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
55 // white ([1.0, 1.0, 1.0]). See bug #58261. |
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
56 if (bg_color(0) == bg_color(1) && bg_color(0) == bg_color(2) |
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
57 && (std::abs (bg_color(1) - 0.94) < .005)) |
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
58 bg_color.fill (1.0); |
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
59 |
28244
cba489221bab
Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128)
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
60 p.setColor (QPalette::Active, QPalette::Base, |
28251
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
61 Utils::fromRgb (bg_color)); |
28244
cba489221bab
Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128)
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
62 p.setColor (QPalette::Inactive, QPalette::Base, |
28251
be19ade4acc3
Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261).
Rik <rik@octave.org>
parents:
28249
diff
changeset
|
63 Utils::fromRgb (bg_color)); |
28244
cba489221bab
Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128)
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
64 p.setColor (QPalette::Active, QPalette::Text, |
cba489221bab
Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128)
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
65 Utils::fromRgb (props.get_foregroundcolor_rgb ())); |
cba489221bab
Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128)
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
66 p.setColor (QPalette::Inactive, QPalette::Text, |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
67 Utils::fromRgb (props.get_foregroundcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
68 } |
22616
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
69 else if (props.style_is ("popupmenu")) |
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
70 { |
28244
cba489221bab
Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128)
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
71 // popupmenu (QComboBox) is a listbox with a button. |
cba489221bab
Implement Enable property values "inactive" and "off" for uicontrol Edit (bug #57128)
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
72 // This requires setting colors for both. |
26337
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
73 QColor bcol = Utils::fromRgb (props.get_backgroundcolor_rgb ()); |
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
74 QColor fcol = Utils::fromRgb (props.get_foregroundcolor_rgb ()); |
28247
20794455ea11
Implement "gray" when uicontrol popupmenus are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28246
diff
changeset
|
75 QString qss = QString (":enabled { background: %1 none;\n" |
20794455ea11
Implement "gray" when uicontrol popupmenus are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28246
diff
changeset
|
76 "color: %2; }") |
26337
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
77 .arg(bcol.name ()).arg (fcol.name ()); |
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
78 w->setStyleSheet(qss); |
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
79 return; |
22616
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
80 } |
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
81 else if (props.style_is ("radiobutton") |
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
82 || props.style_is ("checkbox")) |
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
83 { |
28248
aee0f20c8029
Implement "gray" when uicontrol radiobutton/checkbox are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28247
diff
changeset
|
84 p.setColor (QPalette::Active, QPalette::Button, |
aee0f20c8029
Implement "gray" when uicontrol radiobutton/checkbox are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28247
diff
changeset
|
85 Utils::fromRgb (props.get_backgroundcolor_rgb ())); |
aee0f20c8029
Implement "gray" when uicontrol radiobutton/checkbox are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28247
diff
changeset
|
86 p.setColor (QPalette::Inactive, QPalette::Button, |
22616
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
87 Utils::fromRgb (props.get_backgroundcolor_rgb ())); |
28248
aee0f20c8029
Implement "gray" when uicontrol radiobutton/checkbox are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28247
diff
changeset
|
88 p.setColor (QPalette::Active, QPalette::WindowText, |
aee0f20c8029
Implement "gray" when uicontrol radiobutton/checkbox are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28247
diff
changeset
|
89 Utils::fromRgb (props.get_foregroundcolor_rgb ())); |
aee0f20c8029
Implement "gray" when uicontrol radiobutton/checkbox are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28247
diff
changeset
|
90 p.setColor (QPalette::Inactive, QPalette::WindowText, |
22616
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
91 Utils::fromRgb (props.get_foregroundcolor_rgb ())); |
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
92 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
93 else if (props.style_is ("pushbutton") |
22616
96411a33f570
gui: handle differences in text color for popmenu, checkbox and radiobutton (Bug #49247)
John Donoghue <john.donoghue@ieee.org>
parents:
22611
diff
changeset
|
94 || props.style_is ("togglebutton")) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
95 { |
26337
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
96 QColor bcol = Utils::fromRgb (props.get_backgroundcolor_rgb ()); |
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
97 QColor fcol = Utils::fromRgb (props.get_foregroundcolor_rgb ()); |
28245
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
98 QString qss = QString (":enabled { background: %1 none;\n" |
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
99 "color: %2; }") |
26337
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
100 .arg(bcol.name ()).arg (fcol.name ()); |
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
101 w->setStyleSheet(qss); |
5f321f799cb1
Use stylesheets for coloring pushbuttons and popupmenus (bug #49247).
Torsten <mttl@mailbox.org>
parents:
26037
diff
changeset
|
102 return; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
103 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
104 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
105 { |
28249
be4a6f33d142
Implement "gray" when uicontrol text/slider are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28248
diff
changeset
|
106 p.setColor (QPalette::Active, QPalette::Window, |
be4a6f33d142
Implement "gray" when uicontrol text/slider are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28248
diff
changeset
|
107 Utils::fromRgb (props.get_backgroundcolor_rgb ())); |
be4a6f33d142
Implement "gray" when uicontrol text/slider are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28248
diff
changeset
|
108 p.setColor (QPalette::Inactive, QPalette::Window, |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
109 Utils::fromRgb (props.get_backgroundcolor_rgb ())); |
28249
be4a6f33d142
Implement "gray" when uicontrol text/slider are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28248
diff
changeset
|
110 p.setColor (QPalette::Active, QPalette::WindowText, |
be4a6f33d142
Implement "gray" when uicontrol text/slider are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28248
diff
changeset
|
111 Utils::fromRgb (props.get_foregroundcolor_rgb ())); |
be4a6f33d142
Implement "gray" when uicontrol text/slider are disabled (bug #57128).
Rik <rik@octave.org>
parents:
28248
diff
changeset
|
112 p.setColor (QPalette::Inactive, QPalette::WindowText, |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
113 Utils::fromRgb (props.get_foregroundcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
114 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
116 w->setPalette (p); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
117 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
119 BaseControl::BaseControl (octave::base_qobject& oct_qobj, |
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
120 octave::interpreter& interp, |
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
121 const graphics_object& go, QWidget *w) |
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
122 : Object (oct_qobj, interp, go, w), m_normalizedFont (false), |
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
123 m_keyPressHandlerDefined (false) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
124 { |
26816
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
125 qObject ()->setObjectName ("UIControl"); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
126 init (w); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
127 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
129 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
130 BaseControl::init (QWidget *w, bool callBase) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
131 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
132 if (callBase) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
133 Object::init (w, callBase); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
135 uicontrol::properties& up = properties<uicontrol> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
137 Matrix bb = up.get_boundingbox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
138 w->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
139 octave::math::round (bb(2)), octave::math::round (bb(3))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
140 w->setFont (Utils::computeFont<uicontrol> (up, bb(3))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
141 updatePalette (up, w); |
28245
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
142 if (up.enable_is ("inactive")) |
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
143 w->blockSignals (true); |
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
144 else |
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
145 w->setEnabled (up.enable_is ("on")); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
146 w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
147 w->setVisible (up.is_visible ()); |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
148 m_keyPressHandlerDefined = ! up.get_keypressfcn ().isempty (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
150 w->installEventFilter (this); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
152 m_normalizedFont = up.fontunits_is ("normalized"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
153 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
155 BaseControl::~BaseControl (void) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22413
diff
changeset
|
156 { } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
158 void |
26816
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
159 BaseControl::redraw (void) |
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
160 { |
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
161 update (uicontrol::properties::ID_POSITION); |
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
162 } |
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
163 |
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
164 void |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
165 BaseControl::update (int pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
166 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
167 uicontrol::properties& up = properties<uicontrol> (); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
168 QWidget *w = qWidget<QWidget> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
170 switch (pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
171 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
172 case uicontrol::properties::ID_POSITION: |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
173 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
174 Matrix bb = up.get_boundingbox (false); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
175 w->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)), |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
176 octave::math::round (bb(2)), octave::math::round (bb(3))); |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
177 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
178 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
179 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
180 case uicontrol::properties::ID_FONTNAME: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
181 case uicontrol::properties::ID_FONTSIZE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
182 case uicontrol::properties::ID_FONTWEIGHT: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
183 case uicontrol::properties::ID_FONTANGLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
184 w->setFont (Utils::computeFont<uicontrol> (up)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
185 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
186 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
187 case uicontrol::properties::ID_FONTUNITS: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
188 // FIXME: We shouldn't have to do anything, octave should update |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
189 // the "fontsize" property automatically to the new units. |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
190 // Hence the actual font used shouldn't change. |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
191 m_normalizedFont = up.fontunits_is ("normalized"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
192 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
193 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
194 case uicontrol::properties::ID_BACKGROUNDCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
195 case uicontrol::properties::ID_FOREGROUNDCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
196 updatePalette (up, w); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
197 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
198 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
199 case uicontrol::properties::ID_ENABLE: |
28245
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
200 if (up.enable_is ("inactive")) |
28246
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
201 { |
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
202 w->blockSignals (true); |
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
203 w->setEnabled (true); |
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
204 } |
28245
46a23dc62056
Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128)
Rik <rik@octave.org>
parents:
28244
diff
changeset
|
205 else |
28246
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
206 { |
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
207 w->blockSignals (false); |
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
208 w->setEnabled (up.enable_is ("on")); |
c387a55aed05
Fix problem with uicontrol "Enable" transition from "off"->"inactive" (bug #57128).
Rik <rik@octave.org>
parents:
28245
diff
changeset
|
209 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
210 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
211 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
212 case uicontrol::properties::ID_TOOLTIPSTRING: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
213 w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
214 break; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
216 case base_properties::ID_VISIBLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
217 w->setVisible (up.is_visible ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
218 break; |
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 case uicontrol::properties::ID_KEYPRESSFCN: |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
221 m_keyPressHandlerDefined = ! up.get_keypressfcn ().isempty (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
222 break; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 |
26024
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
224 case uicontrol::properties::ID___FOCUS__: |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
225 if (up.is___focus__ ()) |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
226 w->setFocus (); |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
227 else |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
228 w->clearFocus (); |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
229 break; |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
230 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
231 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
232 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
233 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
234 } |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
235 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
236 bool |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
237 BaseControl::eventFilter (QObject *watched, QEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
238 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
239 gh_manager& gh_mgr = m_interpreter.get_gh_manager (); |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
240 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
241 switch (xevent->type ()) |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
242 { |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
243 case QEvent::Resize: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
244 if (m_normalizedFont) |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
245 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
246 octave::autolock guard (gh_mgr.graphics_lock ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
248 qWidget<QWidget> ()->setFont (Utils::computeFont<uicontrol> |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
249 (properties<uicontrol> ())); |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
250 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
251 break; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
253 case QEvent::MouseButtonPress: |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
254 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
255 octave::autolock guard (gh_mgr.graphics_lock ()); |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
256 |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
257 QMouseEvent *m = dynamic_cast<QMouseEvent *> (xevent); |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
258 graphics_object go = object (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
259 uicontrol::properties& up = Utils::properties<uicontrol> (go); |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19616
diff
changeset
|
260 graphics_object fig = go.get_ancestor ("figure"); |
25996
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
261 if (fig) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
262 { |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
263 emit gh_set_event (fig.get_handle (), "currentobject", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
264 m_handle.value (), false); |
26024
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
265 |
25996
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
266 if (m->button () != Qt::LeftButton || ! up.enable_is ("on")) |
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
267 { |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
268 emit gh_set_event (fig.get_handle (), "selectiontype", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
269 Utils::figureSelectionType (m), false); |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
270 emit gh_set_event (fig.get_handle (), "currentpoint", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
271 Utils::figureCurrentPoint (fig, m), |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
272 false); |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
273 emit gh_callback_event (fig.get_handle (), |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
274 "windowbuttondownfcn"); |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
275 emit gh_callback_event (m_handle, "buttondownfcn"); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
276 |
25996
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
277 if (m->button () == Qt::RightButton) |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
278 ContextMenu::executeAt (m_interpreter, up, m->globalPos ()); |
25996
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
279 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
280 else |
25996
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
281 { |
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
282 if (up.style_is ("listbox")) |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
283 emit gh_set_event (fig.get_handle (), "selectiontype", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
284 Utils::figureSelectionType (m), |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
285 false); |
25996
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
286 else |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
287 emit gh_set_event (fig.get_handle (), "selectiontype", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
288 octave_value ("normal"), false); |
25996
37743ef71734
Let uicontrol objects become the figure currentobject when clicked (bug #44672)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25921
diff
changeset
|
289 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
290 } |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
291 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
292 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
293 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
294 case QEvent::MouseMove: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
295 if (qWidget<QWidget> ()->hasMouseTracking ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
296 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
297 octave::autolock guard (gh_mgr.graphics_lock ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
299 QMouseEvent *m = dynamic_cast<QMouseEvent *> (xevent); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
300 graphics_object go = object (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
301 graphics_object fig = go.get_ancestor ("figure"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
302 |
25921
9c47eedc44e2
msgbox.m: use graphics objects to build dialog (bug #42490)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25054
diff
changeset
|
303 if (fig) |
9c47eedc44e2
msgbox.m: use graphics objects to build dialog (bug #42490)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25054
diff
changeset
|
304 { |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
305 emit gh_set_event (fig.get_handle (), "currentpoint", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
306 Utils::figureCurrentPoint (fig, m), false); |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
307 emit gh_callback_event (fig.get_handle (), |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
308 "windowbuttonmotionfcn"); |
25921
9c47eedc44e2
msgbox.m: use graphics objects to build dialog (bug #42490)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25054
diff
changeset
|
309 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
310 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
311 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
312 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
313 case QEvent::KeyPress: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
314 if (m_keyPressHandlerDefined) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
315 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
316 octave::autolock guard (gh_mgr.graphics_lock ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
318 octave_scalar_map keyData = |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
319 Utils::makeKeyEventStruct (dynamic_cast<QKeyEvent *> (xevent)); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
320 graphics_object fig = object ().get_ancestor ("figure"); |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
321 |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
322 emit gh_set_event (fig.get_handle (), "currentcharacter", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
323 keyData.getfield ("Character"), false); |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
324 emit gh_callback_event (m_handle, "keypressfcn", keyData); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
325 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
326 break; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 |
26024
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
328 case QEvent::FocusIn: |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
329 emit gh_set_event (m_handle, "__focus__", "on", false); |
26024
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
330 break; |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
331 |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
332 case QEvent::FocusOut: |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
333 emit gh_set_event (m_handle, "__focus__", "off", false); |
26024
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
334 break; |
80c8062e855a
Allow uicontrol focus to be set from the interpreter (bug #54942)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25996
diff
changeset
|
335 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
336 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
337 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
338 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
339 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
340 return Object::eventFilter (watched, xevent); |
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 |
22413
8758addcf265
maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
343 } |