annotate libgui/graphics/Panel.cc @ 30398:d4d83344d653 stable

maint: style check C++ files in src/ and libgui/ ahead of 7.1 release. * ButtonGroup.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, Figure.h, FigureWindow.cc, GenericEventNotify.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Menu.cc, Object.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, RadioButtonControl.cc, SliderControl.cc, Table.cc, Table.h, TextControl.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, annotation-dialog.cc, qt-graphics-toolkit.cc, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-model.cc, gui-preferences-dw.h, gui-preferences-ed.h, gui-preferences-global.h, gui-settings.h, interpreter-qobject.cc, led-indicator.cc, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, octave-qscintilla.cc, octave-qscintilla.h, main-window.cc, main-window.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, octave-qtutils.h, qt-interpreter-events.cc, release-notes.cc, resource-manager.cc, set-path-dialog.cc, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.cc, tab-bar.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, workspace-model.cc, workspace-view.cc, mkoctfile.in.cc, octave-config.in.cc: Style check C++ files in src/ and libgui/ ahead of 7.1 release.
author Rik <rik@octave.org>
date Mon, 29 Nov 2021 15:58:51 -0800
parents 6ea4a84df9c7
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 2011-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 ////////////////////////////////////////////////////////////////////////
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
27 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <QEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <QFrame>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QLabel>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <QMouseEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include <QTimer>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "Canvas.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "Container.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "ContextMenu.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include "Panel.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
40 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
42 #include "octave-qobject.h"
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
43
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
44 #include "graphics.h"
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
45 #include "interpreter.h"
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
46
29992
6ea4a84df9c7 rename QtHandles namespace to octave
John W. Eaton <jwe@octave.org>
parents: 29542
diff changeset
47 namespace octave
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
50 static int
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
51 frameStyleFromProperties (const uipanel::properties& pp)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
52 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
53 if (pp.bordertype_is ("none"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
54 return QFrame::NoFrame;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
55 else if (pp.bordertype_is ("etchedin"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
56 return (QFrame::Box | QFrame::Sunken);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
57 else if (pp.bordertype_is ("etchedout"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
58 return (QFrame::Box | QFrame::Raised);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
59 else if (pp.bordertype_is ("beveledin"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
60 return (QFrame::Panel | QFrame::Sunken);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
61 else if (pp.bordertype_is ("beveledout"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
62 return (QFrame::Panel | QFrame::Raised);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
63 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
64 return (QFrame::Panel | QFrame::Plain);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
65 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
67 static void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
68 setupPalette (const uipanel::properties& pp, QPalette& p)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
69 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
70 p.setColor (QPalette::Window,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
71 Utils::fromRgb (pp.get_backgroundcolor_rgb ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
72 p.setColor (QPalette::WindowText,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
73 Utils::fromRgb (pp.get_foregroundcolor_rgb ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
74 p.setColor (QPalette::Light,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
75 Utils::fromRgb (pp.get_highlightcolor_rgb ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
76 p.setColor (QPalette::Dark,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
77 Utils::fromRgb (pp.get_shadowcolor_rgb ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
78 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
80 static int
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
81 borderWidthFromProperties (const uipanel::properties& pp)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
82 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
83 int bw = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
85 if (! pp.bordertype_is ("none"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
86 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
87 bw = octave::math::round (pp.get_borderwidth ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
88 if (pp.bordertype_is ("etchedin") || pp.bordertype_is ("etchedout"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
89 bw *= 2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
90 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
92 return bw;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
93 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
95 Panel *
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
96 Panel::create (octave::base_qobject& oct_qobj, octave::interpreter& interp,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
97 const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
98 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
99 Object *parent = parentObject (interp, go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
101 if (parent)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
102 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
103 Container *container = parent->innerContainer ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
105 if (container)
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
106 return new Panel (oct_qobj, interp, go, new QFrame (container));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
107 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23449
diff changeset
109 return nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
110 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
112 Panel::Panel (octave::base_qobject& oct_qobj, octave::interpreter& interp,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
113 const graphics_object& go, QFrame *frame)
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
114 : Object (oct_qobj, interp, go, frame), m_container (nullptr),
27789
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
115 m_title (nullptr), m_blockUpdates (false),
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
116 m_previous_bbox (Matrix (1, 4, 0))
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
117 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
118 uipanel::properties& pp = properties<uipanel> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
120 frame->setObjectName ("UIPanel");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
121 frame->setAutoFillBackground (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
122 Matrix bb = pp.get_boundingbox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
123 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: 22323
diff changeset
124 octave::math::round (bb(2)), octave::math::round (bb(3)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
125 frame->setFrameStyle (frameStyleFromProperties (pp));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
126 frame->setLineWidth (octave::math::round (pp.get_borderwidth ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
127 QPalette pal = frame->palette ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
128 setupPalette (pp, pal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
129 frame->setPalette (pal);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
131 m_container = new Container (frame, oct_qobj, interp);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
132 m_container->canvas (m_handle);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27224
diff changeset
134 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: 27224
diff changeset
135 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: 27224
diff changeset
136
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27224
diff changeset
137 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: 27224
diff changeset
138 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: 27224
diff changeset
139
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
140 if (frame->hasMouseTracking ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
141 {
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
142 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
143 w->setMouseTracking (true);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
144 }
18612
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
145
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
146 QString title = Utils::fromStdString (pp.get_title ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
147 if (! title.isEmpty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
148 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
149 m_title = new QLabel (title, frame);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
150 m_title->setAutoFillBackground (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
151 m_title->setContentsMargins (4, 0, 4, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
152 m_title->setPalette (pal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
153 m_title->setFont (Utils::computeFont<uipanel> (pp, bb(3)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
154 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
156 frame->installEventFilter (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
157 m_container->installEventFilter (this);
27376
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
158
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26816
diff changeset
159 graphics_object fig (go.get_ancestor ("figure"));
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26816
diff changeset
160 if (! fig.get ("keypressfcn").isempty ())
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26816
diff changeset
161 m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress);
27376
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
162
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26816
diff changeset
163 if (! fig.get ("keyreleasefcn").isempty ())
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26816
diff changeset
164 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
166 if (pp.is_visible ())
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
167 QTimer::singleShot (0, frame, &QFrame::show);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
168 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
169 frame->hide ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
170 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
172 Panel::~Panel (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22411
diff changeset
173 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
175 bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
176 Panel::eventFilter (QObject *watched, QEvent *xevent)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
177 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
178 if (! m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
179 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
180 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: 27303
diff changeset
181
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
182 if (watched == qObject ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
183 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
184 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
185 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
186 case QEvent::Resize:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
187 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
188 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
189
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
190 graphics_object go = object ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
192 if (go.valid_object ())
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
193 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
194 if (m_title)
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
195 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
196 const uipanel::properties& pp =
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
197 Utils::properties<uipanel> (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
198
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
199 if (pp.fontunits_is ("normalized"))
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
200 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
201 QFrame *frame = qWidget<QFrame> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
203 m_title->setFont (Utils::computeFont<uipanel>
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
204 (pp, frame->height ()));
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
205 m_title->resize (m_title->sizeHint ());
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
206 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
207 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
208 updateLayout ();
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
209 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
210 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
211 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
212
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
213 case QEvent::MouseButtonPress:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
214 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
215 QMouseEvent *m = dynamic_cast<QMouseEvent *> (xevent);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
216
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
217 if (m->button () == Qt::RightButton)
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
218 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
219 octave::autolock guard (gh_mgr.graphics_lock ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
220
22190
e68128601f5e skip invalid objects in Qt graphics event handlers (bug #46501)
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
221 graphics_object go = object ();
e68128601f5e skip invalid objects in Qt graphics event handlers (bug #46501)
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
222
e68128601f5e skip invalid objects in Qt graphics event handlers (bug #46501)
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
223 if (go.valid_object ())
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
224 ContextMenu::executeAt (m_interpreter,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
225 go.get_properties (),
22190
e68128601f5e skip invalid objects in Qt graphics event handlers (bug #46501)
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
226 m->globalPos ());
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
227 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
228 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
229 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
231 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
232 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
233 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
234 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
235 else if (watched == m_container)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
236 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
237 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
238 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
239 case QEvent::Resize:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
240 if (qWidget<QWidget> ()->isVisible ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
241 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
242 octave::autolock guard (gh_mgr.graphics_lock ());
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
243
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
244 graphics_object go = object ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
246 if (go.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
247 go.get_properties ().update_boundingbox ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
248 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
249 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
250
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
251 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
252 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
253 }
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
254 }
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
255 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
256
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
257 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
258 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
259
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
260 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
261 Panel::update (int pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
262 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
263 uipanel::properties& pp = properties<uipanel> ();
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
264 QFrame *frame = qWidget<QFrame> ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
265
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
266 m_blockUpdates = true;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
267
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
268 switch (pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
269 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
270 case uipanel::properties::ID_POSITION:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
271 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
272 Matrix bb = pp.get_boundingbox (false);
27789
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
273 if (m_previous_bbox(0) != bb(0) || m_previous_bbox(1) != bb(1)
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
274 || m_previous_bbox(2) != bb(2) || m_previous_bbox(3) != bb(3))
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
275 {
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
276 frame->setGeometry (octave::math::round (bb(0)),
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
277 octave::math::round (bb(1)),
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
278 octave::math::round (bb(2)),
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
279 octave::math::round (bb(3)));
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
280 updateLayout ();
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
281 }
18de38659606 Prevent uipanel from being redrawn when its bbox didn't change (bug #57350)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27677
diff changeset
282 m_previous_bbox = bb;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
283 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
284 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
285
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
286 case uipanel::properties::ID_BORDERWIDTH:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
287 frame->setLineWidth (octave::math::round (pp.get_borderwidth ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
288 updateLayout ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
289 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
290
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
291 case uipanel::properties::ID_BACKGROUNDCOLOR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
292 case uipanel::properties::ID_FOREGROUNDCOLOR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
293 case uipanel::properties::ID_HIGHLIGHTCOLOR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
294 case uipanel::properties::ID_SHADOWCOLOR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
295 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
296 QPalette pal = frame->palette ();
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
297
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
298 setupPalette (pp, pal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
299 frame->setPalette (pal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
300 if (m_title)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
301 m_title->setPalette (pal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
302 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
303 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
304
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
305 case uipanel::properties::ID_TITLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
306 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
307 QString title = Utils::fromStdString (pp.get_title ());
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
308
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
309 if (title.isEmpty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
310 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
311 if (m_title)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
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: 22323
diff changeset
314 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
315 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
316 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
317 if (! m_title)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
318 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
319 QPalette pal = frame->palette ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
320
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
321 m_title = new QLabel (title, frame);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
322 m_title->setAutoFillBackground (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
323 m_title->setContentsMargins (4, 0, 4, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
324 m_title->setPalette (pal);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
325 m_title->setFont (Utils::computeFont<uipanel> (pp));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
326 m_title->show ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
327 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
328 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
329 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
330 m_title->setText (title);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
331 m_title->resize (m_title->sizeHint ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
332 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
333 }
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
334 updateLayout ();
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
335 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
336 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
337
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
338 case uipanel::properties::ID_TITLEPOSITION:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
339 updateLayout ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
340 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
342 case uipanel::properties::ID_BORDERTYPE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
343 frame->setFrameStyle (frameStyleFromProperties (pp));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
344 updateLayout ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
345 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
346
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
347 case uipanel::properties::ID_FONTNAME:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
348 case uipanel::properties::ID_FONTSIZE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
349 case uipanel::properties::ID_FONTWEIGHT:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
350 case uipanel::properties::ID_FONTANGLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
351 if (m_title)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
352 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
353 m_title->setFont (Utils::computeFont<uipanel> (pp));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
354 m_title->resize (m_title->sizeHint ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
355 updateLayout ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
356 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
357 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
358
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
359 case uipanel::properties::ID_VISIBLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
360 frame->setVisible (pp.is_visible ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
361 updateLayout ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
362 break;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
363
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
364 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
365 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
366 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
367
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
368 m_blockUpdates = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
369 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
370
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
371 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
372 Panel::redraw (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
373 {
26816
92ecc4a97b5c Properly redraw uixx objects after Qt figure is (un)maximized (bug #53709)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
374 update (uipanel::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
375
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
376 Canvas *canvas = m_container->canvas (m_handle);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
378 if (canvas)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
379 canvas->redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
380 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
381
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
382 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
383 Panel::updateLayout (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
384 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
385 uipanel::properties& pp = properties<uipanel> ();
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
386 QFrame *frame = qWidget<QFrame> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
387
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
388 Matrix bb = pp.get_boundingbox (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
389 int bw = borderWidthFromProperties (pp);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
390
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
391 frame->setFrameRect (QRect (octave::math::round (bb(0)) - bw,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
392 octave::math::round (bb(1)) - bw,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
393 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: 22323
diff changeset
394 m_container->setGeometry (octave::math::round (bb(0)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
395 octave::math::round (bb(1)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
396 octave::math::round (bb(2)), octave::math::round (bb(3)));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
397
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
398 if (m_blockUpdates)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
399 pp.update_boundingbox ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
400
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
401 if (m_title)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
402 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
403 QSize sz = m_title->sizeHint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
404 int offset = 5;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
405
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
406 if (pp.titleposition_is ("lefttop"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
407 m_title->move (bw+offset, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
408 else if (pp.titleposition_is ("righttop"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
409 m_title->move (frame->width () - bw - offset - sz.width (), 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
410 else if (pp.titleposition_is ("leftbottom"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
411 m_title->move (bw+offset, frame->height () - sz.height ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
412 else if (pp.titleposition_is ("rightbottom"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
413 m_title->move (frame->width () - bw - offset - sz.width (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
414 frame->height () - sz.height ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
415 else if (pp.titleposition_is ("centertop"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
416 m_title->move (frame->width () / 2 - sz.width () / 2, 0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
417 else if (pp.titleposition_is ("centerbottom"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
418 m_title->move (frame->width () / 2 - sz.width () / 2,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
419 frame->height () - sz.height ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
420 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
421 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422
27376
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
423 void
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29992
diff changeset
424 Panel::do_connections (const QObject *receiver, const QObject * /* emitter */)
27376
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
425 {
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
426 Object::do_connections (receiver);
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
427 Object::do_connections (receiver, m_container->canvas (m_handle));
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
428 }
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
429
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
430 };