Commit 887ffec9 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Handle WM_SETCURSOR in the host.

parent cd5b064a
...@@ -233,6 +233,7 @@ ...@@ -233,6 +233,7 @@
#include "shlwapi.h" #include "shlwapi.h"
#include "rtf.h" #include "rtf.h"
#include "imm.h" #include "imm.h"
#include "res.h"
#define STACK_SIZE_DEFAULT 100 #define STACK_SIZE_DEFAULT 100
#define STACK_SIZE_MAX 1000 #define STACK_SIZE_MAX 1000
...@@ -243,7 +244,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); ...@@ -243,7 +244,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit);
static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars); static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars);
HCURSOR cursor_reverse = NULL; HINSTANCE dll_instance = NULL;
BOOL me_debug = FALSE; BOOL me_debug = FALSE;
HANDLE me_heap = NULL; HANDLE me_heap = NULL;
...@@ -2817,96 +2818,52 @@ static BOOL is_link( ME_Run *run ) ...@@ -2817,96 +2818,52 @@ static BOOL is_link( ME_Run *run )
return (run->style->fmt.dwMask & CFM_LINK) && (run->style->fmt.dwEffects & CFE_LINK); return (run->style->fmt.dwMask & CFM_LINK) && (run->style->fmt.dwEffects & CFE_LINK);
} }
static BOOL ME_SetCursor(ME_TextEditor *editor) void editor_set_cursor( ME_TextEditor *editor, int x, int y )
{ {
ME_Cursor cursor; ME_Cursor pos;
POINT pt; BOOL is_exact;
BOOL isExact; static HCURSOR cursor_arrow, cursor_hand, cursor_ibeam, cursor_reverse;
SCROLLBARINFO sbi; HCURSOR cursor;
DWORD messagePos = GetMessagePos();
pt.x = (short)LOWORD(messagePos);
pt.y = (short)HIWORD(messagePos);
if (editor->hWnd) if (!cursor_arrow)
{
sbi.cbSize = sizeof(sbi);
GetScrollBarInfo(editor->hWnd, OBJID_HSCROLL, &sbi);
if (!(sbi.rgstate[0] & (STATE_SYSTEM_INVISIBLE|STATE_SYSTEM_OFFSCREEN)) &&
PtInRect(&sbi.rcScrollBar, pt))
{ {
ITextHost_TxSetCursor(editor->texthost, cursor_arrow = LoadCursorW( NULL, MAKEINTRESOURCEW( IDC_ARROW ) );
LoadCursorW(NULL, (WCHAR*)IDC_ARROW), FALSE); cursor_hand = LoadCursorW( NULL, MAKEINTRESOURCEW( IDC_HAND ) );
return TRUE; cursor_ibeam = LoadCursorW( NULL, MAKEINTRESOURCEW( IDC_IBEAM ) );
cursor_reverse = LoadCursorW( dll_instance, MAKEINTRESOURCEW( OCR_REVERSE ) );
} }
sbi.cbSize = sizeof(sbi);
GetScrollBarInfo(editor->hWnd, OBJID_VSCROLL, &sbi); cursor = cursor_ibeam;
if (!(sbi.rgstate[0] & (STATE_SYSTEM_INVISIBLE|STATE_SYSTEM_OFFSCREEN)) &&
PtInRect(&sbi.rcScrollBar, pt)) if ((editor->nSelectionType == stLine && editor->bMouseCaptured) ||
(!editor->bEmulateVersion10 && y < editor->rcFormat.top && x < editor->rcFormat.left))
cursor = cursor_reverse;
else if (y < editor->rcFormat.top || y > editor->rcFormat.bottom)
{ {
ITextHost_TxSetCursor(editor->texthost, if (editor->bEmulateVersion10) cursor = cursor_arrow;
LoadCursorW(NULL, (WCHAR*)IDC_ARROW), FALSE); else cursor = cursor_ibeam;
return TRUE;
} }
} else if (x < editor->rcFormat.left) cursor = cursor_reverse;
ITextHost_TxScreenToClient(editor->texthost, &pt); else
{
ME_CharFromPos( editor, x, y, &pos, &is_exact );
if (is_exact)
{
ME_Run *run = pos.run;
if (editor->nSelectionType == stLine && editor->bMouseCaptured) if (is_link( run )) cursor = cursor_hand;
{
ITextHost_TxSetCursor( editor->texthost, cursor_reverse, FALSE );
return TRUE;
}
if (!editor->bEmulateVersion10 /* v4.1 */ &&
pt.y < editor->rcFormat.top &&
pt.x < editor->rcFormat.left)
{
ITextHost_TxSetCursor( editor->texthost, cursor_reverse, FALSE );
return TRUE;
}
if (pt.y < editor->rcFormat.top || pt.y > editor->rcFormat.bottom)
{
if (editor->bEmulateVersion10) /* v1.0 - 3.0 */
ITextHost_TxSetCursor(editor->texthost,
LoadCursorW(NULL, (WCHAR*)IDC_ARROW), FALSE);
else /* v4.1 */
ITextHost_TxSetCursor(editor->texthost,
LoadCursorW(NULL, (WCHAR*)IDC_IBEAM), TRUE);
return TRUE;
}
if (pt.x < editor->rcFormat.left)
{
ITextHost_TxSetCursor( editor->texthost, cursor_reverse, FALSE );
return TRUE;
}
ME_CharFromPos(editor, pt.x, pt.y, &cursor, &isExact);
if (isExact)
{
ME_Run *run = cursor.run;
if (is_link( run )) else if (ME_IsSelection( editor ))
{ {
ITextHost_TxSetCursor(editor->texthost, int start, end, offset = ME_GetCursorOfs( &pos );
LoadCursorW(NULL, (WCHAR*)IDC_HAND),
FALSE);
return TRUE;
}
if (ME_IsSelection(editor)) ME_GetSelectionOfs( editor, &start, &end );
{ if (start <= offset && end >= offset) cursor = cursor_arrow;
int selStart, selEnd; }
int offset = ME_GetCursorOfs(&cursor); }
}
ME_GetSelectionOfs(editor, &selStart, &selEnd);
if (selStart <= offset && selEnd >= offset) { ITextHost_TxSetCursor( editor->texthost, cursor, cursor == cursor_ibeam );
ITextHost_TxSetCursor(editor->texthost,
LoadCursorW(NULL, (WCHAR*)IDC_ARROW),
FALSE);
return TRUE;
}
}
}
ITextHost_TxSetCursor(editor->texthost,
LoadCursorW(NULL, (WCHAR*)IDC_IBEAM), TRUE);
return TRUE;
} }
static LONG ME_GetSelectionType(ME_TextEditor *editor) static LONG ME_GetSelectionType(ME_TextEditor *editor)
...@@ -3130,7 +3087,7 @@ static inline int calc_wheel_change( int *remain, int amount_per_click ) ...@@ -3130,7 +3087,7 @@ static inline int calc_wheel_change( int *remain, int amount_per_click )
return change; return change;
} }
static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam) void link_notify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
int x,y; int x,y;
BOOL isExact; BOOL isExact;
...@@ -3936,14 +3893,6 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, ...@@ -3936,14 +3893,6 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam,
} }
case WM_CREATE: case WM_CREATE:
return ME_WmCreate( editor ); return ME_WmCreate( editor );
case WM_SETCURSOR:
{
POINT cursor_pos;
if (wParam == (WPARAM)editor->hWnd && GetCursorPos(&cursor_pos) &&
ScreenToClient(editor->hWnd, &cursor_pos))
ME_LinkNotify(editor, msg, 0, MAKELPARAM(cursor_pos.x, cursor_pos.y));
return ME_SetCursor(editor);
}
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
{ {
...@@ -3953,14 +3902,14 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, ...@@ -3953,14 +3902,14 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam,
ME_CalculateClickCount(editor, msg, wParam, lParam)); ME_CalculateClickCount(editor, msg, wParam, lParam));
ITextHost_TxSetCapture(editor->texthost, TRUE); ITextHost_TxSetCapture(editor->texthost, TRUE);
editor->bMouseCaptured = TRUE; editor->bMouseCaptured = TRUE;
ME_LinkNotify(editor, msg, wParam, lParam); link_notify( editor, msg, wParam, lParam );
break; break;
} }
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (editor->bMouseCaptured) if (editor->bMouseCaptured)
ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)); ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
else else
ME_LinkNotify(editor, msg, wParam, lParam); link_notify( editor, msg, wParam, lParam );
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
if (editor->bMouseCaptured) { if (editor->bMouseCaptured) {
...@@ -3971,14 +3920,14 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, ...@@ -3971,14 +3920,14 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam,
editor->nSelectionType = stPosition; editor->nSelectionType = stPosition;
else else
{ {
ME_LinkNotify(editor, msg, wParam, lParam); link_notify( editor, msg, wParam, lParam );
} }
break; break;
case WM_RBUTTONUP: case WM_RBUTTONUP:
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
ME_CommitUndo(editor); /* End coalesced undos for typed characters */ ME_CommitUndo(editor); /* End coalesced undos for typed characters */
ME_LinkNotify(editor, msg, wParam, lParam); link_notify( editor, msg, wParam, lParam );
goto do_default; goto do_default;
case WM_CONTEXTMENU: case WM_CONTEXTMENU:
if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam))) if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)))
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
struct _RTF_Info; struct _RTF_Info;
extern HINSTANCE dll_instance DECLSPEC_HIDDEN;
extern HANDLE me_heap DECLSPEC_HIDDEN; extern HANDLE me_heap DECLSPEC_HIDDEN;
extern HCURSOR cursor_reverse DECLSPEC_HIDDEN;
#define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \ #define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \
&& (run)->style->fmt.dwEffects & CFE_HIDDEN) && (run)->style->fmt.dwEffects & CFE_HIDDEN)
...@@ -288,6 +288,8 @@ HRESULT editor_copy_or_cut( ME_TextEditor *editor, BOOL cut, ME_Cursor *start, i ...@@ -288,6 +288,8 @@ HRESULT editor_copy_or_cut( ME_TextEditor *editor, BOOL cut, ME_Cursor *start, i
IDataObject **data_out ) DECLSPEC_HIDDEN; IDataObject **data_out ) DECLSPEC_HIDDEN;
ME_Paragraph *editor_end_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN; ME_Paragraph *editor_end_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
ME_Paragraph *editor_first_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN; ME_Paragraph *editor_first_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
void editor_set_cursor( ME_TextEditor *editor, int x, int y ) DECLSPEC_HIDDEN;
void link_notify( ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
/* table.c */ /* table.c */
ME_Cell *cell_create( void ) DECLSPEC_HIDDEN; ME_Cell *cell_create( void ) DECLSPEC_HIDDEN;
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "editstr.h" #include "editstr.h"
#include "rtf.h" #include "rtf.h"
#include "res.h"
WINE_DEFAULT_DEBUG_CHANNEL(richedit); WINE_DEFAULT_DEBUG_CHANNEL(richedit);
...@@ -1207,6 +1206,20 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -1207,6 +1206,20 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
InvalidateRect( hwnd, NULL, TRUE ); InvalidateRect( hwnd, NULL, TRUE );
break; break;
case WM_SETCURSOR:
{
POINT pos;
RECT rect;
if (hwnd != (HWND)wparam) break;
GetCursorPos( &pos );
ScreenToClient( hwnd, &pos );
ITextHost_TxGetClientRect( &host->ITextHost_iface, &rect );
if (PtInRect( &rect, pos ))
ITextServices_OnTxSetCursor( host->text_srv, DVASPECT_CONTENT, 0, NULL, NULL, NULL, NULL, NULL, pos.x, pos.y );
else ITextHost_TxSetCursor( &host->ITextHost_iface, LoadCursorW( NULL, MAKEINTRESOURCEW( IDC_ARROW ) ), FALSE );
break;
}
case EM_SETEVENTMASK: case EM_SETEVENTMASK:
host->event_mask = lparam; host->event_mask = lparam;
hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, lparam, &res ); hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, lparam, &res );
...@@ -1468,10 +1481,10 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) ...@@ -1468,10 +1481,10 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
switch (reason) switch (reason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
dll_instance = instance;
DisableThreadLibraryCalls( instance ); DisableThreadLibraryCalls( instance );
me_heap = HeapCreate( 0, 0x10000, 0 ); me_heap = HeapCreate( 0, 0x10000, 0 );
if (!register_classes( instance )) return FALSE; if (!register_classes( instance )) return FALSE;
cursor_reverse = LoadCursorW( instance, MAKEINTRESOURCEW( OCR_REVERSE ) );
LookupInit(); LookupInit();
break; break;
......
...@@ -184,14 +184,21 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface, ...@@ -184,14 +184,21 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface,
} }
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40) DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxSetCursor(ITextServices *iface, DWORD dwDrawAspect, LONG lindex, DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxSetCursor( ITextServices *iface, DWORD aspect, LONG index,
void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw, void *aspect_info, DVTARGETDEVICE *td, HDC draw,
HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y) HDC target, const RECT *client, INT x, INT y )
{ {
struct text_services *services = impl_from_ITextServices( iface ); struct text_services *services = impl_from_ITextServices( iface );
FIXME( "%p: STUB\n", services ); TRACE( "%p: %d, %d, %p, %p, draw %p target %p client %s pos (%d, %d)\n", services, aspect, index, aspect_info, td, draw,
return E_NOTIMPL; target, wine_dbgstr_rect( client ), x, y );
if (aspect != DVASPECT_CONTENT || index || aspect_info || td || draw || target || client)
FIXME( "Ignoring most params\n" );
link_notify( services->editor, WM_SETCURSOR, 0, MAKELPARAM( x, y ) );
editor_set_cursor( services->editor, x, y );
return S_OK;
} }
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44) DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44)
......
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