annotate src/glyphs-msw.c @ 558:ed498ef2108b

[xemacs-hg @ 2001-05-23 09:59:33 by ben] xemacs.mak: call `ver' to get the exact os version and put it in the installation; suggestion from adrian. behavior-defs.el: Add scroll-in-place, jka-compr, efs, fix up some things. pop.c: Remove BROKEN_CYGWIN. etc\sample.init.el: Rewrite to be much more careful about loading features -- now it decays gracefully even in the complete absence of packages. Also avoid doing obnoxious things when loading efs. configure.in: add some support for eventually turning on file coding by default. Fix numerous places where AC_MSG_WARN had quotes around its arg, which is bad. Replace with []. Same for AC_MSG_ERROR. s\cygwin32.h, s\mingw32.h: remove support for way old beta versions of cygwin. don't put -Wno-sign-compare in the system switches; this isn't a system issue. define BROKEN_SIGIO for cygwin to get C-g support. device-msw.c: signal an error rather than crash with an unavailable network printer (from Mike Alexander). event-msw.c: cleanup headers. fix (hopefully) an error with data corruption when sending to a network connection. fileio.c: Fix evil code that attempts to handle the ~user prefix by (a) always assuming we're referencing ourselves and not even verifying the user -- hence any file with a tilde as its first char is invalid! (b) if there wasn't a slash following the filename, the pointer was set *past* the end of file and we started reading from uninitialized memory. Now we simply treat these as files, always. optionally for 21.4 (doc fix): lread.c: cambia de pas_de_lache_ici -- al minimo usa la palabra certa. frame.c: fix warnings. emacs.c, nt.c, ntproc.c, process-nt.c, realpath.c, unexnt.c: rename MAX_PATH to standard PATH_MAX. process-nt.c, realpath.c: cleanup headers. process-unix.c, sysdep.c, systime.h, syswindows.h: kill BROKEN_CYGWIN and support for way old beta versions of cygwin. sysfile.h: use _MAX_PATH (Windows) preferentially for PATH_MAX if defined. include io.h on Cygwin (we need get_osfhandle()). include sys/fcntl.h always, since we were including it in various header files anyway. unexcw.c: fix up style to conform to standard. remove duplicate definition of PERROR. buffer.c: comment change. database.c, debug.h, device-tty.c, dired-msw.c, glyphs-msw.c: header cleanups (remove places that directly include a system header file, because we have our own layer to do this more cleanly and portably); indentation fixes.
author ben
date Wed, 23 May 2001 09:59:48 +0000
parents 7039e6323819
children 183866b06e0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* mswindows-specific glyph objects.
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2 Copyright (C) 1998, 1999, 2000 Andy Piper.
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 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
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 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
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
23 /* written by Andy Piper <andy@xemacs.org> plagiarising bits from
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 glyphs-x.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "lstream.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 #define OEMRESOURCE /* Define OCR_ and friend constants */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "console-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "glyphs-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "objects-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "elhash.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "opaque.h"
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 502
diff changeset
41 #include "sysdep.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "sysfile.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #include "imgproc.h"
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 #ifdef FILE_CODING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #include "file-coding.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #define WIDGET_GLYPH_SLOT 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 #ifdef HAVE_JPEG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #ifdef HAVE_TIFF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
61 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #ifdef HAVE_PNG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 DECLARE_IMAGE_INSTANTIATOR_FORMAT (png);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
64 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #ifdef HAVE_GIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
67 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 #ifdef HAVE_XPM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 DEFINE_DEVICE_IIFORMAT (mswindows, xpm);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
70 DEFINE_DEVICE_IIFORMAT (msprinter, xpm);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 DEFINE_DEVICE_IIFORMAT (mswindows, xbm);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
73 DEFINE_DEVICE_IIFORMAT (msprinter, xbm);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 #ifdef HAVE_XFACE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 DEFINE_DEVICE_IIFORMAT (mswindows, xface);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
76 DEFINE_DEVICE_IIFORMAT (msprinter, xface);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
78 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
79 DEFINE_DEVICE_IIFORMAT (mswindows, native_layout);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 DEFINE_DEVICE_IIFORMAT (mswindows, button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 DEFINE_DEVICE_IIFORMAT (mswindows, widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 DEFINE_DEVICE_IIFORMAT (mswindows, label);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 DEFINE_DEVICE_IIFORMAT (mswindows, combo_box);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 DEFINE_DEVICE_IIFORMAT (mswindows, progress_gauge);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 DEFINE_DEVICE_IIFORMAT (mswindows, tree_view);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 DEFINE_DEVICE_IIFORMAT (mswindows, tab_control);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 Lisp_Object Qbmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 Lisp_Object Vmswindows_bitmap_file_path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 static COLORREF transparent_color = RGB (1,1,1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 Lisp_Object Q_resource_type, Q_resource_id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 Lisp_Object Qmswindows_resource;
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
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
101 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 int slices,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 enum image_instance_type type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
105 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
106 HDC hcdc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
107
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
108 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
109 * Given device D, retrieve compatible device context. D can be either
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
110 * mswindows or an msprinter device.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
111 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
112 inline static HDC
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
113 get_device_compdc (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
114 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
115 if (DEVICE_MSWINDOWS_P (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
116 return DEVICE_MSWINDOWS_HCDC (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
117 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
118 return DEVICE_MSPRINTER_HCDC (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
119 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
120
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
121 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
122 * Initialize image instance pixel sizes in II. For a display bitmap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
123 * these will be same as real bitmap sizes. For a printer bitmap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
124 * these will be scaled up so that the bitmap is proportionally enlarged
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
125 * when output to printer. Redisplay code takes care of scaling, to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
126 * conserve memory we do not really scale bitmaps. Set the watermark
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
127 * only here.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
128 * #### Add support for unscalable bitmaps.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
129 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
130 static void init_image_instance_geometry (Lisp_Image_Instance *ii)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
131 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
132 struct device *d = DOMAIN_XDEVICE (ii->domain);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
133
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
134 if (/* #### Scaleable && */ DEVICE_MSPRINTER_P (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 HDC printer_dc = DEVICE_MSPRINTER_HCDC (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
137 HDC display_dc = CreateCompatibleDC (NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
138 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140 GetDeviceCaps (printer_dc, LOGPIXELSX),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 GetDeviceCaps (display_dc, LOGPIXELSX));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 GetDeviceCaps (printer_dc, LOGPIXELSY),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 GetDeviceCaps (display_dc, LOGPIXELSY));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 /* proper display */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 unsigned char *pic,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 int *bit_count,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 unsigned char** bmp_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 struct device *d = XDEVICE (device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 int i,j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 RGBQUAD* colortbl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 int ncolors;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 BITMAPINFO* bmp_info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 unsigned char *ip, *dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 int bpline = BPLINE(width * 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 /* FIXME: we can do this because 24bpp implies no color table, once
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 * we start palettizing this is no longer true. The X versions of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 * this function quantises to 256 colors or bit masks down to a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 * long. Windows can actually handle rgb triples in the raw so I
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 * don't see much point trying to optimize down to the best
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 * structure - unless it has memory / color allocation implications
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 bmp_info=xnew_and_zero (BITMAPINFO);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
186
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 if (!bmp_info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
194 bmp_info->bmiHeader.biSizeImage=width*height*3;
428
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 /* bitmap data needs to be in blue, green, red triples - in that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 order, eimage is in RGB format so we need to convert */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 *bit_count = bpline * height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 if (!bmp_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 ip = pic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 for (i = height-1; i >= 0; i--) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 dp = (*bmp_data) + (i * bpline);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 for (j = 0; j < width; j++) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 dp[2] =*ip++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 dp[1] =*ip++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 *dp =*ip++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 dp += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 else /* scale to 256 colors */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 int rd,gr,bl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 quant_table *qtable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 int bpline = BPLINE (width * 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 /* Quantize the image and get a histogram while we're at it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 Do this first to save memory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 qtable = build_EImage_quantable(pic, width, height, 256);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 if (qtable == NULL) return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 /* use our quantize table to allocate the colors */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 ncolors = qtable->num_active_colors;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
230 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) +
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 sizeof(RGBQUAD) * ncolors);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 if (!bmp_info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 xfree (qtable);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
240 bmp_info->bmiHeader.biBitCount=8;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
241 bmp_info->bmiHeader.biCompression=BI_RGB;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 bmp_info->bmiHeader.biSizeImage=bpline*height;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
243 bmp_info->bmiHeader.biClrUsed=ncolors;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
244 bmp_info->bmiHeader.biClrImportant=ncolors;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
245
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 *bit_count = bpline * height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 if (!*bmp_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 xfree (qtable);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
255
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 /* build up an RGBQUAD colortable */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
257 for (i = 0; i < qtable->num_active_colors; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
259 colortbl[i].rgbRed = (BYTE) qtable->rm[i];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
260 colortbl[i].rgbGreen = (BYTE) qtable->gm[i];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261 colortbl[i].rgbBlue = (BYTE) qtable->bm[i];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
262 colortbl[i].rgbReserved = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
263 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /* now build up the data. picture has to be upside-down and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 back-to-front for msw bitmaps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 ip = pic;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 for (i = height-1; i >= 0; i--)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
269 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
270 dp = (*bmp_data) + (i * bpline);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 for (j = 0; j < width; j++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
272 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
273 rd = *ip++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
274 gr = *ip++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
275 bl = *ip++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
276 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
277 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 xfree (qtable);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
280 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 /* fix up the standard stuff */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 bmp_info->bmiHeader.biWidth=width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 bmp_info->bmiHeader.biHeight=height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 bmp_info->bmiHeader.biPlanes=1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
287 bmp_info->bmiHeader.biYPelsPerMeter=0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 return bmp_info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 /* Given a pixmap filename, look through all of the "standard" places
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 where the file might be located. Return a full pathname if found;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 otherwise, return Qnil. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 mswindows_locate_pixmap_file (Lisp_Object name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 /* This function can GC if IN_REDISPLAY is false */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 Lisp_Object found;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 /* Check non-absolute pathnames with a directory component relative to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 the search path; that's the way Xt does it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 if (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 0)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 (XSTRING_BYTE (name, 0) == '.' &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (XSTRING_BYTE (name, 1) == '.' &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 if (!NILP (Ffile_readable_p (name)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
311 return Fexpand_file_name (name, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 }
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 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0)
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 Lisp_Object temp = list1 (Vdata_directory);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 struct gcpro gcpro1;
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 GCPRO1 (temp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 locate_file (temp, name, Qnil, &found, R_OK);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
325
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 return found;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 /* Initialize an image instance from a bitmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 DEST_MASK specifies the mask of allowed image types.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 If this fails, signal an error. INSTANTIATOR is only used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 in the error message. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
338 init_image_instance_from_dibitmap (Lisp_Image_Instance *ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 BITMAPINFO *bmp_info,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 int dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 void *bmp_data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 int bmp_bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 int slices,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
344 Lisp_Object instantiator,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 int x_hot, int y_hot,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 int create_mask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
348 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 void* bmp_buf=0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
350 enum image_instance_type type;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 HBITMAP bitmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 HDC hdc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 type = IMAGE_COLOR_PIXMAP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 else if (dest_mask & IMAGE_POINTER_MASK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 type = IMAGE_POINTER;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
358 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 incompatible_image_types (instantiator, dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362 hdc = get_device_compdc (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
363 bitmap = CreateDIBSection (hdc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
364 bmp_info,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
365 DIB_RGB_COLORS,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
366 &bmp_buf,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
367 0, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 if (!bitmap || !bmp_buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 signal_simple_error ("Unable to create bitmap", instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 /* copy in the actual bitmap */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 memcpy (bmp_buf, bmp_data, bmp_bits);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 mswindows_initialize_dibitmap_image_instance (ii, slices, type);
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 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 find_keyword_in_vector (instantiator, Q_file);
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 /* Fixup a set of bitmaps. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
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 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
384 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
385 bmp_info->bmiHeader.biWidth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
386 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
387 bmp_info->bmiHeader.biHeight;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
388 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
391 init_image_instance_geometry (ii);
428
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 if (create_mask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
395 mswindows_initialize_image_instance_mask (ii, hdc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
397
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 if (type == IMAGE_POINTER)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 mswindows_initialize_image_instance_icon(ii, TRUE);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
405 image_instance_add_dibitmap (Lisp_Image_Instance *ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 BITMAPINFO *bmp_info,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 void *bmp_data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 int bmp_bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 int slice,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 Lisp_Object instantiator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
412 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 void* bmp_buf=0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
414
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
415 HBITMAP bitmap = CreateDIBSection (get_device_compdc (d),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 bmp_info,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 DIB_RGB_COLORS,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
418 &bmp_buf,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 0,0);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
420
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 if (!bitmap || !bmp_buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 signal_simple_error ("Unable to create bitmap", instantiator);
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 /* copy in the actual bitmap */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 memcpy (bmp_buf, bmp_data, bmp_bits);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap;
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 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
430 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 int slices,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
433 unsigned char *eimage,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 int dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 Lisp_Object domain)
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 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 BITMAPINFO* bmp_info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 unsigned char* bmp_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 int bmp_bits;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 COLORREF bkcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 int slice;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
444
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
445 CHECK_MSGDI_DEVICE (device);
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 /* this is a hack but MaskBlt and TransparentBlt are not supported
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 on most windows variants */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
449 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
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 for (slice = 0; slice < slices; slice++)
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 /* build a bitmap from the eimage */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
455 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 eimage + (width * height * 3 * slice),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 &bmp_bits, &bmp_data)))
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 signal_simple_error ("EImage to DIBitmap conversion failed",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 instantiator);
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 /* Now create the pixmap and set up the image instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 if (slice == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 bmp_data, bmp_bits, slices, instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 0, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 instantiator);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
471
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 xfree (bmp_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 inline static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 set_mono_pixel (unsigned char* bits,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 int bpline, int height,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 int x, int y, int white)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
481 {
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
482 int i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 unsigned char bitnum;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 /* Find the byte on which this scanline begins */
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
485 i = (height - y - 1) * bpline;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 /* Find the byte containing this pixel */
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
487 i += (x >> 3);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 /* Which bit is it? */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
489 bitnum = (unsigned char) (7 - (x & 7));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
490 if (white) /* Turn it on */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
491 bits[i] |= (1 << bitnum);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
492 else /* Turn it off */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
493 bits[i] &= ~(1 << bitnum);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
494 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
497 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
498 HDC hcdc)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 HBITMAP mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 HGDIOBJ old = NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
502 unsigned char *dibits, *and_bits;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
503 BITMAPINFO *bmp_info =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
504 (BITMAPINFO*) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 int i, j;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
506 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
508 int maskbpline = BPLINE ((IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) + 7) / 8);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
509 int bpline = BPLINE (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) * 3);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 if (!bmp_info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
514 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 bmp_info->bmiHeader.biHeight = height;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516 bmp_info->bmiHeader.biPlanes = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
518 bmp_info->bmiHeader.biBitCount = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
519 bmp_info->bmiHeader.biCompression = BI_RGB;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
520 bmp_info->bmiHeader.biClrUsed = 2;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
521 bmp_info->bmiHeader.biClrImportant = 2;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
522 bmp_info->bmiHeader.biSizeImage = height * maskbpline;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 bmp_info->bmiColors[0].rgbRed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 bmp_info->bmiColors[0].rgbGreen = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 bmp_info->bmiColors[0].rgbBlue = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 bmp_info->bmiColors[0].rgbReserved = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 bmp_info->bmiColors[1].rgbRed = 255;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 bmp_info->bmiColors[1].rgbGreen = 255;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 bmp_info->bmiColors[1].rgbBlue = 255;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 bmp_info->bmiColors[0].rgbReserved = 0;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
531
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
532 if (!(mask = CreateDIBSection (hcdc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 bmp_info,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 DIB_RGB_COLORS,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535 (void**)&and_bits,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 0,0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 /* build up an in-memory set of bits to mess with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 xzero (*bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
546 bmp_info->bmiHeader.biWidth = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 bmp_info->bmiHeader.biHeight = -height;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
548 bmp_info->bmiHeader.biPlanes = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
549 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
550 bmp_info->bmiHeader.biBitCount = 24;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
551 bmp_info->bmiHeader.biCompression = BI_RGB;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
552 bmp_info->bmiHeader.biClrUsed = 0;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
553 bmp_info->bmiHeader.biClrImportant = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 bmp_info->bmiHeader.biSizeImage = height * bpline;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
556 dibits = (unsigned char*) xmalloc_and_zero (bpline * height);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 if (GetDIBits (hcdc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 dibits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 bmp_info,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 DIB_RGB_COLORS) <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 /* now set the colored bits in the mask and transparent ones to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 black in the original */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
572 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 for (j=0; j<height; j++)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
574 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 unsigned char* idx = &dibits[j * bpline + i * 3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 if (RGB (idx[2], idx[1], idx[0]) == transparent_color)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
578 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 idx[0] = idx[1] = idx[2] = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
582 else
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
583 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 set_mono_pixel (and_bits, maskbpline, height, i, j, FALSE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 SetDIBits (hcdc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 dibits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 bmp_info,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 DIB_RGB_COLORS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 xfree (dibits);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
599
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 SelectObject(hcdc, old);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
606 mswindows_initialize_image_instance_icon (Lisp_Image_Instance* image,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 int cursor)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 ICONINFO x_icon;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 /* we rely on windows to do any resizing necessary */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 x_icon.fIcon=cursor ? FALSE : TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
617
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 IMAGE_INSTANCE_MSWINDOWS_ICON (image)=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 CreateIconIndirect (&x_icon);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622 static HBITMAP
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
623 create_resized_bitmap (HBITMAP curbmp, struct frame *f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
624 int curx, int cury,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
625 int newx, int newy)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 HBITMAP newbmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 HGDIOBJ old1, old2;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
629
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630 HDC hcdc = get_device_compdc (XDEVICE (FRAME_DEVICE (f)));
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
631 HDC hdcDst = CreateCompatibleDC (hcdc);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
632
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 old1 = SelectObject (hcdc, curbmp);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
634
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 newbmp = CreateCompatibleBitmap (hcdc, newx, newy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 old2 = SelectObject (hdcDst, newbmp);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
638
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 if (!StretchBlt (hdcDst, 0, 0, newx, newy,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
640 hcdc, 0, 0,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
641 curx,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
642 cury,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 SRCCOPY))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 DeleteObject (newbmp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 DeleteDC (hdcDst);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 SelectObject (hdcDst, old2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 SelectObject (hcdc, old1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 DeleteDC (hdcDst);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 return newbmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 HBITMAP
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659 struct frame* f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 int newx, int newy)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
662 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
663 f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
665 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666 newx, newy);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
667 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 HBITMAP
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
670 mswindows_create_resized_mask (Lisp_Image_Instance* ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 struct frame* f,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 int newx, int newy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii) == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
675 return NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
676
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
677 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_MASK (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
678 f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
681 newx, newy);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 #if 0 /* Currently unused */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 /* #### Warning: This function is not correct anymore with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
686 resizable printer bitmaps. If you uncomment it, clean it. --kkm */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
688 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 struct frame* f,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 int newx, int newy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 if (!newbmp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 return FALSE;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
697
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = newbmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = newmask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
710 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 /**********************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 * XPM *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 **********************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 #ifdef HAVE_XPM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 struct color_symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 char* name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 COLORREF color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 static struct color_symbol*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 extract_xpm_color_names (Lisp_Object device,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 Lisp_Object domain,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 Lisp_Object color_symbol_alist,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 int* nsymbols)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 Lisp_Object rest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 Lisp_Object results = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 int i, j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 struct color_symbol *colortbl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 GCPRO2 (results, device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 /* We built up results to be (("name" . #<color>) ...) so that if an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 error happens we don't lose any malloc()ed data, or more importantly,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 leave any pixels allocated in the server. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 i = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 LIST_LOOP (rest, color_symbol_alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 Lisp_Object cons = XCAR (rest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 Lisp_Object name = XCAR (cons);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 Lisp_Object value = XCDR (cons);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 if (NILP (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 if (STRINGP (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 value =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 Fmake_color_instance
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 (value, device, encode_error_behavior_flag (ERROR_ME_NOT));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 assert (COLOR_SPECIFIERP (value));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 value = Fspecifier_instance (value, domain, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 if (NILP (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 results = noseeum_cons (noseeum_cons (name, value), results);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 i++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 UNGCPRO; /* no more evaluation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 *nsymbols=i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 if (i == 0) return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 colortbl = xnew_array_and_zero (struct color_symbol, i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 for (j=0; j<i; j++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 Lisp_Object cons = XCAR (results);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
774 colortbl[j].color =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
777 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
778 C_STRING_ALLOCA, colortbl[j].name,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
779 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 free_cons (XCONS (cons));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 cons = results;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 results = XCDR (results);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 free_cons (XCONS (cons));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 return colortbl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
789 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 unsigned char** data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 int* width, int* height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 int* x_hot, int* y_hot,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 int* transp,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 struct color_symbol* color_symbols,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 int nsymbols)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 XpmImage xpmimage;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 XpmInfo xpminfo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 int result, i, j, transp_idx, maskbpline;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 unsigned char* dptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 unsigned int* sptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 COLORREF color; /* the american spelling virus hits again .. */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
803 COLORREF* colortbl;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 xzero (xpmimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 xzero (xpminfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 xpminfo.valuemask=XpmHotspot;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 *transp=FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 result = XpmCreateXpmImageFromBuffer ((char*)buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 &xpmimage,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 &xpminfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 switch (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 case XpmSuccess:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 case XpmFileInvalid:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 signal_simple_error ("Invalid XPM data", image);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 case XpmNoMemory:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 signal_double_file_error ("Parsing pixmap data",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 "out of memory", image);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 signal_double_file_error_2 ("Parsing pixmap data",
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
829 "unknown error",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 make_int (result), image);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
833
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 *width = xpmimage.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 *height = xpmimage.height;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
836 maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
837
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 if (!*data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 XpmFreeXpmImage (&xpmimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 XpmFreeXpmInfo (&xpminfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 /* build a color table to speed things up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 if (!colortbl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 xfree (*data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 XpmFreeXpmImage (&xpmimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 XpmFreeXpmInfo (&xpminfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 for (i=0; i<xpmimage.ncolors; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 /* goto alert!!!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 /* pick up symbolic colors in preference */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 if (xpmimage.colorTable[i].symbolic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 !strcasecmp (xpmimage.colorTable[i].symbolic,"None"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 *transp=TRUE;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
868 colortbl[i]=transparent_color;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 transp_idx=i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 goto label_found_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 else if (color_symbols)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 for (j = 0; j<nsymbols; j++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 if (!strcmp (xpmimage.colorTable[i].symbolic,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 color_symbols[j].name ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 colortbl[i]=color_symbols[j].color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 goto label_found_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 else if (xpmimage.colorTable[i].c_color == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 goto label_no_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 /* pick up transparencies */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 *transp=TRUE;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
893 colortbl[i]=transparent_color;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 transp_idx=i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 goto label_found_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 /* finally pick up a normal color spec */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 if (xpmimage.colorTable[i].c_color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 colortbl[i]=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 mswindows_string_to_color (xpmimage.colorTable[i].c_color);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 goto label_found_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
904
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 label_no_color:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 xfree (*data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 xfree (colortbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 XpmFreeXpmImage (&xpmimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 XpmFreeXpmInfo (&xpminfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 return 0;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
911
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 label_found_color:;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 /* convert the image */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 sptr=xpmimage.data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 dptr=*data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 for (i = 0; i< *width * *height; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 color = colortbl[*sptr++];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 /* split out the 0x02bbggrr colorref into an rgb triple */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 *dptr++=GetRValue (color); /* red */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 *dptr++=GetGValue (color); /* green */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 *dptr++=GetBValue (color); /* blue */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 *x_hot=xpminfo.x_hotspot;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 *y_hot=xpminfo.y_hotspot;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 XpmFreeXpmImage (&xpmimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 XpmFreeXpmInfo (&xpminfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 xfree (colortbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 mswindows_xpm_instantiate (Lisp_Object image_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
943 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
945 const Extbyte *bytes;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 Extcount len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 unsigned char *eimage;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 int width, height, x_hot, y_hot;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 BITMAPINFO* bmp_info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 unsigned char* bmp_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 int bmp_bits;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 int nsymbols=0, transp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 struct color_symbol* color_symbols=NULL;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
954
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 Q_color_symbols);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
959 CHECK_MSGDI_DEVICE (device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 assert (!NILP (data));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
963 TO_EXTERNAL_FORMAT (LISP_STRING, data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
964 ALLOCA, (bytes, len),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
965 Qbinary);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 /* in case we have color symbols */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 color_symbols = extract_xpm_color_names (device, domain,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 color_symbol_alist, &nsymbols);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 /* convert to an eimage to make processing easier */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
975 signal_simple_error ("XPM to EImage conversion failed",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 image_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
978
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 if (color_symbols)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 while (nsymbols--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 xfree (color_symbols[nsymbols].name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 xfree(color_symbols);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
987
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 /* build a bitmap from the eimage */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 &bmp_bits, &bmp_data)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 signal_simple_error ("XPM to EImage conversion failed",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 image_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 xfree (eimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 /* Now create the pixmap and set up the image instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 bmp_data, bmp_bits, 1, instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 x_hot, y_hot, transp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 xfree (bmp_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 #endif /* HAVE_XPM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 /**********************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 * BMP *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 **********************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 bmp_validate (Lisp_Object instantiator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 file_or_data_must_be_present (instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1018 bmp_normalize (Lisp_Object inst, Lisp_Object console_type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1019 Lisp_Object dest_mask)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 return simple_image_type_normalize (inst, console_type, Qbmp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 bmp_possible_dest_types (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 return IMAGE_COLOR_PIXMAP_MASK;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1035 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1037 const Extbyte *bytes;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 Extcount len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 BITMAPFILEHEADER* bmp_file_header;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 BITMAPINFO* bmp_info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 void* bmp_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 int bmp_bits;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1045 CHECK_MSGDI_DEVICE (device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 assert (!NILP (data));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1049 TO_EXTERNAL_FORMAT (LISP_STRING, data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1050 ALLOCA, (bytes, len),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1051 Qbinary);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1052
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 /* Then slurp the image into memory, decoding along the way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 The result is the image in a simple one-byte-per-pixel
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 format. */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1056
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 bmp_file_header=(BITMAPFILEHEADER*)bytes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 /* Now create the pixmap and set up the image instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 bmp_data, bmp_bits, 1, instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 0, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 /**********************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 * RESOURCES *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 **********************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 mswindows_resource_validate (Lisp_Object instantiator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1076 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 &&
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1078 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1086 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1087 Lisp_Object dest_mask)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 Lisp_Object file = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 Lisp_Object alist = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 GCPRO2 (file, alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1096 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 console_type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 if (CONSP (file)) /* failure locating filename */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 signal_double_file_error ("Opening pixmap file",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 "no such file or directory",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 Fcar (file));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 if (NILP (file)) /* no conversion necessary */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 RETURN_UNGCPRO (inst);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 alist = tagged_vector_to_alist (inst);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 alist = remassq_no_quit (Q_file, alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 alist = Fcons (Fcons (Q_file, file), alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 Lisp_Object result = alist_to_tagged_vector (Qmswindows_resource, alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 free_alist (alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 RETURN_UNGCPRO (result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 mswindows_resource_possible_dest_types (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1127 typedef struct
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 int resource_id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 } resource_t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 #ifndef OCR_ICOCUR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 #define OCR_ICOCUR 32647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 #define OIC_SAMPLE 32512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 #define OIC_HAND 32513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 #define OIC_QUES 32514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 #define OIC_BANG 32515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 #define OIC_NOTE 32516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 #define OIC_WINLOGO 32517
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1141 #if defined (CYGWIN) && CYGWIN_VERSION_DLL_MAJOR < 21
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 #define LR_SHARED 0x8000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 #endif
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1144 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1146 static const resource_t bitmap_table[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 /* bitmaps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 { "close", OBM_CLOSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 { "uparrow", OBM_UPARROW },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 { "dnarrow", OBM_DNARROW },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 { "rgarrow", OBM_RGARROW },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 { "lfarrow", OBM_LFARROW },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 { "reduce", OBM_REDUCE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 { "zoom", OBM_ZOOM },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 { "restore", OBM_RESTORE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 { "reduced", OBM_REDUCED },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 { "zoomd", OBM_ZOOMD },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 { "restored", OBM_RESTORED },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 { "uparrowd", OBM_UPARROWD },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 { "dnarrowd", OBM_DNARROWD },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 { "rgarrowd", OBM_RGARROWD },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 { "lfarrowd", OBM_LFARROWD },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 { "mnarrow", OBM_MNARROW },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 { "combo", OBM_COMBO },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 { "uparrowi", OBM_UPARROWI },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 { "dnarrowi", OBM_DNARROWI },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 { "rgarrowi", OBM_RGARROWI },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 { "lfarrowi", OBM_LFARROWI },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 { "size", OBM_SIZE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 { "btsize", OBM_BTSIZE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 { "check", OBM_CHECK },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 { "checkboxes", OBM_CHECKBOXES },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 { "btncorners" , OBM_BTNCORNERS },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 {0}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1178 static const resource_t cursor_table[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 /* cursors */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 { "normal", OCR_NORMAL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 { "ibeam", OCR_IBEAM },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 { "wait", OCR_WAIT },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 { "cross", OCR_CROSS },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 { "up", OCR_UP },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 /* { "icon", OCR_ICON }, */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 { "sizenwse", OCR_SIZENWSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 { "sizenesw", OCR_SIZENESW },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 { "sizewe", OCR_SIZEWE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 { "sizens", OCR_SIZENS },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 { "sizeall", OCR_SIZEALL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 /* { "icour", OCR_ICOCUR }, */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 { "no", OCR_NO },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 { 0 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1197 static const resource_t icon_table[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 /* icons */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 { "sample", OIC_SAMPLE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 { "hand", OIC_HAND },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 { "ques", OIC_QUES },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 { "bang", OIC_BANG },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 { "note", OIC_NOTE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 { "winlogo", OIC_WINLOGO },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 {0}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 static int resource_name_to_resource (Lisp_Object name, int type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1211 const resource_t* res = (type == IMAGE_CURSOR ? cursor_table
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1212 : type == IMAGE_ICON ? icon_table
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 : bitmap_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 if (INTP (name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 return XINT (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 else if (!STRINGP (name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 signal_simple_error ("invalid resource identifier", name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1223
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 do {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 Extbyte* nm=0;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1226 TO_EXTERNAL_FORMAT (LISP_STRING, name,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1227 C_STRING_ALLOCA, nm,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1228 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 if (!strcasecmp ((char*)res->name, nm))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 return res->resource_id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 } while ((++res)->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 resource_symbol_to_type (Lisp_Object data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 if (EQ (data, Qcursor))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 return IMAGE_CURSOR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 else if (EQ (data, Qicon))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 return IMAGE_ICON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 else if (EQ (data, Qbitmap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 return IMAGE_BITMAP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
1249 mswindows_resource_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
1250 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
1251 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
1252 int dest_mask, Lisp_Object domain)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1254 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 unsigned int type = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 HANDLE himage = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 LPCTSTR resid=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 HINSTANCE hinst = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 ICONINFO iconinfo;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1260 enum image_instance_type iitype;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 char* fname=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1265 Lisp_Object resource_type = find_keyword_in_vector (instantiator,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 Q_resource_type);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1267 Lisp_Object resource_id = find_keyword_in_vector (instantiator,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 Q_resource_id);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 xzero (iconinfo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1272 CHECK_MSGDI_DEVICE (device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 type = resource_symbol_to_type (resource_type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 iitype = IMAGE_POINTER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 iitype = IMAGE_COLOR_PIXMAP;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1280 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 incompatible_image_types (instantiator, dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 /* mess with the keyword info we were provided with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 if (!NILP (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 Extbyte* f=0;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1288 TO_EXTERNAL_FORMAT (LISP_STRING, file,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1289 C_STRING_ALLOCA, f,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1290 Qfile_name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1291 #ifdef CYGWIN
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 CYGWIN_WIN32_PATH (f, fname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 fname = f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 #endif
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1296
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 if (NILP (resource_id))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 resid = (LPCTSTR)fname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 hinst = LoadLibraryEx (fname, NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 LOAD_LIBRARY_AS_DATAFILE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 type));
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1305
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 if (!resid)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1307 TO_EXTERNAL_FORMAT (LISP_STRING, resource_id,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1308 C_STRING_ALLOCA, resid,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1309 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 type))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 signal_simple_error ("Invalid resource identifier", resource_id);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1315
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 /* load the image */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1317 if (xLoadImageA) /* not in NT 3.5 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1318 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1319 if (!(himage = xLoadImageA (hinst, resid, type, 0, 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1320 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1321 LR_SHARED |
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1322 (!NILP (file) ? LR_LOADFROMFILE : 0))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1323 signal_simple_error ("Cannot load image", instantiator);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1324 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1325 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1327 /* Is this correct? I don't really care. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1328 switch (type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1329 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1330 case IMAGE_BITMAP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1331 himage = LoadBitmap (hinst, resid);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1332 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1333 case IMAGE_CURSOR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1334 himage = LoadCursor (hinst, resid);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1335 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1336 case IMAGE_ICON:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1337 himage = LoadIcon (hinst, resid);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1338 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1339 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1340
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1341 if (!himage)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1342 signal_simple_error ("Cannot load image", instantiator);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 if (hinst)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 FreeLibrary (hinst);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1351 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1353 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1356 init_image_instance_geometry (ii);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 /* hey, we've got an icon type thing so we can reverse engineer the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 bitmap and mask */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 if (type != IMAGE_BITMAP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1362 GetIconInfo ((HICON)himage, &iconinfo);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1367 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = (HICON) himage;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1372 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = (HBITMAP) himage;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 check_valid_resource_symbol (Lisp_Object data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 CHECK_SYMBOL (data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 if (!resource_symbol_to_type (data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 signal_simple_error ("invalid resource type", data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 check_valid_resource_id (Lisp_Object data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 if (!resource_name_to_resource (data, IMAGE_CURSOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 !resource_name_to_resource (data, IMAGE_ICON)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 !resource_name_to_resource (data, IMAGE_BITMAP))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 signal_simple_error ("invalid resource identifier", data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 /**********************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 * XBM *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 **********************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 #ifndef HAVE_X_WINDOWS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 /* $XConsortium: RdBitF.c,v 1.10 94/04/17 20:16:13 kaleb Exp $ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 Copyright (c) 1988 X Consortium
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 Permission is hereby granted, free of charge, to any person obtaining a copy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 of this software and associated documentation files (the "Software"), to deal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 in the Software without restriction, including without limitation the rights
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 copies of the Software, and to permit persons to whom the Software is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 furnished to do so, subject to the following conditions:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 The above copyright notice and this permission notice shall be included in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 all copies or substantial portions of the Software.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 Except as contained in this notice, the name of the X Consortium shall not be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 used in advertising or otherwise to promote the sale, use or other dealings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 in this Software without prior written authorization from the X Consortium.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 * This file contains miscellaneous utility routines and is not part of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 * Xlib standard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 * Public entry points:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 * XmuReadBitmapData read data from FILE descriptor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 * and return data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1442 * that way (but don't use common source code so that people can have one
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 * without the other).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 * Based on an optimized version provided by Jim Becker, August 5, 1988.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 #ifndef BitmapSuccess
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 #define BitmapSuccess 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 #define BitmapOpenFailed 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 #define BitmapFileInvalid 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 #define BitmapNoMemory 3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 #define MAX_SIZE 255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 /* shared data for the image read/parse logic */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 static short hexTable[256]; /* conversion value */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 static int initialized = FALSE; /* easier to fill in at run time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 * Table index for the hex values. Initialized once, first time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 * Used for translation value or delimiter significance lookup.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1466 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1467 initHexTable (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 * We build the table at run time for several reasons:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 * 1. portable to non-ASCII machines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 * 2. still reentrant since we set the init flag after setting table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 * 3. easier to extend.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 * 4. less prone to bugs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 hexTable['0'] = 0; hexTable['1'] = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 hexTable['2'] = 2; hexTable['3'] = 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 hexTable['4'] = 4; hexTable['5'] = 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 hexTable['6'] = 6; hexTable['7'] = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 hexTable['8'] = 8; hexTable['9'] = 9;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 hexTable['A'] = 10; hexTable['B'] = 11;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 hexTable['C'] = 12; hexTable['D'] = 13;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 hexTable['E'] = 14; hexTable['F'] = 15;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 hexTable['a'] = 10; hexTable['b'] = 11;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 hexTable['c'] = 12; hexTable['d'] = 13;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 hexTable['e'] = 14; hexTable['f'] = 15;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 /* delimiters of significance are flagged w/ negative value */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 hexTable[' '] = -1; hexTable[','] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 hexTable['}'] = -1; hexTable['\n'] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 hexTable['\t'] = -1;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1493
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 initialized = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 * read next hex value in the input stream, return -1 if EOF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1500 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1501 NextInt (FILE *fstream)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 int ch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 int value = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 int gotone = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 int done = 0;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1507
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 /* loop, accumulate hex value until find delimiter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 /* skip any initial delimiters found in read stream */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 while (!done) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 ch = getc(fstream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 if (ch == EOF) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 value = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 done++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 /* trim high bits, check type and accumulate */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 ch &= 0xff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 if (isascii(ch) && isxdigit(ch)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 value = (value << 4) + hexTable[ch];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 gotone++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 } else if ((hexTable[ch]) < 0 && gotone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 done++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 return value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 * The data returned by the following routine is always in left-most byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 * first and left-most bit first. If it doesn't return BitmapSuccess then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 * its arguments won't have been touched. This routine should look as much
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 * like the Xlib routine XReadBitmapfile as possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1536 int read_bitmap_data (FILE* fstream, unsigned int *width,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1537 unsigned int *height, unsigned char **datap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1538 int *x_hot, int *y_hot)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 unsigned char *data = NULL; /* working variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 char line[MAX_SIZE]; /* input line from file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 int size; /* number of bytes of data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 char name_and_type[MAX_SIZE]; /* an input line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 char *type; /* for parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 int value; /* from an input line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 int version10p; /* boolean, old format */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 int padding; /* to handle alignment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 int bytes_per_line; /* per scanline of data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 unsigned int ww = 0; /* width */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 unsigned int hh = 0; /* height */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 int hx = -1; /* x hotspot */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 int hy = -1; /* y hotspot */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 #define Xmalloc(size) malloc(size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 /* first time initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 if (initialized == FALSE) initHexTable();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 /* error cleanup and return macro */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 #define RETURN(code) { if (data) free (data); return code; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 while (fgets(line, MAX_SIZE, fstream)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 if (strlen(line) == MAX_SIZE-1) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 RETURN (BitmapFileInvalid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 if (!(type = strrchr(name_and_type, '_')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 type = name_and_type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 type++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 if (!strcmp("width", type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 ww = (unsigned int) value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 if (!strcmp("height", type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 hh = (unsigned int) value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 if (!strcmp("hot", type)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 if (type-- == name_and_type || type-- == name_and_type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 if (!strcmp("x_hot", type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 hx = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 if (!strcmp("y_hot", type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 hy = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1586
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 if (sscanf(line, "static short %s = {", name_and_type) == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 version10p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 version10p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 version10p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 if (!(type = strrchr(name_and_type, '_')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 type = name_and_type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 type++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 if (strcmp("bits[]", type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 continue;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1603
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 if (!ww || !hh)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 RETURN (BitmapFileInvalid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 if ((ww % 16) && ((ww % 16) < 9) && version10p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 padding = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 padding = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 bytes_per_line = (ww+7)/8 + padding;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 size = bytes_per_line * hh;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 data = (unsigned char *) Xmalloc ((unsigned int) size);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1616 if (!data)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 RETURN (BitmapNoMemory);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 if (version10p) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 unsigned char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 int bytes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 if ((value = NextInt(fstream)) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 RETURN (BitmapFileInvalid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 *(ptr++) = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 if (!padding || ((bytes+2) % bytes_per_line))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 *(ptr++) = value >> 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 unsigned char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 int bytes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1635 if ((value = NextInt(fstream)) < 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 RETURN (BitmapFileInvalid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 *ptr=value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 } /* end while */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 if (data == NULL) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 RETURN (BitmapFileInvalid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 *datap = data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 data = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 *width = ww;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 *height = hh;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 if (x_hot) *x_hot = hx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 if (y_hot) *y_hot = hy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 RETURN (BitmapSuccess);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1658 int read_bitmap_data_from_file (const char *filename, unsigned int *width,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 unsigned int *height, unsigned char **datap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 int *x_hot, int *y_hot)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 FILE *fstream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 int status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 if ((fstream = fopen (filename, "r")) == NULL) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 return BitmapOpenFailed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 fclose (fstream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 return status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 #endif /* HAVE_X_WINDOWS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 /* this table flips four bits around. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 static int flip_table[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 /* the bitmap data comes in the following format: Widths are padded to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 a multiple of 8. Scan lines are stored in increasing byte order
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 from left to right, little-endian within a byte. 0 = white, 1 =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 black. It must be converted to the following format: Widths are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 padded to a multiple of 16. Scan lines are stored in increasing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 byte order from left to right, big-endian within a byte. 0 =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 black, 1 = white. */
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
1687 static HBITMAP
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 xbm_create_bitmap_from_data (HDC hdc, char *data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 unsigned int width, unsigned int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 int mask, COLORREF fg, COLORREF bg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 int old_width = (width + 7)/8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 int new_width = BPLINE (2*((width + 15)/16));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 unsigned char *offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 void *bmp_buf = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 unsigned char *new_data, *new_offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 int i, j;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1698 BITMAPINFO *bmp_info =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1699 (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 HBITMAP bitmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 if (!bmp_info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 return NULL;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1704
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 new_data = (unsigned char *) xmalloc_and_zero (height * new_width);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1706
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 if (!new_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 xfree (bmp_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1712
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 for (i=0; i<height; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 offset = data + i*old_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 new_offset = new_data + i*new_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 for (j=0; j<old_width; j++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 int byte = offset[j];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 new_offset[j] = ~ (unsigned char)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 ((flip_table[byte & 0xf] << 4) + flip_table[byte >> 4]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 /* if we want a mask invert the bits */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 if (!mask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 new_offset = &new_data[height * new_width];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 while (new_offset-- != new_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 *new_offset ^= 0xff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 bmp_info->bmiHeader.biWidth=width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 bmp_info->bmiHeader.biHeight=-(LONG)height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 bmp_info->bmiHeader.biPlanes=1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1740 bmp_info->bmiHeader.biBitCount=1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 bmp_info->bmiHeader.biCompression=BI_RGB;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1742 bmp_info->bmiHeader.biClrUsed = 2;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1743 bmp_info->bmiHeader.biClrImportant = 2;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1744 bmp_info->bmiHeader.biSizeImage = height * new_width;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 bmp_info->bmiColors[0].rgbRed = GetRValue (fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 bmp_info->bmiColors[0].rgbReserved = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 bmp_info->bmiColors[1].rgbRed = GetRValue (bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 bmp_info->bmiColors[1].rgbReserved = 0;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1753
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1754 bitmap = CreateDIBSection (hdc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 bmp_info,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 DIB_RGB_COLORS,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1757 &bmp_buf,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 0,0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 xfree (bmp_info);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1761
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 if (!bitmap || !bmp_buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 xfree (new_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1767
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 /* copy in the actual bitmap */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 memcpy (bmp_buf, new_data, height * new_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 xfree (new_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 return bitmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 /* Given inline data for a mono pixmap, initialize the given
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 image instance accordingly. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1779 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 /* Note that data is in ext-format! */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1782 const char *bits,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 Lisp_Object pointer_fg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 int dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 HBITMAP mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 Lisp_Object mask_filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 enum image_instance_type type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 COLORREF black = PALETTERGB (0,0,0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 COLORREF white = PALETTERGB (255,255,255);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1796 HDC hdc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1797
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1798 CHECK_MSGDI_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1799
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1800 hdc = get_device_compdc (XDEVICE (device));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 if (!NILP (foreground) || !NILP (background))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 type = IMAGE_COLOR_PIXMAP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 type = IMAGE_MONO_PIXMAP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 type = IMAGE_MONO_PIXMAP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 type = IMAGE_COLOR_PIXMAP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 else if (dest_mask & IMAGE_POINTER_MASK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 type = IMAGE_POINTER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 incompatible_image_types (instantiator, dest_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 | IMAGE_POINTER_MASK);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 mswindows_initialize_dibitmap_image_instance (ii, 1, type);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1822
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 find_keyword_in_vector (instantiator, Q_file);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1825 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = width;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1826 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = height;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1830 init_image_instance_geometry (ii);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1831
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask :
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1833 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 TRUE, black, white);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836 switch (type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 case IMAGE_MONO_PIXMAP:
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1839 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1840 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 FALSE, black, black);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 case IMAGE_COLOR_PIXMAP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 COLORREF fg = black;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 COLORREF bg = white;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 foreground =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 Fmake_color_instance (foreground, device,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 encode_error_behavior_flag (ERROR_ME));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 if (COLOR_INSTANCEP (foreground))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 if (!NILP (background) && !COLOR_INSTANCEP (background))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 background =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 Fmake_color_instance (background, device,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 encode_error_behavior_flag (ERROR_ME));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 if (COLOR_INSTANCEP (background))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1868 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1869 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 FALSE, fg, black);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 case IMAGE_POINTER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 COLORREF fg = black;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 COLORREF bg = white;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 if (NILP (foreground))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 foreground = pointer_fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 if (NILP (background))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 background = pointer_bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1884 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 find_keyword_in_vector (instantiator, Q_hotspot_x);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1886 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 find_keyword_in_vector (instantiator, Q_hotspot_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 if (COLOR_INSTANCEP (foreground))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 if (COLOR_INSTANCEP (background))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1895 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1896 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 TRUE, fg, black);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 mswindows_initialize_image_instance_icon (ii, TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 int dest_mask, int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 /* Note that data is in ext-format! */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1912 const char *bits)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1916 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1917 HDC hdc = get_device_compdc (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 HBITMAP mask = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 if (!NILP (mask_data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1922 const char *ext_data;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1923
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1924 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1925 C_STRING_ALLOCA, ext_data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1926 Qbinary);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1927 mask = xbm_create_bitmap_from_data (hdc,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1928 (unsigned char *) ext_data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1929 XINT (XCAR (mask_data)),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1930 XINT (XCAR (XCDR (mask_data))),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1931 FALSE,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1932 PALETTERGB (0,0,0),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1933 PALETTERGB (255,255,255));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 init_image_instance_from_xbm_inline (ii, width, height, bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 instantiator, pointer_fg, pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 dest_mask, mask, mask_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 /* Instantiate method for XBM's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 static void
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
1944 mswindows_xbm_instantiate (Lisp_Object image_instance,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1950 const char *ext_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 assert (!NILP (data));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1954 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1955 C_STRING_ALLOCA, ext_data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1956 Qbinary);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 pointer_bg, dest_mask, XINT (XCAR (data)),
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1960 XINT (XCAR (XCDR (data))), ext_data);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 #ifdef HAVE_XFACE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 /**********************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 * X-Face *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 **********************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 #if defined(EXTERN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 /* This is about to get redefined! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969 #undef EXTERN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 /* We have to define SYSV32 so that compface.h includes string.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972 instead of strings.h. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973 #define SYSV32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 #ifdef __cplusplus
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 extern "C" {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 #include <compface.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 #ifdef __cplusplus
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 /* JMP_BUF cannot be used here because if it doesn't get defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 to jmp_buf we end up with a conflicting type error with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 definition in compface.h */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 extern jmp_buf comp_env;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 #undef SYSV32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
1988 mswindows_xface_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
1989 Lisp_Object instantiator,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 int i, stattis;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 char *p, *bits, *bp;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1996 const char * volatile emsg = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1997 const char * volatile dstring;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999 assert (!NILP (data));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2001 TO_EXTERNAL_FORMAT (LISP_STRING, data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2002 C_STRING_ALLOCA, dstring,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2003 Qbinary);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 if ((p = strchr (dstring, ':')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 dstring = p + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 if (!(stattis = setjmp (comp_env)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 UnCompAll ((char *) dstring);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 UnGenFace ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 switch (stattis)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 case -2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020 emsg = "uncompface: internal error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 case -1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 emsg = "uncompface: insufficient or invalid data";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 emsg = "uncompface: excess data ignored";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 if (emsg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 signal_simple_error_2 (emsg, data, Qimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 bp = bits = (char *) alloca (PIXELS / 8);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 /* the compface library exports char F[], which uses a single byte per
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 pixel to represent a 48x48 bitmap. Yuck. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 for (i = 0, p = F; i < (PIXELS / 8); ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 int n, b;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 /* reverse the bit order of each byte... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 for (b = n = 0; b < 8; ++b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 n |= ((*p++) << b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 *bp++ = (char) n;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 pointer_bg, dest_mask, 48, 48, bits);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 #endif /* HAVE_XFACE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 /* image instance methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2059 mswindows_print_image_instance (Lisp_Image_Instance *p,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 Lisp_Object printcharfun,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061 int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 char buf[100];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 switch (IMAGE_INSTANCE_TYPE (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 case IMAGE_MONO_PIXMAP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 case IMAGE_COLOR_PIXMAP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 case IMAGE_POINTER:
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2070 sprintf (buf, " (0x%lx",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 write_c_string (buf, printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2075 sprintf (buf, "/0x%lx",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 write_c_string (buf, printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 write_c_string (")", printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 #ifdef DEBUG_WIDGETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 extern int debug_widget_instances;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2092 mswindows_finalize_image_instance (Lisp_Image_Instance *p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2094 if (!p->data)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2095 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2096
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2097 if (DEVICE_LIVE_P (XDEVICE (IMAGE_INSTANCE_DEVICE (p))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2099 if (image_instance_type_to_mask (IMAGE_INSTANCE_TYPE (p))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2100 & (IMAGE_WIDGET_MASK | IMAGE_SUBWINDOW_MASK))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 #ifdef DEBUG_WIDGETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 debug_widget_instances--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 stderr_out ("widget destroyed, %d left\n", debug_widget_instances);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109 DestroyWindow (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 else if (p->data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2119 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2137 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 if (p->data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 xfree (p->data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142 p->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2146 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 /* subwindow and widget support */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2150 static HFONT
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2151 mswindows_widget_hfont (Lisp_Image_Instance *p,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2152 Lisp_Object domain)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2153 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2154 Lisp_Object face = IMAGE_INSTANCE_WIDGET_FACE (p);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2155 int under = FACE_UNDERLINE_P (face, domain);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2156 int strike = FACE_STRIKETHRU_P (face, domain);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2157 Lisp_Object font = query_string_font (IMAGE_INSTANCE_WIDGET_TEXT (p),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2158 face, domain);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2159
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2160 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2161 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2162
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2163 static HDWP
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2164 begin_defer_window_pos (struct frame *f)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2165 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2166 #ifdef DEFER_WINDOW_POS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2167 if (FRAME_MSWINDOWS_DATA (f)->hdwp == 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2168 FRAME_MSWINDOWS_DATA (f)->hdwp = BeginDeferWindowPos (10);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2169 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2170 return FRAME_MSWINDOWS_DATA (f)->hdwp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2171 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2172
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173 /* unmap the image if it is a widget. This is used by redisplay via
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 redisplay_unmap_subwindows */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2175 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2176 mswindows_unmap_subwindow (Lisp_Image_Instance *p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2178 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2179 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2180 #ifdef DEFER_WINDOW_POS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2181 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2182 HDWP hdwp = begin_defer_window_pos (f);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2183 HDWP new_hdwp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2184 new_hdwp = DeferWindowPos (hdwp, IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2185 NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2186 0, 0, 0, 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2187 SWP_HIDEWINDOW | SWP_NOACTIVATE |
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2188 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2189 /* Setting this flag causes the call to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2190 DeferWindowPos to fail with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2191 "Invalid parameter". I don't understand
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2192 why we bother to try and set this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2193 anyway. -- ben */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2194 /* | SWP_NOSENDCHANGING */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2195 );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2196 if (!new_hdwp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2197 mswindows_output_last_error ("unmapping");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2198 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2199 hdwp = new_hdwp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2200 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2201 #else
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2202 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2203 NULL,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 0, 0, 0, 0,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2205 SWP_HIDEWINDOW | SWP_NOACTIVATE |
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2206 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2207 #endif
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2208 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2209 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 /* map the subwindow. This is used by redisplay via
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 redisplay_output_subwindow */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2216 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217 struct display_glyph_area* dga)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2219 #ifdef DEFER_WINDOW_POS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2220 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2221 HDWP hdwp = begin_defer_window_pos (f);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2222 HDWP new_hdwp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2223 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 /* move the window before mapping it ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2226 NULL,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 x, y, dga->width, dga->height,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2228 SWP_NOZORDER
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 /* ... adjust the child ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2232 NULL,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 -dga->xoffset, -dga->yoffset, 0, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 SWP_NOZORDER | SWP_NOSIZE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 /* ... now map it - we are not allowed to move it at the same time. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2237 if (!IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (p))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2238 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2239 #ifdef DEFER_WINDOW_POS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2240 new_hdwp = DeferWindowPos
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2241 (hdwp,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2242 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2243 NULL, 0, 0, 0, 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2244 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2245 | SWP_SHOWWINDOW
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2246 /* | SWP_NOCOPYBITS */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2247 /* Setting this flag causes the call to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2248 DeferWindowPos to fail with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2249 "Invalid parameter". I don't understand
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2250 why we bother to try and set this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2251 anyway. -- ben */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2252 /* | SWP_NOSENDCHANGING */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2253 | SWP_NOACTIVATE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2254 if (!new_hdwp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2255 mswindows_output_last_error ("mapping");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2256 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2257 hdwp = new_hdwp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2258 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2259 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2260 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2261 NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2262 0, 0, 0, 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2263 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2264 | SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOACTIVATE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2265 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2266 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 /* resize the subwindow instance */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2270 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2271 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 /* Set the size of the control .... */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2274 if (!SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2275 NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2276 0, 0, w, h,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2277 SWP_NOZORDER | SWP_NOMOVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2278 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2279 mswindows_output_last_error ("resizing");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2280 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2281
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2282 /* Simply resize the window here. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2283 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2284 mswindows_redisplay_subwindow (Lisp_Image_Instance *p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2285 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2286 mswindows_resize_subwindow (p,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2287 IMAGE_INSTANCE_WIDTH (p),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2288 IMAGE_INSTANCE_HEIGHT (p));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 /* when you click on a widget you may activate another widget this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 needs to be checked and all appropriate widgets updated */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2294 mswindows_redisplay_widget (Lisp_Image_Instance *p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2296 /* Possibly update the face font and colors. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2297 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (p))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2298 && (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2299 || XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2300 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302 /* set the widget font from the widget face */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2304 WM_SETFONT,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2305 (WPARAM) mswindows_widget_hfont
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2306 (p, IMAGE_INSTANCE_FRAME (p)),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 MAKELPARAM (TRUE, 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2309 /* Possibly update the dimensions. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2310 if (IMAGE_INSTANCE_SIZE_CHANGED (p))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2311 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2312 mswindows_resize_subwindow (p,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2313 IMAGE_INSTANCE_WIDTH (p),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2314 IMAGE_INSTANCE_HEIGHT (p));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2315 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2316 /* Possibly update the text in the widget. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2317 if (IMAGE_INSTANCE_TEXT_CHANGED (p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2318 && !NILP (IMAGE_INSTANCE_WIDGET_TEXT (p)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2319 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2320 Extbyte* lparam=0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2321 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (p),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2322 C_STRING_ALLOCA, lparam,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2323 Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2324 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2325 WM_SETTEXT, 0, (LPARAM)lparam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2326 }
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2327 /* Set active state. */
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2328 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2329 {
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2330 Lisp_Object item = IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p);
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2331 LONG style = GetWindowLong
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2332 (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2333 GWL_STYLE);
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2334
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2335 if (CONSP (item))
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2336 item = XCAR (item);
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2337
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2338 if (gui_item_active_p (item))
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2339 SetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2340 GWL_STYLE, style & ~WS_DISABLED);
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2341 else
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2342 SetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2343 GWL_STYLE, style | WS_DISABLED);
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2344 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2345 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2347 /* register widgets into our hashtable so that we can cope with the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 callbacks. The hashtable is weak so deregistration is handled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349 automatically */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2350 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2351 mswindows_register_gui_item (Lisp_Object image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2352 Lisp_Object gui, Lisp_Object domain)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2354 Lisp_Object frame = DOMAIN_FRAME (domain);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 struct frame* f = XFRAME (frame);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2356 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2357 gui,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2358 WIDGET_GLYPH_SLOT);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2359 Fputhash (make_int (id), image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2360 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2361 Fputhash (make_int (id), XGUI_ITEM (gui)->callback,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2362 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2363 Fputhash (make_int (id), XGUI_ITEM (gui)->callback_ex,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2364 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365 return id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2366 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2371 return mswindows_register_gui_item (instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2372 XIMAGE_INSTANCE_WIDGET_ITEM (instance),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2373 domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2377 mswindows_subwindow_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2378 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2379 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2380 Lisp_Object pointer_bg,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2383 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2385 Lisp_Object frame = DOMAIN_FRAME (domain);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 HWND wnd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2387
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2388 CHECK_MSWINDOWS_DEVICE (device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 /* have to set the type this late in case there is no device
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391 instantiation for a widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 /* Allocate space for the clip window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2394 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2397 = CreateWindowEx(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2398 0, /* EX flags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 XEMACS_CONTROL_CLASS,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400 0, /* text */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 0, /* starting x position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 0, /* starting y position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2405 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406 /* parent window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2407 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2408 NULL, /* No menu */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2409 NULL, /* must be null for this class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2410 NULL)) == NULL)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2411 signal_simple_error ("window creation failed with code",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2412 make_int (GetLastError()));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2413
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2414 wnd = CreateWindow( "STATIC",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 "",
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2416 WS_CHILD,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 0, /* starting x position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 0, /* starting y position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2419 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422 0,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2423 (HINSTANCE)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2425 GWL_HINSTANCE),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2433 mswindows_image_instance_equal (Lisp_Image_Instance *p1,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2434 Lisp_Image_Instance *p2, int depth)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 switch (IMAGE_INSTANCE_TYPE (p1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2437 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 case IMAGE_MONO_PIXMAP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 case IMAGE_COLOR_PIXMAP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440 case IMAGE_POINTER:
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2441 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2443 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2444 break;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2445
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2446 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2447 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2448 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2450 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2451 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 static unsigned long
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2454 mswindows_image_instance_hash (Lisp_Image_Instance *p, int depth)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 switch (IMAGE_INSTANCE_TYPE (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458 case IMAGE_MONO_PIXMAP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 case IMAGE_COLOR_PIXMAP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2460 case IMAGE_POINTER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2462
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 /* Set all the slots in an image instance structure to reasonable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 default values. This is used somewhere within an instantiate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 method. It is assumed that the device slot within the image
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 instance is already set -- this is the case when instantiate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 methods are called. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2475 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 int slices,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 enum image_instance_type type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 IMAGE_INSTANCE_TYPE (ii) = type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2488 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (ii) =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489 xnew_array_and_zero (HBITMAP, slices);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 #ifdef HAVE_WIDGETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 /* widgets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2499 mswindows_widget_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2500 Lisp_Object instantiator,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2501 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502 int dest_mask, Lisp_Object domain,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2503 const char* class, int flags, int exflags)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 /* this function can call lisp */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2506 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2508 Lisp_Object frame = DOMAIN_FRAME (domain);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 Extbyte* nm=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2510 HWND wnd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 int id = 0xffff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2513 Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2514
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2515 CHECK_MSWINDOWS_DEVICE (device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2517 if (!gui_item_active_p (gui))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2518 flags |= WS_DISABLED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2520 style = pgui->style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2521
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2522 if (!NILP (pgui->callback) || !NILP (pgui->callback_ex))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2523 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2524 id = mswindows_register_widget_instance (image_instance, domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525 }
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2526
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2528 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2529 C_STRING_ALLOCA, nm,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2530 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2532 /* allocate space for the clip window and then allocate the clip window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2533 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2536 = CreateWindowEx(
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2537 WS_EX_CONTROLPARENT, /* EX flags */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538 XEMACS_CONTROL_CLASS,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 0, /* text */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 0, /* starting x position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2542 0, /* starting y position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2544 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2545 /* parent window */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2546 DOMAIN_MSWINDOWS_HANDLE (domain),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2547 (HMENU)id, /* No menu */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2548 NULL, /* must be null for this class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2549 NULL)) == NULL)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2550 signal_simple_error ("window creation failed with code",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2551 make_int (GetLastError()));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2552
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2553 if ((wnd = CreateWindowEx(
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2554 exflags /* | WS_EX_NOPARENTNOTIFY*/,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2555 class,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2556 nm,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2557 flags | WS_CHILD | WS_VISIBLE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2558 0, /* starting x position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2559 0, /* starting y position */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2560 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2561 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2562 /* parent window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2563 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2564 (HMENU)id, /* No menu */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2565 (HINSTANCE)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2566 GetWindowLong
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2567 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2568 GWL_HINSTANCE),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2569 NULL)) == NULL)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2570 signal_simple_error ("window creation failed with code",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2571 make_int (GetLastError()));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2573 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2574 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2575 /* set the widget font from the widget face */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2576 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2577 SendMessage (wnd, WM_SETFONT,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2578 (WPARAM) mswindows_widget_hfont (ii, domain),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2579 MAKELPARAM (TRUE, 0));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2580 #if 0
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2581 /* #### doesn't work. need to investigate more closely. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2582 if (IMAGE_INSTANCE_WANTS_INITIAL_FOCUS (ii))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2583 SetFocus (wnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2584 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2585 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2586
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2587 /* Instantiate a native layout widget. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2588 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2589 mswindows_native_layout_instantiate (Lisp_Object image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2590 Lisp_Object instantiator,
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2591 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2592 Lisp_Object pointer_bg,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2593 int dest_mask, Lisp_Object domain)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2594 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2595 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2596
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2597 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2598 pointer_bg, dest_mask, domain, "STATIC",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2599 /* Approximation to styles available with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2600 an XEmacs layout. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2601 (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2602 Qetched_in) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2603 EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2604 Qetched_out) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2605 GLYPHP (IMAGE_INSTANCE_LAYOUT_BORDER (ii))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2606 ? SS_ETCHEDFRAME : SS_SUNKEN) | DS_CONTROL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2607 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2608 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2610 /* Instantiate a button widget. Unfortunately instantiated widgets are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2611 particular to a frame since they need to have a parent. It's not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2612 like images where you just select the image into the context you
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2613 want to display it in and BitBlt it. So image instances can have a
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2614 many-to-one relationship with things you see, whereas widgets can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2615 only be one-to-one (i.e. per frame) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2616 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2617 mswindows_button_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2618 Lisp_Object instantiator,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2619 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2620 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2621 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2622 /* This function can call lisp */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2623 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2624 HWND wnd;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2625 int flags = WS_TABSTOP | BS_NOTIFY;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2626 /* BS_NOTIFY #### is needed to get exotic feedback only. Since we
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2627 seem to want nothing beyond BN_CLICK, the style is perhaps not
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2628 necessary -- kkm */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2629 Lisp_Object style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2630 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2631 Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2632 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634 if (!NILP (glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 if (!IMAGE_INSTANCEP (glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 if (IMAGE_INSTANCEP (glyph))
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2640 flags |= XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2641 BS_BITMAP : BS_ICON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2644 style = pgui->style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2646 /* #### consider using the default face for radio and toggle
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2647 buttons. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 if (EQ (style, Qradio))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2650 flags |= BS_RADIOBUTTON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2651 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 else if (EQ (style, Qtoggle))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654 flags |= BS_AUTOCHECKBOX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 else
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2657 {
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2658 flags |= BS_DEFPUSHBUTTON;
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2659 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2662 pointer_bg, dest_mask, domain, "BUTTON",
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2663 flags, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2665 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2666 /* set the checked state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2667 if (gui_item_selected_p (gui))
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2668 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2669 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2670 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2671 /* add the image if one was given */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2672 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2673 &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2674 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2675 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2676 SendMessage (wnd, BM_SETIMAGE,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2677 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2678 IMAGE_BITMAP : IMAGE_ICON),
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2679 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2680 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) :
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2681 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2683 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2684
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2685 /* Update the state of a button. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2686 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2687 mswindows_button_redisplay (Lisp_Object image_instance)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2688 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2689 /* This function can GC if IN_REDISPLAY is false. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2690 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2691
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2692 /* buttons checked or otherwise */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2693 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2694 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2695 BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2696 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2697 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2698 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2699 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2700
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2701 /* instantiate an edit control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2702 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2703 mswindows_edit_field_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2704 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2705 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2706 Lisp_Object pointer_bg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2707 int dest_mask, Lisp_Object domain)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2708 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2709 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2710 pointer_bg, dest_mask, domain, "EDIT",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2711 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2712 | WS_BORDER, WS_EX_CLIENTEDGE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2713 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2715 /* instantiate a progress gauge */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2716 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2717 mswindows_progress_gauge_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2718 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2719 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2720 Lisp_Object pointer_bg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2721 int dest_mask, Lisp_Object domain)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723 HWND wnd;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2724 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2725 Lisp_Object val;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2727 pointer_bg, dest_mask, domain, PROGRESS_CLASS,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2728 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 /* set the colors */
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2731 #if 0 /* #### fix this */
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2732 SendMessage (wnd, PBM_SETBKCOLOR, 0,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2733 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2734 (XCOLOR_INSTANCE
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2735 (FACE_BACKGROUND
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 (XIMAGE_INSTANCE_WIDGET_FACE (ii),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2737 XIMAGE_INSTANCE_FRAME (ii))))));
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2738 SendMessage (wnd, PBM_SETBARCOLOR, 0,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2739 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2740 (XCOLOR_INSTANCE
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2741 (FACE_FOREGROUND
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2742 (XIMAGE_INSTANCE_WIDGET_FACE (ii),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2743 XIMAGE_INSTANCE_FRAME (ii))))));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2744 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2745 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEMS (ii))->value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2746 CHECK_INT (val);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2747 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2748 PBM_SETPOS, (WPARAM)XINT (val), 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2749 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2751 /* instantiate a tree view widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2752 static HTREEITEM add_tree_item (Lisp_Object image_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2753 HWND wnd, HTREEITEM parent, Lisp_Object item,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2754 int children, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2755 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2756 TV_INSERTSTRUCT tvitem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757 HTREEITEM ret;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2759 tvitem.hParent = parent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760 tvitem.hInsertAfter = TVI_LAST;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2761 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762 tvitem.item.cChildren = children;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2763
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2764 if (GUI_ITEMP (item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2765 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2766 tvitem.item.lParam = mswindows_register_gui_item (image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2767 item, domain);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2768 tvitem.item.mask |= TVIF_PARAM;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2769 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2770 C_STRING_ALLOCA, tvitem.item.pszText,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2771 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2772 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2773 else
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2774 TO_EXTERNAL_FORMAT (LISP_STRING, item,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2775 C_STRING_ALLOCA, tvitem.item.pszText,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2776 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2778 tvitem.item.cchTextMax = strlen (tvitem.item.pszText);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2779
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2780 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2781 0, (LPARAM)&tvitem)) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2782 signal_simple_error ("error adding tree view entry", item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2784 return ret;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2785 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2787 static void add_tree_item_list (Lisp_Object image_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2788 HWND wnd, HTREEITEM parent, Lisp_Object list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2789 Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2790 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 Lisp_Object rest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2792
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2793 /* get the first item */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2794 parent = add_tree_item (image_instance, wnd, parent, XCAR (list), TRUE, domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2795 /* recursively add items to the tree view */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2796 LIST_LOOP (rest, XCDR (list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2797 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2798 if (LISTP (XCAR (rest)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2799 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2800 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2801 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2802 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2803 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2805 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2806 mswindows_tree_view_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2807 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2808 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2809 Lisp_Object pointer_bg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2810 int dest_mask, Lisp_Object domain)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2811 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2812 Lisp_Object rest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2813 HWND wnd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2814 HTREEITEM parent;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2815 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2816 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2817 pointer_bg, dest_mask, domain, WC_TREEVIEW,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2818 WS_TABSTOP | WS_BORDER | PBS_SMOOTH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2819 | TVS_HASLINES | TVS_HASBUTTONS,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2820 WS_EX_CLIENTEDGE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2822 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2823
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2824 /* define a root */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2825 parent = add_tree_item (image_instance, wnd, NULL,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2826 XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2827 TRUE, domain);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2828
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2829 /* recursively add items to the tree view */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2830 /* add items to the tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2831 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2832 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2833 if (LISTP (XCAR (rest)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2834 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2835 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2836 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2837 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2838 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2839
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2840 /* Set the properties of a tree view. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2841 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2842 mswindows_tree_view_redisplay (Lisp_Object image_instance)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2843 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2844 /* This function can GC if IN_REDISPLAY is false. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2845 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2846
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2847 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2848 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2849 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2850 Lisp_Object rest;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2851 HTREEITEM parent;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2852 /* Delete previous items. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2853 SendMessage (wnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2854 /* define a root */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2855 parent = add_tree_item (image_instance, wnd, NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2856 XCAR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2857 TRUE, IMAGE_INSTANCE_DOMAIN (ii));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2858
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2859 /* recursively add items to the tree view */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2860 /* add items to the tab */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2861 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2862 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2863 if (LISTP (XCAR (rest)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2864 add_tree_item_list (image_instance, wnd, parent, XCAR (rest),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2865 IMAGE_INSTANCE_DOMAIN (ii));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2866 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2867 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2868 IMAGE_INSTANCE_DOMAIN (ii));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2869 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2870 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2871 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2872
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2873 /* instantiate a tab control */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2874 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2875 add_tab_item (Lisp_Object image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2876 HWND wnd, Lisp_Object item,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2877 Lisp_Object domain, int i)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2879 TC_ITEM tvitem;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2880 int ret = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 tvitem.mask = TCIF_TEXT;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2883
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884 if (GUI_ITEMP (item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2886 tvitem.lParam = mswindows_register_gui_item (image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2887 item, domain);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 tvitem.mask |= TCIF_PARAM;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2889 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2890 C_STRING_ALLOCA, tvitem.pszText,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2891 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2893 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2894 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2895 CHECK_STRING (item);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2896 TO_EXTERNAL_FORMAT (LISP_STRING, item,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2897 C_STRING_ALLOCA, tvitem.pszText,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2898 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2899 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901 tvitem.cchTextMax = strlen (tvitem.pszText);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2903 if ((ret = SendMessage (wnd, TCM_INSERTITEM,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2904 i, (LPARAM)&tvitem)) < 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2905 signal_simple_error ("error adding tab entry", item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2907 return ret;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2908 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2909
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2910 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2911 mswindows_tab_control_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2912 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2913 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2914 Lisp_Object pointer_bg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
2915 int dest_mask, Lisp_Object domain)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2916 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2917 /* This function can call lisp */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2918 Lisp_Object rest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2919 HWND wnd;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2920 int i = 0, selected = 0;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2921 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2922 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2923 unsigned int flags = WS_TABSTOP;
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2924
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2925 if (EQ (orient, Qleft) || EQ (orient, Qright))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2926 {
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2927 flags |= TCS_VERTICAL | TCS_MULTILINE;
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2928 }
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2929 if (EQ (orient, Qright) || EQ (orient, Qbottom))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2930 {
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2931 flags |= TCS_BOTTOM;
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2932 }
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2933
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2934 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
2935 pointer_bg, dest_mask, domain, WC_TABCONTROL,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2936 /* borders don't suit tabs so well */
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2937 flags, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2938 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2939 /* add items to the tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2940 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2942 int idx = add_tab_item (image_instance, wnd, XCAR (rest), domain, i);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2943 assert (idx == i);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2944 if (gui_item_selected_p (XCAR (rest)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2945 selected = i;
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2946 i++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2947 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2948 SendMessage (wnd, TCM_SETCURSEL, selected, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2949 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2950
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2951 /* Set the properties of a tab control. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2952 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2953 mswindows_tab_control_redisplay (Lisp_Object image_instance)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2954 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2955 /* This function can GC if IN_REDISPLAY is false. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2956 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2957 #ifdef DEBUG_WIDGET_OUTPUT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2958 stderr_out ("tab control %p redisplayed\n", IMAGE_INSTANCE_SUBWINDOW_ID (ii));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2959 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2960 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2961 ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2962 IMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (ii))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2963 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2964 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
2965 int i = 0, selected_idx = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2966 Lisp_Object rest;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2967
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2968 assert (!NILP (IMAGE_INSTANCE_WIDGET_ITEMS (ii)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2969
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2970 /* If only the order has changed then simply select the first
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2971 one. This stops horrendous rebuilding of the tabs each time
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2972 you click on one. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2973 if (tab_control_order_only_changed (image_instance))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2974 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2975 Lisp_Object selected =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2976 gui_item_list_find_selected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2977 (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)) ?
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2978 XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)) :
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2979 XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2980
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2981 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2982 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2983 if (gui_item_equal_sans_selected (XCAR (rest), selected, 0))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2984 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2985 Lisp_Object old_selected = gui_item_list_find_selected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2986 (XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2987
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2988 /* Pick up the new selected item. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2989 XGUI_ITEM (old_selected)->selected =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2990 XGUI_ITEM (XCAR (rest))->selected;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2991 XGUI_ITEM (XCAR (rest))->selected =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2992 XGUI_ITEM (selected)->selected;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2993 /* We're not actually changing the items. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2994 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2995 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2996
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2997 SendMessage (wnd, TCM_SETCURSEL, i, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2998 #ifdef DEBUG_WIDGET_OUTPUT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2999 stderr_out ("tab control %p selected item %d\n",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3000 IMAGE_INSTANCE_SUBWINDOW_ID (ii), i);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3001 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3002 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3003 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3004 i++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3005 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3006 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3007 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3008 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3009 /* delete the pre-existing items */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3010 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3011
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3012 /* add items to the tab */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3013 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3014 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3015 add_tab_item (image_instance, wnd, XCAR (rest),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3016 IMAGE_INSTANCE_FRAME (ii), i);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3017 if (gui_item_selected_p (XCAR (rest)))
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
3018 selected_idx = i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3019 i++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3020 }
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 444
diff changeset
3021 SendMessage (wnd, TCM_SETCURSEL, selected_idx, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3022 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3023 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3025
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3026 /* instantiate a static control possible for putting other things in */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3027 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3028 mswindows_label_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3029 Lisp_Object instantiator,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3030 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3031 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3032 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3033 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3034 pointer_bg, dest_mask, domain, "STATIC",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3035 0, WS_EX_STATICEDGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3036 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3037
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3038 /* instantiate a scrollbar control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3039 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3040 mswindows_scrollbar_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3041 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3042 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3043 Lisp_Object pointer_bg,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3044 int dest_mask, Lisp_Object domain)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3045 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3046 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3047 pointer_bg, dest_mask, domain, "SCROLLBAR",
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3048 WS_TABSTOP, WS_EX_CLIENTEDGE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3049 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3050
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3051 /* instantiate a combo control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3052 static void
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3053 mswindows_combo_box_instantiate (Lisp_Object image_instance,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3054 Lisp_Object instantiator,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3055 Lisp_Object pointer_fg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3056 Lisp_Object pointer_bg,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 454
diff changeset
3057 int dest_mask, Lisp_Object domain)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3058 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3059 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3060 HWND wnd;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3061 Lisp_Object rest;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3062 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3063 int len, height;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3065 /* Maybe ought to generalise this more but it may be very windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3066 specific. In windows the window height of a combo box is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3067 height when the combo box is open. Thus we need to set the height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3068 before creating the window and then reset it to a single line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3069 after the window is created so that redisplay does the right
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3070 thing. */
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3071 widget_instantiate (image_instance, instantiator, pointer_fg,
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3072 pointer_bg, dest_mask, domain);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3073
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3074 /* We now have everything right apart from the height. */
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3075 default_face_font_info (domain, 0, 0, &height, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3076 GET_LIST_LENGTH (items, len);
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3077
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3078 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len;
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3079 IMAGE_INSTANCE_HEIGHT (ii) = height;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3080
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3081 /* Now create the widget. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3082 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3083 pointer_bg, dest_mask, domain, "COMBOBOX",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3084 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3085 | CBS_AUTOHSCROLL
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3086 | CBS_HASSTRINGS | WS_VSCROLL,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3087 WS_EX_CLIENTEDGE);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3088 /* Reset the height. layout will probably do this safely, but better make sure. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3089 image_instance_layout (image_instance,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3090 IMAGE_UNSPECIFIED_GEOMETRY,
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3091 IMAGE_UNSPECIFIED_GEOMETRY,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3092 IMAGE_UNCHANGED_GEOMETRY,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3093 IMAGE_UNCHANGED_GEOMETRY,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3094 domain);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3095
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3096 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3097 /* add items to the combo box */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3098 SendMessage (wnd, CB_RESETCONTENT, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3099 LIST_LOOP (rest, items)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3100 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3101 Extbyte* lparam;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3102 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3103 C_STRING_ALLOCA, lparam,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3104 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3105 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3106 signal_simple_error ("error adding combo entries", instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3107 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3108 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3110 /* get properties of a control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3111 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3112 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3113 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3114 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3115 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3116 /* get the text from a control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3117 if (EQ (prop, Q_text))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3118 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3119 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3120 Extbyte *buf = (Extbyte*) alloca (len+1);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3121
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3122 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3123 return build_ext_string (buf, Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3124 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3125 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3126 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3128 /* get properties of a button */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3129 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3130 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3131 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3132 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3133 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3134 /* check the state of a button */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3135 if (EQ (prop, Q_selected))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3136 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3137 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3138 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3139 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3140 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3141 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3142 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3143 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3145 /* get properties of a combo box */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3146 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3147 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3148 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3149 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3150 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3151 /* get the text from a control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3152 if (EQ (prop, Q_text))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3153 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3154 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3155 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3156 Extbyte* buf = (Extbyte*) alloca (len+1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3157 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3158 return build_ext_string (buf, Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3159 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3160 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3161 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3162
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3163 /* set the properties of a progress gauge */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3164 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3165 mswindows_progress_gauge_redisplay (Lisp_Object image_instance)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3166 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3167 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3168
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3169 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3170 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3171 Lisp_Object val;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3172 #ifdef ERROR_CHECK_GLYPHS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3173 assert (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3174 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3175 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3176 #ifdef DEBUG_WIDGET_OUTPUT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3177 stderr_out ("progress gauge displayed value on %p updated to %ld\n",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3178 WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3179 XINT(val));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3180 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3181 CHECK_INT (val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3182 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3183 PBM_SETPOS, (WPARAM)XINT (val), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3187 LRESULT WINAPI
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3188 mswindows_control_wnd_proc (HWND hwnd, UINT msg,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3189 WPARAM wParam, LPARAM lParam)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3190 {
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3191 switch (msg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3192 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3193 case WM_NOTIFY:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3194 case WM_COMMAND:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3195 case WM_CTLCOLORBTN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3196 case WM_CTLCOLORLISTBOX:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3197 case WM_CTLCOLOREDIT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3198 case WM_CTLCOLORSTATIC:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3199 case WM_CTLCOLORSCROLLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3200
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3201 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3202 default:
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3203 return DefWindowProc (hwnd, msg, wParam, lParam);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3204 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3207 #endif /* HAVE_WIDGETS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3210 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3211 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3212 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3214 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3215 syms_of_glyphs_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3217 defkeyword (&Q_resource_id, ":resource-id");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3218 defkeyword (&Q_resource_type, ":resource-type");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3219 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3221 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3222 console_type_create_glyphs_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3223 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3224 /* image methods - display */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3225 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3226 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3227 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3228 CONSOLE_HAS_METHOD (mswindows, map_subwindow);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3229 CONSOLE_HAS_METHOD (mswindows, redisplay_subwindow);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3230 CONSOLE_HAS_METHOD (mswindows, resize_subwindow);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3231 CONSOLE_HAS_METHOD (mswindows, redisplay_widget);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3232 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3233 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3234 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3235 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3236
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3237 /* image methods - printer */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3238 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3239 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_image_instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3240 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_equal);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3241 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_hash);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3242 CONSOLE_INHERITS_METHOD (msprinter, mswindows, init_image_instance_from_eimage);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3243 CONSOLE_INHERITS_METHOD (msprinter, mswindows, locate_pixmap_file);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3244 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3246 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3247 image_instantiator_format_create_glyphs_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3248 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3249 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, nothing);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3250 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, string);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3251 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, formatted_string);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3252 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, inherit);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3253 /* image-instantiator types */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3254 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3255 INITIALIZE_DEVICE_IIFORMAT (msprinter, xbm);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3256 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3257 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xbm, instantiate);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3258 #ifdef HAVE_XPM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3259 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3260 INITIALIZE_DEVICE_IIFORMAT (msprinter, xpm);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3261 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3262 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xpm, instantiate);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3263 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3264 #ifdef HAVE_XFACE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3265 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3266 INITIALIZE_DEVICE_IIFORMAT (msprinter, xface);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3267 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3268 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xface, instantiate);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3269 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3270 #ifdef HAVE_JPEG
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3271 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, jpeg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3272 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3273 #ifdef HAVE_TIFF
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3274 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, tiff);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3275 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3276 #ifdef HAVE_PNG
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3277 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, png);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3278 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3279 #ifdef HAVE_GIF
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3280 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, gif);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3281 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3282 #ifdef HAVE_WIDGETS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3283 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3284 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3285 /* layout widget */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3286 IIFORMAT_VALID_CONSOLE (mswindows, layout);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3287 INITIALIZE_DEVICE_IIFORMAT (mswindows, native_layout);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3288 IIFORMAT_HAS_DEVMETHOD (mswindows, native_layout, instantiate);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3289 /* button widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3290 INITIALIZE_DEVICE_IIFORMAT (mswindows, button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3291 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3292 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3293 IIFORMAT_HAS_DEVMETHOD (mswindows, button, redisplay);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3294 /* edit-field widget */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3295 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit_field);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3296 IIFORMAT_HAS_DEVMETHOD (mswindows, edit_field, instantiate);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3297 /* subwindow */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3298 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3299 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3300 /* label */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3301 INITIALIZE_DEVICE_IIFORMAT (mswindows, label);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3302 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3303 /* combo box */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3304 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo_box);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3305 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, property);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3306 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3307 /* scrollbar */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3308 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3309 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3310 /* progress gauge */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3311 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress_gauge);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3312 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, redisplay);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3313 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3314 /* tree view widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3315 INITIALIZE_DEVICE_IIFORMAT (mswindows, tree_view);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3316 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, instantiate);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3317 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, redisplay);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3318 /* tab control widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3319 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3320 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3321 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, redisplay);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3322 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3323 /* windows bitmap format */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3324 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3325 IIFORMAT_HAS_METHOD (bmp, validate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3326 IIFORMAT_HAS_METHOD (bmp, normalize);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3327 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3328 IIFORMAT_HAS_METHOD (bmp, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3330 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3331 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3332 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, bmp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3334 /* mswindows resources */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3335 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3336 "mswindows-resource");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3338 IIFORMAT_HAS_METHOD (mswindows_resource, validate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3339 IIFORMAT_HAS_METHOD (mswindows_resource, normalize);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3340 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3341 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3342
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 430
diff changeset
3343 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3344 check_valid_resource_symbol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3345 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3346 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3347 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, mswindows_resource);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3348 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3350 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3351 vars_of_glyphs_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3353 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3354 A list of the directories in which mswindows bitmap files may be found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3355 This is used by the `make-image-instance' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3356 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3357 Vmswindows_bitmap_file_path = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3358 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3360 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3361 complex_vars_of_glyphs_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3362 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3363 }