mshtml: Removed no longer used attr_name from event_info_t.
[wine.git] / dlls / riched20 / txthost.c
blob0e51ecf850bf1b77ff4009fcbcae7953e8edc0e5
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 COBJMACROS
26 #include "editor.h"
27 #include "ole2.h"
28 #include "richole.h"
29 #include "imm.h"
30 #include "textserv.h"
31 #include "wine/debug.h"
32 #include "editstr.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
36 typedef struct ITextHostImpl {
37 ITextHost ITextHost_iface;
38 LONG ref;
39 HWND hWnd;
40 BOOL bEmulateVersion10;
41 } ITextHostImpl;
43 static const ITextHostVtbl textHostVtbl;
45 ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
47 ITextHostImpl *texthost;
48 texthost = CoTaskMemAlloc(sizeof(*texthost));
49 if (texthost)
51 ME_TextEditor *editor;
53 texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
54 texthost->ref = 1;
55 texthost->hWnd = hwnd;
56 texthost->bEmulateVersion10 = bEmulateVersion10;
58 editor = ME_MakeEditor(&texthost->ITextHost_iface, bEmulateVersion10, cs->style);
59 editor->exStyleFlags = GetWindowLongW(hwnd, GWL_EXSTYLE);
60 editor->styleFlags |= GetWindowLongW(hwnd, GWL_STYLE) & ES_WANTRETURN;
61 editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
62 editor->hwndParent = cs->hwndParent;
63 SetWindowLongPtrW(hwnd, 0, (LONG_PTR)editor);
66 return &texthost->ITextHost_iface;
69 static inline ITextHostImpl *impl_from_ITextHost(ITextHost *iface)
71 return CONTAINING_RECORD(iface, ITextHostImpl, ITextHost_iface);
74 static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid, void **ppvObject)
76 ITextHostImpl *This = impl_from_ITextHost(iface);
78 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost)) {
79 *ppvObject = &This->ITextHost_iface;
80 ITextHost_AddRef((ITextHost *)*ppvObject);
81 return S_OK;
84 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
85 return E_NOINTERFACE;
88 static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
90 ITextHostImpl *This = impl_from_ITextHost(iface);
91 ULONG ref = InterlockedIncrement(&This->ref);
92 return ref;
95 static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
97 ITextHostImpl *This = impl_from_ITextHost(iface);
98 ULONG ref = InterlockedDecrement(&This->ref);
100 if (!ref)
102 SetWindowLongPtrW(This->hWnd, 0, 0);
103 CoTaskMemFree(This);
105 return ref;
108 DECLSPEC_HIDDEN HDC WINAPI ITextHostImpl_TxGetDC(ITextHost *iface)
110 ITextHostImpl *This = impl_from_ITextHost(iface);
111 return GetDC(This->hWnd);
114 DECLSPEC_HIDDEN INT WINAPI ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
116 ITextHostImpl *This = impl_from_ITextHost(iface);
117 return ReleaseDC(This->hWnd, hdc);
120 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
122 ITextHostImpl *This = impl_from_ITextHost(iface);
123 return ShowScrollBar(This->hWnd, fnBar, fShow);
126 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
128 ITextHostImpl *This = impl_from_ITextHost(iface);
129 return EnableScrollBar(This->hWnd, fuSBFlags, fuArrowflags);
132 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos, INT nMaxPos,
133 BOOL fRedraw)
135 ITextHostImpl *This = impl_from_ITextHost(iface);
136 return SetScrollRange(This->hWnd, fnBar, nMinPos, nMaxPos, fRedraw);
139 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
141 ITextHostImpl *This = impl_from_ITextHost(iface);
142 return SetScrollPos(This->hWnd, fnBar, nPos, fRedraw) != 0;
145 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
147 ITextHostImpl *This = impl_from_ITextHost(iface);
148 InvalidateRect(This->hWnd, prc, fMode);
151 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
153 ITextHostImpl *This = impl_from_ITextHost(iface);
154 if (fUpdate)
155 UpdateWindow(This->hWnd);
158 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
160 ITextHostImpl *This = impl_from_ITextHost(iface);
161 return CreateCaret(This->hWnd, hbmp, xWidth, yHeight);
164 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
166 ITextHostImpl *This = impl_from_ITextHost(iface);
167 if (fShow)
168 return ShowCaret(This->hWnd);
169 else
170 return HideCaret(This->hWnd);
173 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetCaretPos(ITextHost *iface,
174 INT x, INT y)
176 return SetCaretPos(x, y);
179 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
181 ITextHostImpl *This = impl_from_ITextHost(iface);
182 return SetTimer(This->hWnd, idTimer, uTimeout, NULL) != 0;
185 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
187 ITextHostImpl *This = impl_from_ITextHost(iface);
188 KillTimer(This->hWnd, idTimer);
191 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll,
192 LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate,
193 UINT fuScroll)
195 ITextHostImpl *This = impl_from_ITextHost(iface);
196 ScrollWindowEx(This->hWnd, dx, dy, lprcScroll, lprcClip,
197 hRgnUpdate, lprcUpdate, fuScroll);
200 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
202 ITextHostImpl *This = impl_from_ITextHost(iface);
203 if (fCapture)
204 SetCapture(This->hWnd);
205 else
206 ReleaseCapture();
209 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxSetFocus(ITextHost *iface)
211 ITextHostImpl *This = impl_from_ITextHost(iface);
212 SetFocus(This->hWnd);
215 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxSetCursor(ITextHost *iface,
216 HCURSOR hcur,
217 BOOL fText)
219 SetCursor(hcur);
222 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt)
224 ITextHostImpl *This = impl_from_ITextHost(iface);
225 return ScreenToClient(This->hWnd, lppt);
228 DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt)
230 ITextHostImpl *This = impl_from_ITextHost(iface);
231 return ClientToScreen(This->hWnd, lppt);
234 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
236 ITextHostImpl *This = impl_from_ITextHost(iface);
237 *plOldState = HandleToLong(SetActiveWindow(This->hWnd));
238 return (*plOldState ? S_OK : E_FAIL);
241 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxDeactivate(ITextHost *iface,
242 LONG lNewState)
244 HWND ret = SetActiveWindow(LongToHandle(lNewState));
245 return (ret ? S_OK : E_FAIL);
248 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc)
250 ITextHostImpl *This = impl_from_ITextHost(iface);
251 int ret = GetClientRect(This->hWnd, prc);
252 return (ret ? S_OK : E_FAIL);
255 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetViewInset(ITextHost *iface,
256 LPRECT prc)
258 prc->top = 0;
259 prc->left = 0;
260 prc->bottom = 0;
261 prc->right = 0;
262 return S_OK;
265 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface,
266 const CHARFORMATW **ppCF)
268 return E_NOTIMPL;
271 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface,
272 const PARAFORMAT **ppPF)
274 return E_NOTIMPL;
277 DECLSPEC_HIDDEN COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface,
278 int nIndex)
280 return GetSysColor(nIndex);
283 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetBackStyle(ITextHost *iface,
284 TXTBACKSTYLE *pStyle)
286 *pStyle = TXTBACK_OPAQUE;
287 return S_OK;
290 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetMaxLength(ITextHost *iface,
291 DWORD *pLength)
293 *pLength = INFINITE;
294 return S_OK;
297 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
299 ITextHostImpl *This = impl_from_ITextHost(iface);
300 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
301 const DWORD mask = WS_VSCROLL|
302 WS_HSCROLL|
303 ES_AUTOVSCROLL|
304 ES_AUTOHSCROLL|
305 ES_DISABLENOSCROLL;
306 if (editor)
308 *pdwScrollBar = editor->styleFlags & mask;
309 } else {
310 DWORD style = GetWindowLongW(This->hWnd, GWL_STYLE);
311 if (style & WS_VSCROLL)
312 style |= ES_AUTOVSCROLL;
313 if (!This->bEmulateVersion10 && (style & WS_HSCROLL))
314 style |= ES_AUTOHSCROLL;
315 *pdwScrollBar = style & mask;
317 return S_OK;
320 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetPasswordChar(ITextHost *iface,
321 WCHAR *pch)
323 *pch = '*';
324 return S_OK;
327 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface,
328 LONG *pch)
330 *pch = -1;
331 return S_OK;
334 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetExtent(ITextHost *iface,
335 LPSIZEL lpExtent)
337 return E_NOTIMPL;
340 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_OnTxCharFormatChange(ITextHost *iface,
341 const CHARFORMATW *pcf)
343 return S_OK;
346 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_OnTxParaFormatChange(ITextHost *iface,
347 const PARAFORMAT *ppf)
349 return S_OK;
352 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
354 ITextHostImpl *This = impl_from_ITextHost(iface);
355 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
356 DWORD style;
357 DWORD dwBits = 0;
359 if (editor)
361 style = editor->styleFlags;
362 if (editor->mode & TM_RICHTEXT)
363 dwBits |= TXTBIT_RICHTEXT;
364 if (editor->bWordWrap)
365 dwBits |= TXTBIT_WORDWRAP;
366 if (style & ECO_AUTOWORDSELECTION)
367 dwBits |= TXTBIT_AUTOWORDSEL;
368 } else {
369 DWORD dwScrollBar;
371 style = GetWindowLongW(This->hWnd, GWL_STYLE);
372 ITextHostImpl_TxGetScrollBars(iface, &dwScrollBar);
374 dwBits |= TXTBIT_RICHTEXT|TXTBIT_AUTOWORDSEL;
375 if (!(dwScrollBar & ES_AUTOHSCROLL))
376 dwBits |= TXTBIT_WORDWRAP;
379 /* Bits that correspond to window styles. */
380 if (style & ES_MULTILINE)
381 dwBits |= TXTBIT_MULTILINE;
382 if (style & ES_READONLY)
383 dwBits |= TXTBIT_READONLY;
384 if (style & ES_PASSWORD)
385 dwBits |= TXTBIT_USEPASSWORD;
386 if (!(style & ES_NOHIDESEL))
387 dwBits |= TXTBIT_HIDESELECTION;
388 if (style & ES_SAVESEL)
389 dwBits |= TXTBIT_SAVESELECTION;
390 if (style & ES_VERTICAL)
391 dwBits |= TXTBIT_VERTICAL;
392 if (style & ES_NOOLEDRAGDROP)
393 dwBits |= TXTBIT_DISABLEDRAG;
395 dwBits |= TXTBIT_ALLOWBEEP;
397 /* The following bits are always FALSE because they are probably only
398 * needed for ITextServices_OnTxPropertyBitsChange:
399 * TXTBIT_VIEWINSETCHANGE
400 * TXTBIT_BACKSTYLECHANGE
401 * TXTBIT_MAXLENGTHCHANGE
402 * TXTBIT_CHARFORMATCHANGE
403 * TXTBIT_PARAFORMATCHANGE
404 * TXTBIT_SHOWACCELERATOR
405 * TXTBIT_EXTENTCHANGE
406 * TXTBIT_SELBARCHANGE
407 * TXTBIT_SCROLLBARCHANGE
408 * TXTBIT_CLIENTRECTCHANGE
410 * Documented by MSDN as not supported:
411 * TXTBIT_USECURRENTBKG
414 *pdwBits = dwBits & dwMask;
415 return S_OK;
418 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
420 ITextHostImpl *This = impl_from_ITextHost(iface);
421 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
422 HWND hwnd = This->hWnd;
423 UINT id;
425 if (!editor || !editor->hwndParent) return S_OK;
427 id = GetWindowLongW(hwnd, GWLP_ID);
429 switch (iNotify)
431 case EN_DROPFILES:
432 case EN_LINK:
433 case EN_OLEOPFAILED:
434 case EN_PROTECTED:
435 case EN_REQUESTRESIZE:
436 case EN_SAVECLIPBOARD:
437 case EN_SELCHANGE:
438 case EN_STOPNOUNDO:
440 /* FIXME: Verify this assumption that pv starts with NMHDR. */
441 NMHDR *info = pv;
442 if (!info)
443 return E_FAIL;
445 info->hwndFrom = hwnd;
446 info->idFrom = id;
447 info->code = iNotify;
448 SendMessageW(editor->hwndParent, WM_NOTIFY, id, (LPARAM)info);
449 break;
452 case EN_UPDATE:
453 /* Only sent when the window is visible. */
454 if (!IsWindowVisible(hwnd))
455 break;
456 /* Fall through */
457 case EN_CHANGE:
458 case EN_ERRSPACE:
459 case EN_HSCROLL:
460 case EN_KILLFOCUS:
461 case EN_MAXTEXT:
462 case EN_SETFOCUS:
463 case EN_VSCROLL:
464 SendMessageW(editor->hwndParent, WM_COMMAND, MAKEWPARAM(id, iNotify), (LPARAM)hwnd);
465 break;
467 case EN_MSGFILTER:
468 FIXME("EN_MSGFILTER is documented as not being sent to TxNotify\n");
469 /* fall through */
470 default:
471 return E_FAIL;
473 return S_OK;
476 DECLSPEC_HIDDEN HIMC WINAPI ITextHostImpl_TxImmGetContext(ITextHost *iface)
478 ITextHostImpl *This = impl_from_ITextHost(iface);
479 return ImmGetContext(This->hWnd);
482 DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
484 ITextHostImpl *This = impl_from_ITextHost(iface);
485 ImmReleaseContext(This->hWnd, himc);
488 DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
490 ITextHostImpl *This = impl_from_ITextHost(iface);
491 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
493 DWORD style = editor ? editor->styleFlags
494 : GetWindowLongW(This->hWnd, GWL_STYLE);
495 *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
496 return S_OK;
500 #ifdef __i386__ /* thiscall functions are i386-specific */
502 #define THISCALL(func) __thiscall_ ## func
503 #define DEFINE_THISCALL_WRAPPER(func,args) \
504 extern typeof(func) THISCALL(func); \
505 __ASM_STDCALL_FUNC(__thiscall_ ## func, args, \
506 "popl %eax\n\t" \
507 "pushl %ecx\n\t" \
508 "pushl %eax\n\t" \
509 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
511 #else /* __i386__ */
513 #define THISCALL(func) func
514 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
516 #endif /* __i386__ */
518 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4)
519 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8)
520 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12)
521 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar,12)
522 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange,20)
523 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos,16)
524 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect,12)
525 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange,8)
526 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret,16)
527 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret,8)
528 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos,12)
529 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer,12)
530 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer,8)
531 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx,32)
532 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture,8)
533 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus,4)
534 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor,12)
535 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient,8)
536 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen,8)
537 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate,8)
538 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate,8)
539 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect,8)
540 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset,8)
541 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetCharFormat,8)
542 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat,8)
543 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor,8)
544 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle,8)
545 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength,8)
546 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars,8)
547 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8)
548 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8)
549 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent,8)
550 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxCharFormatChange,8)
551 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxParaFormatChange,8)
552 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits,12)
553 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify,12)
554 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4)
555 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8)
556 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
558 #ifdef __i386__ /* thiscall functions are i386-specific */
560 #define STDCALL(func) __stdcall_ ## func
561 #define DEFINE_STDCALL_WRAPPER(num,func,args) \
562 extern typeof(func) __stdcall_ ## func; \
563 __ASM_STDCALL_FUNC(__stdcall_ ## func, args, \
564 "popl %eax\n\t" \
565 "popl %ecx\n\t" \
566 "pushl %eax\n\t" \
567 "movl (%ecx), %eax\n\t" \
568 "jmp *(4*(" #num "))(%eax)" )
570 DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4)
571 DEFINE_STDCALL_WRAPPER(4,ITextHostImpl_TxReleaseDC,8)
572 DEFINE_STDCALL_WRAPPER(5,ITextHostImpl_TxShowScrollBar,12)
573 DEFINE_STDCALL_WRAPPER(6,ITextHostImpl_TxEnableScrollBar,12)
574 DEFINE_STDCALL_WRAPPER(7,ITextHostImpl_TxSetScrollRange,20)
575 DEFINE_STDCALL_WRAPPER(8,ITextHostImpl_TxSetScrollPos,16)
576 DEFINE_STDCALL_WRAPPER(9,ITextHostImpl_TxInvalidateRect,12)
577 DEFINE_STDCALL_WRAPPER(10,ITextHostImpl_TxViewChange,8)
578 DEFINE_STDCALL_WRAPPER(11,ITextHostImpl_TxCreateCaret,16)
579 DEFINE_STDCALL_WRAPPER(12,ITextHostImpl_TxShowCaret,8)
580 DEFINE_STDCALL_WRAPPER(13,ITextHostImpl_TxSetCaretPos,12)
581 DEFINE_STDCALL_WRAPPER(14,ITextHostImpl_TxSetTimer,12)
582 DEFINE_STDCALL_WRAPPER(15,ITextHostImpl_TxKillTimer,8)
583 DEFINE_STDCALL_WRAPPER(16,ITextHostImpl_TxScrollWindowEx,32)
584 DEFINE_STDCALL_WRAPPER(17,ITextHostImpl_TxSetCapture,8)
585 DEFINE_STDCALL_WRAPPER(18,ITextHostImpl_TxSetFocus,4)
586 DEFINE_STDCALL_WRAPPER(19,ITextHostImpl_TxSetCursor,12)
587 DEFINE_STDCALL_WRAPPER(20,ITextHostImpl_TxScreenToClient,8)
588 DEFINE_STDCALL_WRAPPER(21,ITextHostImpl_TxClientToScreen,8)
589 DEFINE_STDCALL_WRAPPER(22,ITextHostImpl_TxActivate,8)
590 DEFINE_STDCALL_WRAPPER(23,ITextHostImpl_TxDeactivate,8)
591 DEFINE_STDCALL_WRAPPER(24,ITextHostImpl_TxGetClientRect,8)
592 DEFINE_STDCALL_WRAPPER(25,ITextHostImpl_TxGetViewInset,8)
593 DEFINE_STDCALL_WRAPPER(26,ITextHostImpl_TxGetCharFormat,8)
594 DEFINE_STDCALL_WRAPPER(27,ITextHostImpl_TxGetParaFormat,8)
595 DEFINE_STDCALL_WRAPPER(28,ITextHostImpl_TxGetSysColor,8)
596 DEFINE_STDCALL_WRAPPER(29,ITextHostImpl_TxGetBackStyle,8)
597 DEFINE_STDCALL_WRAPPER(30,ITextHostImpl_TxGetMaxLength,8)
598 DEFINE_STDCALL_WRAPPER(31,ITextHostImpl_TxGetScrollBars,8)
599 DEFINE_STDCALL_WRAPPER(32,ITextHostImpl_TxGetPasswordChar,8)
600 DEFINE_STDCALL_WRAPPER(33,ITextHostImpl_TxGetAcceleratorPos,8)
601 DEFINE_STDCALL_WRAPPER(34,ITextHostImpl_TxGetExtent,8)
602 DEFINE_STDCALL_WRAPPER(35,ITextHostImpl_OnTxCharFormatChange,8)
603 DEFINE_STDCALL_WRAPPER(36,ITextHostImpl_OnTxParaFormatChange,8)
604 DEFINE_STDCALL_WRAPPER(37,ITextHostImpl_TxGetPropertyBits,12)
605 DEFINE_STDCALL_WRAPPER(38,ITextHostImpl_TxNotify,12)
606 DEFINE_STDCALL_WRAPPER(39,ITextHostImpl_TxImmGetContext,4)
607 DEFINE_STDCALL_WRAPPER(40,ITextHostImpl_TxImmReleaseContext,8)
608 DEFINE_STDCALL_WRAPPER(41,ITextHostImpl_TxGetSelectionBarWidth,8)
610 const ITextHostVtbl itextHostStdcallVtbl = {
611 NULL,
612 NULL,
613 NULL,
614 __stdcall_ITextHostImpl_TxGetDC,
615 __stdcall_ITextHostImpl_TxReleaseDC,
616 __stdcall_ITextHostImpl_TxShowScrollBar,
617 __stdcall_ITextHostImpl_TxEnableScrollBar,
618 __stdcall_ITextHostImpl_TxSetScrollRange,
619 __stdcall_ITextHostImpl_TxSetScrollPos,
620 __stdcall_ITextHostImpl_TxInvalidateRect,
621 __stdcall_ITextHostImpl_TxViewChange,
622 __stdcall_ITextHostImpl_TxCreateCaret,
623 __stdcall_ITextHostImpl_TxShowCaret,
624 __stdcall_ITextHostImpl_TxSetCaretPos,
625 __stdcall_ITextHostImpl_TxSetTimer,
626 __stdcall_ITextHostImpl_TxKillTimer,
627 __stdcall_ITextHostImpl_TxScrollWindowEx,
628 __stdcall_ITextHostImpl_TxSetCapture,
629 __stdcall_ITextHostImpl_TxSetFocus,
630 __stdcall_ITextHostImpl_TxSetCursor,
631 __stdcall_ITextHostImpl_TxScreenToClient,
632 __stdcall_ITextHostImpl_TxClientToScreen,
633 __stdcall_ITextHostImpl_TxActivate,
634 __stdcall_ITextHostImpl_TxDeactivate,
635 __stdcall_ITextHostImpl_TxGetClientRect,
636 __stdcall_ITextHostImpl_TxGetViewInset,
637 __stdcall_ITextHostImpl_TxGetCharFormat,
638 __stdcall_ITextHostImpl_TxGetParaFormat,
639 __stdcall_ITextHostImpl_TxGetSysColor,
640 __stdcall_ITextHostImpl_TxGetBackStyle,
641 __stdcall_ITextHostImpl_TxGetMaxLength,
642 __stdcall_ITextHostImpl_TxGetScrollBars,
643 __stdcall_ITextHostImpl_TxGetPasswordChar,
644 __stdcall_ITextHostImpl_TxGetAcceleratorPos,
645 __stdcall_ITextHostImpl_TxGetExtent,
646 __stdcall_ITextHostImpl_OnTxCharFormatChange,
647 __stdcall_ITextHostImpl_OnTxParaFormatChange,
648 __stdcall_ITextHostImpl_TxGetPropertyBits,
649 __stdcall_ITextHostImpl_TxNotify,
650 __stdcall_ITextHostImpl_TxImmGetContext,
651 __stdcall_ITextHostImpl_TxImmReleaseContext,
652 __stdcall_ITextHostImpl_TxGetSelectionBarWidth,
655 #endif /* __i386__ */
657 static const ITextHostVtbl textHostVtbl = {
658 ITextHostImpl_QueryInterface,
659 ITextHostImpl_AddRef,
660 ITextHostImpl_Release,
661 THISCALL(ITextHostImpl_TxGetDC),
662 THISCALL(ITextHostImpl_TxReleaseDC),
663 THISCALL(ITextHostImpl_TxShowScrollBar),
664 THISCALL(ITextHostImpl_TxEnableScrollBar),
665 THISCALL(ITextHostImpl_TxSetScrollRange),
666 THISCALL(ITextHostImpl_TxSetScrollPos),
667 THISCALL(ITextHostImpl_TxInvalidateRect),
668 THISCALL(ITextHostImpl_TxViewChange),
669 THISCALL(ITextHostImpl_TxCreateCaret),
670 THISCALL(ITextHostImpl_TxShowCaret),
671 THISCALL(ITextHostImpl_TxSetCaretPos),
672 THISCALL(ITextHostImpl_TxSetTimer),
673 THISCALL(ITextHostImpl_TxKillTimer),
674 THISCALL(ITextHostImpl_TxScrollWindowEx),
675 THISCALL(ITextHostImpl_TxSetCapture),
676 THISCALL(ITextHostImpl_TxSetFocus),
677 THISCALL(ITextHostImpl_TxSetCursor),
678 THISCALL(ITextHostImpl_TxScreenToClient),
679 THISCALL(ITextHostImpl_TxClientToScreen),
680 THISCALL(ITextHostImpl_TxActivate),
681 THISCALL(ITextHostImpl_TxDeactivate),
682 THISCALL(ITextHostImpl_TxGetClientRect),
683 THISCALL(ITextHostImpl_TxGetViewInset),
684 THISCALL(ITextHostImpl_TxGetCharFormat),
685 THISCALL(ITextHostImpl_TxGetParaFormat),
686 THISCALL(ITextHostImpl_TxGetSysColor),
687 THISCALL(ITextHostImpl_TxGetBackStyle),
688 THISCALL(ITextHostImpl_TxGetMaxLength),
689 THISCALL(ITextHostImpl_TxGetScrollBars),
690 THISCALL(ITextHostImpl_TxGetPasswordChar),
691 THISCALL(ITextHostImpl_TxGetAcceleratorPos),
692 THISCALL(ITextHostImpl_TxGetExtent),
693 THISCALL(ITextHostImpl_OnTxCharFormatChange),
694 THISCALL(ITextHostImpl_OnTxParaFormatChange),
695 THISCALL(ITextHostImpl_TxGetPropertyBits),
696 THISCALL(ITextHostImpl_TxNotify),
697 THISCALL(ITextHostImpl_TxImmGetContext),
698 THISCALL(ITextHostImpl_TxImmReleaseContext),
699 THISCALL(ITextHostImpl_TxGetSelectionBarWidth),