… | |
… | |
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | *----------------------------------------------------------------------*/ |
22 | *----------------------------------------------------------------------*/ |
23 | |
23 | |
24 | #include "../config.h" /* NECESSARY */ |
24 | #include "../config.h" /* NECESSARY */ |
25 | #include "rxvt.h" /* NECESSARY */ |
25 | #include "rxvt.h" /* NECESSARY */ |
26 | #include "scrollbar-xterm.intpro" /* PROTOS for internal routines */ |
|
|
27 | |
26 | |
28 | /*----------------------------------------------------------------------*/ |
27 | /*----------------------------------------------------------------------*/ |
29 | #if defined(XTERM_SCROLLBAR) |
28 | #if defined(XTERM_SCROLLBAR) |
30 | |
29 | |
31 | #define x_stp_width 8 |
30 | #define x_stp_width 8 |
32 | #define x_stp_height 2 |
31 | #define x_stp_height 2 |
33 | const unsigned char x_stp_bits[] = { 0xaa, 0x55 }; |
32 | const unsigned char x_stp_bits[] = { 0xaa, 0x55 }; |
34 | |
33 | |
35 | int |
34 | int |
36 | rxvt_term::scrollbar_show_xterm (int update __attribute__ ((unused)), int last_top, int last_bot, int scrollbar_len) |
35 | rxvt_term::scrollbar_show_xterm (int update, int last_top, int last_bot, int scrollbar_len) |
37 | { |
36 | { |
38 | int xsb = 0; |
37 | int xsb = 0; |
39 | int sbwidth = scrollBar.width - 1; |
38 | int sbwidth = scrollBar.width - 1; |
40 | |
39 | |
41 | if ((scrollBar.init & R_SB_XTERM) == 0) |
40 | if ((scrollBar.init & R_SB_XTERM) == 0) |
42 | { |
41 | { |
43 | XGCValues gcvalue; |
42 | XGCValues gcvalue; |
44 | |
43 | |
45 | scrollBar.init |= R_SB_XTERM; |
44 | scrollBar.init |= R_SB_XTERM; |
46 | gcvalue.stipple = XCreateBitmapFromData (display->display, scrollBar.win, |
45 | gcvalue.stipple = XCreateBitmapFromData (xdisp, scrollBar.win, |
47 | (char *)x_stp_bits, x_stp_width, |
46 | (char *)x_stp_bits, x_stp_width, |
48 | x_stp_height); |
47 | x_stp_height); |
49 | if (!gcvalue.stipple) |
48 | if (!gcvalue.stipple) |
50 | rxvt_fatal ("can't create bitmap"); |
49 | rxvt_fatal ("can't create bitmap\n"); |
51 | |
50 | |
52 | gcvalue.fill_style = FillOpaqueStippled; |
51 | gcvalue.fill_style = FillOpaqueStippled; |
53 | gcvalue.foreground = PixColors[Color_fg]; |
52 | gcvalue.foreground = pix_colors_focused[Color_fg]; |
54 | gcvalue.background = PixColors[Color_bg]; |
53 | gcvalue.background = pix_colors_focused[Color_bg]; |
55 | |
54 | |
56 | xscrollbarGC = XCreateGC (display->display, scrollBar.win, |
55 | xscrollbarGC = XCreateGC (xdisp, scrollBar.win, |
57 | GCForeground | GCBackground |
56 | GCForeground | GCBackground |
58 | | GCFillStyle | GCStipple, &gcvalue); |
57 | | GCFillStyle | GCStipple, &gcvalue); |
59 | gcvalue.foreground = PixColors[Color_border]; |
58 | gcvalue.foreground = pix_colors_focused[Color_border]; |
60 | ShadowGC = XCreateGC (display->display, scrollBar.win, GCForeground, &gcvalue); |
59 | ShadowGC = XCreateGC (xdisp, scrollBar.win, GCForeground, &gcvalue); |
61 | } |
60 | } |
62 | /* instead of XClearWindow (display->display, scrollBar.win); */ |
|
|
63 | xsb = (Options & Opt_scrollBar_right) ? 1 : 0; |
|
|
64 | if (last_top < scrollBar.top) |
|
|
65 | XClearArea (display->display, scrollBar.win, |
|
|
66 | sb_shadow + xsb, last_top, |
|
|
67 | sbwidth, (scrollBar.top - last_top), False); |
|
|
68 | |
61 | |
|
|
62 | if (update) |
|
|
63 | { |
|
|
64 | xsb = OPTION (Opt_scrollBar_right) ? 1 : 0; |
|
|
65 | if (last_top < scrollBar.top) |
|
|
66 | XClearArea (xdisp, scrollBar.win, |
|
|
67 | sb_shadow + xsb, last_top, |
|
|
68 | sbwidth, (scrollBar.top - last_top), False); |
|
|
69 | |
69 | if (scrollBar.bot < last_bot) |
70 | if (scrollBar.bot < last_bot) |
70 | XClearArea (display->display, scrollBar.win, |
71 | XClearArea (xdisp, scrollBar.win, |
71 | sb_shadow + xsb, scrollBar.bot, |
72 | sb_shadow + xsb, scrollBar.bot, |
72 | sbwidth, (last_bot - scrollBar.bot), False); |
73 | sbwidth, (last_bot - scrollBar.bot), False); |
|
|
74 | } |
|
|
75 | else |
|
|
76 | XClearWindow (xdisp, scrollBar.win); |
73 | |
77 | |
74 | /* scrollbar slider */ |
78 | /* scrollbar slider */ |
75 | XFillRectangle (display->display, scrollBar.win, xscrollbarGC, |
79 | XFillRectangle (xdisp, scrollBar.win, xscrollbarGC, |
76 | xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len); |
80 | xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len); |
77 | |
81 | |
78 | XDrawLine (display->display, scrollBar.win, ShadowGC, |
82 | XDrawLine (xdisp, scrollBar.win, ShadowGC, |
79 | xsb ? 0 : sbwidth, scrollBar.beg, |
83 | xsb ? 0 : sbwidth, scrollBar.beg, |
80 | xsb ? 0 : sbwidth, scrollBar.end); |
84 | xsb ? 0 : sbwidth, scrollBar.end); |
81 | return 1; |
85 | return 1; |
82 | } |
86 | } |
83 | #endif /* XTERM_SCROLLBAR */ |
87 | #endif /* XTERM_SCROLLBAR */ |