Mercurial > hg > xemacs-beta
comparison src/scrollbar-x.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | eb5470882647 |
children | c42ec1d1cded |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
185 /* Used by x_update_scrollbar_instance_status. */ | 185 /* Used by x_update_scrollbar_instance_status. */ |
186 static void | 186 static void |
187 update_one_scrollbar_bs (struct frame *f, Widget sb_widget) | 187 update_one_scrollbar_bs (struct frame *f, Widget sb_widget) |
188 { | 188 { |
189 Boolean use_backing_store; | 189 Boolean use_backing_store; |
190 Arg al [1]; | 190 |
191 | 191 Xt_GET_VALUE (FRAME_X_TEXT_WIDGET (f), XtNuseBackingStore, &use_backing_store); |
192 XtSetArg (al [0], XtNuseBackingStore, &use_backing_store); | |
193 XtGetValues (FRAME_X_TEXT_WIDGET (f), al, 1); | |
194 | 192 |
195 if (use_backing_store && sb_widget) | 193 if (use_backing_store && sb_widget) |
196 { | 194 { |
197 unsigned long mask = CWBackingStore; | 195 unsigned long mask = CWBackingStore; |
198 XSetWindowAttributes attrs; | 196 XSetWindowAttributes attrs; |
311 width. */ | 309 width. */ |
312 | 310 |
313 /* mirror the value in the frame resources, unless it was already | 311 /* mirror the value in the frame resources, unless it was already |
314 done. */ | 312 done. */ |
315 if (!in_resource_setting) | 313 if (!in_resource_setting) |
316 { | 314 Xt_SET_VALUE (FRAME_X_TEXT_WIDGET (f), XtNscrollBarWidth, XINT (newval)); |
317 Arg al [1]; | |
318 XtSetArg (al [0], XtNscrollBarWidth, XINT (newval)); | |
319 XtSetValues (FRAME_X_TEXT_WIDGET (f), al, 1); | |
320 } | |
321 | 315 |
322 if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f))) | 316 if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f))) |
323 { | 317 { |
324 req.request_mode = 0; | 318 req.request_mode = 0; |
325 | 319 |
356 done. Also don't do it if this is the when the frame is being | 350 done. Also don't do it if this is the when the frame is being |
357 created -- the widgets don't even exist yet, and even if they | 351 created -- the widgets don't even exist yet, and even if they |
358 did, we wouldn't want to overwrite the resource information | 352 did, we wouldn't want to overwrite the resource information |
359 (which might specify a user preference). */ | 353 (which might specify a user preference). */ |
360 if (!in_resource_setting) | 354 if (!in_resource_setting) |
361 { | 355 Xt_SET_VALUE (FRAME_X_TEXT_WIDGET (f), XtNscrollBarHeight, XINT (newval)); |
362 Arg al [1]; | |
363 XtSetArg (al [0], XtNscrollBarHeight, XINT (newval)); | |
364 XtSetValues (FRAME_X_TEXT_WIDGET (f), al, 1); | |
365 } | |
366 | 356 |
367 if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f))) | 357 if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f))) |
368 { | 358 { |
369 req.request_mode = 0; | 359 req.request_mode = 0; |
370 | 360 |
399 struct window_mirror *retval = NULL; | 389 struct window_mirror *retval = NULL; |
400 | 390 |
401 while (mir) | 391 while (mir) |
402 { | 392 { |
403 struct scrollbar_instance *vinstance = mir->scrollbar_vertical_instance; | 393 struct scrollbar_instance *vinstance = mir->scrollbar_vertical_instance; |
404 struct scrollbar_instance *hinstance = | 394 struct scrollbar_instance *hinstance = mir->scrollbar_horizontal_instance; |
405 mir->scrollbar_horizontal_instance; | 395 struct window *w = XWINDOW (window); |
406 struct frame *f; | |
407 | |
408 assert (!NILP (window)); | |
409 f = XFRAME (XWINDOW (window)->frame); | |
410 | 396 |
411 if (mir->vchild) | 397 if (mir->vchild) |
412 { | 398 retval = x_scrollbar_loop (type, w->vchild, mir->vchild, id, x_win); |
413 retval = x_scrollbar_loop (type, XWINDOW (window)->vchild, | |
414 mir->vchild, id, x_win); | |
415 } | |
416 else if (mir->hchild) | 399 else if (mir->hchild) |
417 { | 400 retval = x_scrollbar_loop (type, w->hchild, mir->hchild, id, x_win); |
418 retval = x_scrollbar_loop (type, XWINDOW (window)->hchild, | 401 if (retval) |
419 mir->hchild, id, x_win); | |
420 } | |
421 | |
422 if (retval != NULL) | |
423 return retval; | 402 return retval; |
424 | 403 |
425 if (hinstance || vinstance) | 404 if (hinstance || vinstance) |
426 { | 405 { |
427 switch (type) | 406 switch (type) |
428 { | 407 { |
429 case X_FIND_SCROLLBAR_WINDOW_MIRROR: | 408 case X_FIND_SCROLLBAR_WINDOW_MIRROR: |
430 if ((vinstance && SCROLLBAR_X_ID (vinstance) == id) | 409 if ((vinstance && SCROLLBAR_X_ID (vinstance) == id) || |
431 || (hinstance && SCROLLBAR_X_ID (hinstance) == id)) | 410 (hinstance && SCROLLBAR_X_ID (hinstance) == id)) |
432 { | 411 return mir; |
433 return mir; | |
434 } | |
435 break; | 412 break; |
436 case X_UPDATE_FRAME_SCROLLBARS: | 413 case X_UPDATE_FRAME_SCROLLBARS: |
437 if (!mir->vchild && !mir->hchild) | 414 if (!mir->vchild && !mir->hchild) |
438 update_window_scrollbars (XWINDOW (window), mir, 1, 0); | 415 update_window_scrollbars (w, mir, 1, 0); |
439 break; | 416 break; |
440 case X_SET_SCROLLBAR_POINTER: | 417 case X_SET_SCROLLBAR_POINTER: |
441 if (!mir->vchild && !mir->hchild) | 418 if (!mir->vchild && !mir->hchild) |
442 { | 419 { |
443 int loop; | 420 Widget widget; |
444 | 421 |
445 for (loop = 0; loop < 2; loop++) | 422 widget = SCROLLBAR_X_WIDGET (hinstance); |
446 { | 423 if (widget && XtIsManaged (widget)) |
447 Widget widget; | 424 update_one_widget_scrollbar_pointer (w, widget); |
448 | 425 |
449 if (loop) | 426 widget = SCROLLBAR_X_WIDGET (vinstance); |
450 widget = SCROLLBAR_X_WIDGET (vinstance); | 427 if (widget && XtIsManaged (widget)) |
451 else | 428 update_one_widget_scrollbar_pointer (w, widget); |
452 widget = SCROLLBAR_X_WIDGET (hinstance); | |
453 | |
454 if (widget && XtIsManaged (widget)) | |
455 { | |
456 update_one_widget_scrollbar_pointer | |
457 (XWINDOW (window), widget); | |
458 } | |
459 } | |
460 } | 429 } |
461 break; | 430 break; |
462 case X_WINDOW_IS_SCROLLBAR: | 431 case X_WINDOW_IS_SCROLLBAR: |
463 if (!mir->vchild && !mir->hchild) | 432 if (!mir->vchild && !mir->hchild) |
464 { | 433 { |
465 int loop; | 434 Widget widget; |
466 | 435 |
467 for (loop = 0; loop < 2; loop++) | 436 widget = SCROLLBAR_X_WIDGET (hinstance); |
468 { | 437 if (widget && XtIsManaged (widget) && |
469 Widget widget; | 438 XtWindow (widget) == x_win) |
470 | 439 return (struct window_mirror *) 1; |
471 if (loop) | 440 |
472 widget = SCROLLBAR_X_WIDGET (vinstance); | 441 widget = SCROLLBAR_X_WIDGET (vinstance); |
473 else | 442 if (widget && XtIsManaged (widget) && |
474 widget = SCROLLBAR_X_WIDGET (hinstance); | 443 XtWindow (widget) == x_win) |
475 | 444 return (struct window_mirror *) 1; |
476 if (widget && XtIsManaged (widget)) | |
477 { | |
478 if (XtWindow (widget) == x_win) | |
479 return (struct window_mirror *) 1; | |
480 } | |
481 } | |
482 } | 445 } |
483 break; | 446 break; |
484 default: | 447 default: |
485 abort (); | 448 abort (); |
486 } | 449 } |
487 } | 450 } |
488 | 451 |
489 mir = mir->next; | 452 mir = mir->next; |
490 window = XWINDOW (window)->next; | 453 window = w->next; |
491 } | 454 } |
492 | 455 |
493 return NULL; | 456 return NULL; |
494 } | 457 } |
495 | 458 |
650 /* shouldn't get here, but just in case */ | 613 /* shouldn't get here, but just in case */ |
651 value = SCROLLBAR_X_POS_DATA (instance).minimum; | 614 value = SCROLLBAR_X_POS_DATA (instance).minimum; |
652 } | 615 } |
653 else | 616 else |
654 { | 617 { |
655 value = (SCROLLBAR_X_POS_DATA (instance).minimum | 618 value = (int) |
656 + (((double) | 619 (SCROLLBAR_X_POS_DATA (instance).minimum |
657 (SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance) | 620 + (((double) |
658 - SCROLLBAR_X_POS_DATA (instance).minimum) | 621 (SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance) |
659 * (data->slider_value - | 622 - SCROLLBAR_X_POS_DATA (instance).minimum) |
660 SCROLLBAR_X_POS_DATA (instance).minimum)) | 623 * (data->slider_value - |
661 / (SCROLLBAR_X_VDRAG_ORIG_VALUE (instance) | 624 SCROLLBAR_X_POS_DATA (instance).minimum)) |
662 - SCROLLBAR_X_POS_DATA (instance).minimum))); | 625 / (SCROLLBAR_X_VDRAG_ORIG_VALUE (instance) |
626 - SCROLLBAR_X_POS_DATA (instance).minimum))); | |
663 } | 627 } |
664 } | 628 } |
665 else | 629 else |
666 { | 630 { |
667 /* We've dragged down; slide linearly from original position to | 631 /* We've dragged down; slide linearly from original position to |
674 /* avoid divide by zero */ | 638 /* avoid divide by zero */ |
675 value = SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance); | 639 value = SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance); |
676 } | 640 } |
677 else | 641 else |
678 { | 642 { |
679 value = (SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance) | 643 value = (int) |
680 + (((double) (SCROLLBAR_X_POS_DATA (instance).maximum | 644 (SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance) |
681 - SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance)) | 645 + (((double) |
682 * (data->slider_value | 646 (SCROLLBAR_X_POS_DATA (instance).maximum |
683 - SCROLLBAR_X_VDRAG_ORIG_VALUE (instance))) | 647 - SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance)) |
684 / (SCROLLBAR_X_POS_DATA (instance).maximum | 648 * (data->slider_value |
685 - SCROLLBAR_X_POS_DATA (instance).slider_size | 649 - SCROLLBAR_X_VDRAG_ORIG_VALUE (instance))) |
686 - SCROLLBAR_X_VDRAG_ORIG_VALUE (instance)))); | 650 / (SCROLLBAR_X_POS_DATA (instance).maximum |
651 - SCROLLBAR_X_POS_DATA (instance).slider_size | |
652 - SCROLLBAR_X_VDRAG_ORIG_VALUE (instance)))); | |
687 } | 653 } |
688 } | 654 } |
689 #else | 655 #else |
690 stupid_vertical_scrollbar_drag_hack = 0; | 656 stupid_vertical_scrollbar_drag_hack = 0; |
691 value = data->slider_value; | 657 value = data->slider_value; |
776 } | 742 } |
777 | 743 |
778 static void | 744 static void |
779 x_scrollbar_pointer_changed_in_window (struct window *w) | 745 x_scrollbar_pointer_changed_in_window (struct window *w) |
780 { | 746 { |
781 Lisp_Object window = Qnil; | 747 Lisp_Object window; |
782 | 748 |
783 XSETWINDOW (window, w); | 749 XSETWINDOW (window, w); |
784 x_scrollbar_loop (X_SET_SCROLLBAR_POINTER, window, find_window_mirror (w), | 750 x_scrollbar_loop (X_SET_SCROLLBAR_POINTER, window, find_window_mirror (w), |
785 0, (Window) NULL); | 751 0, (Window) NULL); |
786 } | 752 } |