Mercurial > octave
annotate libgui/graphics/ButtonGroup.cc @ 27647:2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
Provide reference to interprerter to qt graphics classes to
eliminate need for accessing it through a global variable.
* qt-graphics-toolkit.cc (qt_graphics_toolkit::create_object): Pass
m_interpreter to create functions for individual graphics objects.
* BaseControl.h, BaseControl.cc, ButtonControl.h, ButtonControl.cc,
ButtonGroup.h, ButtonGroup.cc, Canvas.h, Canvas.cc, CheckBoxControl.h,
CheckBoxControl.cc, Container.h, Container.cc, ContextMenu.h,
ContextMenu.cc, EditControl.h, EditControl.cc, Figure.h, Figure.cc,
GLCanvas.h, GLCanvas.cc, ListBoxControl.h, ListBoxControl.cc, Menu.h,
Menu.cc, Object.h, Object.cc, Panel.h, Panel.cc, PopupMenuControl.h,
PopupMenuControl.cc, PushButtonControl.h, PushButtonControl.cc,
PushTool.h, PushTool.cc, QtHandlesUtils.h, RadioButtonControl.h,
RadioButtonControl.cc, SliderControl.h, SliderControl.cc, Table.h,
Table.cc, TextControl.h, TextControl.cc, ToggleButtonControl.h,
ToggleButtonControl.cc, ToggleTool.h, ToggleTool.cc, ToolBar.h,
ToolBar.cc, ToolBarButton.h, ToolBarButton.cc:
Accept reference to interpreter in create function and constructors
for graphics objects. Eliminate global access to interpreter object
and graphics_handle manager.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 06 Nov 2019 12:42:12 -0500 |
parents | 028205a91a07 |
children | 92fea2cd024f |
rev | line source |
---|---|
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
1 /* |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
3 Copyright (C) 2016-2019 Andrew Thornton |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
4 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
5 This file is part of Octave. |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
10 (at your option) any later version. |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
15 GNU General Public License for more details. |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
16 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
20 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
21 */ |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
22 |
22188 | 23 #if defined (HAVE_CONFIG_H) |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
24 # include "config.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
25 #endif |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
26 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
27 #include <QAbstractButton> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
28 #include <QButtonGroup> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
29 #include <QEvent> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
30 #include <QFrame> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
31 #include <QLabel> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
32 #include <QMouseEvent> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
33 #include <QRadioButton> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
34 #include <QTimer> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
35 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
36 #include "Canvas.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
37 #include "Container.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
38 #include "ContextMenu.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
39 #include "ButtonGroup.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
40 #include "ToggleButtonControl.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
41 #include "RadioButtonControl.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
42 #include "QtHandlesUtils.h" |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
43 #include "qt-graphics-toolkit.h" |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
44 |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
45 #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
|
46 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
47 #include "interpreter.h" |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
48 #include "ov-struct.h" |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
49 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
50 namespace QtHandles |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
51 { |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
52 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
53 static int |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
54 frameStyleFromProperties (const uibuttongroup::properties& pp) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
55 { |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
56 if (pp.bordertype_is ("none")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
57 return QFrame::NoFrame; |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
58 else if (pp.bordertype_is ("etchedin")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
59 return (QFrame::Box | QFrame::Sunken); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
60 else if (pp.bordertype_is ("etchedout")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
61 return (QFrame::Box | QFrame::Raised); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
62 else if (pp.bordertype_is ("beveledin")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
63 return (QFrame::Panel | QFrame::Sunken); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
64 else if (pp.bordertype_is ("beveledout")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
65 return (QFrame::Panel | QFrame::Raised); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
66 else |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
67 return (QFrame::Panel | QFrame::Plain); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
68 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
69 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
70 static void |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23223
diff
changeset
|
71 setupPalette (const uibuttongroup::properties& pp, QPalette& p) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
72 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
73 p.setColor (QPalette::Window, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
74 Utils::fromRgb (pp.get_backgroundcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
75 p.setColor (QPalette::WindowText, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
76 Utils::fromRgb (pp.get_foregroundcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
77 p.setColor (QPalette::Light, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
78 Utils::fromRgb (pp.get_highlightcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
79 p.setColor (QPalette::Dark, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
80 Utils::fromRgb (pp.get_shadowcolor_rgb ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
81 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
82 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
83 static int |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
84 borderWidthFromProperties (const uibuttongroup::properties& pp) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
85 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
86 int bw = 0; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
87 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
88 if (! pp.bordertype_is ("none")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
89 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
90 bw = octave::math::round (pp.get_borderwidth ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
91 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
|
92 bw *= 2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
93 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
94 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
95 return bw; |
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 ButtonGroup* |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
99 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
|
100 octave::interpreter& interp, const graphics_object& go) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
101 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
102 Object *parent = parentObject (interp, go); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
103 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
104 if (parent) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
105 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
106 Container *container = parent->innerContainer (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
107 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
108 if (container) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
109 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
110 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
|
111 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
|
112 new QButtonGroup (frame), frame); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
113 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
114 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
115 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
116 return nullptr; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
117 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
118 |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 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
|
123 : 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
|
124 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
|
125 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
126 uibuttongroup::properties& pp = properties<uibuttongroup> (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
127 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
128 frame->setObjectName ("UIButtonGroup"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
129 frame->setAutoFillBackground (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
130 Matrix bb = pp.get_boundingbox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
131 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
|
132 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
|
133 frame->setFrameStyle (frameStyleFromProperties (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
134 frame->setLineWidth (octave::math::round (pp.get_borderwidth ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
135 QPalette pal = frame->palette (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
136 setupPalette (pp, pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
137 frame->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
138 m_buttongroup = buttongroup; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
139 m_hiddenbutton = new QRadioButton (frame); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
140 m_hiddenbutton->hide (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
141 m_buttongroup->addButton (m_hiddenbutton); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
142 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
143 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
|
144 m_container->canvas (m_handle); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
145 |
27303
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
146 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
|
147 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
|
148 |
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 meth_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 meth_callback&))); |
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
151 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
152 if (frame->hasMouseTracking ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
153 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
154 foreach (QWidget *w, frame->findChildren<QWidget*> ()) |
23223
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
155 w->setMouseTracking (true); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
156 foreach (QWidget *w, buttongroup->findChildren<QWidget*> ()) |
23223
4b642b593ec2
maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
157 w->setMouseTracking (true); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
158 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
159 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
160 QString title = Utils::fromStdString (pp.get_title ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
161 if (! title.isEmpty ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
162 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
163 m_title = new QLabel (title, frame); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
164 m_title->setAutoFillBackground (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
165 m_title->setContentsMargins (4, 0, 4, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
166 m_title->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
167 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
|
168 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
169 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
170 frame->installEventFilter (this); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
171 m_container->installEventFilter (this); |
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 if (pp.is_visible ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
174 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
175 QTimer::singleShot (0, frame, SLOT (show (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
176 QTimer::singleShot (0, buttongroup, SLOT (show (void))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
177 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
178 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
179 frame->hide (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
180 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
181 connect (m_buttongroup, SIGNAL (buttonClicked (QAbstractButton*)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
182 SLOT (buttonClicked (QAbstractButton*))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
183 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
184 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
185 ButtonGroup::~ButtonGroup (void) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
186 { } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
187 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
188 bool |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
189 ButtonGroup::eventFilter (QObject *watched, QEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
190 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
191 if (! m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
192 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
193 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
|
194 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
195 if (watched == qObject ()) |
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 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
198 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
199 case QEvent::Resize: |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
200 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
201 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
|
202 |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
203 graphics_object go = object (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
204 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
205 if (go.valid_object ()) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
206 { |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
207 if (m_title) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
208 { |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
209 const uibuttongroup::properties& pp = |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
210 Utils::properties<uibuttongroup> (go); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
211 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
212 if (pp.fontunits_is ("normalized")) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
213 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
214 QFrame *frame = qWidget<QFrame> (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
215 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
216 m_title->setFont (Utils::computeFont<uibuttongroup> |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
217 (pp, frame->height ())); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
218 m_title->resize (m_title->sizeHint ()); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
219 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
220 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
221 updateLayout (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
222 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
223 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
224 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
225 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
226 case QEvent::MouseButtonPress: |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
227 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
228 QMouseEvent *m = dynamic_cast<QMouseEvent *> (xevent); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
229 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
230 if (m->button () == Qt::RightButton) |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
231 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
232 octave::autolock guard (gh_mgr.graphics_lock ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
233 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
234 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
|
235 m->globalPos ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
236 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
237 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
238 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
239 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
240 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
241 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
242 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
243 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
244 else if (watched == m_container) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
245 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
246 switch (xevent->type ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
247 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
248 case QEvent::Resize: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
249 if (qWidget<QWidget> ()->isVisible ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
250 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
251 octave::autolock guard (gh_mgr.graphics_lock ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
252 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
253 properties ().update_boundingbox (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
254 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
255 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
256 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
257 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
258 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
259 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
260 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
261 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
262 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
263 return false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
264 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
265 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
266 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
267 ButtonGroup::update (int pId) |
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 uibuttongroup::properties& pp = properties<uibuttongroup> (); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
270 QFrame *frame = qWidget<QFrame> (); |
22411
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 m_blockUpdates = true; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
273 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
274 switch (pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
275 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
276 case uibuttongroup::properties::ID_POSITION: |
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 Matrix bb = pp.get_boundingbox (false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
279 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
280 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
|
281 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
|
282 updateLayout (); |
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 break; |
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 case uibuttongroup::properties::ID_BORDERWIDTH: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
287 frame->setLineWidth (octave::math::round (pp.get_borderwidth ())); |
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 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
290 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
291 case uibuttongroup::properties::ID_BACKGROUNDCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
292 case uibuttongroup::properties::ID_FOREGROUNDCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
293 case uibuttongroup::properties::ID_HIGHLIGHTCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
294 case uibuttongroup::properties::ID_SHADOWCOLOR: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
295 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
296 QPalette pal = frame->palette (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
297 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
298 setupPalette (pp, pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
299 frame->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
300 if (m_title) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
301 m_title->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
302 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
303 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
304 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
305 case uibuttongroup::properties::ID_TITLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
306 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
307 QString title = Utils::fromStdString (pp.get_title ()); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
308 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
309 if (title.isEmpty ()) |
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 if (m_title) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
312 delete m_title; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
313 m_title = nullptr; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
314 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
315 else |
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 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
319 QPalette pal = frame->palette (); |
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 m_title = new QLabel (title, frame); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
322 m_title->setAutoFillBackground (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
323 m_title->setContentsMargins (4, 0, 4, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
324 m_title->setPalette (pal); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
325 m_title->setFont (Utils::computeFont<uibuttongroup> (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
326 m_title->show (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
327 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
328 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
329 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
330 m_title->setText (title); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
331 m_title->resize (m_title->sizeHint ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
332 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
333 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
334 updateLayout (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
335 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
336 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
337 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
338 case uibuttongroup::properties::ID_TITLEPOSITION: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
339 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
340 break; |
21824
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 case uibuttongroup::properties::ID_BORDERTYPE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
343 frame->setFrameStyle (frameStyleFromProperties (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
344 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
345 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
346 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
347 case uibuttongroup::properties::ID_FONTNAME: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
348 case uibuttongroup::properties::ID_FONTSIZE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
349 case uibuttongroup::properties::ID_FONTWEIGHT: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
350 case uibuttongroup::properties::ID_FONTANGLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
351 if (m_title) |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
352 { |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
353 m_title->setFont (Utils::computeFont<uibuttongroup> (pp)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
354 m_title->resize (m_title->sizeHint ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
355 updateLayout (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
356 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
357 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
358 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
359 case uibuttongroup::properties::ID_VISIBLE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
360 frame->setVisible (pp.is_visible ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
361 updateLayout (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
362 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
363 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
364 case uibuttongroup::properties::ID_SELECTEDOBJECT: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
365 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
366 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
|
367 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
368 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
|
369 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
370 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
|
371 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
372 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
|
373 |
27317
718116e9c7d3
rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
374 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
|
375 ToggleButtonControl *toggle = static_cast<ToggleButtonControl *> |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
376 (selectedObject); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
377 RadioButtonControl *radio = static_cast<RadioButtonControl *>(selectedObject); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
378 if (toggle) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
379 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
380 go.get_properties ().set ("value", 1); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
381 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
382 else if (radio) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
383 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
384 go.get_properties ().set ("value", 1); |
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 else |
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 m_hiddenbutton->setChecked (true); |
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 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
391 break; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
392 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
393 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
394 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
395 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
396 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
397 m_blockUpdates = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
398 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
399 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
400 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
401 ButtonGroup::redraw (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
402 { |
26816
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
403 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
|
404 |
92ecc4a97b5c
Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
405 // 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
|
406 Canvas *canvas = m_container->canvas (m_handle); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
407 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
408 if (canvas) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
409 canvas->redraw (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
410 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
411 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
412 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
413 ButtonGroup::updateLayout (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
414 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
415 uibuttongroup::properties& pp = properties<uibuttongroup> (); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
416 QFrame *frame = qWidget<QFrame> (); |
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 Matrix bb = pp.get_boundingbox (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
419 int bw = borderWidthFromProperties (pp); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
420 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
421 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
|
422 octave::math::round (bb(1)) - bw, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
423 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
|
424 m_container->setGeometry (octave::math::round (bb(0)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
425 octave::math::round (bb(1)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
426 octave::math::round (bb(2)), octave::math::round (bb(3))); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
427 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
428 if (m_blockUpdates) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
429 pp.update_boundingbox (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
430 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
431 if (m_title) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
432 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
433 QSize sz = m_title->sizeHint (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
434 int offset = 5; |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
435 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
436 if (pp.titleposition_is ("lefttop")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
437 m_title->move (bw+offset, 0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
438 else if (pp.titleposition_is ("righttop")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
439 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
|
440 else if (pp.titleposition_is ("leftbottom")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
441 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
|
442 else if (pp.titleposition_is ("rightbottom")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
443 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
|
444 frame->height () - sz.height ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
445 else if (pp.titleposition_is ("centertop")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
446 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
|
447 else if (pp.titleposition_is ("centerbottom")) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
448 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
|
449 frame->height () - sz.height ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
450 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
451 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
452 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
453 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
454 ButtonGroup::selectNothing (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
455 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
456 m_hiddenbutton->setChecked (true); |
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 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
459 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
460 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
461 ButtonGroup::addButton (QAbstractButton *btn) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
462 { |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
463 m_buttongroup->addButton (btn); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
464 connect (btn, SIGNAL (toggled (bool)), SLOT (buttonToggled (bool))); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
465 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
466 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
467 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
468 ButtonGroup::buttonToggled (bool toggled) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
469 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
470 Q_UNUSED (toggled); |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
471 if (! m_blockUpdates) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
472 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
473 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
|
474 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
475 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
|
476 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
477 uibuttongroup::properties& bp = properties<uibuttongroup> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
478 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
479 graphics_handle oldValue = bp.get_selectedobject (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
480 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
481 QAbstractButton *checkedBtn = m_buttongroup->checkedButton (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
482 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
483 graphics_handle newValue = graphics_handle (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
484 if (checkedBtn != m_hiddenbutton) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
485 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
486 Object *checkedObj = Object::fromQObject (checkedBtn); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
487 newValue = checkedObj->properties ().get___myhandle__ (); |
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 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
490 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
|
491 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
|
492 newValue.as_octave_value (), false); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
493 } |
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 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
497 ButtonGroup::buttonClicked (QAbstractButton *btn) |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
498 { |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
499 Q_UNUSED (btn); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
500 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
501 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
|
502 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27319
diff
changeset
|
503 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
|
504 |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
505 uibuttongroup::properties& bp = properties<uibuttongroup> (); |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
506 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
507 graphics_handle oldValue = bp.get_selectedobject (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
508 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
509 QAbstractButton *checkedBtn = m_buttongroup->checkedButton (); |
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
510 Object *checkedObj = Object::fromQObject (checkedBtn); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
511 graphics_handle newValue = checkedObj->properties ().get___myhandle__ (); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
512 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
513 if (oldValue != newValue) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
514 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
515 octave_scalar_map eventData; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
516 eventData.setfield ("OldValue", oldValue.as_octave_value ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
517 eventData.setfield ("NewValue", newValue.as_octave_value ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
518 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
|
519 eventData.setfield ("EventName", "SelectionChanged"); |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26816
diff
changeset
|
520 octave_value selectionChangedEventObject (new octave_struct (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
|
521 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
|
522 selectionChangedEventObject); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22188
diff
changeset
|
523 } |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
524 } |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
525 |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff
changeset
|
526 }; |