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.67 by sf-exg, Mon Aug 22 17:08:52 2011 UTC vs.
Revision 1.71 by sf-exg, Sun Aug 28 18:48:41 2011 UTC

29/*----------------------------------------------------------------------*/ 29/*----------------------------------------------------------------------*/
30 30
31/* 31/*
32 * Map or unmap a scrollbar. Returns non-zero upon change of state 32 * Map or unmap a scrollbar. Returns non-zero upon change of state
33 */ 33 */
34int 34void
35scrollBar_t::map (int map) 35scrollBar_t::map (int map)
36{ 36{
37 int change = 0;
38
39 if (map) 37 if (map)
40 { 38 {
41 state = STATE_IDLE; 39 state = STATE_IDLE;
42 40
43 if (!win) 41 if (!win)
44 resize (); 42 resize ();
45 43
46 if (win) 44 if (win)
47 { 45 {
48 XMapWindow (term->dpy, win); 46 XMapWindow (term->dpy, win);
49 change = 1;
50 } 47 }
51 } 48 }
52 else 49 else
53 { 50 {
54 state = 0; 51 state = STATE_OFF;
55 XUnmapWindow (term->dpy, win); 52 XUnmapWindow (term->dpy, win);
56 change = 1;
57 } 53 }
58
59 return change;
60} 54}
61 55
62void 56void
63scrollBar_t::resize () 57scrollBar_t::resize ()
64{ 58{
116 if (refresh) 110 if (refresh)
117 { 111 {
118 int sb_top = term->view_start - term->top_row; 112 int sb_top = term->view_start - term->top_row;
119 int sb_bot = sb_top + (term->nrow - 1); 113 int sb_bot = sb_top + (term->nrow - 1);
120 int sb_len = max (term->nrow - 1 - term->top_row, 1); 114 int sb_len = max (term->nrow - 1 - term->top_row, 1);
121 int sb_size = (sb_bot - sb_top) * size ();
122 115
123 top = beg + (sb_top * size ()) / sb_len; 116 top = beg + (sb_top * size ()) / sb_len;
124 bot = top + sb_size / sb_len + min_height () + (sb_size % sb_len > 0); 117 bot = top + ecb_div_ru ((sb_bot - sb_top) * size (), sb_len) + min_height ();
125 /* no change */ 118 /* no change */
126 if (top == last_top 119 if (top == last_top
127 && bot == last_bot 120 && bot == last_bot
128 && (state == last_state 121 && (state == last_state
129 || !(state == STATE_UP || state == STATE_DOWN))) 122 || !(state == STATE_UP || state == STATE_DOWN)))
141 134
142void 135void
143scrollBar_t::setup (rxvt_term *term) 136scrollBar_t::setup (rxvt_term *term)
144{ 137{
145 int i; 138 int i;
146 short style, width;
147 const char *scrollalign, *scrollstyle, *thickness; 139 const char *scrollalign, *scrollstyle, *thickness;
148 140
149 this->term = term; 141 this->term = term;
150 scrollalign = term->rs[Rs_scrollBar_align]; 142 scrollalign = term->rs[Rs_scrollBar_align];
151 scrollstyle = term->rs[Rs_scrollstyle]; 143 scrollstyle = term->rs[Rs_scrollstyle];
197# ifdef RXVT_SCROLLBAR 189# ifdef RXVT_SCROLLBAR
198 if (! term->option (Opt_scrollBar_floating) && style == R_SB_RXVT) 190 if (! term->option (Opt_scrollBar_floating) && style == R_SB_RXVT)
199 shadow = SHADOW_WIDTH; 191 shadow = SHADOW_WIDTH;
200# endif 192# endif
201 193
202 this->style = style;
203 this->width = width;
204
205 /* align = R_SB_ALIGN_CENTRE; */ 194 /* align = R_SB_ALIGN_CENTRE; */
206 if (scrollalign) 195 if (scrollalign)
207 { 196 {
208 if (strncasecmp (scrollalign, "top", 3) == 0) 197 if (strncasecmp (scrollalign, "top", 3) == 0)
209 align = R_SB_ALIGN_TOP; 198 align = R_SB_ALIGN_TOP;
210 else if (strncasecmp (scrollalign, "bottom", 6) == 0) 199 else if (strncasecmp (scrollalign, "bottom", 6) == 0)
211 align = R_SB_ALIGN_BOTTOM; 200 align = R_SB_ALIGN_BOTTOM;
212 } 201 }
213 last_state = 0; 202 last_state = STATE_OFF;
214 /* cursor scrollBar: Black-on-White */ 203 /* cursor scrollBar: Black-on-White */
215 leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr); 204 leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr);
216} 205}
217 206
218void 207void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines