1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QACCESSIBLEMENU_H |
5 | #define QACCESSIBLEMENU_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtWidgets/private/qtwidgetsglobal_p.h> |
19 | #include <QtWidgets/qaccessiblewidget.h> |
20 | #include <QtCore/qpointer.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | #if QT_CONFIG(accessibility) |
25 | |
26 | #if QT_CONFIG(menu) |
27 | class QMenu; |
28 | class QMenuBar; |
29 | class QAction; |
30 | |
31 | class QAccessibleMenu : public QAccessibleWidget |
32 | { |
33 | public: |
34 | explicit QAccessibleMenu(QWidget *w); |
35 | |
36 | int childCount() const override; |
37 | QAccessibleInterface *childAt(int x, int y) const override; |
38 | |
39 | QString text(QAccessible::Text t) const override; |
40 | QAccessible::Role role() const override; |
41 | QAccessibleInterface *child(int index) const override; |
42 | QAccessibleInterface *parent() const override; |
43 | int indexOfChild( const QAccessibleInterface *child ) const override; |
44 | |
45 | protected: |
46 | QMenu *menu() const; |
47 | }; |
48 | |
49 | #if QT_CONFIG(menubar) |
50 | class QAccessibleMenuBar : public QAccessibleWidget |
51 | { |
52 | public: |
53 | explicit QAccessibleMenuBar(QWidget *w); |
54 | |
55 | QAccessibleInterface *child(int index) const override; |
56 | int childCount() const override; |
57 | |
58 | int indexOfChild(const QAccessibleInterface *child) const override; |
59 | |
60 | protected: |
61 | QMenuBar *menuBar() const; |
62 | }; |
63 | #endif // QT_CONFIG(menubar) |
64 | |
65 | |
66 | class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActionInterface |
67 | { |
68 | public: |
69 | explicit QAccessibleMenuItem(QWidget *owner, QAction *w); |
70 | |
71 | ~QAccessibleMenuItem(); |
72 | void *interface_cast(QAccessible::InterfaceType t) override; |
73 | |
74 | int childCount() const override; |
75 | QAccessibleInterface *childAt(int x, int y) const override; |
76 | bool isValid() const override; |
77 | int indexOfChild(const QAccessibleInterface * child) const override; |
78 | |
79 | QAccessibleInterface *parent() const override; |
80 | QAccessibleInterface *child(int index) const override; |
81 | QObject * object() const override; |
82 | QWindow *window() const override; |
83 | |
84 | QRect rect() const override; |
85 | QAccessible::Role role() const override; |
86 | void setText(QAccessible::Text t, const QString & text) override; |
87 | QAccessible::State state() const override; |
88 | QString text(QAccessible::Text t) const override; |
89 | |
90 | // QAccessibleActionInterface |
91 | QStringList actionNames() const override; |
92 | void doAction(const QString &actionName) override; |
93 | QStringList keyBindingsForAction(const QString &actionName) const override; |
94 | |
95 | QWidget *owner() const; |
96 | protected: |
97 | QAction *action() const; |
98 | private: |
99 | QAction *m_action; |
100 | QPointer<QWidget> m_owner; // can hold either QMenu or the QMenuBar that contains the action |
101 | }; |
102 | |
103 | #endif // QT_CONFIG(menu) |
104 | |
105 | QT_END_NAMESPACE |
106 | #endif // QT_CONFIG(accessibility) |
107 | #endif // QACCESSIBLEMENU_H |
108 |