Commit 8e17457f authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Add ITextHost2 support and use it to get the window for WM_CONTEXTMENU.

parent c4acdfd3
......@@ -2906,20 +2906,24 @@ static LONG ME_GetSelectionType(ME_TextEditor *editor)
static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
{
CHARRANGE selrange;
HMENU menu;
int seltype;
if(!editor->lpOleCallback || !editor->hWnd)
return FALSE;
ME_GetSelectionOfs(editor, &selrange.cpMin, &selrange.cpMax);
seltype = ME_GetSelectionType(editor);
if(SUCCEEDED(IRichEditOleCallback_GetContextMenu(editor->lpOleCallback, seltype, NULL, &selrange, &menu)))
{
TrackPopupMenu(menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, 0, editor->hwndParent, NULL);
DestroyMenu(menu);
}
return TRUE;
CHARRANGE selrange;
HMENU menu;
int seltype;
HWND hwnd, parent;
if (!editor->lpOleCallback || !editor->have_texthost2) return FALSE;
if (FAILED( ITextHost2_TxGetWindow( editor->texthost, &hwnd ))) return FALSE;
parent = GetParent( hwnd );
if (!parent) parent = hwnd;
ME_GetSelectionOfs( editor, &selrange.cpMin, &selrange.cpMax );
seltype = ME_GetSelectionType( editor );
if (SUCCEEDED( IRichEditOleCallback_GetContextMenu( editor->lpOleCallback, seltype, NULL, &selrange, &menu ) ))
{
TrackPopupMenu( menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, 0, parent, NULL );
DestroyMenu( menu );
}
return TRUE;
}
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
......@@ -2932,16 +2936,26 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->hWnd = NULL;
ed->hwndParent = NULL;
ed->sizeWindow.cx = ed->sizeWindow.cy = 0;
ed->texthost = texthost;
if (ITextHost_QueryInterface( texthost, &IID_ITextHost2, (void **)&ed->texthost ) == S_OK)
{
ITextHost_Release( texthost );
ed->have_texthost2 = TRUE;
}
else
{
ed->texthost = (ITextHost2 *)texthost;
ed->have_texthost2 = FALSE;
}
ed->reOle = NULL;
ed->bEmulateVersion10 = bEmulateVersion10;
ed->in_place_active = FALSE;
ed->total_rows = 0;
ITextHost_TxGetPropertyBits( texthost, TXTBIT_RICHTEXT | TXTBIT_MULTILINE | TXTBIT_READONLY |
ITextHost_TxGetPropertyBits( ed->texthost, TXTBIT_RICHTEXT | TXTBIT_MULTILINE | TXTBIT_READONLY |
TXTBIT_USEPASSWORD | TXTBIT_HIDESELECTION | TXTBIT_SAVESELECTION |
TXTBIT_AUTOWORDSEL | TXTBIT_VERTICAL | TXTBIT_WORDWRAP | TXTBIT_DISABLEDRAG,
&ed->props );
ITextHost_TxGetScrollBars( texthost, &ed->scrollbars );
ITextHost_TxGetScrollBars( ed->texthost, &ed->scrollbars );
ed->pBuffer = ME_MakeText();
ed->nZoomNumerator = ed->nZoomDenominator = 0;
ed->nAvailWidth = 0; /* wrap to client area */
......@@ -3000,7 +3014,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->password_char = 0;
if (ed->props & TXTBIT_USEPASSWORD)
ITextHost_TxGetPasswordChar( texthost, &ed->password_char );
ITextHost_TxGetPasswordChar( ed->texthost, &ed->password_char );
ed->bWordWrap = (ed->props & TXTBIT_WORDWRAP) && (ed->props & TXTBIT_MULTILINE);
......@@ -3025,20 +3039,20 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
{
if (ed->scrollbars & WS_VSCROLL)
{
ITextHost_TxSetScrollRange( texthost, SB_VERT, 0, 1, TRUE );
ITextHost_TxEnableScrollBar( texthost, SB_VERT, ESB_DISABLE_BOTH );
ITextHost_TxSetScrollRange( ed->texthost, SB_VERT, 0, 1, TRUE );
ITextHost_TxEnableScrollBar( ed->texthost, SB_VERT, ESB_DISABLE_BOTH );
}
if (ed->scrollbars & WS_HSCROLL)
{
ITextHost_TxSetScrollRange( texthost, SB_HORZ, 0, 1, TRUE );
ITextHost_TxEnableScrollBar( texthost, SB_HORZ, ESB_DISABLE_BOTH );
ITextHost_TxSetScrollRange( ed->texthost, SB_HORZ, 0, 1, TRUE );
ITextHost_TxEnableScrollBar( ed->texthost, SB_HORZ, ESB_DISABLE_BOTH );
}
}
ed->wheel_remain = 0;
ed->back_style = TXTBACK_OPAQUE;
ITextHost_TxGetBackStyle( texthost, &ed->back_style );
ITextHost_TxGetBackStyle( ed->texthost, &ed->back_style );
list_init( &ed->reobj_list );
OleInitialize(NULL);
......
......@@ -321,8 +321,8 @@ static inline ME_DisplayItem *cell_get_di(ME_Cell *cell)
/* txthost.c */
#ifdef __ASM_USE_THISCALL_WRAPPER
extern const struct ITextHostVtbl text_host_stdcall_vtbl DECLSPEC_HIDDEN;
#define TXTHOST_VTABLE(This) (&text_host_stdcall_vtbl)
extern const struct ITextHost2Vtbl text_host2_stdcall_vtbl DECLSPEC_HIDDEN;
#define TXTHOST_VTABLE(This) (&text_host2_stdcall_vtbl)
#else
#define TXTHOST_VTABLE(This) (This)->lpVtbl
#endif
......@@ -366,6 +366,19 @@ extern const struct ITextHostVtbl text_host_stdcall_vtbl DECLSPEC_HIDDEN;
#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)
/* ITextHost2 */
#define ITextHost2_TxIsDoubleClickPending(This) TXTHOST_VTABLE(This)->TxIsDoubleClickPending(This)
#define ITextHost2_TxGetWindow(This,a) TXTHOST_VTABLE(This)->TxGetWindow(This,a)
#define ITextHost2_TxSetForegroundWindow(This) TXTHOST_VTABLE(This)->TxSetForegroundWindow(This)
#define ITextHost2_TxGetPalette(This) TXTHOST_VTABLE(This)->TxGetPalette(This)
#define ITextHost2_TxGetEastAsianFlags(This,a) TXTHOST_VTABLE(This)->TxGetEastAsianFlags(This,a)
#define ITextHost2_TxSetCursor2(This,a,b) TXTHOST_VTABLE(This)->TxSetCursor2(This,a,b)
#define ITextHost2_TxFreeTextServicesNotification(This) TXTHOST_VTABLE(This)->TxFreeTextServicesNotification(This)
#define ITextHost2_TxGetEditStyle(This,a,b) TXTHOST_VTABLE(This)->TxGetEditStyle(This,a,b)
#define ITextHost2_TxGetWindowStyles(This,a,b) TXTHOST_VTABLE(This)->TxGetWindowStyles(This,a,b)
#define ITextHost2_TxShowDropCaret(This,a,b,c) TXTHOST_VTABLE(This)->TxShowDropCaret(This,a,b,c)
#define ITextHost2_TxDestroyCaret(This) TXTHOST_VTABLE(This)->TxDestroyCaret(This)
#define ITextHost2_TxGetHorzExtent(This,a) TXTHOST_VTABLE(This)->TxGetHorzExtent(This,a)
/* undo.c */
BOOL add_undo_insert_run( ME_TextEditor *, int pos, const WCHAR *str, int len, int flags, ME_Style *style ) DECLSPEC_HIDDEN;
......
......@@ -378,10 +378,11 @@ typedef struct tagME_InStream ME_InStream;
typedef struct tagME_TextEditor
{
HWND hWnd, hwndParent;
ITextHost *texthost;
ITextHost2 *texthost;
IUnknown *reOle;
unsigned int bEmulateVersion10 : 1;
unsigned int in_place_active : 1;
unsigned int have_texthost2 : 1;
ME_TextBuffer *pBuffer;
ME_Cursor *pCursors;
DWORD props;
......
......@@ -1071,7 +1071,7 @@ static void enable_show_scrollbar( ME_TextEditor *editor, INT bar, BOOL enable )
ITextHost_TxShowScrollBar( editor->texthost, bar, enable );
}
static void set_scroll_range_pos( ITextHost *host, INT bar, SCROLLINFO *info, BOOL set_range )
static void set_scroll_range_pos( ITextHost2 *host, INT bar, SCROLLINFO *info, BOOL set_range )
{
LONG max_pos = info->nMax, pos = info->nPos;
......
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