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