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.49 by ayin, Tue Jan 29 13:57:23 2008 UTC vs.
Revision 1.54 by ayin, Sun Feb 17 12:21:45 2008 UTC

110 { 110 {
111 /* create the scrollbar window */ 111 /* create the scrollbar window */
112 scrollBar.win = XCreateSimpleWindow (dpy, 112 scrollBar.win = XCreateSimpleWindow (dpy,
113 parent[0], 113 parent[0],
114 window_sb_x, 0, 114 window_sb_x, 0,
115 scrollbar_TotalWidth (), 115 scrollBar.total_width (),
116 szHint.height, 116 szHint.height,
117 0, 117 0,
118 pix_colors[Color_fg], 118 pix_colors[Color_fg],
119 pix_colors[Color_border]); 119 pix_colors[Color_border]);
120 XDefineCursor (dpy, scrollBar.win, scrollBar.leftptr_cursor); 120 XDefineCursor (dpy, scrollBar.win, scrollBar.leftptr_cursor);
139 */ 139 */
140int 140int
141rxvt_term::scrollbar_show (int update) 141rxvt_term::scrollbar_show (int update)
142{ 142{
143 int ret = 0; 143 int ret = 0;
144 int top, bot, len, adj;
145 144
146 if (!scrollBar.state) 145 if (!scrollBar.state)
147 return 0; 146 return 0;
148 147
149 if (update) 148 if (update)
150 { 149 {
151 top = view_start - top_row; 150 int top = view_start - top_row;
152 bot = top + (nrow - 1); 151 int bot = top + (nrow - 1);
153 len = max (nrow - 1 - top_row, 1); 152 int len = max (nrow - 1 - top_row, 1);
154 adj = (((bot - top) * scrollbar_size ()) % len) > 0 ? 1 : 0; 153 int adj = (((bot - top) * scrollBar.size ()) % len) > 0 ? 1 : 0;
155 154
156 scrollBar.top = (scrollBar.beg + (top * scrollbar_size ()) / len); 155 scrollBar.top = (scrollBar.beg + (top * scrollBar.size ()) / len);
157 scrollBar.len = ((bot - top) * scrollbar_size ()) / len + 156 scrollBar.len = ((bot - top) * scrollBar.size ()) / len +
158 scrollbar_minheight () + adj; 157 scrollBar.min_height () + adj;
159 scrollBar.bot = (scrollBar.top + scrollBar.len); 158 scrollBar.bot = (scrollBar.top + scrollBar.len);
160 /* no change */ 159 /* no change */
161 if (scrollBar.top == scrollBar.last_top 160 if (scrollBar.top == scrollBar.last_top
162 && scrollBar.bot == scrollBar.last_bot 161 && scrollBar.bot == scrollBar.last_bot
163 && (scrollBar.state == scrollBar.last_state 162 && (scrollBar.state == scrollBar.last_state
173 172
174 return ret; 173 return ret;
175} 174}
176 175
177void 176void
178rxvt_term::setup_scrollbar (const char *scrollalign, const char *scrollstyle, const char *thickness) 177scrollBar_t::setup (rxvt_term *term)
179{ 178{
180 int i; 179 int i;
181 short style, width; 180 short style, width;
181 const char *scrollalign, *scrollstyle, *thickness;
182
183 this->term = term;
184 scrollalign = term->rs[Rs_scrollBar_align];
185 scrollstyle = term->rs[Rs_scrollstyle];
186 thickness = term->rs[Rs_scrollBar_thickness];
182 187
183# if defined(RXVT_SCROLLBAR) 188# if defined(RXVT_SCROLLBAR)
184 style = R_SB_RXVT; 189 style = R_SB_RXVT;
185# elif defined(XTERM_SCROLLBAR) 190# elif defined(XTERM_SCROLLBAR)
186 style = R_SB_XTERM; 191 style = R_SB_XTERM;
222 if (style != R_SB_NEXT) /* dishonour request - for now */ 227 if (style != R_SB_NEXT) /* dishonour request - for now */
223 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) 228 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM)
224 width = min (i, SB_WIDTH_MAXIMUM); 229 width = min (i, SB_WIDTH_MAXIMUM);
225 230
226# ifdef RXVT_SCROLLBAR 231# ifdef RXVT_SCROLLBAR
227 if (! option (Opt_scrollBar_floating) && style == R_SB_RXVT) 232 if (! term->option (Opt_scrollBar_floating) && style == R_SB_RXVT)
228 scrollBar.shadow = SHADOW_WIDTH; 233 shadow = SHADOW_WIDTH;
229# endif 234# endif
230 235
231 scrollBar.style = style; 236 this->style = style;
232 scrollBar.width = width; 237 this->width = width;
233 238
234 /* scrollBar.align = R_SB_ALIGN_CENTRE; */ 239 /* align = R_SB_ALIGN_CENTRE; */
235 if (scrollalign) 240 if (scrollalign)
236 { 241 {
237 if (strncasecmp (scrollalign, "top", 3) == 0) 242 if (strncasecmp (scrollalign, "top", 3) == 0)
238 scrollBar.align = R_SB_ALIGN_TOP; 243 align = R_SB_ALIGN_TOP;
239 else if (strncasecmp (scrollalign, "bottom", 6) == 0) 244 else if (strncasecmp (scrollalign, "bottom", 6) == 0)
240 scrollBar.align = R_SB_ALIGN_BOTTOM; 245 align = R_SB_ALIGN_BOTTOM;
241 } 246 }
242 scrollBar.last_bot = scrollBar.last_state = -1; 247 last_bot = last_state = -1;
243 /* cursor scrollBar: Black-on-White */ 248 /* cursor scrollBar: Black-on-White */
244 scrollBar.leftptr_cursor = XCreateFontCursor (dpy, XC_left_ptr); 249 leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr);
245} 250}
246 251
247/*----------------------- end-of-file (C source) -----------------------*/ 252/*----------------------- end-of-file (C source) -----------------------*/
248 253

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines