Mercurial > octave
annotate libgui/graphics/ButtonGroup.cc @ 29542:3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
This changes switches most code in the libgui/src and libgui/graphics
directories to use the new Qt style of connecting signals and slots
that uses pointers to member functions or function objects instead of
strings to refer to the signal and slot functions. For an
introduction, see https://wiki.qt.io/New_Signal_Slot_Syntax.
There are many connections left to adapt. In some cases, there are
overloaded functions (or default parameters) that need to be handled.
Use of QOverload<> or an anonymous function should fix these. In
others, we are connecting to parent objects where we only have a
pointer to QWidget instead of a specific type of object. To fix
those, we need to either move the code that makes th connection to a
place where the actual types of both objects are known or pass more
specific types as the parent object. In a few cases, there appear to
real mismatches in the types of objects and the signal/slot
functions.
Files affected: ButtonControl.cc, ButtonGroup.cc, ContextMenu.cc,
EditControl.cc, Figure.cc, ListBoxControl.cc, Menu.cc, Object.cc,
ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushTool.cc,
SliderControl.cc, Table.cc, ToggleTool.cc, ToolBar.cc,
annotation-dialog.cc, qt-graphics-toolkit.cc, color-picker.cc,
command-widget.cc, dialog.cc, documentation-bookmarks.cc,
documentation.cc, files-dock-widget.cc, find-files-dialog.cc,
history-dock-widget.cc, interpreter-qobject.cc, file-editor-tab.cc,
file-editor-tab.h, file-editor.cc, find-dialog.cc,
octave-qscintilla.cc, main-window.cc, octave-dock-widget.cc,
octave-qobject.cc, qt-interpreter-events.cc, set-path-dialog.cc,
set-path-model.cc, settings-dialog.cc, shortcut-manager.cc,
tab-bar.cc, variable-editor-model.cc, variable-editor.cc,
welcome-wizard.cc, welcome-wizard.h, workspace-view.cc, and
workspace-view.h.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 16 Apr 2021 23:06:32 -0400 |
parents | 7854d5752dd2 |
children | 5b7e721844df |
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 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 // Copyright (C) 2016-2021 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 //////////////////////////////////////////////////////////////////////// |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
25 |
22188 | 26 #if defined (HAVE_CONFIG_H) |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
27 # include "config.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
28 #endif |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
29 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
30 #include <QAbstractButton> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
31 #include <QButtonGroup> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
32 #include <QEvent> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
33 #include <QFrame> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
34 #include <QLabel> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
35 #include <QMouseEvent> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
36 #include <QRadioButton> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
37 #include <QTimer> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
38 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
39 #include "Canvas.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
40 #include "Container.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
41 #include "ContextMenu.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
42 #include "ButtonGroup.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
43 #include "ToggleButtonControl.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
44 #include "RadioButtonControl.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
45 #include "QtHandlesUtils.h" |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
46 #include "qt-graphics-toolkit.h" |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
47 |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
48 #include "octave-qobject.h" |
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
49 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
50 #include "interpreter.h" |
29223
5aa787452544
Use Octave map instead of octave_struct in gui graphics (patch #8919).
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
51 #include "oct-map.h" |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
52 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
53 namespace QtHandles |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
54 { |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
55 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
56 static int |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
57 frameStyleFromProperties (const uibuttongroup::properties& pp) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
58 { |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
59 if (pp.bordertype_is ("none")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
60 return QFrame::NoFrame; |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
61 else if (pp.bordertype_is ("etchedin")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
62 return (QFrame::Box | QFrame::Sunken); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
63 else if (pp.bordertype_is ("etchedout")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
64 return (QFrame::Box | QFrame::Raised); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
65 else if (pp.bordertype_is ("beveledin")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
66 return (QFrame::Panel | QFrame::Sunken); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
67 else if (pp.bordertype_is ("beveledout")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
68 return (QFrame::Panel | QFrame::Raised); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
69 else |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
70 return (QFrame::Panel | QFrame::Plain); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
71 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
72 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
73 static void |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23223
diff
changeset
|
74 setupPalette (const uibuttongroup::properties& pp, QPalette& p) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
75 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
76 p.setColor (QPalette::Window, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
77 Utils::fromRgb (pp.get_backgroundcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
78 p.setColor (QPalette::WindowText, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
79 Utils::fromRgb (pp.get_foregroundcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
80 p.setColor (QPalette::Light, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
81 Utils::fromRgb (pp.get_highlightcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
82 p.setColor (QPalette::Dark, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
83 Utils::fromRgb (pp.get_shadowcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
84 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
85 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
86 static int |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
87 borderWidthFromProperties (const uibuttongroup::properties& pp) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
88 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
89 int bw = 0; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
90 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
91 if (! pp.bordertype_is ("none")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
92 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
93 bw = octave::math::round (pp.get_borderwidth ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
94 if (pp.bordertype_is ("etchedin") || pp.bordertype_is ("etchedout")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
95 bw *= 2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
96 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
97 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
98 return bw; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
99 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
100 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
101 ButtonGroup* |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
102 ButtonGroup::create (octave::base_qobject& oct_qobj, |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
103 octave::interpreter& interp, const graphics_object& go) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
104 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
105 Object *parent = parentObject (interp, go); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
106 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
107 if (parent) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
108 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
109 Container *container = parent->innerContainer (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
110 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
111 if (container) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
112 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
113 QFrame *frame = new QFrame (container); |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
114 return new ButtonGroup (oct_qobj, interp, go, |
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
115 new QButtonGroup (frame), frame); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
116 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
117 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
118 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
119 return nullptr; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
120 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
121 |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
122 ButtonGroup::ButtonGroup (octave::base_qobject& oct_qobj, |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
123 octave::interpreter& interp, |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
124 const graphics_object& go, |
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
125 QButtonGroup *buttongroup, QFrame *frame) |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
126 : Object (oct_qobj, interp, go, frame), m_hiddenbutton (nullptr), |
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
127 m_container (nullptr), m_title (nullptr), m_blockUpdates (false) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
128 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
129 uibuttongroup::properties& pp = properties<uibuttongroup> (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
130 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
131 frame->setObjectName ("UIButtonGroup"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
132 frame->setAutoFillBackground (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
133 Matrix bb = pp.get_boundingbox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
134 frame->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
135 octave::math::round (bb(2)), octave::math::round (bb(3))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
136 frame->setFrameStyle (frameStyleFromProperties (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
137 frame->setLineWidth (octave::math::round (pp.get_borderwidth ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
138 QPalette pal = frame->palette (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
139 setupPalette (pp, pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
140 frame->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
141 m_buttongroup = buttongroup; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
142 m_hiddenbutton = new QRadioButton (frame); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
143 m_hiddenbutton->hide (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
144 m_buttongroup->addButton (m_hiddenbutton); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
145 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
146 m_container = new Container (frame, oct_qobj, interp); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
147 m_container->canvas (m_handle); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
148 |
27303
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
149 connect (m_container, SIGNAL (interpeter_event (const fcn_callback&)), |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
150 this, SIGNAL (interpeter_event (const fcn_callback&))); |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
151 |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
152 connect (m_container, SIGNAL (interpeter_event (const meth_callback&)), |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
153 this, SIGNAL (interpeter_event (const meth_callback&))); |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
154 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
155 if (frame->hasMouseTracking ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
156 { |
27677
92fea2cd024f
use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents:
27647
diff
changeset
|
157 for (auto *w : frame->findChildren<QWidget*> ()) |
23223
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
158 w->setMouseTracking (true); |
27677
92fea2cd024f
use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents:
27647
diff
changeset
|
159 for (auto *w : buttongroup->findChildren<QWidget*> ()) |
23223
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
160 w->setMouseTracking (true); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
161 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
162 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
163 QString title = Utils::fromStdString (pp.get_title ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
164 if (! title.isEmpty ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
165 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
166 m_title = new QLabel (title, frame); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
167 m_title->setAutoFillBackground (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
168 m_title->setContentsMargins (4, 0, 4, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
169 m_title->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
170 m_title->setFont (Utils::computeFont<uibuttongroup> (pp, bb(3))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
171 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
172 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
173 frame->installEventFilter (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
174 m_container->installEventFilter (this); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
175 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
176 if (pp.is_visible ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
177 { |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
178 QTimer::singleShot (0, frame, &QFrame::show); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
179 // FIXME: What is the intent here? QButtonGroup::show is not a |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
180 // member of QButtonGroup. |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
181 QTimer::singleShot (0, buttongroup, SLOT (show (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
182 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
183 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
184 frame->hide (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
185 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
186 connect (m_buttongroup, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
187 QOverload<QAbstractButton *>::of (&QButtonGroup::buttonClicked), |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
188 this, &ButtonGroup::buttonClicked); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
189 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
190 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
191 ButtonGroup::~ButtonGroup (void) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
192 { } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
193 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
194 bool |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
195 ButtonGroup::eventFilter (QObject *watched, QEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
196 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
197 if (! m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
198 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
199 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
|
200 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
201 if (watched == qObject ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
202 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
203 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
204 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
205 case QEvent::Resize: |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
206 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
207 octave::autolock guard (gh_mgr.graphics_lock ()); |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
208 |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
209 graphics_object go = object (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
210 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
211 if (go.valid_object ()) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
212 { |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
213 if (m_title) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
214 { |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
215 const uibuttongroup::properties& pp = |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
216 Utils::properties<uibuttongroup> (go); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
217 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
218 if (pp.fontunits_is ("normalized")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
219 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
220 QFrame *frame = qWidget<QFrame> (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
221 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
222 m_title->setFont (Utils::computeFont<uibuttongroup> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
223 (pp, frame->height ())); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
224 m_title->resize (m_title->sizeHint ()); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
225 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
226 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
227 updateLayout (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
228 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
229 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
230 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
231 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
232 case QEvent::MouseButtonPress: |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
233 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
234 QMouseEvent *m = dynamic_cast<QMouseEvent *> (xevent); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
235 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
236 if (m->button () == Qt::RightButton) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
237 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
238 octave::autolock guard (gh_mgr.graphics_lock ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
239 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
240 ContextMenu::executeAt (m_interpreter, properties (), |
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
241 m->globalPos ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
242 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
243 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
244 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
245 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
246 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
247 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
248 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
249 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
250 else if (watched == m_container) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
251 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
252 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
253 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
254 case QEvent::Resize: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
255 if (qWidget<QWidget> ()->isVisible ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
256 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
257 octave::autolock guard (gh_mgr.graphics_lock ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
258 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
259 properties ().update_boundingbox (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
260 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
261 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
262 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
263 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
264 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
265 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
266 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
267 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
268 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
269 return false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
270 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
271 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
272 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
273 ButtonGroup::update (int pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
274 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
275 uibuttongroup::properties& pp = properties<uibuttongroup> (); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
276 QFrame *frame = qWidget<QFrame> (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
277 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
278 m_blockUpdates = true; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
279 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
280 switch (pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
281 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
282 case uibuttongroup::properties::ID_POSITION: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
283 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
284 Matrix bb = pp.get_boundingbox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
285 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
286 frame->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
287 octave::math::round (bb(2)), octave::math::round (bb(3))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
288 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
289 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
290 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
291 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
292 case uibuttongroup::properties::ID_BORDERWIDTH: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
293 frame->setLineWidth (octave::math::round (pp.get_borderwidth ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
294 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
295 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
296 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
297 case uibuttongroup::properties::ID_BACKGROUNDCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
298 case uibuttongroup::properties::ID_FOREGROUNDCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
299 case uibuttongroup::properties::ID_HIGHLIGHTCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
300 case uibuttongroup::properties::ID_SHADOWCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
301 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
302 QPalette pal = frame->palette (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
303 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
304 setupPalette (pp, pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
305 frame->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
306 if (m_title) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
307 m_title->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
308 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
309 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
310 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
311 case uibuttongroup::properties::ID_TITLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
312 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
313 QString title = Utils::fromStdString (pp.get_title ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
314 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
315 if (title.isEmpty ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
316 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
317 if (m_title) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
318 delete m_title; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
319 m_title = nullptr; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
320 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
321 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
322 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
323 if (! m_title) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
324 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
325 QPalette pal = frame->palette (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
326 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
327 m_title = new QLabel (title, frame); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
328 m_title->setAutoFillBackground (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
329 m_title->setContentsMargins (4, 0, 4, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
330 m_title->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
331 m_title->setFont (Utils::computeFont<uibuttongroup> (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
332 m_title->show (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
333 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
334 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
335 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
336 m_title->setText (title); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
337 m_title->resize (m_title->sizeHint ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
338 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
339 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
340 updateLayout (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
341 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
342 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
343 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
344 case uibuttongroup::properties::ID_TITLEPOSITION: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
345 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
346 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
347 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
348 case uibuttongroup::properties::ID_BORDERTYPE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
349 frame->setFrameStyle (frameStyleFromProperties (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
350 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
351 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
352 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
353 case uibuttongroup::properties::ID_FONTNAME: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
354 case uibuttongroup::properties::ID_FONTSIZE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
355 case uibuttongroup::properties::ID_FONTWEIGHT: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
356 case uibuttongroup::properties::ID_FONTANGLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
357 if (m_title) |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
358 { |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
359 m_title->setFont (Utils::computeFont<uibuttongroup> (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
360 m_title->resize (m_title->sizeHint ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
361 updateLayout (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
362 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
363 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
364 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
365 case uibuttongroup::properties::ID_VISIBLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
366 frame->setVisible (pp.is_visible ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
367 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
368 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
369 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
370 case uibuttongroup::properties::ID_SELECTEDOBJECT: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
371 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
372 graphics_handle h = pp.get_selectedobject (); |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
373 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
374 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
|
375 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
376 octave::autolock guard (gh_mgr.graphics_lock ()); |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
377 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
378 graphics_object go = gh_mgr.get_object (h); |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
379 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
380 Object *selectedObject = qt_graphics_toolkit::toolkitObject (go); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
381 ToggleButtonControl *toggle = static_cast<ToggleButtonControl *> |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
382 (selectedObject); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
383 RadioButtonControl *radio = static_cast<RadioButtonControl *>(selectedObject); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
384 if (toggle) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
385 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
386 go.get_properties ().set ("value", 1); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
387 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
388 else if (radio) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
389 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
390 go.get_properties ().set ("value", 1); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
391 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
392 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
393 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
394 m_hiddenbutton->setChecked (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
395 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
396 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
397 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
398 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
399 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
400 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
401 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
402 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
403 m_blockUpdates = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
404 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
405 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
406 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
407 ButtonGroup::redraw (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
408 { |
26816
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
409 update (uibuttongroup::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
|
410 |
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
411 // FIXME: is it really necessary to update the opengl canvas here? |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
412 Canvas *canvas = m_container->canvas (m_handle); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
413 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
414 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
415 canvas->redraw (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
416 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
417 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
418 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
419 ButtonGroup::updateLayout (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
420 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
421 uibuttongroup::properties& pp = properties<uibuttongroup> (); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
422 QFrame *frame = qWidget<QFrame> (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
423 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
424 Matrix bb = pp.get_boundingbox (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
425 int bw = borderWidthFromProperties (pp); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
426 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
427 frame->setFrameRect (QRect (octave::math::round (bb(0)) - bw, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
428 octave::math::round (bb(1)) - bw, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
429 octave::math::round (bb(2)) + 2*bw, octave::math::round (bb(3)) + 2*bw)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
430 m_container->setGeometry (octave::math::round (bb(0)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
431 octave::math::round (bb(1)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
432 octave::math::round (bb(2)), octave::math::round (bb(3))); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
433 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
434 if (m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
435 pp.update_boundingbox (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
436 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
437 if (m_title) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
438 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
439 QSize sz = m_title->sizeHint (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
440 int offset = 5; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
441 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
442 if (pp.titleposition_is ("lefttop")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
443 m_title->move (bw+offset, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
444 else if (pp.titleposition_is ("righttop")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
445 m_title->move (frame->width () - bw - offset - sz.width (), 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
446 else if (pp.titleposition_is ("leftbottom")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
447 m_title->move (bw+offset, frame->height () - sz.height ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
448 else if (pp.titleposition_is ("rightbottom")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
449 m_title->move (frame->width () - bw - offset - sz.width (), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
450 frame->height () - sz.height ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
451 else if (pp.titleposition_is ("centertop")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
452 m_title->move (frame->width () / 2 - sz.width () / 2, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
453 else if (pp.titleposition_is ("centerbottom")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
454 m_title->move (frame->width () / 2 - sz.width () / 2, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
455 frame->height () - sz.height ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
456 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
457 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
458 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
459 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
460 ButtonGroup::selectNothing (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
461 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
462 m_hiddenbutton->setChecked (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
463 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
464 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
465 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
466 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
467 ButtonGroup::addButton (QAbstractButton *btn) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
468 { |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
469 m_buttongroup->addButton (btn); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
470 connect (btn, &QAbstractButton::toggled, this, &ButtonGroup::buttonToggled); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
471 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
472 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
473 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
474 ButtonGroup::buttonToggled (bool toggled) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
475 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
476 Q_UNUSED (toggled); |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
477 if (! m_blockUpdates) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
478 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
479 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
|
480 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
481 octave::autolock guard (gh_mgr.graphics_lock ()); |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
482 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
483 uibuttongroup::properties& bp = properties<uibuttongroup> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
484 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
485 graphics_handle oldValue = bp.get_selectedobject (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
486 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
487 QAbstractButton *checkedBtn = m_buttongroup->checkedButton (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
488 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
489 graphics_handle newValue = graphics_handle (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
490 if (checkedBtn != m_hiddenbutton) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
491 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
492 Object *checkedObj = Object::fromQObject (checkedBtn); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
493 newValue = checkedObj->properties ().get___myhandle__ (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
494 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
495 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
496 if (oldValue != newValue) |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
497 emit gh_set_event (m_handle, "selectedobject", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
498 newValue.as_octave_value (), false); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
499 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
500 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
501 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
502 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
503 ButtonGroup::buttonClicked (QAbstractButton *btn) |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
504 { |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
505 Q_UNUSED (btn); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
506 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
507 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
|
508 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
509 octave::autolock guard (gh_mgr.graphics_lock ()); |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
510 |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
511 uibuttongroup::properties& bp = properties<uibuttongroup> (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
512 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
513 graphics_handle oldValue = bp.get_selectedobject (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
514 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
515 QAbstractButton *checkedBtn = m_buttongroup->checkedButton (); |
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
516 Object *checkedObj = Object::fromQObject (checkedBtn); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
517 graphics_handle newValue = checkedObj->properties ().get___myhandle__ (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
518 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
519 if (oldValue != newValue) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
520 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
521 octave_scalar_map eventData; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
522 eventData.setfield ("OldValue", oldValue.as_octave_value ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
523 eventData.setfield ("NewValue", newValue.as_octave_value ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
524 eventData.setfield ("Source", bp.get___myhandle__ ().as_octave_value ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
525 eventData.setfield ("EventName", "SelectionChanged"); |
29223
5aa787452544
Use Octave map instead of octave_struct in gui graphics (patch #8919).
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
526 octave_value selectionChangedEventObject (eventData); |
27319
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
527 emit gh_callback_event (m_handle, "selectionchangedfcn", |
6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27317
diff
changeset
|
528 selectionChangedEventObject); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
529 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
530 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
531 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
532 }; |