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 QACCESSIBLEWIDGETS_H
41#define QACCESSIBLEWIDGETS_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 <QtWidgets/qaccessiblewidget.h>
56
57#ifndef QT_NO_ACCESSIBILITY
58
59#include <QtCore/QPointer>
60#include <QtCore/QPair>
61
62QT_BEGIN_NAMESPACE
63
64class QTextEdit;
65class QStackedWidget;
66class QToolBox;
67class QMdiArea;
68class QMdiSubWindow;
69class QRubberBand;
70class QTextBrowser;
71class QCalendarWidget;
72class QAbstractItemView;
73class QDockWidget;
74class QDockWidgetLayout;
75class QMainWindow;
76class QPlainTextEdit;
77class QTextCursor;
78class QTextDocument;
79
80#ifndef QT_NO_CURSOR
81class QAccessibleTextWidget : public QAccessibleWidget,
82 public QAccessibleTextInterface,
83 public QAccessibleEditableTextInterface
84{
85public:
86 QAccessibleTextWidget(QWidget *o, QAccessible::Role r = QAccessible::EditableText, const QString &name = QString());
87
88 QAccessible::State state() const override;
89
90 // QAccessibleTextInterface
91 // selection
92 void selection(int selectionIndex, int *startOffset, int *endOffset) const override;
93 int selectionCount() const override;
94 void addSelection(int startOffset, int endOffset) override;
95 void removeSelection(int selectionIndex) override;
96 void setSelection(int selectionIndex, int startOffset, int endOffset) override;
97
98 // cursor
99 int cursorPosition() const override;
100 void setCursorPosition(int position) override;
101
102 // text
103 QString text(int startOffset, int endOffset) const override;
104 QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,
105 int *startOffset, int *endOffset) const override;
106 QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
107 int *startOffset, int *endOffset) const override;
108 QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
109 int *startOffset, int *endOffset) const override;
110 int characterCount() const override;
111
112 // character <-> geometry
113 QRect characterRect(int offset) const override;
114 int offsetAtPoint(const QPoint &point) const override;
115
116 QString attributes(int offset, int *startOffset, int *endOffset) const override;
117
118 // QAccessibleEditableTextInterface
119 void deleteText(int startOffset, int endOffset) override;
120 void insertText(int offset, const QString &text) override;
121 void replaceText(int startOffset, int endOffset, const QString &text) override;
122
123 using QAccessibleWidget::text;
124
125protected:
126 QTextCursor textCursorForRange(int startOffset, int endOffset) const;
127 virtual QPoint scrollBarPosition() const;
128 // return the current text cursor at the caret position including a potential selection
129 virtual QTextCursor textCursor() const = 0;
130 virtual void setTextCursor(const QTextCursor &) = 0;
131 virtual QTextDocument *textDocument() const = 0;
132 virtual QWidget *viewport() const = 0;
133};
134
135#if QT_CONFIG(textedit)
136class QAccessiblePlainTextEdit : public QAccessibleTextWidget
137{
138public:
139 explicit QAccessiblePlainTextEdit(QWidget *o);
140
141 QString text(QAccessible::Text t) const override;
142 void setText(QAccessible::Text t, const QString &text) override;
143 QAccessible::State state() const override;
144
145 void *interface_cast(QAccessible::InterfaceType t) override;
146
147 // QAccessibleTextInterface
148 void scrollToSubstring(int startIndex, int endIndex) override;
149
150 using QAccessibleTextWidget::text;
151
152protected:
153 QPlainTextEdit *plainTextEdit() const;
154
155 QPoint scrollBarPosition() const override;
156 QTextCursor textCursor() const override;
157 void setTextCursor(const QTextCursor &textCursor) override;
158 QTextDocument *textDocument() const override;
159 QWidget *viewport() const override;
160};
161
162class QAccessibleTextEdit : public QAccessibleTextWidget
163{
164public:
165 explicit QAccessibleTextEdit(QWidget *o);
166
167 QString text(QAccessible::Text t) const override;
168 void setText(QAccessible::Text t, const QString &text) override;
169 QAccessible::State state() const override;
170
171 void *interface_cast(QAccessible::InterfaceType t) override;
172
173 // QAccessibleTextInterface
174 void scrollToSubstring(int startIndex, int endIndex) override;
175
176 using QAccessibleTextWidget::text;
177
178protected:
179 QTextEdit *textEdit() const;
180
181 QPoint scrollBarPosition() const override;
182 QTextCursor textCursor() const override;
183 void setTextCursor(const QTextCursor &textCursor) override;
184 QTextDocument *textDocument() const override;
185 QWidget *viewport() const override;
186};
187#endif // QT_CONFIG(textedit)
188#endif //QT_NO_CURSOR
189
190class QAccessibleStackedWidget : public QAccessibleWidget
191{
192public:
193 explicit QAccessibleStackedWidget(QWidget *widget);
194
195 QAccessibleInterface *childAt(int x, int y) const override;
196 int childCount() const override;
197 int indexOfChild(const QAccessibleInterface *child) const override;
198 QAccessibleInterface *child(int index) const override;
199
200protected:
201 QStackedWidget *stackedWidget() const;
202};
203
204class QAccessibleToolBox : public QAccessibleWidget
205{
206public:
207 explicit QAccessibleToolBox(QWidget *widget);
208
209// FIXME we currently expose the toolbox but it is not keyboard navigatable
210// and the accessible hierarchy is not exactly beautiful.
211// int childCount() const;
212// QAccessibleInterface *child(int index) const;
213// int indexOfChild(const QAccessibleInterface *child) const;
214
215protected:
216 QToolBox *toolBox() const;
217};
218
219#if QT_CONFIG(mdiarea)
220class QAccessibleMdiArea : public QAccessibleWidget
221{
222public:
223 explicit QAccessibleMdiArea(QWidget *widget);
224
225 int childCount() const override;
226 QAccessibleInterface *child(int index) const override;
227 int indexOfChild(const QAccessibleInterface *child) const override;
228
229protected:
230 QMdiArea *mdiArea() const;
231};
232
233class QAccessibleMdiSubWindow : public QAccessibleWidget
234{
235public:
236 explicit QAccessibleMdiSubWindow(QWidget *widget);
237
238 QString text(QAccessible::Text textType) const override;
239 void setText(QAccessible::Text textType, const QString &text) override;
240 QAccessible::State state() const override;
241 int childCount() const override;
242 QAccessibleInterface *child(int index) const override;
243 int indexOfChild(const QAccessibleInterface *child) const override;
244 QRect rect() const override;
245
246protected:
247 QMdiSubWindow *mdiSubWindow() const;
248};
249#endif // QT_CONFIG(mdiarea)
250
251#if QT_CONFIG(dialogbuttonbox)
252class QAccessibleDialogButtonBox : public QAccessibleWidget
253{
254public:
255 explicit QAccessibleDialogButtonBox(QWidget *widget);
256};
257#endif
258
259#if QT_CONFIG(textbrowser) && !defined(QT_NO_CURSOR)
260class QAccessibleTextBrowser : public QAccessibleTextEdit
261{
262public:
263 explicit QAccessibleTextBrowser(QWidget *widget);
264
265 QAccessible::Role role() const override;
266};
267#endif // QT_CONFIG(textbrowser) && QT_NO_CURSOR
268
269#if QT_CONFIG(calendarwidget)
270class QAccessibleCalendarWidget : public QAccessibleWidget
271{
272public:
273 explicit QAccessibleCalendarWidget(QWidget *widget);
274
275 int childCount() const override;
276 int indexOfChild(const QAccessibleInterface *child) const override;
277
278 QAccessibleInterface *child(int index) const override;
279
280protected:
281 QCalendarWidget *calendarWidget() const;
282
283private:
284 QAbstractItemView *calendarView() const;
285 QWidget *navigationBar() const;
286};
287#endif // QT_CONFIG(calendarwidget)
288
289#if QT_CONFIG(dockwidget)
290class QAccessibleDockWidget: public QAccessibleWidget
291{
292public:
293 explicit QAccessibleDockWidget(QWidget *widget);
294 QAccessibleInterface *child(int index) const override;
295 int indexOfChild(const QAccessibleInterface *child) const override;
296 int childCount() const override;
297 QRect rect () const override;
298 QString text(QAccessible::Text t) const override;
299
300 QDockWidget *dockWidget() const;
301protected:
302 QDockWidgetLayout *dockWidgetLayout() const;
303};
304
305#endif // QT_CONFIG(dockwidget)
306
307#if QT_CONFIG(mainwindow)
308class QAccessibleMainWindow : public QAccessibleWidget
309{
310public:
311 explicit QAccessibleMainWindow(QWidget *widget);
312
313 QAccessibleInterface *child(int index) const override;
314 int childCount() const override;
315 int indexOfChild(const QAccessibleInterface *iface) const override;
316 QAccessibleInterface *childAt(int x, int y) const override;
317 QMainWindow *mainWindow() const;
318
319};
320#endif // QT_CONFIG(mainwindow)
321
322#endif // QT_NO_ACCESSIBILITY
323
324QT_END_NAMESPACE
325
326#endif // QACESSIBLEWIDGETS_H
327

source code of qtbase/src/widgets/accessible/qaccessiblewidgets_p.h