Mercurial > hg > xemacs-beta
comparison src/scrollbar.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 | 501cfd01ee6d |
children | 95016f13131a |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
32 #include "commands.h" | 32 #include "commands.h" |
33 #include "scrollbar.h" | 33 #include "scrollbar.h" |
34 #include "device.h" | 34 #include "device.h" |
35 #include "frame.h" | 35 #include "frame.h" |
36 #include "glyphs.h" | 36 #include "glyphs.h" |
37 #include "gutter.h" | |
38 #include "window.h" | 37 #include "window.h" |
39 | 38 |
40 Lisp_Object Qinit_scrollbar_from_resources; | 39 Lisp_Object Qinit_scrollbar_from_resources; |
41 | 40 |
42 Lisp_Object Qscrollbar_line_up; | 41 Lisp_Object Qscrollbar_line_up; |
451 /* We used to check for inhibit_scrollbar_slider_size_change here, | 450 /* We used to check for inhibit_scrollbar_slider_size_change here, |
452 but that seems bogus. */ | 451 but that seems bogus. */ |
453 { | 452 { |
454 int x_offset, y_offset; | 453 int x_offset, y_offset; |
455 | 454 |
456 /* Scrollbars are always the farthest from the text area, barring | 455 /* Scrollbars are always the farthest from the text area. */ |
457 gutters. */ | |
458 if (vertical) | 456 if (vertical) |
459 { | 457 { |
460 if (!NILP (w->scrollbar_on_left_p)) | 458 x_offset = (!NILP (w->scrollbar_on_left_p) |
461 { | 459 ? WINDOW_LEFT (w) |
462 x_offset = WINDOW_LEFT (w); | 460 : (WINDOW_RIGHT (w) - scrollbar_width |
463 } | 461 - (window_needs_vertical_divider (w) |
464 else | 462 ? window_divider_width (w) : 0))); |
465 { | |
466 x_offset = WINDOW_RIGHT (w) - scrollbar_width; | |
467 if (window_needs_vertical_divider (w)) | |
468 x_offset -= window_divider_width (w); | |
469 } | |
470 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset; | 463 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset; |
471 } | 464 } |
472 else | 465 else |
473 { | 466 { |
474 x_offset = WINDOW_TEXT_LEFT (w); | 467 x_offset = WINDOW_TEXT_LEFT (w); |
475 y_offset = f->scrollbar_y_offset; | 468 y_offset = f->scrollbar_y_offset + |
476 | 469 (!NILP (w->scrollbar_on_top_p) |
477 if (!NILP (w->scrollbar_on_top_p)) | 470 ? WINDOW_TOP (w) |
478 { | 471 : WINDOW_TEXT_BOTTOM (w) + window_bottom_toolbar_height (w)); |
479 y_offset += WINDOW_TOP (w); | |
480 } | |
481 else | |
482 { | |
483 y_offset += WINDOW_TEXT_BOTTOM (w); | |
484 } | |
485 } | 472 } |
486 | 473 |
487 new_x = x_offset; | 474 new_x = x_offset; |
488 new_y = y_offset; | 475 new_y = y_offset; |
489 } | 476 } |
733 CHECK_LIVE_WINDOW (window); | 720 CHECK_LIVE_WINDOW (window); |
734 /* Motif and Athena scrollbars behave differently, but in accordance | 721 /* Motif and Athena scrollbars behave differently, but in accordance |
735 with their standard behaviors. It is not possible to hide the | 722 with their standard behaviors. It is not possible to hide the |
736 differences down in lwlib because knowledge of XEmacs buffer and | 723 differences down in lwlib because knowledge of XEmacs buffer and |
737 cursor motion routines is necessary. */ | 724 cursor motion routines is necessary. */ |
738 | 725 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \ |
739 if (NILP (XCDR (object))) | 726 defined (LWLIB_SCROLLBARS_ATHENA3D) || defined(HAVE_MS_WINDOWS) |
740 window_scroll (window, Qnil, -1, ERROR_ME_NOT); | 727 window_scroll (window, Qnil, -1, ERROR_ME_NOT); |
741 else | 728 #else /* Athena */ |
742 { | 729 { |
743 Bufpos bufpos; | 730 Bufpos bufpos; |
744 Lisp_Object value = Fcdr (object); | 731 Lisp_Object value = Fcdr (object); |
745 | 732 |
746 CHECK_INT (value); | 733 CHECK_INT (value); |
747 Fmove_to_window_line (Qzero, window); | 734 Fmove_to_window_line (Qzero, window); |
748 /* can't use Fvertical_motion() because it moves the buffer point | 735 /* can't use Fvertical_motion() because it moves the buffer point |
749 rather than the window's point. | 736 rather than the window's point. |
750 | 737 |
751 #### It does? Why does it take a window argument then? */ | 738 #### It does? Why does it take a window argument then? */ |
752 bufpos = vmotion (XWINDOW (window), XINT (Fwindow_point (window)), | 739 bufpos = vmotion (XWINDOW (window), XINT (Fwindow_point (window)), |
753 XINT (value), 0); | 740 XINT (value), 0); |
754 Fset_window_point (window, make_int (bufpos)); | 741 Fset_window_point (window, make_int (bufpos)); |
755 Fcenter_to_window_line (Qzero, window); | 742 Fcenter_to_window_line (Qzero, window); |
756 } | 743 } |
757 | 744 #endif /* Athena */ |
758 zmacs_region_stays = 1; | 745 zmacs_region_stays = 1; |
759 return Qnil; | 746 return Qnil; |
760 } | 747 } |
761 | 748 |
762 DEFUN ("scrollbar-page-down", Fscrollbar_page_down, 1, 1, 0, /* | 749 DEFUN ("scrollbar-page-down", Fscrollbar_page_down, 1, 1, 0, /* |
774 CHECK_LIVE_WINDOW (window); | 761 CHECK_LIVE_WINDOW (window); |
775 /* Motif and Athena scrollbars behave differently, but in accordance | 762 /* Motif and Athena scrollbars behave differently, but in accordance |
776 with their standard behaviors. It is not possible to hide the | 763 with their standard behaviors. It is not possible to hide the |
777 differences down in lwlib because knowledge of XEmacs buffer and | 764 differences down in lwlib because knowledge of XEmacs buffer and |
778 cursor motion routines is necessary. */ | 765 cursor motion routines is necessary. */ |
779 | 766 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \ |
780 if (NILP (XCDR (object))) | 767 defined (LWLIB_SCROLLBARS_ATHENA3D) || defined (HAVE_MS_WINDOWS) |
781 window_scroll (window, Qnil, 1, ERROR_ME_NOT); | 768 window_scroll (window, Qnil, 1, ERROR_ME_NOT); |
782 else | 769 #else /* Athena */ |
783 { | 770 { |
784 Lisp_Object value = Fcdr (object); | 771 Lisp_Object value = Fcdr (object); |
785 CHECK_INT (value); | 772 CHECK_INT (value); |
786 Fmove_to_window_line (value, window); | 773 Fmove_to_window_line (value, window); |
787 Fcenter_to_window_line (Qzero, window); | 774 Fcenter_to_window_line (Qzero, window); |
788 } | 775 } |
789 | 776 #endif /* Athena */ |
790 zmacs_region_stays = 1; | 777 zmacs_region_stays = 1; |
791 return Qnil; | 778 return Qnil; |
792 } | 779 } |
793 | 780 |
794 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, 1, 1, 0, /* | 781 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, 1, 1, 0, /* |
861 if (!EQ (value, Qmax)) | 848 if (!EQ (value, Qmax)) |
862 CHECK_INT (value); | 849 CHECK_INT (value); |
863 | 850 |
864 w = XWINDOW (window); | 851 w = XWINDOW (window); |
865 wcw = window_char_width (w, 0) - 1; | 852 wcw = window_char_width (w, 0) - 1; |
866 /* #### We should be able to scroll further right as long as there is | 853 /* ### We should be able to scroll further right as long as there is |
867 a visible truncation glyph. This calculation for max is bogus. */ | 854 a visible truncation glyph. This calculation for max is bogus. */ |
868 max_len = w->max_line_len + 2; | 855 max_len = w->max_line_len + 2; |
869 | 856 |
870 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw))) | 857 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw))) |
871 hscroll = max_len - wcw; | 858 hscroll = max_len - wcw; |
948 Vscrollbar_width = make_magic_specifier (Qnatnum); | 935 Vscrollbar_width = make_magic_specifier (Qnatnum); |
949 set_specifier_fallback | 936 set_specifier_fallback |
950 (Vscrollbar_width, | 937 (Vscrollbar_width, |
951 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_WIDTH)))); | 938 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_WIDTH)))); |
952 set_specifier_caching (Vscrollbar_width, | 939 set_specifier_caching (Vscrollbar_width, |
953 offsetof (struct window, scrollbar_width), | 940 slot_offset (struct window, |
941 scrollbar_width), | |
954 vertical_scrollbar_changed_in_window, | 942 vertical_scrollbar_changed_in_window, |
955 offsetof (struct frame, scrollbar_width), | 943 slot_offset (struct frame, |
944 scrollbar_width), | |
956 frame_size_slipped); | 945 frame_size_slipped); |
957 | 946 |
958 DEFVAR_SPECIFIER ("scrollbar-height", &Vscrollbar_height /* | 947 DEFVAR_SPECIFIER ("scrollbar-height", &Vscrollbar_height /* |
959 *Height of horizontal scrollbars. | 948 *Height of horizontal scrollbars. |
960 This is a specifier; use `set-specifier' to change it. | 949 This is a specifier; use `set-specifier' to change it. |
962 Vscrollbar_height = make_magic_specifier (Qnatnum); | 951 Vscrollbar_height = make_magic_specifier (Qnatnum); |
963 set_specifier_fallback | 952 set_specifier_fallback |
964 (Vscrollbar_height, | 953 (Vscrollbar_height, |
965 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_HEIGHT)))); | 954 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_HEIGHT)))); |
966 set_specifier_caching (Vscrollbar_height, | 955 set_specifier_caching (Vscrollbar_height, |
967 offsetof (struct window, scrollbar_height), | 956 slot_offset (struct window, |
957 scrollbar_height), | |
968 some_window_value_changed, | 958 some_window_value_changed, |
969 offsetof (struct frame, scrollbar_height), | 959 slot_offset (struct frame, |
960 scrollbar_height), | |
970 frame_size_slipped); | 961 frame_size_slipped); |
971 | 962 |
972 DEFVAR_SPECIFIER ("horizontal-scrollbar-visible-p", &Vhorizontal_scrollbar_visible_p /* | 963 DEFVAR_SPECIFIER ("horizontal-scrollbar-visible-p", &Vhorizontal_scrollbar_visible_p /* |
973 *Whether the horizontal scrollbar is visible. | 964 *Whether the horizontal scrollbar is visible. |
974 This is a specifier; use `set-specifier' to change it. | 965 This is a specifier; use `set-specifier' to change it. |
975 */ ); | 966 */ ); |
976 Vhorizontal_scrollbar_visible_p = Fmake_specifier (Qboolean); | 967 Vhorizontal_scrollbar_visible_p = Fmake_specifier (Qboolean); |
977 set_specifier_fallback (Vhorizontal_scrollbar_visible_p, | 968 set_specifier_fallback (Vhorizontal_scrollbar_visible_p, |
978 list1 (Fcons (Qnil, Qt))); | 969 list1 (Fcons (Qnil, Qt))); |
979 set_specifier_caching (Vhorizontal_scrollbar_visible_p, | 970 set_specifier_caching (Vhorizontal_scrollbar_visible_p, |
980 offsetof (struct window, | 971 slot_offset (struct window, |
981 horizontal_scrollbar_visible_p), | 972 horizontal_scrollbar_visible_p), |
982 some_window_value_changed, | 973 some_window_value_changed, |
983 offsetof (struct frame, | 974 slot_offset (struct frame, |
984 horizontal_scrollbar_visible_p), | 975 horizontal_scrollbar_visible_p), |
985 frame_size_slipped); | 976 frame_size_slipped); |
986 | 977 |
987 DEFVAR_SPECIFIER ("vertical-scrollbar-visible-p", &Vvertical_scrollbar_visible_p /* | 978 DEFVAR_SPECIFIER ("vertical-scrollbar-visible-p", &Vvertical_scrollbar_visible_p /* |
988 *Whether the vertical scrollbar is visible. | 979 *Whether the vertical scrollbar is visible. |
989 This is a specifier; use `set-specifier' to change it. | 980 This is a specifier; use `set-specifier' to change it. |
990 */ ); | 981 */ ); |
991 Vvertical_scrollbar_visible_p = Fmake_specifier (Qboolean); | 982 Vvertical_scrollbar_visible_p = Fmake_specifier (Qboolean); |
992 set_specifier_fallback (Vvertical_scrollbar_visible_p, | 983 set_specifier_fallback (Vvertical_scrollbar_visible_p, |
993 list1 (Fcons (Qnil, Qt))); | 984 list1 (Fcons (Qnil, Qt))); |
994 set_specifier_caching (Vvertical_scrollbar_visible_p, | 985 set_specifier_caching (Vvertical_scrollbar_visible_p, |
995 offsetof (struct window, | 986 slot_offset (struct window, |
996 vertical_scrollbar_visible_p), | 987 vertical_scrollbar_visible_p), |
997 vertical_scrollbar_changed_in_window, | 988 vertical_scrollbar_changed_in_window, |
998 offsetof (struct frame, | 989 slot_offset (struct frame, |
999 vertical_scrollbar_visible_p), | 990 vertical_scrollbar_visible_p), |
1000 frame_size_slipped); | 991 frame_size_slipped); |
1001 | 992 |
1002 DEFVAR_SPECIFIER ("scrollbar-on-left-p", &Vscrollbar_on_left_p /* | 993 DEFVAR_SPECIFIER ("scrollbar-on-left-p", &Vscrollbar_on_left_p /* |
1003 *Whether the vertical scrollbar is on the left side of window or frame. | 994 *Whether the vertical scrollbar is on the left side of window or frame. |
1004 This is a specifier; use `set-specifier' to change it. | 995 This is a specifier; use `set-specifier' to change it. |
1018 #endif | 1009 #endif |
1019 set_specifier_fallback (Vscrollbar_on_left_p, fallback); | 1010 set_specifier_fallback (Vscrollbar_on_left_p, fallback); |
1020 } | 1011 } |
1021 | 1012 |
1022 set_specifier_caching (Vscrollbar_on_left_p, | 1013 set_specifier_caching (Vscrollbar_on_left_p, |
1023 offsetof (struct window, scrollbar_on_left_p), | 1014 slot_offset (struct window, |
1015 scrollbar_on_left_p), | |
1024 vertical_scrollbar_changed_in_window, | 1016 vertical_scrollbar_changed_in_window, |
1025 offsetof (struct frame, scrollbar_on_left_p), | 1017 slot_offset (struct frame, |
1018 scrollbar_on_left_p), | |
1026 frame_size_slipped); | 1019 frame_size_slipped); |
1027 | 1020 |
1028 DEFVAR_SPECIFIER ("scrollbar-on-top-p", &Vscrollbar_on_top_p /* | 1021 DEFVAR_SPECIFIER ("scrollbar-on-top-p", &Vscrollbar_on_top_p /* |
1029 *Whether the horizontal scrollbar is on the top side of window or frame. | 1022 *Whether the horizontal scrollbar is on the top side of window or frame. |
1030 This is a specifier; use `set-specifier' to change it. | 1023 This is a specifier; use `set-specifier' to change it. |
1031 */ ); | 1024 */ ); |
1032 Vscrollbar_on_top_p = Fmake_specifier (Qboolean); | 1025 Vscrollbar_on_top_p = Fmake_specifier (Qboolean); |
1033 set_specifier_fallback (Vscrollbar_on_top_p, | 1026 set_specifier_fallback (Vscrollbar_on_top_p, |
1034 list1 (Fcons (Qnil, Qnil))); | 1027 list1 (Fcons (Qnil, Qnil))); |
1035 set_specifier_caching (Vscrollbar_on_top_p, | 1028 set_specifier_caching (Vscrollbar_on_top_p, |
1036 offsetof (struct window, scrollbar_on_top_p), | 1029 slot_offset (struct window, |
1030 scrollbar_on_top_p), | |
1037 some_window_value_changed, | 1031 some_window_value_changed, |
1038 offsetof (struct frame, scrollbar_on_top_p), | 1032 slot_offset (struct frame, |
1033 scrollbar_on_top_p), | |
1039 frame_size_slipped); | 1034 frame_size_slipped); |
1040 } | 1035 } |
1041 | 1036 |
1042 void | 1037 void |
1043 complex_vars_of_scrollbar (void) | 1038 complex_vars_of_scrollbar (void) |
1044 { | 1039 { |
1045 Vscrollbar_pointer_glyph = Fmake_glyph_internal (Qpointer); | 1040 Vscrollbar_pointer_glyph = Fmake_glyph_internal (Qpointer); |
1046 | 1041 |
1047 set_specifier_caching (XGLYPH (Vscrollbar_pointer_glyph)->image, | 1042 set_specifier_caching (XGLYPH (Vscrollbar_pointer_glyph)->image, |
1048 offsetof (struct window, scrollbar_pointer), | 1043 slot_offset (struct window, |
1044 scrollbar_pointer), | |
1049 scrollbar_pointer_changed_in_window, | 1045 scrollbar_pointer_changed_in_window, |
1050 0, 0); | 1046 0, 0); |
1051 } | 1047 } |