… | |
… | |
34 | void |
34 | void |
35 | scrollBar_t::map (int map) |
35 | scrollBar_t::map (int map) |
36 | { |
36 | { |
37 | if (map) |
37 | if (map) |
38 | { |
38 | { |
39 | state = STATE_IDLE; |
39 | state = SB_STATE_IDLE; |
40 | |
40 | |
41 | if (!win) |
41 | if (!win) |
42 | resize (); |
42 | resize (); |
43 | else |
43 | else |
44 | XMapWindow (term->dpy, win); |
44 | XMapWindow (term->dpy, win); |
45 | } |
45 | } |
46 | else |
46 | else |
47 | { |
47 | { |
48 | state = STATE_OFF; |
48 | state = SB_STATE_OFF; |
49 | |
49 | |
50 | if (win) |
50 | if (win) |
51 | XUnmapWindow (term->dpy, win); |
51 | XUnmapWindow (term->dpy, win); |
52 | } |
52 | } |
53 | } |
53 | } |
… | |
… | |
116 | bot = top + ecb_div_ru ((sb_bot - sb_top) * size (), sb_len) + min_height (); |
116 | bot = top + ecb_div_ru ((sb_bot - sb_top) * size (), sb_len) + min_height (); |
117 | /* no change */ |
117 | /* no change */ |
118 | if (top == last_top |
118 | if (top == last_top |
119 | && bot == last_bot |
119 | && bot == last_bot |
120 | && (state == last_state |
120 | && (state == last_state |
121 | || !(state == STATE_UP || state == STATE_DOWN))) |
121 | || !(state == SB_STATE_UP || state == SB_STATE_DOWN))) |
122 | return 0; |
122 | return 0; |
123 | } |
123 | } |
124 | |
124 | |
125 | ret = (this->*update) (refresh); |
125 | ret = (this->*update) (refresh); |
126 | |
126 | |
… | |
… | |
132 | } |
132 | } |
133 | |
133 | |
134 | void |
134 | void |
135 | scrollBar_t::setup (rxvt_term *term) |
135 | scrollBar_t::setup (rxvt_term *term) |
136 | { |
136 | { |
137 | int i; |
137 | int i; |
138 | const char *scrollalign, *scrollstyle, *thickness; |
138 | const char *scrollalign, *scrollstyle, *thickness; |
139 | |
139 | |
140 | this->term = term; |
140 | this->term = term; |
141 | scrollalign = term->rs[Rs_scrollBar_align]; |
141 | scrollalign = term->rs[Rs_scrollBar_align]; |
142 | scrollstyle = term->rs[Rs_scrollstyle]; |
142 | scrollstyle = term->rs[Rs_scrollstyle]; |
143 | thickness = term->rs[Rs_scrollBar_thickness]; |
143 | thickness = term->rs[Rs_scrollBar_thickness]; |
144 | |
144 | |
145 | # if defined(RXVT_SCROLLBAR) |
145 | # if defined(RXVT_SCROLLBAR) |
146 | style = R_SB_RXVT; |
146 | style = SB_STYLE_RXVT; |
147 | # elif defined(XTERM_SCROLLBAR) |
147 | # elif defined(XTERM_SCROLLBAR) |
148 | style = R_SB_XTERM; |
148 | style = SB_STYLE_XTERM; |
149 | # elif defined(NEXT_SCROLLBAR) |
149 | # elif defined(NEXT_SCROLLBAR) |
150 | style = R_SB_NEXT; |
150 | style = SB_STYLE_NEXT; |
151 | # elif defined(PLAIN_SCROLLBAR) |
151 | # elif defined(PLAIN_SCROLLBAR) |
152 | style = R_SB_PLAIN; |
152 | style = SB_STYLE_PLAIN; |
153 | #else |
153 | #else |
154 | style = R_SB_RXVT; |
154 | style = SB_STYLE_RXVT; |
155 | # endif |
155 | # endif |
156 | |
156 | |
157 | # if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR)) |
157 | # if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR)) |
158 | if (scrollstyle) |
158 | if (scrollstyle) |
159 | { |
159 | { |
160 | # ifdef NEXT_SCROLLBAR |
160 | # ifdef NEXT_SCROLLBAR |
161 | if (strncasecmp (scrollstyle, "next", 4) == 0) |
161 | if (strncasecmp (scrollstyle, "next", 4) == 0) |
162 | style = R_SB_NEXT; |
162 | style = SB_STYLE_NEXT; |
163 | # endif |
163 | # endif |
164 | # ifdef XTERM_SCROLLBAR |
164 | # ifdef XTERM_SCROLLBAR |
165 | if (strncasecmp (scrollstyle, "xterm", 5) == 0) |
165 | if (strncasecmp (scrollstyle, "xterm", 5) == 0) |
166 | style = R_SB_XTERM; |
166 | style = SB_STYLE_XTERM; |
167 | # endif |
167 | # endif |
168 | # ifdef PLAIN_SCROLLBAR |
168 | # ifdef PLAIN_SCROLLBAR |
169 | if (strncasecmp (scrollstyle, "plain", 5) == 0) |
169 | if (strncasecmp (scrollstyle, "plain", 5) == 0) |
170 | style = R_SB_PLAIN; |
170 | style = SB_STYLE_PLAIN; |
171 | # endif |
171 | # endif |
172 | |
172 | |
173 | } |
173 | } |
174 | # endif |
174 | # endif |
175 | if (style == R_SB_NEXT) |
175 | if (style == SB_STYLE_NEXT) |
176 | width = SB_WIDTH_NEXT; |
176 | width = SB_WIDTH_NEXT; |
177 | else if (style == R_SB_XTERM) |
177 | else if (style == SB_STYLE_XTERM) |
178 | width = SB_WIDTH_XTERM; |
178 | width = SB_WIDTH_XTERM; |
179 | else if (style == R_SB_PLAIN) |
179 | else if (style == SB_STYLE_PLAIN) |
180 | width = SB_WIDTH_PLAIN; |
180 | width = SB_WIDTH_PLAIN; |
181 | else /* if (style == R_SB_RXVT) */ |
181 | else /* if (style == SB_STYLE_RXVT) */ |
182 | width = SB_WIDTH_RXVT; |
182 | width = SB_WIDTH_RXVT; |
183 | |
183 | |
184 | if (style != R_SB_NEXT) /* dishonour request - for now */ |
184 | if (style != SB_STYLE_NEXT) /* dishonour request - for now */ |
185 | if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) |
185 | if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) |
186 | width = min (i, SB_WIDTH_MAXIMUM); |
186 | width = min (i, SB_WIDTH_MAXIMUM); |
187 | |
187 | |
188 | # ifdef RXVT_SCROLLBAR |
188 | # ifdef RXVT_SCROLLBAR |
189 | if (! term->option (Opt_scrollBar_floating) && style == R_SB_RXVT) |
189 | if (! term->option (Opt_scrollBar_floating) && style == SB_STYLE_RXVT) |
190 | shadow = SHADOW_WIDTH; |
190 | shadow = SHADOW_WIDTH; |
191 | # endif |
191 | # endif |
192 | |
192 | |
193 | /* align = R_SB_ALIGN_CENTRE; */ |
193 | /* align = SB_ALIGN_CENTRE; */ |
194 | if (scrollalign) |
194 | if (scrollalign) |
195 | { |
195 | { |
196 | if (strncasecmp (scrollalign, "top", 3) == 0) |
196 | if (strncasecmp (scrollalign, "top", 3) == 0) |
197 | align = R_SB_ALIGN_TOP; |
197 | align = SB_ALIGN_TOP; |
198 | else if (strncasecmp (scrollalign, "bottom", 6) == 0) |
198 | else if (strncasecmp (scrollalign, "bottom", 6) == 0) |
199 | align = R_SB_ALIGN_BOTTOM; |
199 | align = SB_ALIGN_BOTTOM; |
200 | } |
200 | } |
201 | last_state = STATE_OFF; |
201 | last_state = SB_STATE_OFF; |
202 | /* cursor scrollBar: Black-on-White */ |
202 | /* cursor scrollBar: Black-on-White */ |
203 | leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr); |
203 | leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr); |
204 | } |
204 | } |
205 | |
205 | |
206 | void |
206 | void |
… | |
… | |
234 | |
234 | |
235 | void |
235 | void |
236 | scrollBar_t::update_data () |
236 | scrollBar_t::update_data () |
237 | { |
237 | { |
238 | #if defined(PLAIN_SCROLLBAR) |
238 | #if defined(PLAIN_SCROLLBAR) |
239 | if (style == R_SB_PLAIN) |
239 | if (style == SB_STYLE_PLAIN) |
240 | { |
240 | { |
241 | beg = 0; |
241 | beg = 0; |
242 | end = term->szHint.height; |
242 | end = term->szHint.height; |
243 | update = &scrollBar_t::show_plain; |
243 | update = &scrollBar_t::show_plain; |
244 | } |
244 | } |
245 | #endif |
245 | #endif |
246 | #if defined(XTERM_SCROLLBAR) |
246 | #if defined(XTERM_SCROLLBAR) |
247 | if (style == R_SB_XTERM) |
247 | if (style == SB_STYLE_XTERM) |
248 | { |
248 | { |
249 | beg = 0; |
249 | beg = 0; |
250 | end = term->szHint.height; |
250 | end = term->szHint.height; |
251 | update = &scrollBar_t::show_xterm; |
251 | update = &scrollBar_t::show_xterm; |
252 | } |
252 | } |
253 | #endif |
253 | #endif |
254 | #if defined(NEXT_SCROLLBAR) |
254 | #if defined(NEXT_SCROLLBAR) |
255 | if (style == R_SB_NEXT) |
255 | if (style == SB_STYLE_NEXT) |
256 | { |
256 | { |
257 | beg = 0; |
257 | beg = 0; |
258 | end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING); |
258 | end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING); |
259 | update = &scrollBar_t::show_next; |
259 | update = &scrollBar_t::show_next; |
260 | } |
260 | } |
261 | #endif |
261 | #endif |
262 | #if defined(RXVT_SCROLLBAR) |
262 | #if defined(RXVT_SCROLLBAR) |
263 | if (style == R_SB_RXVT) |
263 | if (style == SB_STYLE_RXVT) |
264 | { |
264 | { |
265 | beg = (width + 1) + shadow; |
265 | beg = (width + 1) + shadow; |
266 | end = term->szHint.height - beg - (2 * shadow); |
266 | end = term->szHint.height - beg - (2 * shadow); |
267 | update = &scrollBar_t::show_rxvt; |
267 | update = &scrollBar_t::show_rxvt; |
268 | } |
268 | } |