#ifdef USE_XIM
im_destroy ();
#endif
-#ifdef XTERM_SCROLLBAR
- if (xscrollbarGC) XFreeGC (dpy, xscrollbarGC);
- if (ShadowGC) XFreeGC (dpy, ShadowGC);
-#endif
-#ifdef PLAIN_SCROLLBAR
- if (pscrollbarGC) XFreeGC (dpy, pscrollbarGC);
-#endif
-#ifdef NEXT_SCROLLBAR
- if (blackGC) XFreeGC (dpy, blackGC);
- if (whiteGC) XFreeGC (dpy, whiteGC);
- if (grayGC) XFreeGC (dpy, grayGC);
- if (darkGC) XFreeGC (dpy, darkGC);
- if (stippleGC) XFreeGC (dpy, stippleGC);
- if (dimple) XFreePixmap (dpy, dimple);
- if (upArrow) XFreePixmap (dpy, upArrow);
- if (downArrow) XFreePixmap (dpy, downArrow);
- if (upArrowHi) XFreePixmap (dpy, upArrowHi);
- if (downArrowHi) XFreePixmap (dpy, downArrowHi);
-#endif
-#ifdef RXVT_SCROLLBAR
- if (topShadowGC) XFreeGC (dpy, topShadowGC);
- if (botShadowGC) XFreeGC (dpy, botShadowGC);
- if (scrollbarGC) XFreeGC (dpy, scrollbarGC);
-#endif
+ scrollBar.destroy ();
if (gc) XFreeGC (dpy, gc);
delete drawable;
SavedModes;
/* ---------- */
Atom *xa;
-/* ---------- */
-#ifdef RXVT_SCROLLBAR
- GC scrollbarGC,
- topShadowGC,
- botShadowGC;
-#endif
-#ifdef XTERM_SCROLLBAR
- GC xscrollbarGC,
- ShadowGC;
-#endif
-#ifdef PLAIN_SCROLLBAR
- GC pscrollbarGC;
-#endif
-#ifdef NEXT_SCROLLBAR
- GC blackGC,
- whiteGC,
- grayGC,
- darkGC,
- stippleGC;
- Pixmap dimple,
- upArrow,
- downArrow,
- upArrowHi,
- downArrowHi;
-#endif
/* ---------- */
Time selection_time,
selection_request_time;
void selection_extend (int x, int y, int flag) NOTHROW;
void selection_rotate (int x, int y) NOTHROW;
-#if defined(NEXT_SCROLLBAR)
- // scrollbar-next.C
- Pixmap renderPixmap (const char *const *data, int width, int height);
- void init_scrollbar_stuff ();
- void drawBevel (Drawable d, int x1, int y1, int w, int h);
- int scrollbar_show_next (int update, int last_top, int last_bot, int scrollbar_len);
-#endif
-
-#if defined(RXVT_SCROLLBAR)
- // scrollbar-rxvt.C
- int scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len);
-#endif
-
-#if defined(XTERM_SCROLLBAR)
- // scrollbar-xterm.C
- int scrollbar_show_xterm (int update, int last_top, int last_bot, int scrollbar_len);
-#endif
-
-#if defined(PLAIN_SCROLLBAR)
- // scrollbar-plain.C
- int scrollbar_show_plain (int update, int last_top, int last_bot, int scrollbar_len);
-#endif
-
// xdefaults.C
void get_options (int argc, const char *const *argv);
int parse_keysym (const char *str, const char *arg);
" "
};
-Pixmap
-rxvt_term::renderPixmap (const char *const *data, int width, int height)
+static Pixmap
+renderPixmap (scrollBar_t *sb, const char *const *data, int width, int height)
{
char a;
int x, y;
Pixmap d;
GC pointcolour;
- d = XCreatePixmap (dpy, scrollBar.win, width, height, depth);
+ d = XCreatePixmap (sb->term->dpy, sb->win, width, height, sb->term->depth);
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
if ((a = data[y][x]) == ' ' || a == 'w')
- pointcolour = whiteGC;
+ pointcolour = sb->whiteGC;
else if (a == '.' || a == 'l')
- pointcolour = grayGC;
+ pointcolour = sb->grayGC;
else if (a == '%' || a == 'd')
- pointcolour = darkGC;
+ pointcolour = sb->darkGC;
else /* if (a == '#' || a == 'b' || a) */
- pointcolour = blackGC;
+ pointcolour = sb->blackGC;
- XDrawPoint (dpy, d, pointcolour, x, y);
+ XDrawPoint (sb->term->dpy, d, pointcolour, x, y);
}
}
return d;
}
void
-rxvt_term::init_scrollbar_stuff ()
+scrollBar_t::init_next ()
{
XGCValues gcvalue;
XColor xcol;
gcvalue.graphics_exposures = False;
- gcvalue.foreground = pix_colors_focused[Color_Black];
- blackGC = XCreateGC (dpy, scrollBar.win,
+ gcvalue.foreground = term->pix_colors_focused[Color_Black];
+ blackGC = XCreateGC (term->dpy, win,
GCForeground | GCGraphicsExposures, &gcvalue);
- gcvalue.foreground = pix_colors_focused[Color_White];
- whiteGC = XCreateGC (dpy, scrollBar.win,
+ gcvalue.foreground = term->pix_colors_focused[Color_White];
+ whiteGC = XCreateGC (term->dpy, win,
GCForeground | GCGraphicsExposures, &gcvalue);
xcol.red = 0xaeba;
xcol.green = 0xaaaa;
xcol.blue = 0xaeba;
- xcol.pixel = pix_colors_focused[Color_scroll];
+ xcol.pixel = term->pix_colors_focused[Color_scroll];
light = gcvalue.foreground = xcol.pixel;
- grayGC = XCreateGC (dpy, scrollBar.win,
+ grayGC = XCreateGC (term->dpy, win,
GCForeground | GCGraphicsExposures, &gcvalue);
xcol.red = 0x51aa;
xcol.green = 0x5555;
xcol.blue = 0x5144;
//if (!rXAllocColor (&xcol, "dark gray"))//TODO//D//
- xcol.pixel = pix_colors_focused[Color_Grey25];
+ xcol.pixel = term->pix_colors_focused[Color_Grey25];
dark = gcvalue.foreground = xcol.pixel;
- darkGC = XCreateGC (dpy, scrollBar.win,
+ darkGC = XCreateGC (term->dpy, win,
GCForeground | GCGraphicsExposures, &gcvalue);
- stipple = XCreateBitmapFromData (dpy, scrollBar.win,
+ stipple = XCreateBitmapFromData (term->dpy, win,
(char *)n_stp_bits, n_stp_width,
n_stp_height);
/* XSetWindowBackground (dpy, scrollBar.win, pix_colors_focused[Color_Red]); */
- stippleGC = XCreateGC (dpy, scrollBar.win,
+ stippleGC = XCreateGC (term->dpy, win,
GCForeground | GCBackground | GCStipple
| GCFillStyle | GCGraphicsExposures, &gcvalue);
- dimple = renderPixmap (SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH,
+ dimple = renderPixmap (this, SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH,
SCROLLER_DIMPLE_HEIGHT);
- upArrow = renderPixmap (SCROLLER_ARROW_UP, ARROW_WIDTH,
+ upArrow = renderPixmap (this, SCROLLER_ARROW_UP, ARROW_WIDTH,
ARROW_HEIGHT);
- downArrow = renderPixmap (SCROLLER_ARROW_DOWN, ARROW_WIDTH,
+ downArrow = renderPixmap (this, SCROLLER_ARROW_DOWN, ARROW_WIDTH,
ARROW_HEIGHT);
- upArrowHi = renderPixmap (HI_SCROLLER_ARROW_UP, ARROW_WIDTH,
+ upArrowHi = renderPixmap (this, HI_SCROLLER_ARROW_UP, ARROW_WIDTH,
ARROW_HEIGHT);
- downArrowHi = renderPixmap (HI_SCROLLER_ARROW_DOWN,
+ downArrowHi = renderPixmap (this, HI_SCROLLER_ARROW_DOWN,
ARROW_WIDTH, ARROW_HEIGHT);
}
/* Draw bevel & arrows */
-void
-rxvt_term::drawBevel (Drawable d, int x1, int y1, int w, int h)
+static void
+drawBevel (scrollBar_t *sb, int x1, int y1, int w, int h)
{
int x2, y2;
+ Drawable d = sb->win;
+ Display *dpy = sb->term->dpy;
x2 = x1 + w - 1; /* right point */
y2 = y1 + h - 1; /* bottom point */
/* white top and left */
- XDrawLine (dpy, d, whiteGC, x1, y1, x2, y1);
- XDrawLine (dpy, d, whiteGC, x1, y1, x1, y2);
+ XDrawLine (dpy, d, sb->whiteGC, x1, y1, x2, y1);
+ XDrawLine (dpy, d, sb->whiteGC, x1, y1, x1, y2);
/* black bottom and right */
- XDrawLine (dpy, d, blackGC, x1, y2, x2, y2);
- XDrawLine (dpy, d, blackGC, x2, y1, x2, y2);
+ XDrawLine (dpy, d, sb->blackGC, x1, y2, x2, y2);
+ XDrawLine (dpy, d, sb->blackGC, x2, y1, x2, y2);
/* dark inside bottom and right */
x1++, y1++, x2--, y2--; /* move in one point */
- XDrawLine (dpy, d, darkGC, x1, y2, x2, y2);
- XDrawLine (dpy, d, darkGC, x2, y1, x2, y2);
+ XDrawLine (dpy, d, sb->darkGC, x1, y2, x2, y2);
+ XDrawLine (dpy, d, sb->darkGC, x2, y1, x2, y2);
}
int
-rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scrollbar_len)
+scrollBar_t::show_next (int update)
{
- int height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING;
+ int height = end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING;
Drawable src;
- if ((scrollBar.init & R_SB_NEXT) == 0)
+ if ((init & R_SB_NEXT) == 0)
{
- scrollBar.init |= R_SB_NEXT;
- init_scrollbar_stuff ();
+ init |= R_SB_NEXT;
+ init_next ();
}
- if (top_row == 0 || !update)
+ if (term->top_row == 0 || !update)
{
- XFillRectangle (dpy, scrollBar.win, grayGC, 0, 0,
+ XFillRectangle (term->dpy, win, grayGC, 0, 0,
SB_WIDTH_NEXT + 1, height);
- XDrawRectangle (dpy, scrollBar.win, blackGC, 0,
+ XDrawRectangle (term->dpy, win, blackGC, 0,
-SB_BORDER_WIDTH, SB_WIDTH_NEXT,
height + SB_BORDER_WIDTH);
- XFillRectangle (dpy, scrollBar.win, stippleGC,
+ XFillRectangle (term->dpy, win, stippleGC,
SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height);
}
- if (top_row)
+ if (term->top_row)
{
- if (last_top < scrollBar.top || !update)
- XFillRectangle (dpy, scrollBar.win, stippleGC,
+ if (last_top < top || !update)
+ XFillRectangle (term->dpy, win, stippleGC,
SB_LEFT_PADDING, SB_PADDING + last_top,
- SB_BUTTON_WIDTH, scrollBar.top - last_top);
+ SB_BUTTON_WIDTH, top - last_top);
- if (scrollBar.bot < last_bot || !update)
- XFillRectangle (dpy, scrollBar.win, stippleGC,
- SB_LEFT_PADDING, scrollBar.bot + SB_PADDING,
- SB_BUTTON_WIDTH, (last_bot - scrollBar.bot));
+ if (bot < last_bot || !update)
+ XFillRectangle (term->dpy, win, stippleGC,
+ SB_LEFT_PADDING, bot + SB_PADDING,
+ SB_BUTTON_WIDTH, (last_bot - bot));
- XFillRectangle (dpy, scrollBar.win, grayGC,
- SB_LEFT_PADDING, scrollBar.top + SB_PADDING,
- SB_BUTTON_WIDTH, scrollbar_len);
+ XFillRectangle (term->dpy, win, grayGC,
+ SB_LEFT_PADDING, top + SB_PADDING,
+ SB_BUTTON_WIDTH, len);
- XCopyArea (dpy, dimple, scrollBar.win, whiteGC, 0, 0,
+ XCopyArea (term->dpy, dimple, win, whiteGC, 0, 0,
SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT,
(SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2,
- scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT +
- (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2);
+ top + SB_BEVEL_WIDTH_UPPER_LEFT +
+ (len - SCROLLER_DIMPLE_HEIGHT) / 2);
- drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
- scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH,
- scrollbar_len);
- drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
+ drawBevel (this, SB_BUTTON_BEVEL_X,
+ top + SB_PADDING, SB_BUTTON_WIDTH,
+ len);
+ drawBevel (this, SB_BUTTON_BEVEL_X,
height - SB_BUTTON_BOTH_HEIGHT, SB_BUTTON_WIDTH,
SB_BUTTON_HEIGHT);
- drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
+ drawBevel (this, SB_BUTTON_BEVEL_X,
height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH,
SB_BUTTON_HEIGHT);
- src = scrollBar.state == STATE_UP ? upArrowHi : upArrow;
- XCopyArea (dpy, src, scrollBar.win, whiteGC, 0, 0,
+ src = state == STATE_UP ? upArrowHi : upArrow;
+ XCopyArea (term->dpy, src, win, whiteGC, 0, 0,
ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
- src = scrollBar.state == STATE_DOWN ? downArrowHi : downArrow;
- XCopyArea (dpy, src, scrollBar.win, whiteGC, 0, 0,
+ src = state == STATE_DOWN ? downArrowHi : downArrow;
+ XCopyArea (term->dpy, src, win, whiteGC, 0, 0,
ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
}
#if defined(PLAIN_SCROLLBAR)
int
-rxvt_term::scrollbar_show_plain (int update, int last_top, int last_bot, int scrollbar_len)
+scrollBar_t::show_plain (int update)
{
int xsb = 0;
- int sbwidth = scrollBar.width - 1;
+ int sbwidth = width - 1;
- if ((scrollBar.init & R_SB_PLAIN) == 0)
+ if ((init & R_SB_PLAIN) == 0)
{
XGCValues gcvalue;
- scrollBar.init |= R_SB_PLAIN;
- gcvalue.foreground = pix_colors_focused[Color_scroll];
+ init |= R_SB_PLAIN;
+ gcvalue.foreground = term->pix_colors_focused[Color_scroll];
- pscrollbarGC = XCreateGC (dpy, scrollBar.win, GCForeground, &gcvalue);
+ pscrollbarGC = XCreateGC (term->dpy, win, GCForeground, &gcvalue);
}
- xsb = option (Opt_scrollBar_right) ? 1 : 0;
+ xsb = term->option (Opt_scrollBar_right) ? 1 : 0;
if (update)
{
- if (last_top < scrollBar.top)
- XClearArea (dpy, scrollBar.win,
+ if (last_top < top)
+ XClearArea (term->dpy, win,
0, last_top,
- sbwidth + 1, scrollBar.top - last_top, False);
+ sbwidth + 1, top - last_top, False);
- if (scrollBar.bot < last_bot)
- XClearArea (dpy, scrollBar.win,
- 0, scrollBar.bot,
- sbwidth + 1, last_bot - scrollBar.bot, False);
+ if (bot < last_bot)
+ XClearArea (term->dpy, win,
+ 0, bot,
+ sbwidth + 1, last_bot - bot, False);
}
else
- XClearWindow (dpy, scrollBar.win);
+ XClearWindow (term->dpy, win);
/* scrollbar slider */
- XFillRectangle (dpy, scrollBar.win, pscrollbarGC,
- 1 - xsb, scrollBar.top, sbwidth, scrollbar_len);
+ XFillRectangle (term->dpy, win, pscrollbarGC,
+ 1 - xsb, top, sbwidth, len);
return 1;
}
#if defined(RXVT_SCROLLBAR)
static void
-draw_shadow (rxvt_term *term, int x, int y, int w, int h)
+draw_shadow (scrollBar_t *sb, int x, int y, int w, int h)
{
int shadow;
+ Drawable d = sb->win;
+ Display *dpy = sb->term->dpy;
shadow = (w == 0 || h == 0) ? 1 : SHADOW_WIDTH;
w += x - 1;
for (; shadow-- > 0; x++, y++, w--, h--)
{
- XDrawLine (term->dpy, term->scrollBar.win, term->topShadowGC, x, y, w , y );
- XDrawLine (term->dpy, term->scrollBar.win, term->topShadowGC, x, y, x , h );
- XDrawLine (term->dpy, term->scrollBar.win, term->botShadowGC, w, h, w , y + 1);
- XDrawLine (term->dpy, term->scrollBar.win, term->botShadowGC, w, h, x + 1, h );
+ XDrawLine (dpy, d, sb->topShadowGC, x, y, w , y );
+ XDrawLine (dpy, d, sb->topShadowGC, x, y, x , h );
+ XDrawLine (dpy, d, sb->botShadowGC, w, h, w , y + 1);
+ XDrawLine (dpy, d, sb->botShadowGC, w, h, x + 1, h );
}
}
/* draw triangular button with a shadow of 2 pixels */
static void
-draw_button (rxvt_term *term, int x, int y, int dirn)
+draw_button (scrollBar_t *sb, int x, int y, int dirn)
{
unsigned int sz, sz2;
XPoint pt[3];
GC top, bot;
+ Drawable d = sb->win;
+ Display *dpy = sb->term->dpy;
- sz = term->scrollBar.width;
+ sz = sb->width;
sz2 = sz / 2;
- if ((dirn == UP && term->scrollBar.state == STATE_UP)
- || (dirn == DN && term->scrollBar.state == STATE_DOWN))
+ if ((dirn == UP && sb->state == STATE_UP)
+ || (dirn == DN && sb->state == STATE_DOWN))
{
- top = term->botShadowGC;
- bot = term->topShadowGC;
+ top = sb->botShadowGC;
+ bot = sb->topShadowGC;
}
else
{
- top = term->topShadowGC;
- bot = term->botShadowGC;
+ top = sb->topShadowGC;
+ bot = sb->botShadowGC;
}
/* fill triangle */
pt[2].y = y + sz - 1;
}
- XFillPolygon (term->dpy, term->scrollBar.win, term->scrollbarGC,
+ XFillPolygon (dpy, d, sb->scrollbarGC,
pt, 3, Convex, CoordModeOrigin);
/* draw base */
- XDrawLine (term->dpy, term->scrollBar.win, (dirn == UP ? bot : top),
+ XDrawLine (dpy, d, (dirn == UP ? bot : top),
pt[0].x, pt[0].y, pt[1].x, pt[1].y);
/* draw shadow on left */
pt[1].x = x + sz2 - 1;
pt[1].y = y + (dirn == UP ? 0 : sz - 1);
- XDrawLine (term->dpy, term->scrollBar.win, top,
+ XDrawLine (dpy, d, top,
pt[0].x, pt[0].y, pt[1].x, pt[1].y);
#if SHADOW_WIDTH > 1
pt[1].y--;
}
- XDrawLine (term->dpy, term->scrollBar.win, top,
+ XDrawLine (dpy, d, top,
pt[0].x, pt[0].y, pt[1].x, pt[1].y);
#endif
/* pt[2].x = x + sz2; */
pt[1].y = y + (dirn == UP ? sz - 1 : 0);
pt[2].y = y + (dirn == UP ? 0 : sz - 1);
- XDrawLine (term->dpy, term->scrollBar.win, bot,
+ XDrawLine (dpy, d, bot,
pt[2].x, pt[2].y, pt[1].x, pt[1].y);
#if SHADOW_WIDTH > 1
pt[1].y++;
}
- XDrawLine (term->dpy, term->scrollBar.win, bot,
+ XDrawLine (dpy, d, bot,
pt[2].x, pt[2].y, pt[1].x, pt[1].y);
#endif
}
int
-rxvt_term::scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len)
+scrollBar_t::show_rxvt (int update)
{
- int sbshadow = scrollBar.shadow;
- int sbwidth = (int)scrollBar.width;
+ int sbshadow = shadow;
+ int sbwidth = (int)width;
- if ((scrollBar.init & R_SB_RXVT) == 0)
+ if ((init & R_SB_RXVT) == 0)
{
XGCValues gcvalue;
- scrollBar.init |= R_SB_RXVT;
+ init |= R_SB_RXVT;
- gcvalue.foreground = pix_colors[Color_topShadow];
- topShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue);
- gcvalue.foreground = pix_colors[Color_bottomShadow];
- botShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue);
- gcvalue.foreground = pix_colors[ (depth <= 2 ? Color_fg : Color_scroll)];
- scrollbarGC = XCreateGC (dpy, vt, GCForeground, &gcvalue);
+ gcvalue.foreground = term->pix_colors[Color_topShadow];
+ topShadowGC = XCreateGC (term->dpy, term->vt, GCForeground, &gcvalue);
+ gcvalue.foreground = term->pix_colors[Color_bottomShadow];
+ botShadowGC = XCreateGC (term->dpy, term->vt, GCForeground, &gcvalue);
+ gcvalue.foreground = term->pix_colors[ (term->depth <= 2 ? Color_fg : Color_scroll)];
+ scrollbarGC = XCreateGC (term->dpy, term->vt, GCForeground, &gcvalue);
if (sbshadow)
{
- XSetWindowBackground (dpy, scrollBar.win, pix_colors_focused[Color_trough]);
- XClearWindow (dpy, scrollBar.win);
+ XSetWindowBackground (term->dpy, win, term->pix_colors_focused[Color_trough]);
+ XClearWindow (term->dpy, win);
}
}
else
{
if (update)
{
- if (last_top < scrollBar.top)
- XClearArea (dpy, scrollBar.win,
+ if (last_top < top)
+ XClearArea (term->dpy, win,
sbshadow, last_top,
- sbwidth, (scrollBar.top - last_top),
+ sbwidth, (top - last_top),
False);
- if (scrollBar.bot < last_bot)
- XClearArea (dpy, scrollBar.win,
- sbshadow, scrollBar.bot,
- sbwidth, (last_bot - scrollBar.bot),
+ if (bot < last_bot)
+ XClearArea (term->dpy, win,
+ sbshadow, bot,
+ sbwidth, (last_bot - bot),
False);
}
else
- XClearWindow (dpy, scrollBar.win);
+ XClearWindow (term->dpy, win);
}
/* scrollbar slider */
{
int xofs;
- if (option (Opt_scrollBar_right))
+ if (term->option (Opt_scrollBar_right))
xofs = 0;
else
xofs = sbshadow ? sbwidth : sbwidth - 1;
- XDrawLine (dpy, scrollBar.win, botShadowGC,
- xofs, 0, xofs, scrollBar.end + sbwidth);
+ XDrawLine (term->dpy, win, botShadowGC,
+ xofs, 0, xofs, end + sbwidth);
}
#endif
- XFillRectangle (dpy, scrollBar.win, scrollbarGC,
- sbshadow, scrollBar.top, sbwidth,
- scrollbar_len);
+ XFillRectangle (term->dpy, win, scrollbarGC,
+ sbshadow, top, sbwidth,
+ len);
if (sbshadow)
/* trough shadow */
- draw_shadow (this, 0, 0, sbwidth + 2 * sbshadow, scrollBar.end + (sbwidth + 1) + sbshadow);
+ draw_shadow (this, 0, 0, sbwidth + 2 * sbshadow, end + (sbwidth + 1) + sbshadow);
/* shadow for scrollbar slider */
- draw_shadow (this, sbshadow, scrollBar.top, sbwidth, scrollbar_len);
+ draw_shadow (this, sbshadow, top, sbwidth, len);
/* Redraw scrollbar arrows */
- draw_button (this, sbshadow, sbshadow, UP);
- draw_button (this, sbshadow, scrollBar.end + 1, DN);
+ draw_button (this, sbshadow, sbshadow, UP);
+ draw_button (this, sbshadow, end + 1, DN);
return 1;
}
const unsigned char x_stp_bits[] = { 0xaa, 0x55 };
int
-rxvt_term::scrollbar_show_xterm (int update, int last_top, int last_bot, int scrollbar_len)
+scrollBar_t::show_xterm (int update)
{
int xsb = 0;
- int sbwidth = scrollBar.width - 1;
+ int sbwidth = width - 1;
- if ((scrollBar.init & R_SB_XTERM) == 0)
+ if ((init & R_SB_XTERM) == 0)
{
XGCValues gcvalue;
- scrollBar.init |= R_SB_XTERM;
- gcvalue.stipple = XCreateBitmapFromData (dpy, scrollBar.win,
+ init |= R_SB_XTERM;
+ gcvalue.stipple = XCreateBitmapFromData (term->dpy, win,
(char *)x_stp_bits, x_stp_width,
x_stp_height);
if (!gcvalue.stipple)
rxvt_fatal ("can't create bitmap\n");
gcvalue.fill_style = FillOpaqueStippled;
- gcvalue.foreground = pix_colors_focused[Color_scroll];
- gcvalue.background = pix_colors_focused[Color_bg];
+ gcvalue.foreground = term->pix_colors_focused[Color_scroll];
+ gcvalue.background = term->pix_colors_focused[Color_bg];
- xscrollbarGC = XCreateGC (dpy, scrollBar.win,
+ xscrollbarGC = XCreateGC (term->dpy, win,
GCForeground | GCBackground
| GCFillStyle | GCStipple, &gcvalue);
- gcvalue.foreground = pix_colors_focused[Color_border];
- ShadowGC = XCreateGC (dpy, scrollBar.win, GCForeground, &gcvalue);
+ gcvalue.foreground = term->pix_colors_focused[Color_border];
+ ShadowGC = XCreateGC (term->dpy, win, GCForeground, &gcvalue);
}
- xsb = option (Opt_scrollBar_right) ? 1 : 0;
+ xsb = term->option (Opt_scrollBar_right) ? 1 : 0;
if (update)
{
- if (last_top < scrollBar.top)
- XClearArea (dpy, scrollBar.win,
+ if (last_top < top)
+ XClearArea (term->dpy, win,
xsb, last_top,
- sbwidth, (scrollBar.top - last_top), False);
+ sbwidth, (top - last_top), False);
- if (scrollBar.bot < last_bot)
- XClearArea (dpy, scrollBar.win,
- xsb, scrollBar.bot,
- sbwidth, (last_bot - scrollBar.bot), False);
+ if (bot < last_bot)
+ XClearArea (term->dpy, win,
+ xsb, bot,
+ sbwidth, (last_bot - bot), False);
}
else
- XClearWindow (dpy, scrollBar.win);
+ XClearWindow (term->dpy, win);
/* scrollbar slider */
- XFillRectangle (dpy, scrollBar.win, xscrollbarGC,
- xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len);
+ XFillRectangle (term->dpy, win, xscrollbarGC,
+ xsb + 1, top, sbwidth - 2, len);
- XDrawLine (dpy, scrollBar.win, ShadowGC,
- xsb ? 0 : sbwidth, scrollBar.beg,
- xsb ? 0 : sbwidth, scrollBar.end);
+ XDrawLine (term->dpy, win, ShadowGC,
+ xsb ? 0 : sbwidth, beg,
+ xsb ? 0 : sbwidth, end);
return 1;
}
#endif /* XTERM_SCROLLBAR */
return 0;
}
- ret = (term->*update) (refresh, last_top, last_bot, len);
+ ret = (this->*update) (refresh);
last_top = top;
last_bot = bot;
leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr);
}
+void
+scrollBar_t::destroy ()
+{
+#ifdef XTERM_SCROLLBAR
+ if (xscrollbarGC) XFreeGC (term->dpy, xscrollbarGC);
+ if (ShadowGC) XFreeGC (term->dpy, ShadowGC);
+#endif
+#ifdef PLAIN_SCROLLBAR
+ if (pscrollbarGC) XFreeGC (term->dpy, pscrollbarGC);
+#endif
+#ifdef NEXT_SCROLLBAR
+ if (blackGC) XFreeGC (term->dpy, blackGC);
+ if (whiteGC) XFreeGC (term->dpy, whiteGC);
+ if (grayGC) XFreeGC (term->dpy, grayGC);
+ if (darkGC) XFreeGC (term->dpy, darkGC);
+ if (stippleGC) XFreeGC (term->dpy, stippleGC);
+ if (dimple) XFreePixmap (term->dpy, dimple);
+ if (upArrow) XFreePixmap (term->dpy, upArrow);
+ if (downArrow) XFreePixmap (term->dpy, downArrow);
+ if (upArrowHi) XFreePixmap (term->dpy, upArrowHi);
+ if (downArrowHi) XFreePixmap (term->dpy, downArrowHi);
+#endif
+#ifdef RXVT_SCROLLBAR
+ if (topShadowGC) XFreeGC (term->dpy, topShadowGC);
+ if (botShadowGC) XFreeGC (term->dpy, botShadowGC);
+ if (scrollbarGC) XFreeGC (term->dpy, scrollbarGC);
+#endif
+}
+
void
scrollBar_t::update_data ()
{
{
beg = 0;
end = term->szHint.height;
- update = &rxvt_term::scrollbar_show_plain;
+ update = &scrollBar_t::show_plain;
}
#endif
#if defined(XTERM_SCROLLBAR)
{
beg = 0;
end = term->szHint.height;
- update = &rxvt_term::scrollbar_show_xterm;
+ update = &scrollBar_t::show_xterm;
}
#endif
#if defined(NEXT_SCROLLBAR)
{
beg = 0;
end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING);
- update = &rxvt_term::scrollbar_show_next;
+ update = &scrollBar_t::show_next;
}
#endif
#if defined(RXVT_SCROLLBAR)
{
beg = (width + 1) + shadow;
end = term->szHint.height - beg - (2 * shadow);
- update = &rxvt_term::scrollbar_show_rxvt;
+ update = &scrollBar_t::show_rxvt;
}
#endif
}
unsigned char align;
Window win;
Cursor leftptr_cursor;
- int (rxvt_term::*update)(int, int, int, int);
+ int (scrollBar_t::*update)(int);
void setup (rxvt_term *);
// update style dependent data
void update_data ();
void resize ();
int map (int);
int show (int);
+ void destroy ();
bool upButton (int y)
{
{
return width + shadow * 2;
}
+
+#if defined(NEXT_SCROLLBAR)
+ GC blackGC,
+ whiteGC,
+ grayGC,
+ darkGC,
+ stippleGC;
+ Pixmap dimple,
+ upArrow,
+ downArrow,
+ upArrowHi,
+ downArrowHi;
+#endif
+
+#if defined(RXVT_SCROLLBAR)
+ GC scrollbarGC,
+ topShadowGC,
+ botShadowGC;
+#endif
+
+#if defined(XTERM_SCROLLBAR)
+ GC xscrollbarGC,
+ ShadowGC;
+#endif
+
+#if defined(PLAIN_SCROLLBAR)
+ GC pscrollbarGC;
+#endif
+
+ // scrollbar-next.C
+ int show_next (int);
+ // scrollbar-rxvt.C
+ int show_rxvt (int);
+ // scrollbar-xterm.C
+ int show_xterm (int);
+ // scrollbar-plain.C
+ int show_plain (int);
+
+private:
+ void init_next ();
};
#define scrollbar_above_slider(y) ((y) < scrollBar.top)