… | |
… | |
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. |
… | |
… | |
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 | |
… | |
… | |
209 | if (strncasecmp (scrollalign, "top", 3) == 0) |
208 | if (strncasecmp (scrollalign, "top", 3) == 0) |
210 | align = R_SB_ALIGN_TOP; |
209 | align = R_SB_ALIGN_TOP; |
211 | else if (strncasecmp (scrollalign, "bottom", 6) == 0) |
210 | else if (strncasecmp (scrollalign, "bottom", 6) == 0) |
212 | align = R_SB_ALIGN_BOTTOM; |
211 | align = R_SB_ALIGN_BOTTOM; |
213 | } |
212 | } |
214 | last_bot = last_state = -1; |
213 | last_state = 0; |
215 | /* cursor scrollBar: Black-on-White */ |
214 | /* cursor scrollBar: Black-on-White */ |
216 | leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr); |
215 | leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr); |
217 | } |
216 | } |
218 | |
217 | |
219 | void |
218 | void |
|
|
219 | scrollBar_t::destroy () |
|
|
220 | { |
|
|
221 | #ifdef XTERM_SCROLLBAR |
|
|
222 | if (xscrollbarGC) XFreeGC (term->dpy, xscrollbarGC); |
|
|
223 | if (ShadowGC) XFreeGC (term->dpy, ShadowGC); |
|
|
224 | #endif |
|
|
225 | #ifdef PLAIN_SCROLLBAR |
|
|
226 | if (pscrollbarGC) XFreeGC (term->dpy, pscrollbarGC); |
|
|
227 | #endif |
|
|
228 | #ifdef NEXT_SCROLLBAR |
|
|
229 | if (blackGC) XFreeGC (term->dpy, blackGC); |
|
|
230 | if (whiteGC) XFreeGC (term->dpy, whiteGC); |
|
|
231 | if (grayGC) XFreeGC (term->dpy, grayGC); |
|
|
232 | if (darkGC) XFreeGC (term->dpy, darkGC); |
|
|
233 | if (stippleGC) XFreeGC (term->dpy, stippleGC); |
|
|
234 | if (dimple) XFreePixmap (term->dpy, dimple); |
|
|
235 | if (upArrow) XFreePixmap (term->dpy, upArrow); |
|
|
236 | if (downArrow) XFreePixmap (term->dpy, downArrow); |
|
|
237 | if (upArrowHi) XFreePixmap (term->dpy, upArrowHi); |
|
|
238 | if (downArrowHi) XFreePixmap (term->dpy, downArrowHi); |
|
|
239 | #endif |
|
|
240 | #ifdef RXVT_SCROLLBAR |
|
|
241 | if (topShadowGC) XFreeGC (term->dpy, topShadowGC); |
|
|
242 | if (botShadowGC) XFreeGC (term->dpy, botShadowGC); |
|
|
243 | if (scrollbarGC) XFreeGC (term->dpy, scrollbarGC); |
|
|
244 | #endif |
|
|
245 | } |
|
|
246 | |
|
|
247 | void |
220 | scrollBar_t::update_data () |
248 | scrollBar_t::update_data () |
221 | { |
249 | { |
222 | #if defined(PLAIN_SCROLLBAR) |
250 | #if defined(PLAIN_SCROLLBAR) |
223 | if (style == R_SB_PLAIN) |
251 | if (style == R_SB_PLAIN) |
224 | { |
252 | { |
225 | beg = 0; |
253 | beg = 0; |
226 | end = term->szHint.height; |
254 | end = term->szHint.height; |
227 | update = &rxvt_term::scrollbar_show_plain; |
255 | update = &scrollBar_t::show_plain; |
228 | } |
256 | } |
229 | #endif |
257 | #endif |
230 | #if defined(XTERM_SCROLLBAR) |
258 | #if defined(XTERM_SCROLLBAR) |
231 | if (style == R_SB_XTERM) |
259 | if (style == R_SB_XTERM) |
232 | { |
260 | { |
233 | beg = 0; |
261 | beg = 0; |
234 | end = term->szHint.height; |
262 | end = term->szHint.height; |
235 | update = &rxvt_term::scrollbar_show_xterm; |
263 | update = &scrollBar_t::show_xterm; |
236 | } |
264 | } |
237 | #endif |
265 | #endif |
238 | #if defined(NEXT_SCROLLBAR) |
266 | #if defined(NEXT_SCROLLBAR) |
239 | if (style == R_SB_NEXT) |
267 | if (style == R_SB_NEXT) |
240 | { |
268 | { |
241 | beg = 0; |
269 | beg = 0; |
242 | end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING); |
270 | end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING); |
243 | update = &rxvt_term::scrollbar_show_next; |
271 | update = &scrollBar_t::show_next; |
244 | } |
272 | } |
245 | #endif |
273 | #endif |
246 | #if defined(RXVT_SCROLLBAR) |
274 | #if defined(RXVT_SCROLLBAR) |
247 | if (style == R_SB_RXVT) |
275 | if (style == R_SB_RXVT) |
248 | { |
276 | { |
249 | beg = (width + 1) + shadow; |
277 | beg = (width + 1) + shadow; |
250 | end = term->szHint.height - beg - (2 * shadow); |
278 | end = term->szHint.height - beg - (2 * shadow); |
251 | update = &rxvt_term::scrollbar_show_rxvt; |
279 | update = &scrollBar_t::show_rxvt; |
252 | } |
280 | } |
253 | #endif |
281 | #endif |
254 | } |
282 | } |
255 | |
283 | |
256 | /*----------------------- end-of-file (C source) -----------------------*/ |
284 | /*----------------------- end-of-file (C source) -----------------------*/ |