sync with trunk (r46275)
[reactos.git] / dll / win32 / riched20 / txthost.c
1 /*
2 * RichEdit - ITextHost implementation for windowed richedit controls
3 *
4 * Copyright 2009 by Dylan Smith
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #define NONAMELESSSTRUCT
25 #define NONAMELESSUNION
26 #define COBJMACROS
27
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"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
37
38 typedef struct ITextHostImpl {
39 const ITextHostVtbl *lpVtbl;
40 LONG ref;
41 HWND hWnd;
42 BOOL bEmulateVersion10;
43 } ITextHostImpl;
44
45 static ITextHostVtbl textHostVtbl;
46
47 ITextHost *ME_CreateTextHost(HWND hwnd, BOOL bEmulateVersion10)
48 {
49 ITextHostImpl *texthost;
50 texthost = CoTaskMemAlloc(sizeof(*texthost));
51 if (texthost)
52 {
53 ME_TextEditor *editor;
54
55 texthost->lpVtbl = &textHostVtbl;
56 texthost->ref = 1;
57 texthost->hWnd = hwnd;
58 texthost->bEmulateVersion10 = bEmulateVersion10;
59
60 editor = ME_MakeEditor((ITextHost*)texthost, bEmulateVersion10);
61 editor->exStyleFlags = GetWindowLongW(hwnd, GWL_EXSTYLE);
62 editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
63 SetWindowLongPtrW(hwnd, 0, (LONG_PTR)editor);
64 }
65
66 return (ITextHost*)texthost;
67 }
68
69 static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface,
70 REFIID riid,
71 LPVOID *ppvObject)
72 {
73 ITextHostImpl *This = (ITextHostImpl *)iface;
74
75 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost)) {
76 *ppvObject = This;
77 ITextHost_AddRef((ITextHost *)*ppvObject);
78 return S_OK;
79 }
80
81 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
82 return E_NOINTERFACE;
83 }
84
85 static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
86 {
87 ITextHostImpl *This = (ITextHostImpl *)iface;
88 ULONG ref = InterlockedIncrement(&This->ref);
89 return ref;
90 }
91
92 static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
93 {
94 ITextHostImpl *This = (ITextHostImpl *)iface;
95 ULONG ref = InterlockedDecrement(&This->ref);
96
97 if (!ref)
98 {
99 SetWindowLongPtrW(This->hWnd, 0, 0);
100 CoTaskMemFree(This);
101 }
102 return ref;
103 }
104
105 HDC WINAPI ITextHostImpl_TxGetDC(ITextHost *iface)
106 {
107 ITextHostImpl *This = (ITextHostImpl *)iface;
108 return GetDC(This->hWnd);
109 }
110
111 INT WINAPI ITextHostImpl_TxReleaseDC(ITextHost *iface,
112 HDC hdc)
113 {
114 ITextHostImpl *This = (ITextHostImpl *)iface;
115 return ReleaseDC(This->hWnd, hdc);
116 }
117
118 BOOL WINAPI ITextHostImpl_TxShowScrollBar(ITextHost *iface,
119 INT fnBar,
120 BOOL fShow)
121 {
122 ITextHostImpl *This = (ITextHostImpl *)iface;
123 return ShowScrollBar(This->hWnd, fnBar, fShow);
124 }
125
126 BOOL WINAPI ITextHostImpl_TxEnableScrollBar(ITextHost *iface,
127 INT fuSBFlags,
128 INT fuArrowflags)
129 {
130 ITextHostImpl *This = (ITextHostImpl *)iface;
131 return EnableScrollBar(This->hWnd, fuSBFlags, fuArrowflags);
132 }
133
134 BOOL WINAPI ITextHostImpl_TxSetScrollRange(ITextHost *iface,
135 INT fnBar,
136 LONG nMinPos,
137 INT nMaxPos,
138 BOOL fRedraw)
139 {
140 ITextHostImpl *This = (ITextHostImpl *)iface;
141 return SetScrollRange(This->hWnd, fnBar, nMinPos, nMaxPos, fRedraw);
142 }
143
144 BOOL WINAPI ITextHostImpl_TxSetScrollPos(ITextHost *iface,
145 INT fnBar,
146 INT nPos,
147 BOOL fRedraw)
148 {
149 ITextHostImpl *This = (ITextHostImpl *)iface;
150 int pos = SetScrollPos(This->hWnd, fnBar, nPos, fRedraw);
151 return (pos ? TRUE : FALSE);
152 }
153
154 void WINAPI ITextHostImpl_TxInvalidateRect(ITextHost *iface,
155 LPCRECT prc,
156 BOOL fMode)
157 {
158 ITextHostImpl *This = (ITextHostImpl *)iface;
159 InvalidateRect(This->hWnd, prc, fMode);
160 }
161
162 void WINAPI ITextHostImpl_TxViewChange(ITextHost *iface,
163 BOOL fUpdate)
164 {
165 ITextHostImpl *This = (ITextHostImpl *)iface;
166 if (fUpdate)
167 UpdateWindow(This->hWnd);
168 }
169
170 BOOL WINAPI ITextHostImpl_TxCreateCaret(ITextHost *iface,
171 HBITMAP hbmp,
172 INT xWidth, INT yHeight)
173 {
174 ITextHostImpl *This = (ITextHostImpl *)iface;
175 return CreateCaret(This->hWnd, hbmp, xWidth, yHeight);
176 }
177
178 BOOL WINAPI ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
179 {
180 ITextHostImpl *This = (ITextHostImpl *)iface;
181 if (fShow)
182 return ShowCaret(This->hWnd);
183 else
184 return HideCaret(This->hWnd);
185 }
186
187 BOOL WINAPI ITextHostImpl_TxSetCaretPos(ITextHost *iface,
188 INT x, INT y)
189 {
190 return SetCaretPos(x, y);
191 }
192
193 BOOL WINAPI ITextHostImpl_TxSetTimer(ITextHost *iface,
194 UINT idTimer, UINT uTimeout)
195 {
196 ITextHostImpl *This = (ITextHostImpl *)iface;
197 return SetTimer(This->hWnd, idTimer, uTimeout, NULL) != 0;
198 }
199
200 void WINAPI ITextHostImpl_TxKillTimer(ITextHost *iface,
201 UINT idTimer)
202 {
203 ITextHostImpl *This = (ITextHostImpl *)iface;
204 KillTimer(This->hWnd, idTimer);
205 }
206
207 void WINAPI ITextHostImpl_TxScrollWindowEx(ITextHost *iface,
208 INT dx, INT dy,
209 LPCRECT lprcScroll,
210 LPCRECT lprcClip,
211 HRGN hRgnUpdate,
212 LPRECT lprcUpdate,
213 UINT fuScroll)
214 {
215 ITextHostImpl *This = (ITextHostImpl *)iface;
216 ScrollWindowEx(This->hWnd, dx, dy, lprcScroll, lprcClip,
217 hRgnUpdate, lprcUpdate, fuScroll);
218 }
219
220 void WINAPI ITextHostImpl_TxSetCapture(ITextHost *iface,
221 BOOL fCapture)
222 {
223 ITextHostImpl *This = (ITextHostImpl *)iface;
224 if (fCapture)
225 SetCapture(This->hWnd);
226 else
227 ReleaseCapture();
228 }
229
230 void WINAPI ITextHostImpl_TxSetFocus(ITextHost *iface)
231 {
232 ITextHostImpl *This = (ITextHostImpl *)iface;
233 SetFocus(This->hWnd);
234 }
235
236 void WINAPI ITextHostImpl_TxSetCursor(ITextHost *iface,
237 HCURSOR hcur,
238 BOOL fText)
239 {
240 SetCursor(hcur);
241 }
242
243 BOOL WINAPI ITextHostImpl_TxScreenToClient(ITextHost *iface,
244 LPPOINT lppt)
245 {
246 ITextHostImpl *This = (ITextHostImpl *)iface;
247 return ScreenToClient(This->hWnd, lppt);
248 }
249
250 BOOL WINAPI ITextHostImpl_TxClientToScreen(ITextHost *iface,
251 LPPOINT lppt)
252 {
253 ITextHostImpl *This = (ITextHostImpl *)iface;
254 return ClientToScreen(This->hWnd, lppt);
255 }
256
257 HRESULT WINAPI ITextHostImpl_TxActivate(ITextHost *iface,
258 LONG *plOldState)
259 {
260 ITextHostImpl *This = (ITextHostImpl *)iface;
261 *plOldState = HandleToLong(SetActiveWindow(This->hWnd));
262 return (*plOldState ? S_OK : E_FAIL);
263 }
264
265 HRESULT WINAPI ITextHostImpl_TxDeactivate(ITextHost *iface,
266 LONG lNewState)
267 {
268 HWND ret = SetActiveWindow(LongToHandle(lNewState));
269 return (ret ? S_OK : E_FAIL);
270 }
271
272 HRESULT WINAPI ITextHostImpl_TxGetClientRect(ITextHost *iface,
273 LPRECT prc)
274 {
275 ITextHostImpl *This = (ITextHostImpl *)iface;
276 int ret = GetClientRect(This->hWnd, prc);
277 return (ret ? S_OK : E_FAIL);
278 }
279
280 HRESULT WINAPI ITextHostImpl_TxGetViewInset(ITextHost *iface,
281 LPRECT prc)
282 {
283 prc->top = 0;
284 prc->left = 0;
285 prc->bottom = 0;
286 prc->right = 0;
287 return S_OK;
288 }
289
290 HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface,
291 const CHARFORMATW **ppCF)
292 {
293 return E_NOTIMPL;
294 }
295
296 HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface,
297 const PARAFORMAT **ppPF)
298 {
299 return E_NOTIMPL;
300 }
301
302 COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface,
303 int nIndex)
304 {
305 return GetSysColor(nIndex);
306 }
307
308 HRESULT WINAPI ITextHostImpl_TxGetBackStyle(ITextHost *iface,
309 TXTBACKSTYLE *pStyle)
310 {
311 *pStyle = TXTBACK_OPAQUE;
312 return S_OK;
313 }
314
315 HRESULT WINAPI ITextHostImpl_TxGetMaxLength(ITextHost *iface,
316 DWORD *pLength)
317 {
318 *pLength = INFINITE;
319 return S_OK;
320 }
321
322 HRESULT WINAPI ITextHostImpl_TxGetScrollBars(ITextHost *iface,
323 DWORD *pdwScrollBar)
324 {
325 ITextHostImpl *This = (ITextHostImpl *)iface;
326 ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
327 const DWORD mask = WS_VSCROLL|
328 WS_HSCROLL|
329 ES_AUTOVSCROLL|
330 ES_AUTOHSCROLL|
331 ES_DISABLENOSCROLL;
332 if (editor)
333 {
334 *pdwScrollBar = editor->styleFlags & mask;
335 } else {
336 DWORD style = GetWindowLongW(This->hWnd, GWL_STYLE);
337 if (style & WS_VSCROLL)
338 style |= ES_AUTOVSCROLL;
339 if (!This->bEmulateVersion10 && (style & WS_HSCROLL))
340 style |= ES_AUTOHSCROLL;
341 *pdwScrollBar = style & mask;
342 }
343 return S_OK;
344 }
345
346 HRESULT WINAPI ITextHostImpl_TxGetPasswordChar(ITextHost *iface,
347 WCHAR *pch)
348 {
349 *pch = '*';
350 return S_OK;
351 }
352
353 HRESULT WINAPI ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface,
354 LONG *pch)
355 {
356 *pch = -1;
357 return S_OK;
358 }
359
360 HRESULT WINAPI ITextHostImpl_TxGetExtent(ITextHost *iface,
361 LPSIZEL lpExtent)
362 {
363 return E_NOTIMPL;
364 }
365
366 HRESULT WINAPI ITextHostImpl_OnTxCharFormatChange(ITextHost *iface,
367 const CHARFORMATW *pcf)
368 {
369 return S_OK;
370 }
371
372 HRESULT WINAPI ITextHostImpl_OnTxParaFormatChange(ITextHost *iface,
373 const PARAFORMAT *ppf)
374 {
375 return S_OK;
376 }
377
378 HRESULT WINAPI ITextHostImpl_TxGetPropertyBits(ITextHost *iface,
379 DWORD dwMask,
380 DWORD *pdwBits)
381 {
382 ITextHostImpl *This = (ITextHostImpl *)iface;
383 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
384 DWORD style;
385 DWORD dwBits = 0;
386
387 if (editor)
388 {
389 style = editor->styleFlags;
390 if (editor->mode & TM_RICHTEXT)
391 dwBits |= TXTBIT_RICHTEXT;
392 if (editor->bWordWrap)
393 dwBits |= TXTBIT_WORDWRAP;
394 if (style & ECO_AUTOWORDSELECTION)
395 dwBits |= TXTBIT_AUTOWORDSEL;
396 } else {
397 DWORD dwScrollBar;
398
399 style = GetWindowLongW(This->hWnd, GWL_STYLE);
400 ITextHostImpl_TxGetScrollBars(iface, &dwScrollBar);
401
402 dwBits |= TXTBIT_RICHTEXT|TXTBIT_AUTOWORDSEL;
403 if (!(dwScrollBar & ES_AUTOHSCROLL))
404 dwBits |= TXTBIT_WORDWRAP;
405 }
406
407 /* Bits that correspond to window styles. */
408 if (style & ES_MULTILINE)
409 dwBits |= TXTBIT_MULTILINE;
410 if (style & ES_READONLY)
411 dwBits |= TXTBIT_READONLY;
412 if (style & ES_PASSWORD)
413 dwBits |= TXTBIT_USEPASSWORD;
414 if (!(style & ES_NOHIDESEL))
415 dwBits |= TXTBIT_HIDESELECTION;
416 if (style & ES_SAVESEL)
417 dwBits |= TXTBIT_SAVESELECTION;
418 if (style & ES_VERTICAL)
419 dwBits |= TXTBIT_VERTICAL;
420 if (style & ES_NOOLEDRAGDROP)
421 dwBits |= TXTBIT_DISABLEDRAG;
422
423 dwBits |= TXTBIT_ALLOWBEEP;
424
425 /* The following bits are always FALSE because they are probably only
426 * needed for ITextServices_OnTxPropertyBitsChange:
427 * TXTBIT_VIEWINSETCHANGE
428 * TXTBIT_BACKSTYLECHANGE
429 * TXTBIT_MAXLENGTHCHANGE
430 * TXTBIT_CHARFORMATCHANGE
431 * TXTBIT_PARAFORMATCHANGE
432 * TXTBIT_SHOWACCELERATOR
433 * TXTBIT_EXTENTCHANGE
434 * TXTBIT_SELBARCHANGE
435 * TXTBIT_SCROLLBARCHANGE
436 * TXTBIT_CLIENTRECTCHANGE
437 *
438 * Documented by MSDN as not supported:
439 * TXTBIT_USECURRENTBKG
440 */
441
442 *pdwBits = dwBits & dwMask;
443 return S_OK;
444 }
445
446 HRESULT WINAPI ITextHostImpl_TxNotify(ITextHost *iface,
447 DWORD iNotify,
448 void *pv)
449 {
450 ITextHostImpl *This = (ITextHostImpl *)iface;
451 HWND hwnd = This->hWnd;
452 HWND parent = GetParent(hwnd);
453 UINT id = GetWindowLongW(hwnd, GWLP_ID);
454
455 switch (iNotify)
456 {
457 case EN_DROPFILES:
458 case EN_LINK:
459 case EN_OLEOPFAILED:
460 case EN_PROTECTED:
461 case EN_REQUESTRESIZE:
462 case EN_SAVECLIPBOARD:
463 case EN_SELCHANGE:
464 case EN_STOPNOUNDO:
465 {
466 /* FIXME: Verify this assumption that pv starts with NMHDR. */
467 NMHDR *info = pv;
468 if (!info)
469 return E_FAIL;
470
471 info->hwndFrom = hwnd;
472 info->idFrom = id;
473 info->code = iNotify;
474 SendMessageW(parent, WM_NOTIFY, id, (LPARAM)info);
475 break;
476 }
477
478 case EN_UPDATE:
479 /* Only sent when the window is visible. */
480 if (!IsWindowVisible(This->hWnd))
481 break;
482 /* Fall through */
483 case EN_CHANGE:
484 case EN_ERRSPACE:
485 case EN_HSCROLL:
486 case EN_KILLFOCUS:
487 case EN_MAXTEXT:
488 case EN_SETFOCUS:
489 case EN_VSCROLL:
490 SendMessageW(parent, WM_COMMAND, MAKEWPARAM(id, iNotify), (LPARAM)hwnd);
491 break;
492
493 case EN_MSGFILTER:
494 FIXME("EN_MSGFILTER is documented as not being sent to TxNotify\n");
495 /* fall through */
496 default:
497 return E_FAIL;
498 }
499 return S_OK;
500 }
501
502 HIMC WINAPI ITextHostImpl_TxImmGetContext(ITextHost *iface)
503 {
504 ITextHostImpl *This = (ITextHostImpl *)iface;
505 return ImmGetContext(This->hWnd);
506 }
507
508 void WINAPI ITextHostImpl_TxImmReleaseContext(ITextHost *iface,
509 HIMC himc)
510 {
511 ITextHostImpl *This = (ITextHostImpl *)iface;
512 ImmReleaseContext(This->hWnd, himc);
513 }
514
515 HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface,
516 LONG *lSelBarWidth)
517 {
518 ITextHostImpl *This = (ITextHostImpl *)iface;
519 ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
520
521 DWORD style = editor ? editor->styleFlags
522 : GetWindowLongW(This->hWnd, GWL_STYLE);
523 *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
524 return S_OK;
525 }
526
527
528 #ifdef __i386__ /* thiscall functions are i386-specific */
529
530 #define THISCALL(func) __thiscall_ ## func
531 #define DEFINE_THISCALL_WRAPPER(func) \
532 extern typeof(func) THISCALL(func); \
533 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
534 "popl %eax\n\t" \
535 "pushl %ecx\n\t" \
536 "pushl %eax\n\t" \
537 "jmp " __ASM_NAME(#func) )
538
539 #else /* __i386__ */
540
541 #define THISCALL(func) func
542 #define DEFINE_THISCALL_WRAPPER(func) /* nothing */
543
544 #endif /* __i386__ */
545
546 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC);
547 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC);
548 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar);
549 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar);
550 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange);
551 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos);
552 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect);
553 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange);
554 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret);
555 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret);
556 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos);
557 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer);
558 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer);
559 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx);
560 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture);
561 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus);
562 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor);
563 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient);
564 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen);
565 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate);
566 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate);
567 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect);
568 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset);
569 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetCharFormat);
570 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat);
571 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor);
572 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle);
573 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength);
574 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars);
575 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar);
576 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos);
577 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent);
578 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxCharFormatChange);
579 DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxParaFormatChange);
580 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits);
581 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify);
582 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext);
583 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext);
584 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth);
585
586 static ITextHostVtbl textHostVtbl = {
587 ITextHostImpl_QueryInterface,
588 ITextHostImpl_AddRef,
589 ITextHostImpl_Release,
590 THISCALL(ITextHostImpl_TxGetDC),
591 THISCALL(ITextHostImpl_TxReleaseDC),
592 THISCALL(ITextHostImpl_TxShowScrollBar),
593 THISCALL(ITextHostImpl_TxEnableScrollBar),
594 THISCALL(ITextHostImpl_TxSetScrollRange),
595 THISCALL(ITextHostImpl_TxSetScrollPos),
596 THISCALL(ITextHostImpl_TxInvalidateRect),
597 THISCALL(ITextHostImpl_TxViewChange),
598 THISCALL(ITextHostImpl_TxCreateCaret),
599 THISCALL(ITextHostImpl_TxShowCaret),
600 THISCALL(ITextHostImpl_TxSetCaretPos),
601 THISCALL(ITextHostImpl_TxSetTimer),
602 THISCALL(ITextHostImpl_TxKillTimer),
603 THISCALL(ITextHostImpl_TxScrollWindowEx),
604 THISCALL(ITextHostImpl_TxSetCapture),
605 THISCALL(ITextHostImpl_TxSetFocus),
606 THISCALL(ITextHostImpl_TxSetCursor),
607 THISCALL(ITextHostImpl_TxScreenToClient),
608 THISCALL(ITextHostImpl_TxClientToScreen),
609 THISCALL(ITextHostImpl_TxActivate),
610 THISCALL(ITextHostImpl_TxDeactivate),
611 THISCALL(ITextHostImpl_TxGetClientRect),
612 THISCALL(ITextHostImpl_TxGetViewInset),
613 THISCALL(ITextHostImpl_TxGetCharFormat),
614 THISCALL(ITextHostImpl_TxGetParaFormat),
615 THISCALL(ITextHostImpl_TxGetSysColor),
616 THISCALL(ITextHostImpl_TxGetBackStyle),
617 THISCALL(ITextHostImpl_TxGetMaxLength),
618 THISCALL(ITextHostImpl_TxGetScrollBars),
619 THISCALL(ITextHostImpl_TxGetPasswordChar),
620 THISCALL(ITextHostImpl_TxGetAcceleratorPos),
621 THISCALL(ITextHostImpl_TxGetExtent),
622 THISCALL(ITextHostImpl_OnTxCharFormatChange),
623 THISCALL(ITextHostImpl_OnTxParaFormatChange),
624 THISCALL(ITextHostImpl_TxGetPropertyBits),
625 THISCALL(ITextHostImpl_TxNotify),
626 THISCALL(ITextHostImpl_TxImmGetContext),
627 THISCALL(ITextHostImpl_TxImmReleaseContext),
628 THISCALL(ITextHostImpl_TxGetSelectionBarWidth),
629 };
630
631 #ifdef __i386__ /* thiscall functions are i386-specific */
632
633 #define STDCALL(func) __stdcall_ ## func
634 #define DEFINE_STDCALL_WRAPPER(num,func) \
635 extern typeof(func) __stdcall_ ## func; \
636 __ASM_GLOBAL_FUNC(__stdcall_ ## func, \
637 "popl %eax\n\t" \
638 "popl %ecx\n\t" \
639 "pushl %eax\n\t" \
640 "movl (%ecx), %eax\n\t" \
641 "jmp *(4*(" #num "))(%eax)" )
642
643 DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC);
644 DEFINE_STDCALL_WRAPPER(4,ITextHostImpl_TxReleaseDC);
645 DEFINE_STDCALL_WRAPPER(5,ITextHostImpl_TxShowScrollBar);
646 DEFINE_STDCALL_WRAPPER(6,ITextHostImpl_TxEnableScrollBar);
647 DEFINE_STDCALL_WRAPPER(7,ITextHostImpl_TxSetScrollRange);
648 DEFINE_STDCALL_WRAPPER(8,ITextHostImpl_TxSetScrollPos);
649 DEFINE_STDCALL_WRAPPER(9,ITextHostImpl_TxInvalidateRect);
650 DEFINE_STDCALL_WRAPPER(10,ITextHostImpl_TxViewChange);
651 DEFINE_STDCALL_WRAPPER(11,ITextHostImpl_TxCreateCaret);
652 DEFINE_STDCALL_WRAPPER(12,ITextHostImpl_TxShowCaret);
653 DEFINE_STDCALL_WRAPPER(13,ITextHostImpl_TxSetCaretPos);
654 DEFINE_STDCALL_WRAPPER(14,ITextHostImpl_TxSetTimer);
655 DEFINE_STDCALL_WRAPPER(15,ITextHostImpl_TxKillTimer);
656 DEFINE_STDCALL_WRAPPER(16,ITextHostImpl_TxScrollWindowEx);
657 DEFINE_STDCALL_WRAPPER(17,ITextHostImpl_TxSetCapture);
658 DEFINE_STDCALL_WRAPPER(18,ITextHostImpl_TxSetFocus);
659 DEFINE_STDCALL_WRAPPER(19,ITextHostImpl_TxSetCursor);
660 DEFINE_STDCALL_WRAPPER(20,ITextHostImpl_TxScreenToClient);
661 DEFINE_STDCALL_WRAPPER(21,ITextHostImpl_TxClientToScreen);
662 DEFINE_STDCALL_WRAPPER(22,ITextHostImpl_TxActivate);
663 DEFINE_STDCALL_WRAPPER(23,ITextHostImpl_TxDeactivate);
664 DEFINE_STDCALL_WRAPPER(24,ITextHostImpl_TxGetClientRect);
665 DEFINE_STDCALL_WRAPPER(25,ITextHostImpl_TxGetViewInset);
666 DEFINE_STDCALL_WRAPPER(26,ITextHostImpl_TxGetCharFormat);
667 DEFINE_STDCALL_WRAPPER(27,ITextHostImpl_TxGetParaFormat);
668 DEFINE_STDCALL_WRAPPER(28,ITextHostImpl_TxGetSysColor);
669 DEFINE_STDCALL_WRAPPER(29,ITextHostImpl_TxGetBackStyle);
670 DEFINE_STDCALL_WRAPPER(30,ITextHostImpl_TxGetMaxLength);
671 DEFINE_STDCALL_WRAPPER(31,ITextHostImpl_TxGetScrollBars);
672 DEFINE_STDCALL_WRAPPER(32,ITextHostImpl_TxGetPasswordChar);
673 DEFINE_STDCALL_WRAPPER(33,ITextHostImpl_TxGetAcceleratorPos);
674 DEFINE_STDCALL_WRAPPER(34,ITextHostImpl_TxGetExtent);
675 DEFINE_STDCALL_WRAPPER(35,ITextHostImpl_OnTxCharFormatChange);
676 DEFINE_STDCALL_WRAPPER(36,ITextHostImpl_OnTxParaFormatChange);
677 DEFINE_STDCALL_WRAPPER(37,ITextHostImpl_TxGetPropertyBits);
678 DEFINE_STDCALL_WRAPPER(38,ITextHostImpl_TxNotify);
679 DEFINE_STDCALL_WRAPPER(39,ITextHostImpl_TxImmGetContext);
680 DEFINE_STDCALL_WRAPPER(40,ITextHostImpl_TxImmReleaseContext);
681 DEFINE_STDCALL_WRAPPER(41,ITextHostImpl_TxGetSelectionBarWidth);
682
683 ITextHostVtbl itextHostStdcallVtbl = {
684 NULL,
685 NULL,
686 NULL,
687 __stdcall_ITextHostImpl_TxGetDC,
688 __stdcall_ITextHostImpl_TxReleaseDC,
689 __stdcall_ITextHostImpl_TxShowScrollBar,
690 __stdcall_ITextHostImpl_TxEnableScrollBar,
691 __stdcall_ITextHostImpl_TxSetScrollRange,
692 __stdcall_ITextHostImpl_TxSetScrollPos,
693 __stdcall_ITextHostImpl_TxInvalidateRect,
694 __stdcall_ITextHostImpl_TxViewChange,
695 __stdcall_ITextHostImpl_TxCreateCaret,
696 __stdcall_ITextHostImpl_TxShowCaret,
697 __stdcall_ITextHostImpl_TxSetCaretPos,
698 __stdcall_ITextHostImpl_TxSetTimer,
699 __stdcall_ITextHostImpl_TxKillTimer,
700 __stdcall_ITextHostImpl_TxScrollWindowEx,
701 __stdcall_ITextHostImpl_TxSetCapture,
702 __stdcall_ITextHostImpl_TxSetFocus,
703 __stdcall_ITextHostImpl_TxSetCursor,
704 __stdcall_ITextHostImpl_TxScreenToClient,
705 __stdcall_ITextHostImpl_TxClientToScreen,
706 __stdcall_ITextHostImpl_TxActivate,
707 __stdcall_ITextHostImpl_TxDeactivate,
708 __stdcall_ITextHostImpl_TxGetClientRect,
709 __stdcall_ITextHostImpl_TxGetViewInset,
710 __stdcall_ITextHostImpl_TxGetCharFormat,
711 __stdcall_ITextHostImpl_TxGetParaFormat,
712 __stdcall_ITextHostImpl_TxGetSysColor,
713 __stdcall_ITextHostImpl_TxGetBackStyle,
714 __stdcall_ITextHostImpl_TxGetMaxLength,
715 __stdcall_ITextHostImpl_TxGetScrollBars,
716 __stdcall_ITextHostImpl_TxGetPasswordChar,
717 __stdcall_ITextHostImpl_TxGetAcceleratorPos,
718 __stdcall_ITextHostImpl_TxGetExtent,
719 __stdcall_ITextHostImpl_OnTxCharFormatChange,
720 __stdcall_ITextHostImpl_OnTxParaFormatChange,
721 __stdcall_ITextHostImpl_TxGetPropertyBits,
722 __stdcall_ITextHostImpl_TxNotify,
723 __stdcall_ITextHostImpl_TxImmGetContext,
724 __stdcall_ITextHostImpl_TxImmReleaseContext,
725 __stdcall_ITextHostImpl_TxGetSelectionBarWidth,
726 };
727
728 #endif /* __i386__ */