annotate src/glyphs-msw.c @ 408:501cfd01ee6d r21-2-34

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