riched20: Added support for hidden text.

This commit is contained in:
Phil Krylov 2006-01-31 13:01:26 +01:00 committed by Alexandre Julliard
parent 17a83dc3e3
commit f0d6519ef5
7 changed files with 60 additions and 31 deletions

View File

@ -434,34 +434,37 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
static BOOL
ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
{
ME_DisplayItem *pRun;
ME_DisplayItem *pRun = pCursor->pRun;
if (nRelOfs == -1)
{
if (!pCursor->nOffset)
{
pRun = ME_FindItemBack(pCursor->pRun, diRunOrParagraph);
assert(pRun);
switch (pRun->type)
{
case diRun:
pCursor->pRun = pRun;
pCursor->nOffset = pRun->member.run.strText->nLen;
break;
case diParagraph:
if (pRun->member.para.prev_para->type == diTextStart)
do {
pRun = ME_FindItemBack(pRun, diRunOrParagraph);
assert(pRun);
switch (pRun->type)
{
case diRun:
break;
case diParagraph:
if (pRun->member.para.prev_para->type == diTextStart)
return FALSE;
pRun = ME_FindItemBack(pRun, diRunOrParagraph);
/* every paragraph ought to have at least one run */
assert(pRun && pRun->type == diRun);
assert(pRun->member.run.nFlags & MERF_ENDPARA);
break;
default:
assert(pRun->type != diRun && pRun->type != diParagraph);
return FALSE;
pRun = ME_FindItemBack(pRun, diRunOrParagraph);
/* every paragraph ought to have at least one run */
assert(pRun && pRun->type == diRun);
assert(pRun->member.run.nFlags & MERF_ENDPARA);
pCursor->pRun = pRun;
pCursor->nOffset = 0;
break;
default:
assert(pRun->type != diRun && pRun->type != diParagraph);
return FALSE;
}
}
} while (RUN_IS_HIDDEN(&pRun->member.run));
pCursor->pRun = pRun;
if (pRun->member.run.nFlags & MERF_ENDPARA)
pCursor->nOffset = 0;
else
pCursor->nOffset = pRun->member.run.strText->nLen;
}
if (pCursor->nOffset)
@ -470,17 +473,19 @@ ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
}
else
{
if (!(pCursor->pRun->member.run.nFlags & MERF_ENDPARA))
if (!(pRun->member.run.nFlags & MERF_ENDPARA))
{
int new_ofs = ME_StrRelPos2(pCursor->pRun->member.run.strText, pCursor->nOffset, nRelOfs);
int new_ofs = ME_StrRelPos2(pRun->member.run.strText, pCursor->nOffset, nRelOfs);
if (new_ofs < pCursor->pRun->member.run.strText->nLen)
if (new_ofs < pRun->member.run.strText->nLen)
{
pCursor->nOffset = new_ofs;
return TRUE;
}
}
pRun = ME_FindItemFwd(pCursor->pRun, diRun);
do {
pRun = ME_FindItemFwd(pRun, diRun);
} while (pRun && RUN_IS_HIDDEN(&pRun->member.run));
if (pRun)
{
pCursor->pRun = pRun;

View File

@ -350,6 +350,10 @@ static void ME_RTFCharAttrHook(RTF_Info *info)
if (info->rtfMinor == rtfSuperScrShrink) fmt.dwEffects = CFE_SUPERSCRIPT;
if (info->rtfMinor == rtfNoSuperSub) fmt.dwEffects = 0;
break;
case rtfInvisible:
fmt.dwMask = CFM_HIDDEN;
fmt.dwEffects = info->rtfParam ? fmt.dwMask : 0;
break;
case rtfBackColor:
fmt.dwMask = CFM_BACKCOLOR;
fmt.dwEffects = 0;

View File

@ -24,6 +24,9 @@
#define ALLOC_N_OBJ(type, count) HeapAlloc(me_heap, 0, (count)*sizeof(type))
#define FREE_OBJ(ptr) HeapFree(me_heap, 0, ptr)
#define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \
&& (run)->style->fmt.dwEffects & CFE_HIDDEN)
/* style.c */
ME_Style *ME_MakeStyle(CHARFORMAT2W *style);
void ME_AddRefStyle(ME_Style *item);

View File

@ -103,6 +103,8 @@ typedef enum {
#define MERF_CALCBYWRAP 0x0F0000
/* the "end of paragraph" run, contains 1 character */
#define MERF_ENDPARA 0x100000
/* run is hidden */
#define MERF_HIDDEN 0x200000
/* runs with any of these flags set cannot be joined */
#define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)

View File

@ -226,6 +226,9 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
int nSelFrom, nSelTo;
const WCHAR wszSpace[] = {' ', 0};
if (run->nFlags & MERF_HIDDEN)
return;
ME_GetSelection(c->editor, &nSelFrom, &nSelTo);
/* Draw selected end-of-paragraph mark */

View File

@ -340,6 +340,12 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
{
assert(run->nCharOfs != -1);
if (RUN_IS_HIDDEN(run))
run->nFlags |= MERF_HIDDEN;
else
run->nFlags &= ~MERF_HIDDEN;
if (ME_IsSplitable(run->strText))
run->nFlags |= MERF_SPLITTABLE;
else
@ -539,11 +545,16 @@ SIZE ME_GetRunSize(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen)
void ME_CalcRunExtent(ME_Context *c, ME_Paragraph *para, ME_Run *run)
{
int nEnd = ME_StrVLen(run->strText);
SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, &run->nAscent, &run->nDescent);
run->nWidth = size.cx;
if (!size.cx)
WARN("size.cx == 0\n");
if (run->nFlags & MERF_HIDDEN)
run->nWidth = 0;
else
{
int nEnd = ME_StrVLen(run->strText);
SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, &run->nAscent, &run->nDescent);
run->nWidth = size.cx;
if (!size.cx)
WARN("size.cx == 0\n");
}
}
void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para)

View File

@ -237,6 +237,7 @@ void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048])
ME_DumpStyleEffect(&p, "Font italic:", pFmt, CFM_ITALIC);
ME_DumpStyleEffect(&p, "Font underline:", pFmt, CFM_UNDERLINE);
ME_DumpStyleEffect(&p, "Font strikeout:", pFmt, CFM_STRIKEOUT);
ME_DumpStyleEffect(&p, "Hidden text:", pFmt, CFM_HIDDEN);
p += sprintf(p, "Text color: ");
if (pFmt->dwMask & CFM_COLOR)
{