annotate src/scrollbar.c @ 266:18d185df8c54

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