Qt 4.8
qbbinputcontext_imf.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module 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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QBBINPUTCONTEXT_H
43 #define QBBINPUTCONTEXT_H
44 
45 #include "imf/imf_client.h"
46 #include "imf/input_control.h"
47 
48 #include <QtGui/QPlatformIntegration>
49 #include <qinputcontext.h>
50 
52 
54 
56 {
57 public:
58  explicit QBBInputContext(QBBAbstractVirtualKeyboard &keyboard, QObject* parent = 0);
60 
61  virtual QList<QAction *> actions();
62  virtual bool filterEvent(const QEvent * event);
63  virtual QFont font() const;
64  virtual QString identifierName();
65  virtual bool isComposing() const;
66  virtual QString language();
67  virtual void mouseHandler(int x, QMouseEvent * event);
68  virtual void reset();
69  virtual void setFocusWidget(QWidget * widget);
70  virtual void update();
71  virtual void widgetDestroyed(QWidget * widget);
72  bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
73 
74 protected:
75  // Filters only for IMF events.
76  bool eventFilter(QObject *obj, QEvent *event);
77 
78 private:
79  // IMF Event dispatchers
80  bool dispatchFocusEvent(FocusEventId id, int hints = Qt::ImhNone);
83  int32_t processEvent(event_t* event);
84 
85  void closeSession();
86  void openSession();
87  bool hasSession();
88  void endComposition();
89  void setComposingText(QString const& composingText);
90  bool hasSelectedText();
91 
92  // IMF Event handlers - these events will come in from QCoreApplication.
93  int32_t onBeginBatchEdit(input_session_t* ic);
94  int32_t onClearMetaKeyStates(input_session_t* ic, int32_t states);
95  int32_t onCommitText(input_session_t* ic, spannable_string_t* text, int32_t new_cursor_position);
96  int32_t onDeleteSurroundingText(input_session_t* ic, int32_t left_length, int32_t right_length);
97  int32_t onEndBatchEdit(input_session_t* ic);
98  int32_t onFinishComposingText(input_session_t* ic);
99  int32_t onGetCursorCapsMode(input_session_t* ic, int32_t req_modes);
100  int32_t onGetCursorPosition(input_session_t* ic);
101  extracted_text_t* onGetExtractedText(input_session_t* ic, extracted_text_request_t* request, int32_t flags);
102  spannable_string_t* onGetSelectedText(input_session_t* ic, int32_t flags);
103  spannable_string_t* onGetTextAfterCursor(input_session_t* ic, int32_t n, int32_t flags);
104  spannable_string_t* onGetTextBeforeCursor(input_session_t* ic, int32_t n, int32_t flags);
105  int32_t onPerformEditorAction(input_session_t* ic, int32_t editor_action);
106  int32_t onReportFullscreenMode(input_session_t* ic, int32_t enabled);
107  int32_t onSendEvent(input_session_t* ic, event_t * event);
108  int32_t onSendAsyncEvent(input_session_t* ic, event_t * event);
109  int32_t onSetComposingRegion(input_session_t* ic, int32_t start, int32_t end);
110  int32_t onSetComposingText(input_session_t* ic, spannable_string_t* text, int32_t new_cursor_position);
111  int32_t onSetSelection(input_session_t* ic, int32_t start, int32_t end);
112  int32_t onForceUpdate();
113 
118 };
119 
121 
122 #endif // QBBINPUTCONTEXT_H
extracted_text_t * onGetExtractedText(input_session_t *ic, extracted_text_request_t *request, int32_t flags)
virtual void widgetDestroyed(QWidget *widget)
This virtual function is called when the specified widget is destroyed.
virtual void update()
This virtual function is called when a state in the focus widget has changed.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
virtual void mouseHandler(int x, QMouseEvent *event)
This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.
int32_t onFinishComposingText(input_session_t *ic)
int32_t onSetSelection(input_session_t *ic, int32_t start, int32_t end)
int32_t onSendAsyncEvent(input_session_t *ic, event_t *event)
int32_t onForceUpdate()
int32_t onPerformEditorAction(input_session_t *ic, int32_t editor_action)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int32_t onSetComposingText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
int32_t onGetCursorCapsMode(input_session_t *ic, int32_t req_modes)
bool dispatchFocusEvent(FocusEventId id, int hints=Qt::ImhNone)
virtual void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
spannable_string_t * onGetTextBeforeCursor(input_session_t *ic, int32_t n, int32_t flags)
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QString identifierName()
This function must be implemented in any subclasses to return the identifier name of the input method...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QBBAbstractVirtualKeyboard & mVirtualKeyboard
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
int32_t onGetCursorPosition(input_session_t *ic)
bool eventFilter(QObject *obj, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object...
bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
int32_t processEvent(event_t *event)
QBBInputContext(QBBAbstractVirtualKeyboard &keyboard, QObject *parent=0)
int32_t onBeginBatchEdit(input_session_t *ic)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int32_t onEndBatchEdit(input_session_t *ic)
virtual QFont font() const
Returns the font of the current input widget.
int32_t onReportFullscreenMode(input_session_t *ic, int32_t enabled)
int32_t onSendEvent(input_session_t *ic, event_t *event)
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
virtual bool filterEvent(const QEvent *event)
This function can be reimplemented in a subclass to filter input events.
virtual QString language()
This function must be implemented in any subclasses to return a language code (e. ...
int32_t onDeleteSurroundingText(input_session_t *ic, int32_t left_length, int32_t right_length)
void setComposingText(QString const &composingText)
virtual void setFocusWidget(QWidget *widget)
Sets the widget that has an input focus for this input context.
int32_t onClearMetaKeyStates(input_session_t *ic, int32_t states)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
virtual QList< QAction * > actions()
This is a preliminary interface for Qt 4.
virtual bool isComposing() const
This function indicates whether InputMethodStart event had been sent to the current focus widget...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
int32_t onCommitText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
int32_t onSetComposingRegion(input_session_t *ic, int32_t start, int32_t end)
spannable_string_t * onGetTextAfterCursor(input_session_t *ic, int32_t n, int32_t flags)
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
static const KeyPair *const end
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define enabled
spannable_string_t * onGetSelectedText(input_session_t *ic, int32_t flags)
bool dispatchRequestSoftwareInputPanel()
#define text
Definition: qobjectdefs.h:80
The QList class is a template class that provides lists.
Definition: qdatastream.h:62