1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <Qt5Data.hxx>
22 #include <QtGui/QBitmap>
23 #include <QtGui/QCursor>
24 #include <QtWidgets/QApplication>
25 #include <QtWidgets/QStyle>
27 #include <sal/log.hxx>
29 #include <unx/x11_cursors/ase_curs.h>
30 #include <unx/x11_cursors/ase_mask.h>
31 #include <unx/x11_cursors/asn_curs.h>
32 #include <unx/x11_cursors/asn_mask.h>
33 #include <unx/x11_cursors/asne_curs.h>
34 #include <unx/x11_cursors/asne_mask.h>
35 #include <unx/x11_cursors/asns_curs.h>
36 #include <unx/x11_cursors/asns_mask.h>
37 #include <unx/x11_cursors/asnswe_curs.h>
38 #include <unx/x11_cursors/asnswe_mask.h>
39 #include <unx/x11_cursors/asnw_curs.h>
40 #include <unx/x11_cursors/asnw_mask.h>
41 #include <unx/x11_cursors/ass_curs.h>
42 #include <unx/x11_cursors/ass_mask.h>
43 #include <unx/x11_cursors/asse_curs.h>
44 #include <unx/x11_cursors/asse_mask.h>
45 #include <unx/x11_cursors/assw_curs.h>
46 #include <unx/x11_cursors/assw_mask.h>
47 #include <unx/x11_cursors/asw_curs.h>
48 #include <unx/x11_cursors/asw_mask.h>
49 #include <unx/x11_cursors/aswe_curs.h>
50 #include <unx/x11_cursors/aswe_mask.h>
51 #include <unx/x11_cursors/chain_curs.h>
52 #include <unx/x11_cursors/chain_mask.h>
53 #include <unx/x11_cursors/chainnot_curs.h>
54 #include <unx/x11_cursors/chainnot_mask.h>
55 #include <unx/x11_cursors/chart_curs.h>
56 #include <unx/x11_cursors/chart_mask.h>
57 #include <unx/x11_cursors/copydata_curs.h>
58 #include <unx/x11_cursors/copydata_mask.h>
59 #include <unx/x11_cursors/copydlnk_curs.h>
60 #include <unx/x11_cursors/copydlnk_mask.h>
61 #include <unx/x11_cursors/copyfile_curs.h>
62 #include <unx/x11_cursors/copyfile_mask.h>
63 #include <unx/x11_cursors/copyfiles_curs.h>
64 #include <unx/x11_cursors/copyfiles_mask.h>
65 #include <unx/x11_cursors/copyflnk_curs.h>
66 #include <unx/x11_cursors/copyflnk_mask.h>
67 #include <unx/x11_cursors/crook_curs.h>
68 #include <unx/x11_cursors/crook_mask.h>
69 #include <unx/x11_cursors/crop_curs.h>
70 #include <unx/x11_cursors/crop_mask.h>
71 #include <unx/x11_cursors/detective_curs.h>
72 #include <unx/x11_cursors/detective_mask.h>
73 #include <unx/x11_cursors/drawarc_curs.h>
74 #include <unx/x11_cursors/drawarc_mask.h>
75 #include <unx/x11_cursors/drawbezier_curs.h>
76 #include <unx/x11_cursors/drawbezier_mask.h>
77 #include <unx/x11_cursors/drawcaption_curs.h>
78 #include <unx/x11_cursors/drawcaption_mask.h>
79 #include <unx/x11_cursors/drawcirclecut_curs.h>
80 #include <unx/x11_cursors/drawcirclecut_mask.h>
81 #include <unx/x11_cursors/drawconnect_curs.h>
82 #include <unx/x11_cursors/drawconnect_mask.h>
83 #include <unx/x11_cursors/drawellipse_curs.h>
84 #include <unx/x11_cursors/drawellipse_mask.h>
85 #include <unx/x11_cursors/drawfreehand_curs.h>
86 #include <unx/x11_cursors/drawfreehand_mask.h>
87 #include <unx/x11_cursors/drawline_curs.h>
88 #include <unx/x11_cursors/drawline_mask.h>
89 #include <unx/x11_cursors/drawpie_curs.h>
90 #include <unx/x11_cursors/drawpie_mask.h>
91 #include <unx/x11_cursors/drawpolygon_curs.h>
92 #include <unx/x11_cursors/drawpolygon_mask.h>
93 #include <unx/x11_cursors/drawrect_curs.h>
94 #include <unx/x11_cursors/drawrect_mask.h>
95 #include <unx/x11_cursors/drawtext_curs.h>
96 #include <unx/x11_cursors/drawtext_mask.h>
97 #include <unx/x11_cursors/fill_curs.h>
98 #include <unx/x11_cursors/fill_mask.h>
99 #include <unx/x11_cursors/hshear_curs.h>
100 #include <unx/x11_cursors/hshear_mask.h>
101 #include <unx/x11_cursors/linkdata_curs.h>
102 #include <unx/x11_cursors/linkdata_mask.h>
103 #include <unx/x11_cursors/linkfile_curs.h>
104 #include <unx/x11_cursors/linkfile_mask.h>
105 #include <unx/x11_cursors/magnify_curs.h>
106 #include <unx/x11_cursors/magnify_mask.h>
107 #include <unx/x11_cursors/mirror_curs.h>
108 #include <unx/x11_cursors/mirror_mask.h>
109 #include <unx/x11_cursors/movebezierweight_curs.h>
110 #include <unx/x11_cursors/movebezierweight_mask.h>
111 #include <unx/x11_cursors/movedata_curs.h>
112 #include <unx/x11_cursors/movedata_mask.h>
113 #include <unx/x11_cursors/movedlnk_curs.h>
114 #include <unx/x11_cursors/movedlnk_mask.h>
115 #include <unx/x11_cursors/movefile_curs.h>
116 #include <unx/x11_cursors/movefile_mask.h>
117 #include <unx/x11_cursors/movefiles_curs.h>
118 #include <unx/x11_cursors/movefiles_mask.h>
119 #include <unx/x11_cursors/moveflnk_curs.h>
120 #include <unx/x11_cursors/moveflnk_mask.h>
121 #include <unx/x11_cursors/movepoint_curs.h>
122 #include <unx/x11_cursors/movepoint_mask.h>
123 #include <unx/x11_cursors/nodrop_curs.h>
124 #include <unx/x11_cursors/nodrop_mask.h>
125 #include <unx/x11_cursors/pivotcol_curs.h>
126 #include <unx/x11_cursors/pivotcol_mask.h>
127 #include <unx/x11_cursors/pivotdel_curs.h>
128 #include <unx/x11_cursors/pivotdel_mask.h>
129 #include <unx/x11_cursors/pivotfld_curs.h>
130 #include <unx/x11_cursors/pivotfld_mask.h>
131 #include <unx/x11_cursors/pivotrow_curs.h>
132 #include <unx/x11_cursors/pivotrow_mask.h>
133 #include <unx/x11_cursors/rotate_curs.h>
134 #include <unx/x11_cursors/rotate_mask.h>
135 #include <unx/x11_cursors/tblsele_curs.h>
136 #include <unx/x11_cursors/tblsele_mask.h>
137 #include <unx/x11_cursors/tblsels_curs.h>
138 #include <unx/x11_cursors/tblsels_mask.h>
139 #include <unx/x11_cursors/tblselse_curs.h>
140 #include <unx/x11_cursors/tblselse_mask.h>
141 #include <unx/x11_cursors/tblselsw_curs.h>
142 #include <unx/x11_cursors/tblselsw_mask.h>
143 #include <unx/x11_cursors/tblselw_curs.h>
144 #include <unx/x11_cursors/tblselw_mask.h>
145 #include <unx/x11_cursors/vertcurs_curs.h>
146 #include <unx/x11_cursors/vertcurs_mask.h>
147 #include <unx/x11_cursors/vshear_curs.h>
148 #include <unx/x11_cursors/vshear_mask.h>
149 #include <unx/x11_cursors/wshide_curs.h>
150 #include <unx/x11_cursors/wshide_mask.h>
151 #include <unx/x11_cursors/wsshow_curs.h>
152 #include <unx/x11_cursors/wsshow_mask.h>
154 #include <unx/glyphcache.hxx>
156 Qt5Data::Qt5Data(SalInstance
* pInstance
)
157 : GenericUnixSalData(SAL_DATA_QT5
, pInstance
)
159 ImplSVData
* pSVData
= ImplGetSVData();
161 pSVData
->maNWFData
.mbDockingAreaSeparateTB
= true;
162 pSVData
->maNWFData
.mbFlatMenu
= true;
163 pSVData
->maNWFData
.mbRolloverMenubar
= true;
164 pSVData
->maNWFData
.mbNoFocusRects
= true;
165 pSVData
->maNWFData
.mbNoFocusRectsForFlatButtons
= true;
167 QStyle
* style
= QApplication::style();
168 pSVData
->maNWFData
.mnMenuFormatBorderX
= style
->pixelMetric(QStyle::PM_MenuPanelWidth
)
169 + style
->pixelMetric(QStyle::PM_MenuHMargin
);
170 pSVData
->maNWFData
.mnMenuFormatBorderY
= style
->pixelMetric(QStyle::PM_MenuPanelWidth
)
171 + style
->pixelMetric(QStyle::PM_MenuVMargin
);
174 // outline dtor b/c of GlyphCache incomplete type
175 Qt5Data::~Qt5Data() {}
177 static QCursor
* getQCursorFromXBM(const unsigned char* pBitmap
, const unsigned char* pMask
,
178 int nWidth
, int nHeight
, int nXHot
, int nYHot
)
180 QBitmap aPixmap
= QBitmap::fromData(QSize(nWidth
, nHeight
), pBitmap
);
181 QBitmap aMask
= QBitmap::fromData(QSize(nWidth
, nHeight
), pMask
);
182 return new QCursor(aPixmap
, aMask
, nXHot
, nYHot
);
185 #define MAKE_CURSOR(vcl_name, name) \
187 pCursor = getQCursorFromXBM(name##curs##_bits, name##mask##_bits, name##curs_width, \
188 name##curs_height, name##curs_x_hot, name##curs_y_hot); \
191 #define MAP_BUILTIN(vcl_name, qt_enum) \
193 pCursor = new QCursor(qt_enum); \
196 QCursor
& Qt5Data::getCursor(PointerStyle ePointerStyle
)
198 if (!m_aCursors
[ePointerStyle
])
200 QCursor
* pCursor
= nullptr;
202 switch (ePointerStyle
)
204 MAP_BUILTIN(PointerStyle::Arrow
, Qt::ArrowCursor
);
205 MAP_BUILTIN(PointerStyle::Text
, Qt::IBeamCursor
);
206 MAP_BUILTIN(PointerStyle::Help
, Qt::WhatsThisCursor
);
207 MAP_BUILTIN(PointerStyle::Cross
, Qt::CrossCursor
);
208 MAP_BUILTIN(PointerStyle::Wait
, Qt::WaitCursor
);
209 MAP_BUILTIN(PointerStyle::NSize
, Qt::SizeVerCursor
);
210 MAP_BUILTIN(PointerStyle::SSize
, Qt::SizeVerCursor
);
211 MAP_BUILTIN(PointerStyle::WSize
, Qt::SizeHorCursor
);
212 MAP_BUILTIN(PointerStyle::ESize
, Qt::SizeHorCursor
);
214 MAP_BUILTIN(PointerStyle::NWSize
, Qt::SizeFDiagCursor
);
215 MAP_BUILTIN(PointerStyle::NESize
, Qt::SizeBDiagCursor
);
216 MAP_BUILTIN(PointerStyle::SWSize
, Qt::SizeBDiagCursor
);
217 MAP_BUILTIN(PointerStyle::SESize
, Qt::SizeFDiagCursor
);
218 MAP_BUILTIN(PointerStyle::WindowNSize
, Qt::SizeVerCursor
);
219 MAP_BUILTIN(PointerStyle::WindowSSize
, Qt::SizeVerCursor
);
220 MAP_BUILTIN(PointerStyle::WindowWSize
, Qt::SizeHorCursor
);
221 MAP_BUILTIN(PointerStyle::WindowESize
, Qt::SizeHorCursor
);
222 MAP_BUILTIN(PointerStyle::WindowNWSize
, Qt::SizeFDiagCursor
);
223 MAP_BUILTIN(PointerStyle::WindowNESize
, Qt::SizeBDiagCursor
);
224 MAP_BUILTIN(PointerStyle::WindowSWSize
, Qt::SizeBDiagCursor
);
225 MAP_BUILTIN(PointerStyle::WindowSESize
, Qt::SizeFDiagCursor
);
227 MAP_BUILTIN(PointerStyle::HSizeBar
, Qt::SizeHorCursor
);
228 MAP_BUILTIN(PointerStyle::VSizeBar
, Qt::SizeVerCursor
);
230 MAP_BUILTIN(PointerStyle::RefHand
, Qt::OpenHandCursor
);
231 MAP_BUILTIN(PointerStyle::Hand
, Qt::OpenHandCursor
);
233 MAP_BUILTIN( PointerStyle::Pen
, GDK_PENCIL
);
235 MAP_BUILTIN(PointerStyle::HSplit
, Qt::SizeHorCursor
);
236 MAP_BUILTIN(PointerStyle::VSplit
, Qt::SizeVerCursor
);
238 MAP_BUILTIN(PointerStyle::Move
, Qt::SizeAllCursor
);
240 MAP_BUILTIN(PointerStyle::Null
, Qt::BlankCursor
);
241 MAKE_CURSOR(PointerStyle::Magnify
, magnify_
);
242 MAKE_CURSOR(PointerStyle::Fill
, fill_
);
243 MAKE_CURSOR(PointerStyle::MoveData
, movedata_
);
244 MAKE_CURSOR(PointerStyle::CopyData
, copydata_
);
245 MAKE_CURSOR(PointerStyle::MoveFile
, movefile_
);
246 MAKE_CURSOR(PointerStyle::CopyFile
, copyfile_
);
247 MAKE_CURSOR(PointerStyle::MoveFiles
, movefiles_
);
248 MAKE_CURSOR(PointerStyle::CopyFiles
, copyfiles_
);
249 MAKE_CURSOR(PointerStyle::NotAllowed
, nodrop_
);
250 MAKE_CURSOR(PointerStyle::Rotate
, rotate_
);
251 MAKE_CURSOR(PointerStyle::HShear
, hshear_
);
252 MAKE_CURSOR(PointerStyle::VShear
, vshear_
);
253 MAKE_CURSOR(PointerStyle::DrawLine
, drawline_
);
254 MAKE_CURSOR(PointerStyle::DrawRect
, drawrect_
);
255 MAKE_CURSOR(PointerStyle::DrawPolygon
, drawpolygon_
);
256 MAKE_CURSOR(PointerStyle::DrawBezier
, drawbezier_
);
257 MAKE_CURSOR(PointerStyle::DrawArc
, drawarc_
);
258 MAKE_CURSOR(PointerStyle::DrawPie
, drawpie_
);
259 MAKE_CURSOR(PointerStyle::DrawCircleCut
, drawcirclecut_
);
260 MAKE_CURSOR(PointerStyle::DrawEllipse
, drawellipse_
);
261 MAKE_CURSOR(PointerStyle::DrawConnect
, drawconnect_
);
262 MAKE_CURSOR(PointerStyle::DrawText
, drawtext_
);
263 MAKE_CURSOR(PointerStyle::Mirror
, mirror_
);
264 MAKE_CURSOR(PointerStyle::Crook
, crook_
);
265 MAKE_CURSOR(PointerStyle::Crop
, crop_
);
266 MAKE_CURSOR(PointerStyle::MovePoint
, movepoint_
);
267 MAKE_CURSOR(PointerStyle::MoveBezierWeight
, movebezierweight_
);
268 MAKE_CURSOR(PointerStyle::DrawFreehand
, drawfreehand_
);
269 MAKE_CURSOR(PointerStyle::DrawCaption
, drawcaption_
);
270 MAKE_CURSOR(PointerStyle::LinkData
, linkdata_
);
271 MAKE_CURSOR(PointerStyle::MoveDataLink
, movedlnk_
);
272 MAKE_CURSOR(PointerStyle::CopyDataLink
, copydlnk_
);
273 MAKE_CURSOR(PointerStyle::LinkFile
, linkfile_
);
274 MAKE_CURSOR(PointerStyle::MoveFileLink
, moveflnk_
);
275 MAKE_CURSOR(PointerStyle::CopyFileLink
, copyflnk_
);
276 MAKE_CURSOR(PointerStyle::Chart
, chart_
);
277 MAKE_CURSOR(PointerStyle::Detective
, detective_
);
278 MAKE_CURSOR(PointerStyle::PivotCol
, pivotcol_
);
279 MAKE_CURSOR(PointerStyle::PivotRow
, pivotrow_
);
280 MAKE_CURSOR(PointerStyle::PivotField
, pivotfld_
);
281 MAKE_CURSOR(PointerStyle::PivotDelete
, pivotdel_
);
282 MAKE_CURSOR(PointerStyle::Chain
, chain_
);
283 MAKE_CURSOR(PointerStyle::ChainNotAllowed
, chainnot_
);
284 MAKE_CURSOR(PointerStyle::AutoScrollN
, asn_
);
285 MAKE_CURSOR(PointerStyle::AutoScrollS
, ass_
);
286 MAKE_CURSOR(PointerStyle::AutoScrollW
, asw_
);
287 MAKE_CURSOR(PointerStyle::AutoScrollE
, ase_
);
288 MAKE_CURSOR(PointerStyle::AutoScrollNW
, asnw_
);
289 MAKE_CURSOR(PointerStyle::AutoScrollNE
, asne_
);
290 MAKE_CURSOR(PointerStyle::AutoScrollSW
, assw_
);
291 MAKE_CURSOR(PointerStyle::AutoScrollSE
, asse_
);
292 MAKE_CURSOR(PointerStyle::AutoScrollNS
, asns_
);
293 MAKE_CURSOR(PointerStyle::AutoScrollWE
, aswe_
);
294 MAKE_CURSOR(PointerStyle::AutoScrollNSWE
, asnswe_
);
295 MAKE_CURSOR(PointerStyle::TextVertical
, vertcurs_
);
297 MAKE_CURSOR(PointerStyle::TabSelectS
, tblsels_
);
298 MAKE_CURSOR(PointerStyle::TabSelectE
, tblsele_
);
299 MAKE_CURSOR(PointerStyle::TabSelectSE
, tblselse_
);
300 MAKE_CURSOR(PointerStyle::TabSelectW
, tblselw_
);
301 MAKE_CURSOR(PointerStyle::TabSelectSW
, tblselsw_
);
303 MAKE_CURSOR(PointerStyle::HideWhitespace
, hidewhitespace_
);
304 MAKE_CURSOR(PointerStyle::ShowWhitespace
, showwhitespace_
);
310 pCursor
= new QCursor(Qt::ArrowCursor
);
312 "pointer " << static_cast<int>(ePointerStyle
) << " not implemented");
315 m_aCursors
[ePointerStyle
].reset(pCursor
);
318 return *m_aCursors
[ePointerStyle
];
321 void Qt5Data::ErrorTrapPush() {}
323 bool Qt5Data::ErrorTrapPop(bool /*bIgnoreError*/) { return false; }
325 bool Qt5Data::noNativeControls()
327 static const bool bNoNative
328 = ((nullptr != getenv("SAL_VCL_QT5_NO_NATIVE")) && (nullptr != ImplGetSVData())
329 && ImplGetSVData()->maAppData
.mxToolkitName
330 && ImplGetSVData()->maAppData
.mxToolkitName
->match("qt5"));
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */