1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2015 The Qt Company Ltd. 4 ** Contact: http://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtGui 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 The Qt Company. For licensing terms 14 ** and conditions see http://www.qt.io/terms-conditions. For further 15 ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free 20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 ** following information to ensure the GNU Lesser General Public License 23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 ** 26 ** As a special exception, The Qt Company gives you certain additional 27 ** rights. These rights are described in The Qt Company LGPL Exception 28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 ** 30 ** GNU General Public License Usage 31 ** Alternatively, this file may be used under the terms of the GNU 32 ** General Public License version 3.0 as published by the Free Software 33 ** Foundation and appearing in the file LICENSE.GPL included in the 34 ** packaging of this file. Please review the following information to 35 ** ensure the GNU General Public License version 3.0 requirements will be 36 ** met: http://www.gnu.org/copyleft/gpl.html. 37 ** 38 ** $QT_END_LICENSE$ 39 ** 40 ****************************************************************************/ 41 42 #ifndef QCOEFEPINPUTCONTEXT_P_H 43 #define QCOEFEPINPUTCONTEXT_P_H 44 45 // 46 // W A R N I N G 47 // ------------- 48 // 49 // This file is not part of the Qt API. It exists purely as an 50 // implementation detail. This header file may change from version to 51 // version without notice, or even be removed. 52 // 53 // We mean it. 54 // 55 56 #ifndef QT_NO_IM 57 58 #include "qinputcontext.h" 59 #include <qhash.h> 60 #include <qtimer.h> 61 #include <private/qcore_symbian_p.h> 62 #include <private/qt_s60_p.h> 63 64 #include <fepbase.h> 65 #include <aknedsts.h> 66 #include <eikccpu.h> 67 #include <eikedwin.h> 68 #include <aknedformaccessor.h> 69 70 class CAknExtendedInputCapabilities; 71 72 QT_BEGIN_NAMESPACE 73 74 class QCoeFepInputMaskHandler 75 { 76 public: 77 QCoeFepInputMaskHandler(const QString &mask); 78 ~QCoeFepInputMaskHandler(); 79 bool canPasteClipboard(const QString &text); 80 private: 81 bool isValidInput(QChar key, QChar mask) const; 82 private: 83 struct MaskInputData { 84 enum Casemode { NoCaseMode, Upper, Lower }; 85 QChar maskChar; 86 bool separator; 87 Casemode caseMode; 88 }; 89 int m_maxLength; 90 QChar m_blank; 91 MaskInputData *m_maskData; 92 }; 93 94 class Q_AUTOTEST_EXPORT QCoeFepInputContext : public QInputContext, 95 public MCoeFepAwareTextEditor, 96 public MCoeFepAwareTextEditor_Extension1, 97 public MObjectProvider, 98 public MEikCcpuEditor 99 100 { 101 Q_OBJECT 102 103 public: 104 QCoeFepInputContext(QObject *parent = 0); 105 ~QCoeFepInputContext(); 106 identifierName()107 QString identifierName() { return QLatin1String("coefep"); } 108 QString language(); 109 110 void reset(); 111 void update(); 112 113 bool filterEvent(const QEvent *event); 114 bool symbianFilterEvent(QWidget *keyWidget, const QSymbianEvent *event); 115 void mouseHandler( int x, QMouseEvent *event); isComposing()116 bool isComposing() const { return !m_preeditString.isEmpty(); } 117 118 void setFocusWidget(QWidget * w); 119 void widgetDestroyed(QWidget *w); 120 121 TCoeInputCapabilities inputCapabilities(); 122 123 void resetSplitViewWidget(bool keepInputWidget = false); 124 void ensureFocusWidgetVisible(QWidget *widget); 125 126 protected: 127 void timerEvent(QTimerEvent *timerEvent); 128 129 private: 130 void commitCurrentString(bool cancelFepTransaction); 131 void updateHints(bool mustUpdateInputCapabilities); 132 void applyHints(Qt::InputMethodHints hints); 133 void applyFormat(QList<QInputMethodEvent::Attribute> *attributes); 134 void queueInputCapabilitiesChanged(); 135 bool needsInputPanel(); 136 void commitTemporaryPreeditString(); 137 bool isWidgetVisible(QWidget *widget, int offset = 0); 138 bool isPartialKeyboardSupported(); 139 bool vietCharConversion(const QEvent *event); 140 141 private Q_SLOTS: 142 void ensureInputCapabilitiesChanged(); 143 void translateInputWidget(); 144 void ensureWidgetVisibility(); 145 146 // From MCoeFepAwareTextEditor 147 public: 148 void StartFepInlineEditL(const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, 149 TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, 150 MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, 151 MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit); 152 void UpdateFepInlineTextL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText); 153 void SetInlineEditingCursorVisibilityL(TBool aCursorVisibility); 154 void CancelFepInlineEdit(); 155 TInt DocumentLengthForFep() const; 156 TInt DocumentMaximumLengthForFep() const; 157 void SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection); 158 void GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const; 159 void GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, TInt aLengthToRetrieve) const; 160 void GetFormatForFep(TCharFormat& aFormat, TInt aDocumentPosition) const; 161 void GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, 162 TInt aDocumentPosition) const; 163 private: 164 void DoCommitFepInlineEditL(); 165 MCoeFepAwareTextEditor_Extension1* Extension1(TBool& aSetToTrue); 166 void ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateEvent aEventType); 167 void enableSymbianCcpuSupport(); 168 void changeCBA(bool showCopyAndOrPaste); 169 void copyOrCutTextToClipboard(const char *operation); 170 void getScreenCoordinatesForFepX(TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, 171 TInt aDocumentPosition) const; 172 173 //From MEikCcpuEditor interface 174 public: 175 TBool CcpuIsFocused() const; 176 TBool CcpuCanCut() const; 177 void CcpuCutL(); 178 TBool CcpuCanCopy() const; 179 void CcpuCopyL(); 180 TBool CcpuCanPaste() const; 181 void CcpuPasteL(); 182 TBool CcpuCanUndo() const; 183 void CcpuUndoL(); 184 185 private slots: 186 void copy(); 187 void paste(); 188 189 // From MCoeFepAwareTextEditor_Extension1 190 public: 191 void SetStateTransferingOwnershipL(MCoeFepAwareTextEditor_Extension1::CState* aState, TUid aTypeSafetyUid); 192 MCoeFepAwareTextEditor_Extension1::CState* State(TUid aTypeSafetyUid); 193 194 // From MObjectProvider 195 public: 196 TTypeUid::Ptr MopSupplyObject(TTypeUid id); 197 MObjectProvider *MopNext(); 198 199 private: 200 QSymbianControl *m_parent; 201 CAknEdwinState *m_fepState; 202 QString m_preeditString; 203 Qt::InputMethodHints m_lastImHints; 204 TUint m_textCapabilities; 205 bool m_inDestruction; 206 bool m_pendingInputCapabilitiesChanged; 207 bool m_pendingTransactionCancel; 208 int m_cursorVisibility; 209 int m_inlinePosition; 210 MFepInlineTextFormatRetriever *m_formatRetriever; 211 MFepPointerEventHandlerDuringInlineEdit *m_pointerHandler; 212 QBasicTimer m_tempPreeditStringTimeout; 213 bool m_hasTempPreeditString; 214 QString m_cachedPreeditString; 215 int m_cachedCursorAndAnchorPosition; 216 217 int m_splitViewResizeBy; 218 Qt::WindowStates m_splitViewPreviousWindowStates; 219 QRectF m_transformation; 220 QGraphicsItem *m_splitViewPreviousFocusItem; //can't use QPointer<> since QGraphicsItem is not a QObject. 221 222 CAknCcpuSupport *m_ccpu; 223 QAction *m_copyAction; 224 QAction *m_pasteAction; 225 QPointer<QWidget> m_lastFocusedEditor; 226 QPointer<QObject> m_lastFocusedObject; 227 228 CAknExtendedInputCapabilities *m_extendedInputCapabilities; 229 230 QScopedPointer<CAknEdwinFormAccessor> m_formAccessor; 231 QScopedPointer<CEikEdwin> m_dummyEditor; 232 233 friend class tst_QInputContext; 234 }; 235 236 Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable); 237 Q_GUI_EXPORT void qt_s60_setPartialScreenAutomaticTranslation(bool enable); 238 Q_GUI_EXPORT void qt_s60_setEditorFlags(int flags); 239 240 QT_END_NAMESPACE 241 242 #endif // QT_NO_IM 243 244 #endif // QCOEFEPINPUTCONTEXT_P_H 245