bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / qt5 / Qt5Widget.hxx
blob159794b2d2a3bf6a54fb9f5054ae8804f32e4931
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
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>
28 class Qt5Frame;
29 class Qt5Object;
31 class Qt5Widget : public QWidget
33 Q_OBJECT
35 Qt5Frame& m_rFrame;
36 bool m_bNonEmptyIMPreeditSeen;
37 int m_nDeltaX;
38 int m_nDeltaY;
40 enum class ButtonKeyState
42 Pressed,
43 Released
46 static void commitText(Qt5Frame&, const QString& aText);
47 static bool handleKeyEvent(Qt5Frame&, const QWidget&, QKeyEvent*, const ButtonKeyState);
48 static void handleMouseButtonEvent(const Qt5Frame&, const QMouseEvent*, const ButtonKeyState);
50 virtual bool event(QEvent*) override;
52 virtual void focusInEvent(QFocusEvent*) override;
53 virtual void focusOutEvent(QFocusEvent*) override;
54 // keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment
55 virtual void keyReleaseEvent(QKeyEvent*) override;
56 virtual void mouseMoveEvent(QMouseEvent*) override;
57 virtual void mousePressEvent(QMouseEvent*) override;
58 virtual void mouseReleaseEvent(QMouseEvent*) override;
59 virtual void dragEnterEvent(QDragEnterEvent*) override;
60 virtual void dragLeaveEvent(QDragLeaveEvent*) override;
61 virtual void dragMoveEvent(QDragMoveEvent*) override;
62 virtual void dropEvent(QDropEvent*) override;
63 virtual void moveEvent(QMoveEvent*) override;
64 virtual void paintEvent(QPaintEvent*) override;
65 virtual void resizeEvent(QResizeEvent*) override;
66 virtual void showEvent(QShowEvent*) override;
67 virtual void wheelEvent(QWheelEvent*) override;
68 virtual void closeEvent(QCloseEvent*) override;
69 virtual void changeEvent(QEvent*) override;
71 void inputMethodEvent(QInputMethodEvent*) override;
72 QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
74 public:
75 Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
77 Qt5Frame& frame() const { return m_rFrame; }
78 void endExtTextInput();
80 static bool handleEvent(Qt5Frame&, const QWidget&, QEvent*);
81 // key events might be propagated further down => call base on false
82 static inline bool handleKeyReleaseEvent(Qt5Frame&, const QWidget&, QKeyEvent*);
83 // mouse events are always accepted
84 static inline void handleMousePressEvent(const Qt5Frame&, const QMouseEvent*);
85 static inline void handleMouseReleaseEvent(const Qt5Frame&, const QMouseEvent*);
88 bool Qt5Widget::handleKeyReleaseEvent(Qt5Frame& rFrame, const QWidget& rWidget, QKeyEvent* pEvent)
90 return handleKeyEvent(rFrame, rWidget, pEvent, ButtonKeyState::Released);
93 void Qt5Widget::handleMousePressEvent(const Qt5Frame& rFrame, const QMouseEvent* pEvent)
95 handleMouseButtonEvent(rFrame, pEvent, ButtonKeyState::Pressed);
98 void Qt5Widget::handleMouseReleaseEvent(const Qt5Frame& rFrame, const QMouseEvent* pEvent)
100 handleMouseButtonEvent(rFrame, pEvent, ButtonKeyState::Released);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */