mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
sync riched20 with wine 1.1.11
svn path=/trunk/; revision=38370
This commit is contained in:
parent
133de9dcc5
commit
4324dea95c
13 changed files with 615 additions and 625 deletions
|
@ -214,8 +214,9 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
|
|||
}
|
||||
|
||||
*height = pSizeRun->member.run.nAscent + pSizeRun->member.run.nDescent;
|
||||
*x = run->member.run.pt.x + sz.cx;
|
||||
*y = para->member.para.pt.y + row->member.row.nBaseline + run->member.run.pt.y - pSizeRun->member.run.nAscent - ME_GetYScrollPos(editor);
|
||||
*x = c.rcView.left + run->member.run.pt.x + sz.cx;
|
||||
*y = c.rcView.top + para->member.para.pt.y + row->member.row.nBaseline
|
||||
+ run->member.run.pt.y - pSizeRun->member.run.nAscent - ME_GetYScrollPos(editor);
|
||||
ME_DestroyContext(&c, editor->hWnd);
|
||||
return;
|
||||
}
|
||||
|
@ -236,10 +237,7 @@ ME_MoveCaret(ME_TextEditor *editor)
|
|||
ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
|
||||
if(editor->bHaveFocus && !ME_IsSelection(editor))
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
GetClientRect(editor->hWnd, &rect);
|
||||
x = min(x, rect.right-2);
|
||||
x = min(x, editor->rcFormat.right-1);
|
||||
CreateCaret(editor->hWnd, NULL, 0, height);
|
||||
SetCaretPos(x, y);
|
||||
}
|
||||
|
@ -922,6 +920,9 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
|
|||
int rx = 0;
|
||||
BOOL isExact = TRUE;
|
||||
|
||||
x -= editor->rcFormat.left;
|
||||
y -= editor->rcFormat.top;
|
||||
|
||||
if (is_eol)
|
||||
*is_eol = 0;
|
||||
|
||||
|
@ -1109,13 +1110,13 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
|
|||
|
||||
ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd);
|
||||
|
||||
if (x >= editor->selofs || is_shift)
|
||||
if (x >= editor->rcFormat.left || is_shift)
|
||||
{
|
||||
if (clickNum > 1)
|
||||
{
|
||||
editor->pCursors[1] = editor->pCursors[0];
|
||||
if (is_shift) {
|
||||
if (x >= editor->selofs)
|
||||
if (x >= editor->rcFormat.left)
|
||||
ME_SelectByType(editor, stWord);
|
||||
else
|
||||
ME_SelectByType(editor, stParagraph);
|
||||
|
@ -1177,16 +1178,10 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
|
|||
memcmp(&editor->pCursors[1], &editor->pCursors[3], sizeof(ME_Cursor)))
|
||||
{
|
||||
/* The scroll the cursor towards the other end, since it was the one
|
||||
* extended by ME_ExtendAnchorSelection
|
||||
*/
|
||||
ME_Cursor tmpCursor = editor->pCursors[0];
|
||||
editor->pCursors[0] = editor->pCursors[1];
|
||||
editor->pCursors[1] = tmpCursor;
|
||||
SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0);
|
||||
editor->pCursors[1] = editor->pCursors[0];
|
||||
editor->pCursors[0] = tmpCursor;
|
||||
* extended by ME_ExtendAnchorSelection */
|
||||
ME_EnsureVisible(editor, editor->pCursors[1].pRun);
|
||||
} else {
|
||||
SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0);
|
||||
ME_EnsureVisible(editor, editor->pCursors[0].pRun);
|
||||
}
|
||||
|
||||
ME_InvalidateSelection(editor);
|
||||
|
@ -1571,11 +1566,9 @@ void ME_SendSelChange(ME_TextEditor *editor)
|
|||
|
||||
if (!(editor->nEventMask & ENM_SELCHANGE))
|
||||
return;
|
||||
|
||||
sc.nmhdr.hwndFrom = editor->hWnd;
|
||||
sc.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID);
|
||||
|
||||
sc.nmhdr.code = EN_SELCHANGE;
|
||||
SendMessageW(editor->hWnd, EM_EXGETSEL, 0, (LPARAM)&sc.chrg);
|
||||
ME_GetSelection(editor, &sc.chrg.cpMin, &sc.chrg.cpMax);
|
||||
sc.seltyp = SEL_EMPTY;
|
||||
if (sc.chrg.cpMin != sc.chrg.cpMax)
|
||||
sc.seltyp |= SEL_TEXT;
|
||||
|
|
|
@ -334,7 +334,7 @@ static HGLOBAL get_unicode_text(ME_TextEditor *editor, const CHARRANGE *lpchrg)
|
|||
pars = ME_CountParagraphsBetween(editor, lpchrg->cpMin, lpchrg->cpMax);
|
||||
len = lpchrg->cpMax-lpchrg->cpMin;
|
||||
ret = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR)*(len+pars+1));
|
||||
data = (WCHAR *)GlobalLock(ret);
|
||||
data = GlobalLock(ret);
|
||||
len = ME_GetTextW(editor, data, lpchrg->cpMin, len, TRUE);
|
||||
data[len] = 0;
|
||||
GlobalUnlock(ret);
|
||||
|
@ -359,7 +359,7 @@ static DWORD CALLBACK ME_AppendToHGLOBAL(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG
|
|||
int nNewSize = (((nMaxSize+cb+1)|0x1FFFF)+1) & 0xFFFE0000;
|
||||
pData->hData = GlobalReAlloc(pData->hData, nNewSize, 0);
|
||||
}
|
||||
pDest = (BYTE *)GlobalLock(pData->hData);
|
||||
pDest = GlobalLock(pData->hData);
|
||||
memcpy(pDest + pData->nLength, lpBuff, cb);
|
||||
pData->nLength += cb;
|
||||
pDest[pData->nLength] = '\0';
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -268,11 +268,11 @@ void ME_GetOLEObjectSize(ME_Context *c, ME_Run *run, SIZE *pSize);
|
|||
void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src);
|
||||
void ME_DeleteReObject(REOBJECT* reo);
|
||||
|
||||
/* wintest.c */
|
||||
|
||||
/* editor.c */
|
||||
ME_TextEditor *ME_MakeEditor(HWND hWnd);
|
||||
void ME_DestroyEditor(ME_TextEditor *editor);
|
||||
LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam, BOOL unicode, HRESULT* phresult);
|
||||
void ME_SendOldNotify(ME_TextEditor *editor, int nCode);
|
||||
void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, BOOL bCRLF);
|
||||
|
@ -282,7 +282,6 @@ void ME_RTFParAttrHook(struct _RTF_Info *info);
|
|||
void ME_RTFTblAttrHook(struct _RTF_Info *info);
|
||||
void ME_RTFSpecialCharHook(struct _RTF_Info *info);
|
||||
void ME_StreamInFill(ME_InStream *stream);
|
||||
int ME_AutoURLDetect(ME_TextEditor *editor, WCHAR curChar);
|
||||
extern int me_debug;
|
||||
extern void DoWrap(ME_TextEditor *editor);
|
||||
extern BOOL ME_FindNextURLCandidate(ME_TextEditor *editor, int sel_min, int sel_max,
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef enum {
|
|||
diUndoPotentialEndTransaction, /* 20 - allows grouping typed chars for undo */
|
||||
} ME_DIType;
|
||||
|
||||
#define SELECTIONBAR_WIDTH 9
|
||||
#define SELECTIONBAR_WIDTH 8
|
||||
|
||||
/******************************** run flags *************************/
|
||||
#define MERF_STYLEFLAGS 0x0FFF
|
||||
|
@ -333,7 +333,6 @@ typedef struct tagME_TextEditor
|
|||
int nCursors;
|
||||
SIZE sizeWindow;
|
||||
int nTotalLength, nLastTotalLength;
|
||||
int nHeight;
|
||||
int nUDArrowX;
|
||||
int nSequence;
|
||||
COLORREF rgbBackColor;
|
||||
|
@ -350,7 +349,9 @@ typedef struct tagME_TextEditor
|
|||
ME_DisplayItem *pLastSelStartPara, *pLastSelEndPara;
|
||||
ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
|
||||
int nZoomNumerator, nZoomDenominator;
|
||||
RECT prevClientRect;
|
||||
RECT rcFormat;
|
||||
BOOL bDefaultFormatRect;
|
||||
BOOL bWordWrap;
|
||||
int nInvalidOfs;
|
||||
int nTextLimit;
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
|
||||
|
||||
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *rcUpdate) {
|
||||
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *rcUpdate)
|
||||
{
|
||||
ME_DisplayItem *item;
|
||||
ME_Context c;
|
||||
int yoffset;
|
||||
int ys, ye;
|
||||
|
||||
editor->nSequence++;
|
||||
yoffset = ME_GetYScrollPos(editor);
|
||||
|
@ -34,105 +36,70 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *
|
|||
SetBkMode(hDC, TRANSPARENT);
|
||||
ME_MoveCaret(editor); /* Calls ME_WrapMarkedParagraphs */
|
||||
item = editor->pBuffer->pFirst->next;
|
||||
c.pt.y -= yoffset;
|
||||
while(item != editor->pBuffer->pLast) {
|
||||
int yTextOffset = 0;
|
||||
int ye;
|
||||
/* This context point is an offset for the paragraph positions stored
|
||||
* during wrapping. It shouldn't be modified during painting. */
|
||||
c.pt.x = c.rcView.left;
|
||||
c.pt.y = c.rcView.top - yoffset;
|
||||
while(item != editor->pBuffer->pLast)
|
||||
{
|
||||
assert(item->type == diParagraph);
|
||||
|
||||
ys = c.pt.y + item->member.para.pt.y;
|
||||
if (item->member.para.pCell
|
||||
!= item->member.para.next_para->member.para.pCell)
|
||||
{
|
||||
ME_Cell *cell = NULL;
|
||||
cell = &ME_FindItemBack(item->member.para.next_para, diCell)->member.cell;
|
||||
ye = cell->pt.y + cell->nHeight - yoffset;
|
||||
ye = c.pt.y + cell->pt.y + cell->nHeight;
|
||||
} else {
|
||||
ye = c.pt.y + item->member.para.nHeight;
|
||||
ye = ys + item->member.para.nHeight;
|
||||
}
|
||||
if (!(item->member.para.nFlags & MEPF_ROWEND) &&
|
||||
if (item->member.para.pCell && !(item->member.para.nFlags & MEPF_ROWEND) &&
|
||||
item->member.para.pCell != item->member.para.prev_para->member.para.pCell)
|
||||
{
|
||||
ME_DisplayItem *cell;
|
||||
if (item->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART)
|
||||
cell = item->member.para.pCell;
|
||||
else
|
||||
cell = item->member.para.prev_para->member.para.pCell;
|
||||
assert(cell);
|
||||
/* the border shifts the text down */
|
||||
yTextOffset = cell->member.cell.yTextOffset;
|
||||
ye += yTextOffset;
|
||||
ys -= item->member.para.pCell->member.cell.yTextOffset;
|
||||
}
|
||||
|
||||
if (!bOnlyNew || (item->member.para.nFlags & MEPF_REPAINT))
|
||||
{
|
||||
/* Draw the pargraph if any of the paragraph is in the update region. */
|
||||
BOOL bPaint = (rcUpdate == NULL);
|
||||
if (rcUpdate)
|
||||
bPaint = c.pt.y<rcUpdate->bottom && ye>rcUpdate->top;
|
||||
bPaint = ys < rcUpdate->bottom && ye > rcUpdate->top;
|
||||
if (bPaint)
|
||||
{
|
||||
c.pt.y += yTextOffset;
|
||||
ME_DrawParagraph(&c, item);
|
||||
if (!rcUpdate || (rcUpdate->top<=c.pt.y-yTextOffset && rcUpdate->bottom>=ye))
|
||||
/* Clear the repaint flag if the whole paragraph is in the
|
||||
* update region. */
|
||||
if (!rcUpdate || (rcUpdate->top <= ys && rcUpdate->bottom >= ye))
|
||||
item->member.para.nFlags &= ~MEPF_REPAINT;
|
||||
}
|
||||
}
|
||||
if (item->member.para.pCell)
|
||||
{
|
||||
ME_Cell *cell = &item->member.para.pCell->member.cell;
|
||||
ME_DisplayItem *next_para = item->member.para.next_para;
|
||||
c.pt.x = cell->pt.x + cell->nWidth;
|
||||
if (item->member.para.pCell == next_para->member.para.pCell &&
|
||||
!(next_para->member.para.nFlags & (MEPF_ROWSTART|MEPF_ROWEND)))
|
||||
{
|
||||
c.pt.y = ye;
|
||||
} else {
|
||||
if (next_para->member.para.nFlags & MEPF_ROWSTART)
|
||||
{
|
||||
cell = &ME_FindItemFwd(next_para, diCell)->member.cell;
|
||||
}
|
||||
else if (next_para->member.para.nFlags & MEPF_ROWEND)
|
||||
{
|
||||
cell = &cell->next_cell->member.cell;
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = &next_para->member.para.pCell->member.cell;
|
||||
}
|
||||
c.pt.y = cell->pt.y - yoffset;
|
||||
}
|
||||
} else if (!(item->member.para.nFlags & MEPF_ROWSTART)) {
|
||||
c.pt.y = ye;
|
||||
}
|
||||
item = item->member.para.next_para;
|
||||
}
|
||||
if (c.pt.y<c.rcView.bottom) {
|
||||
if (c.pt.y + editor->nTotalLength < c.rcView.bottom)
|
||||
{
|
||||
/* Fill space after the end of the text. */
|
||||
RECT rc;
|
||||
int xs = c.rcView.left, xe = c.rcView.right;
|
||||
int ys = c.pt.y, ye = c.rcView.bottom;
|
||||
|
||||
rc.top = c.pt.y + editor->nTotalLength;
|
||||
rc.left = c.rcView.left;
|
||||
rc.bottom = c.rcView.bottom;
|
||||
rc.right = c.rcView.right;
|
||||
|
||||
if (bOnlyNew)
|
||||
{
|
||||
int y1 = editor->nTotalLength-yoffset, y2 = editor->nLastTotalLength-yoffset;
|
||||
if (y1<y2)
|
||||
ys = y1, ye = y2+1;
|
||||
/* Only erase region drawn from previous call to ME_PaintContent */
|
||||
if (editor->nTotalLength < editor->nLastTotalLength)
|
||||
rc.bottom = c.pt.y + editor->nLastTotalLength;
|
||||
else
|
||||
ys = ye;
|
||||
}
|
||||
|
||||
if (rcUpdate && ys!=ye)
|
||||
{
|
||||
xs = rcUpdate->left, xe = rcUpdate->right;
|
||||
if (rcUpdate->top > ys)
|
||||
ys = rcUpdate->top;
|
||||
if (rcUpdate->bottom < ye)
|
||||
ye = rcUpdate->bottom;
|
||||
SetRectEmpty(&rc);
|
||||
}
|
||||
|
||||
if (ye>ys) {
|
||||
rc.left = xs;
|
||||
rc.top = ys;
|
||||
rc.right = xe;
|
||||
rc.bottom = ye;
|
||||
IntersectRect(&rc, &rc, rcUpdate);
|
||||
|
||||
if (!IsRectEmpty(&rc))
|
||||
FillRect(hDC, &rc, c.editor->hbrBackground);
|
||||
}
|
||||
}
|
||||
if (editor->nTotalLength != editor->nLastTotalLength)
|
||||
ME_SendRequestResize(editor, FALSE);
|
||||
|
@ -441,7 +408,7 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
|
|||
if (runofs >= nSelFrom && runofs < nSelTo)
|
||||
{
|
||||
ME_HighlightSpace(c, x, y, wszSpace, 1, run->style, 0, 0, 1,
|
||||
c->pt.y + start->member.row.pt.y,
|
||||
c->pt.y + para->pt.y + start->member.row.pt.y,
|
||||
start->member.row.nHeight);
|
||||
}
|
||||
return;
|
||||
|
@ -452,8 +419,8 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
|
|||
/* wszSpace is used instead of the tab character because otherwise
|
||||
* an unwanted symbol can be inserted instead. */
|
||||
ME_DrawTextWithStyle(c, x, y, wszSpace, 1, run->style, run->nWidth,
|
||||
nSelFrom-runofs,nSelTo-runofs,
|
||||
c->pt.y + start->member.row.pt.y,
|
||||
nSelFrom-runofs, nSelTo-runofs,
|
||||
c->pt.y + para->pt.y + start->member.row.pt.y,
|
||||
start->member.row.nHeight);
|
||||
return;
|
||||
}
|
||||
|
@ -467,13 +434,17 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
|
|||
ME_String *szMasked = ME_MakeStringR(c->editor->cPasswordMask,ME_StrVLen(run->strText));
|
||||
ME_DrawTextWithStyle(c, x, y,
|
||||
szMasked->szData, ME_StrVLen(szMasked), run->style, run->nWidth,
|
||||
nSelFrom-runofs,nSelTo-runofs, c->pt.y+start->member.row.pt.y, start->member.row.nHeight);
|
||||
nSelFrom-runofs,nSelTo-runofs,
|
||||
c->pt.y + para->pt.y + start->member.row.pt.y,
|
||||
start->member.row.nHeight);
|
||||
ME_DestroyString(szMasked);
|
||||
}
|
||||
else
|
||||
ME_DrawTextWithStyle(c, x, y,
|
||||
run->strText->szData, ME_StrVLen(run->strText), run->style, run->nWidth,
|
||||
nSelFrom-runofs,nSelTo-runofs, c->pt.y+start->member.row.pt.y, start->member.row.nHeight);
|
||||
nSelFrom-runofs,nSelTo-runofs,
|
||||
c->pt.y + para->pt.y + start->member.row.pt.y,
|
||||
start->member.row.nHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -728,11 +699,11 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph)
|
|||
int width;
|
||||
BOOL atTop = (para->pCell != para->prev_para->member.para.pCell);
|
||||
BOOL atBottom = (para->pCell != para->next_para->member.para.pCell);
|
||||
int top = (atTop ? cell->pt.y : para->pt.y) - ME_GetYScrollPos(c->editor);
|
||||
int top = c->pt.y + (atTop ? cell->pt.y : para->pt.y);
|
||||
int bottom = (atBottom ?
|
||||
cell->pt.y + cell->nHeight - ME_GetYScrollPos(c->editor):
|
||||
c->pt.y + cell->pt.y + cell->nHeight :
|
||||
top + para->nHeight + (atTop ? cell->yTextOffset : 0));
|
||||
rc.left = cell->pt.x;
|
||||
rc.left = c->pt.x + cell->pt.x;
|
||||
rc.right = rc.left + cell->nWidth;
|
||||
if (atTop) {
|
||||
/* Erase gap before text if not all borders are the same height. */
|
||||
|
@ -745,7 +716,7 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph)
|
|||
}
|
||||
}
|
||||
/* Draw cell borders.
|
||||
* The borders borders are draw in is left, top, bottom, right in order
|
||||
* The order borders are draw in is left, top, bottom, right in order
|
||||
* to be consistent with native richedit. This is noticeable from the
|
||||
* overlap of borders of different colours. */
|
||||
if (!(para->nFlags & MEPF_ROWEND)) {
|
||||
|
@ -798,10 +769,10 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph)
|
|||
ME_DisplayItem *nextEndCell;
|
||||
nextEndCell = ME_FindItemBack(ME_GetTableRowEnd(paraAfterRow), diCell);
|
||||
assert(nextEndCell && !nextEndCell->member.cell.next_cell);
|
||||
rc.left = nextEndCell->member.cell.pt.x;
|
||||
rc.left = c->pt.x + nextEndCell->member.cell.pt.x;
|
||||
/* FIXME: Native draws FROM the bottom of the table rather than
|
||||
* TO the bottom of the table in this case, but just doing so here
|
||||
* will case the next row to erase the border. */
|
||||
* will cause the next row to erase the border. */
|
||||
/*
|
||||
rc.top = bottom;
|
||||
rc.bottom = rc.top + width;
|
||||
|
@ -860,12 +831,12 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph)
|
|||
oldpen = SelectObject(c->hDC, pen);
|
||||
|
||||
/* Find the start relative to the text */
|
||||
firstX = ME_FindItemFwd(paragraph, diRun)->member.run.pt.x;
|
||||
firstX = c->pt.x + ME_FindItemFwd(paragraph, diRun)->member.run.pt.x;
|
||||
/* Go back by the horizontal gap, which is stored in dxOffset */
|
||||
firstX -= ME_twips2pointsX(c, para->pFmt->dxOffset);
|
||||
/* The left edge, stored in dxStartIndent affected just the first edge */
|
||||
startX = firstX - ME_twips2pointsX(c, para->pFmt->dxStartIndent);
|
||||
rowY = c->pt.y;
|
||||
rowY = c->pt.y + para->pt.y;
|
||||
if (para->pFmt->dwMask & PFM_SPACEBEFORE)
|
||||
rowY += ME_twips2pointsY(c, para->pFmt->dySpaceBefore);
|
||||
nHeight = ME_FindItemFwd(paragraph, diStartRow)->member.row.nHeight;
|
||||
|
@ -907,53 +878,54 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph)
|
|||
}
|
||||
}
|
||||
|
||||
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
|
||||
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph)
|
||||
{
|
||||
int align = SetTextAlign(c->hDC, TA_BASELINE);
|
||||
ME_DisplayItem *p;
|
||||
ME_Run *run;
|
||||
ME_Paragraph *para = NULL;
|
||||
RECT rc, bounds;
|
||||
int y = c->pt.y;
|
||||
int y;
|
||||
int height = 0, baseline = 0, no=0;
|
||||
BOOL visible = FALSE;
|
||||
|
||||
c->pt.x = c->rcView.left;
|
||||
rc.left = c->rcView.left;
|
||||
rc.left = c->pt.x;
|
||||
rc.right = c->rcView.right;
|
||||
for (p = paragraph; p!=paragraph->member.para.next_para; p = p->next) {
|
||||
|
||||
assert(paragraph);
|
||||
para = ¶graph->member.para;
|
||||
y = c->pt.y + para->pt.y;
|
||||
if (para->pCell)
|
||||
{
|
||||
ME_Cell *cell = ¶->pCell->member.cell;
|
||||
rc.left = c->pt.x + cell->pt.x;
|
||||
rc.right = rc.left + cell->nWidth;
|
||||
}
|
||||
if (para->nFlags & MEPF_ROWSTART) {
|
||||
ME_Cell *cell = ¶->next_para->member.para.pCell->member.cell;
|
||||
rc.right = c->pt.x + cell->pt.x;
|
||||
} else if (para->nFlags & MEPF_ROWEND) {
|
||||
ME_Cell *cell = ¶->prev_para->member.para.pCell->member.cell;
|
||||
rc.left = c->pt.x + cell->pt.x + cell->nWidth;
|
||||
}
|
||||
ME_DrawParaDecoration(c, para, y, &bounds);
|
||||
y += bounds.top;
|
||||
rc.left += bounds.left;
|
||||
rc.right -= bounds.right;
|
||||
|
||||
for (p = paragraph->next; p != para->next_para; p = p->next)
|
||||
{
|
||||
switch(p->type) {
|
||||
case diParagraph:
|
||||
para = &p->member.para;
|
||||
assert(para);
|
||||
if (para->pCell)
|
||||
{
|
||||
ME_Cell *cell = ¶->pCell->member.cell;
|
||||
rc.left = cell->pt.x;
|
||||
rc.right = rc.left + cell->nWidth;
|
||||
}
|
||||
if (para->nFlags & MEPF_ROWSTART) {
|
||||
ME_Cell *cell = ¶->next_para->member.para.pCell->member.cell;
|
||||
rc.right = cell->pt.x;
|
||||
} else if (para->nFlags & MEPF_ROWEND) {
|
||||
ME_Cell *cell = ¶->prev_para->member.para.pCell->member.cell;
|
||||
rc.left = cell->pt.x + cell->nWidth;
|
||||
}
|
||||
ME_DrawParaDecoration(c, para, y, &bounds);
|
||||
y += bounds.top;
|
||||
assert(FALSE);
|
||||
break;
|
||||
case diStartRow:
|
||||
/* we should have seen a diParagraph before */
|
||||
assert(para);
|
||||
y += height;
|
||||
rc.top = y;
|
||||
if (para->nFlags & MEPF_ROWSTART) {
|
||||
ME_Cell *cell = ¶->next_para->member.para.pCell->member.cell;
|
||||
rc.bottom = y + cell->nHeight;
|
||||
} else if (para->nFlags & MEPF_ROWEND) {
|
||||
ME_Cell *cell = ¶->prev_para->member.para.pCell->member.cell;
|
||||
rc.bottom = y + cell->nHeight;
|
||||
if (para->nFlags & (MEPF_ROWSTART|MEPF_ROWEND)) {
|
||||
rc.bottom = y + para->nHeight;
|
||||
} else {
|
||||
rc.bottom = y+p->member.row.nHeight;
|
||||
rc.bottom = y + p->member.row.nHeight;
|
||||
}
|
||||
visible = RectVisible(c->hDC, &rc);
|
||||
if (visible) {
|
||||
|
@ -976,10 +948,11 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
|
|||
assert(para);
|
||||
run = &p->member.run;
|
||||
if (visible && me_debug) {
|
||||
rc.left = c->rcView.left+run->pt.x;
|
||||
rc.right = c->rcView.left+run->pt.x+run->nWidth;
|
||||
rc.top = c->pt.y+run->pt.y;
|
||||
rc.bottom = c->pt.y+run->pt.y+height;
|
||||
RECT rc;
|
||||
rc.left = c->pt.x + run->pt.x;
|
||||
rc.right = rc.left + run->nWidth;
|
||||
rc.top = c->pt.y + para->pt.y + run->pt.y;
|
||||
rc.bottom = rc.bottom + height;
|
||||
TRACE("rc = (%d, %d, %d, %d)\n", rc.left, rc.top, rc.right, rc.bottom);
|
||||
if (run->nFlags & MERF_SKIPPED)
|
||||
DrawFocusRect(c->hDC, &rc);
|
||||
|
@ -987,28 +960,27 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
|
|||
FrameRect(c->hDC, &rc, GetSysColorBrush(COLOR_GRAYTEXT));
|
||||
}
|
||||
if (visible)
|
||||
ME_DrawRun(c, run->pt.x, c->pt.y+run->pt.y+baseline, p, ¶graph->member.para);
|
||||
ME_DrawRun(c, c->pt.x + run->pt.x,
|
||||
c->pt.y + para->pt.y + run->pt.y + baseline, p, para);
|
||||
if (me_debug)
|
||||
{
|
||||
/* I'm using %ls, hope wsprintfW is not going to use wrong (4-byte) WCHAR version */
|
||||
const WCHAR wszRunDebug[] = {'[','%','d',':','%','x',']',' ','%','l','s',0};
|
||||
WCHAR buf[2560];
|
||||
POINT pt;
|
||||
pt.x = run->pt.x;
|
||||
pt.y = c->pt.y + run->pt.y;
|
||||
pt.x = c->pt.x + run->pt.x;
|
||||
pt.y = c->pt.y + para->pt.y + run->pt.y;
|
||||
wsprintfW(buf, wszRunDebug, no, p->member.run.nFlags, p->member.run.strText->szData);
|
||||
ME_DebugWrite(c->hDC, &pt, buf);
|
||||
}
|
||||
/* c->pt.x += p->member.run.nWidth; */
|
||||
break;
|
||||
case diCell:
|
||||
/* Clear any space at the bottom of the cell after the text. */
|
||||
if (para->nFlags & MEPF_ROWSTART)
|
||||
if (para->nFlags & (MEPF_ROWSTART|MEPF_ROWEND))
|
||||
break;
|
||||
y += height;
|
||||
rc.top = y;
|
||||
rc.bottom = p->member.cell.pt.y + p->member.cell.nHeight
|
||||
- ME_GetYScrollPos(c->editor);
|
||||
rc.top = c->pt.y + para->pt.y + para->nHeight;
|
||||
rc.bottom = c->pt.y + p->member.cell.pt.y + p->member.cell.nHeight;
|
||||
if (RectVisible(c->hDC, &rc))
|
||||
{
|
||||
FillRect(c->hDC, &rc, c->editor->hbrBackground);
|
||||
|
@ -1084,7 +1056,7 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
|
|||
hWnd = editor->hWnd;
|
||||
winStyle = GetWindowLongW(hWnd, GWL_STYLE);
|
||||
bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0;
|
||||
bScrollBarWillBeVisible = (editor->nHeight > editor->sizeWindow.cy)
|
||||
bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy)
|
||||
|| (winStyle & ES_DISABLENOSCROLL);
|
||||
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
|
||||
{
|
||||
|
@ -1110,7 +1082,7 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
|
|||
hWnd = editor->hWnd;
|
||||
si.cbSize = sizeof(si);
|
||||
bScrollBarWasVisible = ME_GetYScrollVisible(editor);
|
||||
bScrollBarWillBeVisible = editor->nHeight > editor->sizeWindow.cy;
|
||||
bScrollBarWillBeVisible = editor->nTotalLength > editor->sizeWindow.cy;
|
||||
|
||||
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
|
||||
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
|
||||
|
|
|
@ -38,7 +38,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
|
|||
|
||||
ME_InitContext(&c, editor, GetDC(editor->hWnd));
|
||||
|
||||
hf = (HFONT)GetStockObject(SYSTEM_FONT);
|
||||
hf = GetStockObject(SYSTEM_FONT);
|
||||
assert(hf);
|
||||
GetObjectW(hf, sizeof(LOGFONTW), &lf);
|
||||
ZeroMemory(&cf, sizeof(cf));
|
||||
|
|
|
@ -673,7 +673,7 @@ static void _RTFGetToken2(RTF_Info *info)
|
|||
}
|
||||
|
||||
/* escaped char */
|
||||
/*if (index (":{}\\", c) != (char *) NULL)*/ /* escaped char */
|
||||
/*if (index (":{}\\", c) != NULL)*/ /* escaped char */
|
||||
if (c == ':' || c == '{' || c == '}' || c == '\\')
|
||||
{
|
||||
info->rtfClass = rtfText;
|
||||
|
@ -2289,7 +2289,7 @@ static RTFKey rtfKey[] =
|
|||
{ rtfVersion, -1, "rtf", 0 },
|
||||
{ rtfDefFont, -1, "deff", 0 },
|
||||
|
||||
{ 0, -1, (char *) NULL, 0 }
|
||||
{ 0, -1, NULL, 0 }
|
||||
};
|
||||
#define RTF_KEY_COUNT (sizeof(rtfKey) / sizeof(RTFKey))
|
||||
|
||||
|
@ -2326,7 +2326,7 @@ void LookupInit(void)
|
|||
|
||||
void LookupCleanup(void)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i<RTF_KEY_COUNT*2; i++)
|
||||
{
|
||||
|
|
|
@ -1157,9 +1157,6 @@ struct _RTF_Info {
|
|||
|
||||
ME_InStream *stream;
|
||||
|
||||
/* edit window to output to */
|
||||
HWND hwndEdit;
|
||||
|
||||
ME_TextEditor *editor;
|
||||
ME_Style *style;
|
||||
|
||||
|
|
|
@ -692,7 +692,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run
|
|||
{
|
||||
pos += lDefaultTab - (pos % lDefaultTab);
|
||||
}
|
||||
ppos = ME_twips2pointsX(c, pos) + c->editor->selofs;
|
||||
ppos = ME_twips2pointsX(c, pos);
|
||||
if (ppos > startx + run->pt.x) {
|
||||
size.cx = ppos - startx - run->pt.x;
|
||||
break;
|
||||
|
@ -813,7 +813,7 @@ void ME_SetCharFormat(ME_TextEditor *editor, int nOfs, int nChars, CHARFORMAT2W
|
|||
undo->nStart = tmp.pRun->member.run.nCharOfs+para->member.para.nCharOfs;
|
||||
undo->nLen = tmp.pRun->member.run.strText->nLen;
|
||||
undo->di.member.ustyle = tmp.pRun->member.run.style;
|
||||
/* we'd have to addref undo..ustyle and release tmp...style
|
||||
/* we'd have to addref undo...ustyle and release tmp...style
|
||||
but they'd cancel each other out so we can do nothing instead */
|
||||
}
|
||||
else
|
||||
|
@ -872,8 +872,6 @@ static void ME_GetRunCharFormat(ME_TextEditor *editor, ME_DisplayItem *run, CHAR
|
|||
*/
|
||||
void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
|
||||
{
|
||||
int nFrom, nTo;
|
||||
ME_GetSelection(editor, &nFrom, &nTo);
|
||||
ME_CopyCharFormat(pFmt, &editor->pBuffer->pDefaultStyle->fmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code)
|
|||
int result;
|
||||
int buffer_size = WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
|
||||
NULL, 0, NULL, NULL);
|
||||
char *buffer = (char*)heap_alloc(buffer_size);
|
||||
char *buffer = heap_alloc(buffer_size);
|
||||
WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
|
||||
buffer, buffer_size, NULL, NULL);
|
||||
result = editor->pfnWordBreak(str->szData, start, str->nLen, code);
|
||||
|
|
|
@ -78,8 +78,7 @@ static void ME_BeginRow(ME_WrapContext *wc, ME_DisplayItem *para)
|
|||
wc->bWordWrap = TRUE;
|
||||
} else {
|
||||
wc->nAvailWidth = wc->context->rcView.right - wc->context->rcView.left
|
||||
- (wc->nRow ? wc->nLeftMargin : wc->nFirstMargin) - wc->nRightMargin
|
||||
- wc->context->editor->selofs;
|
||||
- (wc->nRow ? wc->nLeftMargin : wc->nFirstMargin) - wc->nRightMargin;
|
||||
}
|
||||
wc->pt.x = wc->context->pt.x;
|
||||
if (wc->context->editor->bEmulateVersion10 && /* v1.0 - 3.0 */
|
||||
|
@ -458,7 +457,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, DWORD beginofs) {
|
||||
static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
|
||||
ME_DisplayItem *p;
|
||||
ME_WrapContext wc;
|
||||
int border = 0;
|
||||
|
@ -573,28 +572,26 @@ static void ME_PrepareParagraphForWrapping(ME_Context *c, ME_DisplayItem *tp) {
|
|||
}
|
||||
}
|
||||
|
||||
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
|
||||
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
|
||||
{
|
||||
ME_DisplayItem *item;
|
||||
ME_Context c;
|
||||
BOOL bModified = FALSE;
|
||||
int yStart = -1;
|
||||
int yLastPos = 0;
|
||||
|
||||
ME_InitContext(&c, editor, GetDC(editor->hWnd));
|
||||
c.pt.x = editor->selofs;
|
||||
editor->nHeight = 0;
|
||||
c.pt.x = 0;
|
||||
item = editor->pBuffer->pFirst->next;
|
||||
while(item != editor->pBuffer->pLast) {
|
||||
BOOL bRedraw = FALSE;
|
||||
|
||||
assert(item->type == diParagraph);
|
||||
editor->nHeight = max(editor->nHeight, item->member.para.pt.y);
|
||||
if ((item->member.para.nFlags & MEPF_REWRAP)
|
||||
|| (item->member.para.pt.y != c.pt.y))
|
||||
bRedraw = TRUE;
|
||||
item->member.para.pt = c.pt;
|
||||
|
||||
ME_WrapTextParagraph(&c, item, editor->selofs);
|
||||
ME_WrapTextParagraph(&c, item);
|
||||
|
||||
if (bRedraw)
|
||||
{
|
||||
|
@ -605,8 +602,6 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
|
|||
|
||||
bModified = bModified | bRedraw;
|
||||
|
||||
yLastPos = max(yLastPos, c.pt.y);
|
||||
|
||||
if (item->member.para.nFlags & MEPF_ROWSTART)
|
||||
{
|
||||
ME_DisplayItem *cell = ME_FindItemFwd(item, diCell);
|
||||
|
@ -698,7 +693,8 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
|
|||
c.pt.x = cell->pt.x + cell->nWidth;
|
||||
c.pt.y = cell->pt.y;
|
||||
cell->next_cell->member.cell.pt = c.pt;
|
||||
c.pt.y += cell->yTextOffset;
|
||||
if (!(item->member.para.next_para->member.para.nFlags & MEPF_ROWEND))
|
||||
c.pt.y += cell->yTextOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -707,7 +703,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
|
|||
c.pt.x = item->member.para.pCell->member.cell.pt.x;
|
||||
} else {
|
||||
/* Normal paragraph */
|
||||
c.pt.x = editor->selofs;
|
||||
c.pt.x = 0;
|
||||
}
|
||||
c.pt.y += item->member.para.nHeight;
|
||||
}
|
||||
|
@ -718,18 +714,10 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
|
|||
|
||||
editor->nTotalLength = c.pt.y;
|
||||
editor->pBuffer->pLast->member.para.pt.x = 0;
|
||||
editor->pBuffer->pLast->member.para.pt.y = yLastPos;
|
||||
editor->pBuffer->pLast->member.para.pt.y = c.pt.y;
|
||||
|
||||
ME_DestroyContext(&c, editor->hWnd);
|
||||
|
||||
/* Each paragraph may contain multiple rows, which should be scrollable, even
|
||||
if the containing paragraph has pt.y == 0 */
|
||||
item = editor->pBuffer->pFirst;
|
||||
while ((item = ME_FindItemFwd(item, diStartRow)) != NULL) {
|
||||
assert(item->type == diStartRow);
|
||||
editor->nHeight = max(editor->nHeight, item->member.row.pt.y);
|
||||
}
|
||||
|
||||
if (bModified || editor->nTotalLength < editor->nLastTotalLength)
|
||||
ME_InvalidateMarkedParagraphs(editor);
|
||||
return bModified;
|
||||
|
@ -749,16 +737,18 @@ void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor)
|
|||
item = editor->pBuffer->pFirst;
|
||||
while(item != editor->pBuffer->pLast) {
|
||||
if (item->member.para.nFlags & MEPF_REPAINT) {
|
||||
rc.top = item->member.para.pt.y - ofs;
|
||||
rc.bottom = item->member.para.pt.y + item->member.para.nHeight - ofs;
|
||||
rc.top = c.rcView.top + item->member.para.pt.y - ofs;
|
||||
rc.bottom = max(c.rcView.top + item->member.para.pt.y
|
||||
+ item->member.para.nHeight - ofs,
|
||||
c.rcView.bottom);
|
||||
InvalidateRect(editor->hWnd, &rc, TRUE);
|
||||
}
|
||||
item = item->member.para.next_para;
|
||||
}
|
||||
if (editor->nTotalLength < editor->nLastTotalLength)
|
||||
{
|
||||
rc.top = editor->nTotalLength - ofs;
|
||||
rc.bottom = editor->nLastTotalLength - ofs;
|
||||
rc.top = c.rcView.top + editor->nTotalLength - ofs;
|
||||
rc.bottom = c.rcView.top + editor->nLastTotalLength - ofs;
|
||||
InvalidateRect(editor->hWnd, &rc, TRUE);
|
||||
}
|
||||
ME_DestroyContext(&c, editor->hWnd);
|
||||
|
|
|
@ -201,7 +201,7 @@ ME_StreamOutRTFFontAndColorTbl(ME_OutStream *pStream, ME_DisplayItem *pFirstRun,
|
|||
{
|
||||
ME_DisplayItem *item = pFirstRun;
|
||||
ME_FontTableItem *table = pStream->fonttbl;
|
||||
int i;
|
||||
unsigned int i;
|
||||
ME_DisplayItem *pLastPara = ME_GetParagraph(pLastRun);
|
||||
ME_DisplayItem *pCell = NULL;
|
||||
|
||||
|
@ -264,7 +264,7 @@ ME_StreamOutRTFFontAndColorTbl(ME_OutStream *pStream, ME_DisplayItem *pFirstRun,
|
|||
{
|
||||
if (borders[i]->width > 0)
|
||||
{
|
||||
int j;
|
||||
unsigned int j;
|
||||
COLORREF crColor = borders[i]->colorRef;
|
||||
for (j = 1; j < pStream->nColorTblLen; j++)
|
||||
if (pStream->colortbl[j] == crColor)
|
||||
|
@ -348,7 +348,7 @@ ME_StreamOutRTFTableProps(ME_TextEditor *editor, ME_OutStream *pStream,
|
|||
{
|
||||
if (borders[i]->width)
|
||||
{
|
||||
int j;
|
||||
unsigned int j;
|
||||
COLORREF crColor = borders[i]->colorRef;
|
||||
sprintf(props + strlen(props), "\\clbrdr%c", sideChar[i]);
|
||||
sprintf(props + strlen(props), "\\brdrs");
|
||||
|
@ -380,7 +380,7 @@ ME_StreamOutRTFTableProps(ME_TextEditor *editor, ME_OutStream *pStream,
|
|||
{
|
||||
if (borders[i]->width)
|
||||
{
|
||||
int j;
|
||||
unsigned int j;
|
||||
COLORREF crColor = borders[i]->colorRef;
|
||||
sprintf(props + strlen(props), "\\trbrdr%c", sideChar[i]);
|
||||
sprintf(props + strlen(props), "\\brdrs");
|
||||
|
@ -555,7 +555,7 @@ static BOOL
|
|||
ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt)
|
||||
{
|
||||
char props[STREAMOUT_BUFFER_SIZE] = "";
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
if (fmt->dwMask & CFM_ALLCAPS && fmt->dwEffects & CFE_ALLCAPS)
|
||||
strcat(props, "\\caps");
|
||||
|
|
Loading…
Reference in a new issue