richedit: Simplify first para style handling by creating a context.
This commit is contained in:
parent
d5478118a1
commit
39aa3beaf2
|
@ -1159,14 +1159,12 @@ static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
|
|||
|
||||
ME_TextEditor *ME_MakeEditor(HWND hWnd) {
|
||||
ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor);
|
||||
HDC hDC;
|
||||
int i;
|
||||
ed->hWnd = hWnd;
|
||||
ed->bEmulateVersion10 = FALSE;
|
||||
ed->pBuffer = ME_MakeText();
|
||||
hDC = GetDC(hWnd);
|
||||
ME_MakeFirstParagraph(hDC, ed->pBuffer);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
ed->nZoomNumerator = ed->nZoomDenominator = 0;
|
||||
ME_MakeFirstParagraph(ed);
|
||||
ed->bCaretShown = FALSE;
|
||||
ed->nCursors = 4;
|
||||
ed->pCursors = ALLOC_N_OBJ(ME_Cursor, ed->nCursors);
|
||||
|
@ -1191,7 +1189,6 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
|
|||
ed->nParagraphs = 1;
|
||||
ed->nLastSelStart = ed->nLastSelEnd = 0;
|
||||
ed->pLastSelStartPara = ed->pLastSelEndPara = ME_FindItemFwd(ed->pBuffer->pFirst, diParagraph);
|
||||
ed->nZoomNumerator = ed->nZoomDenominator = 0;
|
||||
ed->bRedraw = TRUE;
|
||||
ed->bHideSelection = FALSE;
|
||||
ed->nInvalidOfs = -1;
|
||||
|
|
|
@ -219,7 +219,7 @@ int ME_twips2pointsY(ME_Context *c, int y);
|
|||
/* para.c */
|
||||
ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run);
|
||||
void ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end);
|
||||
void ME_MakeFirstParagraph(HDC hDC, ME_TextBuffer *editor);
|
||||
void ME_MakeFirstParagraph(ME_TextEditor *editor);
|
||||
ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *rp, ME_Style *style);
|
||||
ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp);
|
||||
void ME_DumpParaStyle(ME_Paragraph *s);
|
||||
|
|
|
@ -25,16 +25,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit);
|
|||
|
||||
static const WCHAR wszParagraphSign[] = {0xB6, 0};
|
||||
|
||||
void ME_MakeFirstParagraph(HDC hDC, ME_TextBuffer *text)
|
||||
void ME_MakeFirstParagraph(ME_TextEditor *editor)
|
||||
{
|
||||
ME_Context c;
|
||||
HDC hDC;
|
||||
PARAFORMAT2 fmt;
|
||||
CHARFORMAT2W cf;
|
||||
LOGFONTW lf;
|
||||
HFONT hf;
|
||||
ME_TextBuffer *text = editor->pBuffer;
|
||||
ME_DisplayItem *para = ME_MakeDI(diParagraph);
|
||||
ME_DisplayItem *run;
|
||||
ME_Style *style;
|
||||
|
||||
hDC = GetDC(editor->hWnd);
|
||||
|
||||
ME_InitContext(&c, editor, hDC);
|
||||
hf = (HFONT)GetStockObject(SYSTEM_FONT);
|
||||
assert(hf);
|
||||
GetObjectW(hf, sizeof(LOGFONTW), &lf);
|
||||
|
@ -48,9 +54,8 @@ void ME_MakeFirstParagraph(HDC hDC, ME_TextBuffer *text)
|
|||
|
||||
cf.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
|
||||
lstrcpyW(cf.szFaceName, lf.lfFaceName);
|
||||
cf.yHeight=lf.lfHeight*1440/GetDeviceCaps(hDC, LOGPIXELSY);
|
||||
if (lf.lfWeight>=700) /* FIXME correct weight ? */
|
||||
cf.dwEffects |= CFE_BOLD;
|
||||
cf.yHeight = ME_twips2pointsY(&c, lf.lfHeight);
|
||||
if (lf.lfWeight >= 700) cf.dwEffects |= CFE_BOLD;
|
||||
cf.wWeight = lf.lfWeight;
|
||||
if (lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
|
||||
cf.bUnderlineType = (lf.lfUnderline) ? CFU_CF1UNDERLINE : CFU_UNDERLINENONE;
|
||||
|
@ -79,6 +84,9 @@ void ME_MakeFirstParagraph(HDC hDC, ME_TextBuffer *text)
|
|||
text->pLast->member.para.prev_para = para;
|
||||
|
||||
text->pLast->member.para.nCharOfs = 1;
|
||||
|
||||
ME_DestroyContext(&c);
|
||||
ReleaseDC(editor->hWnd, hDC);
|
||||
}
|
||||
|
||||
void ME_MarkAllForWrapping(ME_TextEditor *editor)
|
||||
|
|
Loading…
Reference in New Issue