1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: scrollbar-rxvt.C |
2 | * File: scrollbar-rxvt.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
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) 1999-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> |
… | |
… | |
45 | } |
45 | } |
46 | } |
46 | } |
47 | |
47 | |
48 | /* draw triangular button with a shadow of 2 pixels */ |
48 | /* draw triangular button with a shadow of 2 pixels */ |
49 | static void |
49 | static void |
50 | draw_button (rxvt_term *term, int x, int y, int state, int dirn) |
50 | draw_button (rxvt_term *term, int x, int y, int dirn) |
51 | { |
51 | { |
52 | unsigned int sz, sz2; |
52 | unsigned int sz, sz2; |
53 | XPoint pt[3]; |
53 | XPoint pt[3]; |
54 | GC top, bot; |
54 | GC top, bot; |
55 | |
55 | |
56 | sz = term->scrollBar.width; |
56 | sz = term->scrollBar.width; |
57 | sz2 = sz / 2; |
57 | sz2 = sz / 2; |
58 | |
58 | |
59 | switch (state) |
59 | if ((dirn == UP && term->scrollBar.state == STATE_UP) |
|
|
60 | || (dirn == DN && term->scrollBar.state == STATE_DOWN)) |
60 | { |
61 | { |
61 | case +1: |
|
|
62 | top = term->topShadowGC; |
|
|
63 | bot = term->botShadowGC; |
|
|
64 | break; |
|
|
65 | case -1: |
|
|
66 | top = term->botShadowGC; |
62 | top = term->botShadowGC; |
67 | bot = term->topShadowGC; |
63 | bot = term->topShadowGC; |
68 | break; |
64 | } |
69 | default: |
65 | else |
70 | top = bot = term->scrollbarGC; |
66 | { |
71 | break; |
67 | top = term->topShadowGC; |
|
|
68 | bot = term->botShadowGC; |
72 | } |
69 | } |
73 | |
70 | |
74 | /* fill triangle */ |
71 | /* fill triangle */ |
75 | pt[0].x = x; |
72 | pt[0].x = x; |
76 | pt[1].x = x + sz - 1; |
73 | pt[1].x = x + sz - 1; |
… | |
… | |
147 | } |
144 | } |
148 | |
145 | |
149 | int |
146 | int |
150 | rxvt_term::scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len) |
147 | rxvt_term::scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len) |
151 | { |
148 | { |
152 | int sbshadow = sb_shadow; |
149 | int sbshadow = scrollBar.shadow; |
153 | int sbwidth = (int)scrollBar.width; |
150 | int sbwidth = (int)scrollBar.width; |
154 | |
151 | |
155 | if ((scrollBar.init & R_SB_RXVT) == 0) |
152 | if ((scrollBar.init & R_SB_RXVT) == 0) |
156 | { |
153 | { |
|
|
154 | XGCValues gcvalue; |
|
|
155 | |
157 | scrollBar.init |= R_SB_RXVT; |
156 | scrollBar.init |= R_SB_RXVT; |
158 | |
157 | |
|
|
158 | gcvalue.foreground = pix_colors[Color_topShadow]; |
|
|
159 | topShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); |
|
|
160 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
|
|
161 | botShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); |
|
|
162 | gcvalue.foreground = pix_colors[ (depth <= 2 ? Color_fg : Color_scroll)]; |
|
|
163 | scrollbarGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); |
159 | if (sbshadow) |
164 | if (sbshadow) |
160 | { |
165 | { |
161 | XSetWindowBackground (dpy, scrollBar.win, pix_colors_focused[Color_trough]); |
166 | XSetWindowBackground (dpy, scrollBar.win, pix_colors_focused[Color_trough]); |
162 | XClearWindow (dpy, scrollBar.win); |
167 | XClearWindow (dpy, scrollBar.win); |
163 | } |
168 | } |
… | |
… | |
185 | /* scrollbar slider */ |
190 | /* scrollbar slider */ |
186 | #ifdef SB_BORDER |
191 | #ifdef SB_BORDER |
187 | { |
192 | { |
188 | int xofs; |
193 | int xofs; |
189 | |
194 | |
190 | if (OPTION (Opt_scrollBar_right)) |
195 | if (option (Opt_scrollBar_right)) |
191 | xofs = 0; |
196 | xofs = 0; |
192 | else |
197 | else |
193 | xofs = sbshadow ? sbwidth : sbwidth - 1; |
198 | xofs = sbshadow ? sbwidth : sbwidth - 1; |
194 | |
199 | |
195 | XDrawLine (dpy, scrollBar.win, botShadowGC, |
200 | XDrawLine (dpy, scrollBar.win, botShadowGC, |
… | |
… | |
207 | |
212 | |
208 | /* shadow for scrollbar slider */ |
213 | /* shadow for scrollbar slider */ |
209 | draw_shadow (this, sbshadow, scrollBar.top, sbwidth, scrollbar_len); |
214 | draw_shadow (this, sbshadow, scrollBar.top, sbwidth, scrollbar_len); |
210 | |
215 | |
211 | /* Redraw scrollbar arrows */ |
216 | /* Redraw scrollbar arrows */ |
212 | draw_button (this, sbshadow, sbshadow, (scrollbar_isUp () ? -1 : +1), UP); |
217 | draw_button (this, sbshadow, sbshadow, UP); |
213 | draw_button (this, sbshadow, scrollBar.end + 1, (scrollbar_isDn () ? -1 : +1), DN); |
218 | draw_button (this, sbshadow, scrollBar.end + 1, DN); |
214 | |
219 | |
215 | return 1; |
220 | return 1; |
216 | } |
221 | } |
217 | #endif /* RXVT_SCROLLBAR */ |
222 | #endif /* RXVT_SCROLLBAR */ |
218 | /*----------------------- end-of-file (C source) -----------------------*/ |
223 | /*----------------------- end-of-file (C source) -----------------------*/ |
219 | |
224 | |