d3d9: Get rid of IDirect3DVertexBuffer9Impl.
[wine.git] / dlls / riched20 / txthost.c
blobbc96588abdfb2ac76afc94973b9f6b2f9d490483
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 #include "config.h"
22 #include "wine/port.h"
24 #define NONAMELESSSTRUCT
25 #define NONAMELESSUNION
26 #define COBJMACROS
28 #include "editor.h"
29 #include "ole2.h"
30 #include "richole.h"
31 #include "imm.h"
32 #include "textserv.h"
33 #include "wine/debug.h"
34 #include "editstr.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
38 typedef struct ITextHostImpl {
39 ITextHost ITextHost_iface;
40 LONG ref;
41 HWND hWnd;
42 BOOL bEmulateVersion10;
43 } ITextHostImpl;
45 static const ITextHostVtbl textHostVtbl;
47 ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
49 ITextHostImpl *texthost;
50 texthost = CoTaskMemAlloc(sizeof(*texthost));
51 if (texthost)
53 ME_TextEditor *editor;
55 texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
56 texthost->ref = 1;
57 texthost->hWnd = hwnd;
58 texthost->bEmulateVersion10 = bEmulateVersion10;
60 editor = ME_MakeEditor(&texthost->ITextHost_iface, bEmulateVersion10);
61 editor->exStyleFlags = GetWindowLongW(hwnd, GWL_EXSTYLE);
62 editor->styleFlags |= GetWindowLongW(hwnd, GWL_STYLE) & ES_WANTRETURN;
63 editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
64 editor->hwndParent = cs->hwndParent;
65 SetWindowLongPtrW(hwnd, 0, (LONG_PTR)editor);
68 return &texthost->ITextHost_iface;
71 static inline ITextHostImpl *impl_from_ITextHost(ITextHost *iface)
73 return CONTAINING_RECORD(iface, ITextHostImpl, ITextHost_iface);
76 static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid, void **ppvObject)
78 ITextHostImpl *This = impl_from_ITextHost(iface);
80 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost)) {
81 *ppvObject = This;
82 ITextHost_AddRef((ITextHost *)*ppvObject);
83 return S_OK;
86 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
87 return E_NOINTERFACE;
90 static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
92 ITextHostImpl *This = impl_from_ITextHost(iface);
93 ULONG ref = InterlockedIncrement(&This->ref);
94 return ref;
97 static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
99 ITextHostImpl *This = impl_from_ITextHost(iface);
100 ULONG ref = InterlockedDecrement(&This->ref);
102 if (!ref)
104 SetWindowLongPtrW(This->hWnd, 0, 0);
105 CoTaskMemFree(This);
107 return ref;
110 DECLSPEC_HIDDEN HDC WINAPI ITextHostImpl_TxGetDC(ITextHost *iface)
112 ITextHostImpl *This = impl_from_ITextHost(iface);
113 return GetDC(This->hWnd);
116 DECLSPEC_HIDDEN INT WINAPI ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
118 ITextHostImpl *This = impl_from_ITextHost(iface);
119 return ReleaseDC(This->hWnd, hdc);
122 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
124 ITextHostImpl *This = impl_from_ITextHost(iface);
125 return ShowScrollBar(This->hWnd, fnBar, fShow);
128 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
130 ITextHostImpl *This = impl_from_ITextHost(iface);
131 return EnableScrollBar(This->hWnd, fuSBFlags, fuArrowflags);
134 DECLSPEC_HIDDEN BOOL WINAPI 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 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
143 ITextHostImpl *This = impl_from_ITextHost(iface);
144 int pos = SetScrollPos(This->hWnd, fnBar, nPos, fRedraw);
145 return (pos ? TRUE : FALSE);
148 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
150 ITextHostImpl *This = impl_from_ITextHost(iface);
151 InvalidateRect(This->hWnd, prc, fMode);
154 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
156 ITextHostImpl *This = impl_from_ITextHost(iface);
157 if (fUpdate)
158 UpdateWindow(This->hWnd);
161 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
163 ITextHostImpl *This = impl_from_ITextHost(iface);
164 return CreateCaret(This->hWnd, hbmp, xWidth, yHeight);
167 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
169 ITextHostImpl *This = impl_from_ITextHost(iface);
170 if (fShow)
171 return ShowCaret(This->hWnd);
172 else
173 return HideCaret(This->hWnd);
176 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetCaretPos(ITextHost *iface,
177 INT x, INT y)
179 return SetCaretPos(x, y);
182 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
184 ITextHostImpl *This = impl_from_ITextHost(iface);
185 return SetTimer(This->hWnd, idTimer, uTimeout, NULL) != 0;
188 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
190 ITextHostImpl *This = impl_from_ITextHost(iface);
191 KillTimer(This->hWnd, idTimer);
194 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll,
195 LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate,
196 UINT fuScroll)
198 ITextHostImpl *This = impl_from_ITextHost(iface);
199 ScrollWindowEx(This->hWnd, dx, dy, lprcScroll, lprcClip,
200 hRgnUpdate, lprcUpdate, fuScroll);
203 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
205 ITextHostImpl *This = impl_from_ITextHost(iface);
206 if (fCapture)
207 SetCapture(This->hWnd);
208 else
209 ReleaseCapture();
212 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxSetFocus(ITextHost *iface)
214 ITextHostImpl *This = impl_from_ITextHost(iface);
215 SetFocus(This->hWnd);
218 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxSetCursor(ITextHost *iface,
219 HCURSOR hcur,
220 BOOL fText)
222 SetCursor(hcur);
225 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt)
227 ITextHostImpl *This = impl_from_ITextHost(iface);
228 return ScreenToClient(This->hWnd, lppt);
231 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt)
233 ITextHostImpl *This = impl_from_ITextHost(iface);
234 return ClientToScreen(This->hWnd, lppt);
237 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
239 ITextHostImpl *This = impl_from_ITextHost(iface);
240 *plOldState = HandleToLong(SetActiveWindow(This->hWnd));
241 return (*plOldState ? S_OK : E_FAIL);
244 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxDeactivate(ITextHost *iface,
245 LONG lNewState)
247 HWND ret = SetActiveWindow(LongToHandle(lNewState));
248 return (ret ? S_OK : E_FAIL);
251 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc)
253 ITextHostImpl *This = impl_from_ITextHost(iface);
254 int ret = GetClientRect(This->hWnd, prc);
255 return (ret ? S_OK : E_FAIL);
258 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetViewInset(ITextHost *iface,
259 LPRECT prc)
261 prc->top = 0;
262 prc->left = 0;
263 prc->bottom = 0;
264 prc->right = 0;
265 return S_OK;
268 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface,
269 const CHARFORMATW **ppCF)
271 return E_NOTIMPL;
274 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface,
275 const PARAFORMAT **ppPF)
277 return E_NOTIMPL;
280 DECLSPEC_HIDDEN COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface,
281 int nIndex)
283 return GetSysColor(nIndex);
286 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetBackStyle(ITextHost *iface,
287 TXTBACKSTYLE *pStyle)
289 *pStyle = TXTBACK_OPAQUE;
290 return S_OK;
293 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetMaxLength(ITextHost *iface,
294 DWORD *pLength)
296 *pLength = INFINITE;
297 return S_OK;
300 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
302 ITextHostImpl *This = impl_from_ITextHost(iface);
303 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
304 const DWORD mask = WS_VSCROLL|
305 WS_HSCROLL|
306 ES_AUTOVSCROLL|
307 ES_AUTOHSCROLL|
308 ES_DISABLENOSCROLL;
309 if (editor)
311 *pdwScrollBar = editor->styleFlags & mask;
312 } else {
313 DWORD style = GetWindowLongW(This->hWnd, GWL_STYLE);
314 if (style & WS_VSCROLL)
315 style |= ES_AUTOVSCROLL;
316 if (!This->bEmulateVersion10 && (style & WS_HSCROLL))
317 style |= ES_AUTOHSCROLL;
318 *pdwScrollBar = style & mask;
320 return S_OK;
323 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetPasswordChar(ITextHost *iface,
324 WCHAR *pch)
326 *pch = '*';
327 return S_OK;
330 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface,
331 LONG *pch)
333 *pch = -1;
334 return S_OK;
337 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetExtent(ITextHost *iface,
338 LPSIZEL lpExtent)
340 return E_NOTIMPL;
343 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_OnTxCharFormatChange(ITextHost *iface,
344 const CHARFORMATW *pcf)
346 return S_OK;
349 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_OnTxParaFormatChange(ITextHost *iface,
350 const PARAFORMAT *ppf)
352 return S_OK;
355 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
357 ITextHostImpl *This = impl_from_ITextHost(iface);
358 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
359 DWORD style;
360 DWORD dwBits = 0;
362 if (editor)
364 style = editor->styleFlags;
365 if (editor->mode & TM_RICHTEXT)
366 dwBits |= TXTBIT_RICHTEXT;
367 if (editor->bWordWrap)
368 dwBits |= TXTBIT_WORDWRAP;
369 if (style & ECO_AUTOWORDSELECTION)
370 dwBits |= TXTBIT_AUTOWORDSEL;
371 } else {
372 DWORD dwScrollBar;
374 style = GetWindowLongW(This->hWnd, GWL_STYLE);
375 ITextHostImpl_TxGetScrollBars(iface, &dwScrollBar);
377 dwBits |= TXTBIT_RICHTEXT|TXTBIT_AUTOWORDSEL;
378 if (!(dwScrollBar & ES_AUTOHSCROLL))
379 dwBits |= TXTBIT_WORDWRAP;
382 /* Bits that correspond to window styles. */
383 if (style & ES_MULTILINE)
384 dwBits |= TXTBIT_MULTILINE;
385 if (style & ES_READONLY)
386 dwBits |= TXTBIT_READONLY;
387 if (style & ES_PASSWORD)
388 dwBits |= TXTBIT_USEPASSWORD;
389 if (!(style & ES_NOHIDESEL))
390 dwBits |= TXTBIT_HIDESELECTION;
391 if (style & ES_SAVESEL)
392 dwBits |= TXTBIT_SAVESELECTION;
393 if (style & ES_VERTICAL)
394 dwBits |= TXTBIT_VERTICAL;
395 if (style & ES_NOOLEDRAGDROP)
396 dwBits |= TXTBIT_DISABLEDRAG;
398 dwBits |= TXTBIT_ALLOWBEEP;
400 /* The following bits are always FALSE because they are probably only
401 * needed for ITextServices_OnTxPropertyBitsChange:
402 * TXTBIT_VIEWINSETCHANGE
403 * TXTBIT_BACKSTYLECHANGE
404 * TXTBIT_MAXLENGTHCHANGE
405 * TXTBIT_CHARFORMATCHANGE
406 * TXTBIT_PARAFORMATCHANGE
407 * TXTBIT_SHOWACCELERATOR
408 * TXTBIT_EXTENTCHANGE
409 * TXTBIT_SELBARCHANGE
410 * TXTBIT_SCROLLBARCHANGE
411 * TXTBIT_CLIENTRECTCHANGE
413 * Documented by MSDN as not supported:
414 * TXTBIT_USECURRENTBKG
417 *pdwBits = dwBits & dwMask;
418 return S_OK;
421 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
423 ITextHostImpl *This = impl_from_ITextHost(iface);
424 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
425 HWND hwnd = This->hWnd;
426 UINT id;
428 if (!editor || !editor->hwndParent) return S_OK;
430 id = GetWindowLongW(hwnd, GWLP_ID);
432 switch (iNotify)
434 case EN_DROPFILES:
435 case EN_LINK:
436 case EN_OLEOPFAILED:
437 case EN_PROTECTED:
438 case EN_REQUESTRESIZE:
439 case EN_SAVECLIPBOARD:
440 case EN_SELCHANGE:
441 case EN_STOPNOUNDO:
443 /* FIXME: Verify this assumption that pv starts with NMHDR. */
444 NMHDR *info = pv;
445 if (!info)
446 return E_FAIL;
448 info->hwndFrom = hwnd;
449 info->idFrom = id;
450 info->code = iNotify;
451 SendMessageW(editor->hwndParent, WM_NOTIFY, id, (LPARAM)info);
452 break;
455 case EN_UPDATE:
456 /* Only sent when the window is visible. */
457 if (!IsWindowVisible(hwnd))
458 break;
459 /* Fall through */
460 case EN_CHANGE:
461 case EN_ERRSPACE:
462 case EN_HSCROLL:
463 case EN_KILLFOCUS:
464 case EN_MAXTEXT:
465 case EN_SETFOCUS:
466 case EN_VSCROLL:
467 SendMessageW(editor->hwndParent, WM_COMMAND, MAKEWPARAM(id, iNotify), (LPARAM)hwnd);
468 break;
470 case EN_MSGFILTER:
471 FIXME("EN_MSGFILTER is documented as not being sent to TxNotify\n");
472 /* fall through */
473 default:
474 return E_FAIL;
476 return S_OK;
479 DECLSPEC_HIDDEN HIMC WINAPI ITextHostImpl_TxImmGetContext(ITextHost *iface)
481 ITextHostImpl *This = impl_from_ITextHost(iface);
482 return ImmGetContext(This->hWnd);
485 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
487 ITextHostImpl *This = impl_from_ITextHost(iface);
488 ImmReleaseContext(This->hWnd, himc);
491 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
493 ITextHostImpl *This = impl_from_ITextHost(iface);
494 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
496 DWORD style = editor ? editor->styleFlags
497 : GetWindowLongW(This->hWnd, GWL_STYLE);
498 *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
499 return S_OK;
503 #ifdef __i386__ /* thiscall functions are i386-specific */
505 #define THISCALL(func) __thiscall_ ## func
506 #define DEFINE_THISCALL_WRAPPER(func,args) \
507 extern typeof(func) THISCALL(func); \
508 __ASM_STDCALL_FUNC(__thiscall_ ## func, args, \
509 "popl %eax\n\t" \
510 "pushl %ecx\n\t" \
511 "pushl %eax\n\t" \
512 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
514 #else /* __i386__ */
516 #define THISCALL(func) func
517 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
519 #endif /* __i386__ */
521 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4)
522 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8)
523 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12)
524 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar,12)
525 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange,20)
526 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos,16)
527 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect,12)
528 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange,8)
529 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret,16)
530 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret,8)
531 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos,12)
532 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer,12)
533 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer,8)
534 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx,32)
535 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture,8)
536 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus,4)
537 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor,12)
538 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient,8)
539 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen,8)
540 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate,8)
541 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate,8)
542 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect,8)
543 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset,8)
544 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetCharFormat,8)
545 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat,8)
546 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor,8)
547 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle,8)
548 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength,8)
549 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars,8)
550 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8)
551 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8)
552 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent,8)
553 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxCharFormatChange,8)
554 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxParaFormatChange,8)
555 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits,12)
556 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify,12)
557 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4)
558 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8)
559 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
561 #ifdef __i386__ /* thiscall functions are i386-specific */
563 #define STDCALL(func) __stdcall_ ## func
564 #define DEFINE_STDCALL_WRAPPER(num,func,args) \
565 extern typeof(func) __stdcall_ ## func; \
566 __ASM_STDCALL_FUNC(__stdcall_ ## func, args, \
567 "popl %eax\n\t" \
568 "popl %ecx\n\t" \
569 "pushl %eax\n\t" \
570 "movl (%ecx), %eax\n\t" \
571 "jmp *(4*(" #num "))(%eax)" )
573 DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4)
574 DEFINE_STDCALL_WRAPPER(4,ITextHostImpl_TxReleaseDC,8)
575 DEFINE_STDCALL_WRAPPER(5,ITextHostImpl_TxShowScrollBar,12)
576 DEFINE_STDCALL_WRAPPER(6,ITextHostImpl_TxEnableScrollBar,12)
577 DEFINE_STDCALL_WRAPPER(7,ITextHostImpl_TxSetScrollRange,20)
578 DEFINE_STDCALL_WRAPPER(8,ITextHostImpl_TxSetScrollPos,16)
579 DEFINE_STDCALL_WRAPPER(9,ITextHostImpl_TxInvalidateRect,12)
580 DEFINE_STDCALL_WRAPPER(10,ITextHostImpl_TxViewChange,8)
581 DEFINE_STDCALL_WRAPPER(11,ITextHostImpl_TxCreateCaret,16)
582 DEFINE_STDCALL_WRAPPER(12,ITextHostImpl_TxShowCaret,8)
583 DEFINE_STDCALL_WRAPPER(13,ITextHostImpl_TxSetCaretPos,12)
584 DEFINE_STDCALL_WRAPPER(14,ITextHostImpl_TxSetTimer,12)
585 DEFINE_STDCALL_WRAPPER(15,ITextHostImpl_TxKillTimer,8)
586 DEFINE_STDCALL_WRAPPER(16,ITextHostImpl_TxScrollWindowEx,32)
587 DEFINE_STDCALL_WRAPPER(17,ITextHostImpl_TxSetCapture,8)
588 DEFINE_STDCALL_WRAPPER(18,ITextHostImpl_TxSetFocus,4)
589 DEFINE_STDCALL_WRAPPER(19,ITextHostImpl_TxSetCursor,12)
590 DEFINE_STDCALL_WRAPPER(20,ITextHostImpl_TxScreenToClient,8)
591 DEFINE_STDCALL_WRAPPER(21,ITextHostImpl_TxClientToScreen,8)
592 DEFINE_STDCALL_WRAPPER(22,ITextHostImpl_TxActivate,8)
593 DEFINE_STDCALL_WRAPPER(23,ITextHostImpl_TxDeactivate,8)
594 DEFINE_STDCALL_WRAPPER(24,ITextHostImpl_TxGetClientRect,8)
595 DEFINE_STDCALL_WRAPPER(25,ITextHostImpl_TxGetViewInset,8)
596 DEFINE_STDCALL_WRAPPER(26,ITextHostImpl_TxGetCharFormat,8)
597 DEFINE_STDCALL_WRAPPER(27,ITextHostImpl_TxGetParaFormat,8)
598 DEFINE_STDCALL_WRAPPER(28,ITextHostImpl_TxGetSysColor,8)
599 DEFINE_STDCALL_WRAPPER(29,ITextHostImpl_TxGetBackStyle,8)
600 DEFINE_STDCALL_WRAPPER(30,ITextHostImpl_TxGetMaxLength,8)
601 DEFINE_STDCALL_WRAPPER(31,ITextHostImpl_TxGetScrollBars,8)
602 DEFINE_STDCALL_WRAPPER(32,ITextHostImpl_TxGetPasswordChar,8)
603 DEFINE_STDCALL_WRAPPER(33,ITextHostImpl_TxGetAcceleratorPos,8)
604 DEFINE_STDCALL_WRAPPER(34,ITextHostImpl_TxGetExtent,8)
605 DEFINE_STDCALL_WRAPPER(35,ITextHostImpl_OnTxCharFormatChange,8)
606 DEFINE_STDCALL_WRAPPER(36,ITextHostImpl_OnTxParaFormatChange,8)
607 DEFINE_STDCALL_WRAPPER(37,ITextHostImpl_TxGetPropertyBits,12)
608 DEFINE_STDCALL_WRAPPER(38,ITextHostImpl_TxNotify,12)
609 DEFINE_STDCALL_WRAPPER(39,ITextHostImpl_TxImmGetContext,4)
610 DEFINE_STDCALL_WRAPPER(40,ITextHostImpl_TxImmReleaseContext,8)
611 DEFINE_STDCALL_WRAPPER(41,ITextHostImpl_TxGetSelectionBarWidth,8)
613 const ITextHostVtbl itextHostStdcallVtbl = {
614 NULL,
615 NULL,
616 NULL,
617 __stdcall_ITextHostImpl_TxGetDC,
618 __stdcall_ITextHostImpl_TxReleaseDC,
619 __stdcall_ITextHostImpl_TxShowScrollBar,
620 __stdcall_ITextHostImpl_TxEnableScrollBar,
621 __stdcall_ITextHostImpl_TxSetScrollRange,
622 __stdcall_ITextHostImpl_TxSetScrollPos,
623 __stdcall_ITextHostImpl_TxInvalidateRect,
624 __stdcall_ITextHostImpl_TxViewChange,
625 __stdcall_ITextHostImpl_TxCreateCaret,
626 __stdcall_ITextHostImpl_TxShowCaret,
627 __stdcall_ITextHostImpl_TxSetCaretPos,
628 __stdcall_ITextHostImpl_TxSetTimer,
629 __stdcall_ITextHostImpl_TxKillTimer,
630 __stdcall_ITextHostImpl_TxScrollWindowEx,
631 __stdcall_ITextHostImpl_TxSetCapture,
632 __stdcall_ITextHostImpl_TxSetFocus,
633 __stdcall_ITextHostImpl_TxSetCursor,
634 __stdcall_ITextHostImpl_TxScreenToClient,
635 __stdcall_ITextHostImpl_TxClientToScreen,
636 __stdcall_ITextHostImpl_TxActivate,
637 __stdcall_ITextHostImpl_TxDeactivate,
638 __stdcall_ITextHostImpl_TxGetClientRect,
639 __stdcall_ITextHostImpl_TxGetViewInset,
640 __stdcall_ITextHostImpl_TxGetCharFormat,
641 __stdcall_ITextHostImpl_TxGetParaFormat,
642 __stdcall_ITextHostImpl_TxGetSysColor,
643 __stdcall_ITextHostImpl_TxGetBackStyle,
644 __stdcall_ITextHostImpl_TxGetMaxLength,
645 __stdcall_ITextHostImpl_TxGetScrollBars,
646 __stdcall_ITextHostImpl_TxGetPasswordChar,
647 __stdcall_ITextHostImpl_TxGetAcceleratorPos,
648 __stdcall_ITextHostImpl_TxGetExtent,
649 __stdcall_ITextHostImpl_OnTxCharFormatChange,
650 __stdcall_ITextHostImpl_OnTxParaFormatChange,
651 __stdcall_ITextHostImpl_TxGetPropertyBits,
652 __stdcall_ITextHostImpl_TxNotify,
653 __stdcall_ITextHostImpl_TxImmGetContext,
654 __stdcall_ITextHostImpl_TxImmReleaseContext,
655 __stdcall_ITextHostImpl_TxGetSelectionBarWidth,
658 #endif /* __i386__ */
660 static const ITextHostVtbl textHostVtbl = {
661 ITextHostImpl_QueryInterface,
662 ITextHostImpl_AddRef,
663 ITextHostImpl_Release,
664 THISCALL(ITextHostImpl_TxGetDC),
665 THISCALL(ITextHostImpl_TxReleaseDC),
666 THISCALL(ITextHostImpl_TxShowScrollBar),
667 THISCALL(ITextHostImpl_TxEnableScrollBar),
668 THISCALL(ITextHostImpl_TxSetScrollRange),
669 THISCALL(ITextHostImpl_TxSetScrollPos),
670 THISCALL(ITextHostImpl_TxInvalidateRect),
671 THISCALL(ITextHostImpl_TxViewChange),
672 THISCALL(ITextHostImpl_TxCreateCaret),
673 THISCALL(ITextHostImpl_TxShowCaret),
674 THISCALL(ITextHostImpl_TxSetCaretPos),
675 THISCALL(ITextHostImpl_TxSetTimer),
676 THISCALL(ITextHostImpl_TxKillTimer),
677 THISCALL(ITextHostImpl_TxScrollWindowEx),
678 THISCALL(ITextHostImpl_TxSetCapture),
679 THISCALL(ITextHostImpl_TxSetFocus),
680 THISCALL(ITextHostImpl_TxSetCursor),
681 THISCALL(ITextHostImpl_TxScreenToClient),
682 THISCALL(ITextHostImpl_TxClientToScreen),
683 THISCALL(ITextHostImpl_TxActivate),
684 THISCALL(ITextHostImpl_TxDeactivate),
685 THISCALL(ITextHostImpl_TxGetClientRect),
686 THISCALL(ITextHostImpl_TxGetViewInset),
687 THISCALL(ITextHostImpl_TxGetCharFormat),
688 THISCALL(ITextHostImpl_TxGetParaFormat),
689 THISCALL(ITextHostImpl_TxGetSysColor),
690 THISCALL(ITextHostImpl_TxGetBackStyle),
691 THISCALL(ITextHostImpl_TxGetMaxLength),
692 THISCALL(ITextHostImpl_TxGetScrollBars),
693 THISCALL(ITextHostImpl_TxGetPasswordChar),
694 THISCALL(ITextHostImpl_TxGetAcceleratorPos),
695 THISCALL(ITextHostImpl_TxGetExtent),
696 THISCALL(ITextHostImpl_OnTxCharFormatChange),
697 THISCALL(ITextHostImpl_OnTxParaFormatChange),
698 THISCALL(ITextHostImpl_TxGetPropertyBits),
699 THISCALL(ITextHostImpl_TxNotify),
700 THISCALL(ITextHostImpl_TxImmGetContext),
701 THISCALL(ITextHostImpl_TxImmReleaseContext),
702 THISCALL(ITextHostImpl_TxGetSelectionBarWidth),