Commit 7a038cae authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Handle dialog mode in the host.

parent 84aa9b91
...@@ -2411,34 +2411,8 @@ static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor) ...@@ -2411,34 +2411,8 @@ static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
static BOOL handle_enter(ME_TextEditor *editor) static BOOL handle_enter(ME_TextEditor *editor)
{ {
BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000; BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000;
if (editor->bDialogMode)
{
if (ctrl_is_down)
return TRUE;
if (!(editor->styleFlags & ES_WANTRETURN))
{
if (editor->hwndParent)
{
DWORD dw;
dw = SendMessageW(editor->hwndParent, DM_GETDEFID, 0, 0);
if (HIWORD(dw) == DC_HASDEFID)
{
HWND hwDefCtrl = GetDlgItem(editor->hwndParent, LOWORD(dw));
if (hwDefCtrl)
{
SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE);
PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
}
}
}
return TRUE;
}
}
if (editor->props & TXTBIT_MULTILINE) if (editor->props & TXTBIT_MULTILINE)
{ {
ME_Cursor cursor = editor->pCursors[0]; ME_Cursor cursor = editor->pCursors[0];
...@@ -2647,14 +2621,6 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey) ...@@ -2647,14 +2621,6 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
if (!editor->bEmulateVersion10) if (!editor->bEmulateVersion10)
return handle_enter(editor); return handle_enter(editor);
break; break;
case VK_ESCAPE:
if (editor->bDialogMode && editor->hwndParent)
PostMessageW(editor->hwndParent, WM_CLOSE, 0, 0);
return TRUE;
case VK_TAB:
if (editor->bDialogMode && editor->hwndParent)
SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, shift_is_down, 0);
return TRUE;
case 'A': case 'A':
if (ctrl_is_down) if (ctrl_is_down)
{ {
...@@ -3068,7 +3034,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ...@@ -3068,7 +3034,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->mode |= (ed->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->bMouseCaptured = FALSE; ed->bMouseCaptured = FALSE;
ed->caret_hidden = FALSE; ed->caret_hidden = FALSE;
ed->caret_height = 0; ed->caret_height = 0;
...@@ -3399,18 +3364,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ...@@ -3399,18 +3364,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam, TRUE); return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam, TRUE);
case EM_STREAMOUT: case EM_STREAMOUT:
return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam); return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam);
case WM_GETDLGCODE:
{
UINT code = DLGC_WANTCHARS|DLGC_WANTTAB|DLGC_WANTARROWS;
if (lParam)
editor->bDialogMode = TRUE;
if (editor->props & TXTBIT_MULTILINE)
code |= DLGC_WANTMESSAGE;
if (!(editor->props & TXTBIT_SAVESELECTION))
code |= DLGC_HASSETSEL;
return code;
}
case EM_EMPTYUNDOBUFFER: case EM_EMPTYUNDOBUFFER:
ME_EmptyUndoStack(editor); ME_EmptyUndoStack(editor);
return 0; return 0;
......
...@@ -424,7 +424,6 @@ typedef struct tagME_TextEditor ...@@ -424,7 +424,6 @@ typedef struct tagME_TextEditor
BOOL AutoURLDetect_bEnable; BOOL AutoURLDetect_bEnable;
WCHAR cPasswordMask; WCHAR cPasswordMask;
BOOL bHaveFocus; BOOL bHaveFocus;
BOOL bDialogMode; /* Indicates that we are inside a dialog window */
/*for IME */ /*for IME */
int imeStartIndex; int imeStartIndex;
DWORD selofs; /* The size of the selection bar on the left side of control */ DWORD selofs; /* The size of the selection bar on the left side of control */
......
...@@ -39,7 +39,8 @@ struct host ...@@ -39,7 +39,8 @@ struct host
ITextServices *text_srv; ITextServices *text_srv;
ME_TextEditor *editor; /* to be removed */ ME_TextEditor *editor; /* to be removed */
HWND window, parent; HWND window, parent;
BOOL emulate_10; unsigned int emulate_10 : 1;
unsigned int dialog_mode : 1;
PARAFORMAT2 para_fmt; PARAFORMAT2 para_fmt;
DWORD props, scrollbars, event_mask; DWORD props, scrollbars, event_mask;
}; };
...@@ -84,6 +85,7 @@ struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 ) ...@@ -84,6 +85,7 @@ struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
texthost->window = hwnd; texthost->window = hwnd;
texthost->parent = cs->hwndParent; texthost->parent = cs->hwndParent;
texthost->emulate_10 = emulate_10; texthost->emulate_10 = emulate_10;
texthost->dialog_mode = 0;
memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) ); memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) );
texthost->para_fmt.cbSize = sizeof(texthost->para_fmt); texthost->para_fmt.cbSize = sizeof(texthost->para_fmt);
texthost->para_fmt.dwMask = PFM_ALIGNMENT; texthost->para_fmt.dwMask = PFM_ALIGNMENT;
...@@ -844,6 +846,31 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r ...@@ -844,6 +846,31 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
return hr; return hr;
} }
/* handle dialog mode VK_RETURN. Returns TRUE if message has been processed */
static BOOL handle_dialog_enter( struct host *host )
{
BOOL ctrl_is_down = GetKeyState( VK_CONTROL ) & 0x8000;
if (ctrl_is_down) return TRUE;
if (host->editor->styleFlags & ES_WANTRETURN) return FALSE;
if (host->parent)
{
DWORD id = SendMessageW( host->parent, DM_GETDEFID, 0, 0 );
if (HIWORD( id ) == DC_HASDEFID)
{
HWND ctrl = GetDlgItem( host->parent, LOWORD( id ));
if (ctrl)
{
SendMessageW( host->parent, WM_NEXTDLGCTL, (WPARAM)ctrl, TRUE );
PostMessageW( ctrl, WM_KEYDOWN, VK_RETURN, 0 );
}
}
}
return TRUE;
}
static LRESULT send_msg_filter( struct host *host, UINT msg, WPARAM *wparam, LPARAM *lparam ) static LRESULT send_msg_filter( struct host *host, UINT msg, WPARAM *wparam, LPARAM *lparam )
{ {
MSGFILTER msgf; MSGFILTER msgf;
...@@ -905,6 +932,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -905,6 +932,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
WCHAR wc = wparam; WCHAR wc = wparam;
if (!unicode) MultiByteToWideChar( CP_ACP, 0, (char *)&wparam, 1, &wc, 1 ); if (!unicode) MultiByteToWideChar( CP_ACP, 0, (char *)&wparam, 1, &wc, 1 );
if (wparam == '\r' && host->dialog_mode && host->emulate_10 && handle_dialog_enter( host )) break;
hr = ITextServices_TxSendMessage( host->text_srv, msg, wc, lparam, &res ); hr = ITextServices_TxSendMessage( host->text_srv, msg, wc, lparam, &res );
break; break;
} }
...@@ -958,6 +986,14 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -958,6 +986,14 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
} }
break; break;
} }
case WM_GETDLGCODE:
if (lparam) host->dialog_mode = TRUE;
res = DLGC_WANTCHARS | DLGC_WANTTAB | DLGC_WANTARROWS;
if (host->props & TXTBIT_MULTILINE) res |= DLGC_WANTMESSAGE;
if (!(host->props & TXTBIT_SAVESELECTION)) res |= DLGC_HASSETSEL;
break;
case EM_GETLINE: case EM_GETLINE:
if (unicode) hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, lparam, &res ); if (unicode) hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, lparam, &res );
else hr = get_lineA( host->text_srv, wparam, lparam, &res ); else hr = get_lineA( host->text_srv, wparam, lparam, &res );
...@@ -1014,6 +1050,25 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -1014,6 +1050,25 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
else hr = get_text_rangeA( host, (TEXTRANGEA *)lparam, &res ); else hr = get_text_rangeA( host, (TEXTRANGEA *)lparam, &res );
break; break;
case WM_KEYDOWN:
switch (LOWORD( wparam ))
{
case VK_ESCAPE:
if (host->dialog_mode && host->parent)
PostMessageW( host->parent, WM_CLOSE, 0, 0 );
break;
case VK_TAB:
if (host->dialog_mode && host->parent)
SendMessageW( host->parent, WM_NEXTDLGCTL, GetKeyState( VK_SHIFT ) & 0x8000, 0 );
break;
case VK_RETURN:
if (host->dialog_mode && !host->emulate_10 && handle_dialog_enter( host )) break;
/* fall through */
default:
hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, lparam, &res );
}
break;
case WM_PAINT: case WM_PAINT:
{ {
HDC hdc; HDC hdc;
......
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