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.7 by pcg, Thu Dec 18 14:11:47 2003 UTC vs.
Revision 1.8 by pcg, Sat Jan 31 00:20:21 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: scrollbar.c 2 * File: scrollbar.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: scrollbar.C,v 1.7 2003/12/18 14:11:47 pcg Exp $ 4 * $Id: scrollbar.C,v 1.8 2004/01/31 00:20:21 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>
30/*----------------------------------------------------------------------*/ 30/*----------------------------------------------------------------------*/
31 31
32/* 32/*
33 * Map or unmap a scrollbar. Returns non-zero upon change of state 33 * Map or unmap a scrollbar. Returns non-zero upon change of state
34 */ 34 */
35/* EXTPROTO */
36int 35int
37rxvt_scrollbar_mapping(pR_ int map) 36rxvt_term::scrollbar_mapping (int map)
38{ 37{
39 int change = 0; 38 int change = 0;
40 39
41#ifdef HAVE_SCROLLBARS 40#ifdef HAVE_SCROLLBARS
42 if (map && !scrollbar_visible(R)) { 41 if (map && !scrollbar_visible()) {
43 R->scrollBar.setIdle (); 42 scrollBar.setIdle ();
44 if (!R->scrollBar.win) 43 if (!scrollBar.win)
45 R->resize_scrollbar (); 44 resize_scrollbar ();
46 if (R->scrollBar.win) { 45 if (scrollBar.win) {
47 XMapWindow(R->Xdisplay, R->scrollBar.win); 46 XMapWindow(Xdisplay, scrollBar.win);
48 change = 1; 47 change = 1;
49 } 48 }
50 } else if (!map && scrollbar_visible(R)) { 49 } else if (!map && scrollbar_visible()) {
51 R->scrollBar.state = 0; 50 scrollBar.state = 0;
52 XUnmapWindow(R->Xdisplay, R->scrollBar.win); 51 XUnmapWindow(Xdisplay, scrollBar.win);
53 change = 1; 52 change = 1;
54 } 53 }
55#endif 54#endif
56 return change; 55 return change;
57} 56}
73 72
74#if defined(XTERM_SCROLLBAR) 73#if defined(XTERM_SCROLLBAR)
75 if (scrollBar.style == R_SB_XTERM) { 74 if (scrollBar.style == R_SB_XTERM) {
76 scrollBar.beg = R_SCROLLBEG_XTERM; 75 scrollBar.beg = R_SCROLLBEG_XTERM;
77 scrollBar.end = R_SCROLLEND_XTERM; 76 scrollBar.end = R_SCROLLEND_XTERM;
78 scrollBar.update = rxvt_scrollbar_show_xterm; 77 //scrollBar.update = rxvt_scrollbar_show_xterm;
79 } 78 }
80#endif 79#endif
81#if defined(NEXT_SCROLLBAR) 80#if defined(NEXT_SCROLLBAR)
82 if (scrollBar.style == R_SB_NEXT) { 81 if (scrollBar.style == R_SB_NEXT) {
83 scrollBar.beg = R_SCROLLBEG_NEXT; 82 scrollBar.beg = R_SCROLLBEG_NEXT;
84 scrollBar.end = R_SCROLLEND_NEXT; 83 scrollBar.end = R_SCROLLEND_NEXT;
85 scrollBar.update = rxvt_scrollbar_show_next; 84 //scrollBar.update = rxvt_scrollbar_show_next;
86 } 85 }
87#endif 86#endif
88#if defined(RXVT_SCROLLBAR) 87#if defined(RXVT_SCROLLBAR)
89 if (scrollBar.style == R_SB_RXVT) { 88 if (scrollBar.style == R_SB_RXVT) {
90 scrollBar.beg = R_SCROLLBEG_RXVT; 89 scrollBar.beg = R_SCROLLBEG_RXVT;
91 scrollBar.end = R_SCROLLEND_RXVT; 90 scrollBar.end = R_SCROLLEND_RXVT;
92 scrollBar.update = rxvt_scrollbar_show_rxvt; 91 //scrollBar.update = rxvt_scrollbar_show_rxvt;
93 } 92 }
94#endif 93#endif
95 94
96 if (!scrollBar.win) { 95 if (!scrollBar.win) {
97/* create the scrollbar window */ 96/* create the scrollbar window */
111 (ExposureMask | ButtonPressMask | ButtonReleaseMask 110 (ExposureMask | ButtonPressMask | ButtonReleaseMask
112 | Button1MotionMask | Button2MotionMask 111 | Button1MotionMask | Button2MotionMask
113 | Button3MotionMask)); 112 | Button3MotionMask));
114 delayed_init = 1; 113 delayed_init = 1;
115 } 114 }
116 rxvt_scrollbar_show (this, 1); 115 scrollbar_show (1);
117 if (delayed_init) 116 if (delayed_init)
118 XMapWindow (Xdisplay, scrollBar.win); 117 XMapWindow (Xdisplay, scrollBar.win);
119#endif 118#endif
120} 119}
121 120
122/* 121/*
123 * Update current scrollbar view w.r.t. slider heights, etc. 122 * Update current scrollbar view w.r.t. slider heights, etc.
124 */ 123 */
125/* EXTPROTO */
126int 124int
127rxvt_scrollbar_show(pR_ int update) 125rxvt_term::scrollbar_show (int update)
128{ 126{
129 int ret = 0; 127 int ret = 0;
130#ifdef HAVE_SCROLLBARS 128#ifdef HAVE_SCROLLBARS
131 int top, bot, len, adj; 129 int top, bot, len, adj;
132 130
133 if (!scrollbar_visible(R)) 131 if (!scrollbar_visible())
134 return 0; 132 return 0;
135 133
136 if (update) { 134 if (update) {
137 top = (R->TermWin.nscrolled - R->TermWin.view_start); 135 top = (TermWin.nscrolled - TermWin.view_start);
138 bot = top + (R->TermWin.nrow - 1); 136 bot = top + (TermWin.nrow - 1);
139 len = max((R->TermWin.nscrolled + (R->TermWin.nrow - 1)), 1); 137 len = max((TermWin.nscrolled + (TermWin.nrow - 1)), 1);
140 adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0; 138 adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0;
141 139
142 R->scrollBar.top = (R->scrollBar.beg + (top * scrollbar_size()) / len); 140 scrollBar.top = (scrollBar.beg + (top * scrollbar_size()) / len);
143 R->scrollbar_len = ((bot - top) * scrollbar_size()) / len + 141 scrollbar_len = ((bot - top) * scrollbar_size()) / len +
144 scrollbar_minheight() + adj; 142 scrollbar_minheight() + adj;
145 R->scrollBar.bot = (R->scrollBar.top + R->scrollbar_len); 143 scrollBar.bot = (scrollBar.top + scrollbar_len);
146 /* no change */ 144 /* no change */
147 if (R->scrollBar.top == R->last_top 145 if (scrollBar.top == last_top
148 && R->scrollBar.bot == R->last_bot 146 && scrollBar.bot == last_bot
149 && (R->scrollBar.state == R->last_state || !scrollbar_isUpDn())) 147 && (scrollBar.state == last_state || !scrollbar_isUpDn()))
150 return 0; 148 return 0;
151 } 149 }
152 150
153 ret = R->scrollBar.update(aR_ update, R->last_top, R->last_bot, 151 ret = scrollbar_update (update, last_top, last_bot, scrollbar_len);
154 R->scrollbar_len);
155 152
156 R->last_top = R->scrollBar.top; 153 last_top = scrollBar.top;
157 R->last_bot = R->scrollBar.bot; 154 last_bot = scrollBar.bot;
158 R->last_state = R->scrollBar.state; 155 last_state = scrollBar.state;
159#endif 156#endif
160 157
161 return ret; 158 return ret;
162} 159}
163 160
164/* EXTPROTO */
165void 161void
166rxvt_setup_scrollbar(pR_ const char *scrollalign, const char *scrollstyle, const char *thickness) 162rxvt_term::setup_scrollbar (const char *scrollalign, const char *scrollstyle, const char *thickness)
167{ 163{
168#ifdef HAVE_SCROLLBARS 164#ifdef HAVE_SCROLLBARS
169 int i; 165 int i;
170 short style, width; 166 short style, width;
171 167
201 if (style != R_SB_NEXT) /* dishonour request - for now */ 197 if (style != R_SB_NEXT) /* dishonour request - for now */
202 if (thickness && (i = atoi(thickness)) >= SB_WIDTH_MINIMUM) 198 if (thickness && (i = atoi(thickness)) >= SB_WIDTH_MINIMUM)
203 width = min(i, SB_WIDTH_MAXIMUM); 199 width = min(i, SB_WIDTH_MAXIMUM);
204 200
205# if defined(RXVT_SCROLLBAR) 201# if defined(RXVT_SCROLLBAR)
206 if (!(R->Options & Opt_scrollBar_floating) && style == R_SB_RXVT) 202 if (!(Options & Opt_scrollBar_floating) && style == R_SB_RXVT)
207 R->sb_shadow = SHADOW; 203 sb_shadow = SHADOW;
208# endif 204# endif
209 205
210 R->scrollBar.style = style; 206 scrollBar.style = style;
211 R->scrollBar.width = width; 207 scrollBar.width = width;
212 208
213 /* R->scrollbar_align = R_SB_ALIGN_CENTRE; */ 209 /* scrollbar_align = R_SB_ALIGN_CENTRE; */
214 if (scrollalign) { 210 if (scrollalign) {
215 if (STRNCASECMP(scrollalign, "top", 3) == 0) 211 if (STRNCASECMP(scrollalign, "top", 3) == 0)
216 R->scrollbar_align = R_SB_ALIGN_TOP; 212 scrollbar_align = R_SB_ALIGN_TOP;
217 else if (STRNCASECMP(scrollalign, "bottom", 6) == 0) 213 else if (STRNCASECMP(scrollalign, "bottom", 6) == 0)
218 R->scrollbar_align = R_SB_ALIGN_BOTTOM; 214 scrollbar_align = R_SB_ALIGN_BOTTOM;
219 } 215 }
220#endif 216#endif
221} 217}
222 218
223/*----------------------- end-of-file (C source) -----------------------*/ 219/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines