annotate src/scrollbar-msw.c @ 737:6415e2b73e04

[xemacs-hg @ 2002-02-02 01:53:07 by youngs] 2002-02-01 Steve Youngs <youngs@xemacs.org> * xemacs/packages.texi (Removing Packages): The interactive function is 'package-get-delete-package'.
author youngs
date Sat, 02 Feb 2002 01:53:09 +0000
parents a307f9a2021d
children 943eaba38521
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>.
664
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
6 Copyright (C) 2001 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 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
12 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 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
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "console-msw.h"
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
31 #include "elhash.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "events.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "frame.h"
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
34 #include "opaque.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "scrollbar-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "scrollbar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "specifier.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 /* We use a similar sort of vertical scrollbar drag hack for mswindows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 * scrollbars as is used for Motif or Lucid scrollbars under X.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 * 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
43 * 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
44 #define VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 static int vertical_drag_in_progress = 0;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
47 extern Lisp_Object mswindows_find_frame (HWND hwnd);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
49 /* As long as the HWND is around, the scrollbar instance must be GC-protected.
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
50 We have gotten crashes, apparently from trying to access a dead, freed
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
51 frame inside of a window mirror pointed to by the scrollbar structure. */
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
52 static Lisp_Object Vmswindows_scrollbar_instance_table;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
53
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 mswindows_create_scrollbar_instance (struct frame *f, int vertical,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 struct scrollbar_instance *sb)
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 int orientation;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
59 Lisp_Object ptr;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
60
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 sb->scrollbar_data = xnew_and_zero (struct mswindows_scrollbar_data);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
62
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 if (vertical)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 orientation = SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 orientation = SBS_HORZ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
67
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 SCROLLBAR_MSW_HANDLE (sb) =
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
69 CreateWindowEx (0, "SCROLLBAR", 0, orientation|WS_CHILD,
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
70 CW_USEDEFAULT, CW_USEDEFAULT,
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
71 CW_USEDEFAULT, CW_USEDEFAULT,
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
72 FRAME_MSWINDOWS_HANDLE (f),
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
73 NULL, NULL, NULL);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
74 SCROLLBAR_MSW_INFO (sb).cbSize = sizeof (SCROLLINFO);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
76 GetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
77 &SCROLLBAR_MSW_INFO (sb));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
78 ptr = make_opaque_ptr (SCROLLBAR_MSW_HANDLE (sb));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
79 Fputhash (ptr, wrap_scrollbar_instance (sb),
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
80 Vmswindows_scrollbar_instance_table);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
81 SetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
82 (LONG) LISP_TO_VOID (ptr));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 mswindows_free_scrollbar_instance (struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
88 void *opaque =
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
89 (void *) GetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
90 Lisp_Object ptr;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
91
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
92 VOID_TO_LISP (ptr, opaque);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
93 assert (OPAQUE_PTRP (ptr));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
94 ptr = Fremhash (ptr, Vmswindows_scrollbar_instance_table);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
95 assert (!NILP (ptr));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 DestroyWindow (SCROLLBAR_MSW_HANDLE (sb));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
97 if (sb->scrollbar_data)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 xfree (sb->scrollbar_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 static void
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
102 unshow_that_mofo (void *handle)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
103 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
104 ShowScrollBar ((HWND) handle, SB_CTL, 0);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
105 }
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
106
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
107 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 mswindows_release_scrollbar_instance (struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 {
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
110 if (gc_in_progress)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
111 /* #### way bogus! need to remove the offending call.
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
112 see mark_redisplay(). */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
113 register_post_gc_action (unshow_that_mofo,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
114 (void *) SCROLLBAR_MSW_HANDLE (sb));
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
115 else
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
116 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 SCROLLBAR_MSW_SIZE (sb) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 }
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 #define UPDATE_POS_FIELD(field) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 if (new_##field >= 0 && SCROLLBAR_MSW_DATA (sb)->field != new_##field) { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 SCROLLBAR_MSW_DATA (sb)->field = new_##field; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 pos_changed = 1; \
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 mswindows_update_scrollbar_instance_values (struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 struct scrollbar_instance *sb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 int new_line_increment,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 int new_page_increment,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 int new_minimum, int new_maximum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 int new_slider_size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 int new_slider_position,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 int new_scrollbar_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 int new_scrollbar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 int new_scrollbar_x,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 int new_scrollbar_y)
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 int pos_changed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 int vert = GetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_STYLE) & SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 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
144 new_slider_size, new_slider_position,inhibit_slider_size_change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 /* 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
148 call, it's probably not worth it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 SCROLLBAR_MSW_INFO (sb).nMin = new_minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 SCROLLBAR_MSW_INFO (sb).nMax = new_maximum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 SCROLLBAR_MSW_INFO (sb).nPage = new_slider_size + 1; /* +1 for DISABLENOSCROLL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 SCROLLBAR_MSW_INFO (sb).nPos = new_slider_position;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 #ifndef VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 SCROLLBAR_MSW_INFO (sb).fMask = ((vert && vertical_drag_in_progress)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 ? SIF_RANGE | SIF_POS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 : SIF_ALL | SIF_DISABLENOSCROLL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL | SIF_DISABLENOSCROLL;
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 /* 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
161 * bear any relation to reality because we're reporting made-up positions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 if (!(vert && vertical_drag_in_progress))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 UPDATE_POS_FIELD (scrollbar_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 UPDATE_POS_FIELD (scrollbar_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 UPDATE_POS_FIELD (scrollbar_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 UPDATE_POS_FIELD (scrollbar_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
172 if (pos_changed)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
174 MoveWindow (SCROLLBAR_MSW_HANDLE (sb),
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
175 new_scrollbar_x, new_scrollbar_y,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
176 new_scrollbar_width, new_scrollbar_height,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
177 TRUE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 mswindows_update_scrollbar_instance_status (struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 int active, int size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 if (SCROLLBAR_MSW_SIZE (sb) != size)
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 SCROLLBAR_MSW_SIZE (sb) = size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 SCROLLBAR_MSW_SIZE (sb));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 SCROLLBAR_MSW_INFO(sb).fMask |= SIF_DISABLENOSCROLL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 SetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb), TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 mswindows_handle_scrollbar_event (HWND hwnd, int code, int pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 struct frame *f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 Lisp_Object win, frame;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
201 struct scrollbar_instance *sb = 0;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
202 void *v;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 SCROLLINFO scrollinfo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 int vert = GetWindowLong (hwnd, GWL_STYLE) & SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 int value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
207 v = (void *) GetWindowLong (hwnd, GWL_USERDATA);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
208 if (!v)
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
209 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
210 /* apparently this can happen, as it was definitely necessary
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
211 to put the check in for sb below (VERTICAL_SCROLLBAR_DRAG_HACK) */
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
212 frame = mswindows_find_frame (hwnd);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
213 f = XFRAME (frame);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
214 win = FRAME_SELECTED_WINDOW (f);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
215 }
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
216 else
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
217 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
218 Lisp_Object ptr;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
219 VOID_TO_LISP (ptr, v);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
220 assert (OPAQUE_PTRP (ptr));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
221 ptr = Fgethash (ptr, Vmswindows_scrollbar_instance_table, Qnil);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
222 sb = XSCROLLBAR_INSTANCE (ptr);
664
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
223 /* #### we're still hitting an abort here with 0 as the second
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
224 parameter, although only occasionally. It seems that sometimes we
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
225 receive events for scrollbars that don't exist anymore. I assume
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
226 it must happen like this: The user does something that causes a
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
227 scrollbar to disappear (e.g. Alt-TAB, causing recomputation of
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
228 everything in the new frame) and then immediately uses the mouse
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
229 wheel, generating scrollbar events. Both events get posted before
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
230 we have a chance to process them, and in processing the first, the
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
231 scrollbar mentioned in the second disappears. */
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
232 win = real_window (sb->mirror, 1);
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
233 if (NILP (win))
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
234 return;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
235 frame = WINDOW_FRAME (XWINDOW (win));
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
236 f = XFRAME (frame);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
237 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
239 /* SB_LINEDOWN == SB_CHARLEFT etc. This is the way they will
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
240 always be - any Windows is binary compatible backward with
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
241 old programs */
428
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 switch (code)
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 case SB_LINEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 (frame, vert ? Qscrollbar_line_down : Qscrollbar_char_right, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
249
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 case SB_LINEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 (frame, vert ? Qscrollbar_line_up : Qscrollbar_char_left, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
254
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 case SB_PAGEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 (win, vert ? Qscrollbar_page_down : Qscrollbar_page_right,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 vert ? Fcons (win, Qnil) : win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 case SB_PAGEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 vert ? Qscrollbar_page_up : Qscrollbar_page_left,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 vert ? Fcons (win, Qnil) : win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
267
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 case SB_BOTTOM:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 (frame, vert ? Qscrollbar_to_bottom : Qscrollbar_to_right, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 case SB_TOP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 (frame, vert ? Qscrollbar_to_top : Qscrollbar_to_left, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 break;
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 case SB_THUMBTRACK:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 case SB_THUMBPOSITION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 scrollinfo.cbSize = sizeof(SCROLLINFO);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 scrollinfo.fMask = SIF_ALL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 GetScrollInfo (hwnd, SB_CTL, &scrollinfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 vertical_drag_in_progress = vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 if (vert && (scrollinfo.nTrackPos > scrollinfo.nPos))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 /* new buffer position =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 * buffer position at start of drag +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 * ((text remaining in buffer at start of drag) *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 * (amount that the thumb has been moved) /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 * (space that remained past end of the thumb at start of drag)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 value = (int)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (scrollinfo.nPos
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 + (((double)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (scrollinfo.nMax - scrollinfo.nPos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 * (scrollinfo.nTrackPos - scrollinfo.nPos))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 / (scrollinfo.nMax - scrollinfo.nPage - scrollinfo.nPos)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 - 2; /* ensure that the last line doesn't disappear off screen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 value = scrollinfo.nTrackPos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 (frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 vert ? Qscrollbar_vertical_drag : Qscrollbar_horizontal_drag,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 Fcons (win, make_int (value)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 case SB_ENDSCROLL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
309 if (vertical_drag_in_progress && sb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 /* User has just dropped the thumb - finally update it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 &SCROLLBAR_MSW_INFO (sb), TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 vertical_drag_in_progress = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 break;
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 }
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 static int
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
320 can_scroll (struct scrollbar_instance* scrollbar)
428
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 return scrollbar != NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 && IsWindowVisible (SCROLLBAR_MSW_HANDLE (scrollbar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 && IsWindowEnabled (SCROLLBAR_MSW_HANDLE (scrollbar));
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 int
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
328 mswindows_handle_mousewheel_event (Lisp_Object frame, int keys, int delta,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
329 POINTS where)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
331 int hasVertBar, hasHorzBar; /* Indicates presence of scroll bars */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
333 Lisp_Object win, corpore, sano;
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
334 struct window_mirror *mirror;
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
335 int mene, _mene, tekel, upharsin;
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
336 Charbpos mens, sana;
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
337 Charcount in;
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
338 struct window *needle_in_haystack = 0;
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
339 POINT donde_esta;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
341 donde_esta.x = where.x;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
342 donde_esta.y = where.y;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
343
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
344 /* Find the window to scroll */
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
345
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
346 /* The mouse event could actually occur outside of the emacs
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
347 frame. */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
348 if (ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
349 &donde_esta) != 0)
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
350 {
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
351 /* stderr_out ("donde_esta: %d %d\n", donde_esta.x, donde_esta.y); */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
352 pixel_to_glyph_translation (XFRAME (frame), donde_esta.x, donde_esta.y,
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
353 &mene, &_mene, &tekel, &upharsin,
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
354 &needle_in_haystack,
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
355 &mens, &sana, &in, &corpore, &sano);
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
356
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
357 if (needle_in_haystack)
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
358 {
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
359 XSETWINDOW (win, needle_in_haystack);
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
360 /* stderr_out ("found needle\n");
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
361 debug_print (win); */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
362 }
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
363 }
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
364
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
365 if (!needle_in_haystack)
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
366 {
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
367 win = FRAME_SELECTED_WINDOW (XFRAME (frame));
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
368 needle_in_haystack = XWINDOW (win);
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
369 }
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
370
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
371 mirror = find_window_mirror (needle_in_haystack);
428
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 /* Check that there is something to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 hasVertBar = can_scroll (mirror->scrollbar_vertical_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 hasHorzBar = can_scroll (mirror->scrollbar_horizontal_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 if (!hasVertBar && !hasHorzBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 /* No support for panning and zooming, so ignore */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 if (keys & (MK_SHIFT | MK_CONTROL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 /* Get the number of lines per wheel delta */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0);
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 /* Calculate the amount to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 if (wheelScrollLines == WHEEL_PAGESCROLL)
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 /* Scroll by a page */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 Lisp_Object function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 if (hasVertBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 function = delta > 0 ? Qscrollbar_page_up : Qscrollbar_page_down;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 function = delta > 0 ? Qscrollbar_page_left : Qscrollbar_page_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 mswindows_enqueue_misc_user_event (frame, function, Fcons (win, Qnil));
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 else /* Scroll by a number of lines */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 /* Calc the number of lines to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 int toScroll = MulDiv (delta, wheelScrollLines, WHEEL_DELTA);
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 /* Do the scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 Lisp_Object function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 if (hasVertBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 function = delta > 0 ? Qscrollbar_line_up : Qscrollbar_line_down;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 function = delta > 0 ? Qscrollbar_char_left : Qscrollbar_char_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 if (toScroll < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 toScroll = -toScroll;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 while (toScroll--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 mswindows_enqueue_misc_user_event (frame, function, win);
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 return TRUE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 #ifdef MEMORY_USAGE_STATS
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 mswindows_compute_scrollbar_instance_usage (struct device *d,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 struct scrollbar_instance *inst,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 struct overhead_stats *ovstats)
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 int total = 0;
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 while (inst)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 struct mswindows_scrollbar_data *data =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 (struct mswindows_scrollbar_data *) inst->scrollbar_data;
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 total += malloced_storage_size (data, sizeof (*data), ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 inst = inst->next;
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 return total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 }
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 #endif /* MEMORY_USAGE_STATS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 /* Device-specific ghost specifiers initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
444 DEFUN ("mswindows-init-scrollbar-metrics", Fmswindows_init_scrollbar_metrics,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
445 1, 1, 0, /*
428
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 (locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 if (DEVICEP (locale))
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 add_spec_to_ghost_specifier (Vscrollbar_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 make_int (GetSystemMetrics (SM_CXVSCROLL)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 locale, Qmswindows, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 add_spec_to_ghost_specifier (Vscrollbar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 make_int (GetSystemMetrics (SM_CYHSCROLL)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 locale, Qmswindows, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 return Qnil;
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
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 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 /************************************************************************/
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 console_type_create_scrollbar_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 CONSOLE_HAS_METHOD (mswindows, create_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 CONSOLE_HAS_METHOD (mswindows, free_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 CONSOLE_HAS_METHOD (mswindows, release_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_values);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_status);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 /* CONSOLE_HAS_METHOD (mswindows, scrollbar_width_changed_in_frame); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 #ifdef MEMORY_USAGE_STATS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 CONSOLE_HAS_METHOD (mswindows, compute_scrollbar_instance_usage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 #endif
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 void
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
481 syms_of_scrollbar_mswindows (void)
428
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 DEFSUBR (Fmswindows_init_scrollbar_metrics);
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 void
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
487 vars_of_scrollbar_mswindows (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 Fprovide (intern ("mswindows-scrollbars"));
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
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
492 void
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
493 complex_vars_of_scrollbar_mswindows (void)
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
494 {
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
495 staticpro (&Vmswindows_scrollbar_instance_table);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
496 Vmswindows_scrollbar_instance_table =
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
497 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
498 }