1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef SIMPLEWIDGETS_H
41#define SIMPLEWIDGETS_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtWidgets/private/qtwidgetsglobal_p.h>
55#include <QtCore/qcoreapplication.h>
56#include <QtWidgets/qaccessiblewidget.h>
57
58QT_BEGIN_NAMESPACE
59
60#ifndef QT_NO_ACCESSIBILITY
61
62class QAbstractButton;
63class QLineEdit;
64class QToolButton;
65class QGroupBox;
66class QProgressBar;
67
68#if QT_CONFIG(abstractbutton)
69class QAccessibleButton : public QAccessibleWidget
70{
71 Q_DECLARE_TR_FUNCTIONS(QAccessibleButton)
72public:
73 QAccessibleButton(QWidget *w);
74
75 QString text(QAccessible::Text t) const override;
76 QAccessible::State state() const override;
77 QRect rect() const override;
78 QAccessible::Role role() const override;
79
80 QStringList actionNames() const override;
81 void doAction(const QString &actionName) override;
82 QStringList keyBindingsForAction(const QString &actionName) const override;
83
84protected:
85 QAbstractButton *button() const;
86};
87#endif
88
89#if QT_CONFIG(toolbutton)
90class QAccessibleToolButton : public QAccessibleButton
91{
92public:
93 QAccessibleToolButton(QWidget *w);
94
95 QAccessible::State state() const override;
96 QAccessible::Role role() const override;
97
98 int childCount() const override;
99 QAccessibleInterface *child(int index) const override;
100
101 // QAccessibleActionInterface
102 QStringList actionNames() const override;
103 void doAction(const QString &actionName) override;
104
105protected:
106 QToolButton *toolButton() const;
107
108 bool isSplitButton() const;
109};
110#endif // QT_CONFIG(toolbutton)
111
112class QAccessibleDisplay : public QAccessibleWidget, public QAccessibleImageInterface
113{
114public:
115 explicit QAccessibleDisplay(QWidget *w, QAccessible::Role role = QAccessible::StaticText);
116
117 QString text(QAccessible::Text t) const override;
118 QAccessible::Role role() const override;
119 QAccessible::State state() const override;
120
121 QList<QPair<QAccessibleInterface *, QAccessible::Relation>>
122 relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
123 void *interface_cast(QAccessible::InterfaceType t) override;
124
125 // QAccessibleImageInterface
126 QString imageDescription() const override;
127 QSize imageSize() const override;
128 QPoint imagePosition() const override;
129};
130
131#if QT_CONFIG(groupbox)
132class QAccessibleGroupBox : public QAccessibleWidget
133{
134public:
135 explicit QAccessibleGroupBox(QWidget *w);
136
137 QAccessible::State state() const override;
138 QAccessible::Role role() const override;
139 QString text(QAccessible::Text t) const override;
140
141 QList<QPair<QAccessibleInterface *, QAccessible::Relation>>
142 relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
143
144 //QAccessibleActionInterface
145 QStringList actionNames() const override;
146 void doAction(const QString &actionName) override;
147 QStringList keyBindingsForAction(const QString &) const override;
148
149private:
150 QGroupBox *groupBox() const;
151};
152#endif
153
154#if QT_CONFIG(lineedit)
155class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface, public QAccessibleEditableTextInterface
156{
157public:
158 explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString());
159
160 QString text(QAccessible::Text t) const override;
161 void setText(QAccessible::Text t, const QString &text) override;
162 QAccessible::State state() const override;
163 void *interface_cast(QAccessible::InterfaceType t) override;
164
165 // QAccessibleTextInterface
166 void addSelection(int startOffset, int endOffset) override;
167 QString attributes(int offset, int *startOffset, int *endOffset) const override;
168 int cursorPosition() const override;
169 QRect characterRect(int offset) const override;
170 int selectionCount() const override;
171 int offsetAtPoint(const QPoint &point) const override;
172 void selection(int selectionIndex, int *startOffset, int *endOffset) const override;
173 QString text(int startOffset, int endOffset) const override;
174 QString textBeforeOffset (int offset, QAccessible::TextBoundaryType boundaryType,
175 int *startOffset, int *endOffset) const override;
176 QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
177 int *startOffset, int *endOffset) const override;
178 QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
179 int *startOffset, int *endOffset) const override;
180 void removeSelection(int selectionIndex) override;
181 void setCursorPosition(int position) override;
182 void setSelection(int selectionIndex, int startOffset, int endOffset) override;
183 int characterCount() const override;
184 void scrollToSubstring(int startIndex, int endIndex) override;
185
186 // QAccessibleEditableTextInterface
187 void deleteText(int startOffset, int endOffset) override;
188 void insertText(int offset, const QString &text) override;
189 void replaceText(int startOffset, int endOffset, const QString &text) override;
190protected:
191 QLineEdit *lineEdit() const;
192 friend class QAccessibleAbstractSpinBox;
193};
194#endif // QT_CONFIG(lineedit)
195
196#if QT_CONFIG(progressbar)
197class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValueInterface
198{
199public:
200 explicit QAccessibleProgressBar(QWidget *o);
201 void *interface_cast(QAccessible::InterfaceType t) override;
202
203 // QAccessibleValueInterface
204 QVariant currentValue() const override;
205 QVariant maximumValue() const override;
206 QVariant minimumValue() const override;
207 QVariant minimumStepSize() const override;
208 void setCurrentValue(const QVariant &) override {}
209
210protected:
211 QProgressBar *progressBar() const;
212};
213#endif
214
215class QWindowContainer;
216class QAccessibleWindowContainer : public QAccessibleWidget
217{
218public:
219 QAccessibleWindowContainer(QWidget *w);
220 int childCount() const override;
221 int indexOfChild(const QAccessibleInterface *child) const override;
222 QAccessibleInterface *child(int i) const override;
223
224private:
225 QWindowContainer *container() const;
226};
227
228#endif // QT_NO_ACCESSIBILITY
229
230QT_END_NAMESPACE
231
232#endif // SIMPLEWIDGETS_H
233