Commit 6c4dda00 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Implemented ITextHost for windowed richedit controls.

parent 7e388190
...@@ -21,6 +21,7 @@ C_SRCS = \ ...@@ -21,6 +21,7 @@ C_SRCS = \
string.c \ string.c \
style.c \ style.c \
table.c \ table.c \
txthost.c \
txtsrv.c \ txtsrv.c \
undo.c \ undo.c \
wrap.c \ wrap.c \
......
...@@ -2657,17 +2657,26 @@ static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y) ...@@ -2657,17 +2657,26 @@ static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
return TRUE; return TRUE;
} }
static ME_TextEditor *ME_MakeEditor(HWND hWnd, BOOL bEmulateVersion10) ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
{ {
ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor); ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor);
int i; int i;
ed->hWnd = hWnd; DWORD props;
LONG selbarwidth;
ed->hWnd = NULL;
ed->texthost = texthost;
ed->bEmulateVersion10 = bEmulateVersion10; ed->bEmulateVersion10 = bEmulateVersion10;
ed->styleFlags = GetWindowLongW(hWnd, GWL_STYLE); ITextHost_TxGetPropertyBits(texthost,
if (ed->styleFlags & WS_VSCROLL) (TXTBIT_RICHTEXT|TXTBIT_MULTILINE|
ed->styleFlags |= ES_AUTOVSCROLL; TXTBIT_READONLY|TXTBIT_USEPASSWORD|
if (!ed->bEmulateVersion10 && (ed->styleFlags & WS_HSCROLL)) TXTBIT_HIDESELECTION|TXTBIT_SAVESELECTION|
ed->styleFlags |= ES_AUTOHSCROLL; TXTBIT_AUTOWORDSEL|TXTBIT_VERTICAL|
TXTBIT_WORDWRAP|TXTBIT_DISABLEDRAG),
&props);
ITextHost_TxGetScrollBars(texthost, &ed->styleFlags);
ed->styleFlags &= (WS_VSCROLL|WS_HSCROLL|ES_AUTOVSCROLL|
ES_AUTOHSCROLL|ES_DISABLENOSCROLL);
ed->pBuffer = ME_MakeText(); ed->pBuffer = ME_MakeText();
ed->nZoomNumerator = ed->nZoomDenominator = 0; ed->nZoomNumerator = ed->nZoomDenominator = 0;
ME_MakeFirstParagraph(ed); ME_MakeFirstParagraph(ed);
...@@ -2702,12 +2711,13 @@ static ME_TextEditor *ME_MakeEditor(HWND hWnd, BOOL bEmulateVersion10) ...@@ -2702,12 +2711,13 @@ static ME_TextEditor *ME_MakeEditor(HWND hWnd, BOOL bEmulateVersion10)
ed->nParagraphs = 1; ed->nParagraphs = 1;
ed->nLastSelStart = ed->nLastSelEnd = 0; ed->nLastSelStart = ed->nLastSelEnd = 0;
ed->pLastSelStartPara = ed->pLastSelEndPara = ME_FindItemFwd(ed->pBuffer->pFirst, diParagraph); ed->pLastSelStartPara = ed->pLastSelEndPara = ME_FindItemFwd(ed->pBuffer->pFirst, diParagraph);
ed->bWordWrap = !(ed->styleFlags & ES_AUTOHSCROLL); ed->bWordWrap = (props & TXTBIT_WORDWRAP) != 0;
ed->bHideSelection = FALSE; ed->bHideSelection = FALSE;
ed->nInvalidOfs = -1; ed->nInvalidOfs = -1;
ed->pfnWordBreak = NULL; ed->pfnWordBreak = NULL;
ed->lpOleCallback = NULL; ed->lpOleCallback = NULL;
ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE; ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
ed->mode |= (props & TXTBIT_RICHTEXT) ? TM_RICHTEXT : TM_PLAINTEXT;
ed->AutoURLDetect_bEnable = FALSE; ed->AutoURLDetect_bEnable = FALSE;
ed->bHaveFocus = FALSE; ed->bHaveFocus = FALSE;
ed->bMouseCaptured = FALSE; ed->bMouseCaptured = FALSE;
...@@ -2719,17 +2729,30 @@ static ME_TextEditor *ME_MakeEditor(HWND hWnd, BOOL bEmulateVersion10) ...@@ -2719,17 +2729,30 @@ static ME_TextEditor *ME_MakeEditor(HWND hWnd, BOOL bEmulateVersion10)
} }
ME_CheckCharOffsets(ed); ME_CheckCharOffsets(ed);
if (ed->styleFlags & ES_SELECTIONBAR)
ed->selofs = SELECTIONBAR_WIDTH;
else
ed->selofs = 0;
ed->bDefaultFormatRect = TRUE; ed->bDefaultFormatRect = TRUE;
ITextHost_TxGetSelectionBarWidth(ed->texthost, &selbarwidth);
/* FIXME: Convert selbarwidth from HIMETRIC to pixels */
ed->selofs = selbarwidth ? SELECTIONBAR_WIDTH : 0;
ed->nSelectionType = stPosition; ed->nSelectionType = stPosition;
if (ed->styleFlags & ES_PASSWORD) ed->cPasswordMask = 0;
ed->cPasswordMask = '*'; if (props & TXTBIT_USEPASSWORD)
else ITextHost_TxGetPasswordChar(texthost, &ed->cPasswordMask);
ed->cPasswordMask = 0;
if (props & TXTBIT_AUTOWORDSEL)
ed->styleFlags |= ECO_AUTOWORDSELECTION;
if (props & TXTBIT_MULTILINE)
ed->styleFlags |= ES_MULTILINE;
if (props & TXTBIT_READONLY)
ed->styleFlags |= ES_READONLY;
if (!(props & TXTBIT_HIDESELECTION))
ed->styleFlags |= ES_NOHIDESEL;
if (props & TXTBIT_SAVESELECTION)
ed->styleFlags |= ES_SAVESEL;
if (props & TXTBIT_VERTICAL)
ed->styleFlags |= ES_VERTICAL;
if (props & TXTBIT_DISABLEDRAG)
ed->styleFlags |= ES_NOOLEDRAGDROP;
ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0; ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0;
...@@ -2774,7 +2797,7 @@ static void ME_DestroyEditor(ME_TextEditor *editor) ...@@ -2774,7 +2797,7 @@ static void ME_DestroyEditor(ME_TextEditor *editor)
DeleteObject(editor->hbrBackground); DeleteObject(editor->hbrBackground);
if(editor->lpOleCallback) if(editor->lpOleCallback)
IUnknown_Release(editor->lpOleCallback); IUnknown_Release(editor->lpOleCallback);
SetWindowLongPtrW(editor->hWnd, 0, 0); IUnknown_Release(editor->texthost);
OleUninitialize(); OleUninitialize();
FREE_OBJ(editor->pBuffer); FREE_OBJ(editor->pBuffer);
...@@ -4425,10 +4448,11 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ...@@ -4425,10 +4448,11 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
if (msg == WM_NCCREATE) if (msg == WM_NCCREATE)
{ {
CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
ITextHost *texthost;
TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style); TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
editor = ME_MakeEditor(hWnd, FALSE); texthost = ME_CreateTextHost(hWnd, FALSE);
SetWindowLongPtrW(hWnd, 0, (LONG_PTR)editor); return texthost != NULL;
return TRUE;
} }
else if (msg != WM_NCDESTROY) else if (msg != WM_NCDESTROY)
{ {
...@@ -4479,13 +4503,12 @@ LRESULT WINAPI RichEdit10ANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM ...@@ -4479,13 +4503,12 @@ LRESULT WINAPI RichEdit10ANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
{ {
if (msg == WM_NCCREATE && !GetWindowLongPtrW(hWnd, 0)) if (msg == WM_NCCREATE && !GetWindowLongPtrW(hWnd, 0))
{ {
ME_TextEditor *editor; ITextHost *texthost;
CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style); TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
editor = ME_MakeEditor(hWnd, TRUE); texthost = ME_CreateTextHost(hWnd, TRUE);
SetWindowLongPtrW(hWnd, 0, (LONG_PTR)editor); return texthost != NULL;
return TRUE;
} }
return RichEditANSIWndProc(hWnd, msg, wParam, lParam); return RichEditANSIWndProc(hWnd, msg, wParam, lParam);
} }
......
...@@ -261,6 +261,7 @@ void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src); ...@@ -261,6 +261,7 @@ void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src);
void ME_DeleteReObject(REOBJECT* reo); void ME_DeleteReObject(REOBJECT* reo);
/* editor.c */ /* editor.c */
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10);
void ME_SendOldNotify(ME_TextEditor *editor, int nCode); void ME_SendOldNotify(ME_TextEditor *editor, int nCode);
int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, BOOL bCRLF); int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, BOOL bCRLF);
ME_DisplayItem *ME_FindItemAtOffset(ME_TextEditor *editor, ME_DIType nItemType, int nOffset, int *nItemOffset); ME_DisplayItem *ME_FindItemAtOffset(ME_TextEditor *editor, ME_DIType nItemType, int nOffset, int *nItemOffset);
...@@ -289,6 +290,54 @@ void ME_MoveCursorFromTableRowStartParagraph(ME_TextEditor *editor); ...@@ -289,6 +290,54 @@ void ME_MoveCursorFromTableRowStartParagraph(ME_TextEditor *editor);
struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor); struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor);
void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef); void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef);
/* txthost.c */
ITextHost *ME_CreateTextHost(HWND hwnd, BOOL bEmulateVersion10);
#ifdef __i386__ /* Use wrappers to perform thiscall on i386 */
#define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl)
#else /* __i386__ */
#define TXTHOST_VTABLE(This) (This)->lpVtbl
#endif /* __i386__ */
/*** ITextHost methods ***/
#define ITextHost_TxGetDC(This) TXTHOST_VTABLE(This)->TxGetDC(This)
#define ITextHost_TxReleaseDC(This,a) TXTHOST_VTABLE(This)->TxReleaseDC(This,a)
#define ITextHost_TxShowScrollBar(This,a,b) TXTHOST_VTABLE(This)->TxShowScrollBar(This,a,b)
#define ITextHost_TxEnableScrollBar(This,a,b) TXTHOST_VTABLE(This)->TxEnableScrollBar(This,a,b)
#define ITextHost_TxSetScrollRange(This,a,b,c,d) TXTHOST_VTABLE(This)->TxSetScrollRange(This,a,b,c,d)
#define ITextHost_TxSetScrollPos(This,a,b,c) TXTHOST_VTABLE(This)->TxSetScrollPos(This,a,b,c)
#define ITextHost_TxInvalidateRect(This,a,b) TXTHOST_VTABLE(This)->TxInvalidateRect(This,a,b)
#define ITextHost_TxViewChange(This,a) TXTHOST_VTABLE(This)->TxViewChange(This,a)
#define ITextHost_TxCreateCaret(This,a,b,c) TXTHOST_VTABLE(This)->TxCreateCaret(This,a,b,c)
#define ITextHost_TxShowCaret(This,a) TXTHOST_VTABLE(This)->TxShowCaret(This,a)
#define ITextHost_TxSetCaretPos(This,a,b) TXTHOST_VTABLE(This)->TxSetCaretPos(This,a,b)
#define ITextHost_TxSetTimer(This,a,b) TXTHOST_VTABLE(This)->TxSetTimer(This,a,b)
#define ITextHost_TxKillTimer(This,a) TXTHOST_VTABLE(This)->TxKillTimer(This,a)
#define ITextHost_TxScrollWindowEx(This,a,b,c,d,e,f,g) TXTHOST_VTABLE(This)->TxScrollWindowEx(This,a,b,c,d,e,f,g)
#define ITextHost_TxSetCapture(This,a) TXTHOST_VTABLE(This)->TxSetCapture(This,a)
#define ITextHost_TxSetFocus(This) TXTHOST_VTABLE(This)->TxSetFocus(This)
#define ITextHost_TxSetCursor(This,a,b) TXTHOST_VTABLE(This)->TxSetCursor(This,a,b)
#define ITextHost_TxScreenToClient(This,a) TXTHOST_VTABLE(This)->TxScreenToClient(This,a)
#define ITextHost_TxClientToScreen(This,a) TXTHOST_VTABLE(This)->TxClientToScreen(This,a)
#define ITextHost_TxActivate(This,a) TXTHOST_VTABLE(This)->TxActivate(This,a)
#define ITextHost_TxDeactivate(This,a) TXTHOST_VTABLE(This)->TxDeactivate(This,a)
#define ITextHost_TxGetClientRect(This,a) TXTHOST_VTABLE(This)->TxGetClientRect(This,a)
#define ITextHost_TxGetViewInset(This,a) TXTHOST_VTABLE(This)->TxGetViewInset(This,a)
#define ITextHost_TxGetCharFormat(This,a) TXTHOST_VTABLE(This)->TxGetCharFormat(This,a)
#define ITextHost_TxGetParaFormat(This,a) TXTHOST_VTABLE(This)->TxGetParaFormat(This,a)
#define ITextHost_TxGetSysColor(This,a) TXTHOST_VTABLE(This)->TxGetSysColor(This,a)
#define ITextHost_TxGetBackStyle(This,a) TXTHOST_VTABLE(This)->TxGetBackStyle(This,a)
#define ITextHost_TxGetMaxLength(This,a) TXTHOST_VTABLE(This)->TxGetMaxLength(This,a)
#define ITextHost_TxGetScrollBars(This,a) TXTHOST_VTABLE(This)->TxGetScrollBars(This,a)
#define ITextHost_TxGetPasswordChar(This,a) TXTHOST_VTABLE(This)->TxGetPasswordChar(This,a)
#define ITextHost_TxGetAcceleratorPos(This,a) TXTHOST_VTABLE(This)->TxGetAcceleratorPos(This,a)
#define ITextHost_TxGetExtent(This,a) TXTHOST_VTABLE(This)->TxGetExtent(This,a)
#define ITextHost_OnTxCharFormatChange(This,a) TXTHOST_VTABLE(This)->OnTxCharFormatChange(This,a)
#define ITextHost_OnTxParaFormatChange(This,a) TXTHOST_VTABLE(This)->OnTxParaFormatChange(This,a)
#define ITextHost_TxGetPropertyBits(This,a,b) TXTHOST_VTABLE(This)->TxGetPropertyBits(This,a,b)
#define ITextHost_TxNotify(This,a,b) TXTHOST_VTABLE(This)->TxNotify(This,a,b)
#define ITextHost_TxImmGetContext(This) TXTHOST_VTABLE(This)->TxImmGetContext(This)
#define ITextHost_TxImmReleaseContext(This,a) TXTHOST_VTABLE(This)->TxImmReleaseContext(This,a)
#define ITextHost_TxGetSelectionBarWidth(This,a) TXTHOST_VTABLE(This)->TxGetSelectionBarWidth(This,a)
/* undo.c */ /* undo.c */
ME_UndoItem *ME_AddUndoItem(ME_TextEditor *editor, ME_DIType type, const ME_DisplayItem *pdi); ME_UndoItem *ME_AddUndoItem(ME_TextEditor *editor, ME_DIType type, const ME_DisplayItem *pdi);
void ME_CommitUndo(ME_TextEditor *editor); void ME_CommitUndo(ME_TextEditor *editor);
......
...@@ -44,9 +44,15 @@ ...@@ -44,9 +44,15 @@
#include <commctrl.h> #include <commctrl.h>
#include <ole2.h> #include <ole2.h>
#include <richole.h> #include <richole.h>
#include "imm.h"
#include <textserv.h>
#include "wine/debug.h" #include "wine/debug.h"
#ifdef __i386__
extern struct ITextHostVtbl itextHostStdcallVtbl;
#endif /* __i386__ */
typedef struct tagME_String typedef struct tagME_String
{ {
WCHAR *szData; WCHAR *szData;
...@@ -327,6 +333,7 @@ typedef struct tagME_FontCacheItem ...@@ -327,6 +333,7 @@ typedef struct tagME_FontCacheItem
typedef struct tagME_TextEditor typedef struct tagME_TextEditor
{ {
HWND hWnd; HWND hWnd;
ITextHost *texthost;
BOOL bEmulateVersion10; BOOL bEmulateVersion10;
ME_TextBuffer *pBuffer; ME_TextBuffer *pBuffer;
ME_Cursor *pCursors; ME_Cursor *pCursors;
......
...@@ -357,46 +357,6 @@ DECLARE_INTERFACE_(ITextHost,IUnknown) ...@@ -357,46 +357,6 @@ DECLARE_INTERFACE_(ITextHost,IUnknown)
#define ITextHost_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) #define ITextHost_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define ITextHost_AddRef(p) (p)->lpVtbl->AddRef(p) #define ITextHost_AddRef(p) (p)->lpVtbl->AddRef(p)
#define ITextHost_Release(p) (p)->lpVtbl->Release(p) #define ITextHost_Release(p) (p)->lpVtbl->Release(p)
/*** ITextHost methods ***/
#define ITextHost_TxGetDC(p) (p)->lpVtbl->TxGetDC(p)
#define ITextHost_TxReleaseDC(p,a) (p)->lpVtbl->TxReleaseDC(p,a)
#define ITextHost_TxShowScrollBar(p,a,b) (p)->lpVtbl->TxShowScrollBar(p,a,b)
#define ITextHost_TxEnableScrollBar(p,a,b) (p)->lpVtbl->TxEnableScrollBar(p,a,b)
#define ITextHost_TxSetScrollRange(p,a,b,c,d) (p)->lpVtbl->TxSetScrollRange(p,a,b,c,d)
#define ITextHost_TxSetScrollPos(p,a,b,c) (p)->lpVtbl->TxSetScrollPos(p,a,b,c)
#define ITextHost_TxInvalidateRect(p,a,b) (p)->lpVtbl->TxInvalidateRect(p,a,b)
#define ITextHost_TxViewChange(p,a) (p)->lpVtbl->TxViewChange(p,a)
#define ITextHost_TxCreateCaret(p,a,b,c) (p)->lpVtbl->TxCreateCaret(p,a,b,c)
#define ITextHost_TxShowCaret(p,a) (p)->lpVtbl->TxShowCaret(p,a)
#define ITextHost_TxSetCarentPos(p,a,b) (p)->lpVtbl->TxSetCarentPos(p,a,b)
#define ITextHost_TxSetTimer(p,a,b) (p)->lpVtbl->TxSetTimer(p,a,b)
#define ITextHost_TxKillTimer(p,a) (p)->lpVtbl->TxKillTimer(p,a)
#define ITextHost_TxScrollWindowEx(p,a,b,c,d,e,f,g) (p)->lpVtbl->TxScrollWindowEx(p,a,b,c,d,e,f,g)
#define ITextHost_TxSetCapture(p,a) (p)->lpVtbl->TxSetCapture(p,a)
#define ITextHost_TxSetFocus(p) (p)->lpVtbl->TxSetFocus(p)
#define ITextHost_TxSetCursor(p,a,b) (p)->lpVtbl->TxSetCursor(p,a,b)
#define ITextHost_TxScreenToClient(p,a) (p)->lpVtbl->TxScreenToClient(p,a)
#define ITextHost_TxClientToScreen(p,a) (p)->lpVtbl->TxClientToScreen(p,a)
#define ITextHost_TxActivate(p,a) (p)->lpVtbl->TxActivate(p,a)
#define ITextHost_TxDeactivate(p,a) (p)->lpVtbl->TxDeactivate(p,a)
#define ITextHost_TxGetClientRect(p,a) (p)->lpVtbl->TxGetClientRect(p,a)
#define ITextHost_TxGetViewInset(p,a) (p)->lpVtbl->TxGetViewInset(p,a)
#define ITextHost_TxGetCharFormat(p,a) (p)->lpVtbl->TxGetCharFormat(p,a)
#define ITextHost_TxGetParaFormat(p,a) (p)->lpVtbl->TxGetParaFormat(p,a)
#define ITextHost_TxGetSysColor(p,a) (p)->lpVtbl->TxGetSysColor(p,a)
#define ITextHost_TxGetBackStyle(p,a) (p)->lpVtbl->TxGetBackStyle(p,a)
#define ITextHost_TxGetMaxLength(p,a) (p)->lpVtbl->TxGetMaxLength(p,a)
#define ITextHost_TxGetScrollBars(p,a) (p)->lpVtbl->TxGetScrollBars(p,a)
#define ITextHost_TxGetPasswordChar(p,a) (p)->lpVtbl->TxGetPasswordChar(p,a)
#define ITextHost_TxGetAcceleratorPos(p,a) (p)->lpVtbl->TxGetAcceleratorPos(p,a)
#define ITextHost_TxGetExtent(p,a) (p)->lpVtbl->TxGetExtent(p,a)
#define ITextHost_OnTxCharFormatChange(p,a) (p)->lpVtbl->OnTxCharFormatChange(p,a)
#define ITextHost_OnTxParaFormatChange(p,a) (p)->lpVtbl->OnTxParaFormatChange(p,a)
#define ITextHost_TxGetPropertyBits(p,a,b) (p)->lpVtbl->TxGetPropertyBits(p,a,b)
#define ITextHost_TxNotify(p,a,b) (p)->lpVtbl->TxNotify(p,a,b)
#define ITextHost_TxImmGetContext(p) (p)->lpVtbl->TxImmGetContext(p)
#define ITextHost_TxImmReleaseContext(p,a) (p)->lpVtbl->TxImmReleaseContext(p,a)
#define ITextHost_TxGetSelectionBarWidth(p,a) (p)->lpVtbl->TxGetSelectionBarWidth(p,a)
#endif #endif
#undef INTERFACE #undef INTERFACE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment