59 #if defined(Q_WS_WINCE) 69 0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
74 0x4955DD33, 0xB159, 0x11d0, 0x8F, 0xCF, 0x0, 0xAA, 0x00, 0x6B, 0xCC, 0x59);
79 0xb5cf2cfa, 0x8aeb, 0x11d1, 0x93, 0x64, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
83 interface IEnumRegisterWordW;
84 interface IEnumInputContext;
90 #define IFMETHOD HRESULT STDMETHODCALLTYPE 92 interface IActiveIMMApp :
public IUnknown
102 IEnumRegisterWordW __RPC_FAR *__RPC_FAR *pEnum) = 0;
104 virtual IFMETHOD EscapeW(HKL hKL, HIMC hIMC, UINT uEscape, LPVOID pData, LRESULT __RPC_FAR *plResult) = 0;
107 UINT __RPC_FAR *puCopied) = 0;
119 CANDIDATELIST __RPC_FAR *pDst, UINT __RPC_FAR *puCopied) = 0;
125 virtual IFMETHOD GetGuideLineW(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPWSTR pBuf, DWORD __RPC_FAR *pdwResult) = 0;
135 virtual IFMETHOD InstallIMEW(LPWSTR szIMEFileName, LPWSTR szLayoutText, HKL __RPC_FAR *phKL) = 0;
139 virtual IFMETHOD NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue) = 0;
148 LPVOID pRead, DWORD dwReadLen) = 0;
158 virtual IFMETHOD OnDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT __RPC_FAR *plResult) = 0;
166 void __RPC_FAR *pImeMenu, DWORD dwSize, DWORD __RPC_FAR *pdwResult) = 0;
170 interface IActiveIMMMessagePumpOwner :
public IUnknown
181 static IActiveIMMApp *
aimm = 0;
188 #ifndef LGRPID_INSTALLED 189 #define LGRPID_INSTALLED 0x00000001 // installed language group ids 190 #define LGRPID_SUPPORTED 0x00000002 // supported language group ids 193 #ifndef LGRPID_ARABIC 194 #define LGRPID_WESTERN_EUROPE 0x0001 // Western Europe & U.S. 195 #define LGRPID_CENTRAL_EUROPE 0x0002 // Central Europe 196 #define LGRPID_BALTIC 0x0003 // Baltic 197 #define LGRPID_GREEK 0x0004 // Greek 198 #define LGRPID_CYRILLIC 0x0005 // Cyrillic 199 #define LGRPID_TURKISH 0x0006 // Turkish 200 #define LGRPID_JAPANESE 0x0007 // Japanese 201 #define LGRPID_KOREAN 0x0008 // Korean 202 #define LGRPID_TRADITIONAL_CHINESE 0x0009 // Traditional Chinese 203 #define LGRPID_SIMPLIFIED_CHINESE 0x000a // Simplified Chinese 204 #define LGRPID_THAI 0x000b // Thai 205 #define LGRPID_HEBREW 0x000c // Hebrew 206 #define LGRPID_ARABIC 0x000d // Arabic 207 #define LGRPID_VIETNAMESE 0x000e // Vietnamese 208 #define LGRPID_INDIC 0x000f // Indic 209 #define LGRPID_GEORGIAN 0x0010 // Georgian 210 #define LGRPID_ARMENIAN 0x0011 // Armenian 223 UINT nLayouts = GetKeyboardLayoutList(0, 0);
225 HKL *lpList =
new HKL[nLayouts];
226 GetKeyboardLayoutList(nLayouts, lpList);
227 for (
int i = 0; i<(int)nLayouts; i++) {
228 WORD plangid = PRIMARYLANGID((
quintptr)lpList[i]);
229 if (plangid == LANG_ARABIC
230 || plangid == LANG_HEBREW
231 || plangid == LANG_FARSI
246 || IsValidLocale(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
247 || IsValidLocale(MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
249 || IsValidLocale(MAKELCID(MAKELANGID(
LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
251 || IsValidLocale(MAKELCID(MAKELANGID(LANG_FARSI, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED);
279 aimm->GetDefaultIMEWnd(wnd, &ime_wnd);
281 ime_wnd = ImmGetDefaultIMEWnd(wnd);
289 aimm->GetContext(wnd, &imc);
291 imc = ImmGetContext(wnd);
299 aimm->ReleaseContext(wnd, imc);
301 ImmReleaseContext(wnd, imc);
304 static void notifyIME(HIMC imc, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
309 aimm->NotifyIME(imc, dwAction, dwIndex, dwValue);
311 ImmNotifyIME(imc, dwAction, dwIndex, dwValue);
318 aimm->GetCompositionStringW(himc, dwIndex, dBufLen, &len, lpbuf);
320 len = ImmGetCompositionString(himc, dwIndex, lpbuf, dBufLen);
331 const int bufferSize = 256;
332 wchar_t buffer[bufferSize];
336 char attrbuffer[bufferSize];
338 *selStart = attrlen+1;
340 for (
int i = 0; i < attrlen; i++) {
341 if (attrbuffer[i] & ATTR_TARGET_CONVERTED) {
342 *selStart =
qMin(*selStart, i);
343 *selLength =
qMax(*selLength, i);
346 *selLength =
qMax(0, *selLength - *selStart + 1);
357 if (!aimmpump || aimmpump->OnTranslateMessage(msg) != S_OK)
364 if (!aimm || aimm->OnDefWindowProc(hwnd, msg, wParam, lParam, &retval) != S_OK)
389 if (GetObject(hf,
sizeof(lf), &lf)) {
391 aimm->SetCompositionFontW(imc, &lf);
393 ImmSetCompositionFont(imc, &lf);
400 if (imeWnd && !aimm) {
409 cf.dwStyle = CFS_FORCE_POSITION;
410 cf.ptCurrentPos.x = r.
x();
411 cf.ptCurrentPos.y = r.
y();
415 candf.dwStyle = CFS_EXCLUDE;
416 candf.ptCurrentPos.x = r.
x();
417 candf.ptCurrentPos.y = r.
y() + r.
height();
418 candf.rcArea.left = r.
x();
419 candf.rcArea.top = r.
y();
420 candf.rcArea.right = r.
x() + r.
width();
421 candf.rcArea.bottom = r.
y() + r.
height();
424 SetCaretPos(r.
x(), r.
y());
427 aimm->SetCompositionWindow(imc, &cf);
428 aimm->SetCandidateWindow(imc, &candf);
430 ImmSetCompositionWindow(imc, &cf);
431 ImmSetCandidateWindow(imc, &candf);
442 qDebug(
"endComposition! fw = %s", fw ? fw->className() :
"(null)");
456 notifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
473 imeComposition->
clear();
486 qDebug(
"sending accept to focus widget %s", fw ? fw->className() :
"(null)");
498 imeComposition->
clear();
504 notifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
514 qDebug(
"startComposition");
518 imeComposition =
new QString();
540 if (lParam & GCS_RESULTSTR)
542 if (lParam & GCS_COMPSTR)
544 if (lParam & GCS_COMPATTR)
546 if (lParam & GCS_CURSORPOS)
548 if (lParam & GCS_COMPCLAUSE)
549 str +=
"COMPCLAUSE ";
550 if (lParam & CS_INSERTCHAR)
551 str +=
"INSERTCHAR ";
552 if (lParam & CS_NOMOVECARET)
553 str +=
"NOMOVECARET ";
554 qDebug(
"composition, lParam=(%x) %s imePosition=%d", lParam, str.latin1(),
imePosition);
568 if (lParam & (GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS)) {
574 int selStart, selLength;
575 *imeComposition =
getString(imc, GCS_COMPSTR, &selStart, &selLength);
577 if (lParam & CS_INSERTCHAR && lParam & CS_NOMOVECARET) {
580 selLength = imeComposition->
length();
592 if (selStart + selLength < imeComposition->length())
594 imeComposition->
length() - selStart - selLength,
601 if (lParam & GCS_RESULTSTR) {
605 *imeComposition =
getString(imc, GCS_RESULTSTR);
607 e.setCommitString(*imeComposition);
608 imeComposition->
clear();
615 qDebug(
"imecomposition: cursor pos at %d, str=%x",
imePosition, str[0].unicode());
665 if (
qApp->autoSipEnabled())
674 if (
qApp->autoSipEnabled())
687 if (!focusProxyWidget)
688 focusProxyWidget = w;
691 bool hasIme = e && hasFocus;
693 qDebug(
"%s HasFocus = %d hasIme = %d e = %d ", w->className(), hasFocus, hasIme, e);
713 qDebug(
"enablePopupChild: w=%s, enable = %s", w ? w->className() :
"(null)" , e ?
"true" :
"false");
731 qDebug(
"enable: w=%s, enable = %s", w ? w->className() :
"(null)" , e ?
"true" :
"false");
770 return imeComposition && !imeComposition->
isEmpty();
778 if (pos < 0 || pos > imeComposition->
length())
782 DWORD button = MK_LBUTTON;
789 SendMessage(ime_wnd,
WM_MSIME_MOUSE, MAKELONG(MAKEWORD(button, pos == 0 ? 2 : 1), pos), (LPARAM)himc);
811 if (surroundingText.isEmpty())
819 bounds.setPosition(pos);
820 if (bounds.isAtBoundary()) {
822 bounds.toPreviousBoundary();
824 bounds.toPreviousBoundary();
826 int startPos = bounds.position();
827 bounds.toNextBoundary();
828 int endPos = bounds.position();
838 reconv->
dwStrLen = surroundingText.length();
844 memcpy((
char*)(reconv+1), surroundingText.utf16(), surroundingText.length()*
sizeof(
ushort));
The QVariant class acts like a union for the most common Qt data types.
virtual IFMETHOD EnumInputContext(DWORD idThread, IEnumInputContext __RPC_FAR *__RPC_FAR *ppEnum)=0
virtual IFMETHOD Pause(DWORD __RPC_FAR *pdwCookie)=0
virtual IFMETHOD CreateContext(HIMC __RPC_FAR *phIMC)=0
int reconvertString(RECONVERTSTRING *reconv)
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
static void enable(QWidget *w, bool e)
QIntegerForSizeof< void * >::Unsigned quintptr
virtual IFMETHOD GetProperty(HKL hKL, DWORD fdwIndex, DWORD __RPC_FAR *pdwProperty)=0
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
virtual IFMETHOD GetDefaultIMEWnd(HWND hWnd, HWND __RPC_FAR *phDefWnd)=0
virtual IFMETHOD dummy_InstallIMEA()=0
virtual IFMETHOD GetDescriptionW(HKL hKL, UINT uBufLen, LPWSTR szDescription, UINT __RPC_FAR *puCopied)=0
virtual IFMETHOD EnumRegisterWordW(HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister, LPVOID pData, IEnumRegisterWordW __RPC_FAR *__RPC_FAR *pEnum)=0
static QString * imeComposition
virtual void update()
This virtual function is called when a state in the focus widget has changed.
virtual IFMETHOD IsIME(HKL hKL)=0
virtual void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
int length() const
Returns the number of characters in this string.
virtual IFMETHOD GetStatusWindowPos(HIMC hIMC, POINT __RPC_FAR *pptPos)=0
virtual IFMETHOD GetConversionListW(HKL hKL, HIMC hIMC, LPWSTR pSrc, UINT uBufLen, UINT uFlag, CANDIDATELIST __RPC_FAR *pDst, UINT __RPC_FAR *puCopied)=0
void qt_wince_show_SIP(bool show)
virtual IFMETHOD SetCompositionWindow(HIMC hIMC, COMPOSITIONFORM __RPC_FAR *pCompForm)=0
static WinVersion windowsVersion()
Returns the version of the Windows operating system on which the application is run (Windows only)...
virtual IFMETHOD dummy_GetConversionListA()=0
virtual IFMETHOD GetRegisterWordStyleW(HKL hKL, UINT nItem, STYLEBUFW __RPC_FAR *pStyleBuf, UINT __RPC_FAR *puCopied)=0
int width() const
Returns the width of the rectangle.
virtual IFMETHOD dummy_IsUIMessageA()=0
virtual IFMETHOD AssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags)=0
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
int height() const
Returns the height of the rectangle.
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
virtual IFMETHOD GetCompositionFontW(HIMC hIMC, LOGFONTW __RPC_FAR *plf)=0
The QString class provides a Unicode character string.
HFONT handle() const
Returns the window system handle to the font, for low-level access.
static int getCursorPosition(HIMC himc)
virtual IFMETHOD Resume(DWORD dwCookie)=0
The QObject class is the base class of all Qt objects.
virtual IFMETHOD SetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwCompLen, LPVOID pRead, DWORD dwReadLen)=0
static void TranslateMessage(const MSG *msg)
The QChar class provides a 16-bit Unicode character.
virtual ~QWinInputContext()
virtual IFMETHOD dummy_GetCandidateListCountA()=0
virtual IFMETHOD dummy_SetCompositionStringA()=0
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
virtual bool isComposing() const
This function indicates whether InputMethodStart event had been sent to the current focus widget...
virtual IFMETHOD dummy_RegisterWordA()=0
virtual IFMETHOD IsUIMessageW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)=0
Q_CORE_EXPORT void qDebug(const char *,...)
virtual IFMETHOD dummy_UnregisterWordA()=0
QWinInputContext(QObject *parent=0)
static void updateImeStatus(QWidget *w, bool hasFocus)
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual IFMETHOD GetCompositionStringW(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG __RPC_FAR *plCopied, LPVOID pBuf)=0
static LONG getCompositionString(HIMC himc, DWORD dwIndex, LPVOID lpbuf, DWORD dBufLen)
virtual IFMETHOD dummy_GetDescriptionA()=0
static DWORD WM_MSIME_MOUSE
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
virtual IFMETHOD RegisterWordW(HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister)=0
QTextFormat standardFormat(StandardFormat s) const
Returns a QTextFormat object that specifies the format for component s.
virtual IFMETHOD SimulateHotKey(HWND hWnd, DWORD dwHotKeyID)=0
virtual IFMETHOD GetContext(HWND hWnd, HIMC __RPC_FAR *phIMC)=0
virtual IFMETHOD dummy_GetCandidateListA()=0
virtual IFMETHOD GetCandidateWindow(HIMC hIMC, DWORD dwIndex, CANDIDATEFORM __RPC_FAR *pCandidate)=0
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.
virtual IFMETHOD dummy_ConfigureIMEA()=0
virtual QString language()
This function must be implemented in any subclasses to return a language code (e. ...
virtual IFMETHOD OnTranslateMessage(const MSG __RPC_FAR *pMsg)=0
virtual IFMETHOD dummy_GetCompositionStringA()=0
virtual IFMETHOD ConfigureIMEW(HKL hKL, HWND hWnd, DWORD dwMode, REGISTERWORDW __RPC_FAR *pData)=0
virtual IFMETHOD dummy_EscapeA()=0
bool qt_use_rtl_extensions
struct tagRECONVERTSTRING RECONVERTSTRING
virtual IFMETHOD GetVirtualKey(HWND hWnd, UINT __RPC_FAR *puVirtualKey)=0
virtual IFMETHOD UnregisterWordW(HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szUnregister)=0
virtual IFMETHOD dummy_GetIMEFileNameA()=0
virtual IFMETHOD dummy_GetImeMenuItemsA()=0
The QMouseEvent class contains parameters that describe a mouse event.
virtual IFMETHOD SetCompositionFontW(HIMC hIMC, LOGFONTW __RPC_FAR *plf)=0
virtual IFMETHOD Activate(BOOL fRestoreLayout)=0
virtual IFMETHOD OnDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT __RPC_FAR *plResult)=0
virtual IFMETHOD GetConversionStatus(HIMC hIMC, DWORD __RPC_FAR *pfdwConversion, DWORD __RPC_FAR *pfdwSentence)=0
virtual IFMETHOD GetLangId(HKL hKL, LANGID __RPC_FAR *plid)=0
virtual IFMETHOD EscapeW(HKL hKL, HIMC hIMC, UINT uEscape, LPVOID pData, LRESULT __RPC_FAR *plResult)=0
bool composition(LPARAM lparam)
virtual IFMETHOD dummy_GetRegisterWordStyleA()=0
virtual IFMETHOD Deactivate(void)=0
void enableIme(QWidget *w, bool value)
static HIMC getContext(HWND wnd)
virtual IFMETHOD GetIMEFileNameW(HKL hKL, UINT uBufLen, LPWSTR szFileName, UINT __RPC_FAR *puCopied)=0
The QFont class specifies a font used for drawing text.
int y() const
Returns the y-coordinate of the rectangle's top edge.
virtual IFMETHOD dummy_GetGuideLineA()=0
void clear()
Clears the contents of the string and makes it empty.
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
static void enablePopupChild(QWidget *w, bool e)
virtual IFMETHOD GetCompositionWindow(HIMC hIMC, COMPOSITIONFORM __RPC_FAR *pCompForm)=0
static IActiveIMMMessagePumpOwner * aimmpump
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
virtual IFMETHOD GetCandidateListCountW(HIMC hIMC, DWORD __RPC_FAR *pdwListSize, DWORD __RPC_FAR *pdwBufLen)=0
virtual IFMETHOD SetOpenStatus(HIMC hIMC, BOOL fOpen)=0
The QPoint class defines a point in the plane using integer precision.
virtual IFMETHOD dummy_GetCompositionFontA()=0
virtual IFMETHOD GetGuideLineW(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPWSTR pBuf, DWORD __RPC_FAR *pdwResult)=0
interface HIMC HIMC __RPC_FAR * phPrev
virtual IFMETHOD SetStatusWindowPos(HIMC hIMC, POINT __RPC_FAR *pptPos)=0
The QRect class defines a rectangle in the plane using integer precision.
static HIMC defaultContext
static IActiveIMMApp * aimm
static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
T qvariant_cast(const QVariant &)
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
virtual IFMETHOD GetCandidateListW(HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST __RPC_FAR *pCandList, UINT __RPC_FAR *puCopied)=0
virtual IFMETHOD DestroyContext(HIMC hIME)=0
virtual IFMETHOD dummy_EnumRegisterWordA()=0
virtual IFMETHOD GetOpenStatus(HIMC hIMC)=0
virtual IFMETHOD SetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)=0
WinVersion
This enum provides symbolic names for the various versions of the Windows operating system...
static HWND getDefaultIMEWnd(HWND wnd)
static void releaseContext(HWND wnd, HIMC imc)
static QString getString(HIMC himc, DWORD dwindex, int *selStart=0, int *selLength=0)
static void notifyIME(HIMC imc, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
The QInputContext class abstracts the input method dependent data and composing state.
bool isInPopup(QWidget *w)
virtual IFMETHOD NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)=0
DEFINE_GUID(IID_IActiveIMMApp, 0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e)
QWidget * findParentforPopup(QWidget *w)
virtual IFMETHOD InstallIMEW(LPWSTR szIMEFileName, LPWSTR szLayoutText, HKL __RPC_FAR *phKL)=0
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
virtual IFMETHOD SetCompositionFontA(HIMC hIMC, LOGFONTA __RPC_FAR *plf)=0
virtual IFMETHOD DisableIME(DWORD idThread)=0
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
virtual IFMETHOD FilterClientWindows(ATOM __RPC_FAR *aaClassList, UINT uSize)=0
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
virtual IFMETHOD ReleaseContext(HWND hWnd, HIMC hIMC)=0
virtual IFMETHOD End(void)=0
virtual IFMETHOD dummy_GetCodePageA()=0
virtual IFMETHOD GetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType, void __RPC_FAR *pImeParentMenu, void __RPC_FAR *pImeMenu, DWORD dwSize, DWORD __RPC_FAR *pdwResult)=0
virtual IFMETHOD SetCandidateWindow(HIMC hIMC, CANDIDATEFORM __RPC_FAR *pCandidate)=0
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.