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 .
22 #include <QtCore/QRect>
23 #include <QtWidgets/QGestureEvent>
24 #include <QtWidgets/QWidget>
25 #include <rtl/ustring.hxx>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
33 struct SalAbstractMouseEvent
;
35 class QtWidget
: public QWidget
40 bool m_bNonEmptyIMPreeditSeen
;
41 mutable bool m_bInInputMethodQueryCursorRectangle
;
42 mutable QRect m_aImCursorRectangle
;
46 static void commitText(QtFrame
&, const QString
& aText
);
47 static void deleteReplacementText(QtFrame
& rFrame
, int nReplacementStart
,
48 int nReplacementLength
);
49 static bool handleGestureEvent(QtFrame
& rFrame
, QGestureEvent
* pGestureEvent
);
50 static bool handleKeyEvent(QtFrame
&, const QWidget
&, QKeyEvent
*);
51 static void handleMouseEnterLeaveEvents(const QtFrame
&, QEvent
*);
52 static void fillSalAbstractMouseEvent(const QtFrame
& rFrame
, const QInputEvent
* pQEvent
,
53 const QPoint
& rPos
, Qt::MouseButtons eButtons
, int nWidth
,
54 SalAbstractMouseEvent
& aSalEvent
);
56 virtual bool event(QEvent
*) override
;
58 virtual void focusInEvent(QFocusEvent
*) override
;
59 virtual void focusOutEvent(QFocusEvent
*) override
;
60 // keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment
61 virtual void keyReleaseEvent(QKeyEvent
*) override
;
62 virtual void mouseMoveEvent(QMouseEvent
*) override
;
63 virtual void mousePressEvent(QMouseEvent
*) override
;
64 virtual void mouseReleaseEvent(QMouseEvent
*) override
;
65 virtual void dragEnterEvent(QDragEnterEvent
*) override
;
66 virtual void dragLeaveEvent(QDragLeaveEvent
*) override
;
67 virtual void dragMoveEvent(QDragMoveEvent
*) override
;
68 virtual void dropEvent(QDropEvent
*) override
;
69 virtual void moveEvent(QMoveEvent
*) override
;
70 virtual void paintEvent(QPaintEvent
*) override
;
71 virtual void resizeEvent(QResizeEvent
*) override
;
72 virtual void showEvent(QShowEvent
*) override
;
73 virtual void hideEvent(QHideEvent
*) override
;
74 virtual void wheelEvent(QWheelEvent
*) override
;
75 virtual void closeEvent(QCloseEvent
*) override
;
76 virtual void changeEvent(QEvent
*) override
;
77 virtual void leaveEvent(QEvent
*) override
;
78 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
79 virtual void enterEvent(QEnterEvent
*) override
;
81 virtual void enterEvent(QEvent
*) override
;
84 void inputMethodEvent(QInputMethodEvent
*) override
;
85 QVariant
inputMethodQuery(Qt::InputMethodQuery
) const override
;
86 static void closePopup();
89 QtWidget(QtFrame
& rFrame
, Qt::WindowFlags f
= Qt::WindowFlags());
91 QtFrame
& frame() const { return m_rFrame
; }
92 void endExtTextInput();
95 static bool handleEvent(QtFrame
&, QWidget
&, QEvent
*);
96 // key events might be propagated further down => call base on false
97 static inline bool handleKeyReleaseEvent(QtFrame
&, const QWidget
&, QKeyEvent
*);
98 // mouse events are always accepted
99 static void handleMouseButtonEvent(const QtFrame
&, const QMouseEvent
*);
102 bool QtWidget::handleKeyReleaseEvent(QtFrame
& rFrame
, const QWidget
& rWidget
, QKeyEvent
* pEvent
)
104 return handleKeyEvent(rFrame
, rWidget
, pEvent
);
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */