Initial git import
[sxemacs] / lisp / scrollbar.el
1 ;;; scrollbar.el --- Scrollbar support for SXEmacs
2
3 ;; Copyright (C) 1995, 1997 Free Software Foundation, Inc.
4
5 ;; Maintainer: SXEmacs Development Team
6 ;; Keywords: internal, extensions, dumped
7
8 ;; This file is part of SXEmacs.
9
10 ;; SXEmacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
14
15 ;; SXEmacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 ;;; Synched up with: Not in FSF. (Completely divergent from FSF scroll-bar.el)
24
25 ;;; Commentary:
26
27 ;; This file is dumped with SXEmacs (when scrollbar support is compiled in).
28
29 ;;; Code:
30
31 ;; added for the options menu - dverna
32 (defcustom scrollbars-visible-p t
33   "Whether the scrollbars are globally visible.
34 This variable can be customized through the options menu."
35   :type 'boolean
36   :set (lambda (var val)
37          (set-specifier vertical-scrollbar-visible-p val)
38          (set-specifier horizontal-scrollbar-visible-p val)
39          (setq-default scrollbars-visible-p val))
40   :group 'display)
41
42 (defun init-scrollbar-from-resources (locale)
43   (when (and (featurep 'x)
44              (or (eq locale 'global)
45                  (eq 'x (device-or-frame-type locale))))
46     (x-init-scrollbar-from-resources locale)))
47
48 ;;
49 ;; vertical scrollbar functions
50 ;;
51
52 ;;; #### Move functions from C into Lisp here!
53
54 ;;
55 ;; horizontal scrollbar functions
56 ;;
57
58 (defun scrollbar-char-left (window)
59   "Function called when the char-left arrow on the scrollbar is clicked.
60 This is the little arrow to the left of the scrollbar.  One argument is
61 passed, the scrollbar's window.  You can advise this function to
62 change the scrollbar behavior."
63   (when (window-live-p window)
64     (scrollbar-set-hscroll window (- (window-hscroll window) 1))
65     (setq zmacs-region-stays t)
66     nil))
67
68 (defun scrollbar-char-right (window)
69   "Function called when the char-right arrow on the scrollbar is clicked.
70 This is the little arrow to the right of the scrollbar.  One argument is
71 passed, the scrollbar's window.  You can advise this function to
72 change the scrollbar behavior."
73   (when (window-live-p window)
74     (scrollbar-set-hscroll window (+ (window-hscroll window) 1))
75     (setq zmacs-region-stays t)
76     nil))
77
78 (defun scrollbar-page-left (window)
79   "Function called when the user gives the \"page-left\" scrollbar action.
80 \(The way this is done can vary from scrollbar to scrollbar.\) One argument is
81 passed, the scrollbar's window.  You can advise this function to
82 change the scrollbar behavior."
83   (when (window-live-p window)
84     (scrollbar-set-hscroll window (- (window-hscroll window)
85                                      (- (window-width window) 2)))
86     (setq zmacs-region-stays t)
87     nil))
88
89 (defun scrollbar-page-right (window)
90   "Function called when the user gives the \"page-right\" scrollbar action.
91 \(The way this is done can vary from scrollbar to scrollbar.\) One argument is
92 passed, the scrollbar's window.  You can advise this function to
93 change the scrollbar behavior."
94   (when (window-live-p window)
95     (scrollbar-set-hscroll window (+ (window-hscroll window)
96                                      (- (window-width window) 2)))
97     (setq zmacs-region-stays t)
98     nil))
99
100 (defun scrollbar-to-left (window)
101   "Function called when the user gives the \"to-left\" scrollbar action.
102 \(The way this is done can vary from scrollbar to scrollbar.\). One argument is
103 passed, the scrollbar's window.  You can advise this function to
104 change the scrollbar behavior."
105   (when (window-live-p window)
106     (scrollbar-set-hscroll window 0)
107     (setq zmacs-region-stays t)
108     nil))
109
110 (defun scrollbar-to-right (window)
111   "Function called when the user gives the \"to-right\" scrollbar action.
112 \(The way this is done can vary from scrollbar to scrollbar.\). One argument is
113 passed, the scrollbar's window.  You can advise this function to
114 change the scrollbar behavior."
115   (when (window-live-p window)
116     (scrollbar-set-hscroll window 'max)
117     (setq zmacs-region-stays t)
118     nil))
119
120 (defun scrollbar-horizontal-drag (data)
121   "Function called when the user drags the horizontal scrollbar thumb.
122 One argument is passed, a cons containing the scrollbar's window and a value
123 representing how many columns the thumb is slid over.  You can advise
124 this function to change the scrollbar behavior."
125   (let ((window (car data))
126         (value  (cdr data)))
127     (when (and (window-live-p window) (integerp value))
128       (scrollbar-set-hscroll window value)
129       (setq zmacs-region-stays t)
130       nil)))
131
132 ;;; scrollbar.el ends here