Commit b8133550 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

riched20: Implement ECO/EM SELECTIONBAR.

parent 964a0303
......@@ -27,7 +27,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit);
static BOOL
ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs);
void ME_GetSelection(ME_TextEditor *editor, int *from, int *to)
{
*from = ME_GetCursorOfs(editor, 0);
......@@ -832,25 +831,64 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y)
tmp_cursor = editor->pCursors[0];
is_selection = ME_IsSelection(editor);
if (x >= editor->selofs)
{
ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd);
if (GetKeyState(VK_SHIFT)>=0)
{
editor->pCursors[1] = editor->pCursors[0];
}
else
{
if (!is_selection) {
else if (!is_selection) {
editor->pCursors[1] = tmp_cursor;
is_selection = 1;
}
ME_InvalidateSelection(editor);
HideCaret(editor->hWnd);
ME_MoveCaret(editor);
ShowCaret(editor->hWnd);
ME_ClearTempStyle(editor);
ME_SendSelChange(editor);
}
else
{
ME_DisplayItem *pRow;
editor->linesel = 1;
editor->sely = y;
/* Set pCursors[0] to beginning of line */
ME_FindPixelPos(editor, x, y, &editor->pCursors[1], &editor->bCaretAtEnd);
/* Set pCursors[1] to end of line */
pRow = ME_FindItemFwd(editor->pCursors[1].pRun, diStartRowOrParagraphOrEnd);
assert(pRow);
/* pCursor[0] is the position where the cursor will be drawn,
* pCursor[1] is the other end of the selection range
* pCursor[2] and [3] are backups of [0] and [1] so I
* don't have to look them up again
*/
if (pRow->type == diStartRow) {
/* FIXME WTF was I thinking about here ? */
ME_DisplayItem *pRun = ME_FindItemFwd(pRow, diRun);
assert(pRun);
editor->pCursors[0].pRun = pRun;
editor->pCursors[0].nOffset = 0;
editor->bCaretAtEnd = 1;
} else {
editor->pCursors[0].pRun = ME_FindItemBack(pRow, diRun);
assert(editor->pCursors[0].pRun && editor->pCursors[0].pRun->member.run.nFlags & MERF_ENDPARA);
editor->pCursors[0].nOffset = 0;
editor->bCaretAtEnd = 0;
}
editor->pCursors[2] = editor->pCursors[0];
editor->pCursors[3] = editor->pCursors[1];
ME_InvalidateSelection(editor);
HideCaret(editor->hWnd);
ME_MoveCaret(editor);
ShowCaret(editor->hWnd);
ME_ClearTempStyle(editor);
ME_SendSelChange(editor);
}
}
void ME_MouseMove(ME_TextEditor *editor, int x, int y)
......@@ -861,14 +899,33 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
tmp_cursor = editor->pCursors[0];
/* FIXME: do something with the return value of ME_FindPixelPos */
if (!editor->linesel)
ME_FindPixelPos(editor, x, y, &tmp_cursor, &editor->bCaretAtEnd);
else ME_FindPixelPos(editor, (y > editor->sely) * editor->rcFormat.right, y, &tmp_cursor, &editor->bCaretAtEnd);
if (tmp_cursor.pRun == editor->pCursors[0].pRun &&
tmp_cursor.nOffset == editor->pCursors[0].nOffset)
if (!memcmp(&tmp_cursor, editor->pCursors, sizeof(tmp_cursor)))
return;
ME_InvalidateSelection(editor);
if (!editor->linesel)
editor->pCursors[0] = tmp_cursor;
else if (!memcmp(&tmp_cursor, editor->pCursors+2, sizeof(tmp_cursor)) ||
!memcmp(&tmp_cursor, editor->pCursors+3, sizeof(tmp_cursor)))
{
editor->pCursors[0] = editor->pCursors[2];
editor->pCursors[1] = editor->pCursors[3];
}
else if (y < editor->sely)
{
editor->pCursors[0] = tmp_cursor;
editor->pCursors[1] = editor->pCursors[2];
}
else
{
editor->pCursors[0] = tmp_cursor;
editor->pCursors[1] = editor->pCursors[3];
}
HideCaret(editor->hWnd);
ME_MoveCaret(editor);
ME_InvalidateSelection(editor);
......@@ -1240,7 +1297,6 @@ void ME_SendSelChange(ME_TextEditor *editor)
SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc);
}
BOOL
ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl)
{
......
......@@ -228,6 +228,7 @@
#include "shlwapi.h"
#include "rtf.h"
#include "imm.h"
#include "res.h"
#define STACK_SIZE_DEFAULT 100
#define STACK_SIZE_MAX 1000
......@@ -242,6 +243,8 @@ static const WCHAR RichEdit20W[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '2',
static const WCHAR RichEdit50W[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '5', '0', 'W', 0};
static const WCHAR REListBox20W[] = {'R','E','L','i','s','t','B','o','x','2','0','W', 0};
static const WCHAR REComboBox20W[] = {'R','E','C','o','m','b','o','B','o','x','2','0','W', 0};
static HCURSOR hLeft;
static HCURSOR hBeam;
int me_debug = 0;
HANDLE me_heap = NULL;
......@@ -1088,6 +1091,14 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
return FALSE;
}
static void ME_SetCursor(ME_TextEditor *editor, int x)
{
if (x < editor->selofs || editor->linesel)
SetCursor(hLeft);
else
SetCursor(hBeam);
}
static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
{
CHARRANGE selrange;
......@@ -1124,7 +1135,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ME_MakeFirstParagraph(hDC, ed->pBuffer);
ReleaseDC(hWnd, hDC);
ed->bCaretShown = FALSE;
ed->nCursors = 2;
ed->nCursors = 4;
ed->pCursors = ALLOC_N_OBJ(ME_Cursor, ed->nCursors);
ed->pCursors[0].pRun = ME_FindItemFwd(ed->pBuffer->pFirst, diRun);
ed->pCursors[0].nOffset = 0;
......@@ -1165,6 +1176,11 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
}
ME_CheckCharOffsets(ed);
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_SELECTIONBAR)
ed->selofs = 16;
else
ed->selofs = 0;
ed->linesel = 0;
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_PASSWORD)
ed->cPasswordMask = '*';
......@@ -1254,6 +1270,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
DisableThreadLibraryCalls(hinstDLL);
me_heap = HeapCreate (0, 0x10000, 0);
if (!ME_RegisterEditorClass(hinstDLL)) return FALSE;
hLeft = LoadCursorW(hinstDLL, MAKEINTRESOURCEW(OCR_REVERSE));
hBeam = LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_IBEAM));
LookupInit();
break;
......@@ -1574,7 +1592,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
if (lParam & ECO_AUTOWORDSELECTION)
FIXME("ECO_AUTOWORDSELECTION not implemented yet!\n");
if (lParam & ECO_SELECTIONBAR)
FIXME("ECO_SELECTIONBAR not implemented yet!\n");
editor->selofs = 16;
else
editor->selofs = 0;
if (lParam & ECO_VERTICAL)
FIXME("ECO_VERTICAL not implemented yet!\n");
if (lParam & ECO_AUTOHSCROLL)
......@@ -2356,15 +2377,19 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
SetCapture(hWnd);
ME_LinkNotify(editor,msg,wParam,lParam);
ME_SetCursor(editor, LOWORD(lParam));
break;
case WM_MOUSEMOVE:
if (GetCapture() == hWnd)
ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
ME_LinkNotify(editor,msg,wParam,lParam);
ME_SetCursor(editor, LOWORD(lParam));
break;
case WM_LBUTTONUP:
if (GetCapture() == hWnd)
ReleaseCapture();
editor->linesel = 0;
ME_SetCursor(editor, LOWORD(lParam));
ME_LinkNotify(editor,msg,wParam,lParam);
break;
case WM_LBUTTONDBLCLK:
......@@ -2878,7 +2903,7 @@ static BOOL ME_RegisterEditorClass(HINSTANCE hInstance)
wcW.cbWndExtra = sizeof(ME_TextEditor *);
wcW.hInstance = NULL; /* hInstance would register DLL-local class */
wcW.hIcon = NULL;
wcW.hCursor = LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_IBEAM));
wcW.hCursor = hBeam;
wcW.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
wcW.lpszMenuName = NULL;
......
......@@ -325,6 +325,7 @@ typedef struct tagME_TextEditor
BOOL bHaveFocus;
/*for IME */
int imeStartIndex;
DWORD selofs, linesel, sely;
} ME_TextEditor;
typedef struct tagME_Context
......
/*
* Top level resource file for MOUSE driver dll
*
* Copyright 2007 Maarten Lankhorst for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define OCR_REVERSE 32768
......@@ -24,3 +24,7 @@
#define WINE_PRODUCTVERSION_STR "5,30,23,1215"
#include "wine/wine_common_ver.rc"
#include "res.h"
OCR_REVERSE CURSOR ocr_reverse.cur
......@@ -338,7 +338,7 @@ static ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
static void ME_PrepareParagraphForWrapping(ME_Context *c, ME_DisplayItem *tp);
static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD beginofs) {
ME_DisplayItem *p;
ME_WrapContext wc;
int dpi = GetDeviceCaps(c->hDC, LOGPIXELSX);
......@@ -353,8 +353,8 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
/* wc.para_style = tp->member.para.style; */
wc.style = NULL;
tp->member.para.nRightMargin = tp->member.para.pFmt->dxRightIndent*dpi/1440;
tp->member.para.nFirstMargin = tp->member.para.pFmt->dxStartIndent*dpi/1440;
tp->member.para.nLeftMargin = (tp->member.para.pFmt->dxStartIndent+tp->member.para.pFmt->dxOffset)*dpi/1440;
tp->member.para.nFirstMargin = tp->member.para.pFmt->dxStartIndent*dpi/1440 + beginofs;
tp->member.para.nLeftMargin = (tp->member.para.pFmt->dxStartIndent+tp->member.para.pFmt->dxOffset)*dpi/1440 + beginofs;
wc.nFirstMargin = tp->member.para.nFirstMargin;
wc.nLeftMargin = tp->member.para.nLeftMargin;
wc.nRightMargin = tp->member.para.nRightMargin;
......@@ -443,7 +443,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
bRedraw = TRUE;
item->member.para.nYPos = c.pt.y;
ME_WrapTextParagraph(&c, item);
ME_WrapTextParagraph(&c, item, editor->selofs);
if (bRedraw)
{
......
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