annotate src/scrollbar.c @ 470:8a548306e08d

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