richedit: Optimizations for the style selection.
Use a ME_Context for style selection/unselection. Store the (x,y) dpi information for a given DC in the corresponding ME_Context structure.
This commit is contained in:
parent
475b45d8ab
commit
f43570cbf0
|
@ -29,6 +29,8 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
|
|||
c->pt.y = 0;
|
||||
c->hbrMargin = CreateSolidBrush(RGB(224,224,224));
|
||||
c->rcView = editor->rcFormat;
|
||||
c->dpi.cx = GetDeviceCaps(hDC, LOGPIXELSX);
|
||||
c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY);
|
||||
}
|
||||
|
||||
void ME_DestroyContext(ME_Context *c)
|
||||
|
|
|
@ -60,8 +60,8 @@ void ME_AddRefStyle(ME_Style *item);
|
|||
void ME_ReleaseStyle(ME_Style *item);
|
||||
ME_Style *ME_GetInsertStyle(ME_TextEditor *editor, int nCursor);
|
||||
ME_Style *ME_ApplyStyle(ME_Style *sSrc, CHARFORMAT2W *style);
|
||||
HFONT ME_SelectStyleFont(ME_TextEditor *editor, HDC hDC, ME_Style *s);
|
||||
void ME_UnselectStyleFont(ME_TextEditor *editor, HDC hDC, ME_Style *s, HFONT hOldFont);
|
||||
HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s);
|
||||
void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont);
|
||||
void ME_InitCharFormat2W(CHARFORMAT2W *pFmt);
|
||||
void ME_SaveTempStyle(ME_TextEditor *editor);
|
||||
void ME_ClearTempStyle(ME_TextEditor *editor);
|
||||
|
@ -213,7 +213,8 @@ BOOL ME_UpdateSelection(ME_TextEditor *editor, const ME_Cursor *pTempCursor);
|
|||
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor);
|
||||
void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor);
|
||||
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force);
|
||||
int ME_twips2points(ME_Context *c, int x, int dpi);
|
||||
int ME_twips2pointsX(ME_Context *c, int x);
|
||||
int ME_twips2pointsY(ME_Context *c, int y);
|
||||
|
||||
/* para.c */
|
||||
ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run);
|
||||
|
@ -255,7 +256,7 @@ BOOL ME_GetYScrollVisible(ME_TextEditor *editor);
|
|||
|
||||
/* other functions in paint.c */
|
||||
int ME_GetParaBorderWidth(ME_TextEditor *editor, int);
|
||||
int ME_GetParaLineSpace(ME_TextEditor *editor, ME_Paragraph*, int);
|
||||
int ME_GetParaLineSpace(ME_Context *c, ME_Paragraph*);
|
||||
|
||||
/* richole.c */
|
||||
extern LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *);
|
||||
|
|
|
@ -334,6 +334,7 @@ typedef struct tagME_Context
|
|||
POINT ptRowOffset;
|
||||
RECT rcView;
|
||||
HBRUSH hbrMargin;
|
||||
SIZE dpi;
|
||||
|
||||
/* those are valid inside ME_WrapTextParagraph and related */
|
||||
POINT ptFirstRun;
|
||||
|
|
|
@ -141,12 +141,20 @@ ME_RewrapRepaint(ME_TextEditor *editor)
|
|||
ME_Repaint(editor);
|
||||
}
|
||||
|
||||
int ME_twips2points(ME_Context *c, int x, int dpi)
|
||||
int ME_twips2pointsX(ME_Context *c, int x)
|
||||
{
|
||||
if (c->editor->nZoomNumerator == 0)
|
||||
return x * dpi / 1440;
|
||||
return x * c->dpi.cx / 1440;
|
||||
else
|
||||
return x * dpi * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
|
||||
return x * c->dpi.cx * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
|
||||
}
|
||||
|
||||
int ME_twips2pointsY(ME_Context *c, int y)
|
||||
{
|
||||
if (c->editor->nZoomNumerator == 0)
|
||||
return y * c->dpi.cy / 1440;
|
||||
else
|
||||
return y * c->dpi.cy * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
|
||||
}
|
||||
|
||||
static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, int nChars,
|
||||
|
@ -158,7 +166,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in
|
|||
SIZE sz;
|
||||
COLORREF rgb;
|
||||
|
||||
hOldFont = ME_SelectStyleFont(c->editor, hDC, s);
|
||||
hOldFont = ME_SelectStyleFont(c, s);
|
||||
if ((s->fmt.dwMask & CFM_LINK) && (s->fmt.dwEffects & CFE_LINK))
|
||||
rgb = RGB(0,0,255);
|
||||
else if ((s->fmt.dwMask & CFM_COLOR) && (s->fmt.dwEffects & CFE_AUTOCOLOR))
|
||||
|
@ -174,8 +182,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in
|
|||
if (s->fmt.dwEffects & CFE_SUBSCRIPT) yTwipsOffset = -s->fmt.yHeight/12;
|
||||
}
|
||||
if (yTwipsOffset)
|
||||
yOffset = ME_twips2points(c, yTwipsOffset, GetDeviceCaps(hDC, LOGPIXELSY));
|
||||
|
||||
yOffset = ME_twips2pointsY(c, yTwipsOffset);
|
||||
ExtTextOutW(hDC, x, y-yOffset, 0, NULL, szText, nChars, NULL);
|
||||
GetTextExtentPoint32W(hDC, szText, nChars, &sz);
|
||||
if (width) *width = sz.cx;
|
||||
|
@ -223,7 +230,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in
|
|||
PatBlt(hDC, x, ymin, sz.cx, cy, DSTINVERT);
|
||||
}
|
||||
SetTextColor(hDC, rgbOld);
|
||||
ME_UnselectStyleFont(c->editor, hDC, s, hOldFont);
|
||||
ME_UnselectStyleFont(c, s, hOldFont);
|
||||
}
|
||||
|
||||
static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText) {
|
||||
|
@ -366,7 +373,7 @@ int ME_GetParaBorderWidth(ME_TextEditor* editor, int flags)
|
|||
return width;
|
||||
}
|
||||
|
||||
int ME_GetParaLineSpace(ME_TextEditor* editor, ME_Paragraph* para, int dpi)
|
||||
int ME_GetParaLineSpace(ME_Context* c, ME_Paragraph* para)
|
||||
{
|
||||
int sp = 0, ls = 0;
|
||||
if (!(para->pFmt->dwMask & PFM_LINESPACING)) return 0;
|
||||
|
@ -378,18 +385,18 @@ int ME_GetParaLineSpace(ME_TextEditor* editor, ME_Paragraph* para, int dpi)
|
|||
case 0: sp = ls; break;
|
||||
case 1: sp = (3 * ls) / 2; break;
|
||||
case 2: sp = 2 * ls; break;
|
||||
case 3: sp = para->pFmt->dyLineSpacing * dpi / 1440; if (sp < ls) sp = ls; break;
|
||||
case 4: sp = para->pFmt->dyLineSpacing * dpi / 1440; break;
|
||||
case 3: sp = ME_twips2pointsY(c, para->pFmt->dyLineSpacing); if (sp < ls) sp = ls; break;
|
||||
case 4: sp = ME_twips2pointsY(c, para->pFmt->dyLineSpacing); break;
|
||||
case 5: sp = para->pFmt->dyLineSpacing / 20; break;
|
||||
default: FIXME("Unsupported spacing rule value %d\n", para->pFmt->bLineSpacingRule);
|
||||
}
|
||||
if (editor->nZoomNumerator == 0)
|
||||
if (c->editor->nZoomNumerator == 0)
|
||||
return sp;
|
||||
else
|
||||
return sp * editor->nZoomNumerator / editor->nZoomDenominator;
|
||||
return sp * c->editor->nZoomNumerator / c->editor->nZoomDenominator;
|
||||
}
|
||||
|
||||
static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int dpi)
|
||||
static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y)
|
||||
{
|
||||
int idx, border_width;
|
||||
int ybefore, yafter;
|
||||
|
@ -402,7 +409,7 @@ static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int d
|
|||
rc.left = c->rcView.left;
|
||||
rc.right = c->rcView.right;
|
||||
rc.top = y;
|
||||
ybefore = ME_twips2points(c, para->pFmt->dySpaceBefore, dpi);
|
||||
ybefore = ME_twips2pointsY(c, para->pFmt->dySpaceBefore);
|
||||
rc.bottom = y + ybefore;
|
||||
FillRect(c->hDC, &rc, c->editor->hbrBackground);
|
||||
}
|
||||
|
@ -412,7 +419,7 @@ static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int d
|
|||
rc.left = c->rcView.left;
|
||||
rc.right = c->rcView.right;
|
||||
rc.bottom = y + para->nHeight;
|
||||
yafter = ME_twips2points(c, para->pFmt->dySpaceAfter, dpi);
|
||||
yafter = ME_twips2pointsY(c, para->pFmt->dySpaceAfter);
|
||||
rc.top = rc.bottom - yafter;
|
||||
FillRect(c->hDC, &rc, c->editor->hbrBackground);
|
||||
}
|
||||
|
@ -489,7 +496,6 @@ static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int d
|
|||
|
||||
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
|
||||
int align = SetTextAlign(c->hDC, TA_BASELINE);
|
||||
int dpi = GetDeviceCaps(c->hDC, LOGPIXELSX);
|
||||
ME_DisplayItem *p;
|
||||
ME_Run *run;
|
||||
ME_Paragraph *para = NULL;
|
||||
|
@ -508,12 +514,12 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
|
|||
case diParagraph:
|
||||
para = &p->member.para;
|
||||
assert(para);
|
||||
nMargWidth = ME_twips2points(c, para->pFmt->dxStartIndent, dpi);
|
||||
nMargWidth = ME_twips2pointsX(c, para->pFmt->dxStartIndent);
|
||||
if (pno != 0)
|
||||
nMargWidth += ME_twips2points(c, para->pFmt->dxOffset, dpi);
|
||||
nMargWidth += ME_twips2pointsX(c, para->pFmt->dxOffset);
|
||||
xs = c->rcView.left+nMargWidth;
|
||||
xe = c->rcView.right - ME_twips2points(c, para->pFmt->dxRightIndent, dpi);
|
||||
y += ME_DrawParaDecoration(c, para, y, dpi);
|
||||
xe = c->rcView.right - ME_twips2pointsX(c, para->pFmt->dxRightIndent);
|
||||
y += ME_DrawParaDecoration(c, para, y);
|
||||
break;
|
||||
case diStartRow:
|
||||
y += height;
|
||||
|
|
|
@ -509,7 +509,7 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
|
|||
return 0;
|
||||
return 1;
|
||||
}
|
||||
hOldFont = ME_SelectStyleFont(c->editor, c->hDC, run->style);
|
||||
hOldFont = ME_SelectStyleFont(c, run->style);
|
||||
|
||||
if (c->editor->cPasswordMask)
|
||||
{
|
||||
|
@ -524,7 +524,7 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
|
|||
cx, &fit, NULL, &sz);
|
||||
}
|
||||
|
||||
ME_UnselectStyleFont(c->editor, c->hDC, run->style, hOldFont);
|
||||
ME_UnselectStyleFont(c, run->style, hOldFont);
|
||||
|
||||
return fit;
|
||||
}
|
||||
|
@ -546,8 +546,8 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
|
|||
/* This could point to either the run's real text, or it's masked form in a password control */
|
||||
|
||||
int fit = 0, fit1 = 0;
|
||||
ME_Context c;
|
||||
HGDIOBJ hOldFont;
|
||||
HDC hDC;
|
||||
SIZE sz, sz2, sz3;
|
||||
if (!run->strText->nLen)
|
||||
return 0;
|
||||
|
@ -572,17 +572,17 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
|
|||
else
|
||||
strRunText = run->strText;
|
||||
|
||||
hDC = GetDC(editor->hWnd);
|
||||
hOldFont = ME_SelectStyleFont(editor, hDC, run->style);
|
||||
GetTextExtentExPointW(hDC, strRunText->szData, strRunText->nLen,
|
||||
ME_InitContext(&c, editor, GetDC(editor->hWnd));
|
||||
hOldFont = ME_SelectStyleFont(&c, run->style);
|
||||
GetTextExtentExPointW(c.hDC, strRunText->szData, strRunText->nLen,
|
||||
cx, &fit, NULL, &sz);
|
||||
if (fit != strRunText->nLen)
|
||||
{
|
||||
int chars = 1;
|
||||
|
||||
GetTextExtentPoint32W(hDC, strRunText->szData, fit, &sz2);
|
||||
GetTextExtentPoint32W(c.hDC, strRunText->szData, fit, &sz2);
|
||||
fit1 = ME_StrRelPos(strRunText, fit, &chars);
|
||||
GetTextExtentPoint32W(hDC, strRunText->szData, fit1, &sz3);
|
||||
GetTextExtentPoint32W(c.hDC, strRunText->szData, fit1, &sz3);
|
||||
if (cx >= (sz2.cx+sz3.cx)/2)
|
||||
fit = fit1;
|
||||
}
|
||||
|
@ -590,11 +590,24 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
|
|||
if (editor->cPasswordMask)
|
||||
ME_DestroyString(strRunText);
|
||||
|
||||
ME_UnselectStyleFont(editor, hDC, run->style, hOldFont);
|
||||
ReleaseDC(editor->hWnd, hDC);
|
||||
ME_UnselectStyleFont(&c, run->style, hOldFont);
|
||||
ReleaseDC(editor->hWnd, c.hDC);
|
||||
return fit;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* ME_GetTextExtent
|
||||
*
|
||||
* Finds a width and a height of the text using a specified style
|
||||
*/
|
||||
static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE *size)
|
||||
{
|
||||
HGDIOBJ hOldFont;
|
||||
hOldFont = ME_SelectStyleFont(c, s);
|
||||
GetTextExtentPoint32W(c->hDC, szText, nChars, size);
|
||||
ME_UnselectStyleFont(c, s, hOldFont);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* ME_PointFromChar
|
||||
*
|
||||
|
@ -604,8 +617,7 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
|
|||
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
|
||||
{
|
||||
SIZE size;
|
||||
HDC hDC;
|
||||
HGDIOBJ hOldFont;
|
||||
ME_Context c;
|
||||
ME_String *strRunText;
|
||||
/* This could point to either the run's real text, or it's masked form in a password control */
|
||||
|
||||
|
@ -621,30 +633,14 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
|
|||
else
|
||||
strRunText = pRun->strText;
|
||||
|
||||
hDC = GetDC(editor->hWnd);
|
||||
hOldFont = ME_SelectStyleFont(editor, hDC, pRun->style);
|
||||
GetTextExtentPoint32W(hDC, strRunText->szData, nOffset, &size);
|
||||
ME_UnselectStyleFont(editor, hDC, pRun->style, hOldFont);
|
||||
ReleaseDC(editor->hWnd, hDC);
|
||||
ME_InitContext(&c, editor, GetDC(editor->hWnd));
|
||||
ME_GetTextExtent(&c, strRunText->szData, nOffset, pRun->style, &size);
|
||||
ReleaseDC(editor->hWnd, c.hDC);
|
||||
if (editor->cPasswordMask)
|
||||
ME_DestroyString(strRunText);
|
||||
return size.cx;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* ME_GetTextExtent
|
||||
*
|
||||
* Finds a width and a height of the text using a specified style
|
||||
*/
|
||||
static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE *size)
|
||||
{
|
||||
HDC hDC = c->hDC;
|
||||
HGDIOBJ hOldFont;
|
||||
hOldFont = ME_SelectStyleFont(c->editor, hDC, s);
|
||||
GetTextExtentPoint32W(hDC, szText, nChars, size);
|
||||
ME_UnselectStyleFont(c->editor, hDC, s, hOldFont);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* ME_GetRunSizeCommon
|
||||
*
|
||||
|
@ -682,7 +678,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run
|
|||
if (run->nFlags & MERF_TAB)
|
||||
{
|
||||
int pos = 0, i = 0, ppos;
|
||||
int lpsx = GetDeviceCaps(c->hDC, LOGPIXELSX);
|
||||
|
||||
PARAFORMAT2 *pFmt = para->pFmt;
|
||||
do {
|
||||
if (i < pFmt->cTabCount)
|
||||
|
@ -694,7 +690,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run
|
|||
{
|
||||
pos += 720-(pos%720);
|
||||
}
|
||||
ppos = pos*lpsx/1440;
|
||||
ppos = ME_twips2pointsX(c, pos);
|
||||
if (ppos>run->pt.x) {
|
||||
size.cx = ppos - run->pt.x;
|
||||
break;
|
||||
|
@ -713,9 +709,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run
|
|||
}
|
||||
if (run->nFlags & MERF_CELL)
|
||||
{
|
||||
int lpsx = GetDeviceCaps(c->hDC, LOGPIXELSX);
|
||||
|
||||
size.cx = run->pCell->nRightBoundary * lpsx / 1440 - run->pt.x;
|
||||
size.cx = ME_twips2pointsX(c, run->pCell->nRightBoundary) - run->pt.x;
|
||||
return size;
|
||||
}
|
||||
return size;
|
||||
|
|
|
@ -297,20 +297,12 @@ void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048])
|
|||
|
||||
|
||||
static void
|
||||
ME_LogFontFromStyle(HDC hDC, LOGFONTW *lf, const ME_Style *s, int nZoomNumerator, int nZoomDenominator)
|
||||
ME_LogFontFromStyle(ME_Context* c, LOGFONTW *lf, const ME_Style *s)
|
||||
{
|
||||
int rx, ry;
|
||||
rx = GetDeviceCaps(hDC, LOGPIXELSX);
|
||||
ry = GetDeviceCaps(hDC, LOGPIXELSY);
|
||||
ZeroMemory(lf, sizeof(LOGFONTW));
|
||||
lstrcpyW(lf->lfFaceName, s->fmt.szFaceName);
|
||||
|
||||
if (nZoomNumerator == 0)
|
||||
{
|
||||
nZoomNumerator = 1;
|
||||
nZoomDenominator = 1;
|
||||
}
|
||||
lf->lfHeight = -s->fmt.yHeight*ry*nZoomNumerator/nZoomDenominator/1440;
|
||||
lf->lfHeight = ME_twips2pointsY(c, -s->fmt.yHeight);
|
||||
|
||||
lf->lfWeight = 400;
|
||||
if (s->fmt.dwEffects & s->fmt.dwMask & CFM_BOLD)
|
||||
|
@ -363,22 +355,22 @@ static BOOL ME_IsFontEqual(const LOGFONTW *p1, const LOGFONTW *p2)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
HFONT ME_SelectStyleFont(ME_TextEditor *editor, HDC hDC, ME_Style *s)
|
||||
HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s)
|
||||
{
|
||||
HFONT hOldFont;
|
||||
LOGFONTW lf;
|
||||
int i, nEmpty, nAge = 0x7FFFFFFF;
|
||||
ME_FontCacheItem *item;
|
||||
assert(hDC);
|
||||
assert(c->hDC);
|
||||
assert(s);
|
||||
|
||||
ME_LogFontFromStyle(hDC, &lf, s, editor->nZoomNumerator, editor->nZoomDenominator);
|
||||
ME_LogFontFromStyle(c, &lf, s);
|
||||
|
||||
for (i=0; i<HFONT_CACHE_SIZE; i++)
|
||||
editor->pFontCache[i].nAge++;
|
||||
c->editor->pFontCache[i].nAge++;
|
||||
for (i=0, nEmpty=-1, nAge=0; i<HFONT_CACHE_SIZE; i++)
|
||||
{
|
||||
item = &editor->pFontCache[i];
|
||||
item = &c->editor->pFontCache[i];
|
||||
if (!item->nRefs)
|
||||
{
|
||||
if (item->nAge > nAge)
|
||||
|
@ -389,7 +381,7 @@ HFONT ME_SelectStyleFont(ME_TextEditor *editor, HDC hDC, ME_Style *s)
|
|||
}
|
||||
if (i < HFONT_CACHE_SIZE) /* found */
|
||||
{
|
||||
item = &editor->pFontCache[i];
|
||||
item = &c->editor->pFontCache[i];
|
||||
TRACE_(richedit_style)("font reused %d\n", i);
|
||||
|
||||
s->hFont = item->hFont;
|
||||
|
@ -397,7 +389,7 @@ HFONT ME_SelectStyleFont(ME_TextEditor *editor, HDC hDC, ME_Style *s)
|
|||
}
|
||||
else
|
||||
{
|
||||
item = &editor->pFontCache[nEmpty]; /* this legal even when nEmpty == -1, as we don't dereference it */
|
||||
item = &c->editor->pFontCache[nEmpty]; /* this legal even when nEmpty == -1, as we don't dereference it */
|
||||
|
||||
assert(nEmpty != -1); /* otherwise we leak cache entries or get too many fonts at once*/
|
||||
if (item->hFont) {
|
||||
|
@ -412,22 +404,22 @@ HFONT ME_SelectStyleFont(ME_TextEditor *editor, HDC hDC, ME_Style *s)
|
|||
item->nRefs = 1;
|
||||
memcpy(&item->lfSpecs, &lf, sizeof(LOGFONTW));
|
||||
}
|
||||
hOldFont = SelectObject(hDC, s->hFont);
|
||||
hOldFont = SelectObject(c->hDC, s->hFont);
|
||||
/* should be cached too, maybe ? */
|
||||
GetTextMetricsW(hDC, &s->tm);
|
||||
GetTextMetricsW(c->hDC, &s->tm);
|
||||
return hOldFont;
|
||||
}
|
||||
|
||||
void ME_UnselectStyleFont(ME_TextEditor *editor, HDC hDC, ME_Style *s, HFONT hOldFont)
|
||||
void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(hDC);
|
||||
assert(c->hDC);
|
||||
assert(s);
|
||||
SelectObject(hDC, hOldFont);
|
||||
SelectObject(c->hDC, hOldFont);
|
||||
for (i=0; i<HFONT_CACHE_SIZE; i++)
|
||||
{
|
||||
ME_FontCacheItem *pItem = &editor->pFontCache[i];
|
||||
ME_FontCacheItem *pItem = &c->editor->pFontCache[i];
|
||||
if (pItem->hFont == s->hFont && pItem->nRefs > 0)
|
||||
{
|
||||
pItem->nRefs--;
|
||||
|
|
|
@ -341,7 +341,6 @@ static void ME_PrepareParagraphForWrapping(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;
|
||||
int border = 0;
|
||||
int linespace = 0;
|
||||
|
||||
|
@ -351,18 +350,17 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
|
|||
}
|
||||
ME_PrepareParagraphForWrapping(c, tp);
|
||||
|
||||
dpi = GetDeviceCaps(c->hDC, LOGPIXELSX);
|
||||
wc.context = c;
|
||||
/* wc.para_style = tp->member.para.style; */
|
||||
wc.style = NULL;
|
||||
wc.nFirstMargin = ME_twips2points(c, tp->member.para.pFmt->dxStartIndent, dpi) + beginofs;
|
||||
wc.nLeftMargin = wc.nFirstMargin + ME_twips2points(c, tp->member.para.pFmt->dxOffset, dpi) + beginofs;
|
||||
wc.nRightMargin = ME_twips2points(c, tp->member.para.pFmt->dxRightIndent, dpi);
|
||||
wc.nFirstMargin = ME_twips2pointsX(c, tp->member.para.pFmt->dxStartIndent) + beginofs;
|
||||
wc.nLeftMargin = wc.nFirstMargin + ME_twips2pointsX(c, tp->member.para.pFmt->dxOffset) + beginofs;
|
||||
wc.nRightMargin = ME_twips2pointsX(c, tp->member.para.pFmt->dxRightIndent);
|
||||
wc.nRow = 0;
|
||||
wc.pt.x = 0;
|
||||
wc.pt.y = 0;
|
||||
if (tp->member.para.pFmt->dwMask & PFM_SPACEBEFORE)
|
||||
wc.pt.y += ME_twips2points(c, tp->member.para.pFmt->dySpaceBefore, dpi);
|
||||
wc.pt.y += ME_twips2pointsY(c, tp->member.para.pFmt->dySpaceBefore);
|
||||
if (tp->member.para.pFmt->dwMask & PFM_BORDER)
|
||||
{
|
||||
border = ME_GetParaBorderWidth(c->editor, tp->member.para.pFmt->wBorders);
|
||||
|
@ -380,7 +378,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
|
|||
wc.nAvailWidth = wc.nTotalWidth - wc.nFirstMargin - wc.nRightMargin;
|
||||
wc.pRowStart = NULL;
|
||||
|
||||
linespace = ME_GetParaLineSpace(c->editor, &tp->member.para, dpi);
|
||||
linespace = ME_GetParaLineSpace(c, &tp->member.para);
|
||||
|
||||
ME_BeginRow(&wc);
|
||||
for (p = tp->next; p!=tp->member.para.next_para; ) {
|
||||
|
@ -396,7 +394,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
|
|||
if ((tp->member.para.pFmt->dwMask & PFM_BORDER) && (tp->member.para.pFmt->wBorders & 8))
|
||||
wc.pt.y += border;
|
||||
if (tp->member.para.pFmt->dwMask & PFM_SPACEAFTER)
|
||||
wc.pt.y += ME_twips2points(c, tp->member.para.pFmt->dySpaceAfter, dpi);
|
||||
wc.pt.y += ME_twips2pointsY(c, tp->member.para.pFmt->dySpaceAfter);
|
||||
|
||||
tp->member.para.nFlags &= ~MEPF_REWRAP;
|
||||
tp->member.para.nHeight = wc.pt.y;
|
||||
|
|
Loading…
Reference in New Issue