void Text::scroll_to(DimensionName dimension, Coord position) { // let the user scroll to the right (or down) past the current size. /* if (position > (upper(dimension) - cur_length(dimension))) { position = upper(dimension) - cur_length(dimension); } */ // if (position < lower(dimension)) { // position = lower(dimension); // } if (dimension == Dimension_X) { if (position < lower(dimension)) { position = lower(dimension); } } else { if (position > (upper(dimension) - cur_length(dimension))) { position = upper(dimension) - cur_length(dimension); } } if (position == cur_lower(dimension)) { return; } cur_lower(dimension, position); notify(dimension); damage(); }
void Text::scroll_backward(DimensionName dimension) { FontBoundingBox fbb; font_->font_bbox(fbb); if (dimension == Dimension_X) { scroll_to(dimension, cur_lower(Dimension_X) - width(' ')); } else { scroll_to(dimension, cur_lower(Dimension_Y) - (fbb.ascent() + fbb.descent())); } }
void Scrollable::scroll_to(DimensionName d, Coord lower) { Coord p = lower; Coord prevdx = dx_; Coord prevdy = dy_; constrain(d, p); if (p != cur_lower(d)) { if (d == Dimension_X) dx_ = p; else dy_ = p; redraw(); for (int i=0; i<page_->count(); i++) { Coord x, y; page_->location(i, x, y); page_->move(i, x+prevdx-dx_, y+prevdy-dy_); } notify(d); redraw(); }; }
Coord Adjustable::cur_length(DimensionName d) const { return cur_upper(d) - cur_lower(d); }
void Adjustable::page_backward(DimensionName d) { scroll_to(d, cur_lower(d) - large_scroll(d)); }
void Adjustable::scroll_backward(DimensionName d) { scroll_to(d, cur_lower(d) - small_scroll(d)); }
void Text::page_backward(DimensionName dimension) { scroll_to(dimension, cur_lower(dimension) - cur_length(dimension)); }
Coord Text::cur_length(DimensionName dimension) const { return cur_upper(dimension) - cur_lower(dimension); }