annotate src/scrollbar.c @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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 =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (struct scrollbar_instance *) xmalloc (sizeof (*instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 memset (instance, 0, sizeof (*instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 MAYBE_DEVMETH (d, create_scrollbar_instance, (f, vertical, instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 return instance;
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 #define GET_SCROLLBAR_INSTANCE_INTERNAL(cache) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 if (FRAME_SB_##cache (f)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 struct scrollbar_instance *retval = FRAME_SB_##cache (f); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 FRAME_SB_##cache (f) = FRAME_SB_##cache (f)->next; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 retval->next = NULL; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 return retval; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 static struct scrollbar_instance *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 get_scrollbar_instance (struct frame *f, int vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 /* Check if there are any available scrollbars already in existence. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 if (vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 GET_SCROLLBAR_INSTANCE_INTERNAL (VCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 GET_SCROLLBAR_INSTANCE_INTERNAL (HCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 return create_scrollbar_instance (f, vertical);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 #undef GET_SCROLLBAR_INSTANCE_INTERNAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 #define RELEASE_SCROLLBAR_INSTANCE_INTERNAL(cache) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 if (!FRAME_SB_##cache (f)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 instance->next = NULL; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 FRAME_SB_##cache (f) = instance; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 else \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 instance->next = FRAME_SB_##cache (f); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 FRAME_SB_##cache (f) = instance; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 release_scrollbar_instance (struct frame *f, int vertical,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 struct scrollbar_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 /* #### should we do "instance->mir = 0;" for safety? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 if (vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 RELEASE_SCROLLBAR_INSTANCE_INTERNAL (VCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 RELEASE_SCROLLBAR_INSTANCE_INTERNAL (HCACHE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 #undef RELEASE_SCROLLBAR_INSTANCE_INTERNAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 #ifdef MEMORY_USAGE_STATS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 compute_scrollbar_instance_usage (struct device *d,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 struct scrollbar_instance *inst,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 struct overhead_stats *ovstats)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 int total = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 total += DEVMETH (d, compute_scrollbar_instance_usage, (d, inst, ovstats));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 while (inst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 total += malloced_storage_size (inst, sizeof (*inst), ovstats);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 inst = inst->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 return total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 #endif /* MEMORY_USAGE_STATS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 update_window_scrollbars (struct window *w, struct window_mirror *mirror,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 int active, int horiz_only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 struct frame *f = XFRAME (w->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 if (!HAS_DEVMETH_P (d, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 in_display++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 /* It is possible for this to get called from the mirror update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 routines. In that case the structure is in an indeterminate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 state but we know exactly what struct we are working with. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 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
268 other points where we know what the mirror struct is. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 if (!mirror)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 mirror = find_window_mirror (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 if (!mirror->scrollbar_vertical_instance && active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 mirror->scrollbar_vertical_instance = get_scrollbar_instance (f, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 if (!mirror->scrollbar_horizontal_instance && active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 mirror->scrollbar_horizontal_instance = get_scrollbar_instance (f, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 if (!horiz_only && mirror->scrollbar_vertical_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 int size = (active ? window_scrollbar_width (w) : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 struct scrollbar_instance *instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 instance = mirror->scrollbar_vertical_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 instance->scrollbar_is_active = active;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 instance->mirror = mirror;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 if (active && size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 update_scrollbar_instance (w, 1, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 MAYBE_DEVMETH (d, update_scrollbar_instance_status,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (w, active, size, instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 if (!active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 release_scrollbar_instance (f, 1, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 mirror->scrollbar_vertical_instance = NULL;
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 if (mirror->scrollbar_horizontal_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 int size = (active ? window_scrollbar_height (w) : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 struct scrollbar_instance *instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 instance = mirror->scrollbar_horizontal_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 instance->scrollbar_is_active = active;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 instance->mirror = mirror;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 if (active && size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 update_scrollbar_instance (w, 0, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 MAYBE_DEVMETH (d, update_scrollbar_instance_status,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (w, active, size, instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 if (!active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 release_scrollbar_instance (f, 0, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 mirror->scrollbar_horizontal_instance = NULL;
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 in_display--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 release_window_mirror_scrollbars (struct window_mirror *mir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 struct device *d = XDEVICE (mir->frame->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 if (!HAS_DEVMETH_P (d, create_scrollbar_instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 if (mir->scrollbar_vertical_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 release_scrollbar_instance (mir->frame, 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 mir->scrollbar_vertical_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 MAYBE_DEVMETH (d, release_scrollbar_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (mir->scrollbar_vertical_instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 mir->scrollbar_vertical_instance = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 if (mir->scrollbar_horizontal_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 release_scrollbar_instance (mir->frame, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 mir->scrollbar_horizontal_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 MAYBE_DEVMETH (d, release_scrollbar_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (mir->scrollbar_horizontal_instance));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 mir->scrollbar_horizontal_instance = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 /* This check needs to be done in the device-specific side. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 #define UPDATE_DATA_FIELD(field, value) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 if (instance->field != value) {\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 instance->field = value;\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 instance->scrollbar_instance_changed = 1;\
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 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 * 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
359 * return w->start. If flag, then return beginning point of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 * which w->sb_point lies on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 static Bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 scrollbar_point (struct window *w, int flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 Bufpos start_pos, end_pos, sb_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Lisp_Object buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 struct buffer *b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 if (NILP (w->buffer)) /* non-leaf window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 start_pos = marker_position (w->start[CURRENT_DISP]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 sb_pos = marker_position (w->sb_point);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 if (!flag && sb_pos < start_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 return start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 buf = get_buffer (w->buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 if (!NILP (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 b = XBUFFER (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 return start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 if (flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 end_pos = find_next_newline_no_quit (b, sb_pos, -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 end_pos = find_next_newline_no_quit (b, start_pos, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 if (flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 return end_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 else if (sb_pos > end_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 return start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 return sb_pos;
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 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 * Update a window's horizontal or vertical scrollbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 update_scrollbar_instance (struct window *w, int vertical,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 struct scrollbar_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 struct frame *f = XFRAME (w->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 struct buffer *b = XBUFFER (w->buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 Bufpos start_pos, end_pos, sb_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 int scrollbar_width = window_scrollbar_width (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 int scrollbar_height = window_scrollbar_height (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 int new_line_increment = -1, new_page_increment = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 int new_minimum = -1, new_maximum = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 int new_slider_size = -1, new_slider_position = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 int new_width = -1, new_height = -1, new_x = -1, new_y = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 struct window *new_window = 0; /* kludge city */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 end_pos = BUF_Z (b) - w->window_end_pos[CURRENT_DISP];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 sb_pos = scrollbar_point (w, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 start_pos = sb_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 /* The end position must be strictly greater than the start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 position, at least for the Motify scrollbar. It shouldn't hurt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 anything for other scrollbar implementations. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 if (end_pos <= start_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 end_pos = start_pos + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 if (vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 new_height = WINDOW_TEXT_HEIGHT (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 new_width = scrollbar_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 new_height = scrollbar_height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 new_width = WINDOW_TEXT_WIDTH (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 /* 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
439 Motif widgets will bitch and moan. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 if (new_height <= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 new_height = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 if (new_width <= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 new_width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 assert (instance->mirror && XWINDOW (real_window(instance->mirror, 0)) == w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 /* Only character-based scrollbars are implemented at the moment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Line-based will be implemented in the future. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 instance->scrollbar_is_active = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 new_line_increment = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 new_page_increment = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_thumb_size_change, (), 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 int x_offset, y_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 /* Scrollbars are always the farthest from the text area. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 if (vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 x_offset = (f->scrollbar_on_left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ? WINDOW_LEFT (w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 : WINDOW_RIGHT (w) - scrollbar_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 y_offset = WINDOW_TEXT_TOP (w) + f->scrollbar_y_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 x_offset = WINDOW_TEXT_LEFT (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 y_offset = f->scrollbar_y_offset +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (f->scrollbar_on_top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ? WINDOW_TOP (w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 : WINDOW_TEXT_BOTTOM (w) + window_bottom_toolbar_height (w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 new_x = x_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 new_y = y_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 }
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 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (!DEVMETH_OR_GIVEN (d, inhibit_scrollbar_thumb_size_change, (), 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 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 else
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 DEFUN ("scrollbar-line-up", Fscrollbar_line_up, Sscrollbar_line_up, 1, 1, 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.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 Lisp_Object window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 window_scroll (window, make_int (1), -1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 DEFUN ("scrollbar-line-down", Fscrollbar_line_down, Sscrollbar_line_down,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 Function called when the line-down arrow on the scrollbar is clicked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 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
697 scrollbar's window. You can advise this function to change the scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 Lisp_Object window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 window_scroll (window, make_int (1), 1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 DEFUN ("scrollbar-page-up", Fscrollbar_page_up, Sscrollbar_page_up,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 Function called when the user gives the \"page-up\" scrollbar action.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (The way this is done can vary from scrollbar to scrollbar.) One argument,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 a cons containing the scrollbar's window and a value (#### document me!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 This value is nil for Motif/Lucid scrollbars and a number for Athena
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 scrollbars). You can advise this function to change the scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 Lisp_Object window = Fcar (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 /* Motif and Athena scrollbars behave differently, but in accordance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 with their standard behaviors. It is not possible to hide the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 differences down in lwlib because knowledge of XEmacs buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 cursor motion routines is necessary. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 window_scroll (window, Qnil, -1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 #else /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 Bufpos bufpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 Lisp_Object value = Fcdr (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 Fmove_to_window_line (Qzero, window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 /* can't use Fvertical_motion() because it moves the buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 rather than the window's point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 #### It does? Why does it take a window argument then? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 bufpos = vmotion (XWINDOW (window), XINT (Fwindow_point (window)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 XINT (value), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 Fset_window_point (window, make_int (bufpos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 Frecenter (Qzero, window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 #endif /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 DEFUN ("scrollbar-page-down", Fscrollbar_page_down, Sscrollbar_page_down,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 Function called when the user gives the \"page-down\" scrollbar action.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (The way this is done can vary from scrollbar to scrollbar.) One argument,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 a cons containing the scrollbar's window and a value (#### document me!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 This value is nil for Motif/Lucid scrollbars and a number for Athena
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 scrollbars). You can advise this function to change the scrollbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 Lisp_Object window = Fcar (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 /* Motif and Athena scrollbars behave differently, but in accordance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 with their standard behaviors. It is not possible to hide the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 differences down in lwlib because knowledge of XEmacs buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 cursor motion routines is necessary. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 window_scroll (window, Qnil, 1, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 #else /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 Lisp_Object value = Fcdr (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 Fmove_to_window_line (value, window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 Frecenter (Qzero, window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 #endif /* Athena */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 DEFUN ("scrollbar-to-top", Fscrollbar_to_top, Sscrollbar_to_top,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 Function called when the user gives the \"to-top\" scrollbar action.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (The way this is done can vary from scrollbar to scrollbar.). One argument,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 the scrollbar's window. You can advise this function to change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 scrollbar behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 Lisp_Object window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 Lisp_Object orig_pt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 orig_pt = Fwindow_point (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 Fset_window_point (window, Fpoint_min (Fwindow_buffer (window)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 Frecenter (Qzero, window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 scrollbar_reset_cursor (window, orig_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 DEFUN ("scrollbar-to-bottom", Fscrollbar_to_bottom, Sscrollbar_to_bottom,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 Function called when the user gives the \"to-bottom\" scrollbar action.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (The way this is done can vary from scrollbar to scrollbar.). One argument,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 the scrollbar's window. You can advise this function to change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 scrollbar behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 Lisp_Object window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 Lisp_Object orig_pt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 orig_pt = Fwindow_point (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 Fset_window_point (window, Fpoint_max (Fwindow_buffer (window)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 Frecenter (Qzero, window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 scrollbar_reset_cursor (window, orig_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 DEFUN ("scrollbar-vertical-drag", Fscrollbar_vertical_drag,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 Sscrollbar_vertical_drag, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 Function called when the user drags the vertical scrollbar thumb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 One argument, a cons containing the scrollbar's window and a value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (#### document me!). You can advise this function to change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 scrollbar behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 Bufpos start_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 Lisp_Object orig_pt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 Lisp_Object window = Fcar (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 Lisp_Object value = Fcdr (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 orig_pt = Fwindow_point (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 Fset_marker (XWINDOW (window)->sb_point, value, Fwindow_buffer (window));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 start_pos = scrollbar_point (XWINDOW (window), 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 Fset_window_start (window, make_int (start_pos), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 scrollbar_reset_cursor (window, orig_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 zmacs_region_stays = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 DEFUN ("scrollbar-set-hscroll", Fscrollbar_set_hscroll, Sscrollbar_set_hscroll,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 2, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 Sets WINDOW's hscroll position to VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 This ensures that VALUE is in the proper range for the horizontal scrollbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (window, value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 Lisp_Object window, value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 struct window *w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 int hscroll, wcw, max_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 CHECK_LIVE_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 if (!EQ (value, Qmax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 w = XWINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 wcw = window_char_width (w, 0) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 max_len = w->max_line_len + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 if (EQ (value, Qmax) || (XINT (value) > (max_len - wcw)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 hscroll = max_len - wcw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 hscroll = XINT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 /* Can't allow this out of set-window-hscroll's acceptable range. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 if (hscroll < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 hscroll = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 else if (hscroll >= (1 << (SHORTBITS - 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 hscroll = (1 << (SHORTBITS - 1)) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 if (hscroll != w->hscroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 Fset_window_hscroll (window, make_int (hscroll));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 syms_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 defsymbol (&Qscrollbar_line_up, "scrollbar-line-up");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 defsymbol (&Qscrollbar_line_down, "scrollbar-line-down");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 defsymbol (&Qscrollbar_page_up, "scrollbar-page-up");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 defsymbol (&Qscrollbar_page_down, "scrollbar-page-down");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 defsymbol (&Qscrollbar_to_top, "scrollbar-to-top");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 defsymbol (&Qscrollbar_to_bottom, "scrollbar-to-bottom");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 defsymbol (&Qscrollbar_vertical_drag, "scrollbar-vertical-drag");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 defsymbol (&Qscrollbar_char_left, "scrollbar-char-left");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 defsymbol (&Qscrollbar_char_right, "scrollbar-char-right");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 defsymbol (&Qscrollbar_page_left, "scrollbar-page-left");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 defsymbol (&Qscrollbar_page_right, "scrollbar-page-right");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 defsymbol (&Qscrollbar_to_left, "scrollbar-to-left");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 defsymbol (&Qscrollbar_to_right, "scrollbar-to-right");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 defsymbol (&Qscrollbar_horizontal_drag, "scrollbar-horizontal-drag");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 defsymbol (&Qinit_scrollbar_from_resources, "init-scrollbar-from-resources");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 /* #### All these functions should be moved into Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 See comment above. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 defsubr (&Sscrollbar_line_up);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 defsubr (&Sscrollbar_line_down);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 defsubr (&Sscrollbar_page_up);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 defsubr (&Sscrollbar_page_down);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 defsubr (&Sscrollbar_to_top);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 defsubr (&Sscrollbar_to_bottom);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 defsubr (&Sscrollbar_vertical_drag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 defsubr (&Sscrollbar_set_hscroll);
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 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 vars_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 DEFVAR_LISP ("scrollbar-pointer-glyph", &Vscrollbar_pointer_glyph /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 *The shape of the mouse-pointer when over a scrollbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 This is a glyph; use `set-glyph-image' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 If unspecified in a particular domain, the window-system-provided
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 default pointer is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 Fprovide (intern ("scrollbar"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 specifier_vars_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 DEFVAR_SPECIFIER ("scrollbar-width", &Vscrollbar_width /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 *Width of vertical scrollbars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 This is a specifier; use `set-specifier' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 Vscrollbar_width = Fmake_specifier (Qnatnum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 set_specifier_fallback
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (Vscrollbar_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_WIDTH))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 set_specifier_caching (Vscrollbar_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 slot_offset (struct window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 scrollbar_width),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 some_window_value_changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 slot_offset (struct frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 scrollbar_width),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 scrollbar_width_changed_in_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 DEFVAR_SPECIFIER ("scrollbar-height", &Vscrollbar_height /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 *Height of horizontal scrollbars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 This is a specifier; use `set-specifier' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 Vscrollbar_height = Fmake_specifier (Qnatnum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 set_specifier_fallback
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (Vscrollbar_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 list1 (Fcons (Qnil, make_int (DEFAULT_SCROLLBAR_HEIGHT))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 set_specifier_caching (Vscrollbar_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 slot_offset (struct window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 scrollbar_height),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 some_window_value_changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 slot_offset (struct frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 scrollbar_height),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 scrollbar_height_changed_in_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 complex_vars_of_scrollbar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 Vscrollbar_pointer_glyph = Fmake_glyph_internal (Qpointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 set_specifier_caching (XGLYPH (Vscrollbar_pointer_glyph)->image,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 slot_offset (struct window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 scrollbar_pointer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 scrollbar_pointer_changed_in_window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 }