10#if QT_CONFIG(textedit)
13#include "private/qtextedit_p.h"
16#if QT_CONFIG(scrollbar)
20#include <QApplication>
21#if QT_CONFIG(stackedwidget)
22#include <QStackedWidget>
29#include <QMdiSubWindow>
31#if QT_CONFIG(dialogbuttonbox)
32#include <QDialogButtonBox>
35#if QT_CONFIG(rubberband)
38#if QT_CONFIG(textbrowser)
39#include <QTextBrowser>
41#if QT_CONFIG(calendarwidget)
42#include <QCalendarWidget>
44#if QT_CONFIG(itemviews)
45#include <QAbstractItemView>
47#if QT_CONFIG(dockwidget)
49#include <private/qdockwidget_p.h>
51#if QT_CONFIG(mainwindow)
59#if QT_CONFIG(accessibility)
77 QString objectName =
w->objectName();
79 && !qobject_cast<QFocusFrame*>(
w)
81 && !qobject_cast<QMenu*>(
w)
84 && objectName !=
"qt_rubberband"_L1
85 && objectName !=
"qt_qmainwindow_extended_splitter"_L1
86 && objectName !=
"qt_spinbox_lineedit"_L1) {
93#if QT_CONFIG(textedit) && !defined(QT_NO_CURSOR)
95QAccessiblePlainTextEdit::QAccessiblePlainTextEdit(
QWidget*
o)
96 :QAccessibleTextWidget(
o)
106QString QAccessiblePlainTextEdit::text(QAccessible::Text
t)
const
108 if (
t == QAccessible::Value)
109 return plainTextEdit()->toPlainText();
111 return QAccessibleWidget::text(
t);
114void QAccessiblePlainTextEdit::setText(QAccessible::Text
t,
const QString &
text)
116 if (
t != QAccessible::Value) {
117 QAccessibleWidget::setText(
t,
text);
120 if (plainTextEdit()->isReadOnly())
123 plainTextEdit()->setPlainText(
text);
129 if (plainTextEdit()->isReadOnly())
136void *QAccessiblePlainTextEdit::interface_cast(QAccessible::InterfaceType
t)
138 if (
t == QAccessible::TextInterface)
139 return static_cast<QAccessibleTextInterface*
>(
this);
140 else if (
t == QAccessible::EditableTextInterface)
141 return static_cast<QAccessibleEditableTextInterface*
>(
this);
142 return QAccessibleWidget::interface_cast(
t);
145QPoint QAccessiblePlainTextEdit::scrollBarPosition()
const
148 result.setX(plainTextEdit()->horizontalScrollBar() ? plainTextEdit()->horizontalScrollBar()->sliderPosition() : 0);
149 result.setY(plainTextEdit()->verticalScrollBar() ? plainTextEdit()->verticalScrollBar()->sliderPosition() : 0);
153QTextCursor QAccessiblePlainTextEdit::textCursor()
const
155 return plainTextEdit()->textCursor();
165 return plainTextEdit()->document();
168QWidget* QAccessiblePlainTextEdit::viewport()
const
170 return plainTextEdit()->viewport();
173void QAccessiblePlainTextEdit::scrollToSubstring(
int startIndex,
int endIndex)
192QAccessibleTextEdit::QAccessibleTextEdit(
QWidget *
o)
199QTextEdit *QAccessibleTextEdit::textEdit()
const
219QWidget *QAccessibleTextEdit::viewport()
const
224QPoint QAccessibleTextEdit::scrollBarPosition()
const
232QString QAccessibleTextEdit::text(QAccessible::Text
t)
const
234 if (
t == QAccessible::Value)
237 return QAccessibleWidget::text(
t);
240void QAccessibleTextEdit::setText(QAccessible::Text
t,
const QString &
text)
242 if (
t != QAccessible::Value) {
243 QAccessibleWidget::setText(
t,
text);
262void *QAccessibleTextEdit::interface_cast(QAccessible::InterfaceType
t)
264 if (
t == QAccessible::TextInterface)
265 return static_cast<QAccessibleTextInterface*
>(
this);
266 else if (
t == QAccessible::EditableTextInterface)
267 return static_cast<QAccessibleEditableTextInterface*
>(
this);
268 return QAccessibleWidget::interface_cast(
t);
271void QAccessibleTextEdit::scrollToSubstring(
int startIndex,
int endIndex)
276 cursor.setPosition(startIndex);
279 cursor.setPosition(endIndex);
282 r.moveTo(
r.x() +
edit->horizontalScrollBar()->value(),
283 r.
y() +
edit->verticalScrollBar()->value());
287 qWarning(
"AccessibleTextEdit::scrollToSubstring failed!");
292#if QT_CONFIG(stackedwidget)
294QAccessibleStackedWidget::QAccessibleStackedWidget(
QWidget *
widget)
300QAccessibleInterface *QAccessibleStackedWidget::childAt(
int x,
int y)
const
304 QWidget *currentWidget = stackedWidget()->currentWidget();
309 return child(stackedWidget()->currentIndex());
313int QAccessibleStackedWidget::childCount()
const
315 return stackedWidget()->count();
318int QAccessibleStackedWidget::indexOfChild(
const QAccessibleInterface *
child)
const
324 return stackedWidget()->indexOf(
widget);
327QAccessibleInterface *QAccessibleStackedWidget::child(
int index)
const
329 if (index < 0 || index >= stackedWidget()->
count())
331 return QAccessible::queryAccessibleInterface(stackedWidget()->
widget(
index));
340#if QT_CONFIG(toolbox)
348QToolBox * QAccessibleToolBox::toolBox()
const
355#if QT_CONFIG(mdiarea)
362int QAccessibleMdiArea::childCount()
const
364 return mdiArea()->subWindowList().size();
367QAccessibleInterface *QAccessibleMdiArea::child(
int index)
const
373 return QAccessible::queryAccessibleInterface(targetObject);
377int QAccessibleMdiArea::indexOfChild(
const QAccessibleInterface *
child)
const
379 if (!
child || !
child->object() || mdiArea()->subWindowList().isEmpty())
382 return mdiArea()->subWindowList().indexOf(
window);
387QMdiArea *QAccessibleMdiArea::mdiArea()
const
393QAccessibleMdiSubWindow::QAccessibleMdiSubWindow(
QWidget *
widget)
399QString QAccessibleMdiSubWindow::text(QAccessible::Text textType)
const
401 if (textType == QAccessible::Name) {
406 return QAccessibleWidget::text(textType);
409void QAccessibleMdiSubWindow::setText(QAccessible::Text textType,
const QString &
text)
411 if (textType == QAccessible::Name)
412 mdiSubWindow()->setWindowTitle(
text);
414 QAccessibleWidget::setText(textType,
text);
420 state.focusable =
true;
421 if (!mdiSubWindow()->isMaximized()) {
422 state.movable =
true;
423 state.sizeable =
true;
427 state.focused =
true;
429 state.invisible =
true;
431 if (!
parent->contentsRect().contains(mdiSubWindow()->geometry()))
432 state.offscreen =
true;
434 state.disabled =
true;
438int QAccessibleMdiSubWindow::childCount()
const
440 if (mdiSubWindow()->
widget())
445QAccessibleInterface *QAccessibleMdiSubWindow::child(
int index)
const
451 return QAccessible::queryAccessibleInterface(
source->widget());
454int QAccessibleMdiSubWindow::indexOfChild(
const QAccessibleInterface *
child)
const
461QRect QAccessibleMdiSubWindow::rect()
const
463 if (mdiSubWindow()->isHidden())
465 if (!mdiSubWindow()->
parent())
466 return QAccessibleWidget::rect();
477#if QT_CONFIG(dialogbuttonbox)
479QAccessibleDialogButtonBox::QAccessibleDialogButtonBox(
QWidget *
widget)
487#if QT_CONFIG(textbrowser) && !defined(QT_NO_CURSOR)
488QAccessibleTextBrowser::QAccessibleTextBrowser(
QWidget *
widget)
489 : QAccessibleTextEdit(
widget)
494QAccessible::Role QAccessibleTextBrowser::role()
const
496 return QAccessible::StaticText;
500#if QT_CONFIG(calendarwidget)
502QAccessibleCalendarWidget::QAccessibleCalendarWidget(
QWidget *
widget)
508int QAccessibleCalendarWidget::childCount()
const
510 return calendarWidget()->isNavigationBarVisible() ? 2 : 1;
513int QAccessibleCalendarWidget::indexOfChild(
const QAccessibleInterface *
child)
const
515 if (!
child || !
child->object() || childCount() <= 0)
517 if (qobject_cast<QAbstractItemView *>(
child->object()))
518 return childCount() - 1;
522QAccessibleInterface *QAccessibleCalendarWidget::child(
int index)
const
524 if (index < 0 || index >= childCount())
527 if (childCount() > 1 &&
index == 0)
528 return QAccessible::queryAccessibleInterface(navigationBar());
530 return QAccessible::queryAccessibleInterface(calendarView());
541 if (
child->objectName() ==
"qt_calendar_calendarview"_L1)
547QWidget *QAccessibleCalendarWidget::navigationBar()
const
550 if (
child->objectName() ==
"qt_calendar_navigationbar"_L1)
557#if QT_CONFIG(dockwidget)
575int QAccessibleDockWidget::childCount()
const
580 return dockWidgetLayout()->count();
583QAccessibleInterface *QAccessibleDockWidget::child(
int index)
const
587 return QAccessible::queryAccessibleInterface(
dockWidget()->titleBarWidget());
593 return QAccessible::queryAccessibleInterface(
item->widget());
598int QAccessibleDockWidget::indexOfChild(
const QAccessibleInterface *
child)
const
600 if (!
child || !
child->object() ||
child->object()->parent() !=
object())
610QRect QAccessibleDockWidget::rect()
const
624QDockWidget *QAccessibleDockWidget::dockWidget()
const
629QString QAccessibleDockWidget::text(QAccessible::Text
t)
const
631 if (
t == QAccessible::Name) {
633 }
else if (
t == QAccessible::Accelerator) {
642QAccessibleTextWidget::QAccessibleTextWidget(
QWidget *
o, QAccessible::Role
r,
const QString &
name):
643 QAccessibleWidget(
o,
r,
name)
651 s.selectableText =
true;
656QRect QAccessibleTextWidget::characterRect(
int offset)
const
669 if (
line.isValid()) {
687 int w = fm.horizontalAdvance(
ch);
689 r =
QRect(layoutPosition.
x() +
x, layoutPosition.
y() +
line.y() +
line.ascent() + fm.descent() -
h,
691 r.moveTo(
viewport()->mapToGlobal(
r.topLeft()));
693 r.translate(-scrollBarPosition());
699int QAccessibleTextWidget::offsetAtPoint(
const QPoint &point)
const
703 p += scrollBarPosition();
707int QAccessibleTextWidget::selectionCount()
const
724class AttributeFormatterRef {
727 friend class AttributeFormatter;
730 template <
typename RHS>
731 void operator=(RHS &&rhs)
749class AttributeFormatter {
752 AttributeFormatterRef operator[](
const char *
key)
753 {
return AttributeFormatterRef(
string,
key); }
759QString QAccessibleTextWidget::attributes(
int offset,
int *startOffset,
int *endOffset)
const
767 offset = cursorPosition();
769 const int charCount = characterCount();
776 if (offset < 0 || offset > charCount) {
788 int blockEnd = blockStart + block.
length();
791 int lastFragmentIndex = blockStart;
792 while (!
iter.atEnd()) {
796 lastFragmentIndex =
f.position() +
f.length();
806 *startOffset =
qMax(
pos, blockStart);
810 *startOffset = lastFragmentIndex;
811 *endOffset = blockEnd;
818 const QFont charFormatFont = charFormat.
font();
820 AttributeFormatter
attrs;
823 family = family.
replace(u
'\\',
"\\\\"_L1);
824 family = family.
replace(u
':',
"\\:"_L1);
825 family = family.
replace(u
',',
"\\,"_L1);
826 family = family.
replace(u
'=',
"\\="_L1);
827 family = family.
replace(u
';',
"\\;"_L1);
828 family = family.
replace(u
'\"',
"\\\""_L1);
829 attrs[
"font-family"] = u
'"' + family + u
'"';
846 switch (underlineStyle) {
871 qWarning() <<
"Unknown QTextCharFormat::​UnderlineStyle value " << underlineStyle <<
" could not be translated to IAccessible2 value";
874 if (!underlineStyleValue.
isNull()) {
875 attrs[
"text-underline-style"] = underlineStyleValue;
910 return attrs.toFormatted();
913int QAccessibleTextWidget::cursorPosition()
const
918void QAccessibleTextWidget::selection(
int selectionIndex,
int *startOffset,
int *endOffset)
const
920 *startOffset = *endOffset = 0;
923 if (selectionIndex != 0 || !
cursor.hasSelection())
926 *startOffset =
cursor.selectionStart();
927 *endOffset =
cursor.selectionEnd();
930QString QAccessibleTextWidget::text(
int startOffset,
int endOffset)
const
940QPoint QAccessibleTextWidget::scrollBarPosition()
const
946QString QAccessibleTextWidget::textBeforeOffset(
int offset, QAccessible::TextBoundaryType boundaryType,
947 int *startOffset,
int *endOffset)
const
955 cursor.setPosition(boundaries.first - 1);
956 boundaries = QAccessible::qAccessibleTextBoundaryHelper(
cursor, boundaryType);
958 *startOffset = boundaries.first;
959 *endOffset = boundaries.second;
961 return text(boundaries.first, boundaries.second);
965QString QAccessibleTextWidget::textAfterOffset(
int offset, QAccessible::TextBoundaryType boundaryType,
966 int *startOffset,
int *endOffset)
const
974 cursor.setPosition(boundaries.second);
975 boundaries = QAccessible::qAccessibleTextBoundaryHelper(
cursor, boundaryType);
977 *startOffset = boundaries.first;
978 *endOffset = boundaries.second;
980 return text(boundaries.first, boundaries.second);
983QString QAccessibleTextWidget::textAtOffset(
int offset, QAccessible::TextBoundaryType boundaryType,
984 int *startOffset,
int *endOffset)
const
993 *startOffset = boundaries.first;
994 *endOffset = boundaries.second;
996 return text(boundaries.first, boundaries.second);
999void QAccessibleTextWidget::setCursorPosition(
int position)
1006void QAccessibleTextWidget::addSelection(
int startOffset,
int endOffset)
1011void QAccessibleTextWidget::removeSelection(
int selectionIndex)
1013 if (selectionIndex != 0)
1021void QAccessibleTextWidget::setSelection(
int selectionIndex,
int startOffset,
int endOffset)
1023 if (selectionIndex != 0)
1032int QAccessibleTextWidget::characterCount()
const
1036 return cursor.position();
1039QTextCursor QAccessibleTextWidget::textCursorForRange(
int startOffset,
int endOffset)
const
1048void QAccessibleTextWidget::deleteText(
int startOffset,
int endOffset)
1051 cursor.removeSelectedText();
1061void QAccessibleTextWidget::replaceText(
int startOffset,
int endOffset,
const QString &
text)
1064 cursor.removeSelectedText();
1070#if QT_CONFIG(mainwindow)
1071QAccessibleMainWindow::QAccessibleMainWindow(
QWidget *
widget)
1074QAccessibleInterface *QAccessibleMainWindow::child(
int index)
const
1078 return QAccessible::queryAccessibleInterface(kids.
at(
index));
1083int QAccessibleMainWindow::childCount()
const
1089int QAccessibleMainWindow::indexOfChild(
const QAccessibleInterface *iface)
const
1095QAccessibleInterface *QAccessibleMainWindow::childAt(
int x,
int y)
const
1098 if (!
w->isVisible())
1108 return QAccessible::queryAccessibleInterface(
child);
1114QMainWindow *QAccessibleMainWindow::mainWindow()
const
1116 return qobject_cast<QMainWindow *>(
object());
The QAbstractItemView class provides the basic functionality for item view classes.
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const =0
Returns the cursor position for the given point with the specified accuracy.
The QAccessible class provides enums and static functions related to accessibility.
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or \nullptr if no widget in this ap...
const QColor & color() const
Returns the brush color.
Qt::BrushStyle style() const
Returns the brush style.
int red() const noexcept
Returns the red color component of this color.
int blue() const noexcept
Returns the blue color component of this color.
int green() const noexcept
Returns the green color component of this color.
\reentrant \inmodule QtGui
bool underline() const
Returns true if underline has been set; otherwise returns false.
QStringList families() const
Weight weight() const
Returns the weight of the font, using the same scale as the \l{QFont::Weight} enumeration.
int pointSize() const
Returns the point size of the font.
Style style() const
Returns the style of the font.
Style
This enum describes the different styles of glyphs that are used to display text.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual QRect geometry() const =0
Returns the rectangle covered by this layout item.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
void append(parameter_type t)
The QMainWindow class provides a main application window.
The QMdiArea widget provides an area in which MDI windows are displayed.
The QMdiSubWindow class provides a subwindow class for QMdiArea.
The QPlainTextEdit class provides a widget that is used to edit and display plain text.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr QPoint bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const
Returns true if this string is null; otherwise returns false.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Qt::Alignment alignment() const
Returns the paragraph's alignment.
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
int length() const
Returns the length of the block in characters.
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block's contents.
int position() const
Returns the index of the block's first character within the document.
Qt::LayoutDirection textDirection() const
QTextCharFormat charFormat() const
Returns the QTextCharFormat that describes the block's character format.
VerticalAlignment
This enum describes the ways that adjacent characters can be vertically aligned.
UnderlineStyle underlineStyle() const
UnderlineStyle
This enum describes the different ways drawing underlined text.
VerticalAlignment verticalAlignment() const
Returns the vertical alignment used for characters with this format.
QFont font() const
Returns the font for this character format.
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QTextBlock findBlock(int pos) const
Returns the text block that contains the {pos}-th character.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
QBrush background() const
Returns the brush used to paint the document's background.
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines,...
QTextCharFormat charFormat() const
Returns the text fragment's character format.
int length() const
Returns the number of characters in the text fragment.
int position() const
Returns the position of this text fragment in the document.
[Window class with invokable method]
Combined button and popup list for selecting options.
constexpr QBindableInterface iface
MyMainWidget * mainWindow
QTextDocument * textDocument
static jboolean setSelection(JNIEnv *, jobject, jint start, jint end)
std::pair< T1, T2 > QPair
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
static struct AttrInfo attrs[]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
#define Q_ARG(Type, data)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLenum GLsizeiptr fontSize
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
GLsizei const GLchar *const * string
[0]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define QStringLiteral(str)
#define QT_CONFIG(feature)
static QT_BEGIN_NAMESPACE QString windowTitle(HWND hwnd)
QList< QWidget * > widgets
[11]
QGraphicsWidget * textEdit
view viewport() -> scroll(dx, dy, deviceRect)
edit textCursor().insertText(text)
[0]
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent