makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / riched20 / txthost.c
blob3f25625ed52b24f27b34388a52ae0892dcf41585
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/asm.h"
29 #include "wine/debug.h"
30 #include "editstr.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
34 typedef struct ITextHostImpl {
35 ITextHost ITextHost_iface;
36 LONG ref;
37 HWND hWnd;
38 BOOL bEmulateVersion10;
39 PARAFORMAT2 para_fmt;
40 } ITextHostImpl;
42 static const ITextHostVtbl textHostVtbl;
44 ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
46 ITextHostImpl *texthost;
48 texthost = CoTaskMemAlloc(sizeof(*texthost));
49 if (!texthost) return NULL;
51 texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
52 texthost->ref = 1;
53 texthost->hWnd = hwnd;
54 texthost->bEmulateVersion10 = bEmulateVersion10;
55 memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) );
56 texthost->para_fmt.cbSize = sizeof(texthost->para_fmt);
57 texthost->para_fmt.dwMask = PFM_ALIGNMENT;
58 texthost->para_fmt.wAlignment = PFA_LEFT;
59 if (cs->style & ES_RIGHT)
60 texthost->para_fmt.wAlignment = PFA_RIGHT;
61 if (cs->style & ES_CENTER)
62 texthost->para_fmt.wAlignment = PFA_CENTER;
64 return &texthost->ITextHost_iface;
67 static inline ITextHostImpl *impl_from_ITextHost(ITextHost *iface)
69 return CONTAINING_RECORD(iface, ITextHostImpl, ITextHost_iface);
72 static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid, void **ppvObject)
74 ITextHostImpl *This = impl_from_ITextHost(iface);
76 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost)) {
77 *ppvObject = &This->ITextHost_iface;
78 ITextHost_AddRef((ITextHost *)*ppvObject);
79 return S_OK;
82 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
83 return E_NOINTERFACE;
86 static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
88 ITextHostImpl *This = impl_from_ITextHost(iface);
89 ULONG ref = InterlockedIncrement(&This->ref);
90 return ref;
93 static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
95 ITextHostImpl *This = impl_from_ITextHost(iface);
96 ULONG ref = InterlockedDecrement(&This->ref);
98 if (!ref)
100 SetWindowLongPtrW(This->hWnd, 0, 0);
101 CoTaskMemFree(This);
103 return ref;
106 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4)
107 DECLSPEC_HIDDEN HDC __thiscall ITextHostImpl_TxGetDC(ITextHost *iface)
109 ITextHostImpl *This = impl_from_ITextHost(iface);
110 return GetDC(This->hWnd);
113 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8)
114 DECLSPEC_HIDDEN INT __thiscall ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
116 ITextHostImpl *This = impl_from_ITextHost(iface);
117 return ReleaseDC(This->hWnd, hdc);
120 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12)
121 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
123 ITextHostImpl *This = impl_from_ITextHost(iface);
124 return ShowScrollBar(This->hWnd, fnBar, fShow);
127 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar,12)
128 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
130 ITextHostImpl *This = impl_from_ITextHost(iface);
131 return EnableScrollBar(This->hWnd, fuSBFlags, fuArrowflags);
134 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange,20)
135 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos, INT nMaxPos,
136 BOOL fRedraw)
138 ITextHostImpl *This = impl_from_ITextHost(iface);
139 return SetScrollRange(This->hWnd, fnBar, nMinPos, nMaxPos, fRedraw);
142 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos,16)
143 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
145 ITextHostImpl *This = impl_from_ITextHost(iface);
146 return SetScrollPos(This->hWnd, fnBar, nPos, fRedraw) != 0;
149 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect,12)
150 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
152 ITextHostImpl *This = impl_from_ITextHost(iface);
153 InvalidateRect(This->hWnd, prc, fMode);
156 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange,8)
157 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
159 ITextHostImpl *This = impl_from_ITextHost(iface);
160 if (fUpdate)
161 UpdateWindow(This->hWnd);
164 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret,16)
165 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
167 ITextHostImpl *This = impl_from_ITextHost(iface);
168 return CreateCaret(This->hWnd, hbmp, xWidth, yHeight);
171 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret,8)
172 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
174 ITextHostImpl *This = impl_from_ITextHost(iface);
175 if (fShow)
176 return ShowCaret(This->hWnd);
177 else
178 return HideCaret(This->hWnd);
181 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos,12)
182 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetCaretPos(ITextHost *iface,
183 INT x, INT y)
185 return SetCaretPos(x, y);
188 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer,12)
189 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
191 ITextHostImpl *This = impl_from_ITextHost(iface);
192 return SetTimer(This->hWnd, idTimer, uTimeout, NULL) != 0;
195 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer,8)
196 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
198 ITextHostImpl *This = impl_from_ITextHost(iface);
199 KillTimer(This->hWnd, idTimer);
202 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx,32)
203 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll,
204 LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate,
205 UINT fuScroll)
207 ITextHostImpl *This = impl_from_ITextHost(iface);
208 ScrollWindowEx(This->hWnd, dx, dy, lprcScroll, lprcClip,
209 hRgnUpdate, lprcUpdate, fuScroll);
212 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture,8)
213 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
215 ITextHostImpl *This = impl_from_ITextHost(iface);
216 if (fCapture)
217 SetCapture(This->hWnd);
218 else
219 ReleaseCapture();
222 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus,4)
223 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetFocus(ITextHost *iface)
225 ITextHostImpl *This = impl_from_ITextHost(iface);
226 SetFocus(This->hWnd);
229 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor,12)
230 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCursor(ITextHost *iface, HCURSOR hcur, BOOL fText)
232 SetCursor(hcur);
235 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient,8)
236 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt)
238 ITextHostImpl *This = impl_from_ITextHost(iface);
239 return ScreenToClient(This->hWnd, lppt);
242 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen,8)
243 DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt)
245 ITextHostImpl *This = impl_from_ITextHost(iface);
246 return ClientToScreen(This->hWnd, lppt);
249 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate,8)
250 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
252 ITextHostImpl *This = impl_from_ITextHost(iface);
253 *plOldState = HandleToLong(SetActiveWindow(This->hWnd));
254 return (*plOldState ? S_OK : E_FAIL);
257 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate,8)
258 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState)
260 HWND ret = SetActiveWindow(LongToHandle(lNewState));
261 return (ret ? S_OK : E_FAIL);
264 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect,8)
265 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc)
267 ITextHostImpl *This = impl_from_ITextHost(iface);
268 int ret = GetClientRect(This->hWnd, prc);
269 return (ret ? S_OK : E_FAIL);
272 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset,8)
273 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetViewInset(ITextHost *iface, LPRECT prc)
275 prc->top = 0;
276 prc->left = 0;
277 prc->bottom = 0;
278 prc->right = 0;
279 return S_OK;
282 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetCharFormat,8)
283 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetCharFormat(ITextHost *iface, const CHARFORMATW **ppCF)
285 return E_NOTIMPL;
288 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat,8)
289 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetParaFormat(ITextHost *iface, const PARAFORMAT **fmt)
291 ITextHostImpl *This = impl_from_ITextHost(iface);
292 *fmt = (const PARAFORMAT *)&This->para_fmt;
293 return S_OK;
296 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor,8)
297 DECLSPEC_HIDDEN COLORREF __thiscall ITextHostImpl_TxGetSysColor(ITextHost *iface, int nIndex)
299 return GetSysColor(nIndex);
302 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle,8)
303 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetBackStyle(ITextHost *iface, TXTBACKSTYLE *pStyle)
305 *pStyle = TXTBACK_OPAQUE;
306 return S_OK;
309 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength,8)
310 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetMaxLength(ITextHost *iface, DWORD *pLength)
312 *pLength = INFINITE;
313 return S_OK;
316 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars,8)
317 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
319 ITextHostImpl *This = impl_from_ITextHost(iface);
320 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
321 const DWORD mask = WS_VSCROLL|
322 WS_HSCROLL|
323 ES_AUTOVSCROLL|
324 ES_AUTOHSCROLL|
325 ES_DISABLENOSCROLL;
326 if (editor)
328 *pdwScrollBar = editor->styleFlags & mask;
329 } else {
330 DWORD style = GetWindowLongW(This->hWnd, GWL_STYLE);
331 if (style & WS_VSCROLL)
332 style |= ES_AUTOVSCROLL;
333 if (!This->bEmulateVersion10 && (style & WS_HSCROLL))
334 style |= ES_AUTOHSCROLL;
335 *pdwScrollBar = style & mask;
337 return S_OK;
340 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8)
341 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPasswordChar(ITextHost *iface, WCHAR *pch)
343 *pch = '*';
344 return S_OK;
347 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8)
348 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface, LONG *pch)
350 *pch = -1;
351 return S_OK;
354 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent,8)
355 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetExtent(ITextHost *iface, LPSIZEL lpExtent)
357 return E_NOTIMPL;
360 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxCharFormatChange,8)
361 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_OnTxCharFormatChange(ITextHost *iface, const CHARFORMATW *pcf)
363 return S_OK;
366 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxParaFormatChange,8)
367 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_OnTxParaFormatChange(ITextHost *iface, const PARAFORMAT *ppf)
369 return S_OK;
372 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits,12)
373 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
375 ITextHostImpl *This = impl_from_ITextHost(iface);
376 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
377 DWORD style;
378 DWORD dwBits = 0;
380 if (editor)
382 style = editor->styleFlags;
383 if (editor->mode & TM_RICHTEXT)
384 dwBits |= TXTBIT_RICHTEXT;
385 if (editor->bWordWrap)
386 dwBits |= TXTBIT_WORDWRAP;
387 if (style & ECO_AUTOWORDSELECTION)
388 dwBits |= TXTBIT_AUTOWORDSEL;
389 } else {
390 DWORD dwScrollBar;
392 style = GetWindowLongW(This->hWnd, GWL_STYLE);
393 ITextHostImpl_TxGetScrollBars(iface, &dwScrollBar);
395 dwBits |= TXTBIT_RICHTEXT|TXTBIT_AUTOWORDSEL;
396 if (!(dwScrollBar & ES_AUTOHSCROLL))
397 dwBits |= TXTBIT_WORDWRAP;
400 /* Bits that correspond to window styles. */
401 if (style & ES_MULTILINE)
402 dwBits |= TXTBIT_MULTILINE;
403 if (style & ES_READONLY)
404 dwBits |= TXTBIT_READONLY;
405 if (style & ES_PASSWORD)
406 dwBits |= TXTBIT_USEPASSWORD;
407 if (!(style & ES_NOHIDESEL))
408 dwBits |= TXTBIT_HIDESELECTION;
409 if (style & ES_SAVESEL)
410 dwBits |= TXTBIT_SAVESELECTION;
411 if (style & ES_VERTICAL)
412 dwBits |= TXTBIT_VERTICAL;
413 if (style & ES_NOOLEDRAGDROP)
414 dwBits |= TXTBIT_DISABLEDRAG;
416 dwBits |= TXTBIT_ALLOWBEEP;
418 /* The following bits are always FALSE because they are probably only
419 * needed for ITextServices_OnTxPropertyBitsChange:
420 * TXTBIT_VIEWINSETCHANGE
421 * TXTBIT_BACKSTYLECHANGE
422 * TXTBIT_MAXLENGTHCHANGE
423 * TXTBIT_CHARFORMATCHANGE
424 * TXTBIT_PARAFORMATCHANGE
425 * TXTBIT_SHOWACCELERATOR
426 * TXTBIT_EXTENTCHANGE
427 * TXTBIT_SELBARCHANGE
428 * TXTBIT_SCROLLBARCHANGE
429 * TXTBIT_CLIENTRECTCHANGE
431 * Documented by MSDN as not supported:
432 * TXTBIT_USECURRENTBKG
435 *pdwBits = dwBits & dwMask;
436 return S_OK;
439 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify,12)
440 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
442 ITextHostImpl *This = impl_from_ITextHost(iface);
443 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
444 HWND hwnd = This->hWnd;
445 UINT id;
447 if (!editor || !editor->hwndParent) return S_OK;
449 id = GetWindowLongW(hwnd, GWLP_ID);
451 switch (iNotify)
453 case EN_DROPFILES:
454 case EN_LINK:
455 case EN_OLEOPFAILED:
456 case EN_PROTECTED:
457 case EN_REQUESTRESIZE:
458 case EN_SAVECLIPBOARD:
459 case EN_SELCHANGE:
460 case EN_STOPNOUNDO:
462 /* FIXME: Verify this assumption that pv starts with NMHDR. */
463 NMHDR *info = pv;
464 if (!info)
465 return E_FAIL;
467 info->hwndFrom = hwnd;
468 info->idFrom = id;
469 info->code = iNotify;
470 SendMessageW(editor->hwndParent, WM_NOTIFY, id, (LPARAM)info);
471 break;
474 case EN_UPDATE:
475 /* Only sent when the window is visible. */
476 if (!IsWindowVisible(hwnd))
477 break;
478 /* Fall through */
479 case EN_CHANGE:
480 case EN_ERRSPACE:
481 case EN_HSCROLL:
482 case EN_KILLFOCUS:
483 case EN_MAXTEXT:
484 case EN_SETFOCUS:
485 case EN_VSCROLL:
486 SendMessageW(editor->hwndParent, WM_COMMAND, MAKEWPARAM(id, iNotify), (LPARAM)hwnd);
487 break;
489 case EN_MSGFILTER:
490 FIXME("EN_MSGFILTER is documented as not being sent to TxNotify\n");
491 /* fall through */
492 default:
493 return E_FAIL;
495 return S_OK;
498 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4)
499 DECLSPEC_HIDDEN HIMC __thiscall ITextHostImpl_TxImmGetContext(ITextHost *iface)
501 ITextHostImpl *This = impl_from_ITextHost(iface);
502 return ImmGetContext(This->hWnd);
505 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8)
506 DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
508 ITextHostImpl *This = impl_from_ITextHost(iface);
509 ImmReleaseContext(This->hWnd, himc);
512 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
513 DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
515 ITextHostImpl *This = impl_from_ITextHost(iface);
516 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
518 DWORD style = editor ? editor->styleFlags
519 : GetWindowLongW(This->hWnd, GWL_STYLE);
520 *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
521 return S_OK;
525 #if defined(__i386__) && !defined(__MINGW32__) /* thiscall functions are i386-specific */
527 #define STDCALL(func) (void *) __stdcall_ ## func
528 #ifdef _MSC_VER
529 #define DEFINE_STDCALL_WRAPPER(num,func,args) \
530 __declspec(naked) HRESULT __stdcall_##func(void) \
532 __asm pop eax \
533 __asm pop ecx \
534 __asm push eax \
535 __asm mov eax, [ecx] \
536 __asm jmp dword ptr [eax + 4*num] \
538 #else /* _MSC_VER */
539 #define DEFINE_STDCALL_WRAPPER(num,func,args) \
540 extern HRESULT __stdcall_ ## func(void); \
541 __ASM_GLOBAL_FUNC(__stdcall_ ## func, \
542 "popl %eax\n\t" \
543 "popl %ecx\n\t" \
544 "pushl %eax\n\t" \
545 "movl (%ecx), %eax\n\t" \
546 "jmp *(4*(" #num "))(%eax)" )
547 #endif /* _MSC_VER */
549 DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4)
550 DEFINE_STDCALL_WRAPPER(4,ITextHostImpl_TxReleaseDC,8)
551 DEFINE_STDCALL_WRAPPER(5,ITextHostImpl_TxShowScrollBar,12)
552 DEFINE_STDCALL_WRAPPER(6,ITextHostImpl_TxEnableScrollBar,12)
553 DEFINE_STDCALL_WRAPPER(7,ITextHostImpl_TxSetScrollRange,20)
554 DEFINE_STDCALL_WRAPPER(8,ITextHostImpl_TxSetScrollPos,16)
555 DEFINE_STDCALL_WRAPPER(9,ITextHostImpl_TxInvalidateRect,12)
556 DEFINE_STDCALL_WRAPPER(10,ITextHostImpl_TxViewChange,8)
557 DEFINE_STDCALL_WRAPPER(11,ITextHostImpl_TxCreateCaret,16)
558 DEFINE_STDCALL_WRAPPER(12,ITextHostImpl_TxShowCaret,8)
559 DEFINE_STDCALL_WRAPPER(13,ITextHostImpl_TxSetCaretPos,12)
560 DEFINE_STDCALL_WRAPPER(14,ITextHostImpl_TxSetTimer,12)
561 DEFINE_STDCALL_WRAPPER(15,ITextHostImpl_TxKillTimer,8)
562 DEFINE_STDCALL_WRAPPER(16,ITextHostImpl_TxScrollWindowEx,32)
563 DEFINE_STDCALL_WRAPPER(17,ITextHostImpl_TxSetCapture,8)
564 DEFINE_STDCALL_WRAPPER(18,ITextHostImpl_TxSetFocus,4)
565 DEFINE_STDCALL_WRAPPER(19,ITextHostImpl_TxSetCursor,12)
566 DEFINE_STDCALL_WRAPPER(20,ITextHostImpl_TxScreenToClient,8)
567 DEFINE_STDCALL_WRAPPER(21,ITextHostImpl_TxClientToScreen,8)
568 DEFINE_STDCALL_WRAPPER(22,ITextHostImpl_TxActivate,8)
569 DEFINE_STDCALL_WRAPPER(23,ITextHostImpl_TxDeactivate,8)
570 DEFINE_STDCALL_WRAPPER(24,ITextHostImpl_TxGetClientRect,8)
571 DEFINE_STDCALL_WRAPPER(25,ITextHostImpl_TxGetViewInset,8)
572 DEFINE_STDCALL_WRAPPER(26,ITextHostImpl_TxGetCharFormat,8)
573 DEFINE_STDCALL_WRAPPER(27,ITextHostImpl_TxGetParaFormat,8)
574 DEFINE_STDCALL_WRAPPER(28,ITextHostImpl_TxGetSysColor,8)
575 DEFINE_STDCALL_WRAPPER(29,ITextHostImpl_TxGetBackStyle,8)
576 DEFINE_STDCALL_WRAPPER(30,ITextHostImpl_TxGetMaxLength,8)
577 DEFINE_STDCALL_WRAPPER(31,ITextHostImpl_TxGetScrollBars,8)
578 DEFINE_STDCALL_WRAPPER(32,ITextHostImpl_TxGetPasswordChar,8)
579 DEFINE_STDCALL_WRAPPER(33,ITextHostImpl_TxGetAcceleratorPos,8)
580 DEFINE_STDCALL_WRAPPER(34,ITextHostImpl_TxGetExtent,8)
581 DEFINE_STDCALL_WRAPPER(35,ITextHostImpl_OnTxCharFormatChange,8)
582 DEFINE_STDCALL_WRAPPER(36,ITextHostImpl_OnTxParaFormatChange,8)
583 DEFINE_STDCALL_WRAPPER(37,ITextHostImpl_TxGetPropertyBits,12)
584 DEFINE_STDCALL_WRAPPER(38,ITextHostImpl_TxNotify,12)
585 DEFINE_STDCALL_WRAPPER(39,ITextHostImpl_TxImmGetContext,4)
586 DEFINE_STDCALL_WRAPPER(40,ITextHostImpl_TxImmReleaseContext,8)
587 DEFINE_STDCALL_WRAPPER(41,ITextHostImpl_TxGetSelectionBarWidth,8)
589 const ITextHostVtbl itextHostStdcallVtbl = {
590 NULL,
591 NULL,
592 NULL,
593 STDCALL(ITextHostImpl_TxGetDC),
594 STDCALL(ITextHostImpl_TxReleaseDC),
595 STDCALL(ITextHostImpl_TxShowScrollBar),
596 STDCALL(ITextHostImpl_TxEnableScrollBar),
597 STDCALL(ITextHostImpl_TxSetScrollRange),
598 STDCALL(ITextHostImpl_TxSetScrollPos),
599 STDCALL(ITextHostImpl_TxInvalidateRect),
600 STDCALL(ITextHostImpl_TxViewChange),
601 STDCALL(ITextHostImpl_TxCreateCaret),
602 STDCALL(ITextHostImpl_TxShowCaret),
603 STDCALL(ITextHostImpl_TxSetCaretPos),
604 STDCALL(ITextHostImpl_TxSetTimer),
605 STDCALL(ITextHostImpl_TxKillTimer),
606 STDCALL(ITextHostImpl_TxScrollWindowEx),
607 STDCALL(ITextHostImpl_TxSetCapture),
608 STDCALL(ITextHostImpl_TxSetFocus),
609 STDCALL(ITextHostImpl_TxSetCursor),
610 STDCALL(ITextHostImpl_TxScreenToClient),
611 STDCALL(ITextHostImpl_TxClientToScreen),
612 STDCALL(ITextHostImpl_TxActivate),
613 STDCALL(ITextHostImpl_TxDeactivate),
614 STDCALL(ITextHostImpl_TxGetClientRect),
615 STDCALL(ITextHostImpl_TxGetViewInset),
616 STDCALL(ITextHostImpl_TxGetCharFormat),
617 STDCALL(ITextHostImpl_TxGetParaFormat),
618 STDCALL(ITextHostImpl_TxGetSysColor),
619 STDCALL(ITextHostImpl_TxGetBackStyle),
620 STDCALL(ITextHostImpl_TxGetMaxLength),
621 STDCALL(ITextHostImpl_TxGetScrollBars),
622 STDCALL(ITextHostImpl_TxGetPasswordChar),
623 STDCALL(ITextHostImpl_TxGetAcceleratorPos),
624 STDCALL(ITextHostImpl_TxGetExtent),
625 STDCALL(ITextHostImpl_OnTxCharFormatChange),
626 STDCALL(ITextHostImpl_OnTxParaFormatChange),
627 STDCALL(ITextHostImpl_TxGetPropertyBits),
628 STDCALL(ITextHostImpl_TxNotify),
629 STDCALL(ITextHostImpl_TxImmGetContext),
630 STDCALL(ITextHostImpl_TxImmReleaseContext),
631 STDCALL(ITextHostImpl_TxGetSelectionBarWidth),
634 #endif /* __i386__ */
636 static const ITextHostVtbl textHostVtbl = {
637 ITextHostImpl_QueryInterface,
638 ITextHostImpl_AddRef,
639 ITextHostImpl_Release,
640 THISCALL(ITextHostImpl_TxGetDC),
641 THISCALL(ITextHostImpl_TxReleaseDC),
642 THISCALL(ITextHostImpl_TxShowScrollBar),
643 THISCALL(ITextHostImpl_TxEnableScrollBar),
644 THISCALL(ITextHostImpl_TxSetScrollRange),
645 THISCALL(ITextHostImpl_TxSetScrollPos),
646 THISCALL(ITextHostImpl_TxInvalidateRect),
647 THISCALL(ITextHostImpl_TxViewChange),
648 THISCALL(ITextHostImpl_TxCreateCaret),
649 THISCALL(ITextHostImpl_TxShowCaret),
650 THISCALL(ITextHostImpl_TxSetCaretPos),
651 THISCALL(ITextHostImpl_TxSetTimer),
652 THISCALL(ITextHostImpl_TxKillTimer),
653 THISCALL(ITextHostImpl_TxScrollWindowEx),
654 THISCALL(ITextHostImpl_TxSetCapture),
655 THISCALL(ITextHostImpl_TxSetFocus),
656 THISCALL(ITextHostImpl_TxSetCursor),
657 THISCALL(ITextHostImpl_TxScreenToClient),
658 THISCALL(ITextHostImpl_TxClientToScreen),
659 THISCALL(ITextHostImpl_TxActivate),
660 THISCALL(ITextHostImpl_TxDeactivate),
661 THISCALL(ITextHostImpl_TxGetClientRect),
662 THISCALL(ITextHostImpl_TxGetViewInset),
663 THISCALL(ITextHostImpl_TxGetCharFormat),
664 THISCALL(ITextHostImpl_TxGetParaFormat),
665 THISCALL(ITextHostImpl_TxGetSysColor),
666 THISCALL(ITextHostImpl_TxGetBackStyle),
667 THISCALL(ITextHostImpl_TxGetMaxLength),
668 THISCALL(ITextHostImpl_TxGetScrollBars),
669 THISCALL(ITextHostImpl_TxGetPasswordChar),
670 THISCALL(ITextHostImpl_TxGetAcceleratorPos),
671 THISCALL(ITextHostImpl_TxGetExtent),
672 THISCALL(ITextHostImpl_OnTxCharFormatChange),
673 THISCALL(ITextHostImpl_OnTxParaFormatChange),
674 THISCALL(ITextHostImpl_TxGetPropertyBits),
675 THISCALL(ITextHostImpl_TxNotify),
676 THISCALL(ITextHostImpl_TxImmGetContext),
677 THISCALL(ITextHostImpl_TxImmReleaseContext),
678 THISCALL(ITextHostImpl_TxGetSelectionBarWidth),