Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhaikucursor.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qhaikucursor.h"
5
7
8#include <Cursor.h>
9
10QHaikuCursor::QHaikuCursor()
11{
12 m_cursorIds.insert(Qt::ArrowCursor, B_CURSOR_ID_SYSTEM_DEFAULT);
13 m_cursorIds.insert(Qt::UpArrowCursor, B_CURSOR_ID_RESIZE_NORTH);
14 m_cursorIds.insert(Qt::CrossCursor, B_CURSOR_ID_CROSS_HAIR);
15 m_cursorIds.insert(Qt::WaitCursor, B_CURSOR_ID_PROGRESS);
16 m_cursorIds.insert(Qt::IBeamCursor, B_CURSOR_ID_I_BEAM);
17 m_cursorIds.insert(Qt::SizeVerCursor, B_CURSOR_ID_RESIZE_NORTH_SOUTH);
18 m_cursorIds.insert(Qt::SizeHorCursor, B_CURSOR_ID_RESIZE_EAST_WEST);
19 m_cursorIds.insert(Qt::SizeBDiagCursor, B_CURSOR_ID_RESIZE_NORTH_EAST_SOUTH_WEST);
20 m_cursorIds.insert(Qt::SizeFDiagCursor, B_CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST);
21 m_cursorIds.insert(Qt::SizeAllCursor, B_CURSOR_ID_MOVE);
22 m_cursorIds.insert(Qt::BlankCursor, B_CURSOR_ID_NO_CURSOR);
23 m_cursorIds.insert(Qt::SplitVCursor, B_CURSOR_ID_RESIZE_NORTH_SOUTH);
24 m_cursorIds.insert(Qt::SplitHCursor, B_CURSOR_ID_RESIZE_EAST_WEST);
25 m_cursorIds.insert(Qt::PointingHandCursor, B_CURSOR_ID_FOLLOW_LINK);
26 m_cursorIds.insert(Qt::ForbiddenCursor, B_CURSOR_ID_NOT_ALLOWED);
27 m_cursorIds.insert(Qt::OpenHandCursor, B_CURSOR_ID_GRAB);
28 m_cursorIds.insert(Qt::ClosedHandCursor, B_CURSOR_ID_GRABBING);
29 m_cursorIds.insert(Qt::WhatsThisCursor, B_CURSOR_ID_HELP);
30 m_cursorIds.insert(Qt::BusyCursor, B_CURSOR_ID_PROGRESS);
31}
32
33#ifndef QT_NO_CURSOR
34void QHaikuCursor::changeCursor(QCursor *windowCursor, QWindow *window)
35{
36 if (!window)
37 return;
38
39 BWindow *haikuWindow = reinterpret_cast<BWindow*>(window->winId());
40
41 // We expect that every BWindow has exactly one BView as child,
42 // so we can use CurrentFocus to retrieve it and call SetViewCursor
43 // to change the cursor for the whole window.
44 if (!windowCursor) {
45 BView *view = haikuWindow->CurrentFocus();
46 if (view) {
47 view->SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
48 }
49 } else {
50 const Qt::CursorShape shape = windowCursor->shape();
51 if (!m_cursors.contains(shape))
52 m_cursors.insert(shape, new BCursor(m_cursorIds.value(shape)));
53
54 BView *view = haikuWindow->CurrentFocus();
55 if (view) {
56 view->LockLooper();
57 view->SetViewCursor(m_cursors.value(shape));
58 view->UnlockLooper();
59 }
60 }
61}
62#endif