mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 04:54:46 +00:00
riched20: Handle ES_SELECTIONBAR in the host.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6162703fbb
commit
518c548b7a
|
@ -2979,6 +2979,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
|
|||
ME_TextEditor *ed = heap_alloc(sizeof(*ed));
|
||||
int i;
|
||||
LONG selbarwidth;
|
||||
HRESULT hr;
|
||||
|
||||
ed->hWnd = NULL;
|
||||
ed->hwndParent = NULL;
|
||||
|
@ -2986,7 +2987,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
|
|||
ed->texthost = texthost;
|
||||
ed->reOle = NULL;
|
||||
ed->bEmulateVersion10 = bEmulateVersion10;
|
||||
ed->styleFlags = 0;
|
||||
ed->exStyleFlags = 0;
|
||||
ed->total_rows = 0;
|
||||
ITextHost_TxGetPropertyBits( texthost, TXTBIT_RICHTEXT | TXTBIT_MULTILINE | TXTBIT_READONLY |
|
||||
|
@ -3047,14 +3047,10 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
|
|||
ME_CheckCharOffsets(ed);
|
||||
SetRectEmpty(&ed->rcFormat);
|
||||
ed->bDefaultFormatRect = TRUE;
|
||||
ITextHost_TxGetSelectionBarWidth(ed->texthost, &selbarwidth);
|
||||
if (selbarwidth) {
|
||||
/* FIXME: Convert selbarwidth from HIMETRIC to pixels */
|
||||
ed->selofs = SELECTIONBAR_WIDTH;
|
||||
ed->styleFlags |= ES_SELECTIONBAR;
|
||||
} else {
|
||||
ed->selofs = 0;
|
||||
}
|
||||
hr = ITextHost_TxGetSelectionBarWidth( ed->texthost, &selbarwidth );
|
||||
/* FIXME: Convert selbarwidth from HIMETRIC to pixels */
|
||||
if (hr == S_OK && selbarwidth) ed->selofs = SELECTIONBAR_WIDTH;
|
||||
else ed->selofs = 0;
|
||||
ed->nSelectionType = stPosition;
|
||||
|
||||
ed->cPasswordMask = 0;
|
||||
|
@ -3405,14 +3401,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
return ME_Undo(editor);
|
||||
case EM_REDO:
|
||||
return ME_Redo(editor);
|
||||
case EM_GETOPTIONS:
|
||||
{
|
||||
/* these flags are equivalent to the ES_* counterparts */
|
||||
DWORD mask = ECO_SELECTIONBAR;
|
||||
DWORD settings = editor->styleFlags & mask;
|
||||
|
||||
return settings;
|
||||
}
|
||||
case EM_SETFONTSIZE:
|
||||
{
|
||||
CHARFORMAT2W cf;
|
||||
|
@ -3454,54 +3442,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
case EM_SETOPTIONS:
|
||||
{
|
||||
/* 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_SELECTIONBAR;
|
||||
DWORD settings = mask & editor->styleFlags;
|
||||
DWORD oldSettings = settings;
|
||||
DWORD changedSettings;
|
||||
|
||||
switch(wParam)
|
||||
{
|
||||
case ECOOP_SET:
|
||||
settings = lParam;
|
||||
break;
|
||||
case ECOOP_OR:
|
||||
settings |= lParam;
|
||||
break;
|
||||
case ECOOP_AND:
|
||||
settings &= lParam;
|
||||
break;
|
||||
case ECOOP_XOR:
|
||||
settings ^= lParam;
|
||||
}
|
||||
changedSettings = oldSettings ^ settings;
|
||||
|
||||
if (changedSettings) {
|
||||
editor->styleFlags = (editor->styleFlags & ~mask) | (settings & mask);
|
||||
|
||||
if (changedSettings & ECO_SELECTIONBAR)
|
||||
{
|
||||
ITextHost_TxInvalidateRect(editor->texthost, &editor->rcFormat, TRUE);
|
||||
if (settings & ECO_SELECTIONBAR) {
|
||||
assert(!editor->selofs);
|
||||
editor->selofs = SELECTIONBAR_WIDTH;
|
||||
editor->rcFormat.left += editor->selofs;
|
||||
} else {
|
||||
editor->rcFormat.left -= editor->selofs;
|
||||
editor->selofs = 0;
|
||||
}
|
||||
ME_RewrapRepaint(editor);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
case EM_SETSEL:
|
||||
{
|
||||
return set_selection( editor, wParam, lParam );
|
||||
|
|
|
@ -383,7 +383,6 @@ typedef struct tagME_TextEditor
|
|||
BOOL bEmulateVersion10;
|
||||
ME_TextBuffer *pBuffer;
|
||||
ME_Cursor *pCursors;
|
||||
DWORD styleFlags;
|
||||
DWORD exStyleFlags;
|
||||
DWORD props;
|
||||
DWORD scrollbars;
|
||||
|
|
|
@ -42,6 +42,7 @@ struct host
|
|||
unsigned int emulate_10 : 1;
|
||||
unsigned int dialog_mode : 1;
|
||||
unsigned int want_return : 1;
|
||||
unsigned int sel_bar : 1;
|
||||
PARAFORMAT2 para_fmt;
|
||||
DWORD props, scrollbars, event_mask;
|
||||
};
|
||||
|
@ -73,6 +74,7 @@ static void host_init_props( struct host *host )
|
|||
|
||||
if (!(host->scrollbars & ES_AUTOHSCROLL)) host->props |= TXTBIT_WORDWRAP;
|
||||
|
||||
host->sel_bar = !!(style & ES_SELECTIONBAR);
|
||||
host->want_return = !!(style & ES_WANTRETURN);
|
||||
}
|
||||
|
||||
|
@ -471,8 +473,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth( ITextHo
|
|||
{
|
||||
struct host *host = impl_from_ITextHost( iface );
|
||||
|
||||
DWORD style = host->editor ? host->editor->styleFlags : GetWindowLongW( host->window, GWL_STYLE );
|
||||
*width = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
|
||||
*width = host->sel_bar ? 225 : 0; /* in HIMETRIC */
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -773,10 +774,6 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
|
|||
DWORD style, old_options, new_options, change, props_mask = 0;
|
||||
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_WANTRETURN | ECO_SAVESEL | ECO_VERTICAL;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
new_options = old_options = SendMessageW( host->window, EM_GETOPTIONS, 0, 0 );
|
||||
|
||||
|
@ -828,6 +825,11 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
|
|||
host->props ^= TXTBIT_SAVESELECTION;
|
||||
props_mask |= TXTBIT_SAVESELECTION;
|
||||
}
|
||||
if (change & ECO_SELECTIONBAR)
|
||||
{
|
||||
host->sel_bar ^= 1;
|
||||
props_mask |= TXTBIT_SELBARCHANGE;
|
||||
}
|
||||
if (change & ECO_VERTICAL)
|
||||
{
|
||||
host->props ^= TXTBIT_VERTICAL;
|
||||
|
@ -838,15 +840,13 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
|
|||
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);
|
||||
*res = new_options;
|
||||
|
||||
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 );
|
||||
return hr;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* handle dialog mode VK_RETURN. Returns TRUE if message has been processed */
|
||||
|
@ -1017,7 +1017,6 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
|
|||
break;
|
||||
}
|
||||
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;
|
||||
|
@ -1026,6 +1025,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
|
|||
if (host->scrollbars & ES_AUTOHSCROLL) res |= ECO_AUTOHSCROLL;
|
||||
if (host->scrollbars & ES_AUTOVSCROLL) res |= ECO_AUTOVSCROLL;
|
||||
if (host->want_return) res |= ECO_WANTRETURN;
|
||||
if (host->sel_bar) res |= ECO_SELECTIONBAR;
|
||||
break;
|
||||
|
||||
case WM_GETTEXT:
|
||||
|
|
|
@ -327,6 +327,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServic
|
|||
struct text_services *services = impl_from_ITextServices( iface );
|
||||
DWORD scrollbars;
|
||||
HRESULT hr;
|
||||
BOOL repaint = FALSE;
|
||||
|
||||
TRACE( "%p, mask %08x, bits %08x\n", services, mask, bits );
|
||||
|
||||
|
@ -349,6 +350,23 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServic
|
|||
|
||||
if ((mask & TXTBIT_HIDESELECTION) && !services->editor->bHaveFocus) ME_InvalidateSelection( services->editor );
|
||||
|
||||
if (mask & TXTBIT_SELBARCHANGE)
|
||||
{
|
||||
LONG width;
|
||||
|
||||
hr = ITextHost_TxGetSelectionBarWidth( services->host, &width );
|
||||
if (hr == S_OK)
|
||||
{
|
||||
ITextHost_TxInvalidateRect( services->host, &services->editor->rcFormat, TRUE );
|
||||
services->editor->rcFormat.left -= services->editor->selofs;
|
||||
services->editor->selofs = width ? SELECTIONBAR_WIDTH : 0; /* FIXME: convert from HIMETRIC */
|
||||
services->editor->rcFormat.left += services->editor->selofs;
|
||||
repaint = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (repaint) ME_RewrapRepaint( services->editor );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue