annotate src/scrollbar-msw.c @ 665:fdefd0186b75

[xemacs-hg @ 2001-09-20 06:28:42 by ben] The great integral types renaming. The purpose of this is to rationalize the names used for various integral types, so that they match their intended uses and follow consist conventions, and eliminate types that were not semantically different from each other. The conventions are: -- All integral types that measure quantities of anything are signed. Some people disagree vociferously with this, but their arguments are mostly theoretical, and are vastly outweighed by the practical headaches of mixing signed and unsigned values, and more importantly by the far increased likelihood of inadvertent bugs: Because of the broken "viral" nature of unsigned quantities in C (operations involving mixed signed/unsigned are done unsigned, when exactly the opposite is nearly always wanted), even a single error in declaring a quantity unsigned that should be signed, or even the even more subtle error of comparing signed and unsigned values and forgetting the necessary cast, can be catastrophic, as comparisons will yield wrong results. -Wsign-compare is turned on specifically to catch this, but this tends to result in a great number of warnings when mixing signed and unsigned, and the casts are annoying. More has been written on this elsewhere. -- All such quantity types just mentioned boil down to EMACS_INT, which is 32 bits on 32-bit machines and 64 bits on 64-bit machines. This is guaranteed to be the same size as Lisp objects of type `int', and (as far as I can tell) of size_t (unsigned!) and ssize_t. The only type below that is not an EMACS_INT is Hashcode, which is an unsigned value of the same size as EMACS_INT. -- Type names should be relatively short (no more than 10 characters or so), with the first letter capitalized and no underscores if they can at all be avoided. -- "count" == a zero-based measurement of some quantity. Includes sizes, offsets, and indexes. -- "bpos" == a one-based measurement of a position in a buffer. "Charbpos" and "Bytebpos" count text in the buffer, rather than bytes in memory; thus Bytebpos does not directly correspond to the memory representation. Use "Membpos" for this. -- "Char" refers to internal-format characters, not to the C type "char", which is really a byte. -- For the actual name changes, see the script below. I ran the following script to do the conversion. (NOTE: This script is idempotent. You can safely run it multiple times and it will not screw up previous results -- in fact, it will do nothing if nothing has changed. Thus, it can be run repeatedly as necessary to handle patches coming in from old workspaces, or old branches.) There are two tags, just before and just after the change: `pre-integral-type-rename' and `post-integral-type-rename'. When merging code from the main trunk into a branch, the best thing to do is first merge up to `pre-integral-type-rename', then apply the script and associated changes, then merge from `post-integral-type-change' to the present. (Alternatively, just do the merging in one operation; but you may then have a lot of conflicts needing to be resolved by hand.) Script `fixtypes.sh' follows: ----------------------------------- cut ------------------------------------ files="*.[ch] s/*.h m/*.h config.h.in ../configure.in Makefile.in.in ../lib-src/*.[ch] ../lwlib/*.[ch]" gr Memory_Count Bytecount $files gr Lstream_Data_Count Bytecount $files gr Element_Count Elemcount $files gr Hash_Code Hashcode $files gr extcount bytecount $files gr bufpos charbpos $files gr bytind bytebpos $files gr memind membpos $files gr bufbyte intbyte $files gr Extcount Bytecount $files gr Bufpos Charbpos $files gr Bytind Bytebpos $files gr Memind Membpos $files gr Bufbyte Intbyte $files gr EXTCOUNT BYTECOUNT $files gr BUFPOS CHARBPOS $files gr BYTIND BYTEBPOS $files gr MEMIND MEMBPOS $files gr BUFBYTE INTBYTE $files gr MEMORY_COUNT BYTECOUNT $files gr LSTREAM_DATA_COUNT BYTECOUNT $files gr ELEMENT_COUNT ELEMCOUNT $files gr HASH_CODE HASHCODE $files ----------------------------------- cut ------------------------------------ `fixtypes.sh' is a Bourne-shell script; it uses 'gr': ----------------------------------- cut ------------------------------------ #!/bin/sh # Usage is like this: # gr FROM TO FILES ... # globally replace FROM with TO in FILES. FROM and TO are regular expressions. # backup files are stored in the `backup' directory. from="$1" to="$2" shift 2 echo ${1+"$@"} | xargs global-replace "s/$from/$to/g" ----------------------------------- cut ------------------------------------ `gr' in turn uses a Perl script to do its real work, `global-replace', which follows: ----------------------------------- cut ------------------------------------ : #-*- Perl -*- ### global-modify --- modify the contents of a file by a Perl expression ## Copyright (C) 1999 Martin Buchholz. ## Copyright (C) 2001 Ben Wing. ## Authors: Martin Buchholz <martin@xemacs.org>, Ben Wing <ben@xemacs.org> ## Maintainer: Ben Wing <ben@xemacs.org> ## Current Version: 1.0, May 5, 2001 # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XEmacs; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. eval 'exec perl -w -S $0 ${1+"$@"}' if 0; use strict; use FileHandle; use Carp; use Getopt::Long; use File::Basename; (my $myName = $0) =~ s@.*/@@; my $usage=" Usage: $myName [--help] [--backup-dir=DIR] [--line-mode] [--hunk-mode] PERLEXPR FILE ... Globally modify a file, either line by line or in one big hunk. Typical usage is like this: [with GNU print, GNU xargs: guaranteed to handle spaces, quotes, etc. in file names] find . -name '*.[ch]' -print0 | xargs -0 $0 's/\bCONST\b/const/g'\n [with non-GNU print, xargs] find . -name '*.[ch]' -print | xargs $0 's/\bCONST\b/const/g'\n The file is read in, either line by line (with --line-mode specified) or in one big hunk (with --hunk-mode specified; it's the default), and the Perl expression is then evalled with \$_ set to the line or hunk of text, including the terminating newline if there is one. It should destructively modify the value there, storing the changed result in \$_. Files in which any modifications are made are backed up to the directory specified using --backup-dir, or to `backup' by default. To disable this, use --backup-dir= with no argument. Hunk mode is the default because it is MUCH MUCH faster than line-by-line. Use line-by-line only when it matters, e.g. you want to do a replacement only once per line (the default without the `g' argument). Conversely, when using hunk mode, *ALWAYS* use `g'; otherwise, you will only make one replacement in the entire file! "; my %options = (); $Getopt::Long::ignorecase = 0; &GetOptions ( \%options, 'help', 'backup-dir=s', 'line-mode', 'hunk-mode', ); die $usage if $options{"help"} or @ARGV <= 1; my $code = shift; die $usage if grep (-d || ! -w, @ARGV); sub SafeOpen { open ((my $fh = new FileHandle), $_[0]); confess "Can't open $_[0]: $!" if ! defined $fh; return $fh; } sub SafeClose { close $_[0] or confess "Can't close $_[0]: $!"; } sub FileContents { my $fh = SafeOpen ("< $_[0]"); my $olddollarslash = $/; local $/ = undef; my $contents = <$fh>; $/ = $olddollarslash; return $contents; } sub WriteStringToFile { my $fh = SafeOpen ("> $_[0]"); binmode $fh; print $fh $_[1] or confess "$_[0]: $!\n"; SafeClose $fh; } foreach my $file (@ARGV) { my $changed_p = 0; my $new_contents = ""; if ($options{"line-mode"}) { my $fh = SafeOpen $file; while (<$fh>) { my $save_line = $_; eval $code; $changed_p = 1 if $save_line ne $_; $new_contents .= $_; } } else { my $orig_contents = $_ = FileContents $file; eval $code; if ($_ ne $orig_contents) { $changed_p = 1; $new_contents = $_; } } if ($changed_p) { my $backdir = $options{"backup-dir"}; $backdir = "backup" if !defined ($backdir); if ($backdir) { my ($name, $path, $suffix) = fileparse ($file, ""); my $backfulldir = $path . $backdir; my $backfile = "$backfulldir/$name"; mkdir $backfulldir, 0755 unless -d $backfulldir; print "modifying $file (original saved in $backfile)\n"; rename $file, $backfile; } WriteStringToFile ($file, $new_contents); } } ----------------------------------- cut ------------------------------------ In addition to those programs, I needed to fix up a few other things, particularly relating to the duplicate definitions of types, now that some types merged with others. Specifically: 1. in lisp.h, removed duplicate declarations of Bytecount. The changed code should now look like this: (In each code snippet below, the first and last lines are the same as the original, as are all lines outside of those lines. That allows you to locate the section to be replaced, and replace the stuff in that section, verifying that there isn't anything new added that would need to be kept.) --------------------------------- snip ------------------------------------- /* Counts of bytes or chars */ typedef EMACS_INT Bytecount; typedef EMACS_INT Charcount; /* Counts of elements */ typedef EMACS_INT Elemcount; /* Hash codes */ typedef unsigned long Hashcode; /* ------------------------ dynamic arrays ------------------- */ --------------------------------- snip ------------------------------------- 2. in lstream.h, removed duplicate declaration of Bytecount. Rewrote the comment about this type. The changed code should now look like this: --------------------------------- snip ------------------------------------- #endif /* The have been some arguments over the what the type should be that specifies a count of bytes in a data block to be written out or read in, using Lstream_read(), Lstream_write(), and related functions. Originally it was long, which worked fine; Martin "corrected" these to size_t and ssize_t on the grounds that this is theoretically cleaner and is in keeping with the C standards. Unfortunately, this practice is horribly error-prone due to design flaws in the way that mixed signed/unsigned arithmetic happens. In fact, by doing this change, Martin introduced a subtle but fatal error that caused the operation of sending large mail messages to the SMTP server under Windows to fail. By putting all values back to be signed, avoiding any signed/unsigned mixing, the bug immediately went away. The type then in use was Lstream_Data_Count, so that it be reverted cleanly if a vote came to that. Now it is Bytecount. Some earlier comments about why the type must be signed: This MUST BE SIGNED, since it also is used in functions that return the number of bytes actually read to or written from in an operation, and these functions can return -1 to signal error. Note that the standard Unix read() and write() functions define the count going in as a size_t, which is UNSIGNED, and the count going out as an ssize_t, which is SIGNED. This is a horrible design flaw. Not only is it highly likely to lead to logic errors when a -1 gets interpreted as a large positive number, but operations are bound to fail in all sorts of horrible ways when a number in the upper-half of the size_t range is passed in -- this number is unrepresentable as an ssize_t, so code that checks to see how many bytes are actually written (which is mandatory if you are dealing with certain types of devices) will get completely screwed up. --ben */ typedef enum lstream_buffering --------------------------------- snip ------------------------------------- 3. in dumper.c, there are four places, all inside of switch() statements, where XD_BYTECOUNT appears twice as a case tag. In each case, the two case blocks contain identical code, and you should *REMOVE THE SECOND* and leave the first.
author ben
date Thu, 20 Sep 2001 06:31:11 +0000
parents 6e99cc8c6ca5
children 685b588e92d8
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;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
48 /* 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
49 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
50 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
51 static Lisp_Object Vmswindows_scrollbar_instance_table;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
52
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 mswindows_create_scrollbar_instance (struct frame *f, int vertical,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 int orientation;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
58 Lisp_Object ptr;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
59
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 sb->scrollbar_data = xnew_and_zero (struct mswindows_scrollbar_data);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
61
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 if (vertical)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 orientation = SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 orientation = SBS_HORZ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
66
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 SCROLLBAR_MSW_HANDLE (sb) =
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
68 CreateWindowEx (0, "SCROLLBAR", 0, orientation|WS_CHILD,
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
69 CW_USEDEFAULT, CW_USEDEFAULT,
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 FRAME_MSWINDOWS_HANDLE (f),
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
72 NULL, NULL, NULL);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
73 SCROLLBAR_MSW_INFO (sb).cbSize = sizeof (SCROLLINFO);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
75 GetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
76 &SCROLLBAR_MSW_INFO (sb));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
77 ptr = make_opaque_ptr (SCROLLBAR_MSW_HANDLE (sb));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
78 Fputhash (ptr, wrap_scrollbar_instance (sb),
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
79 Vmswindows_scrollbar_instance_table);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
80 SetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
81 (LONG) LISP_TO_VOID (ptr));
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 mswindows_free_scrollbar_instance (struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
87 void *opaque =
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
88 (void *) GetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
89 Lisp_Object ptr;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
90
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
91 VOID_TO_LISP (ptr, opaque);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
92 assert (OPAQUE_PTRP (ptr));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
93 ptr = Fremhash (ptr, Vmswindows_scrollbar_instance_table);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
94 assert (!NILP (ptr));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 DestroyWindow (SCROLLBAR_MSW_HANDLE (sb));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
96 if (sb->scrollbar_data)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 xfree (sb->scrollbar_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 static void
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
101 unshow_that_mofo (void *handle)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
102 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
103 ShowScrollBar ((HWND) handle, SB_CTL, 0);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
104 }
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 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 mswindows_release_scrollbar_instance (struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 {
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
109 if (gc_in_progress)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
110 /* #### way bogus! need to remove the offending call.
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
111 see mark_redisplay(). */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
112 register_post_gc_action (unshow_that_mofo,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
113 (void *) SCROLLBAR_MSW_HANDLE (sb));
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
114 else
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 546
diff changeset
115 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 SCROLLBAR_MSW_SIZE (sb) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 }
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 #define UPDATE_POS_FIELD(field) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 if (new_##field >= 0 && SCROLLBAR_MSW_DATA (sb)->field != new_##field) { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 SCROLLBAR_MSW_DATA (sb)->field = new_##field; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 pos_changed = 1; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 mswindows_update_scrollbar_instance_values (struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 struct scrollbar_instance *sb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 int new_line_increment,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 int new_page_increment,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 int new_minimum, int new_maximum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 int new_slider_size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 int new_slider_position,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 int new_scrollbar_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 int new_scrollbar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 int new_scrollbar_x,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 int new_scrollbar_y)
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 int pos_changed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 int vert = GetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_STYLE) & SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 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
143 new_slider_size, new_slider_position,inhibit_slider_size_change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 /* 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
147 call, it's probably not worth it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 SCROLLBAR_MSW_INFO (sb).nMin = new_minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 SCROLLBAR_MSW_INFO (sb).nMax = new_maximum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 SCROLLBAR_MSW_INFO (sb).nPage = new_slider_size + 1; /* +1 for DISABLENOSCROLL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 SCROLLBAR_MSW_INFO (sb).nPos = new_slider_position;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 #ifndef VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 SCROLLBAR_MSW_INFO (sb).fMask = ((vert && vertical_drag_in_progress)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 ? SIF_RANGE | SIF_POS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 : SIF_ALL | SIF_DISABLENOSCROLL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL | SIF_DISABLENOSCROLL;
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 /* 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
160 * bear any relation to reality because we're reporting made-up positions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 if (!(vert && vertical_drag_in_progress))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 TRUE);
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 UPDATE_POS_FIELD (scrollbar_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 UPDATE_POS_FIELD (scrollbar_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 UPDATE_POS_FIELD (scrollbar_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 UPDATE_POS_FIELD (scrollbar_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
171 if (pos_changed)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
173 MoveWindow (SCROLLBAR_MSW_HANDLE (sb),
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
174 new_scrollbar_x, new_scrollbar_y,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
175 new_scrollbar_width, new_scrollbar_height,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
176 TRUE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 mswindows_update_scrollbar_instance_status (struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 int active, int size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 struct scrollbar_instance *sb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 if (SCROLLBAR_MSW_SIZE (sb) != size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 SCROLLBAR_MSW_SIZE (sb) = size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 SCROLLBAR_MSW_SIZE (sb));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 SCROLLBAR_MSW_INFO(sb).fMask |= SIF_DISABLENOSCROLL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 SetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb), TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 }
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 mswindows_handle_scrollbar_event (HWND hwnd, int code, int pos)
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 struct frame *f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 Lisp_Object win, frame;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
200 struct scrollbar_instance *sb = 0;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
201 void *v;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 SCROLLINFO scrollinfo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 int vert = GetWindowLong (hwnd, GWL_STYLE) & SBS_VERT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 int value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
206 v = (void *) GetWindowLong (hwnd, GWL_USERDATA);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
207 if (!v)
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
208 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
209 /* 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
210 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
211 frame = mswindows_find_frame (hwnd);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
212 f = XFRAME (frame);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
213 win = FRAME_SELECTED_WINDOW (f);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
214 }
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
215 else
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
216 {
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
217 Lisp_Object ptr;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
218 VOID_TO_LISP (ptr, v);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
219 assert (OPAQUE_PTRP (ptr));
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
220 ptr = Fgethash (ptr, Vmswindows_scrollbar_instance_table, Qnil);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
221 sb = XSCROLLBAR_INSTANCE (ptr);
664
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
222 /* #### 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 scrollbar mentioned in the second disappears. */
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
231 win = real_window (sb->mirror, 1);
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
232 if (NILP (win))
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 617
diff changeset
233 return;
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
234 frame = WINDOW_FRAME (XWINDOW (win));
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
235 f = XFRAME (frame);
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
236 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
238 /* SB_LINEDOWN == SB_CHARLEFT etc. This is the way they will
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
239 always be -- any Windows is binary compatible backward with
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
240 old programs. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 switch (code)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 case SB_LINEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 (frame, vert ? Qscrollbar_line_down : Qscrollbar_char_right, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
248
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 case SB_LINEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (frame, vert ? Qscrollbar_line_up : Qscrollbar_char_left, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
253
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 case SB_PAGEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 (win, vert ? Qscrollbar_page_down : Qscrollbar_page_right,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 vert ? Fcons (win, Qnil) : win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 case SB_PAGEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 (frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 vert ? Qscrollbar_page_up : Qscrollbar_page_left,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 vert ? Fcons (win, Qnil) : win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
266
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 case SB_BOTTOM:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 (frame, vert ? Qscrollbar_to_bottom : Qscrollbar_to_right, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 case SB_TOP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 (frame, vert ? Qscrollbar_to_top : Qscrollbar_to_left, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 break;
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 case SB_THUMBTRACK:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 case SB_THUMBPOSITION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 scrollinfo.cbSize = sizeof(SCROLLINFO);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 scrollinfo.fMask = SIF_ALL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 GetScrollInfo (hwnd, SB_CTL, &scrollinfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 vertical_drag_in_progress = vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 if (vert && (scrollinfo.nTrackPos > scrollinfo.nPos))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 /* new buffer position =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 * buffer position at start of drag +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 * ((text remaining in buffer at start of drag) *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 * (amount that the thumb has been moved) /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 * (space that remained past end of the thumb at start of drag)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 value = (int)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (scrollinfo.nPos
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 + (((double)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (scrollinfo.nMax - scrollinfo.nPos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 * (scrollinfo.nTrackPos - scrollinfo.nPos))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 / (scrollinfo.nMax - scrollinfo.nPage - scrollinfo.nPos)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 - 2; /* ensure that the last line doesn't disappear off screen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 value = scrollinfo.nTrackPos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 mswindows_enqueue_misc_user_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 vert ? Qscrollbar_vertical_drag : Qscrollbar_horizontal_drag,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 Fcons (win, make_int (value)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 case SB_ENDSCROLL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 487
diff changeset
308 if (vertical_drag_in_progress && sb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 /* User has just dropped the thumb - finally update it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 &SCROLLBAR_MSW_INFO (sb), TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 vertical_drag_in_progress = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 }
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 static int
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
319 can_scroll (struct scrollbar_instance* scrollbar)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 return scrollbar != NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 && IsWindowVisible (SCROLLBAR_MSW_HANDLE (scrollbar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 && IsWindowEnabled (SCROLLBAR_MSW_HANDLE (scrollbar));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 }
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 int
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
327 mswindows_handle_mousewheel_event (Lisp_Object frame, int keys, int delta,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
328 POINTS where)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
330 int hasVertBar, hasHorzBar; /* Indicates presence of scroll bars */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
332 Lisp_Object win;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
333 struct window_mirror *mirror;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
334 POINT donde_esta;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
336 donde_esta.x = where.x;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
337 donde_esta.y = where.y;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
338
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
339 ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), &donde_esta);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
340
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
341 /* Find the window to scroll */
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
342 {
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
343 int mene, _mene, tekel, upharsin;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 664
diff changeset
344 Charbpos mens, sana;
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
345 Charcount in;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
346 Lisp_Object corpore, sano;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
347 struct window *needle_in_haystack;
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
348
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
349 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
350 &mene, &_mene, &tekel, &upharsin,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
351 &needle_in_haystack,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
352 &mens, &sana, &in, &corpore, &sano);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
353
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
354 if (needle_in_haystack)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
355 {
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
356 XSETWINDOW (win, needle_in_haystack);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
357 }
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
358 else
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
359 {
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
360 win = FRAME_SELECTED_WINDOW (XFRAME (frame));
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
361 needle_in_haystack = XWINDOW (win);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
362 }
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
363
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
364 mirror = find_window_mirror (needle_in_haystack);
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 442
diff changeset
365 }
428
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 /* Check that there is something to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 hasVertBar = can_scroll (mirror->scrollbar_vertical_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 hasHorzBar = can_scroll (mirror->scrollbar_horizontal_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 if (!hasVertBar && !hasHorzBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 return FALSE;
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 /* No support for panning and zooming, so ignore */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 if (keys & (MK_SHIFT | MK_CONTROL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 /* Get the number of lines per wheel delta */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 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 /* Calculate the amount to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 if (wheelScrollLines == WHEEL_PAGESCROLL)
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 /* Scroll by a page */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 Lisp_Object function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 if (hasVertBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 function = delta > 0 ? Qscrollbar_page_up : Qscrollbar_page_down;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 function = delta > 0 ? Qscrollbar_page_left : Qscrollbar_page_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 mswindows_enqueue_misc_user_event (frame, function, Fcons (win, Qnil));
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 else /* Scroll by a number of lines */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 /* Calc the number of lines to scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 int toScroll = MulDiv (delta, wheelScrollLines, WHEEL_DELTA);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 /* Do the scroll */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 Lisp_Object function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 if (hasVertBar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 function = delta > 0 ? Qscrollbar_line_up : Qscrollbar_line_down;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 function = delta > 0 ? Qscrollbar_char_left : Qscrollbar_char_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 if (toScroll < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 toScroll = -toScroll;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 while (toScroll--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 mswindows_enqueue_misc_user_event (frame, function, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 }
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 #ifdef MEMORY_USAGE_STATS
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 mswindows_compute_scrollbar_instance_usage (struct device *d,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 struct scrollbar_instance *inst,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 struct overhead_stats *ovstats)
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 int total = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 while (inst)
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 struct mswindows_scrollbar_data *data =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (struct mswindows_scrollbar_data *) inst->scrollbar_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 total += malloced_storage_size (data, sizeof (*data), ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 inst = inst->next;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 return total;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 #endif /* MEMORY_USAGE_STATS */
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 /* Device-specific ghost specifiers initialization */
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
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
438 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
439 1, 1, 0, /*
428
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 (locale))
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 if (DEVICEP (locale))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 add_spec_to_ghost_specifier (Vscrollbar_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 make_int (GetSystemMetrics (SM_CXVSCROLL)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 locale, Qmswindows, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 add_spec_to_ghost_specifier (Vscrollbar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 make_int (GetSystemMetrics (SM_CYHSCROLL)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 locale, Qmswindows, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 /************************************************************************/
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 console_type_create_scrollbar_mswindows (void)
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 CONSOLE_HAS_METHOD (mswindows, create_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 CONSOLE_HAS_METHOD (mswindows, free_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 CONSOLE_HAS_METHOD (mswindows, release_scrollbar_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_values);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_status);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 /* CONSOLE_HAS_METHOD (mswindows, scrollbar_width_changed_in_frame); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 #ifdef MEMORY_USAGE_STATS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 CONSOLE_HAS_METHOD (mswindows, compute_scrollbar_instance_usage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 void
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
475 syms_of_scrollbar_mswindows (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 DEFSUBR (Fmswindows_init_scrollbar_metrics);
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 vars_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 Fprovide (intern ("mswindows-scrollbars"));
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
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
486 void
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
487 complex_vars_of_scrollbar_mswindows (void)
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
488 {
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
489 staticpro (&Vmswindows_scrollbar_instance_table);
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
490 Vmswindows_scrollbar_instance_table =
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 611
diff changeset
491 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
492 }