Beispiel #1
0
void ScrollBar::SetFilled(float perc) {
    CrashIf((perc < 0.f) || (perc > 1.f));
    int prev = IntFromPerc(pos.Width, filledPerc);
    int curr = IntFromPerc(pos.Width, perc);
    filledPerc = perc;
    if (prev != curr)
        RequestRepaint(this);
}
// (x, y) is in the coordinates of w
void EbookController::ClickedProgress(Control *c, int x, int y)
{
    CrashIf(c != ctrls->progress);
    float perc = ctrls->progress->GetPercAt(x);
    int pageCount = (int)GetPages()->Count();
    int newPageNo = IntFromPerc(pageCount, perc) + 1;
    GoToPage(newPageNo, true);
}
// (x, y) is in the coordinates of w
void EbookController::ClickedProgress(Control *c, int x, int y)
{
    CrashIf(c != ctrls->progress);
    float perc = ctrls->progress->GetPercAt(x);
    // TODO: shouldn't be active if we don't have pages from
    // beginnign, but happened in real life, crash 1096004
    if (!GetPagesFromBeginning())
        return;
    int pageCount = GetPagesFromBeginning()->Count();
    int newPageNo = IntFromPerc(pageCount, perc) + 1;
    GoToPage(newPageNo);
}
Beispiel #4
0
void ScrollBar::Paint(Graphics *gfx, int offX, int offY) {
    CrashIf(!IsVisible());
    // TODO: take padding into account
    CachedStyle *s = cachedStyle;

    int dy = inactiveDy;
    if (IsMouseOver())
        dy = onOverDy;

    Rect r(offX, offY + pos.Height - dy, pos.Width, dy);
    Brush *br = BrushFromColorData(s->bgColor, r);
    gfx->FillRectangle(br, r);

    int filledDx = IntFromPerc(pos.Width, filledPerc);
    if (0 == filledDx)
        return;

    r.Width = filledDx;
    br = BrushFromColorData(s->color, r);
    gfx->FillRectangle(br, r);
}