makefiles: Explicitly create destination dirs when installing symlinks.
[wine/zf.git] / dlls / riched20 / txthost.c
blob99f446e58129b890bdd3927abe3c3c339d368275
1 /*
2 * RichEdit - ITextHost implementation for windowed richedit controls
4 * Copyright 2009 by Dylan Smith
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "editor.h"
24 #include "ole2.h"
25 #include "richole.h"
26 #include "imm.h"
27 #include "textserv.h"
28 #include "wine/debug.h"
29 #include "editstr.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
33 typedef struct ITextHostImpl {
34 ITextHost ITextHost_iface;
35 LONG ref;
36 HWND hWnd;
37 BOOL bEmulateVersion10;
38 PARAFORMAT2 para_fmt;
39 } ITextHostImpl;
41 static const ITextHostVtbl textHostVtbl;
43 ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
45 ITextHostImpl *texthost;
47 texthost = CoTaskMemAlloc(sizeof(*texthost));
48 if (!texthost) return NULL;
50 texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
51 texthost->ref = 1;
52 texthost->hWnd = hwnd;
53 texthost->bEmulateVersion10 = bEmulateVersion10;
54 memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) );
55 texthost->para_fmt.cbSize = sizeof(texthost->para_fmt);
56 texthost->para_fmt.dwMask = PFM_ALIGNMENT;
57 texthost->para_fmt.wAlignment = PFA_LEFT;
58 if (cs->style & ES_RIGHT)
59 texthost->para_fmt.wAlignment = PFA_RIGHT;
60 if (cs->style & ES_CENTER)
61 texthost->para_fmt.wAlignment = PFA_CENTER;
63 return &texthost->ITextHost_iface;
66 static inline ITextHostImpl *impl_from_ITextHost(ITextHost *iface)
68 return CONTAINING_RECORD(iface, ITextHostImpl, ITextHost_iface);
71 static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid, void **ppvObject)
73 ITextHostImpl *This = impl_from_ITextHost(iface);
75 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost)) {
76 *ppvObject = &This->ITextHost_iface;
77 ITextHost_AddRef((ITextHost *)*ppvObject);
78 return S_OK;
81 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
82 return E_NOINTERFACE;
85 static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
87 ITextHostImpl *This = impl_from_ITextHost(iface);
88 ULONG ref = InterlockedIncrement(&This->ref);
89 return ref;
92 static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
94 ITextHostImpl *This = impl_from_ITextHost(iface);
95 ULONG ref = InterlockedDecrement(&This->ref);
97 if (!ref)
99 SetWindowLongPtrW(This->hWnd, 0, 0);
100 CoTaskMemFree(This);
102 return ref;
105 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4)
106 DECLSPEC_HIDDEN HDC __thiscall ITextHostImpl_TxGetDC(ITextHost *iface)
108 ITextHostImpl *This = impl_from_ITextHost(iface);
109 return GetDC(This->hWnd);
112 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8)
113 DECLSPEC_HIDDEN INT __thiscall ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
115 ITextHostImpl *This = impl_from_ITextHost(iface);
116 return ReleaseDC(This->hWnd, hdc);
119 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12)
120 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
122 ITextHostImpl *This = impl_from_ITextHost(iface);
123 return ShowScrollBar(This->hWnd, fnBar, fShow);
126 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar,12)
127 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
129 ITextHostImpl *This = impl_from_ITextHost(iface);
130 return EnableScrollBar(This->hWnd, fuSBFlags, fuArrowflags);
133 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange,20)
134 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos, INT nMaxPos,
135 BOOL fRedraw)
137 ITextHostImpl *This = impl_from_ITextHost(iface);
138 return SetScrollRange(This->hWnd, fnBar, nMinPos, nMaxPos, fRedraw);
141 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos,16)
142 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
144 ITextHostImpl *This = impl_from_ITextHost(iface);
145 return SetScrollPos(This->hWnd, fnBar, nPos, fRedraw) != 0;
148 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect,12)
149 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
151 ITextHostImpl *This = impl_from_ITextHost(iface);
152 InvalidateRect(This->hWnd, prc, fMode);
155 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange,8)
156 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
158 ITextHostImpl *This = impl_from_ITextHost(iface);
159 if (fUpdate)
160 UpdateWindow(This->hWnd);
163 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret,16)
164 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
166 ITextHostImpl *This = impl_from_ITextHost(iface);
167 return CreateCaret(This->hWnd, hbmp, xWidth, yHeight);
170 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret,8)
171 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
173 ITextHostImpl *This = impl_from_ITextHost(iface);
174 if (fShow)
175 return ShowCaret(This->hWnd);
176 else
177 return HideCaret(This->hWnd);
180 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos,12)
181 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetCaretPos(ITextHost *iface,
182 INT x, INT y)
184 return SetCaretPos(x, y);
187 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer,12)
188 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
190 ITextHostImpl *This = impl_from_ITextHost(iface);
191 return SetTimer(This->hWnd, idTimer, uTimeout, NULL) != 0;
194 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer,8)
195 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
197 ITextHostImpl *This = impl_from_ITextHost(iface);
198 KillTimer(This->hWnd, idTimer);
201 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx,32)
202 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll,
203 LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate,
204 UINT fuScroll)
206 ITextHostImpl *This = impl_from_ITextHost(iface);
207 ScrollWindowEx(This->hWnd, dx, dy, lprcScroll, lprcClip,
208 hRgnUpdate, lprcUpdate, fuScroll);
211 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture,8)
212 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
214 ITextHostImpl *This = impl_from_ITextHost(iface);
215 if (fCapture)
216 SetCapture(This->hWnd);
217 else
218 ReleaseCapture();
221 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus,4)
222 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetFocus(ITextHost *iface)
224 ITextHostImpl *This = impl_from_ITextHost(iface);
225 SetFocus(This->hWnd);
228 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor,12)
229 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCursor(ITextHost *iface, HCURSOR hcur, BOOL fText)
231 SetCursor(hcur);
234 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient,8)
235 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt)
237 ITextHostImpl *This = impl_from_ITextHost(iface);
238 return ScreenToClient(This->hWnd, lppt);
241 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen,8)
242 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt)
244 ITextHostImpl *This = impl_from_ITextHost(iface);
245 return ClientToScreen(This->hWnd, lppt);
248 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate,8)
249 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
251 ITextHostImpl *This = impl_from_ITextHost(iface);
252 *plOldState = HandleToLong(SetActiveWindow(This->hWnd));
253 return (*plOldState ? S_OK : E_FAIL);
256 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate,8)
257 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState)
259 HWND ret = SetActiveWindow(LongToHandle(lNewState));
260 return (ret ? S_OK : E_FAIL);
263 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect,8)
264 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc)
266 ITextHostImpl *This = impl_from_ITextHost(iface);
267 int ret = GetClientRect(This->hWnd, prc);
268 return (ret ? S_OK : E_FAIL);
271 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset,8)
272 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetViewInset(ITextHost *iface, LPRECT prc)
274 prc->top = 0;
275 prc->left = 0;
276 prc->bottom = 0;
277 prc->right = 0;
278 return S_OK;
281 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetCharFormat,8)
282 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetCharFormat(ITextHost *iface, const CHARFORMATW **ppCF)
284 return E_NOTIMPL;
287 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat,8)
288 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetParaFormat(ITextHost *iface, const PARAFORMAT **fmt)
290 ITextHostImpl *This = impl_from_ITextHost(iface);
291 *fmt = (const PARAFORMAT *)&This->para_fmt;
292 return S_OK;
295 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor,8)
296 DECLSPEC_HIDDEN COLORREF __thiscall ITextHostImpl_TxGetSysColor(ITextHost *iface, int nIndex)
298 return GetSysColor(nIndex);
301 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle,8)
302 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetBackStyle(ITextHost *iface, TXTBACKSTYLE *pStyle)
304 *pStyle = TXTBACK_OPAQUE;
305 return S_OK;
308 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength,8)
309 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetMaxLength(ITextHost *iface, DWORD *pLength)
311 *pLength = INFINITE;
312 return S_OK;
315 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars,8)
316 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
318 ITextHostImpl *This = impl_from_ITextHost(iface);
319 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
320 const DWORD mask = WS_VSCROLL|
321 WS_HSCROLL|
322 ES_AUTOVSCROLL|
323 ES_AUTOHSCROLL|
324 ES_DISABLENOSCROLL;
325 if (editor)
327 *pdwScrollBar = editor->styleFlags & mask;
328 } else {
329 DWORD style = GetWindowLongW(This->hWnd, GWL_STYLE);
330 if (style & WS_VSCROLL)
331 style |= ES_AUTOVSCROLL;
332 if (!This->bEmulateVersion10 && (style & WS_HSCROLL))
333 style |= ES_AUTOHSCROLL;
334 *pdwScrollBar = style & mask;
336 return S_OK;
339 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8)
340 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPasswordChar(ITextHost *iface, WCHAR *pch)
342 *pch = '*';
343 return S_OK;
346 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8)
347 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface, LONG *pch)
349 *pch = -1;
350 return S_OK;
353 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent,8)
354 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetExtent(ITextHost *iface, LPSIZEL lpExtent)
356 return E_NOTIMPL;
359 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxCharFormatChange,8)
360 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_OnTxCharFormatChange(ITextHost *iface, const CHARFORMATW *pcf)
362 return S_OK;
365 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxParaFormatChange,8)
366 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_OnTxParaFormatChange(ITextHost *iface, const PARAFORMAT *ppf)
368 return S_OK;
371 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits,12)
372 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
374 ITextHostImpl *This = impl_from_ITextHost(iface);
375 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
376 DWORD style;
377 DWORD dwBits = 0;
379 if (editor)
381 style = editor->styleFlags;
382 if (editor->mode & TM_RICHTEXT)
383 dwBits |= TXTBIT_RICHTEXT;
384 if (editor->bWordWrap)
385 dwBits |= TXTBIT_WORDWRAP;
386 if (style & ECO_AUTOWORDSELECTION)
387 dwBits |= TXTBIT_AUTOWORDSEL;
388 } else {
389 DWORD dwScrollBar;
391 style = GetWindowLongW(This->hWnd, GWL_STYLE);
392 ITextHostImpl_TxGetScrollBars(iface, &dwScrollBar);
394 dwBits |= TXTBIT_RICHTEXT|TXTBIT_AUTOWORDSEL;
395 if (!(dwScrollBar & ES_AUTOHSCROLL))
396 dwBits |= TXTBIT_WORDWRAP;
399 /* Bits that correspond to window styles. */
400 if (style & ES_MULTILINE)
401 dwBits |= TXTBIT_MULTILINE;
402 if (style & ES_READONLY)
403 dwBits |= TXTBIT_READONLY;
404 if (style & ES_PASSWORD)
405 dwBits |= TXTBIT_USEPASSWORD;
406 if (!(style & ES_NOHIDESEL))
407 dwBits |= TXTBIT_HIDESELECTION;
408 if (style & ES_SAVESEL)
409 dwBits |= TXTBIT_SAVESELECTION;
410 if (style & ES_VERTICAL)
411 dwBits |= TXTBIT_VERTICAL;
412 if (style & ES_NOOLEDRAGDROP)
413 dwBits |= TXTBIT_DISABLEDRAG;
415 dwBits |= TXTBIT_ALLOWBEEP;
417 /* The following bits are always FALSE because they are probably only
418 * needed for ITextServices_OnTxPropertyBitsChange:
419 * TXTBIT_VIEWINSETCHANGE
420 * TXTBIT_BACKSTYLECHANGE
421 * TXTBIT_MAXLENGTHCHANGE
422 * TXTBIT_CHARFORMATCHANGE
423 * TXTBIT_PARAFORMATCHANGE
424 * TXTBIT_SHOWACCELERATOR
425 * TXTBIT_EXTENTCHANGE
426 * TXTBIT_SELBARCHANGE
427 * TXTBIT_SCROLLBARCHANGE
428 * TXTBIT_CLIENTRECTCHANGE
430 * Documented by MSDN as not supported:
431 * TXTBIT_USECURRENTBKG
434 *pdwBits = dwBits & dwMask;
435 return S_OK;
438 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify,12)
439 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
441 ITextHostImpl *This = impl_from_ITextHost(iface);
442 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
443 HWND hwnd = This->hWnd;
444 UINT id;
446 if (!editor || !editor->hwndParent) return S_OK;
448 id = GetWindowLongW(hwnd, GWLP_ID);
450 switch (iNotify)
452 case EN_DROPFILES:
453 case EN_LINK:
454 case EN_OLEOPFAILED:
455 case EN_PROTECTED:
456 case EN_REQUESTRESIZE:
457 case EN_SAVECLIPBOARD:
458 case EN_SELCHANGE:
459 case EN_STOPNOUNDO:
461 /* FIXME: Verify this assumption that pv starts with NMHDR. */
462 NMHDR *info = pv;
463 if (!info)
464 return E_FAIL;
466 info->hwndFrom = hwnd;
467 info->idFrom = id;
468 info->code = iNotify;
469 SendMessageW(editor->hwndParent, WM_NOTIFY, id, (LPARAM)info);
470 break;
473 case EN_UPDATE:
474 /* Only sent when the window is visible. */
475 if (!IsWindowVisible(hwnd))
476 break;
477 /* Fall through */
478 case EN_CHANGE:
479 case EN_ERRSPACE:
480 case EN_HSCROLL:
481 case EN_KILLFOCUS:
482 case EN_MAXTEXT:
483 case EN_SETFOCUS:
484 case EN_VSCROLL:
485 SendMessageW(editor->hwndParent, WM_COMMAND, MAKEWPARAM(id, iNotify), (LPARAM)hwnd);
486 break;
488 case EN_MSGFILTER:
489 FIXME("EN_MSGFILTER is documented as not being sent to TxNotify\n");
490 /* fall through */
491 default:
492 return E_FAIL;
494 return S_OK;
497 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4)
498 DECLSPEC_HIDDEN HIMC __thiscall ITextHostImpl_TxImmGetContext(ITextHost *iface)
500 ITextHostImpl *This = impl_from_ITextHost(iface);
501 return ImmGetContext(This->hWnd);
504 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8)
505 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
507 ITextHostImpl *This = impl_from_ITextHost(iface);
508 ImmReleaseContext(This->hWnd, himc);
511 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
512 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
514 ITextHostImpl *This = impl_from_ITextHost(iface);
515 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
517 DWORD style = editor ? editor->styleFlags
518 : GetWindowLongW(This->hWnd, GWL_STYLE);
519 *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
520 return S_OK;
524 #ifdef __ASM_USE_THISCALL_WRAPPER
526 #define STDCALL(func) (void *) __stdcall_ ## func
527 #ifdef _MSC_VER
528 #define DEFINE_STDCALL_WRAPPER(num,func,args) \
529 __declspec(naked) HRESULT __stdcall_##func(void) \
531 __asm pop eax \
532 __asm pop ecx \
533 __asm push eax \
534 __asm mov eax, [ecx] \
535 __asm jmp dword ptr [eax + 4*num] \
537 #else /* _MSC_VER */
538 #define DEFINE_STDCALL_WRAPPER(num,func,args) \
539 extern HRESULT __stdcall_ ## func(void); \
540 __ASM_GLOBAL_FUNC(__stdcall_ ## func, \
541 "popl %eax\n\t" \
542 "popl %ecx\n\t" \
543 "pushl %eax\n\t" \
544 "movl (%ecx), %eax\n\t" \
545 "jmp *(4*(" #num "))(%eax)" )
546 #endif /* _MSC_VER */
548 DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4)
549 DEFINE_STDCALL_WRAPPER(4,ITextHostImpl_TxReleaseDC,8)
550 DEFINE_STDCALL_WRAPPER(5,ITextHostImpl_TxShowScrollBar,12)
551 DEFINE_STDCALL_WRAPPER(6,ITextHostImpl_TxEnableScrollBar,12)
552 DEFINE_STDCALL_WRAPPER(7,ITextHostImpl_TxSetScrollRange,20)
553 DEFINE_STDCALL_WRAPPER(8,ITextHostImpl_TxSetScrollPos,16)
554 DEFINE_STDCALL_WRAPPER(9,ITextHostImpl_TxInvalidateRect,12)
555 DEFINE_STDCALL_WRAPPER(10,ITextHostImpl_TxViewChange,8)
556 DEFINE_STDCALL_WRAPPER(11,ITextHostImpl_TxCreateCaret,16)
557 DEFINE_STDCALL_WRAPPER(12,ITextHostImpl_TxShowCaret,8)
558 DEFINE_STDCALL_WRAPPER(13,ITextHostImpl_TxSetCaretPos,12)
559 DEFINE_STDCALL_WRAPPER(14,ITextHostImpl_TxSetTimer,12)
560 DEFINE_STDCALL_WRAPPER(15,ITextHostImpl_TxKillTimer,8)
561 DEFINE_STDCALL_WRAPPER(16,ITextHostImpl_TxScrollWindowEx,32)
562 DEFINE_STDCALL_WRAPPER(17,ITextHostImpl_TxSetCapture,8)
563 DEFINE_STDCALL_WRAPPER(18,ITextHostImpl_TxSetFocus,4)
564 DEFINE_STDCALL_WRAPPER(19,ITextHostImpl_TxSetCursor,12)
565 DEFINE_STDCALL_WRAPPER(20,ITextHostImpl_TxScreenToClient,8)
566 DEFINE_STDCALL_WRAPPER(21,ITextHostImpl_TxClientToScreen,8)
567 DEFINE_STDCALL_WRAPPER(22,ITextHostImpl_TxActivate,8)
568 DEFINE_STDCALL_WRAPPER(23,ITextHostImpl_TxDeactivate,8)
569 DEFINE_STDCALL_WRAPPER(24,ITextHostImpl_TxGetClientRect,8)
570 DEFINE_STDCALL_WRAPPER(25,ITextHostImpl_TxGetViewInset,8)
571 DEFINE_STDCALL_WRAPPER(26,ITextHostImpl_TxGetCharFormat,8)
572 DEFINE_STDCALL_WRAPPER(27,ITextHostImpl_TxGetParaFormat,8)
573 DEFINE_STDCALL_WRAPPER(28,ITextHostImpl_TxGetSysColor,8)
574 DEFINE_STDCALL_WRAPPER(29,ITextHostImpl_TxGetBackStyle,8)
575 DEFINE_STDCALL_WRAPPER(30,ITextHostImpl_TxGetMaxLength,8)
576 DEFINE_STDCALL_WRAPPER(31,ITextHostImpl_TxGetScrollBars,8)
577 DEFINE_STDCALL_WRAPPER(32,ITextHostImpl_TxGetPasswordChar,8)
578 DEFINE_STDCALL_WRAPPER(33,ITextHostImpl_TxGetAcceleratorPos,8)
579 DEFINE_STDCALL_WRAPPER(34,ITextHostImpl_TxGetExtent,8)
580 DEFINE_STDCALL_WRAPPER(35,ITextHostImpl_OnTxCharFormatChange,8)
581 DEFINE_STDCALL_WRAPPER(36,ITextHostImpl_OnTxParaFormatChange,8)
582 DEFINE_STDCALL_WRAPPER(37,ITextHostImpl_TxGetPropertyBits,12)
583 DEFINE_STDCALL_WRAPPER(38,ITextHostImpl_TxNotify,12)
584 DEFINE_STDCALL_WRAPPER(39,ITextHostImpl_TxImmGetContext,4)
585 DEFINE_STDCALL_WRAPPER(40,ITextHostImpl_TxImmReleaseContext,8)
586 DEFINE_STDCALL_WRAPPER(41,ITextHostImpl_TxGetSelectionBarWidth,8)
588 const ITextHostVtbl itextHostStdcallVtbl = {
589 NULL,
590 NULL,
591 NULL,
592 STDCALL(ITextHostImpl_TxGetDC),
593 STDCALL(ITextHostImpl_TxReleaseDC),
594 STDCALL(ITextHostImpl_TxShowScrollBar),
595 STDCALL(ITextHostImpl_TxEnableScrollBar),
596 STDCALL(ITextHostImpl_TxSetScrollRange),
597 STDCALL(ITextHostImpl_TxSetScrollPos),
598 STDCALL(ITextHostImpl_TxInvalidateRect),
599 STDCALL(ITextHostImpl_TxViewChange),
600 STDCALL(ITextHostImpl_TxCreateCaret),
601 STDCALL(ITextHostImpl_TxShowCaret),
602 STDCALL(ITextHostImpl_TxSetCaretPos),
603 STDCALL(ITextHostImpl_TxSetTimer),
604 STDCALL(ITextHostImpl_TxKillTimer),
605 STDCALL(ITextHostImpl_TxScrollWindowEx),
606 STDCALL(ITextHostImpl_TxSetCapture),
607 STDCALL(ITextHostImpl_TxSetFocus),
608 STDCALL(ITextHostImpl_TxSetCursor),
609 STDCALL(ITextHostImpl_TxScreenToClient),
610 STDCALL(ITextHostImpl_TxClientToScreen),
611 STDCALL(ITextHostImpl_TxActivate),
612 STDCALL(ITextHostImpl_TxDeactivate),
613 STDCALL(ITextHostImpl_TxGetClientRect),
614 STDCALL(ITextHostImpl_TxGetViewInset),
615 STDCALL(ITextHostImpl_TxGetCharFormat),
616 STDCALL(ITextHostImpl_TxGetParaFormat),
617 STDCALL(ITextHostImpl_TxGetSysColor),
618 STDCALL(ITextHostImpl_TxGetBackStyle),
619 STDCALL(ITextHostImpl_TxGetMaxLength),
620 STDCALL(ITextHostImpl_TxGetScrollBars),
621 STDCALL(ITextHostImpl_TxGetPasswordChar),
622 STDCALL(ITextHostImpl_TxGetAcceleratorPos),
623 STDCALL(ITextHostImpl_TxGetExtent),
624 STDCALL(ITextHostImpl_OnTxCharFormatChange),
625 STDCALL(ITextHostImpl_OnTxParaFormatChange),
626 STDCALL(ITextHostImpl_TxGetPropertyBits),
627 STDCALL(ITextHostImpl_TxNotify),
628 STDCALL(ITextHostImpl_TxImmGetContext),
629 STDCALL(ITextHostImpl_TxImmReleaseContext),
630 STDCALL(ITextHostImpl_TxGetSelectionBarWidth),
633 #endif /* __i386__ */
635 static const ITextHostVtbl textHostVtbl = {
636 ITextHostImpl_QueryInterface,
637 ITextHostImpl_AddRef,
638 ITextHostImpl_Release,
639 THISCALL(ITextHostImpl_TxGetDC),
640 THISCALL(ITextHostImpl_TxReleaseDC),
641 THISCALL(ITextHostImpl_TxShowScrollBar),
642 THISCALL(ITextHostImpl_TxEnableScrollBar),
643 THISCALL(ITextHostImpl_TxSetScrollRange),
644 THISCALL(ITextHostImpl_TxSetScrollPos),
645 THISCALL(ITextHostImpl_TxInvalidateRect),
646 THISCALL(ITextHostImpl_TxViewChange),
647 THISCALL(ITextHostImpl_TxCreateCaret),
648 THISCALL(ITextHostImpl_TxShowCaret),
649 THISCALL(ITextHostImpl_TxSetCaretPos),
650 THISCALL(ITextHostImpl_TxSetTimer),
651 THISCALL(ITextHostImpl_TxKillTimer),
652 THISCALL(ITextHostImpl_TxScrollWindowEx),
653 THISCALL(ITextHostImpl_TxSetCapture),
654 THISCALL(ITextHostImpl_TxSetFocus),
655 THISCALL(ITextHostImpl_TxSetCursor),
656 THISCALL(ITextHostImpl_TxScreenToClient),
657 THISCALL(ITextHostImpl_TxClientToScreen),
658 THISCALL(ITextHostImpl_TxActivate),
659 THISCALL(ITextHostImpl_TxDeactivate),
660 THISCALL(ITextHostImpl_TxGetClientRect),
661 THISCALL(ITextHostImpl_TxGetViewInset),
662 THISCALL(ITextHostImpl_TxGetCharFormat),
663 THISCALL(ITextHostImpl_TxGetParaFormat),
664 THISCALL(ITextHostImpl_TxGetSysColor),
665 THISCALL(ITextHostImpl_TxGetBackStyle),
666 THISCALL(ITextHostImpl_TxGetMaxLength),
667 THISCALL(ITextHostImpl_TxGetScrollBars),
668 THISCALL(ITextHostImpl_TxGetPasswordChar),
669 THISCALL(ITextHostImpl_TxGetAcceleratorPos),
670 THISCALL(ITextHostImpl_TxGetExtent),
671 THISCALL(ITextHostImpl_OnTxCharFormatChange),
672 THISCALL(ITextHostImpl_OnTxParaFormatChange),
673 THISCALL(ITextHostImpl_TxGetPropertyBits),
674 THISCALL(ITextHostImpl_TxNotify),
675 THISCALL(ITextHostImpl_TxImmGetContext),
676 THISCALL(ITextHostImpl_TxImmReleaseContext),
677 THISCALL(ITextHostImpl_TxGetSelectionBarWidth),