static Boolean ScrollVerticalText( Widget w, int new_line, Boolean force_redisp) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; int num_lines = sblw->scroll.num_visible_lines; int max_lines, old_line; Boolean move_thumb = FALSE; /* * Do not let the window extend out of bounds. */ if ( new_line < 0) { new_line = 0; move_thumb = TRUE; } else { max_lines = sblw->scroll.lines - (int)w->core.height / sblw->scroll.font_height; AssignMax(max_lines, 0); if ( new_line > max_lines ) { new_line = max_lines; move_thumb = TRUE; } } /* * If forced to redisplay then do a full redisplay and return. */ old_line = sblw->scroll.line_pointer; sblw->scroll.line_pointer = new_line; /* Set current top of page. */ if (force_redisp) MoveAndClearText(w, 0, /* cause a full redisplay */ 0, 0); if (new_line == old_line) return(move_thumb); /* * Scroll forward. */ else if (new_line < old_line) { int lines_to_scroll = old_line - new_line; MoveAndClearText(w, 0, num_lines - lines_to_scroll, lines_to_scroll); } /* * Scroll back. */ else { int lines_to_scroll = new_line - old_line; MoveAndClearText(w, lines_to_scroll, num_lines - lines_to_scroll, 0); } return(move_thumb); }
/* * Function: * ComputeWithForceBars * * Parameters: * widget - viewport widget * query - whether or not to query the child * intended - cache of the childs height is stored here * (used and returned) * clip_width - size of clip window (used and returned) * clip_height - "" * * Description: * Computes the layout give forcebars is set. */ static void ComputeWithForceBars(Widget widget, Bool query, XtWidgetGeometry *intended, int *clip_width, int *clip_height) { ViewportWidget w = (ViewportWidget)widget; Widget child = w->viewport.child; XtWidgetGeometry preferred; /* * If forcebars then needs = allows = has * Thus if needsvert is set it MUST have a scrollbar */ if (w->viewport.allowvert) { if (w->viewport.vert_bar == NULL) w->viewport.vert_bar = CreateScrollbar(w, False); *clip_width -= XtWidth(w->viewport.vert_bar) + XtBorderWidth(w->viewport.vert_bar); } if (w->viewport.allowhoriz) { if (w->viewport.horiz_bar == NULL) w->viewport.horiz_bar = CreateScrollbar(w, True); *clip_height -= XtHeight(w->viewport.horiz_bar) + XtBorderWidth(w->viewport.horiz_bar); } AssignMax(*clip_width, 1); AssignMax(*clip_height, 1); if (!w->viewport.allowvert) { intended->height = *clip_height; intended->request_mode = CWHeight; } if (!w->viewport.allowhoriz) { intended->width = *clip_width; intended->request_mode = CWWidth; } if (query) { if (w->viewport.allowvert || w->viewport.allowhoriz) { XtQueryGeometry(child, intended, &preferred); if (!(intended->request_mode & CWWidth)) { if (preferred.request_mode & CWWidth) intended->width = preferred.width; else intended->width = XtWidth(child); } if (!(intended->request_mode & CWHeight)) { if (preferred.request_mode & CWHeight) intended->height = preferred.height; else intended->height = XtHeight(child); } } } else { if (w->viewport.allowvert) intended->height = XtHeight(child); if (w->viewport.allowhoriz) intended->width = XtWidth(child); } if (*clip_width > (int)intended->width) intended->width = *clip_width; if (*clip_height > (int)intended->height) intended->height = *clip_height; }