BScrollView::BScrollView(const char *name, BView *target, uint32 resizingMode, uint32 flags, bool horizontal, bool vertical, border_style border) : BView(CalcFrame(target, horizontal, vertical, border), name, ModifyFlags(flags, border), resizingMode), fTarget(target), fHorizontalScrollBar(NULL), fVerticalScrollBar(NULL), fBorder(border), fHighlighted(false) { fTarget->TargetedByScrollView(this); fTarget->MoveTo(B_ORIGIN); if (border != B_NO_BORDER) fTarget->MoveBy(BorderSize(border), BorderSize(border)); AddChild(fTarget); BRect frame = fTarget->Frame(); if (horizontal) { BRect rect = frame; rect.top = rect.bottom + 1; rect.bottom += B_H_SCROLL_BAR_HEIGHT + 1; if (border != B_NO_BORDER || vertical) rect.right++; if (border != B_NO_BORDER) rect.left--; fHorizontalScrollBar = new BScrollBar(rect, "_HSB_", fTarget, 0, 1000, B_HORIZONTAL); AddChild(fHorizontalScrollBar); } if (vertical) { BRect rect = frame; rect.left = rect.right + 1; rect.right += B_V_SCROLL_BAR_WIDTH + 1; if (border != B_NO_BORDER || horizontal) rect.bottom++; if (border != B_NO_BORDER) rect.top--; fVerticalScrollBar = new BScrollBar(rect, "_VSB_", fTarget, 0, 1000, B_VERTICAL); AddChild(fVerticalScrollBar); } fPreviousWidth = uint16(Bounds().Width()); fPreviousHeight = uint16(Bounds().Height()); }
void BScrollView::GetPreferredSize(float *_width, float *_height) { BRect frame = CalcFrame(fTarget, fHorizontalScrollBar, fVerticalScrollBar, fBorder); if (fTarget != NULL) { float width, height; fTarget->GetPreferredSize(&width, &height); frame.right += width - fTarget->Frame().Width(); frame.bottom += height - fTarget->Frame().Height(); } if (_width) *_width = frame.Width(); if (_height) *_height = frame.Height(); }
cMotion::tFrame cMotion::CalcFramePhase(double phase) const { double max_time = GetDuration(); double time = phase * max_time; return CalcFrame(time); }