Module: wine Branch: master Commit: 39aa3beaf286a30c66743f24599c8bc652f49b31 URL: http://source.winehq.org/git/wine.git/?a=commit;h=39aa3beaf286a30c66743f2459...
Author: Eric Pouech eric.pouech@orange.fr Date: Tue Jan 1 22:05:46 2008 +0100
richedit: Simplify first para style handling by creating a context.
---
dlls/riched20/editor.c | 7 ++----- dlls/riched20/editor.h | 2 +- dlls/riched20/para.c | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index bbc5622..a9948b2 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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; diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 8e99175..145dc91 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -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); diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 3b2750b..af292f1 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -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)