Mercurial > hg > octave-nkf
annotate libgui/graphics/Panel.cc @ 20711:1f330d33388f
maint: Periodic merge of stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 22 Sep 2015 04:50:47 -0700 |
parents | f0e61a67ad9f |
children |
rev | line source |
---|---|
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
20213
f0e61a67ad9f
Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents:
20176
diff
changeset
|
3 Copyright (C) 2011-2015 Michael Goffioul |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
5 This file is part of Octave. |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10 option) any later version. |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
15 for more details. |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
18568
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 #include <config.h> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include <QEvent> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include <QFrame> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <QLabel> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <QMouseEvent> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QTimer> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "Canvas.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include "Container.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "ContextMenu.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "Panel.h" |
18573
fb96b7f55242
rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents:
18569
diff
changeset
|
37 #include "QtHandlesUtils.h" |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
42 static int |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
43 frameStyleFromProperties (const uipanel::properties& pp) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 if (pp.bordertype_is ("none")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 return QFrame::NoFrame; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 else if (pp.bordertype_is ("etchedin")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 return (QFrame::Box | QFrame::Sunken); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 else if (pp.bordertype_is ("etchedout")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 return (QFrame::Box | QFrame::Raised); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 else if (pp.bordertype_is ("beveledin")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 return (QFrame::Panel | QFrame::Sunken); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 else if (pp.bordertype_is ("beveledout")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 return (QFrame::Panel | QFrame::Raised); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 return (QFrame::Panel | QFrame::Plain); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
59 static void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
60 setupPalette (const uipanel::properties& pp, QPalette& p) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 p.setColor (QPalette::Window, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
63 Utils::fromRgb (pp.get_backgroundcolor_rgb ())); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 p.setColor (QPalette::WindowText, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
65 Utils::fromRgb (pp.get_foregroundcolor_rgb ())); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 p.setColor (QPalette::Light, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
67 Utils::fromRgb (pp.get_highlightcolor_rgb ())); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 p.setColor (QPalette::Dark, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
69 Utils::fromRgb (pp.get_shadowcolor_rgb ())); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
72 static int |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
73 borderWidthFromProperties (const uipanel::properties& pp) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 int bw = 0; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 if (! pp.bordertype_is ("none")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 bw = xround (pp.get_borderwidth ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 if (pp.bordertype_is ("etchedin") || pp.bordertype_is ("etchedout")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
81 bw *= 2; |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 return bw; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
87 Panel* |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
88 Panel::create (const graphics_object& go) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 Object* parent = Object::parentObject (go); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 if (parent) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 Container* container = parent->innerContainer (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 if (container) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
97 return new Panel (go, new QFrame (container)); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 return 0; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 Panel::Panel (const graphics_object& go, QFrame* frame) |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
104 : Object (go, frame), m_container (0), m_title (0), m_blockUpdates (false) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 uipanel::properties& pp = properties<uipanel> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 frame->setObjectName ("UIPanel"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 frame->setAutoFillBackground (true); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 Matrix bb = pp.get_boundingbox (false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 frame->setGeometry (xround (bb(0)), xround (bb(1)), |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
112 xround (bb(2)), xround (bb(3))); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 frame->setFrameStyle (frameStyleFromProperties (pp)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 frame->setLineWidth (xround (pp.get_borderwidth ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 QPalette pal = frame->palette (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 setupPalette (pp, pal); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 frame->setPalette (pal); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 m_container = new Container (frame); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 m_container->canvas (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 |
18760
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
122 if (frame->hasMouseTracking ()) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
123 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
124 foreach (QWidget* w, frame->findChildren<QWidget*> ()) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
125 { w->setMouseTracking (true); } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
126 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18573
diff
changeset
|
127 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 QString title = Utils::fromStdString (pp.get_title ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 if (! title.isEmpty ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 m_title = new QLabel (title, frame); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 m_title->setAutoFillBackground (true); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 m_title->setContentsMargins (4, 0, 4, 0); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 m_title->setPalette (pal); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 m_title->setFont (Utils::computeFont<uipanel> (pp, bb(3))); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 frame->installEventFilter (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 m_container->installEventFilter (this); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 if (pp.is_visible ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 QTimer::singleShot (0, frame, SLOT (show (void))); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 frame->hide (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 Panel::~Panel (void) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
151 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
152 Panel::eventFilter (QObject* watched, QEvent* xevent) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 if (! m_blockUpdates) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 if (watched == qObject ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
157 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
158 switch (xevent->type ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
159 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
160 case QEvent::Resize: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
161 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
162 gh_manager::auto_lock lock; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
163 graphics_object go = object (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
165 if (go.valid_object ()) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
166 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
167 if (m_title) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
168 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
169 const uipanel::properties& pp = |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
170 Utils::properties<uipanel> (go); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
172 if (pp.fontunits_is ("normalized")) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
173 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
174 QFrame* frame = qWidget<QFrame> (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
176 m_title->setFont (Utils::computeFont<uipanel> |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
177 (pp, frame->height ())); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
178 m_title->resize (m_title->sizeHint ()); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
179 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
180 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
181 updateLayout (); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
182 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
183 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
184 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
185 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
186 case QEvent::MouseButtonPress: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
187 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
188 QMouseEvent* m = dynamic_cast<QMouseEvent*> (xevent); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
190 if (m->button () == Qt::RightButton) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
191 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
192 gh_manager::auto_lock lock; |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
194 ContextMenu::executeAt (properties (), m->globalPos ()); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
195 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
196 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
197 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
198 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
199 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
200 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
201 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
202 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 else if (watched == m_container) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
204 { |
19820
6b2d7a5dc62a
use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents:
19818
diff
changeset
|
205 switch (xevent->type ()) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
206 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
207 case QEvent::Resize: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
208 if (qWidget<QWidget> ()->isVisible ()) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
209 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
210 gh_manager::auto_lock lock; |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
212 properties ().update_boundingbox (); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
213 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
214 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
215 |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
216 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
217 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
218 } |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
219 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
225 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
226 Panel::update (int pId) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 uipanel::properties& pp = properties<uipanel> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 QFrame* frame = qWidget<QFrame> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 m_blockUpdates = true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 switch (pId) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 case uipanel::properties::ID_POSITION: |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
236 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
237 Matrix bb = pp.get_boundingbox (false); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
239 frame->setGeometry (xround (bb(0)), xround (bb(1)), |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
240 xround (bb(2)), xround (bb(3))); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
241 updateLayout (); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
242 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
244 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 case uipanel::properties::ID_BORDERWIDTH: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 frame->setLineWidth (xround (pp.get_borderwidth ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 updateLayout (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
249 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 case uipanel::properties::ID_BACKGROUNDCOLOR: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 case uipanel::properties::ID_FOREGROUNDCOLOR: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 case uipanel::properties::ID_HIGHLIGHTCOLOR: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 case uipanel::properties::ID_SHADOWCOLOR: |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
254 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
255 QPalette pal = frame->palette (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
257 setupPalette (pp, pal); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
258 frame->setPalette (pal); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
259 if (m_title) |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
260 m_title->setPalette (pal); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
261 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
263 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 case uipanel::properties::ID_TITLE: |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
265 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
266 QString title = Utils::fromStdString (pp.get_title ()); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
268 if (title.isEmpty ()) |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
269 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
270 if (m_title) |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
271 delete m_title; |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
272 m_title = 0; |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
273 } |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
274 else |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
275 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
276 if (! m_title) |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
277 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
278 QPalette pal = frame->palette (); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
280 m_title = new QLabel (title, frame); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
281 m_title->setAutoFillBackground (true); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
282 m_title->setContentsMargins (4, 0, 4, 0); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
283 m_title->setPalette (pal); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
284 m_title->setFont (Utils::computeFont<uipanel> (pp)); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
285 m_title->show (); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
286 } |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
287 else |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
288 { |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
289 m_title->setText (title); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
290 m_title->resize (m_title->sizeHint ()); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
291 } |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
292 } |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
293 updateLayout (); |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
294 } |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
295 break; |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
296 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 case uipanel::properties::ID_TITLEPOSITION: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 updateLayout (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
300 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 case uipanel::properties::ID_BORDERTYPE: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 frame->setFrameStyle (frameStyleFromProperties (pp)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 updateLayout (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
305 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 case uipanel::properties::ID_FONTNAME: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 case uipanel::properties::ID_FONTSIZE: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 case uipanel::properties::ID_FONTWEIGHT: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 case uipanel::properties::ID_FONTANGLE: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 if (m_title) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
311 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
312 m_title->setFont (Utils::computeFont<uipanel> (pp)); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
313 m_title->resize (m_title->sizeHint ()); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
314 updateLayout (); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
315 } |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
317 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 case uipanel::properties::ID_VISIBLE: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 frame->setVisible (pp.is_visible ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 updateLayout (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 break; |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
322 |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 default: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 break; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 m_blockUpdates = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
330 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
331 Panel::redraw (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 Canvas* canvas = m_container->canvas (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 if (canvas) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
336 canvas->redraw (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 |
20176
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
339 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19822
diff
changeset
|
340 Panel::updateLayout (void) |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 uipanel::properties& pp = properties<uipanel> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 QFrame* frame = qWidget<QFrame> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
345 Matrix bb = pp.get_boundingbox (true); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 int bw = borderWidthFromProperties (pp); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 frame->setFrameRect (QRect (xround (bb(0)) - bw, xround (bb(1)) - bw, |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
349 xround (bb(2)) + 2*bw, xround (bb(3)) + 2*bw)); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 m_container->setGeometry (xround (bb(0)), xround (bb(1)), |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
351 xround (bb(2)), xround (bb(3))); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
353 if (m_blockUpdates) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 pp.update_boundingbox (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 if (m_title) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 QSize sz = m_title->sizeHint (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 int offset = 5; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 if (pp.titleposition_is ("lefttop")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
362 m_title->move (bw+offset, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
363 else if (pp.titleposition_is ("righttop")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
364 m_title->move (frame->width () - bw - offset - sz.width (), 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 else if (pp.titleposition_is ("leftbottom")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
366 m_title->move (bw+offset, frame->height () - sz.height ()); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 else if (pp.titleposition_is ("rightbottom")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
368 m_title->move (frame->width () - bw - offset - sz.width (), |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
369 frame->height () - sz.height ()); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
370 else if (pp.titleposition_is ("centertop")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
371 m_title->move (frame->width () / 2 - sz.width () / 2, 0); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 else if (pp.titleposition_is ("centerbottom")) |
19818
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
373 m_title->move (frame->width () / 2 - sz.width () / 2, |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19813
diff
changeset
|
374 frame->height () - sz.height ()); |
18566
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 }; |