riched20: Use the host to set hide/save-sel, auto-word-sel, and vertical properties.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-03-16 08:22:47 +00:00 committed by Alexandre Julliard
parent d7d81d7182
commit 030fbc4587
4 changed files with 42 additions and 31 deletions

View File

@ -3118,20 +3118,13 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
if (ed->props & TXTBIT_USEPASSWORD)
ITextHost_TxGetPasswordChar(texthost, &ed->cPasswordMask);
if (ed->props & TXTBIT_AUTOWORDSEL)
ed->styleFlags |= ECO_AUTOWORDSELECTION;
if (ed->props & TXTBIT_MULTILINE) {
ed->styleFlags |= ES_MULTILINE;
ed->bWordWrap = (ed->props & TXTBIT_WORDWRAP) != 0;
} else {
ed->bWordWrap = FALSE;
}
if (!(ed->props & TXTBIT_HIDESELECTION))
ed->styleFlags |= ES_NOHIDESEL;
if (ed->props & TXTBIT_SAVESELECTION)
ed->styleFlags |= ES_SAVESEL;
if (ed->props & TXTBIT_VERTICAL)
ed->styleFlags |= ES_VERTICAL;
if (ed->props & TXTBIT_DISABLEDRAG)
ed->styleFlags |= ES_NOOLEDRAGDROP;
@ -3444,7 +3437,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
editor->bDialogMode = TRUE;
if (editor->styleFlags & ES_MULTILINE)
code |= DLGC_WANTMESSAGE;
if (!(editor->styleFlags & ES_SAVESEL))
if (!(editor->props & TXTBIT_SAVESELECTION))
code |= DLGC_HASSETSEL;
return code;
}
@ -3492,8 +3485,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case EM_GETOPTIONS:
{
/* these flags are equivalent to the ES_* counterparts */
DWORD mask = ECO_VERTICAL |
ECO_NOHIDESEL | ECO_WANTRETURN | ECO_SELECTIONBAR;
DWORD mask = ECO_WANTRETURN | ECO_SELECTIONBAR;
DWORD settings = editor->styleFlags & mask;
return settings;
@ -3544,9 +3536,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
/* these flags are equivalent to ES_* counterparts, except for
* ECO_AUTOWORDSELECTION that doesn't have an ES_* counterpart,
* but is still stored in editor->styleFlags. */
const DWORD mask = ECO_VERTICAL |
ECO_NOHIDESEL | ECO_WANTRETURN |
ECO_SELECTIONBAR | ECO_AUTOWORDSELECTION;
const DWORD mask = ECO_WANTRETURN | ECO_SELECTIONBAR;
DWORD settings = mask & editor->styleFlags;
DWORD oldSettings = settings;
DWORD changedSettings;
@ -3584,15 +3574,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
ME_RewrapRepaint(editor);
}
if ((changedSettings & settings & ES_NOHIDESEL) && !editor->bHaveFocus)
ME_InvalidateSelection( editor );
if (changedSettings & settings & ECO_VERTICAL)
FIXME("ECO_VERTICAL not implemented yet!\n");
if (changedSettings & settings & ECO_AUTOHSCROLL)
FIXME("ECO_WANTRETURN not implemented yet!\n");
if (changedSettings & settings & ECO_AUTOWORDSELECTION)
FIXME("ECO_AUTOWORDSELECTION not implemented yet!\n");
}
return settings;
@ -4216,7 +4198,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
create_caret(editor);
update_caret(editor);
ME_SendOldNotify(editor, EN_SETFOCUS);
if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
if (!editor->bHideSelection && (editor->props & TXTBIT_HIDESELECTION))
ME_InvalidateSelection( editor );
return 0;
case WM_KILLFOCUS:
@ -4226,7 +4208,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
hide_caret(editor);
DestroyCaret();
ME_SendOldNotify(editor, EN_KILLFOCUS);
if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
if (!editor->bHideSelection && (editor->props & TXTBIT_HIDESELECTION))
ME_InvalidateSelection( editor );
return 0;
case WM_COMMAND:

View File

@ -270,8 +270,8 @@ static void draw_space( ME_Context *c, ME_Run *run, int x, int y,
SetRect( &rect, x, ymin, x + run->nWidth, ymin + cy );
if (c->editor->bHideSelection || (!c->editor->bHaveFocus &&
!(c->editor->styleFlags & ES_NOHIDESEL))) selected = FALSE;
if (c->editor->bHideSelection || (!c->editor->bHaveFocus && (c->editor->props & TXTBIT_HIDESELECTION)))
selected = FALSE;
if (c->editor->bEmulateVersion10)
{
old_style_selected = selected;
@ -366,7 +366,7 @@ static void draw_text_with_style( ME_Context *c, ME_Run *run, int x, int y,
int yOffset = 0;
BOOL selected = (nSelFrom < run->len && nSelTo >= 0
&& nSelFrom < nSelTo && !c->editor->bHideSelection &&
(c->editor->bHaveFocus || (c->editor->styleFlags & ES_NOHIDESEL)));
(c->editor->bHaveFocus || !(c->editor->props & TXTBIT_HIDESELECTION)));
BOOL old_style_selected = FALSE;
RECT sel_rect;
HRGN clip = NULL, sel_rgn = NULL;

View File

@ -60,7 +60,7 @@ static void host_init_props( struct host *host )
if (style & WS_VSCROLL) host->scrollbars |= ES_AUTOVSCROLL;
if ((style & WS_HSCROLL) && !host->emulate_10) host->scrollbars |= ES_AUTOHSCROLL;
host->props = TXTBIT_RICHTEXT | TXTBIT_AUTOWORDSEL | TXTBIT_ALLOWBEEP;
host->props = TXTBIT_RICHTEXT | TXTBIT_ALLOWBEEP;
if (style & ES_MULTILINE) host->props |= TXTBIT_MULTILINE;
if (style & ES_READONLY) host->props |= TXTBIT_READONLY;
if (style & ES_PASSWORD) host->props |= TXTBIT_USEPASSWORD;
@ -765,9 +765,11 @@ static HRESULT get_text_rangeA( struct host *host, TEXTRANGEA *rangeA, LRESULT *
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_AUTOVSCROLL | ECO_AUTOHSCROLL | ECO_READONLY;
DWORD mask = ECO_AUTOWORDSELECTION | ECO_AUTOVSCROLL | ECO_AUTOHSCROLL | ECO_NOHIDESEL | ECO_READONLY |
ECO_WANTRETURN | ECO_SAVESEL | ECO_SELECTIONBAR | ECO_VERTICAL;
const DWORD host_mask = ECO_AUTOWORDSELECTION | ECO_AUTOVSCROLL | ECO_AUTOHSCROLL | ECO_NOHIDESEL | ECO_READONLY |
ECO_SAVESEL | ECO_VERTICAL;
HRESULT hr = S_OK;
new_options = old_options = SendMessageW( host->window, EM_GETOPTIONS, 0, 0 );
@ -790,6 +792,11 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
change = (new_options ^ old_options);
if (change & ECO_AUTOWORDSELECTION)
{
host->props ^= TXTBIT_AUTOWORDSEL;
props_mask |= TXTBIT_AUTOWORDSEL;
}
if (change & ECO_AUTOVSCROLL)
{
host->scrollbars ^= WS_VSCROLL;
@ -800,11 +807,26 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
host->scrollbars ^= WS_HSCROLL;
props_mask |= TXTBIT_SCROLLBARCHANGE;
}
if (change & ECO_NOHIDESEL)
{
host->props ^= TXTBIT_HIDESELECTION;
props_mask |= TXTBIT_HIDESELECTION;
}
if (change & ECO_READONLY)
{
host->props ^= TXTBIT_READONLY;
props_mask |= TXTBIT_READONLY;
}
if (change & ECO_SAVESEL)
{
host->props ^= TXTBIT_SAVESELECTION;
props_mask |= TXTBIT_SAVESELECTION;
}
if (change & ECO_VERTICAL)
{
host->props ^= TXTBIT_VERTICAL;
props_mask |= TXTBIT_VERTICAL;
}
if (props_mask)
ITextServices_OnTxPropertyBitsChange( host->text_srv, props_mask, host->props & props_mask );
@ -813,6 +835,7 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
hr = ITextServices_TxSendMessage( host->text_srv, EM_SETOPTIONS, op, value, res );
*res = (*res & ~host_mask) | (new_options & host_mask);
mask &= ~ECO_AUTOWORDSELECTION; /* doesn't correspond to a window style */
style = GetWindowLongW( host->window, GWL_STYLE );
style = (style & ~mask) | (*res & mask);
SetWindowLongW( host->window, GWL_STYLE, style );
@ -926,6 +949,10 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
case EM_GETOPTIONS:
hr = ITextServices_TxSendMessage( host->text_srv, EM_GETOPTIONS, 0, 0, &res );
if (host->props & TXTBIT_READONLY) res |= ECO_READONLY;
if (!(host->props & TXTBIT_HIDESELECTION)) res |= ECO_NOHIDESEL;
if (host->props & TXTBIT_SAVESELECTION) res |= ECO_SAVESEL;
if (host->props & TXTBIT_AUTOWORDSEL) res |= ECO_AUTOWORDSELECTION;
if (host->props & TXTBIT_VERTICAL) res |= ECO_VERTICAL;
if (host->scrollbars & ES_AUTOHSCROLL) res |= ECO_AUTOHSCROLL;
if (host->scrollbars & ES_AUTOVSCROLL) res |= ECO_AUTOVSCROLL;
break;

View File

@ -347,6 +347,8 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServic
}
}
if ((mask & TXTBIT_HIDESELECTION) && !services->editor->bHaveFocus) ME_InvalidateSelection( services->editor );
return S_OK;
}