Mercurial > hg > xemacs-beta
comparison src/scrollbar-msw.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children | 11054d720c21 |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
263 vertical_drag_in_progress = 0; | 263 vertical_drag_in_progress = 0; |
264 break; | 264 break; |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 static int | |
269 can_scroll(struct scrollbar_instance* scrollbar) | |
270 { | |
271 return scrollbar != NULL | |
272 && IsWindowVisible (SCROLLBAR_MSW_HANDLE (scrollbar)) | |
273 && IsWindowEnabled (SCROLLBAR_MSW_HANDLE (scrollbar)); | |
274 } | |
275 | |
276 int | |
277 mswindows_handle_mousewheel_event (Lisp_Object frame, int keys, int delta) | |
278 { | |
279 int hasVertBar, hasHorzBar; /* Indicates prescence of scroll bars */ | |
280 unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */ | |
281 | |
282 /* Find the currently selected window */ | |
283 Lisp_Object win = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
284 struct window* w = XWINDOW (win); | |
285 struct window_mirror* mirror = find_window_mirror (w); | |
286 | |
287 /* Check that there is something to scroll */ | |
288 hasVertBar = can_scroll (mirror->scrollbar_vertical_instance); | |
289 hasHorzBar = can_scroll (mirror->scrollbar_horizontal_instance); | |
290 if (!hasVertBar && !hasHorzBar) | |
291 return FALSE; | |
292 | |
293 /* No support for panning and zooming, so ignore */ | |
294 if (keys & (MK_SHIFT | MK_CONTROL)) | |
295 return FALSE; | |
296 | |
297 /* Get the number of lines per wheel delta */ | |
298 SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0); | |
299 | |
300 /* Calculate the amount to scroll */ | |
301 if (wheelScrollLines == WHEEL_PAGESCROLL) | |
302 { | |
303 /* Scroll by a page */ | |
304 Lisp_Object function; | |
305 if (hasVertBar) | |
306 function = delta > 0 ? Qscrollbar_page_up : Qscrollbar_page_down; | |
307 else | |
308 function = delta > 0 ? Qscrollbar_page_left : Qscrollbar_page_right; | |
309 mswindows_enqueue_misc_user_event (frame, function, Fcons (win, Qnil)); | |
310 } | |
311 else /* Scroll by a number of lines */ | |
312 { | |
313 /* Calc the number of lines to scroll */ | |
314 int toScroll = MulDiv (delta, wheelScrollLines, WHEEL_DELTA); | |
315 | |
316 /* Do the scroll */ | |
317 Lisp_Object function; | |
318 if (hasVertBar) | |
319 function = delta > 0 ? Qscrollbar_line_up : Qscrollbar_line_down; | |
320 else | |
321 function = delta > 0 ? Qscrollbar_char_left : Qscrollbar_char_right; | |
322 if (toScroll < 0) | |
323 toScroll = -toScroll; | |
324 while (toScroll--) | |
325 mswindows_enqueue_misc_user_event (frame, function, win); | |
326 } | |
327 | |
328 return TRUE; | |
329 } | |
330 | |
331 #ifdef MEMORY_USAGE_STATS | 268 #ifdef MEMORY_USAGE_STATS |
332 | 269 |
333 static int | 270 static int |
334 mswindows_compute_scrollbar_instance_usage (struct device *d, | 271 mswindows_compute_scrollbar_instance_usage (struct device *d, |
335 struct scrollbar_instance *inst, | 272 struct scrollbar_instance *inst, |