--- rxvt-unicode/src/scrollbar.C 2008/02/19 17:49:16 1.62 +++ rxvt-unicode/src/scrollbar.C 2011/09/01 08:11:27 1.74 @@ -6,7 +6,7 @@ * Copyright (c) 1998 Alfredo K. Kojima * - N*XTstep like scrollbars * Copyright (c) 1999-2001 Geoff Wing - * Copyright (c) 2004-2006 Marc Lehmann + * Copyright (c) 2004-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,32 +31,25 @@ /* * Map or unmap a scrollbar. Returns non-zero upon change of state */ -int +void scrollBar_t::map (int map) { - int change = 0; - if (map) { - state = STATE_IDLE; + state = SB_STATE_IDLE; if (!win) resize (); - - if (win) - { - XMapWindow (term->dpy, win); - change = 1; - } + else + XMapWindow (term->dpy, win); } else { - state = 0; - XUnmapWindow (term->dpy, win); - change = 1; - } + state = SB_STATE_OFF; - return change; + if (win) + XUnmapWindow (term->dpy, win); + } } void @@ -74,7 +67,7 @@ { /* create the scrollbar window */ win = XCreateSimpleWindow (term->dpy, - term->parent[0], + term->parent, window_sb_x, 0, total_width (), term->szHint.height, @@ -118,15 +111,14 @@ int sb_top = term->view_start - term->top_row; int sb_bot = sb_top + (term->nrow - 1); int sb_len = max (term->nrow - 1 - term->top_row, 1); - int sb_size = (sb_bot - sb_top) * size (); top = beg + (sb_top * size ()) / sb_len; - bot = top + sb_size / sb_len + min_height () + (sb_size % sb_len > 0); + bot = top + ecb_div_ru ((sb_bot - sb_top) * size (), sb_len) + min_height (); /* no change */ if (top == last_top && bot == last_bot && (state == last_state - || !(state == STATE_UP || state == STATE_DOWN))) + || !(state == SB_STATE_UP || state == SB_STATE_DOWN))) return 0; } @@ -142,8 +134,7 @@ void scrollBar_t::setup (rxvt_term *term) { - int i; - short style, width; + int i; const char *scrollalign, *scrollstyle, *thickness; this->term = term; @@ -152,15 +143,15 @@ thickness = term->rs[Rs_scrollBar_thickness]; # if defined(RXVT_SCROLLBAR) - style = R_SB_RXVT; + style = SB_STYLE_RXVT; # elif defined(XTERM_SCROLLBAR) - style = R_SB_XTERM; + style = SB_STYLE_XTERM; # elif defined(NEXT_SCROLLBAR) - style = R_SB_NEXT; + style = SB_STYLE_NEXT; # elif defined(PLAIN_SCROLLBAR) - style = R_SB_PLAIN; + style = SB_STYLE_PLAIN; #else - style = R_SB_RXVT; + style = SB_STYLE_RXVT; # endif # if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR)) @@ -168,49 +159,46 @@ { # ifdef NEXT_SCROLLBAR if (strncasecmp (scrollstyle, "next", 4) == 0) - style = R_SB_NEXT; + style = SB_STYLE_NEXT; # endif # ifdef XTERM_SCROLLBAR if (strncasecmp (scrollstyle, "xterm", 5) == 0) - style = R_SB_XTERM; + style = SB_STYLE_XTERM; # endif # ifdef PLAIN_SCROLLBAR if (strncasecmp (scrollstyle, "plain", 5) == 0) - style = R_SB_PLAIN; + style = SB_STYLE_PLAIN; # endif } # endif - if (style == R_SB_NEXT) + if (style == SB_STYLE_NEXT) width = SB_WIDTH_NEXT; - else if (style == R_SB_XTERM) + else if (style == SB_STYLE_XTERM) width = SB_WIDTH_XTERM; - else if (style == R_SB_PLAIN) + else if (style == SB_STYLE_PLAIN) width = SB_WIDTH_PLAIN; - else /* if (style == R_SB_RXVT) */ + else /* if (style == SB_STYLE_RXVT) */ width = SB_WIDTH_RXVT; - if (style != R_SB_NEXT) /* dishonour request - for now */ + if (style != SB_STYLE_NEXT) /* dishonour request - for now */ if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) width = min (i, SB_WIDTH_MAXIMUM); # ifdef RXVT_SCROLLBAR - if (! term->option (Opt_scrollBar_floating) && style == R_SB_RXVT) + if (! term->option (Opt_scrollBar_floating) && style == SB_STYLE_RXVT) shadow = SHADOW_WIDTH; # endif - this->style = style; - this->width = width; - - /* align = R_SB_ALIGN_CENTRE; */ + /* align = SB_ALIGN_CENTRE; */ if (scrollalign) { if (strncasecmp (scrollalign, "top", 3) == 0) - align = R_SB_ALIGN_TOP; + align = SB_ALIGN_TOP; else if (strncasecmp (scrollalign, "bottom", 6) == 0) - align = R_SB_ALIGN_BOTTOM; + align = SB_ALIGN_BOTTOM; } - last_bot = last_state = -1; + last_state = SB_STATE_OFF; /* cursor scrollBar: Black-on-White */ leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr); } @@ -248,7 +236,7 @@ scrollBar_t::update_data () { #if defined(PLAIN_SCROLLBAR) - if (style == R_SB_PLAIN) + if (style == SB_STYLE_PLAIN) { beg = 0; end = term->szHint.height; @@ -256,7 +244,7 @@ } #endif #if defined(XTERM_SCROLLBAR) - if (style == R_SB_XTERM) + if (style == SB_STYLE_XTERM) { beg = 0; end = term->szHint.height; @@ -264,7 +252,7 @@ } #endif #if defined(NEXT_SCROLLBAR) - if (style == R_SB_NEXT) + if (style == SB_STYLE_NEXT) { beg = 0; end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING); @@ -272,7 +260,7 @@ } #endif #if defined(RXVT_SCROLLBAR) - if (style == R_SB_RXVT) + if (style == SB_STYLE_RXVT) { beg = (width + 1) + shadow; end = term->szHint.height - beg - (2 * shadow);