예제 #1
0
HtmlFormatterArgs* CreateFormatterDefaultArgs(int dx, int dy, Allocator* textAllocator) {
    HtmlFormatterArgs* args = new HtmlFormatterArgs();
    args->SetFontName(L"Georgia");
    args->fontSize = 12.5f;
    args->pageDx = (REAL)dx;
    args->pageDy = (REAL)dy;
    args->textAllocator = textAllocator;
    args->textRenderMethod = GetTextRenderMethod();
    return args;
}
예제 #2
0
void PageControl::Paint(Graphics *gfx, int offX, int offY)
{
    CrashIf(!IsVisible());

    Timer timerAll;

    CachedStyle *s = cachedStyle;
    Timer timerFill;
    Rect r(offX, offY, pos.Width, pos.Height);
    if (!s->bgColor->IsTransparent()) {
        Brush *br = BrushFromColorData(s->bgColor, r);
        gfx->FillRectangle(br, r);
    }
    double durFill = timerFill.Stop();

    if (!page)
        return;

    // during resize the page we currently show might be bigger than
    // our area. To avoid drawing outside our area we clip
    Region origClipRegion;
    gfx->GetClip(&origClipRegion);
    r.X += s->padding.left;
    r.Y += s->padding.top;
    r.Width  -= (s->padding.left + s->padding.right);
    r.Height -= (s->padding.top  + s->padding.bottom);
    r.Inflate(1,0);
    gfx->SetClip(r, CombineModeReplace);

    Color textColor;
    if (gGlobalPrefs->useSysColors)
        textColor.SetFromCOLORREF(GetSysColor(COLOR_WINDOWTEXT));
    else
        textColor.SetFromCOLORREF(gGlobalPrefs->ebookUI.textColor);

    ITextRender *textRender = CreateTextRender(GetTextRenderMethod(), gfx);

    Color bgCol;
    if (gGlobalPrefs->useSysColors)
        bgCol.SetFromCOLORREF(GetSysColor(COLOR_WINDOW));
    else
        bgCol.SetFromCOLORREF(gGlobalPrefs->ebookUI.backgroundColor);
    textRender->SetTextBgColor(bgCol);

    Timer timerDrawHtml;
    DrawHtmlPage(gfx, textRender, &page->instructions, (REAL)r.X, (REAL)r.Y, IsDebugPaint(), textColor);
    double durDraw = timerDrawHtml.Stop();
    gfx->SetClip(&origClipRegion, CombineModeReplace);
    delete textRender;

    double durAll = timerAll.Stop();
    plogf("all: %.2f, fill: %.2f, draw html: %.2f", durAll, durFill, durDraw);
}