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 <QtWidgets/QWidget>
23 #include <rtl/ustring.hxx>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
31 struct SalAbstractMouseEvent
;
33 class Qt5Widget
: public QWidget
38 bool m_bNonEmptyIMPreeditSeen
;
42 enum class ButtonKeyState
48 static void commitText(Qt5Frame
&, const QString
& aText
);
49 static bool handleKeyEvent(Qt5Frame
&, const QWidget
&, QKeyEvent
*, const ButtonKeyState
);
50 static void handleMouseButtonEvent(const Qt5Frame
&, const QMouseEvent
*, const ButtonKeyState
);
51 static void fillSalAbstractMouseEvent(const Qt5Frame
& rFrame
, const QInputEvent
* pQEvent
,
52 const QPoint
& rPos
, Qt::MouseButtons eButtons
, int nWidth
,
53 SalAbstractMouseEvent
& aSalEvent
);
55 virtual bool event(QEvent
*) override
;
57 virtual void focusInEvent(QFocusEvent
*) override
;
58 virtual void focusOutEvent(QFocusEvent
*) override
;
59 // keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment
60 virtual void keyReleaseEvent(QKeyEvent
*) override
;
61 virtual void mouseMoveEvent(QMouseEvent
*) override
;
62 virtual void mousePressEvent(QMouseEvent
*) override
;
63 virtual void mouseReleaseEvent(QMouseEvent
*) override
;
64 virtual void dragEnterEvent(QDragEnterEvent
*) override
;
65 virtual void dragLeaveEvent(QDragLeaveEvent
*) override
;
66 virtual void dragMoveEvent(QDragMoveEvent
*) override
;
67 virtual void dropEvent(QDropEvent
*) override
;
68 virtual void moveEvent(QMoveEvent
*) override
;
69 virtual void paintEvent(QPaintEvent
*) override
;
70 virtual void resizeEvent(QResizeEvent
*) override
;
71 virtual void showEvent(QShowEvent
*) override
;
72 virtual void wheelEvent(QWheelEvent
*) override
;
73 virtual void closeEvent(QCloseEvent
*) override
;
74 virtual void changeEvent(QEvent
*) override
;
76 void inputMethodEvent(QInputMethodEvent
*) override
;
77 QVariant
inputMethodQuery(Qt::InputMethodQuery
) const override
;
80 Qt5Widget(Qt5Frame
& rFrame
, Qt::WindowFlags f
= Qt::WindowFlags());
82 Qt5Frame
& frame() const { return m_rFrame
; }
83 void endExtTextInput();
85 static bool handleEvent(Qt5Frame
&, const QWidget
&, QEvent
*);
86 // key events might be propagated further down => call base on false
87 static inline bool handleKeyReleaseEvent(Qt5Frame
&, const QWidget
&, QKeyEvent
*);
88 // mouse events are always accepted
89 static inline void handleMousePressEvent(const Qt5Frame
&, const QMouseEvent
*);
90 static inline void handleMouseReleaseEvent(const Qt5Frame
&, const QMouseEvent
*);
93 bool Qt5Widget::handleKeyReleaseEvent(Qt5Frame
& rFrame
, const QWidget
& rWidget
, QKeyEvent
* pEvent
)
95 return handleKeyEvent(rFrame
, rWidget
, pEvent
, ButtonKeyState::Released
);
98 void Qt5Widget::handleMousePressEvent(const Qt5Frame
& rFrame
, const QMouseEvent
* pEvent
)
100 handleMouseButtonEvent(rFrame
, pEvent
, ButtonKeyState::Pressed
);
103 void Qt5Widget::handleMouseReleaseEvent(const Qt5Frame
& rFrame
, const QMouseEvent
* pEvent
)
105 handleMouseButtonEvent(rFrame
, pEvent
, ButtonKeyState::Released
);
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */