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
369 QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
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;
430 if (
const QWidget *parent = mdiSubWindow()->parentWidget())
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())
607 return dockWidgetLayout()->indexOf(qobject_cast<QWidget*>(
child->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
'"';
832 int fontSize = int(charFormatFont.pointSize());
842 attrs[
"text-line-through-type"] = charFormatFont.strikeOut() ?
"single"_L1 :
"none"_L1;
848 switch (underlineStyle) {
873 qWarning() <<
"Unknown QTextCharFormat::UnderlineStyle value " << underlineStyle <<
" could not be translated to IAccessible2 value";
876 if (!underlineStyleValue.isNull()) {
877 attrs[
"text-underline-style"] = underlineStyleValue;
912 return attrs.toFormatted();
915int QAccessibleTextWidget::cursorPosition()
const
920void QAccessibleTextWidget::selection(
int selectionIndex,
int *startOffset,
int *endOffset)
const
922 *startOffset = *endOffset = 0;
925 if (selectionIndex != 0 || !
cursor.hasSelection())
928 *startOffset =
cursor.selectionStart();
929 *endOffset =
cursor.selectionEnd();
932QString QAccessibleTextWidget::text(
int startOffset,
int endOffset)
const
939 return cursor.selectedText().replace(
QChar(QChar::ParagraphSeparator), u
'\n');
942QPoint QAccessibleTextWidget::scrollBarPosition()
const
948QString QAccessibleTextWidget::textBeforeOffset(
int offset, QAccessible::TextBoundaryType boundaryType,
949 int *startOffset,
int *endOffset)
const
956 QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(
cursor, boundaryType);
957 cursor.setPosition(boundaries.first - 1);
958 boundaries = QAccessible::qAccessibleTextBoundaryHelper(
cursor, boundaryType);
960 *startOffset = boundaries.first;
961 *endOffset = boundaries.second;
963 return text(boundaries.first, boundaries.second);
967QString QAccessibleTextWidget::textAfterOffset(
int offset, QAccessible::TextBoundaryType boundaryType,
968 int *startOffset,
int *endOffset)
const
975 QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(
cursor, boundaryType);
976 cursor.setPosition(boundaries.second);
977 boundaries = QAccessible::qAccessibleTextBoundaryHelper(
cursor, boundaryType);
979 *startOffset = boundaries.first;
980 *endOffset = boundaries.second;
982 return text(boundaries.first, boundaries.second);
985QString QAccessibleTextWidget::textAtOffset(
int offset, QAccessible::TextBoundaryType boundaryType,
986 int *startOffset,
int *endOffset)
const
993 QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(
cursor, boundaryType);
995 *startOffset = boundaries.first;
996 *endOffset = boundaries.second;
998 return text(boundaries.first, boundaries.second);
1001void QAccessibleTextWidget::setCursorPosition(
int position)
1008void QAccessibleTextWidget::addSelection(
int startOffset,
int endOffset)
1013void QAccessibleTextWidget::removeSelection(
int selectionIndex)
1015 if (selectionIndex != 0)
1023void QAccessibleTextWidget::setSelection(
int selectionIndex,
int startOffset,
int endOffset)
1025 if (selectionIndex != 0)
1034int QAccessibleTextWidget::characterCount()
const
1038 return cursor.position();
1041QTextCursor QAccessibleTextWidget::textCursorForRange(
int startOffset,
int endOffset)
const
1050void QAccessibleTextWidget::deleteText(
int startOffset,
int endOffset)
1053 cursor.removeSelectedText();
1063void QAccessibleTextWidget::replaceText(
int startOffset,
int endOffset,
const QString &
text)
1066 cursor.removeSelectedText();
1072#if QT_CONFIG(mainwindow)
1073QAccessibleMainWindow::QAccessibleMainWindow(
QWidget *
widget)
1076QAccessibleInterface *QAccessibleMainWindow::child(
int index)
const
1078 QList<QWidget*> kids = _q_ac_childWidgets(
mainWindow());
1080 return QAccessible::queryAccessibleInterface(kids.at(
index));
1085int QAccessibleMainWindow::childCount()
const
1087 QList<QWidget*> kids = _q_ac_childWidgets(
mainWindow());
1091int QAccessibleMainWindow::indexOfChild(
const QAccessibleInterface *iface)
const
1093 QList<QWidget*> kids = _q_ac_childWidgets(
mainWindow());
1094 return kids.indexOf(
static_cast<QWidget*
>(
iface->object()));
1097QAccessibleInterface *QAccessibleMainWindow::childAt(
int x,
int y)
const
1100 if (!
w->isVisible())
1110 return QAccessible::queryAccessibleInterface(
child);
1116QMainWindow *QAccessibleMainWindow::mainWindow()
const
1118 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
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.
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
\inmodule QtCore\reentrant
constexpr void setX(int x) noexcept
Sets the x coordinate of this point to the given x coordinate.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr void moveTopLeft(const QPoint &p) noexcept
Moves the rectangle, leaving the top-left corner at the given position.
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 isEmpty() const noexcept
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)
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 QString windowTitle(HWND hwnd)
QList< QWidget * > widgets
[11]
QGraphicsWidget * textEdit
view viewport() -> scroll(dx, dy, deviceRect)
edit textCursor().insertText(text)
[0]