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.55 by ayin, Mon Feb 18 09:58:05 2008 UTC

61 61
62void 62void
63rxvt_term::resize_scrollbar () 63rxvt_term::resize_scrollbar ()
64{ 64{
65 int delayed_init = 0; 65 int delayed_init = 0;
66 int window_sb_x = 0;
67
68 if (option (Opt_scrollBar_right))
69 window_sb_x = szHint.width - scrollBar.total_width ();
66 70
67#define R_SCROLLBEG_XTERM 0 71#define R_SCROLLBEG_XTERM 0
68#define R_SCROLLEND_XTERM szHint.height 72#define R_SCROLLEND_XTERM szHint.height
69#define R_SCROLLBEG_NEXT 0 73#define R_SCROLLBEG_NEXT 0
70#define R_SCROLLEND_NEXT szHint.height - (SB_BUTTON_TOTAL_HEIGHT + \ 74#define R_SCROLLEND_NEXT szHint.height - (SB_BUTTON_TOTAL_HEIGHT + \
110 { 114 {
111 /* create the scrollbar window */ 115 /* create the scrollbar window */
112 scrollBar.win = XCreateSimpleWindow (dpy, 116 scrollBar.win = XCreateSimpleWindow (dpy,
113 parent[0], 117 parent[0],
114 window_sb_x, 0, 118 window_sb_x, 0,
115 scrollbar_TotalWidth (), 119 scrollBar.total_width (),
116 szHint.height, 120 szHint.height,
117 0, 121 0,
118 pix_colors[Color_fg], 122 pix_colors[Color_fg],
119 pix_colors[Color_border]); 123 pix_colors[Color_border]);
120 XDefineCursor (dpy, scrollBar.win, scrollBar.leftptr_cursor); 124 XDefineCursor (dpy, scrollBar.win, scrollBar.leftptr_cursor);
125 | Button3MotionMask); 129 | Button3MotionMask);
126 scrollbar_ev.start (display, scrollBar.win); 130 scrollbar_ev.start (display, scrollBar.win);
127 131
128 delayed_init = 1; 132 delayed_init = 1;
129 } 133 }
134 else
135 XMoveResizeWindow (dpy, scrollBar.win,
136 window_sb_x, 0,
137 scrollBar.total_width (), szHint.height);
130 138
131 scrollbar_show (1); 139 scrollbar_show (1);
132 140
133 if (delayed_init) 141 if (delayed_init)
134 XMapWindow (dpy, scrollBar.win); 142 XMapWindow (dpy, scrollBar.win);
139 */ 147 */
140int 148int
141rxvt_term::scrollbar_show (int update) 149rxvt_term::scrollbar_show (int update)
142{ 150{
143 int ret = 0; 151 int ret = 0;
144 int top, bot, len, adj;
145 152
146 if (!scrollBar.state) 153 if (!scrollBar.state)
147 return 0; 154 return 0;
148 155
149 if (update) 156 if (update)
150 { 157 {
151 top = view_start - top_row; 158 int top = view_start - top_row;
152 bot = top + (nrow - 1); 159 int bot = top + (nrow - 1);
153 len = max (nrow - 1 - top_row, 1); 160 int len = max (nrow - 1 - top_row, 1);
154 adj = (((bot - top) * scrollbar_size ()) % len) > 0 ? 1 : 0; 161 int adj = (((bot - top) * scrollBar.size ()) % len) > 0 ? 1 : 0;
155 162
156 scrollBar.top = (scrollBar.beg + (top * scrollbar_size ()) / len); 163 scrollBar.top = (scrollBar.beg + (top * scrollBar.size ()) / len);
157 scrollBar.len = ((bot - top) * scrollbar_size ()) / len + 164 scrollBar.len = ((bot - top) * scrollBar.size ()) / len +
158 scrollbar_minheight () + adj; 165 scrollBar.min_height () + adj;
159 scrollBar.bot = (scrollBar.top + scrollBar.len); 166 scrollBar.bot = (scrollBar.top + scrollBar.len);
160 /* no change */ 167 /* no change */
161 if (scrollBar.top == scrollBar.last_top 168 if (scrollBar.top == scrollBar.last_top
162 && scrollBar.bot == scrollBar.last_bot 169 && scrollBar.bot == scrollBar.last_bot
163 && (scrollBar.state == scrollBar.last_state 170 && (scrollBar.state == scrollBar.last_state
173 180
174 return ret; 181 return ret;
175} 182}
176 183
177void 184void
178rxvt_term::setup_scrollbar (const char *scrollalign, const char *scrollstyle, const char *thickness) 185scrollBar_t::setup (rxvt_term *term)
179{ 186{
180 int i; 187 int i;
181 short style, width; 188 short style, width;
189 const char *scrollalign, *scrollstyle, *thickness;
190
191 this->term = term;
192 scrollalign = term->rs[Rs_scrollBar_align];
193 scrollstyle = term->rs[Rs_scrollstyle];
194 thickness = term->rs[Rs_scrollBar_thickness];
182 195
183# if defined(RXVT_SCROLLBAR) 196# if defined(RXVT_SCROLLBAR)
184 style = R_SB_RXVT; 197 style = R_SB_RXVT;
185# elif defined(XTERM_SCROLLBAR) 198# elif defined(XTERM_SCROLLBAR)
186 style = R_SB_XTERM; 199 style = R_SB_XTERM;
222 if (style != R_SB_NEXT) /* dishonour request - for now */ 235 if (style != R_SB_NEXT) /* dishonour request - for now */
223 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) 236 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM)
224 width = min (i, SB_WIDTH_MAXIMUM); 237 width = min (i, SB_WIDTH_MAXIMUM);
225 238
226# ifdef RXVT_SCROLLBAR 239# ifdef RXVT_SCROLLBAR
227 if (! option (Opt_scrollBar_floating) && style == R_SB_RXVT) 240 if (! term->option (Opt_scrollBar_floating) && style == R_SB_RXVT)
228 scrollBar.shadow = SHADOW_WIDTH; 241 shadow = SHADOW_WIDTH;
229# endif 242# endif
230 243
231 scrollBar.style = style; 244 this->style = style;
232 scrollBar.width = width; 245 this->width = width;
233 246
234 /* scrollBar.align = R_SB_ALIGN_CENTRE; */ 247 /* align = R_SB_ALIGN_CENTRE; */
235 if (scrollalign) 248 if (scrollalign)
236 { 249 {
237 if (strncasecmp (scrollalign, "top", 3) == 0) 250 if (strncasecmp (scrollalign, "top", 3) == 0)
238 scrollBar.align = R_SB_ALIGN_TOP; 251 align = R_SB_ALIGN_TOP;
239 else if (strncasecmp (scrollalign, "bottom", 6) == 0) 252 else if (strncasecmp (scrollalign, "bottom", 6) == 0)
240 scrollBar.align = R_SB_ALIGN_BOTTOM; 253 align = R_SB_ALIGN_BOTTOM;
241 } 254 }
242 scrollBar.last_bot = scrollBar.last_state = -1; 255 last_bot = last_state = -1;
243 /* cursor scrollBar: Black-on-White */ 256 /* cursor scrollBar: Black-on-White */
244 scrollBar.leftptr_cursor = XCreateFontCursor (dpy, XC_left_ptr); 257 leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr);
245} 258}
246 259
247/*----------------------- end-of-file (C source) -----------------------*/ 260/*----------------------- end-of-file (C source) -----------------------*/
248 261

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines