comparison src/scrollbar.c @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 859a2309aef8
children 131b0175ea99
comparison
equal deleted inserted replaced
25:383a494979f8 26:441bb1e64a06
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 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_thumb_size_change, (), 0)) 454 /* We used to check for inhibit_scrollbar_slider_size_change here,
455 { 455 but that seems bogus. */
456 int x_offset, y_offset; 456 {
457 457 int x_offset, y_offset;
458 /* Scrollbars are always the farthest from the text area. */ 458
459 if (vertical) 459 /* Scrollbars are always the farthest from the text area. */
460 { 460 if (vertical)
461 x_offset = (f->scrollbar_on_left 461 {
462 ? WINDOW_LEFT (w) 462 x_offset = (f->scrollbar_on_left
463 : WINDOW_RIGHT (w) - scrollbar_width); 463 ? WINDOW_LEFT (w)
464 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset; 464 : WINDOW_RIGHT (w) - scrollbar_width);
465 } 465 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset;
466 else 466 }
467 { 467 else
468 x_offset = WINDOW_TEXT_LEFT (w); 468 {
469 y_offset = f->scrollbar_y_offset + 469 x_offset = WINDOW_TEXT_LEFT (w);
470 (f->scrollbar_on_top 470 y_offset = f->scrollbar_y_offset +
471 ? WINDOW_TOP (w) 471 (f->scrollbar_on_top
472 : WINDOW_TEXT_BOTTOM (w) + window_bottom_toolbar_height (w)); 472 ? WINDOW_TOP (w)
473 } 473 : WINDOW_TEXT_BOTTOM (w) + window_bottom_toolbar_height (w));
474 474 }
475 new_x = x_offset; 475
476 new_y = y_offset; 476 new_x = x_offset;
477 } 477 new_y = y_offset;
478 }
478 479
479 /* A disabled scrollbar has its slider sized to the entire height of 480 /* A disabled scrollbar has its slider sized to the entire height of
480 the scrollbar. Currently the minibuffer scrollbar is 481 the scrollbar. Currently the minibuffer scrollbar is
481 disabled. */ 482 disabled. */
482 if (!MINI_WINDOW_P (w) && vertical) 483 if (!MINI_WINDOW_P (w) && vertical)
483 { 484 {
484 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_thumb_size_change, (), 0)) 485 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_slider_size_change, (), 0))
485 { 486 {
486 new_minimum = BUF_BEGV (b); 487 new_minimum = BUF_BEGV (b);
487 new_maximum = max (BUF_ZV (b), new_minimum + 1); 488 new_maximum = max (BUF_ZV (b), new_minimum + 1);
488 new_slider_size = min ((end_pos - start_pos), 489 new_slider_size = min ((end_pos - start_pos),
489 (new_maximum - new_minimum)); 490 (new_maximum - new_minimum));
512 new_minimum = 0; 513 new_minimum = 0;
513 new_maximum = max_width; 514 new_maximum = max_width;
514 new_slider_size = wcw; 515 new_slider_size = wcw;
515 new_slider_position = min (w->hscroll, max_slide); 516 new_slider_position = min (w->hscroll, max_slide);
516 } 517 }
517 else 518 else /* MINI_WINDOW_P (w) */
518 { 519 {
519 new_minimum = 1; 520 new_minimum = 1;
520 new_maximum = 2; 521 new_maximum = 2;
521 new_slider_size = 1; 522 new_slider_size = 1;
522 new_slider_position = 1; 523 new_slider_position = 1;
775 zmacs_region_stays = 1; 776 zmacs_region_stays = 1;
776 return Qnil; 777 return Qnil;
777 } 778 }
778 779
779 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, 1, 1, 0, /* 780 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, 1, 1, 0, /*
780 Function called when the user gives the \"to-top\" scrollbar action. 781 Function called when the user invokes the \"to-top\" scrollbar action.
781 (The way this is done can vary from scrollbar to scrollbar.). One argument, 782 The way this is done can vary from scrollbar to scrollbar, but
782 the scrollbar's window. You can advise this function to change the 783 C-button1 on the up-arrow is very common. One argument, the
784 scrollbar's window. You can advise this function to change the
783 scrollbar behavior. 785 scrollbar behavior.
784 */ 786 */
785 (window)) 787 (window))
786 { 788 {
787 Lisp_Object orig_pt; 789 Lisp_Object orig_pt = Fwindow_point (window);
788
789 orig_pt = Fwindow_point (window);
790 Fset_window_point (window, Fpoint_min (Fwindow_buffer (window))); 790 Fset_window_point (window, Fpoint_min (Fwindow_buffer (window)));
791 Frecenter (Qzero, window); 791 Frecenter (Qzero, window);
792 scrollbar_reset_cursor (window, orig_pt); 792 scrollbar_reset_cursor (window, orig_pt);
793 zmacs_region_stays = 1; 793 zmacs_region_stays = 1;
794 return Qnil; 794 return Qnil;
795 } 795 }
796 796
797 DEFUN ("scrollbar-to-bottom", Fscrollbar_to_bottom, 1, 1, 0, /* 797 DEFUN ("scrollbar-to-bottom", Fscrollbar_to_bottom, 1, 1, 0, /*
798 Function called when the user gives the \"to-bottom\" scrollbar action. 798 Function called when the user invokes the \"to-bottom\" scrollbar action.
799 (The way this is done can vary from scrollbar to scrollbar.). One argument, 799 The way this is done can vary from scrollbar to scrollbar, but
800 the scrollbar's window. You can advise this function to change the 800 C-button1 on the down-arrow is very common. One argument, the
801 scrollbar's window. You can advise this function to change the
801 scrollbar behavior. 802 scrollbar behavior.
802 */ 803 */
803 (window)) 804 (window))
804 { 805 {
805 Lisp_Object orig_pt; 806 Lisp_Object orig_pt = Fwindow_point (window);
806
807 orig_pt = Fwindow_point (window);
808 Fset_window_point (window, Fpoint_max (Fwindow_buffer (window))); 807 Fset_window_point (window, Fpoint_max (Fwindow_buffer (window)));
809 Frecenter (Qzero, window); 808 Frecenter (make_int (-3), window);
810 scrollbar_reset_cursor (window, orig_pt); 809 scrollbar_reset_cursor (window, orig_pt);
811 zmacs_region_stays = 1; 810 zmacs_region_stays = 1;
812 return Qnil; 811 return Qnil;
813 } 812 }
814 813
815 DEFUN ("scrollbar-vertical-drag", Fscrollbar_vertical_drag, 1, 1, 0, /* 814 DEFUN ("scrollbar-vertical-drag", Fscrollbar_vertical_drag, 1, 1, 0, /*
816 Function called when the user drags the vertical scrollbar thumb. 815 Function called when the user drags the vertical scrollbar slider.
817 One argument, a cons containing the scrollbar's window and a value 816 One argument, a cons containing the scrollbar's window and a value
818 between point-min and point-max. You can advise this function to 817 between point-min and point-max. You can advise this function to
819 change the scrollbar behavior. 818 change the scrollbar behavior.
820 */ 819 */
821 (object)) 820 (object))
847 if (!EQ (value, Qmax)) 846 if (!EQ (value, Qmax))
848 CHECK_INT (value); 847 CHECK_INT (value);
849 848
850 w = XWINDOW (window); 849 w = XWINDOW (window);
851 wcw = window_char_width (w, 0) - 1; 850 wcw = window_char_width (w, 0) - 1;
852 max_len = w->max_line_len + 1; 851 /* ### We should be able to scroll further right as long as there is
852 a visible truncation glyph. This calculation for max is bogus. */
853 max_len = w->max_line_len + 2;
853 854
854 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw))) 855 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw)))
855 hscroll = max_len - wcw; 856 hscroll = max_len - wcw;
856 else 857 else
857 hscroll = XINT (value); 858 hscroll = XINT (value);