~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to src/TerminalDisplayAccessible.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 14:29:24 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120606142924-1rekqv6j25lw2k41
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  This file is part of Konsole, a terminal emulator for KDE.
 
3
 *
 
4
 *  Copyright 2012  Frederik Gladhorn <gladhorn@kde.org>
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
19
 *  02110-1301  USA.
 
20
 */
 
21
 
 
22
#ifndef TERMINALDISPLAYACCESSIBLE_H
 
23
#define TERMINALDISPLAYACCESSIBLE_H
 
24
 
 
25
#include <QtGui/qaccessible.h>
 
26
#include <QtGui/qaccessible2.h>
 
27
#include <QtGui/qaccessiblewidget.h>
 
28
 
 
29
#include "TerminalDisplay.h"
 
30
#include "ScreenWindow.h"
 
31
#include "Screen.h"
 
32
 
 
33
namespace Konsole {
 
34
 
 
35
/**
 
36
 * Class implementing the QAccessibleInterface for the terminal display.
 
37
 * This exposes information about the display to assistive technology using the QAccessible framework.
 
38
 *
 
39
 * Most functions are re-implemented from QAccessibleTextInterface.
 
40
 */
 
41
class TerminalDisplayAccessible
 
42
    : public QAccessibleWidgetEx, public QAccessibleTextInterface, public QAccessibleSimpleEditableTextInterface
 
43
{
 
44
    Q_ACCESSIBLE_OBJECT
 
45
 
 
46
public:
 
47
    explicit TerminalDisplayAccessible(TerminalDisplay *display);
 
48
 
 
49
    QString text(QAccessible::Text t, int child) const;
 
50
 
 
51
    QString text(int startOffset, int endOffset);
 
52
    QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset);
 
53
    QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset);
 
54
    QString textBeforeOffset(int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset);
 
55
    int characterCount();
 
56
 
 
57
    int selectionCount();
 
58
    void selection(int selectionIndex, int *startOffset, int *endOffset);
 
59
    void addSelection(int startOffset, int endOffset);
 
60
    void setSelection(int selectionIndex, int startOffset, int endOffset);
 
61
    void removeSelection(int selectionIndex);
 
62
 
 
63
    QRect characterRect(int offset, QAccessible2::CoordinateType coordType);
 
64
    int offsetAtPoint(const QPoint& point, QAccessible2::CoordinateType coordType);
 
65
    void scrollToSubstring(int startIndex, int endIndex);
 
66
 
 
67
    QString attributes(int offset, int* startOffset, int* endOffset);
 
68
 
 
69
    int cursorPosition();
 
70
    void setCursorPosition(int position);
 
71
 
 
72
private:
 
73
    Konsole::TerminalDisplay *display();
 
74
 
 
75
    inline int positionToOffset(int column, int line)
 
76
    {
 
77
        return line * display()->_usedColumns + column;
 
78
    }
 
79
 
 
80
    inline int lineForOffset(int offset)
 
81
    {
 
82
        return offset / display()->_usedColumns;
 
83
    }
 
84
 
 
85
    inline int columnForOffset(int offset)
 
86
    {
 
87
        return offset % display()->_usedColumns;
 
88
    }
 
89
 
 
90
    QString visibleText() const;
 
91
};
 
92
 
 
93
 
 
94
} // namespace
 
95
 
 
96
#endif // TERMINALDISPLAYACCESSIBLE_H