ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.C
(Generate patch)

Comparing rxvt-unicode/src/scrollbar.C (file contents):
Revision 1.60 by ayin, Tue Feb 19 10:47:03 2008 UTC vs.
Revision 1.68 by sf-exg, Mon Aug 22 17:09:46 2011 UTC

4 * 4 *
5 * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA> 5 * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA>
6 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> 6 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org>
7 * - N*XTstep like scrollbars 7 * - N*XTstep like scrollbars
8 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> 8 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
9 * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com> 9 * Copyright (c) 2004-2006 Marc Lehmann <schmorp@schmorp.de>
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. 14 * (at your option) any later version.
49 change = 1; 49 change = 1;
50 } 50 }
51 } 51 }
52 else 52 else
53 { 53 {
54 state = 0; 54 state = STATE_OFF;
55 XUnmapWindow (term->dpy, win); 55 XUnmapWindow (term->dpy, win);
56 change = 1; 56 change = 1;
57 } 57 }
58 58
59 return change; 59 return change;
72 72
73 if (!win) 73 if (!win)
74 { 74 {
75 /* create the scrollbar window */ 75 /* create the scrollbar window */
76 win = XCreateSimpleWindow (term->dpy, 76 win = XCreateSimpleWindow (term->dpy,
77 term->parent[0], 77 term->parent,
78 window_sb_x, 0, 78 window_sb_x, 0,
79 total_width (), 79 total_width (),
80 term->szHint.height, 80 term->szHint.height,
81 0, 81 0,
82 term->pix_colors[Color_fg], 82 term->pix_colors[Color_fg],
119 int sb_bot = sb_top + (term->nrow - 1); 119 int sb_bot = sb_top + (term->nrow - 1);
120 int sb_len = max (term->nrow - 1 - term->top_row, 1); 120 int sb_len = max (term->nrow - 1 - term->top_row, 1);
121 int sb_size = (sb_bot - sb_top) * size (); 121 int sb_size = (sb_bot - sb_top) * size ();
122 122
123 top = beg + (sb_top * size ()) / sb_len; 123 top = beg + (sb_top * size ()) / sb_len;
124 len = sb_size / sb_len + min_height () + (sb_size % sb_len > 0); 124 bot = top + sb_size / sb_len + min_height () + (sb_size % sb_len > 0);
125 bot = top + len;
126 /* no change */ 125 /* no change */
127 if (top == last_top 126 if (top == last_top
128 && bot == last_bot 127 && bot == last_bot
129 && (state == last_state 128 && (state == last_state
130 || !(state == STATE_UP || state == STATE_DOWN))) 129 || !(state == STATE_UP || state == STATE_DOWN)))
131 return 0; 130 return 0;
132 } 131 }
133 132
134 ret = (term->*update) (refresh, last_top, last_bot, len); 133 ret = (this->*update) (refresh);
135 134
136 last_top = top; 135 last_top = top;
137 last_bot = bot; 136 last_bot = bot;
138 last_state = state; 137 last_state = state;
139 138
142 141
143void 142void
144scrollBar_t::setup (rxvt_term *term) 143scrollBar_t::setup (rxvt_term *term)
145{ 144{
146 int i; 145 int i;
147 short style, width; 146 short width;
148 const char *scrollalign, *scrollstyle, *thickness; 147 const char *scrollalign, *scrollstyle, *thickness;
148 enum sb_style style;
149 149
150 this->term = term; 150 this->term = term;
151 scrollalign = term->rs[Rs_scrollBar_align]; 151 scrollalign = term->rs[Rs_scrollBar_align];
152 scrollstyle = term->rs[Rs_scrollstyle]; 152 scrollstyle = term->rs[Rs_scrollstyle];
153 thickness = term->rs[Rs_scrollBar_thickness]; 153 thickness = term->rs[Rs_scrollBar_thickness];
209 if (strncasecmp (scrollalign, "top", 3) == 0) 209 if (strncasecmp (scrollalign, "top", 3) == 0)
210 align = R_SB_ALIGN_TOP; 210 align = R_SB_ALIGN_TOP;
211 else if (strncasecmp (scrollalign, "bottom", 6) == 0) 211 else if (strncasecmp (scrollalign, "bottom", 6) == 0)
212 align = R_SB_ALIGN_BOTTOM; 212 align = R_SB_ALIGN_BOTTOM;
213 } 213 }
214 last_bot = last_state = -1; 214 last_state = STATE_OFF;
215 /* cursor scrollBar: Black-on-White */ 215 /* cursor scrollBar: Black-on-White */
216 leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr); 216 leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr);
217} 217}
218 218
219void 219void
220scrollBar_t::destroy ()
221{
222#ifdef XTERM_SCROLLBAR
223 if (xscrollbarGC) XFreeGC (term->dpy, xscrollbarGC);
224 if (ShadowGC) XFreeGC (term->dpy, ShadowGC);
225#endif
226#ifdef PLAIN_SCROLLBAR
227 if (pscrollbarGC) XFreeGC (term->dpy, pscrollbarGC);
228#endif
229#ifdef NEXT_SCROLLBAR
230 if (blackGC) XFreeGC (term->dpy, blackGC);
231 if (whiteGC) XFreeGC (term->dpy, whiteGC);
232 if (grayGC) XFreeGC (term->dpy, grayGC);
233 if (darkGC) XFreeGC (term->dpy, darkGC);
234 if (stippleGC) XFreeGC (term->dpy, stippleGC);
235 if (dimple) XFreePixmap (term->dpy, dimple);
236 if (upArrow) XFreePixmap (term->dpy, upArrow);
237 if (downArrow) XFreePixmap (term->dpy, downArrow);
238 if (upArrowHi) XFreePixmap (term->dpy, upArrowHi);
239 if (downArrowHi) XFreePixmap (term->dpy, downArrowHi);
240#endif
241#ifdef RXVT_SCROLLBAR
242 if (topShadowGC) XFreeGC (term->dpy, topShadowGC);
243 if (botShadowGC) XFreeGC (term->dpy, botShadowGC);
244 if (scrollbarGC) XFreeGC (term->dpy, scrollbarGC);
245#endif
246}
247
248void
220scrollBar_t::update_data () 249scrollBar_t::update_data ()
221{ 250{
222#if defined(PLAIN_SCROLLBAR) 251#if defined(PLAIN_SCROLLBAR)
223 if (style == R_SB_PLAIN) 252 if (style == R_SB_PLAIN)
224 { 253 {
225 beg = 0; 254 beg = 0;
226 end = term->szHint.height; 255 end = term->szHint.height;
227 update = &rxvt_term::scrollbar_show_plain; 256 update = &scrollBar_t::show_plain;
228 } 257 }
229#endif 258#endif
230#if defined(XTERM_SCROLLBAR) 259#if defined(XTERM_SCROLLBAR)
231 if (style == R_SB_XTERM) 260 if (style == R_SB_XTERM)
232 { 261 {
233 beg = 0; 262 beg = 0;
234 end = term->szHint.height; 263 end = term->szHint.height;
235 update = &rxvt_term::scrollbar_show_xterm; 264 update = &scrollBar_t::show_xterm;
236 } 265 }
237#endif 266#endif
238#if defined(NEXT_SCROLLBAR) 267#if defined(NEXT_SCROLLBAR)
239 if (style == R_SB_NEXT) 268 if (style == R_SB_NEXT)
240 { 269 {
241 beg = 0; 270 beg = 0;
242 end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING); 271 end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING);
243 update = &rxvt_term::scrollbar_show_next; 272 update = &scrollBar_t::show_next;
244 } 273 }
245#endif 274#endif
246#if defined(RXVT_SCROLLBAR) 275#if defined(RXVT_SCROLLBAR)
247 if (style == R_SB_RXVT) 276 if (style == R_SB_RXVT)
248 { 277 {
249 beg = (width + 1) + shadow; 278 beg = (width + 1) + shadow;
250 end = term->szHint.height - beg - (2 * shadow); 279 end = term->szHint.height - beg - (2 * shadow);
251 update = &rxvt_term::scrollbar_show_rxvt; 280 update = &scrollBar_t::show_rxvt;
252 } 281 }
253#endif 282#endif
254} 283}
255 284
256/*----------------------- end-of-file (C source) -----------------------*/ 285/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines