annotate src/scrollbar.c @ 280:7df0dd720c89 r21-0b38

Import from CVS: tag r21-0b38
author cvs
date Mon, 13 Aug 2007 10:32:22 +0200
parents 6330739388db
children c42ec1d1cded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Generic scrollbar implementation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 Copyright (C) 1995 Darrell Kindred <dkindred+@cmu.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 /* This file has been Mule-ized. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "commands.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "scrollbar.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "glyphs.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Lisp_Object Qinit_scrollbar_from_resources;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 Lisp_Object Qscrollbar_line_up;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 Lisp_Object Qscrollbar_line_down;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Lisp_Object Qscrollbar_page_up;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 Lisp_Object Qscrollbar_page_down;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Lisp_Object Qscrollbar_to_top;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 Lisp_Object Qscrollbar_to_bottom;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 Lisp_Object Qscrollbar_vertical_drag;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 Lisp_Object Qscrollbar_char_left;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 Lisp_Object Qscrollbar_char_right;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Lisp_Object Qscrollbar_page_left;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Lisp_Object Qscrollbar_page_right;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 Lisp_Object Qscrollbar_to_left;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Lisp_Object Qscrollbar_to_right;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 Lisp_Object Qscrollbar_horizontal_drag;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #define DEFAULT_SCROLLBAR_WIDTH 15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #define DEFAULT_SCROLLBAR_HEIGHT 15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 /* Width of the scrollbar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Lisp_Object Vscrollbar_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 /* Height of the scrollbar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Lisp_Object Vscrollbar_height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Lisp_Object Vscrollbar_pointer_glyph;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
68 EXFUN (Fcenter_to_window_line, 2);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
69
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 static void update_scrollbar_instance (struct window *w, int vertical,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 struct scrollbar_instance *instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 free_scrollbar_instance (struct scrollbar_instance *instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 struct frame *frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 if (!instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 struct device *d = XDEVICE (frame->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 MAYBE_DEVMETH (d, free_scrollbar_instance, (instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 xfree (instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 free_window_mirror_scrollbars (struct window_mirror *mir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 struct frame *f = mir->frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 free_scrollbar_instance (mir->scrollbar_vertical_instance, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 mir->scrollbar_vertical_instance = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 free_scrollbar_instance (mir->scrollbar_horizontal_instance, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 mir->scrollbar_horizontal_instance = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 static struct window_mirror *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 free_scrollbars_loop (Lisp_Object window, struct window_mirror *mir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 struct window_mirror *retval = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 while (mir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 struct scrollbar_instance *vinst = mir->scrollbar_vertical_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 struct scrollbar_instance *hinst = mir->scrollbar_horizontal_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 struct frame *f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 assert (!NILP (window));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 f = XFRAME (XWINDOW (window)->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 if (mir->vchild)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 retval = free_scrollbars_loop (XWINDOW (window)->vchild,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 mir->vchild);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 else if (mir->hchild)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 retval = free_scrollbars_loop (XWINDOW (window)->hchild,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 mir->hchild);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 if (retval != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 if (hinst || vinst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 free_window_mirror_scrollbars (mir);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 mir = mir->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 window = XWINDOW (window)->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 /* Destroy all scrollbars associated with FRAME. Only called from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 delete_frame_internal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 #define FREE_FRAME_SCROLLBARS_INTERNAL(cache) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 while (FRAME_SB_##cache (f)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 struct scrollbar_instance *tofree = FRAME_SB_##cache (f); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 FRAME_SB_##cache (f) = FRAME_SB_##cache (f)->next; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 tofree->next = NULL; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 free_scrollbar_instance (tofree, f); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 free_frame_scrollbars (struct frame *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 if (!HAS_FRAMEMETH_P (f, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 if (f->mirror_dirty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 update_frame_window_mirror (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 free_scrollbars_loop (f->root_window, f->root_mirror);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 FREE_FRAME_SCROLLBARS_INTERNAL (VCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 FREE_FRAME_SCROLLBARS_INTERNAL (HCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 #undef FREE_FRAME_SCROLLBARS_INTERNAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 static struct scrollbar_instance *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 create_scrollbar_instance (struct frame *f, int vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 struct scrollbar_instance *instance =
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 102
diff changeset
173 xnew_and_zero (struct scrollbar_instance);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 MAYBE_DEVMETH (d, create_scrollbar_instance, (f, vertical, instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 return instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 #define GET_SCROLLBAR_INSTANCE_INTERNAL(cache) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 if (FRAME_SB_##cache (f)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 struct scrollbar_instance *retval = FRAME_SB_##cache (f); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 FRAME_SB_##cache (f) = FRAME_SB_##cache (f)->next; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 retval->next = NULL; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 return retval; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 static struct scrollbar_instance *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 get_scrollbar_instance (struct frame *f, int vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 /* Check if there are any available scrollbars already in existence. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 if (vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 GET_SCROLLBAR_INSTANCE_INTERNAL (VCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 GET_SCROLLBAR_INSTANCE_INTERNAL (HCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 return create_scrollbar_instance (f, vertical);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 #undef GET_SCROLLBAR_INSTANCE_INTERNAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 #define RELEASE_SCROLLBAR_INSTANCE_INTERNAL(cache) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 if (!FRAME_SB_##cache (f)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 instance->next = NULL; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 FRAME_SB_##cache (f) = instance; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 else \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 instance->next = FRAME_SB_##cache (f); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 FRAME_SB_##cache (f) = instance; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 release_scrollbar_instance (struct frame *f, int vertical,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 struct scrollbar_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 /* #### should we do "instance->mir = 0;" for safety? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 if (vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 RELEASE_SCROLLBAR_INSTANCE_INTERNAL (VCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 RELEASE_SCROLLBAR_INSTANCE_INTERNAL (HCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 #undef RELEASE_SCROLLBAR_INSTANCE_INTERNAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 #ifdef MEMORY_USAGE_STATS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 compute_scrollbar_instance_usage (struct device *d,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 struct scrollbar_instance *inst,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 struct overhead_stats *ovstats)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 int total = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 total += DEVMETH (d, compute_scrollbar_instance_usage, (d, inst, ovstats));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 while (inst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 total += malloced_storage_size (inst, sizeof (*inst), ovstats);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 inst = inst->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 return total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 #endif /* MEMORY_USAGE_STATS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 update_window_scrollbars (struct window *w, struct window_mirror *mirror,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 int active, int horiz_only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 struct frame *f = XFRAME (w->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 if (!HAS_DEVMETH_P (d, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 in_display++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 /* It is possible for this to get called from the mirror update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 routines. In that case the structure is in an indeterminate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 state but we know exactly what struct we are working with. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 pass it in in that case. We also take advantage of it at some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 other points where we know what the mirror struct is. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 if (!mirror)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 mirror = find_window_mirror (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 if (!mirror->scrollbar_vertical_instance && active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 mirror->scrollbar_vertical_instance = get_scrollbar_instance (f, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 if (!mirror->scrollbar_horizontal_instance && active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 mirror->scrollbar_horizontal_instance = get_scrollbar_instance (f, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 if (!horiz_only && mirror->scrollbar_vertical_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 int size = (active ? window_scrollbar_width (w) : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 struct scrollbar_instance *instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 instance = mirror->scrollbar_vertical_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 instance->scrollbar_is_active = active;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 instance->mirror = mirror;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 if (active && size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 update_scrollbar_instance (w, 1, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 MAYBE_DEVMETH (d, update_scrollbar_instance_status,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (w, active, size, instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 if (!active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 release_scrollbar_instance (f, 1, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 mirror->scrollbar_vertical_instance = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 if (mirror->scrollbar_horizontal_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 int size = (active ? window_scrollbar_height (w) : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 struct scrollbar_instance *instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 instance = mirror->scrollbar_horizontal_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 instance->scrollbar_is_active = active;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 instance->mirror = mirror;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 if (active && size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 update_scrollbar_instance (w, 0, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 MAYBE_DEVMETH (d, update_scrollbar_instance_status,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (w, active, size, instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 if (!active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 release_scrollbar_instance (f, 0, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 mirror->scrollbar_horizontal_instance = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 in_display--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 release_window_mirror_scrollbars (struct window_mirror *mir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 struct device *d = XDEVICE (mir->frame->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 if (!HAS_DEVMETH_P (d, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 if (mir->scrollbar_vertical_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 release_scrollbar_instance (mir->frame, 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 mir->scrollbar_vertical_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 MAYBE_DEVMETH (d, release_scrollbar_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (mir->scrollbar_vertical_instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 mir->scrollbar_vertical_instance = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 if (mir->scrollbar_horizontal_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 release_scrollbar_instance (mir->frame, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 mir->scrollbar_horizontal_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 MAYBE_DEVMETH (d, release_scrollbar_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (mir->scrollbar_horizontal_instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 mir->scrollbar_horizontal_instance = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 /* This check needs to be done in the device-specific side. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 #define UPDATE_DATA_FIELD(field, value) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 if (instance->field != value) {\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 instance->field = value;\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 instance->scrollbar_instance_changed = 1;\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 }\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 * If w->sb_point is on the top line then return w->sb_point else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 * return w->start. If flag, then return beginning point of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 * which w->sb_point lies on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 static Bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 scrollbar_point (struct window *w, int flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Bufpos start_pos, end_pos, sb_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 Lisp_Object buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 struct buffer *b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 if (NILP (w->buffer)) /* non-leaf window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 start_pos = marker_position (w->start[CURRENT_DISP]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 sb_pos = marker_position (w->sb_point);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 if (!flag && sb_pos < start_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 return start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 buf = get_buffer (w->buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 if (!NILP (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 b = XBUFFER (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 return start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 if (flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 end_pos = find_next_newline_no_quit (b, sb_pos, -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 end_pos = find_next_newline_no_quit (b, start_pos, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 if (flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 return end_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 else if (sb_pos > end_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 return start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 return sb_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 * Update a window's horizontal or vertical scrollbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 update_scrollbar_instance (struct window *w, int vertical,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 struct scrollbar_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 struct frame *f = XFRAME (w->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 struct buffer *b = XBUFFER (w->buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 Bufpos start_pos, end_pos, sb_pos;
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
409 int scrollbar_width = window_scrollbar_width (w);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 int scrollbar_height = window_scrollbar_height (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 int new_line_increment = -1, new_page_increment = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 int new_minimum = -1, new_maximum = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 int new_slider_size = -1, new_slider_position = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 int new_width = -1, new_height = -1, new_x = -1, new_y = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 struct window *new_window = 0; /* kludge city */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 end_pos = BUF_Z (b) - w->window_end_pos[CURRENT_DISP];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 sb_pos = scrollbar_point (w, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 start_pos = sb_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 /* The end position must be strictly greater than the start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 position, at least for the Motify scrollbar. It shouldn't hurt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 anything for other scrollbar implementations. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 if (end_pos <= start_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 end_pos = start_pos + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 if (vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 new_height = WINDOW_TEXT_HEIGHT (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 new_width = scrollbar_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 new_height = scrollbar_height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 new_width = WINDOW_TEXT_WIDTH (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 /* If the height and width are not greater than 0, then later on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 Motif widgets will bitch and moan. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 if (new_height <= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 new_height = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 if (new_width <= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 new_width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 assert (instance->mirror && XWINDOW (real_window(instance->mirror, 0)) == w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 /* Only character-based scrollbars are implemented at the moment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Line-based will be implemented in the future. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 instance->scrollbar_is_active = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 new_line_increment = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 new_page_increment = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
455 /* We used to check for inhibit_scrollbar_slider_size_change here,
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
456 but that seems bogus. */
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
457 {
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
458 int x_offset, y_offset;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
460 /* Scrollbars are always the farthest from the text area. */
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
461 if (vertical)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
462 {
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
463 x_offset = (f->scrollbar_on_left
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
464 ? WINDOW_LEFT (w)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
465 : WINDOW_RIGHT (w) - scrollbar_width);
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
466 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset;
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
467 }
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
468 else
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
469 {
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
470 x_offset = WINDOW_TEXT_LEFT (w);
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
471 y_offset = f->scrollbar_y_offset +
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
472 (f->scrollbar_on_top
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
473 ? WINDOW_TOP (w)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
474 : WINDOW_TEXT_BOTTOM (w) + window_bottom_toolbar_height (w));
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
475 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
477 new_x = x_offset;
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
478 new_y = y_offset;
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
479 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 /* A disabled scrollbar has its slider sized to the entire height of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 the scrollbar. Currently the minibuffer scrollbar is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 disabled. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (!MINI_WINDOW_P (w) && vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 {
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
486 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_slider_size_change, (), 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 new_minimum = BUF_BEGV (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 new_maximum = max (BUF_ZV (b), new_minimum + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 new_slider_size = min ((end_pos - start_pos),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (new_maximum - new_minimum));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 new_slider_position = sb_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 new_window = w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 else if (!MINI_WINDOW_P (w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 /* The minus one is to account for the truncation glyph. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 int wcw = window_char_width (w, 0) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 int max_width, max_slide;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 if (w->max_line_len < wcw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 max_width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 max_slide = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 wcw = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 max_width = w->max_line_len + 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 max_slide = max_width - wcw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 new_minimum = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 new_maximum = max_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 new_slider_size = wcw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 new_slider_position = min (w->hscroll, max_slide);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 }
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
519 else /* MINI_WINDOW_P (w) */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 new_minimum = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 new_maximum = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 new_slider_size = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 new_slider_position = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 instance->scrollbar_is_active = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 DEVMETH (d, update_scrollbar_instance_values, (w, instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 new_line_increment,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 new_page_increment,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 new_minimum,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 new_maximum,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 new_slider_size,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 new_slider_position,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 new_width, new_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 new_x, new_y));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 init_frame_scrollbars (struct frame *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 if (HAS_DEVMETH_P (d, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 {
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
546 int depth = unlock_ghost_specifiers_protected ();
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
547 Lisp_Object frame;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 XSETFRAME (frame, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 call_critical_lisp_code (XDEVICE (FRAME_DEVICE (f)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 Qinit_scrollbar_from_resources,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 frame);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
552 unbind_to (depth, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 init_device_scrollbars (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 if (HAS_DEVMETH_P (d, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 {
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
561 int depth = unlock_ghost_specifiers_protected ();
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
562 Lisp_Object device;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 call_critical_lisp_code (d,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 Qinit_scrollbar_from_resources,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 device);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
567 unbind_to (depth, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 init_global_scrollbars (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 if (HAS_DEVMETH_P (d, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 {
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
576 int depth = unlock_ghost_specifiers_protected ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 call_critical_lisp_code (d,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 Qinit_scrollbar_from_resources,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 Qglobal);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
580 unbind_to (depth, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 /* This function is called as a result of a change to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 `scrollbar-width' specifier. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 scrollbar_width_changed_in_frame (Lisp_Object specifier, struct frame *f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 Lisp_Object oldval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 MAYBE_FRAMEMETH (f, scrollbar_width_changed_in_frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (specifier, f, oldval));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 /* This function is called as a result of a change to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 `scrollbar-height' specifier. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 scrollbar_height_changed_in_frame (Lisp_Object specifier, struct frame *f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 Lisp_Object oldval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 MAYBE_FRAMEMETH (f, scrollbar_height_changed_in_frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (specifier, f, oldval));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 /* This function is called as a result of a change to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 `scrollbar-pointer' glyph. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 scrollbar_pointer_changed_in_window (Lisp_Object specifier, struct window *w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 Lisp_Object oldval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 struct frame *f = XFRAME (WINDOW_FRAME (w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 if (f->init_finished)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 MAYBE_FRAMEMETH (f, scrollbar_pointer_changed_in_window, (w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 /* ####
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 All of the following stuff is functions that handle scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 actions. All of it should be moved into Lisp. This may require
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 adding some badly-needed primitives. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 /********** vertical scrollbar stuff **********/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 * If the original point is still visible, put the cursor back there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 * Otherwise, when scrolling down stick it at the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 * first visible line and when scrolling up stick it at the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 * of the last visible line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 /* #### This function should be moved into Lisp */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 scrollbar_reset_cursor (Lisp_Object win, Lisp_Object orig_pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 /* When this function is called we know that start is already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 accurate. We know this because either set-window-start or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 recenter was called immediately prior to it being called. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 Lisp_Object buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 Bufpos start_pos = XINT (Fwindow_start (win));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 Bufpos ptint = XINT (orig_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 struct window *w = XWINDOW (win);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 int selected = ((w == XWINDOW (Fselected_window (XFRAME (w->frame)->device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ? 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 buf = Fwindow_buffer (win);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 if (NILP (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 return; /* the window was deleted out from under us */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 if (ptint < XINT (Fwindow_start (win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 if (selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 Fgoto_char (make_int (start_pos), buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 Fset_window_point (win, make_int (start_pos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 else if (!point_would_be_visible (XWINDOW (win), start_pos, ptint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 Fmove_to_window_line (make_int (-1), win);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 if (selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 Fbeginning_of_line (Qnil, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 /* #### Taken from forward-line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 Bufpos pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 pos = find_next_newline (XBUFFER (buf),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 marker_position (w->pointm[CURRENT_DISP]),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 Fset_window_point (win, make_int (pos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 if (selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 Fgoto_char (orig_pt, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 Fset_window_point (win, orig_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
684 DEFUN ("scrollbar-line-up", Fscrollbar_line_up, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 Function called when the line-up arrow on the scrollbar is clicked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 This is the little arrow at the top of the scrollbar. One argument, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 scrollbar's window. You can advise this function to change the scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 behavior.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
689 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
690 (window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 window_scroll (window, make_int (1), -1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
698 DEFUN ("scrollbar-line-down", Fscrollbar_line_down, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 Function called when the line-down arrow on the scrollbar is clicked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 This is the little arrow at the bottom of the scrollbar. One argument, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 scrollbar's window. You can advise this function to change the scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 behavior.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
703 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
704 (window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 window_scroll (window, make_int (1), 1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
712 DEFUN ("scrollbar-page-up", Fscrollbar_page_up, 1, 1, 0, /*
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 102
diff changeset
713 Function called when the user gives the "page-up" scrollbar action.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
714 \(The way this is done can vary from scrollbar to scrollbar.) One argument,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 a cons containing the scrollbar's window and a value (#### document me!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 This value is nil for Motif/Lucid scrollbars and a number for Athena
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 scrollbars). You can advise this function to change the scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 behavior.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
719 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
720 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 Lisp_Object window = Fcar (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 /* Motif and Athena scrollbars behave differently, but in accordance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 with their standard behaviors. It is not possible to hide the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 differences down in lwlib because knowledge of XEmacs buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 cursor motion routines is necessary. */
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
729 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 185
diff changeset
730 defined (LWLIB_SCROLLBARS_ATHENA3D) || defined(HAVE_MS_WINDOWS)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 window_scroll (window, Qnil, -1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 #else /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 Bufpos bufpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 Lisp_Object value = Fcdr (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 Fmove_to_window_line (Qzero, window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 /* can't use Fvertical_motion() because it moves the buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 rather than the window's point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 #### It does? Why does it take a window argument then? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 bufpos = vmotion (XWINDOW (window), XINT (Fwindow_point (window)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 XINT (value), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 Fset_window_point (window, make_int (bufpos));
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
746 Fcenter_to_window_line (Qzero, window);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 #endif /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
753 DEFUN ("scrollbar-page-down", Fscrollbar_page_down, 1, 1, 0, /*
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 102
diff changeset
754 Function called when the user gives the "page-down" scrollbar action.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
755 \(The way this is done can vary from scrollbar to scrollbar.) One argument,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 a cons containing the scrollbar's window and a value (#### document me!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 This value is nil for Motif/Lucid scrollbars and a number for Athena
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 scrollbars). You can advise this function to change the scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 behavior.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
760 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
761 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 Lisp_Object window = Fcar (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 /* Motif and Athena scrollbars behave differently, but in accordance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 with their standard behaviors. It is not possible to hide the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 differences down in lwlib because knowledge of XEmacs buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 cursor motion routines is necessary. */
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
770 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 185
diff changeset
771 defined (LWLIB_SCROLLBARS_ATHENA3D) || defined (HAVE_MS_WINDOWS)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 window_scroll (window, Qnil, 1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 #else /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 Lisp_Object value = Fcdr (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 Fmove_to_window_line (value, window);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
778 Fcenter_to_window_line (Qzero, window);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 #endif /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
785 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, 1, 1, 0, /*
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 102
diff changeset
786 Function called when the user invokes the "to-top" scrollbar action.
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
787 The way this is done can vary from scrollbar to scrollbar, but
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
788 C-button1 on the up-arrow is very common. One argument, the
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
789 scrollbar's window. You can advise this function to change the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 scrollbar behavior.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
791 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
792 (window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 {
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
794 Lisp_Object orig_pt = Fwindow_point (window);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 Fset_window_point (window, Fpoint_min (Fwindow_buffer (window)));
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
796 Fcenter_to_window_line (Qzero, window);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 scrollbar_reset_cursor (window, orig_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
802 DEFUN ("scrollbar-to-bottom", Fscrollbar_to_bottom, 1, 1, 0, /*
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 102
diff changeset
803 Function called when the user invokes the "to-bottom" scrollbar action.
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
804 The way this is done can vary from scrollbar to scrollbar, but
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
805 C-button1 on the down-arrow is very common. One argument, the
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
806 scrollbar's window. You can advise this function to change the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 scrollbar behavior.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
808 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
809 (window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 {
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
811 Lisp_Object orig_pt = Fwindow_point (window);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 Fset_window_point (window, Fpoint_max (Fwindow_buffer (window)));
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 276
diff changeset
813 Fcenter_to_window_line (make_int (-3), window);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 scrollbar_reset_cursor (window, orig_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
819 DEFUN ("scrollbar-vertical-drag", Fscrollbar_vertical_drag, 1, 1, 0, /*
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
820 Function called when the user drags the vertical scrollbar slider.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 One argument, a cons containing the scrollbar's window and a value
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
822 between point-min and point-max. You can advise this function to
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
823 change the scrollbar behavior.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
824 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
825 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 Bufpos start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 Lisp_Object orig_pt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 Lisp_Object window = Fcar (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 Lisp_Object value = Fcdr (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 orig_pt = Fwindow_point (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 Fset_marker (XWINDOW (window)->sb_point, value, Fwindow_buffer (window));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 start_pos = scrollbar_point (XWINDOW (window), 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 Fset_window_start (window, make_int (start_pos), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 scrollbar_reset_cursor (window, orig_pt);
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
837 Fsit_for(Qzero, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
842 DEFUN ("scrollbar-set-hscroll", Fscrollbar_set_hscroll, 2, 2, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
843 Set WINDOW's hscroll position to VALUE.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 This ensures that VALUE is in the proper range for the horizontal scrollbar.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
845 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
846 (window, value))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 struct window *w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 int hscroll, wcw, max_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 if (!EQ (value, Qmax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 w = XWINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 wcw = window_char_width (w, 0) - 1;
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
857 /* ### We should be able to scroll further right as long as there is
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
858 a visible truncation glyph. This calculation for max is bogus. */
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
859 max_len = w->max_line_len + 2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 hscroll = max_len - wcw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 hscroll = XINT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 /* Can't allow this out of set-window-hscroll's acceptable range. */
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
867 /* #### What hell on the earth this code limits scroll size to the
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
868 machine-dependant SHORT size? -- kkm */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 if (hscroll < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 hscroll = 0;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
871 else if (hscroll >= (1 << (SHORTBITS - 1)) - 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 hscroll = (1 << (SHORTBITS - 1)) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 if (hscroll != w->hscroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 Fset_window_hscroll (window, make_int (hscroll));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 syms_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 defsymbol (&Qscrollbar_line_up, "scrollbar-line-up");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 defsymbol (&Qscrollbar_line_down, "scrollbar-line-down");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 defsymbol (&Qscrollbar_page_up, "scrollbar-page-up");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 defsymbol (&Qscrollbar_page_down, "scrollbar-page-down");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 defsymbol (&Qscrollbar_to_top, "scrollbar-to-top");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 defsymbol (&Qscrollbar_to_bottom, "scrollbar-to-bottom");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 defsymbol (&Qscrollbar_vertical_drag, "scrollbar-vertical-drag");
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 102
diff changeset
895
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 defsymbol (&Qscrollbar_char_left, "scrollbar-char-left");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 defsymbol (&Qscrollbar_char_right, "scrollbar-char-right");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 defsymbol (&Qscrollbar_page_left, "scrollbar-page-left");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 defsymbol (&Qscrollbar_page_right, "scrollbar-page-right");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 defsymbol (&Qscrollbar_to_left, "scrollbar-to-left");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 defsymbol (&Qscrollbar_to_right, "scrollbar-to-right");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 defsymbol (&Qscrollbar_horizontal_drag, "scrollbar-horizontal-drag");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 defsymbol (&Qinit_scrollbar_from_resources, "init-scrollbar-from-resources");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 /* #### All these functions should be moved into Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 See comment above. */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
908 DEFSUBR (Fscrollbar_line_up);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
909 DEFSUBR (Fscrollbar_line_down);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
910 DEFSUBR (Fscrollbar_page_up);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
911 DEFSUBR (Fscrollbar_page_down);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
912 DEFSUBR (Fscrollbar_to_top);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
913 DEFSUBR (Fscrollbar_to_bottom);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
914 DEFSUBR (Fscrollbar_vertical_drag);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
916 DEFSUBR (Fscrollbar_set_hscroll);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 vars_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 DEFVAR_LISP ("scrollbar-pointer-glyph", &Vscrollbar_pointer_glyph /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 *The shape of the mouse-pointer when over a scrollbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 This is a glyph; use `set-glyph-image' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 If unspecified in a particular domain, the window-system-provided
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 default pointer is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 Fprovide (intern ("scrollbar"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 specifier_vars_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 DEFVAR_SPECIFIER ("scrollbar-width", &Vscrollbar_width /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 *Width of vertical scrollbars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 This is a specifier; use `set-specifier' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 */ );
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
939 Vscrollbar_width = make_magic_specifier (Qnatnum);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 set_specifier_fallback
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (Vscrollbar_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_WIDTH))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 set_specifier_caching (Vscrollbar_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 slot_offset (struct window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 scrollbar_width),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 some_window_value_changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 slot_offset (struct frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 scrollbar_width),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 scrollbar_width_changed_in_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 DEFVAR_SPECIFIER ("scrollbar-height", &Vscrollbar_height /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 *Height of horizontal scrollbars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 This is a specifier; use `set-specifier' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 */ );
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
955 Vscrollbar_height = make_magic_specifier (Qnatnum);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 set_specifier_fallback
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (Vscrollbar_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_HEIGHT))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 set_specifier_caching (Vscrollbar_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 slot_offset (struct window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 scrollbar_height),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 some_window_value_changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 slot_offset (struct frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 scrollbar_height),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 scrollbar_height_changed_in_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 complex_vars_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 Vscrollbar_pointer_glyph = Fmake_glyph_internal (Qpointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 set_specifier_caching (XGLYPH (Vscrollbar_pointer_glyph)->image,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 slot_offset (struct window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 scrollbar_pointer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 scrollbar_pointer_changed_in_window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 }