Commit 39aa3bea authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

richedit: Simplify first para style handling by creating a context.

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