Commit 8544242f authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Handle the read-only property setting in the host.

parent 23ffd0a7
...@@ -2279,10 +2279,9 @@ static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BO ...@@ -2279,10 +2279,9 @@ static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BO
IDataObject *data; IDataObject *data;
/* Protect read-only edit control from modification */ /* Protect read-only edit control from modification */
if (editor->styleFlags & ES_READONLY) if (editor->props & TXTBIT_READONLY)
{ {
if (!check_only) if (!check_only) MessageBeep(MB_ICONERROR);
MessageBeep(MB_ICONERROR);
return FALSE; return FALSE;
} }
...@@ -2354,7 +2353,7 @@ HRESULT editor_copy_or_cut( ME_TextEditor *editor, BOOL cut, ME_Cursor *start, i ...@@ -2354,7 +2353,7 @@ HRESULT editor_copy_or_cut( ME_TextEditor *editor, BOOL cut, ME_Cursor *start, i
{ {
HRESULT hr; HRESULT hr;
if (cut && (editor->styleFlags & ES_READONLY)) if (cut && (editor->props & TXTBIT_READONLY))
{ {
return E_ACCESSDENIED; return E_ACCESSDENIED;
} }
...@@ -2469,7 +2468,7 @@ static BOOL handle_enter(ME_TextEditor *editor) ...@@ -2469,7 +2468,7 @@ static BOOL handle_enter(ME_TextEditor *editor)
int from, to; int from, to;
ME_Style *style, *eop_style; ME_Style *style, *eop_style;
if (editor->styleFlags & ES_READONLY) if (editor->props & TXTBIT_READONLY)
{ {
MessageBeep(MB_ICONERROR); MessageBeep(MB_ICONERROR);
return TRUE; return TRUE;
...@@ -2631,7 +2630,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey) ...@@ -2631,7 +2630,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
case VK_DELETE: case VK_DELETE:
editor->nUDArrowX = -1; editor->nUDArrowX = -1;
/* FIXME backspace and delete aren't the same, they act different wrt paragraph style of the merged paragraph */ /* FIXME backspace and delete aren't the same, they act different wrt paragraph style of the merged paragraph */
if (editor->styleFlags & ES_READONLY) if (editor->props & TXTBIT_READONLY)
return FALSE; return FALSE;
if (ME_IsSelection(editor)) if (ME_IsSelection(editor))
{ {
...@@ -2738,7 +2737,7 @@ static LRESULT handle_wm_char( ME_TextEditor *editor, WCHAR wstr, LPARAM flags ) ...@@ -2738,7 +2737,7 @@ static LRESULT handle_wm_char( ME_TextEditor *editor, WCHAR wstr, LPARAM flags )
if (editor->bMouseCaptured) if (editor->bMouseCaptured)
return 0; return 0;
if (editor->styleFlags & ES_READONLY) if (editor->props & TXTBIT_READONLY)
{ {
MessageBeep(MB_ICONERROR); MessageBeep(MB_ICONERROR);
return 0; /* FIXME really 0 ? */ return 0; /* FIXME really 0 ? */
...@@ -3035,7 +3034,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ...@@ -3035,7 +3034,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
{ {
ME_TextEditor *ed = heap_alloc(sizeof(*ed)); ME_TextEditor *ed = heap_alloc(sizeof(*ed));
int i; int i;
DWORD props;
LONG selbarwidth; LONG selbarwidth;
ed->hWnd = NULL; ed->hWnd = NULL;
...@@ -3047,13 +3045,10 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ...@@ -3047,13 +3045,10 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->styleFlags = 0; ed->styleFlags = 0;
ed->exStyleFlags = 0; ed->exStyleFlags = 0;
ed->total_rows = 0; ed->total_rows = 0;
ITextHost_TxGetPropertyBits(texthost, ITextHost_TxGetPropertyBits( texthost, TXTBIT_RICHTEXT | TXTBIT_MULTILINE | TXTBIT_READONLY |
(TXTBIT_RICHTEXT|TXTBIT_MULTILINE| TXTBIT_USEPASSWORD | TXTBIT_HIDESELECTION | TXTBIT_SAVESELECTION |
TXTBIT_READONLY|TXTBIT_USEPASSWORD| TXTBIT_AUTOWORDSEL | TXTBIT_VERTICAL | TXTBIT_WORDWRAP | TXTBIT_DISABLEDRAG,
TXTBIT_HIDESELECTION|TXTBIT_SAVESELECTION| &ed->props );
TXTBIT_AUTOWORDSEL|TXTBIT_VERTICAL|
TXTBIT_WORDWRAP|TXTBIT_DISABLEDRAG),
&props);
ITextHost_TxGetScrollBars(texthost, &ed->styleFlags); ITextHost_TxGetScrollBars(texthost, &ed->styleFlags);
ed->styleFlags &= (WS_VSCROLL|WS_HSCROLL|ES_AUTOVSCROLL| ed->styleFlags &= (WS_VSCROLL|WS_HSCROLL|ES_AUTOVSCROLL|
ES_AUTOHSCROLL|ES_DISABLENOSCROLL); ES_AUTOHSCROLL|ES_DISABLENOSCROLL);
...@@ -3094,7 +3089,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ...@@ -3094,7 +3089,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->pfnWordBreak = NULL; ed->pfnWordBreak = NULL;
ed->lpOleCallback = NULL; ed->lpOleCallback = NULL;
ed->mode = TM_MULTILEVELUNDO | TM_MULTICODEPAGE; ed->mode = TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
ed->mode |= (props & TXTBIT_RICHTEXT) ? TM_RICHTEXT : TM_PLAINTEXT; ed->mode |= (ed->props & TXTBIT_RICHTEXT) ? TM_RICHTEXT : TM_PLAINTEXT;
ed->AutoURLDetect_bEnable = FALSE; ed->AutoURLDetect_bEnable = FALSE;
ed->bHaveFocus = FALSE; ed->bHaveFocus = FALSE;
ed->bDialogMode = FALSE; ed->bDialogMode = FALSE;
...@@ -3122,26 +3117,24 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ...@@ -3122,26 +3117,24 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->nSelectionType = stPosition; ed->nSelectionType = stPosition;
ed->cPasswordMask = 0; ed->cPasswordMask = 0;
if (props & TXTBIT_USEPASSWORD) if (ed->props & TXTBIT_USEPASSWORD)
ITextHost_TxGetPasswordChar(texthost, &ed->cPasswordMask); ITextHost_TxGetPasswordChar(texthost, &ed->cPasswordMask);
if (props & TXTBIT_AUTOWORDSEL) if (ed->props & TXTBIT_AUTOWORDSEL)
ed->styleFlags |= ECO_AUTOWORDSELECTION; ed->styleFlags |= ECO_AUTOWORDSELECTION;
if (props & TXTBIT_MULTILINE) { if (ed->props & TXTBIT_MULTILINE) {
ed->styleFlags |= ES_MULTILINE; ed->styleFlags |= ES_MULTILINE;
ed->bWordWrap = (props & TXTBIT_WORDWRAP) != 0; ed->bWordWrap = (ed->props & TXTBIT_WORDWRAP) != 0;
} else { } else {
ed->bWordWrap = FALSE; ed->bWordWrap = FALSE;
} }
if (props & TXTBIT_READONLY) if (!(ed->props & TXTBIT_HIDESELECTION))
ed->styleFlags |= ES_READONLY;
if (!(props & TXTBIT_HIDESELECTION))
ed->styleFlags |= ES_NOHIDESEL; ed->styleFlags |= ES_NOHIDESEL;
if (props & TXTBIT_SAVESELECTION) if (ed->props & TXTBIT_SAVESELECTION)
ed->styleFlags |= ES_SAVESEL; ed->styleFlags |= ES_SAVESEL;
if (props & TXTBIT_VERTICAL) if (ed->props & TXTBIT_VERTICAL)
ed->styleFlags |= ES_VERTICAL; ed->styleFlags |= ES_VERTICAL;
if (props & TXTBIT_DISABLEDRAG) if (ed->props & TXTBIT_DISABLEDRAG)
ed->styleFlags |= ES_NOOLEDRAGDROP; ed->styleFlags |= ES_NOOLEDRAGDROP;
ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0; ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0;
...@@ -3502,7 +3495,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ...@@ -3502,7 +3495,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
{ {
/* these flags are equivalent to the ES_* counterparts */ /* these flags are equivalent to the ES_* counterparts */
DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL | DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL |
ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN | ECO_SELECTIONBAR; ECO_NOHIDESEL | ECO_WANTRETURN | ECO_SELECTIONBAR;
DWORD settings = editor->styleFlags & mask; DWORD settings = editor->styleFlags & mask;
return settings; return settings;
...@@ -3554,7 +3547,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ...@@ -3554,7 +3547,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
* ECO_AUTOWORDSELECTION that doesn't have an ES_* counterpart, * ECO_AUTOWORDSELECTION that doesn't have an ES_* counterpart,
* but is still stored in editor->styleFlags. */ * but is still stored in editor->styleFlags. */
const DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL | const DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL |
ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN | ECO_NOHIDESEL | ECO_WANTRETURN |
ECO_SELECTIONBAR | ECO_AUTOWORDSELECTION; ECO_SELECTIONBAR | ECO_AUTOWORDSELECTION;
DWORD settings = mask & editor->styleFlags; DWORD settings = mask & editor->styleFlags;
DWORD oldSettings = settings; DWORD oldSettings = settings;
......
...@@ -385,6 +385,7 @@ typedef struct tagME_TextEditor ...@@ -385,6 +385,7 @@ typedef struct tagME_TextEditor
ME_Cursor *pCursors; ME_Cursor *pCursors;
DWORD styleFlags; DWORD styleFlags;
DWORD exStyleFlags; DWORD exStyleFlags;
DWORD props;
int nCursors; int nCursors;
SIZE sizeWindow; SIZE sizeWindow;
int nTotalLength, nLastTotalLength; int nTotalLength, nLastTotalLength;
......
...@@ -775,12 +775,59 @@ static HRESULT get_text_rangeA( struct host *host, TEXTRANGEA *rangeA, LRESULT * ...@@ -775,12 +775,59 @@ static HRESULT get_text_rangeA( struct host *host, TEXTRANGEA *rangeA, LRESULT *
return hr; return hr;
} }
static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *res )
{
DWORD style, old_options, new_options, change, props_mask = 0;
const DWORD mask = ECO_AUTOVSCROLL | ECO_AUTOHSCROLL | ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN |
ECO_SELECTIONBAR | ECO_VERTICAL;
const DWORD host_mask = ECO_READONLY;
HRESULT hr = S_OK;
new_options = old_options = SendMessageW( host->window, EM_GETOPTIONS, 0, 0 );
switch (op)
{
case ECOOP_SET:
new_options = value;
break;
case ECOOP_OR:
new_options |= value;
break;
case ECOOP_AND:
new_options &= value;
break;
case ECOOP_XOR:
new_options ^= value;
}
new_options &= mask;
change = (new_options ^ old_options);
if (change & ECO_READONLY)
{
host->props ^= TXTBIT_READONLY;
props_mask |= TXTBIT_READONLY;
}
if (props_mask)
ITextServices_OnTxPropertyBitsChange( host->text_srv, props_mask, host->props & props_mask );
/* Handle the rest in the editor for now */
hr = ITextServices_TxSendMessage( host->text_srv, EM_SETOPTIONS, op, value, res );
*res = (*res & ~host_mask) | (new_options & host_mask);
style = GetWindowLongW( host->window, GWL_STYLE );
style = (style & ~mask) | (*res & mask);
SetWindowLongW( host->window, GWL_STYLE, style );
return hr;
}
static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
LPARAM lparam, BOOL unicode ) LPARAM lparam, BOOL unicode )
{ {
struct host *host; struct host *host;
ME_TextEditor *editor; ME_TextEditor *editor;
HRESULT hr; HRESULT hr = S_OK;
LRESULT res = 0; LRESULT res = 0;
TRACE( "enter hwnd %p msg %04x (%s) %lx %lx, unicode %d\n", TRACE( "enter hwnd %p msg %04x (%s) %lx %lx, unicode %d\n",
...@@ -879,6 +926,11 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -879,6 +926,11 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
} }
break; break;
} }
case EM_GETOPTIONS:
hr = ITextServices_TxSendMessage( host->text_srv, EM_GETOPTIONS, 0, 0, &res );
if (host->props & TXTBIT_READONLY) res |= ECO_READONLY;
break;
case WM_GETTEXT: case WM_GETTEXT:
{ {
GETTEXTEX params; GETTEXTEX params;
...@@ -965,18 +1017,9 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -965,18 +1017,9 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
break; break;
} }
case EM_SETOPTIONS: case EM_SETOPTIONS:
{ hr = set_options( host, wparam, lparam, &res );
DWORD style; break;
const DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL |
ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN |
ECO_SELECTIONBAR;
res = ME_HandleMessage( editor, msg, wparam, lparam, unicode, &hr );
style = GetWindowLongW( hwnd, GWL_STYLE );
style = (style & ~mask) | (res & mask);
SetWindowLongW( hwnd, GWL_STYLE, style );
return res;
}
case EM_SETREADONLY: case EM_SETREADONLY:
{ {
DWORD op = wparam ? ECOOP_OR : ECOOP_AND; DWORD op = wparam ? ECOOP_OR : ECOOP_AND;
......
...@@ -322,12 +322,15 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *ifac ...@@ -322,12 +322,15 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *ifac
} }
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12) DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange(ITextServices *iface, DWORD dwMask, DWORD dwBits) DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServices *iface, DWORD mask, DWORD bits )
{ {
struct text_services *services = impl_from_ITextServices( iface ); struct text_services *services = impl_from_ITextServices( iface );
FIXME( "%p: STUB\n", services ); TRACE( "%p, mask %08x, bits %08x\n", services, mask, bits );
return E_NOTIMPL;
services->editor->props = (services->editor->props & ~mask) | (bits & mask);
return S_OK;
} }
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12) DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12)
......
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