void ScrollBarOn(XtermWidget xw, Bool init) { TScreen *screen = TScreenOf(xw); if (screen->fullVwin.sb_info.width || IsIcon(screen)) return; TRACE(("ScrollBarOn(init %s)\n", BtoS(init))); if (init) { /* then create it only */ if (screen->scrollWidget == 0) { /* make it a dummy size and resize later */ screen->scrollWidget = CreateScrollBar(xw, -ScrollBarBorder(xw), -ScrollBarBorder(xw), 5); if (screen->scrollWidget == NULL) { Bell(xw, XkbBI_MinorError, 0); } } } else if (!screen->scrollWidget || !XtIsRealized((Widget) xw)) { Bell(xw, XkbBI_MinorError, 0); Bell(xw, XkbBI_MinorError, 0); } else { ResizeScrollBar(xw); xtermAddInput(screen->scrollWidget); XtRealizeWidget(screen->scrollWidget); TRACE_TRANS("scrollbar", screen->scrollWidget); screen->fullVwin.sb_info.rv_cached = False; screen->fullVwin.sb_info.width = (screen->scrollWidget->core.width + BorderWidth(screen->scrollWidget)); TRACE(("setting scrollbar width %d = %d + %d\n", screen->fullVwin.sb_info.width, screen->scrollWidget->core.width, BorderWidth(screen->scrollWidget))); ScrollBarDrawThumb(screen->scrollWidget); DoResizeScreen(xw); #ifdef SCROLLBAR_RIGHT updateRightScrollbar(xw); #endif XtMapWidget(screen->scrollWidget); update_scrollbar(); if (screen->visbuf) { xtermClear(xw); Redraw(); } } }
void ScrollBarOn (XtermWidget xw,int init,int doalloc) { register TScreen *screen = &xw->screen; register int border = 2 * screen->border; register int i,j,k; /* if(screen->scrollbar) return; */ if(screen->fullVwin.sb_info.width) return; if (init) { /* then create it only */ if (screen->scrollWidget) return; /* make it a dummy size and resize later */ if ((screen->scrollWidget = CreateScrollBar (xw, -1, - 1, 5)) == NULL) { Bell(XkbBI_MinorError,0); return; } return; } if (!screen->scrollWidget) { Bell (XkbBI_MinorError,0); Bell (XkbBI_MinorError,0); return; } if (doalloc && screen->allbuf) { /* FIXME: this is not integrated well with Allocate */ if((screen->allbuf = (ScrnBuf) realloc((char *) screen->visbuf, (unsigned) MAX_PTRS*(screen->max_row + 2 + screen->savelines) * sizeof(char *))) == NULL) SysError(ERROR_SBRALLOC); screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; memmove( (char *)screen->visbuf, (char *)screen->allbuf, MAX_PTRS * (screen->max_row + 2) * sizeof (char *)); for (i = k = 0; i < screen->savelines; i++) { k += BUF_HEAD; for (j = BUF_HEAD; j < MAX_PTRS; j++) { if((screen->allbuf[k++] = (Char *)calloc((unsigned) screen->max_col + 1, sizeof(Char))) == NULL) SysError(ERROR_SBRALLOC2); } } } ResizeScrollBar (screen); xtermAddInput(screen->scrollWidget); XtRealizeWidget (screen->scrollWidget); /* Now set the left ptr cursor for the scrollbar [email protected] */ XDefineCursor(XtDisplay(screen->scrollWidget), XtWindow(screen->scrollWidget), screen->arrow); screen->fullVwin.sb_info.rv_cached = False; screen->fullVwin.sb_info.width = screen->scrollWidget->core.width + screen->scrollWidget->core.border_width; ScrollBarDrawThumb(screen->scrollWidget); DoResizeScreen (xw); XtMapWidget(screen->scrollWidget); update_scrollbar (); if (screen->visbuf) { XClearWindow (screen->display, XtWindow (term)); Redraw (); } /* XXX TODO if scrollbar is on right [email protected] */ }