Mercurial > hg > xemacs-beta
comparison src/scrollbar.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 441bb1e64a06 |
children | 6a378aca36af |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
403 { | 403 { |
404 struct frame *f = XFRAME (w->frame); | 404 struct frame *f = XFRAME (w->frame); |
405 struct device *d = XDEVICE (f->device); | 405 struct device *d = XDEVICE (f->device); |
406 struct buffer *b = XBUFFER (w->buffer); | 406 struct buffer *b = XBUFFER (w->buffer); |
407 Bufpos start_pos, end_pos, sb_pos; | 407 Bufpos start_pos, end_pos, sb_pos; |
408 int scrollbar_width = window_scrollbar_width (w); | 408 int scrollbar_width = window_scrollbar_width (w); |
409 int scrollbar_height = window_scrollbar_height (w); | 409 int scrollbar_height = window_scrollbar_height (w); |
410 | 410 |
411 int new_line_increment = -1, new_page_increment = -1; | 411 int new_line_increment = -1, new_page_increment = -1; |
412 int new_minimum = -1, new_maximum = -1; | 412 int new_minimum = -1, new_maximum = -1; |
413 int new_slider_size = -1, new_slider_position = -1; | 413 int new_slider_size = -1, new_slider_position = -1; |
449 | 449 |
450 instance->scrollbar_is_active = 1; | 450 instance->scrollbar_is_active = 1; |
451 new_line_increment = 1; | 451 new_line_increment = 1; |
452 new_page_increment = 1; | 452 new_page_increment = 1; |
453 | 453 |
454 /* We used to check for inhibit_scrollbar_slider_size_change here, | 454 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_thumb_size_change, (), 0)) |
455 but that seems bogus. */ | 455 { |
456 { | 456 int x_offset, y_offset; |
457 int x_offset, y_offset; | 457 |
458 | 458 /* Scrollbars are always the farthest from the text area. */ |
459 /* Scrollbars are always the farthest from the text area. */ | 459 if (vertical) |
460 if (vertical) | 460 { |
461 { | 461 x_offset = (f->scrollbar_on_left |
462 x_offset = (f->scrollbar_on_left | 462 ? WINDOW_LEFT (w) |
463 ? WINDOW_LEFT (w) | 463 : WINDOW_RIGHT (w) - scrollbar_width); |
464 : WINDOW_RIGHT (w) - scrollbar_width); | 464 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset; |
465 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset; | 465 } |
466 } | 466 else |
467 else | 467 { |
468 { | 468 x_offset = WINDOW_TEXT_LEFT (w); |
469 x_offset = WINDOW_TEXT_LEFT (w); | 469 y_offset = f->scrollbar_y_offset + |
470 y_offset = f->scrollbar_y_offset + | 470 (f->scrollbar_on_top |
471 (f->scrollbar_on_top | 471 ? WINDOW_TOP (w) |
472 ? WINDOW_TOP (w) | 472 : WINDOW_TEXT_BOTTOM (w) + window_bottom_toolbar_height (w)); |
473 : WINDOW_TEXT_BOTTOM (w) + window_bottom_toolbar_height (w)); | 473 } |
474 } | 474 |
475 | 475 new_x = x_offset; |
476 new_x = x_offset; | 476 new_y = y_offset; |
477 new_y = y_offset; | 477 } |
478 } | |
479 | 478 |
480 /* A disabled scrollbar has its slider sized to the entire height of | 479 /* A disabled scrollbar has its slider sized to the entire height of |
481 the scrollbar. Currently the minibuffer scrollbar is | 480 the scrollbar. Currently the minibuffer scrollbar is |
482 disabled. */ | 481 disabled. */ |
483 if (!MINI_WINDOW_P (w) && vertical) | 482 if (!MINI_WINDOW_P (w) && vertical) |
484 { | 483 { |
485 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_slider_size_change, (), 0)) | 484 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_thumb_size_change, (), 0)) |
486 { | 485 { |
487 new_minimum = BUF_BEGV (b); | 486 new_minimum = BUF_BEGV (b); |
488 new_maximum = max (BUF_ZV (b), new_minimum + 1); | 487 new_maximum = max (BUF_ZV (b), new_minimum + 1); |
489 new_slider_size = min ((end_pos - start_pos), | 488 new_slider_size = min ((end_pos - start_pos), |
490 (new_maximum - new_minimum)); | 489 (new_maximum - new_minimum)); |
513 new_minimum = 0; | 512 new_minimum = 0; |
514 new_maximum = max_width; | 513 new_maximum = max_width; |
515 new_slider_size = wcw; | 514 new_slider_size = wcw; |
516 new_slider_position = min (w->hscroll, max_slide); | 515 new_slider_position = min (w->hscroll, max_slide); |
517 } | 516 } |
518 else /* MINI_WINDOW_P (w) */ | 517 else |
519 { | 518 { |
520 new_minimum = 1; | 519 new_minimum = 1; |
521 new_maximum = 2; | 520 new_maximum = 2; |
522 new_slider_size = 1; | 521 new_slider_size = 1; |
523 new_slider_position = 1; | 522 new_slider_position = 1; |
719 CHECK_LIVE_WINDOW (window); | 718 CHECK_LIVE_WINDOW (window); |
720 /* Motif and Athena scrollbars behave differently, but in accordance | 719 /* Motif and Athena scrollbars behave differently, but in accordance |
721 with their standard behaviors. It is not possible to hide the | 720 with their standard behaviors. It is not possible to hide the |
722 differences down in lwlib because knowledge of XEmacs buffer and | 721 differences down in lwlib because knowledge of XEmacs buffer and |
723 cursor motion routines is necessary. */ | 722 cursor motion routines is necessary. */ |
724 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \ | 723 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
725 defined (LWLIB_SCROLLBARS_ATHENA3D) | |
726 window_scroll (window, Qnil, -1, ERROR_ME_NOT); | 724 window_scroll (window, Qnil, -1, ERROR_ME_NOT); |
727 #else /* Athena */ | 725 #else /* Athena */ |
728 { | 726 { |
729 Bufpos bufpos; | 727 Bufpos bufpos; |
730 Lisp_Object value = Fcdr (object); | 728 Lisp_Object value = Fcdr (object); |
760 CHECK_LIVE_WINDOW (window); | 758 CHECK_LIVE_WINDOW (window); |
761 /* Motif and Athena scrollbars behave differently, but in accordance | 759 /* Motif and Athena scrollbars behave differently, but in accordance |
762 with their standard behaviors. It is not possible to hide the | 760 with their standard behaviors. It is not possible to hide the |
763 differences down in lwlib because knowledge of XEmacs buffer and | 761 differences down in lwlib because knowledge of XEmacs buffer and |
764 cursor motion routines is necessary. */ | 762 cursor motion routines is necessary. */ |
765 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \ | 763 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
766 defined (LWLIB_SCROLLBARS_ATHENA3D) | |
767 window_scroll (window, Qnil, 1, ERROR_ME_NOT); | 764 window_scroll (window, Qnil, 1, ERROR_ME_NOT); |
768 #else /* Athena */ | 765 #else /* Athena */ |
769 { | 766 { |
770 Lisp_Object value = Fcdr (object); | 767 Lisp_Object value = Fcdr (object); |
771 CHECK_INT (value); | 768 CHECK_INT (value); |
776 zmacs_region_stays = 1; | 773 zmacs_region_stays = 1; |
777 return Qnil; | 774 return Qnil; |
778 } | 775 } |
779 | 776 |
780 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, 1, 1, 0, /* | 777 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, 1, 1, 0, /* |
781 Function called when the user invokes the \"to-top\" scrollbar action. | 778 Function called when the user gives the \"to-top\" scrollbar action. |
782 The way this is done can vary from scrollbar to scrollbar, but | 779 (The way this is done can vary from scrollbar to scrollbar.). One argument, |
783 C-button1 on the up-arrow is very common. One argument, the | 780 the scrollbar's window. You can advise this function to change the |
784 scrollbar's window. You can advise this function to change the | |
785 scrollbar behavior. | 781 scrollbar behavior. |
786 */ | 782 */ |
787 (window)) | 783 (window)) |
788 { | 784 { |
789 Lisp_Object orig_pt = Fwindow_point (window); | 785 Lisp_Object orig_pt; |
786 | |
787 orig_pt = Fwindow_point (window); | |
790 Fset_window_point (window, Fpoint_min (Fwindow_buffer (window))); | 788 Fset_window_point (window, Fpoint_min (Fwindow_buffer (window))); |
791 Frecenter (Qzero, window); | 789 Frecenter (Qzero, window); |
792 scrollbar_reset_cursor (window, orig_pt); | 790 scrollbar_reset_cursor (window, orig_pt); |
793 zmacs_region_stays = 1; | 791 zmacs_region_stays = 1; |
794 return Qnil; | 792 return Qnil; |
795 } | 793 } |
796 | 794 |
797 DEFUN ("scrollbar-to-bottom", Fscrollbar_to_bottom, 1, 1, 0, /* | 795 DEFUN ("scrollbar-to-bottom", Fscrollbar_to_bottom, 1, 1, 0, /* |
798 Function called when the user invokes the \"to-bottom\" scrollbar action. | 796 Function called when the user gives the \"to-bottom\" scrollbar action. |
799 The way this is done can vary from scrollbar to scrollbar, but | 797 (The way this is done can vary from scrollbar to scrollbar.). One argument, |
800 C-button1 on the down-arrow is very common. One argument, the | 798 the scrollbar's window. You can advise this function to change the |
801 scrollbar's window. You can advise this function to change the | |
802 scrollbar behavior. | 799 scrollbar behavior. |
803 */ | 800 */ |
804 (window)) | 801 (window)) |
805 { | 802 { |
806 Lisp_Object orig_pt = Fwindow_point (window); | 803 Lisp_Object orig_pt; |
804 | |
805 orig_pt = Fwindow_point (window); | |
807 Fset_window_point (window, Fpoint_max (Fwindow_buffer (window))); | 806 Fset_window_point (window, Fpoint_max (Fwindow_buffer (window))); |
808 Frecenter (make_int (-3), window); | 807 Frecenter (Qzero, window); |
809 scrollbar_reset_cursor (window, orig_pt); | 808 scrollbar_reset_cursor (window, orig_pt); |
810 zmacs_region_stays = 1; | 809 zmacs_region_stays = 1; |
811 return Qnil; | 810 return Qnil; |
812 } | 811 } |
813 | 812 |
814 DEFUN ("scrollbar-vertical-drag", Fscrollbar_vertical_drag, 1, 1, 0, /* | 813 DEFUN ("scrollbar-vertical-drag", Fscrollbar_vertical_drag, 1, 1, 0, /* |
815 Function called when the user drags the vertical scrollbar slider. | 814 Function called when the user drags the vertical scrollbar thumb. |
816 One argument, a cons containing the scrollbar's window and a value | 815 One argument, a cons containing the scrollbar's window and a value |
817 between point-min and point-max. You can advise this function to | 816 between point-min and point-max. You can advise this function to |
818 change the scrollbar behavior. | 817 change the scrollbar behavior. |
819 */ | 818 */ |
820 (object)) | 819 (object)) |
846 if (!EQ (value, Qmax)) | 845 if (!EQ (value, Qmax)) |
847 CHECK_INT (value); | 846 CHECK_INT (value); |
848 | 847 |
849 w = XWINDOW (window); | 848 w = XWINDOW (window); |
850 wcw = window_char_width (w, 0) - 1; | 849 wcw = window_char_width (w, 0) - 1; |
851 /* ### We should be able to scroll further right as long as there is | 850 max_len = w->max_line_len + 1; |
852 a visible truncation glyph. This calculation for max is bogus. */ | |
853 max_len = w->max_line_len + 2; | |
854 | 851 |
855 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw))) | 852 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw))) |
856 hscroll = max_len - wcw; | 853 hscroll = max_len - wcw; |
857 else | 854 else |
858 hscroll = XINT (value); | 855 hscroll = XINT (value); |