| 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 SIMPLEWIDGETS_H |
| 5 | #define SIMPLEWIDGETS_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 <QtCore/qcoreapplication.h> |
| 20 | #include <QtWidgets/qaccessiblewidget.h> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | #if QT_CONFIG(accessibility) |
| 25 | |
| 26 | class QAbstractButton; |
| 27 | class QLineEdit; |
| 28 | class QToolButton; |
| 29 | class QGroupBox; |
| 30 | class QMessageBox; |
| 31 | class QProgressBar; |
| 32 | |
| 33 | #if QT_CONFIG(abstractbutton) |
| 34 | class QAccessibleButton : public QAccessibleWidget |
| 35 | { |
| 36 | Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) |
| 37 | public: |
| 38 | QAccessibleButton(QWidget *w); |
| 39 | |
| 40 | QString text(QAccessible::Text t) const override; |
| 41 | QAccessible::State state() const override; |
| 42 | QRect rect() const override; |
| 43 | QAccessible::Role role() const override; |
| 44 | |
| 45 | QStringList actionNames() const override; |
| 46 | void doAction(const QString &actionName) override; |
| 47 | QStringList keyBindingsForAction(const QString &actionName) const override; |
| 48 | |
| 49 | protected: |
| 50 | QAbstractButton *button() const; |
| 51 | }; |
| 52 | #endif |
| 53 | |
| 54 | #if QT_CONFIG(toolbutton) |
| 55 | class QAccessibleToolButton : public QAccessibleButton |
| 56 | { |
| 57 | public: |
| 58 | QAccessibleToolButton(QWidget *w); |
| 59 | |
| 60 | QAccessible::State state() const override; |
| 61 | QAccessible::Role role() const override; |
| 62 | |
| 63 | int childCount() const override; |
| 64 | QAccessibleInterface *child(int index) const override; |
| 65 | |
| 66 | // QAccessibleActionInterface |
| 67 | QStringList actionNames() const override; |
| 68 | void doAction(const QString &actionName) override; |
| 69 | |
| 70 | protected: |
| 71 | QToolButton *toolButton() const; |
| 72 | |
| 73 | bool isSplitButton() const; |
| 74 | }; |
| 75 | #endif // QT_CONFIG(toolbutton) |
| 76 | |
| 77 | class QAccessibleDisplay : public QAccessibleWidget, public QAccessibleImageInterface |
| 78 | { |
| 79 | public: |
| 80 | explicit QAccessibleDisplay(QWidget *w, QAccessible::Role role = QAccessible::StaticText); |
| 81 | |
| 82 | QString text(QAccessible::Text t) const override; |
| 83 | QAccessible::Role role() const override; |
| 84 | QAccessible::State state() const override; |
| 85 | |
| 86 | QList<std::pair<QAccessibleInterface *, QAccessible::Relation>> |
| 87 | relations(QAccessible::Relation match = QAccessible::AllRelations) const override; |
| 88 | void *interface_cast(QAccessible::InterfaceType t) override; |
| 89 | |
| 90 | // QAccessibleImageInterface |
| 91 | QString imageDescription() const override; |
| 92 | QSize imageSize() const override; |
| 93 | QPoint imagePosition() const override; |
| 94 | }; |
| 95 | |
| 96 | #if QT_CONFIG(groupbox) |
| 97 | class QAccessibleGroupBox : public QAccessibleWidget |
| 98 | { |
| 99 | public: |
| 100 | explicit QAccessibleGroupBox(QWidget *w); |
| 101 | |
| 102 | QAccessible::State state() const override; |
| 103 | QAccessible::Role role() const override; |
| 104 | QString text(QAccessible::Text t) const override; |
| 105 | |
| 106 | QList<std::pair<QAccessibleInterface *, QAccessible::Relation>> |
| 107 | relations(QAccessible::Relation match = QAccessible::AllRelations) const override; |
| 108 | |
| 109 | //QAccessibleActionInterface |
| 110 | QStringList actionNames() const override; |
| 111 | void doAction(const QString &actionName) override; |
| 112 | QStringList keyBindingsForAction(const QString &) const override; |
| 113 | |
| 114 | private: |
| 115 | QGroupBox *groupBox() const; |
| 116 | }; |
| 117 | #endif |
| 118 | |
| 119 | #if QT_CONFIG(lineedit) |
| 120 | class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface, public QAccessibleEditableTextInterface |
| 121 | { |
| 122 | public: |
| 123 | explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString()); |
| 124 | |
| 125 | QString text(QAccessible::Text t) const override; |
| 126 | void setText(QAccessible::Text t, const QString &text) override; |
| 127 | QAccessible::State state() const override; |
| 128 | void *interface_cast(QAccessible::InterfaceType t) override; |
| 129 | |
| 130 | // QAccessibleTextInterface |
| 131 | void addSelection(int startOffset, int endOffset) override; |
| 132 | QString attributes(int offset, int *startOffset, int *endOffset) const override; |
| 133 | int cursorPosition() const override; |
| 134 | QRect characterRect(int offset) const override; |
| 135 | int selectionCount() const override; |
| 136 | int offsetAtPoint(const QPoint &point) const override; |
| 137 | void selection(int selectionIndex, int *startOffset, int *endOffset) const override; |
| 138 | QString text(int startOffset, int endOffset) const override; |
| 139 | QString textBeforeOffset (int offset, QAccessible::TextBoundaryType boundaryType, |
| 140 | int *startOffset, int *endOffset) const override; |
| 141 | QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, |
| 142 | int *startOffset, int *endOffset) const override; |
| 143 | QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, |
| 144 | int *startOffset, int *endOffset) const override; |
| 145 | void removeSelection(int selectionIndex) override; |
| 146 | void setCursorPosition(int position) override; |
| 147 | void setSelection(int selectionIndex, int startOffset, int endOffset) override; |
| 148 | int characterCount() const override; |
| 149 | void scrollToSubstring(int startIndex, int endIndex) override; |
| 150 | |
| 151 | // QAccessibleEditableTextInterface |
| 152 | void deleteText(int startOffset, int endOffset) override; |
| 153 | void insertText(int offset, const QString &text) override; |
| 154 | void replaceText(int startOffset, int endOffset, const QString &text) override; |
| 155 | protected: |
| 156 | QLineEdit *lineEdit() const; |
| 157 | friend class QAccessibleAbstractSpinBox; |
| 158 | }; |
| 159 | #endif // QT_CONFIG(lineedit) |
| 160 | |
| 161 | #if QT_CONFIG(progressbar) |
| 162 | class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValueInterface |
| 163 | { |
| 164 | public: |
| 165 | explicit QAccessibleProgressBar(QWidget *o); |
| 166 | void *interface_cast(QAccessible::InterfaceType t) override; |
| 167 | |
| 168 | // QAccessibleValueInterface |
| 169 | QVariant currentValue() const override; |
| 170 | QVariant maximumValue() const override; |
| 171 | QVariant minimumValue() const override; |
| 172 | QVariant minimumStepSize() const override; |
| 173 | void setCurrentValue(const QVariant &) override {} |
| 174 | |
| 175 | protected: |
| 176 | QProgressBar *progressBar() const; |
| 177 | }; |
| 178 | #endif |
| 179 | |
| 180 | class QWindowContainer; |
| 181 | class QAccessibleWindowContainer : public QAccessibleWidget |
| 182 | { |
| 183 | public: |
| 184 | QAccessibleWindowContainer(QWidget *w); |
| 185 | int childCount() const override; |
| 186 | int indexOfChild(const QAccessibleInterface *child) const override; |
| 187 | QAccessibleInterface *child(int i) const override; |
| 188 | |
| 189 | private: |
| 190 | QWindowContainer *container() const; |
| 191 | }; |
| 192 | |
| 193 | #if QT_CONFIG(messagebox) |
| 194 | class QAccessibleMessageBox : public QAccessibleWidget |
| 195 | { |
| 196 | public: |
| 197 | explicit QAccessibleMessageBox(QWidget *widget); |
| 198 | |
| 199 | QString text(QAccessible::Text t) const override; |
| 200 | |
| 201 | QMessageBox *messageBox() const; |
| 202 | }; |
| 203 | #endif |
| 204 | |
| 205 | #endif // QT_CONFIG(accessibility) |
| 206 | |
| 207 | QT_END_NAMESPACE |
| 208 | |
| 209 | #endif // SIMPLEWIDGETS_H |
| 210 | |