annotate src/scrollbar-msw.c @ 388:aabb7f5b1c81 r21-2-9

Import from CVS: tag r21-2-9
author cvs
date Mon, 13 Aug 2007 11:09:42 +0200
parents 8626e4521993
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
1 /* scrollbar implementation -- mswindows interface.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 375
diff changeset
3 Copyright (C) 1994 Amdahl Corporation.
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
5 Copyright (C) 1995 Darrell Kindred <dkindred+@cmu.edu>.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
6
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
7 This file is part of XEmacs.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
8
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
12 later version.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
13
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
17 for more details.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
18
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
23
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
25
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
26 #include <config.h>
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
27 #include "lisp.h"
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
28
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
29 #include "console-msw.h"
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
30 #include "events.h"
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
31 #include "frame.h"
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
32 #include "scrollbar-msw.h"
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
33 #include "scrollbar.h"
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
34 #include "specifier.h"
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
35 #include "window.h"
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
36
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
37 /* We use a similar sort of vertical scrollbar drag hack for mswindows
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
38 * scrollbars as is used for Motif or Lucid scrollbars under X.
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
39 * We do character-based instead of line-based scrolling, which can mean that
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
40 * without the hack it is impossible to drag to the end of a buffer. */
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
41 #define VERTICAL_SCROLLBAR_DRAG_HACK
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
42
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
43 static int vertical_drag_in_progress = 0;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
44
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
45 static void
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
46 mswindows_create_scrollbar_instance (struct frame *f, int vertical,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
47 struct scrollbar_instance *sb)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
48 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
49 int orientation;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
50
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
51 sb->scrollbar_data = xnew_and_zero (struct mswindows_scrollbar_data);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
52
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
53 if (vertical)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
54 orientation = SBS_VERT;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
55 else
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
56 orientation = SBS_HORZ;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
57
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
58 SCROLLBAR_MSW_HANDLE (sb) =
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
59 CreateWindowEx(0, "SCROLLBAR", 0, orientation|WS_CHILD,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
60 CW_USEDEFAULT, CW_USEDEFAULT,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
61 CW_USEDEFAULT, CW_USEDEFAULT,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
62 FRAME_MSWINDOWS_HANDLE (f),
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
63 NULL, NULL, NULL);
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
64 SCROLLBAR_MSW_INFO (sb).cbSize = sizeof(SCROLLINFO);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
65 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
66 GetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
67 &SCROLLBAR_MSW_INFO (sb));
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
68 SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
69
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
70 #if 0
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
71 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
72 HWND h = SCROLLBAR_MSW_HANDLE (sb);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
73 int x = SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
74 int y = GetLastError();
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
75 struct scrollbar_instance *z = (struct scrollbar_instance *)GetWindowLong (SCROLLBAR_MSW_HANDLE(sb),
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
76 GWL_USERDATA);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
77 *z = *z;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
78 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
79 #endif
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
80 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
81
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
82 static void
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
83 mswindows_free_scrollbar_instance (struct scrollbar_instance *sb)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
84 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
85 DestroyWindow (SCROLLBAR_MSW_HANDLE (sb));
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
86 if (sb->scrollbar_data)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
87 xfree (sb->scrollbar_data);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
88 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
89
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
90 static void
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
91 mswindows_release_scrollbar_instance (struct scrollbar_instance *sb)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
92 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
93 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, 0);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
94 SCROLLBAR_MSW_SIZE (sb) = 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
95 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
96
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
97 #define UPDATE_POS_FIELD(field) \
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
98 if (new_##field >= 0 && SCROLLBAR_MSW_DATA (sb)->field != new_##field) { \
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
99 SCROLLBAR_MSW_DATA (sb)->field = new_##field; \
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
100 pos_changed = 1; \
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
101 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
102
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
103 static void
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
104 mswindows_update_scrollbar_instance_values (struct window *w,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
105 struct scrollbar_instance *sb,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
106 int new_line_increment,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
107 int new_page_increment,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
108 int new_minimum, int new_maximum,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
109 int new_slider_size,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
110 int new_slider_position,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
111 int new_scrollbar_width,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
112 int new_scrollbar_height,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
113 int new_scrollbar_x,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
114 int new_scrollbar_y)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
115 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
116 int pos_changed = 0;
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
117 int vert = GetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_STYLE) & SBS_VERT;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
118
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
119 #if 0
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
120 stderr_out ("[%d, %d], page = %d, pos = %d, inhibit = %d\n", new_minimum, new_maximum,
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
121 new_slider_size, new_slider_position,inhibit_slider_size_change);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
122 #endif
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
123
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
124 /* These might be optimized, but since at least one will change at each
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
125 call, it's probably not worth it. */
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
126 SCROLLBAR_MSW_INFO (sb).nMin = new_minimum;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
127 SCROLLBAR_MSW_INFO (sb).nMax = new_maximum;
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
128 SCROLLBAR_MSW_INFO (sb).nPage = new_slider_size + 1; /* +1 for DISABLENOSCROLL */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
129 SCROLLBAR_MSW_INFO (sb).nPos = new_slider_position;
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
130 #ifndef VERTICAL_SCROLLBAR_DRAG_HACK
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
131 SCROLLBAR_MSW_INFO (sb).fMask = ((vert && vertical_drag_in_progress)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
132 ? SIF_RANGE | SIF_POS
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
133 : SIF_ALL | SIF_DISABLENOSCROLL);
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
134 #else
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
135 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL | SIF_DISABLENOSCROLL;
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
136
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
137 /* Ignore XEmacs' requests to update the thumb position and size; they don't
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
138 * bear any relation to reality because we're reporting made-up positions */
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
139 if (!(vert && vertical_drag_in_progress))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
140 #endif
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
141 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb),
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
142 TRUE);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
143
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
144 UPDATE_POS_FIELD (scrollbar_x);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
145 UPDATE_POS_FIELD (scrollbar_y);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
146 UPDATE_POS_FIELD (scrollbar_width);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
147 UPDATE_POS_FIELD (scrollbar_height);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
148
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
149 if (pos_changed)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
150 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
151 MoveWindow(SCROLLBAR_MSW_HANDLE (sb),
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
152 new_scrollbar_x, new_scrollbar_y,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
153 new_scrollbar_width, new_scrollbar_height,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
154 TRUE);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
155 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
156 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
157
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
158 static void
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
159 mswindows_update_scrollbar_instance_status (struct window *w,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
160 int active, int size,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
161 struct scrollbar_instance *sb)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
162 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
163 if (SCROLLBAR_MSW_SIZE (sb) != size)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
164 {
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
165 SCROLLBAR_MSW_SIZE (sb) = size;
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
166 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
167 SCROLLBAR_MSW_SIZE (sb));
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
168 SCROLLBAR_MSW_INFO(sb).fMask |= SIF_DISABLENOSCROLL;
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
169 SetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb), TRUE);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 249
diff changeset
170 }
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
171 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
172
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
173 void
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
174 mswindows_handle_scrollbar_event (HWND hwnd, int code, int pos)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
175 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
176 struct frame *f;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
177 Lisp_Object win, frame;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
178 struct scrollbar_instance *sb;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
179 SCROLLINFO scrollinfo;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
180 int vert = GetWindowLong (hwnd, GWL_STYLE) & SBS_VERT;
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
181 int value;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
182
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
183 sb = (struct scrollbar_instance *)GetWindowLong (hwnd, GWL_USERDATA);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
184 win = real_window (sb->mirror, 1);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
185 frame = XWINDOW (win)->frame;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
186 f = XFRAME (frame);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
187
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
188 /* SB_LINEDOWN == SB_CHARLEFT etc. This is the way they will
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
189 always be - any Windows is binary compatible backward with
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
190 old programs */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
191
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
192 switch (code)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
193 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
194 case SB_LINEDOWN:
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
195 mswindows_enqueue_misc_user_event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
196 (frame, vert ? Qscrollbar_line_down : Qscrollbar_char_right, win);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
197 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
198
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
199 case SB_LINEUP:
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
200 mswindows_enqueue_misc_user_event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
201 (frame, vert ? Qscrollbar_line_up : Qscrollbar_char_left, win);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
202 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
203
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
204 case SB_PAGEDOWN:
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
205 mswindows_enqueue_misc_user_event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
206 (win, vert ? Qscrollbar_page_down : Qscrollbar_page_right,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
207 vert ? Fcons (win, Qnil) : win);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
208 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
209
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
210 case SB_PAGEUP:
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
211 mswindows_enqueue_misc_user_event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
212 (frame,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
213 vert ? Qscrollbar_page_up : Qscrollbar_page_left,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
214 vert ? Fcons (win, Qnil) : win);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
215 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
216
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
217 case SB_BOTTOM:
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
218 mswindows_enqueue_misc_user_event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
219 (frame, vert ? Qscrollbar_to_bottom : Qscrollbar_to_right, win);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
220 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
221
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
222 case SB_TOP:
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
223 mswindows_enqueue_misc_user_event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
224 (frame, vert ? Qscrollbar_to_top : Qscrollbar_to_left, win);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
225 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
226
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
227 case SB_THUMBTRACK:
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
228 case SB_THUMBPOSITION:
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
229 scrollinfo.cbSize = sizeof(SCROLLINFO);
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
230 scrollinfo.fMask = SIF_ALL;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
231 GetScrollInfo (hwnd, SB_CTL, &scrollinfo);
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
232 vertical_drag_in_progress = vert;
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
233 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
234 if (vert && (scrollinfo.nTrackPos > scrollinfo.nPos))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
235 /* new buffer position =
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
236 * buffer position at start of drag +
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
237 * ((text remaining in buffer at start of drag) *
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
238 * (amount that the thumb has been moved) /
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
239 * (space that remained past end of the thumb at start of drag)) */
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
240 value = (int)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
241 (scrollinfo.nPos
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
242 + (((double)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
243 (scrollinfo.nMax - scrollinfo.nPos)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
244 * (scrollinfo.nTrackPos - scrollinfo.nPos))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
245 / (scrollinfo.nMax - scrollinfo.nPage - scrollinfo.nPos)))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
246 - 2; /* ensure that the last line doesn't disappear off screen */
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
247 else
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
248 #endif
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
249 value = scrollinfo.nTrackPos;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
250 mswindows_enqueue_misc_user_event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
251 (frame,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
252 vert ? Qscrollbar_vertical_drag : Qscrollbar_horizontal_drag,
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
253 Fcons (win, make_int (value)));
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
254 break;
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
255
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
256 case SB_ENDSCROLL:
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
257 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
258 if (vertical_drag_in_progress)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
259 /* User has just dropped the thumb - finally update it */
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
260 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
261 &SCROLLBAR_MSW_INFO (sb), TRUE);
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
262 #endif
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 371
diff changeset
263 vertical_drag_in_progress = 0;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
264 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
265 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
266 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
267
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
268 #ifdef MEMORY_USAGE_STATS
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
269
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
270 static int
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
271 mswindows_compute_scrollbar_instance_usage (struct device *d,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
272 struct scrollbar_instance *inst,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
273 struct overhead_stats *ovstats)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
274 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
275 int total = 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
276
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
277 while (inst)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
278 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
279 struct mswindows_scrollbar_data *data =
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
280 (struct mswindows_scrollbar_data *) inst->scrollbar_data;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
281
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
282 total += malloced_storage_size (data, sizeof (*data), ovstats);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
283 inst = inst->next;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
284 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
285
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
286 return total;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
287 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
288
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
289 #endif /* MEMORY_USAGE_STATS */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
290
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
291 /************************************************************************/
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
292 /* Device-specific ghost specifiers initialization */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
293 /************************************************************************/
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
294
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
295 DEFUN ("mswindows-init-scrollbar-metrics", Fmswindows_init_scrollbar_metrics, 1, 1, 0, /*
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
296 */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
297 (locale))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
298 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
299 if (DEVICEP (locale))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
300 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
301 add_spec_to_ghost_specifier (Vscrollbar_width,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
302 make_int (GetSystemMetrics (SM_CXVSCROLL)),
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
303 locale, Qmswindows, Qnil);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
304 add_spec_to_ghost_specifier (Vscrollbar_height,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
305 make_int (GetSystemMetrics (SM_CYHSCROLL)),
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
306 locale, Qmswindows, Qnil);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
307 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
308 return Qnil;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
309 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
310
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
311
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
312 /************************************************************************/
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
313 /* initialization */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
314 /************************************************************************/
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
315
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
316 void
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
317 console_type_create_scrollbar_mswindows (void)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
318 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
319 CONSOLE_HAS_METHOD (mswindows, create_scrollbar_instance);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
320 CONSOLE_HAS_METHOD (mswindows, free_scrollbar_instance);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
321 CONSOLE_HAS_METHOD (mswindows, release_scrollbar_instance);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
322 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_values);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
323 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_status);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
324 /* CONSOLE_HAS_METHOD (mswindows, scrollbar_width_changed_in_frame); */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
325 #ifdef MEMORY_USAGE_STATS
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
326 CONSOLE_HAS_METHOD (mswindows, compute_scrollbar_instance_usage);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
327 #endif
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
328 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
329
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
330 void
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
331 syms_of_scrollbar_mswindows(void)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
332 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
333 DEFSUBR (Fmswindows_init_scrollbar_metrics);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
334 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
335
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 269
diff changeset
336 void
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
337 vars_of_scrollbar_mswindows(void)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
338 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
339 Fprovide (intern ("mswindows-scrollbars"));
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
340 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents:
diff changeset
341