1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: scrollbar.c |
2 | * File: scrollbar.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: scrollbar.C,v 1.2 2003/11/24 17:31:28 pcg Exp $ |
4 | * $Id: scrollbar.C,v 1.5 2003/12/18 05:45:11 pcg Exp $ |
5 | * |
5 | * |
6 | * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA> |
6 | * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA> |
7 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
7 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
8 | * - N*XTstep like scrollbars |
8 | * - N*XTstep like scrollbars |
9 | * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> |
9 | * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> |
… | |
… | |
38 | { |
38 | { |
39 | int change = 0; |
39 | int change = 0; |
40 | #ifdef HAVE_SCROLLBARS |
40 | #ifdef HAVE_SCROLLBARS |
41 | |
41 | |
42 | if (map && !scrollbar_visible(R)) { |
42 | if (map && !scrollbar_visible(R)) { |
43 | scrollbar_setIdle(); |
43 | R->scrollBar.setIdle (); |
44 | if (!R->scrollBar.win) |
44 | if (!R->scrollBar.win) |
45 | rxvt_Resize_scrollBar(aR); |
45 | rxvt_Resize_scrollBar(aR); |
46 | if (R->scrollBar.win) { |
46 | if (R->scrollBar.win) { |
47 | XMapWindow(R->Xdisplay, R->scrollBar.win); |
47 | XMapWindow(R->Xdisplay, R->scrollBar.win); |
48 | change = 1; |
48 | change = 1; |
… | |
… | |
96 | |
96 | |
97 | if (!R->scrollBar.win) { |
97 | if (!R->scrollBar.win) { |
98 | /* create the scrollbar window */ |
98 | /* create the scrollbar window */ |
99 | R->scrollBar.win = XCreateSimpleWindow(R->Xdisplay, |
99 | R->scrollBar.win = XCreateSimpleWindow(R->Xdisplay, |
100 | R->TermWin.parent[0], |
100 | R->TermWin.parent[0], |
101 | R->h->window_sb_x, 0, |
101 | R->window_sb_x, 0, |
102 | scrollbar_TotalWidth(), |
102 | scrollbar_TotalWidth(), |
103 | R->szHint.height, |
103 | R->szHint.height, |
104 | 0, |
104 | 0, |
105 | R->PixColors[Color_fg], |
105 | R->PixColors[Color_fg], |
106 | R->PixColors[Color_bg]); |
106 | R->PixColors[Color_bg]); |
107 | #ifdef DEBUG_X |
107 | #ifdef DEBUG_X |
108 | XStoreName(R->Xdisplay, R->scrollBar.win, "scrollbar"); |
108 | XStoreName(R->Xdisplay, R->scrollBar.win, "scrollbar"); |
109 | #endif |
109 | #endif |
110 | XDefineCursor(R->Xdisplay, R->scrollBar.win, R->h->pointer_leftptr); |
110 | XDefineCursor(R->Xdisplay, R->scrollBar.win, R->leftptr_cursor); |
111 | XSelectInput(R->Xdisplay, R->scrollBar.win, |
111 | XSelectInput(R->Xdisplay, R->scrollBar.win, |
112 | (ExposureMask | ButtonPressMask | ButtonReleaseMask |
112 | (ExposureMask | ButtonPressMask | ButtonReleaseMask |
113 | | Button1MotionMask | Button2MotionMask |
113 | | Button1MotionMask | Button2MotionMask |
114 | | Button3MotionMask)); |
114 | | Button3MotionMask)); |
115 | delayed_init = 1; |
115 | delayed_init = 1; |
… | |
… | |
139 | bot = top + (R->TermWin.nrow - 1); |
139 | bot = top + (R->TermWin.nrow - 1); |
140 | len = max((R->TermWin.nscrolled + (R->TermWin.nrow - 1)), 1); |
140 | len = max((R->TermWin.nscrolled + (R->TermWin.nrow - 1)), 1); |
141 | adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0; |
141 | adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0; |
142 | |
142 | |
143 | R->scrollBar.top = (R->scrollBar.beg + (top * scrollbar_size()) / len); |
143 | R->scrollBar.top = (R->scrollBar.beg + (top * scrollbar_size()) / len); |
144 | R->h->scrollbar_len = ((bot - top) * scrollbar_size()) / len + |
144 | R->scrollbar_len = ((bot - top) * scrollbar_size()) / len + |
145 | scrollbar_minheight() + adj; |
145 | scrollbar_minheight() + adj; |
146 | R->scrollBar.bot = (R->scrollBar.top + R->h->scrollbar_len); |
146 | R->scrollBar.bot = (R->scrollBar.top + R->scrollbar_len); |
147 | /* no change */ |
147 | /* no change */ |
148 | if (R->scrollBar.top == R->h->last_top |
148 | if (R->scrollBar.top == R->last_top |
149 | && R->scrollBar.bot == R->h->last_bot |
149 | && R->scrollBar.bot == R->last_bot |
150 | && (R->scrollBar.state == R->h->last_state || !scrollbar_isUpDn())) |
150 | && (R->scrollBar.state == R->last_state || !scrollbar_isUpDn())) |
151 | return 0; |
151 | return 0; |
152 | } |
152 | } |
153 | |
153 | |
154 | ret = R->scrollBar.update(aR_ update, R->h->last_top, R->h->last_bot, |
154 | ret = R->scrollBar.update(aR_ update, R->last_top, R->last_bot, |
155 | R->h->scrollbar_len); |
155 | R->scrollbar_len); |
156 | |
156 | |
157 | R->h->last_top = R->scrollBar.top; |
157 | R->last_top = R->scrollBar.top; |
158 | R->h->last_bot = R->scrollBar.bot; |
158 | R->last_bot = R->scrollBar.bot; |
159 | R->h->last_state = R->scrollBar.state; |
159 | R->last_state = R->scrollBar.state; |
160 | |
160 | |
161 | #endif |
161 | #endif |
162 | return ret; |
162 | return ret; |
163 | } |
163 | } |
164 | |
164 | |
… | |
… | |
209 | # endif |
209 | # endif |
210 | |
210 | |
211 | R->scrollBar.style = style; |
211 | R->scrollBar.style = style; |
212 | R->scrollBar.width = width; |
212 | R->scrollBar.width = width; |
213 | |
213 | |
214 | /* R->h->scrollbar_align = R_SB_ALIGN_CENTRE; */ |
214 | /* R->scrollbar_align = R_SB_ALIGN_CENTRE; */ |
215 | if (scrollalign) { |
215 | if (scrollalign) { |
216 | if (STRNCASECMP(scrollalign, "top", 3) == 0) |
216 | if (STRNCASECMP(scrollalign, "top", 3) == 0) |
217 | R->h->scrollbar_align = R_SB_ALIGN_TOP; |
217 | R->scrollbar_align = R_SB_ALIGN_TOP; |
218 | else if (STRNCASECMP(scrollalign, "bottom", 6) == 0) |
218 | else if (STRNCASECMP(scrollalign, "bottom", 6) == 0) |
219 | R->h->scrollbar_align = R_SB_ALIGN_BOTTOM; |
219 | R->scrollbar_align = R_SB_ALIGN_BOTTOM; |
220 | } |
220 | } |
221 | #endif |
221 | #endif |
222 | } |
222 | } |
223 | |
223 | |
224 | /*----------------------- end-of-file (C source) -----------------------*/ |
224 | /*----------------------- end-of-file (C source) -----------------------*/ |