annotate src/scrollbar-msw.c @ 581:5c09e1d634a3

[xemacs-hg @ 2001-05-26 12:27:47 by ben] rewrite warning output so that it doesn't happen by default -- you should only get warnings when something is actively wrong, not just because a feature is not present.
author ben
date Sat, 26 May 2001 12:27:47 +0000
parents 666d73d6ac56
children 38db05db9cb5
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 /* scrollbar implementation -- mswindows interface.
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) 1994 Amdahl Corporation.
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 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "console-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "events.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "scrollbar-msw.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 "specifier.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 /* We use a similar sort of vertical scrollbar drag hack for mswindows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 * scrollbars as is used for Motif or Lucid scrollbars under X.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 * We do character-based instead of line-based scrolling, which can mean that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 * without the hack it is impossible to drag to the end of a buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #define VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 static int vertical_drag_in_progress = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 mswindows_create_scrollbar_instance (struct frame *f, int vertical,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 int orientation;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
50
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 sb->scrollbar_data = xnew_and_zero (struct mswindows_scrollbar_data);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
52
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 if (vertical)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 orientation = SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 orientation = SBS_HORZ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
57
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 SCROLLBAR_MSW_HANDLE (sb) =
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
59 CreateWindowEx (0, "SCROLLBAR", 0, orientation|WS_CHILD,
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
60 CW_USEDEFAULT, CW_USEDEFAULT,
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
61 CW_USEDEFAULT, CW_USEDEFAULT,
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
62 FRAME_MSWINDOWS_HANDLE (f),
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
63 NULL, NULL, NULL);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
64 SCROLLBAR_MSW_INFO (sb).cbSize = sizeof (SCROLLINFO);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 GetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 &SCROLLBAR_MSW_INFO (sb));
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
68 SetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA, (LONG) sb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 {
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
72 HWND h = SCROLLBAR_MSW_HANDLE (sb);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
73 int x = SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
74 int y = GetLastError();
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
75 struct scrollbar_instance *z =
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
76 (struct scrollbar_instance *)GetWindowLong (SCROLLBAR_MSW_HANDLE(sb),
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
77 GWL_USERDATA);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
78 *z = *z;
428
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 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 mswindows_free_scrollbar_instance (struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 DestroyWindow (SCROLLBAR_MSW_HANDLE (sb));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
87 if (sb->scrollbar_data)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 xfree (sb->scrollbar_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 mswindows_release_scrollbar_instance (struct scrollbar_instance *sb)
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 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 SCROLLBAR_MSW_SIZE (sb) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #define UPDATE_POS_FIELD(field) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 if (new_##field >= 0 && SCROLLBAR_MSW_DATA (sb)->field != new_##field) { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 SCROLLBAR_MSW_DATA (sb)->field = new_##field; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 pos_changed = 1; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 mswindows_update_scrollbar_instance_values (struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 struct scrollbar_instance *sb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 int new_line_increment,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 int new_page_increment,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 int new_minimum, int new_maximum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 int new_slider_size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 int new_slider_position,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 int new_scrollbar_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 int new_scrollbar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 int new_scrollbar_x,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 int new_scrollbar_y)
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 int pos_changed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 int vert = GetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_STYLE) & SBS_VERT;
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 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 stderr_out ("[%d, %d], page = %d, pos = %d, inhibit = %d\n", new_minimum, new_maximum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 new_slider_size, new_slider_position,inhibit_slider_size_change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 #endif
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 /* These might be optimized, but since at least one will change at each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 call, it's probably not worth it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 SCROLLBAR_MSW_INFO (sb).nMin = new_minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 SCROLLBAR_MSW_INFO (sb).nMax = new_maximum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 SCROLLBAR_MSW_INFO (sb).nPage = new_slider_size + 1; /* +1 for DISABLENOSCROLL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 SCROLLBAR_MSW_INFO (sb).nPos = new_slider_position;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 #ifndef VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 SCROLLBAR_MSW_INFO (sb).fMask = ((vert && vertical_drag_in_progress)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 ? SIF_RANGE | SIF_POS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 : SIF_ALL | SIF_DISABLENOSCROLL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL | SIF_DISABLENOSCROLL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 /* Ignore XEmacs' requests to update the thumb position and size; they don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 * bear any relation to reality because we're reporting made-up positions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 if (!(vert && vertical_drag_in_progress))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 TRUE);
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 UPDATE_POS_FIELD (scrollbar_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 UPDATE_POS_FIELD (scrollbar_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 UPDATE_POS_FIELD (scrollbar_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 UPDATE_POS_FIELD (scrollbar_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
150 if (pos_changed)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 MoveWindow(SCROLLBAR_MSW_HANDLE (sb),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 new_scrollbar_x, new_scrollbar_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 new_scrollbar_width, new_scrollbar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 mswindows_update_scrollbar_instance_status (struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 int active, int size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 if (SCROLLBAR_MSW_SIZE (sb) != size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 SCROLLBAR_MSW_SIZE (sb) = size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 SCROLLBAR_MSW_SIZE (sb));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 SCROLLBAR_MSW_INFO(sb).fMask |= SIF_DISABLENOSCROLL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 SetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb), TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 }
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 mswindows_handle_scrollbar_event (HWND hwnd, int code, int pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 struct frame *f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 Lisp_Object win, frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 struct scrollbar_instance *sb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 SCROLLINFO scrollinfo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 int vert = GetWindowLong (hwnd, GWL_STYLE) & SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 int value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
184 sb = (struct scrollbar_instance *) GetWindowLong (hwnd, GWL_USERDATA);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
185 if (!sb)
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
186 {
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
187 frame = mswindows_find_frame (hwnd);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
188 f = XFRAME (frame);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
189 win = FRAME_SELECTED_WINDOW (f);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
190 }
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
191 else
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
192 {
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
193 win = real_window (sb->mirror, 0);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
194 frame = XWINDOW (win)->frame;
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
195 f = XFRAME (frame);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
196 }
428
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 /* SB_LINEDOWN == SB_CHARLEFT etc. This is the way they will
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
199 always be - any Windows is binary compatible backward with
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 old programs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 switch (code)
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 case SB_LINEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (frame, vert ? Qscrollbar_line_down : Qscrollbar_char_right, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
208
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 case SB_LINEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 (frame, vert ? Qscrollbar_line_up : Qscrollbar_char_left, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
213
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 case SB_PAGEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 (win, vert ? Qscrollbar_page_down : Qscrollbar_page_right,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 vert ? Fcons (win, Qnil) : win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 break;
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 case SB_PAGEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 (frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 vert ? Qscrollbar_page_up : Qscrollbar_page_left,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 vert ? Fcons (win, Qnil) : win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
226
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 case SB_BOTTOM:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (frame, vert ? Qscrollbar_to_bottom : Qscrollbar_to_right, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 break;
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 case SB_TOP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (frame, vert ? Qscrollbar_to_top : Qscrollbar_to_left, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 case SB_THUMBTRACK:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 case SB_THUMBPOSITION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 scrollinfo.cbSize = sizeof(SCROLLINFO);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 scrollinfo.fMask = SIF_ALL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 GetScrollInfo (hwnd, SB_CTL, &scrollinfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 vertical_drag_in_progress = vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 if (vert && (scrollinfo.nTrackPos > scrollinfo.nPos))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 /* new buffer position =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 * buffer position at start of drag +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 * ((text remaining in buffer at start of drag) *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 * (amount that the thumb has been moved) /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 * (space that remained past end of the thumb at start of drag)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 value = (int)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (scrollinfo.nPos
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 + (((double)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 (scrollinfo.nMax - scrollinfo.nPos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 * (scrollinfo.nTrackPos - scrollinfo.nPos))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 / (scrollinfo.nMax - scrollinfo.nPage - scrollinfo.nPos)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 - 2; /* ensure that the last line doesn't disappear off screen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 value = scrollinfo.nTrackPos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 (frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 vert ? Qscrollbar_vertical_drag : Qscrollbar_horizontal_drag,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 Fcons (win, make_int (value)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 break;
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 case SB_ENDSCROLL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
268 if (vertical_drag_in_progress && sb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 /* User has just dropped the thumb - finally update it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 &SCROLLBAR_MSW_INFO (sb), TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 vertical_drag_in_progress = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 break;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 static int
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
279 can_scroll (struct scrollbar_instance* scrollbar)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 return scrollbar != NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 && IsWindowVisible (SCROLLBAR_MSW_HANDLE (scrollbar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 && IsWindowEnabled (SCROLLBAR_MSW_HANDLE (scrollbar));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 int
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
287 mswindows_handle_mousewheel_event (Lisp_Object frame, int keys, int delta,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
288 POINTS where)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
290 int hasVertBar, hasHorzBar; /* Indicates presence of scroll bars */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
292 Lisp_Object win;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
293 struct window_mirror *mirror;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
294 POINT donde_esta;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
296 donde_esta.x = where.x;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
297 donde_esta.y = where.y;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
298
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
299 ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), &donde_esta);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
300
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
301 /* Find the window to scroll */
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
302 {
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
303 int mene, _mene, tekel, upharsin;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
304 Bufpos mens, sana;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
305 Charcount in;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
306 Lisp_Object corpore, sano;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
307 struct window *needle_in_haystack;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
308
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
309 pixel_to_glyph_translation (XFRAME (frame), donde_esta.x, donde_esta.y,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
310 &mene, &_mene, &tekel, &upharsin,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
311 &needle_in_haystack,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
312 &mens, &sana, &in, &corpore, &sano);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
313
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
314 if (needle_in_haystack)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
315 {
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
316 XSETWINDOW (win, needle_in_haystack);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
317 }
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
318 else
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
319 {
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
320 win = FRAME_SELECTED_WINDOW (XFRAME (frame));
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
321 needle_in_haystack = XWINDOW (win);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
322 }
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
323
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
324 mirror = find_window_mirror (needle_in_haystack);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
325 }
428
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 /* Check that there is something to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 hasVertBar = can_scroll (mirror->scrollbar_vertical_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 hasHorzBar = can_scroll (mirror->scrollbar_horizontal_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 if (!hasVertBar && !hasHorzBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 /* No support for panning and zooming, so ignore */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 if (keys & (MK_SHIFT | MK_CONTROL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 return FALSE;
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 /* Get the number of lines per wheel delta */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 /* Calculate the amount to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 if (wheelScrollLines == WHEEL_PAGESCROLL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 /* Scroll by a page */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 Lisp_Object function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 if (hasVertBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 function = delta > 0 ? Qscrollbar_page_up : Qscrollbar_page_down;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 function = delta > 0 ? Qscrollbar_page_left : Qscrollbar_page_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 mswindows_enqueue_misc_user_event (frame, function, Fcons (win, Qnil));
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 else /* Scroll by a number of lines */
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 /* Calc the number of lines to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 int toScroll = MulDiv (delta, wheelScrollLines, WHEEL_DELTA);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 /* Do the scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 Lisp_Object function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 if (hasVertBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 function = delta > 0 ? Qscrollbar_line_up : Qscrollbar_line_down;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 function = delta > 0 ? Qscrollbar_char_left : Qscrollbar_char_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 if (toScroll < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 toScroll = -toScroll;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 while (toScroll--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 mswindows_enqueue_misc_user_event (frame, function, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 #ifdef MEMORY_USAGE_STATS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 mswindows_compute_scrollbar_instance_usage (struct device *d,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 struct scrollbar_instance *inst,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 struct overhead_stats *ovstats)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 int total = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 while (inst)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 struct mswindows_scrollbar_data *data =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 (struct mswindows_scrollbar_data *) inst->scrollbar_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 total += malloced_storage_size (data, sizeof (*data), ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 inst = inst->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 return total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 #endif /* MEMORY_USAGE_STATS */
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 /* Device-specific ghost specifiers initialization */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 DEFUN ("mswindows-init-scrollbar-metrics", Fmswindows_init_scrollbar_metrics, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 if (DEVICEP (locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 add_spec_to_ghost_specifier (Vscrollbar_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 make_int (GetSystemMetrics (SM_CXVSCROLL)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 locale, Qmswindows, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 add_spec_to_ghost_specifier (Vscrollbar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 make_int (GetSystemMetrics (SM_CYHSCROLL)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 locale, Qmswindows, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 /* initialization */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 console_type_create_scrollbar_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 CONSOLE_HAS_METHOD (mswindows, create_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 CONSOLE_HAS_METHOD (mswindows, free_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 CONSOLE_HAS_METHOD (mswindows, release_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_values);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_status);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 /* CONSOLE_HAS_METHOD (mswindows, scrollbar_width_changed_in_frame); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 #ifdef MEMORY_USAGE_STATS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 CONSOLE_HAS_METHOD (mswindows, compute_scrollbar_instance_usage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 syms_of_scrollbar_mswindows(void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 DEFSUBR (Fmswindows_init_scrollbar_metrics);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 vars_of_scrollbar_mswindows(void)
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 Fprovide (intern ("mswindows-scrollbars"));
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