annotate src/glyphs-msw.c @ 384:bbff43aa5eb7 r21-2-7

Import from CVS: tag r21-2-7
author cvs
date Mon, 13 Aug 2007 11:08:24 +0200
parents 064ab7fed2e0
children aabb7f5b1c81
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.
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
2 Copyright (C) 1998 Andy Piper.
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
3
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
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
23 /* written by Andy Piper <andy@xemacs.org> plagerising 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>
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
50
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
51 #define WIDGET_GLYPH_SLOT 0
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
52
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
53 #ifdef HAVE_XPM
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
54 DEFINE_DEVICE_IIFORMAT (mswindows, xpm);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
55 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
56 DEFINE_DEVICE_IIFORMAT (mswindows, xbm);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
57 DEFINE_DEVICE_IIFORMAT (mswindows, button);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
58 DEFINE_DEVICE_IIFORMAT (mswindows, edit);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
59 #if 0
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
60 DEFINE_DEVICE_IIFORMAT (mswindows, group);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
61 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
62 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
63 DEFINE_DEVICE_IIFORMAT (mswindows, widget);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
64 DEFINE_DEVICE_IIFORMAT (mswindows, label);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
65 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
66 DEFINE_DEVICE_IIFORMAT (mswindows, combo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
67
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
68 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
69 Lisp_Object Qbmp;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
70 Lisp_Object Vmswindows_bitmap_file_path;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
71 static COLORREF transparent_color = RGB (1,1,1);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
72
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
73 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
74 Lisp_Object Q_resource_type, Q_resource_id;
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
75 Lisp_Object Qmswindows_resource;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
76
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
77 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
78 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
79 enum image_instance_type type);
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
80 static void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
81 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
82 struct frame* f);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
83
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
84 COLORREF mswindows_string_to_color (CONST char *name);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
85
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
86 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
87
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
88 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
89 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
90 /* proper display */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
91 /************************************************************************/
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
92 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
93 int width, int height,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
94 unsigned char *pic,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
95 int *bit_count,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
96 unsigned char** bmp_data)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
97 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
98 struct device *d = XDEVICE (device);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
99 int i,j;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
100 RGBQUAD* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
101 int ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
102 BITMAPINFO* bmp_info;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
103 unsigned char *ip, *dp;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
104
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
105 if (DEVICE_MSWINDOWS_BITSPIXEL (d) > 0)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
106 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
107 int bpline = BPLINE(width * 3);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
108 /* 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
109 * 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
110 * this function quantises to 256 colors or bit masks down to a
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
111 * 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
112 * don't see much point trying to optimize down to the best
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
113 * structure - unless it has memory / color allocation implications
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
114 * .... */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
115 bmp_info=xnew_and_zero (BITMAPINFO);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
116
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
117 if (!bmp_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
118 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
119 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
120 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
121
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
122 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
123 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
124 bmp_info->bmiHeader.biSizeImage=width*height*3;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
125
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
126 /* bitmap data needs to be in blue, green, red triples - in that
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
127 order, eimage is in RGB format so we need to convert */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
128 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
129 *bit_count = bpline * height;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
130
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
131 if (!bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
132 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
133 xfree (bmp_info);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
134 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
135 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
136
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
137 ip = pic;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
138 for (i = height-1; i >= 0; i--) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
139 dp = (*bmp_data) + (i * bpline);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
140 for (j = 0; j < width; j++) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
141 dp[2] =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
142 dp[1] =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
143 *dp =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
144 dp += 3;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
145 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
146 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
147 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
148 else /* scale to 256 colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
149 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
150 int rd,gr,bl;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
151 quant_table *qtable;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
152 int bpline = BPLINE (width * 3);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
153 /* Quantize the image and get a histogram while we're at it.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
154 Do this first to save memory */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
155 qtable = build_EImage_quantable(pic, width, height, 256);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
156 if (qtable == NULL) return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
157
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
158 /* use our quantize table to allocate the colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
159 ncolors = qtable->num_active_colors;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
160 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) +
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
161 sizeof(RGBQUAD) * ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
162 if (!bmp_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
163 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
164 xfree (qtable);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
165 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
166 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
167
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
168 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
169
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
170 bmp_info->bmiHeader.biBitCount=8;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
171 bmp_info->bmiHeader.biCompression=BI_RGB;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
172 bmp_info->bmiHeader.biSizeImage=bpline*height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
173 bmp_info->bmiHeader.biClrUsed=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
174 bmp_info->bmiHeader.biClrImportant=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
175
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
176 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
177 *bit_count = bpline * height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
178
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
179 if (!*bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
180 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
181 xfree (qtable);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
182 xfree (bmp_info);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
183 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
184 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
185
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
186 /* build up an RGBQUAD colortable */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
187 for (i = 0; i < qtable->num_active_colors; i++) {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
188 colortbl[i].rgbRed = (BYTE) qtable->rm[i];
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
189 colortbl[i].rgbGreen = (BYTE) qtable->gm[i];
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
190 colortbl[i].rgbBlue = (BYTE) qtable->bm[i];
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
191 colortbl[i].rgbReserved = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
192 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
193
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
194 /* now build up the data. picture has to be upside-down and
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
195 back-to-front for msw bitmaps */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
196 ip = pic;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
197 for (i = height-1; i >= 0; i--) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
198 dp = (*bmp_data) + (i * bpline);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
199 for (j = 0; j < width; j++) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
200 rd = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
201 gr = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
202 bl = *ip++;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
203 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl);
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 }
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
206 xfree (qtable);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
207 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
208 /* fix up the standard stuff */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
209 bmp_info->bmiHeader.biWidth=width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
210 bmp_info->bmiHeader.biHeight=height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
211 bmp_info->bmiHeader.biPlanes=1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
212 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
213 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
214 bmp_info->bmiHeader.biYPelsPerMeter=0;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
215
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
216 return bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
217 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
218
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
219 /* Given a pixmap filename, look through all of the "standard" places
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
220 where the file might be located. Return a full pathname if found;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
221 otherwise, return Qnil. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
222
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
223 static Lisp_Object
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
224 mswindows_locate_pixmap_file (Lisp_Object name)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
225 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
226 /* This function can GC if IN_REDISPLAY is false */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
227 Lisp_Object found;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
228
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
229 /* Check non-absolute pathnames with a directory component relative to
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
230 the search path; that's the way Xt does it. */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
231 if (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 0)) ||
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
232 (XSTRING_BYTE (name, 0) == '.' &&
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
233 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) ||
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
234 (XSTRING_BYTE (name, 1) == '.' &&
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
235 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2)))))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
236 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
237 if (!NILP (Ffile_readable_p (name)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
238 return name;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
239 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
240 return Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
241 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
242
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
243 if (locate_file (Vmswindows_bitmap_file_path, name, "", &found, R_OK) < 0)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
244 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
245 Lisp_Object temp = list1 (Vdata_directory);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
246 struct gcpro gcpro1;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
247
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
248 GCPRO1 (temp);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
249 locate_file (temp, name, "", &found, R_OK);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
250 UNGCPRO;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
251 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
252
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
253 return found;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
254 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
255
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
256
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
257 /* Initialize an image instance from a bitmap
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
258
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
259 DEST_MASK specifies the mask of allowed image types.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
260
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
261 If this fails, signal an error. INSTANTIATOR is only used
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
262 in the error message. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
263
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
264 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
265 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
266 BITMAPINFO *bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
267 int dest_mask,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
268 void *bmp_data,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
269 int bmp_bits,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
270 Lisp_Object instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
271 int x_hot, int y_hot,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
272 int create_mask)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
273 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
274 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
275 struct device *d = XDEVICE (device);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
276 struct frame *f;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
277 void* bmp_buf=0;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
278 int type;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
279 HBITMAP bitmap;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
280 HDC hdc;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
281
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
282 if (!DEVICE_MSWINDOWS_P (d))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
283 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
284
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
285 if (NILP (DEVICE_SELECTED_FRAME (d)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
286 signal_simple_error ("No selected frame on mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
287
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
288 f = XFRAME (DEVICE_SELECTED_FRAME (d));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
289
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
290 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
291 type = IMAGE_COLOR_PIXMAP;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
292 else if (dest_mask & IMAGE_POINTER_MASK)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
293 type = IMAGE_POINTER;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
294 else
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
295 incompatible_image_types (instantiator, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
296 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
297 hdc = FRAME_MSWINDOWS_CDC (f);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
298
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
299 bitmap=CreateDIBSection (hdc,
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
300 bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
301 DIB_RGB_COLORS,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
302 &bmp_buf,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
303 0,0);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
304
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
305 if (!bitmap || !bmp_buf)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
306 signal_simple_error ("Unable to create bitmap", instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
307
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
308 /* copy in the actual bitmap */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
309 memcpy (bmp_buf, bmp_data, bmp_bits);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
310
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
311 mswindows_initialize_dibitmap_image_instance (ii, type);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
312
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
313 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
314 find_keyword_in_vector (instantiator, Q_file);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
315
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
316 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
317 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
318 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
319 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
320 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
321 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
322 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
323
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
324 if (create_mask)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
325 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
326 mswindows_initialize_image_instance_mask (ii, f);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
327 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
328
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
329 if (type == IMAGE_POINTER)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
330 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
331 mswindows_initialize_image_instance_icon(ii, TRUE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
332 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
333 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
334
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
335 static void
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
336 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
337 int width, int height,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
338 unsigned char *eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
339 int dest_mask,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
340 Lisp_Object instantiator,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
341 Lisp_Object domain)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
342 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
343 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
344 BITMAPINFO* bmp_info;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
345 unsigned char* bmp_data;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
346 int bmp_bits;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
347 COLORREF bkcolor;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
348
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
349 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
350 signal_simple_error ("Not an mswindows device", device);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
351
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
352 /* this is a hack but MaskBlt and TransparentBlt are not supported
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
353 on most windows variants */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
354 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
355 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
356
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
357 /* build a bitmap from the eimage */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
358 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
359 &bmp_bits, &bmp_data)))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
360 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
361 signal_simple_error ("EImage to DIBitmap conversion failed",
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
362 instantiator);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
363 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
364
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
365 /* Now create the pixmap and set up the image instance */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
366 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
367 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
368 0, 0, 0);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
369
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
370 xfree (bmp_info);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
371 xfree (bmp_data);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
372 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
373
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
374 static void set_mono_pixel ( unsigned char* bits,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
375 int bpline, int height,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
376 int x, int y, int white )
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
377 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
378 int index;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
379 unsigned char bitnum;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
380 /* Find the byte on which this scanline begins */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
381 index = (height - y - 1) * bpline;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
382 /* Find the byte containing this pixel */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
383 index += (x >> 3);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
384 /* Which bit is it? */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
385 bitnum = (unsigned char)( 7 - (x % 8) );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
386 if( white ) /* Turn it on */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
387 bits[index] |= (1<<bitnum);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
388 else /* Turn it off */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
389 bits[index] &= ~(1<<bitnum);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
390 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
391
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
392 static void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
393 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
394 struct frame* f)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
395 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
396 HBITMAP mask;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
397 HGDIOBJ old = NULL;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
398 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
399 unsigned char* dibits;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
400 BITMAPINFO* bmp_info =
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
401 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
402 int i, j;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
403 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
404
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
405 void* and_bits;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
406 int maskbpline = BPLINE (((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
407 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
408
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
409 if (!bmp_info)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
410 return;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
411
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
412 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
413 bmp_info->bmiHeader.biHeight = height;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
414 bmp_info->bmiHeader.biPlanes=1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
415 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
416 bmp_info->bmiHeader.biBitCount=1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
417 bmp_info->bmiHeader.biCompression=BI_RGB;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
418 bmp_info->bmiHeader.biClrUsed = 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
419 bmp_info->bmiHeader.biClrImportant = 2;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
420 bmp_info->bmiHeader.biSizeImage = height * maskbpline;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
421 bmp_info->bmiColors[0].rgbRed = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
422 bmp_info->bmiColors[0].rgbGreen = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
423 bmp_info->bmiColors[0].rgbBlue = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
424 bmp_info->bmiColors[0].rgbReserved = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
425 bmp_info->bmiColors[1].rgbRed = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
426 bmp_info->bmiColors[1].rgbGreen = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
427 bmp_info->bmiColors[1].rgbBlue = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
428 bmp_info->bmiColors[0].rgbReserved = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
429
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
430 if (!(mask = CreateDIBSection (hcdc,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
431 bmp_info,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
432 DIB_RGB_COLORS,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
433 &and_bits,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
434 0,0)))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
435 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
436 xfree (bmp_info);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
437 return;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
438 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
439
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
440 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
441 /* build up an in-memory set of bits to mess with */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
442 xzero (*bmp_info);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
443
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
444 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
445 bmp_info->bmiHeader.biHeight = -height;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
446 bmp_info->bmiHeader.biPlanes=1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
447 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
448 bmp_info->bmiHeader.biBitCount=24;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
449 bmp_info->bmiHeader.biCompression=BI_RGB;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
450 bmp_info->bmiHeader.biClrUsed = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
451 bmp_info->bmiHeader.biClrImportant = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
452 bmp_info->bmiHeader.biSizeImage = height * bpline;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
453
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
454 dibits = xmalloc_and_zero (bpline * height);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
455 if (GetDIBits (hcdc,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
456 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
457 0,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
458 height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
459 dibits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
460 bmp_info,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
461 DIB_RGB_COLORS) <= 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
462 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
463 xfree (bmp_info);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
464 return;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
465 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
466
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
467 /* now set the colored bits in the mask and transparent ones to
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
468 black in the original */
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
469 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
470 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
471 for(j=0; j<height; j++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
472 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
473 unsigned char* idx = &dibits[j * bpline + i * 3];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
474
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
475 if( RGB (idx[2], idx[1], idx[0]) == transparent_color )
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
476 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
477 idx[0] = idx[1] = idx[2] = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
478 set_mono_pixel( and_bits, maskbpline, height, i, j, TRUE );
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
479 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
480 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
481 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
482 set_mono_pixel( and_bits, maskbpline, height, i, j, FALSE );
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
483 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
484 }
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
485 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
486
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
487 SetDIBits (hcdc,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
488 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
489 0,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
490 height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
491 dibits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
492 bmp_info,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
493 DIB_RGB_COLORS);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
494
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
495 xfree (bmp_info);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
496 xfree (dibits);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
497
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
498 SelectObject(hcdc, old);
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 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
501 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
502
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
503 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
504 mswindows_initialize_image_instance_icon (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
505 int cursor)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
506 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
507 ICONINFO x_icon;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
508
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
509 /* we rely on windows to do any resizing necessary */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
510 x_icon.fIcon=cursor ? FALSE : TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
511 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
512 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
513 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
514 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
515
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
516 IMAGE_INSTANCE_MSWINDOWS_ICON (image)=
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
517 CreateIconIndirect (&x_icon);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
518 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
519
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
520 HBITMAP
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
521 mswindows_create_resized_bitmap (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
522 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
523 int newx, int newy)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
524 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
525 HBITMAP newbmp;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
526 HGDIOBJ old1, old2;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
527 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
528 HDC hdcDst = CreateCompatibleDC (hcdc);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
529
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
530 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
531
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
532 newbmp = CreateCompatibleBitmap (hcdc, newx, newy);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
533
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
534 old2 = SelectObject (hdcDst, newbmp);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
535
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
536 if (!StretchBlt (hdcDst, 0, 0, newx, newy,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
537 hcdc, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
538 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
539 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
540 SRCCOPY))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
541 {
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
542 DeleteObject (newbmp);
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
543 DeleteDC (hdcDst);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
544 return 0;
276
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
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
547 SelectObject (hdcDst, old2);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
548 SelectObject (hcdc, old1);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
549 DeleteDC (hdcDst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
550
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
551 return newbmp;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
552 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
553
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
554 HBITMAP
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
555 mswindows_create_resized_mask (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
556 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
557 int newx, int newy)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
558 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
559 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
560 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
561 HBITMAP newmask;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
562 HGDIOBJ old1, old2;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
563 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
564 HDC hdcDst = CreateCompatibleDC (hcdc);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
565
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
566 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
567 newmask = CreateCompatibleBitmap(hcdc, newx, newy);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
568 old2 = SelectObject (hdcDst, newmask);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
569
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
570 if (!StretchBlt(hdcDst, 0, 0, newx, newy,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
571 hcdc, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
572 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
573 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
574 SRCCOPY))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
575 {
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
576 DeleteObject (newmask);
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
577 DeleteDC (hdcDst);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
578 return NULL;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
579 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
580
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
581 SelectObject (hdcDst, old2);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
582 SelectObject (hcdc, old1);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
583
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
584 DeleteDC (hdcDst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
585
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
586 return newmask;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
587 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
588
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
589 return NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
590 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
591
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
592 int
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
593 mswindows_resize_dibitmap_instance (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
594 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
595 int newx, int newy)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
596 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
597 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
598 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
599
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
600 if (!newbmp)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
601 return FALSE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
602
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
603 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
604 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
605 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
606 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
607
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
608 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = newbmp;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
609 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = newmask;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
610 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
611 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
612
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
613 return TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
614 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
615
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
616 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
617 * XPM *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
618 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
619
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
620 #ifdef HAVE_XPM
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
621
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
622 struct color_symbol
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
623 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
624 char* name;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
625 COLORREF color;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
626 };
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
627
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
628 static struct color_symbol*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
629 extract_xpm_color_names (Lisp_Object device,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
630 Lisp_Object domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
631 Lisp_Object color_symbol_alist,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
632 int* nsymbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
633 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
634 /* This function can GC */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
635 Lisp_Object rest;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
636 Lisp_Object results = Qnil;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
637 int i, j;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
638 struct color_symbol *colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
639 struct gcpro gcpro1, gcpro2;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
640
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
641 GCPRO2 (results, device);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
642
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
643 /* We built up results to be (("name" . #<color>) ...) so that if an
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
644 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
645 leave any pixels allocated in the server. */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
646 i = 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
647 LIST_LOOP (rest, color_symbol_alist)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
648 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
649 Lisp_Object cons = XCAR (rest);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
650 Lisp_Object name = XCAR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
651 Lisp_Object value = XCDR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
652 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
653 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
654 if (STRINGP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
655 value =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
656 Fmake_color_instance
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
657 (value, device, encode_error_behavior_flag (ERROR_ME_NOT));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
658 else
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
659 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
660 assert (COLOR_SPECIFIERP (value));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
661 value = Fspecifier_instance (value, domain, Qnil, Qnil);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
662 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
663 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
664 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
665 results = noseeum_cons (noseeum_cons (name, value), results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
666 i++;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
667 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
668 UNGCPRO; /* no more evaluation */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
669
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
670 *nsymbols=i;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
671 if (i == 0) return 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
672
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
673 colortbl = xnew_array_and_zero (struct color_symbol, i);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
674
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
675 for (j=0; j<i; j++)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
676 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
677 Lisp_Object cons = XCAR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
678 colortbl[j].color =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
679 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
680
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
681 GET_C_STRING_OS_DATA_ALLOCA (XCAR (cons), colortbl[j].name);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
682 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
683 cons = results;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
684 results = XCDR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
685 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
686 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
687 return colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
688 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
689
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
690 static int xpm_to_eimage (Lisp_Object image, CONST Extbyte *buffer,
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
691 unsigned char** data,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
692 int* width, int* height,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
693 int* x_hot, int* y_hot,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
694 int* transp,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
695 struct color_symbol* color_symbols,
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
696 int nsymbols)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
697 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
698 XpmImage xpmimage;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
699 XpmInfo xpminfo;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
700 int result, i, j, transp_idx, maskbpline;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
701 unsigned char* dptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
702 unsigned int* sptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
703 COLORREF color; /* the american spelling virus hits again .. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
704 COLORREF* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
705
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
706 xzero (xpmimage);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
707 xzero (xpminfo);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
708 xpminfo.valuemask=XpmHotspot;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
709 *transp=FALSE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
710
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
711 result = XpmCreateXpmImageFromBuffer ((char*)buffer,
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
712 &xpmimage,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
713 &xpminfo);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
714 switch (result)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
715 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
716 case XpmSuccess:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
717 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
718 case XpmFileInvalid:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
719 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
720 signal_simple_error ("Invalid XPM data", image);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
721 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
722 case XpmNoMemory:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
723 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
724 signal_double_file_error ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
725 "out of memory", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
726 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
727 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
728 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
729 signal_double_file_error_2 ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
730 "unknown error code",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
731 make_int (result), image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
732 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
733 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
734
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
735 *width = xpmimage.width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
736 *height = xpmimage.height;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
737 maskbpline = BPLINE (((~7UL & (unsigned long)(*width + 7)) / 8));
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
738
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
739 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
740
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
741 if (!*data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
742 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
743 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
744 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
745 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
746 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
747
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
748 /* build a color table to speed things up */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
749 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
750 if (!colortbl)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
751 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
752 xfree (*data);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
753 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
754 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
755 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
756 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
757
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
758 for (i=0; i<xpmimage.ncolors; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
759 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
760 /* goto alert!!!! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
761 /* pick up symbolic colors in preference */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
762 if (xpmimage.colorTable[i].symbolic)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
763 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
764 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
765 ||
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
766 !strcasecmp (xpmimage.colorTable[i].symbolic,"None"))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
767 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
768 *transp=TRUE;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
769 colortbl[i]=transparent_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
770 transp_idx=i;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
771 goto label_found_color;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
772 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
773 else if (color_symbols)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
774 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
775 for (j = 0; j<nsymbols; j++)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
776 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
777 if (!strcmp (xpmimage.colorTable[i].symbolic,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
778 color_symbols[j].name ))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
779 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
780 colortbl[i]=color_symbols[j].color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
781 goto label_found_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
782 }
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
783 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
784 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
785 else if (xpmimage.colorTable[i].c_color == 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
786 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
787 goto label_no_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
788 }
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
789 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
790 /* pick up transparencies */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
791 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None"))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
792 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
793 *transp=TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
794 colortbl[i]=transparent_color;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
795 transp_idx=i;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
796 goto label_found_color;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
797 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
798 /* finally pick up a normal color spec */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
799 if (xpmimage.colorTable[i].c_color)
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 colortbl[i]=
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
802 mswindows_string_to_color (xpmimage.colorTable[i].c_color);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
803 goto label_found_color;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
804 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
805
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
806 label_no_color:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
807 xfree (*data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
808 xfree (colortbl);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
809 XpmFreeXpmImage (&xpmimage);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
810 XpmFreeXpmInfo (&xpminfo);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
811 return 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
812
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
813 label_found_color:;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
814 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
815
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
816 /* convert the image */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
817 sptr=xpmimage.data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
818 dptr=*data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
819 for (i = 0; i< *width * *height; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
820 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
821 color = colortbl[*sptr++];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
822
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
823 /* split out the 0x02bbggrr colorref into an rgb triple */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
824 *dptr++=GetRValue (color); /* red */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
825 *dptr++=GetGValue (color); /* green */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
826 *dptr++=GetBValue (color); /* blue */
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
827 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
828
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
829 *x_hot=xpminfo.x_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
830 *y_hot=xpminfo.y_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
831
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
832 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
833 XpmFreeXpmInfo (&xpminfo);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
834 xfree (colortbl);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
835 return TRUE;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
836 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
837
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
838 static void
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
839 mswindows_xpm_instantiate (Lisp_Object image_instance,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
840 Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
841 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
842 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
843 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
844 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
845 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
846 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
847 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
848 unsigned char *eimage;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
849 int width, height, x_hot, y_hot;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
850 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
851 unsigned char* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
852 int bmp_bits;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
853 int nsymbols=0, transp;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
854 struct color_symbol* color_symbols=NULL;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
855
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
856 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
857 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
858 Q_color_symbols);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
859
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
860 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
861 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
862
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
863 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
864
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
865 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
866
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
867 /* in case we have color symbols */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
868 color_symbols = extract_xpm_color_names (device, domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
869 color_symbol_alist, &nsymbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
870
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
871 /* convert to an eimage to make processing easier */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
872 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
873 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
874 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
875 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
876 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
877 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
878
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
879 if (color_symbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
880 xfree(color_symbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
881
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
882 /* build a bitmap from the eimage */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
883 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
884 &bmp_bits, &bmp_data)))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
885 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
886 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
887 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
888 }
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
889 xfree (eimage);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
890
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
891 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
892 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
893 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
894 x_hot, y_hot, transp);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
895
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
896 xfree (bmp_info);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
897 xfree (bmp_data);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
898 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
899 #endif /* HAVE_XPM */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
900
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
901 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
902 * BMP *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
903 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
904
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
905 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
906 bmp_validate (Lisp_Object instantiator)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
907 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
908 file_or_data_must_be_present (instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
909 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
910
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
911 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
912 bmp_normalize (Lisp_Object inst, Lisp_Object console_type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
913 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
914 return simple_image_type_normalize (inst, console_type, Qbmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
915 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
916
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
917 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
918 bmp_possible_dest_types (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
919 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
920 return IMAGE_COLOR_PIXMAP_MASK;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
921 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
922
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
923 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
924 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
925 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
926 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
927 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
928 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
929 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
930 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
931 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
932 BITMAPFILEHEADER* bmp_file_header;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
933 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
934 void* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
935 int bmp_bits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
936 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
937
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
938 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
939 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
940
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
941 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
942
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
943 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
944
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
945 /* Then slurp the image into memory, decoding along the way.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
946 The result is the image in a simple one-byte-per-pixel
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
947 format. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
948
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
949 bmp_file_header=(BITMAPFILEHEADER*)bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
950 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
951 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
952 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
953
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
954 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
955 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
956 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
957 0, 0, 0);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
958 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
959
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
960
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
961 /**********************************************************************
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
962 * RESOURCES *
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
963 **********************************************************************/
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
964
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
965 static void
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
966 mswindows_resource_validate (Lisp_Object instantiator)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
967 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
968 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
969 &&
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
970 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
971 ||
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
972 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
973 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
974 instantiator);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
975 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
976
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
977 static Lisp_Object
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
978 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
979 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
980 /* This function can call lisp */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
981 Lisp_Object file = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
982 struct gcpro gcpro1, gcpro2;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
983 Lisp_Object alist = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
984
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
985 GCPRO2 (file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
986
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
987 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
988 console_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
989
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
990 if (CONSP (file)) /* failure locating filename */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
991 signal_double_file_error ("Opening pixmap file",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
992 "no such file or directory",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
993 Fcar (file));
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
994
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
995 if (NILP (file)) /* no conversion necessary */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
996 RETURN_UNGCPRO (inst);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
997
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
998 alist = tagged_vector_to_alist (inst);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
999
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1000 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1001 alist = remassq_no_quit (Q_file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1002 alist = Fcons (Fcons (Q_file, file), alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1003 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1004
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1005 {
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1006 Lisp_Object result = alist_to_tagged_vector (Qmswindows_resource, alist);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1007 free_alist (alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1008 RETURN_UNGCPRO (result);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1009 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1010 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1011
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1012 static int
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1013 mswindows_resource_possible_dest_types (void)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1014 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1015 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1016 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1017
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1018 typedef struct
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1019 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1020 char *name;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1021 int resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1022 } resource_t;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1023
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1024 #ifndef OCR_ICOCUR
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1025 #define OCR_ICOCUR 32647
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1026 #define OIC_SAMPLE 32512
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1027 #define OIC_HAND 32513
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1028 #define OIC_QUES 32514
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1029 #define OIC_BANG 32515
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1030 #define OIC_NOTE 32516
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1031 #define OIC_WINLOGO 32517
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1032 #define LR_SHARED 0x8000
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1033 #endif
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1034
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1035 static CONST resource_t bitmap_table[] =
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1036 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1037 /* bitmaps */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1038 { "close", OBM_CLOSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1039 { "uparrow", OBM_UPARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1040 { "dnarrow", OBM_DNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1041 { "rgarrow", OBM_RGARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1042 { "lfarrow", OBM_LFARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1043 { "reduce", OBM_REDUCE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1044 { "zoom", OBM_ZOOM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1045 { "restore", OBM_RESTORE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1046 { "reduced", OBM_REDUCED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1047 { "zoomd", OBM_ZOOMD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1048 { "restored", OBM_RESTORED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1049 { "uparrowd", OBM_UPARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1050 { "dnarrowd", OBM_DNARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1051 { "rgarrowd", OBM_RGARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1052 { "lfarrowd", OBM_LFARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1053 { "mnarrow", OBM_MNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1054 { "combo", OBM_COMBO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1055 { "uparrowi", OBM_UPARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1056 { "dnarrowi", OBM_DNARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1057 { "rgarrowi", OBM_RGARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1058 { "lfarrowi", OBM_LFARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1059 { "size", OBM_SIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1060 { "btsize", OBM_BTSIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1061 { "check", OBM_CHECK },
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
1062 { "checkboxes", OBM_CHECKBOXES },
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1063 { "btncorners" , OBM_BTNCORNERS },
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1064 {0}
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1065 };
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1066
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1067 static CONST resource_t cursor_table[] =
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1068 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1069 /* cursors */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1070 { "normal", OCR_NORMAL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1071 { "ibeam", OCR_IBEAM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1072 { "wait", OCR_WAIT },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1073 { "cross", OCR_CROSS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1074 { "up", OCR_UP },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1075 /* { "icon", OCR_ICON }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1076 { "sizenwse", OCR_SIZENWSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1077 { "sizenesw", OCR_SIZENESW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1078 { "sizewe", OCR_SIZEWE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1079 { "sizens", OCR_SIZENS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1080 { "sizeall", OCR_SIZEALL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1081 /* { "icour", OCR_ICOCUR }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1082 { "no", OCR_NO },
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1083 { 0 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1084 };
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1085
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1086 static CONST resource_t icon_table[] =
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1087 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1088 /* icons */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1089 { "sample", OIC_SAMPLE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1090 { "hand", OIC_HAND },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1091 { "ques", OIC_QUES },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1092 { "bang", OIC_BANG },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1093 { "note", OIC_NOTE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1094 { "winlogo", OIC_WINLOGO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1095 {0}
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1096 };
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1097
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1098 static int resource_name_to_resource (Lisp_Object name, int type)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1099 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1100 CONST resource_t* res = (type == IMAGE_CURSOR ? cursor_table
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1101 : type == IMAGE_ICON ? icon_table
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1102 : bitmap_table);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1103
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1104 if (INTP (name))
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 return XINT (name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1107 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1108 else if (!STRINGP (name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1109 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1110 signal_simple_error ("invalid resource identifier", name);
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
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1113 do {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1114 Extbyte* nm=0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1115 GET_C_STRING_OS_DATA_ALLOCA (name, nm);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1116 if (!strcasecmp ((char*)res->name, nm))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1117 return res->resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1118 } while ((++res)->name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1119 return 0;
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
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1122 static int
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1123 resource_symbol_to_type (Lisp_Object data)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1124 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1125 if (EQ (data, Qcursor))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1126 return IMAGE_CURSOR;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1127 else if (EQ (data, Qicon))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1128 return IMAGE_ICON;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1129 else if (EQ (data, Qbitmap))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1130 return IMAGE_BITMAP;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1131 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1132 return 0;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1133 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1134
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1135 static void
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1136 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1137 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1138 int dest_mask, Lisp_Object domain)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1139 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1140 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1141 unsigned int type = 0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1142 HANDLE himage = NULL;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1143 LPCTSTR resid=0;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1144 HINSTANCE hinst = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1145 ICONINFO iconinfo;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1146 int iitype=0;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1147 char* fname=0;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1148 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
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 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1151 Lisp_Object resource_type = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1152 Q_resource_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1153 Lisp_Object resource_id = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1154 Q_resource_id);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1155
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1156 xzero (iconinfo);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1157
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1158 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1159 signal_simple_error ("Not an mswindows device", device);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1160
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1161 type = resource_symbol_to_type (resource_type);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1162
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1163 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1164 iitype = IMAGE_POINTER;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1165 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1166 iitype = IMAGE_COLOR_PIXMAP;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1167 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1168 incompatible_image_types (instantiator, dest_mask,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1169 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1170
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1171 /* mess with the keyword info we were provided with */
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1172 if (!NILP (file))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1173 {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1174 Extbyte* f=0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1175 GET_C_STRING_FILENAME_DATA_ALLOCA (file, f);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1176 #ifdef __CYGWIN32__
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1177 CYGWIN_WIN32_PATH (f, fname);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1178 #else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1179 /* #### FIXME someone who knows ... */
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1180 fname = f
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1181 #endif
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1182
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1183 if (NILP (resource_id))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1184 resid = (LPCTSTR)fname;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1185 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1186 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1187 hinst = LoadLibraryEx (fname, NULL,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1188 LOAD_LIBRARY_AS_DATAFILE);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1189 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1190 type));
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1191
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1192 if (!resid)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1193 GET_C_STRING_OS_DATA_ALLOCA (resource_id, resid);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1194 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1195 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1196 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1197 type))))
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1198 signal_simple_error ("Invalid resource identifier", resource_id);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1199
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1200 /* load the image */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1201 if (!(himage = LoadImage (hinst, resid, type, 0, 0,
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1202 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1203 LR_SHARED |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1204 (!NILP (file) ? LR_LOADFROMFILE : 0))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1205 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1206 signal_simple_error ("Cannot load image", instantiator);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1207 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1208
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1209 if (hinst)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1210 FreeLibrary (hinst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1211
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1212 mswindows_initialize_dibitmap_image_instance (ii, iitype);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1213
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1214 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1215 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1216 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1217 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1218 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1219 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1220
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1221 /* 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
1222 bitmap and mask */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1223 if (type != IMAGE_BITMAP)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1224 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1225 GetIconInfo (himage, &iconinfo);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1226 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1227 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1228 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1229 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1230 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = himage;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1231 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1232 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1233 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1234 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1235 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = himage;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1236 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1237 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1238 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1239 }
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1240 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1241
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1242 static void
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1243 check_valid_resource_symbol (Lisp_Object data)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1244 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1245 CHECK_SYMBOL (data);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1246 if (!resource_symbol_to_type (data))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1247 signal_simple_error ("invalid resource type", data);
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
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1250 static void
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1251 check_valid_resource_id (Lisp_Object data)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1252 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1253 if (!resource_name_to_resource (data, IMAGE_CURSOR)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1254 &&
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1255 !resource_name_to_resource (data, IMAGE_ICON)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1256 &&
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1257 !resource_name_to_resource (data, IMAGE_BITMAP))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1258 signal_simple_error ("invalid resource identifier", data);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1259 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1260
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1261 void
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1262 check_valid_string_or_int (Lisp_Object data)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1263 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1264 if (!INTP (data))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1265 CHECK_STRING (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1266 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1267 CHECK_INT (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1268 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1269
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1270 /**********************************************************************
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1271 * XBM *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1272 **********************************************************************/
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1273 #ifndef HAVE_X_WINDOWS
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1274 /* $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
1275
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1276 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1277
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1278 Copyright (c) 1988 X Consortium
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1279
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1280 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
1281 of this software and associated documentation files (the "Software"), to deal
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1282 in the Software without restriction, including without limitation the rights
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1283 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1284 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
1285 furnished to do so, subject to the following conditions:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1286
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1287 The above copyright notice and this permission notice shall be included in
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1288 all copies or substantial portions of the Software.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1289
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1290 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
1291 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1292 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1293 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
1294 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
1295 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
1296
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1297 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
1298 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
1299 in this Software without prior written authorization from the X Consortium.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1300
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1301 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1302
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1303 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1304 * This file contains miscellaneous utility routines and is not part of the
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1305 * Xlib standard.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1306 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1307 * Public entry points:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1308 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1309 * XmuReadBitmapData read data from FILE descriptor
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1310 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1311 * and return data
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1312 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1313 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1314 * that way (but don't use common source code so that people can have one
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1315 * without the other).
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1316 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1317
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1318
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1319 /*
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1320 * 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
1321 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1322 #ifndef BitmapSuccess
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1323 #define BitmapSuccess 0
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1324 #define BitmapOpenFailed 1
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1325 #define BitmapFileInvalid 2
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1326 #define BitmapNoMemory 3
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1327 #endif
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1328 #define MAX_SIZE 255
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1329
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1330 /* shared data for the image read/parse logic */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1331 static short hexTable[256]; /* conversion value */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1332 static int initialized = FALSE; /* easier to fill in at run time */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1333
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1334 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1335 * Table index for the hex values. Initialized once, first time.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1336 * Used for translation value or delimiter significance lookup.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1337 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1338 static void initHexTable()
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1339 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1340 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1341 * We build the table at run time for several reasons:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1342 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1343 * 1. portable to non-ASCII machines.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1344 * 2. still reentrant since we set the init flag after setting table.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1345 * 3. easier to extend.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1346 * 4. less prone to bugs.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1347 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1348 hexTable['0'] = 0; hexTable['1'] = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1349 hexTable['2'] = 2; hexTable['3'] = 3;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1350 hexTable['4'] = 4; hexTable['5'] = 5;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1351 hexTable['6'] = 6; hexTable['7'] = 7;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1352 hexTable['8'] = 8; hexTable['9'] = 9;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1353 hexTable['A'] = 10; hexTable['B'] = 11;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1354 hexTable['C'] = 12; hexTable['D'] = 13;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1355 hexTable['E'] = 14; hexTable['F'] = 15;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1356 hexTable['a'] = 10; hexTable['b'] = 11;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1357 hexTable['c'] = 12; hexTable['d'] = 13;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1358 hexTable['e'] = 14; hexTable['f'] = 15;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1359
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1360 /* delimiters of significance are flagged w/ negative value */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1361 hexTable[' '] = -1; hexTable[','] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1362 hexTable['}'] = -1; hexTable['\n'] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1363 hexTable['\t'] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1364
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1365 initialized = TRUE;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1366 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1367
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1368 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1369 * read next hex value in the input stream, return -1 if EOF
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1370 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1371 static int NextInt ( FILE *fstream )
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1372 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1373 int ch;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1374 int value = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1375 int gotone = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1376 int done = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1377
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1378 /* loop, accumulate hex value until find delimiter */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1379 /* skip any initial delimiters found in read stream */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1380
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1381 while (!done) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1382 ch = getc(fstream);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1383 if (ch == EOF) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1384 value = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1385 done++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1386 } else {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1387 /* trim high bits, check type and accumulate */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1388 ch &= 0xff;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1389 if (isascii(ch) && isxdigit(ch)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1390 value = (value << 4) + hexTable[ch];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1391 gotone++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1392 } else if ((hexTable[ch]) < 0 && gotone)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1393 done++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1394 }
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 return value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1397 }
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
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1400 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1401 * 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
1402 * 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
1403 * 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
1404 * like the Xlib routine XReadBitmapfile as possible.
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 int read_bitmap_data (fstream, width, height, datap, x_hot, y_hot)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1407 FILE *fstream; /* handle on file */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1408 unsigned int *width, *height; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1409 unsigned char **datap; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1410 int *x_hot, *y_hot; /* RETURNED */
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 unsigned char *data = NULL; /* working variable */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1413 char line[MAX_SIZE]; /* input line from file */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1414 int size; /* number of bytes of data */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1415 char name_and_type[MAX_SIZE]; /* an input line */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1416 char *type; /* for parsing */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1417 int value; /* from an input line */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1418 int version10p; /* boolean, old format */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1419 int padding; /* to handle alignment */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1420 int bytes_per_line; /* per scanline of data */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1421 unsigned int ww = 0; /* width */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1422 unsigned int hh = 0; /* height */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1423 int hx = -1; /* x hotspot */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1424 int hy = -1; /* y hotspot */
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 #define Xmalloc(size) malloc(size)
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 /* first time initialization */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1429 if (initialized == FALSE) initHexTable();
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 /* error cleanup and return macro */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1432 #define RETURN(code) { if (data) free (data); return code; }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1433
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1434 while (fgets(line, MAX_SIZE, fstream)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1435 if (strlen(line) == MAX_SIZE-1) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1436 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1437 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1438 if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1439 if (!(type = strrchr(name_and_type, '_')))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1440 type = name_and_type;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1441 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1442 type++;
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 if (!strcmp("width", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1445 ww = (unsigned int) value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1446 if (!strcmp("height", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1447 hh = (unsigned int) value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1448 if (!strcmp("hot", type)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1449 if (type-- == name_and_type || type-- == name_and_type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1450 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1451 if (!strcmp("x_hot", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1452 hx = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1453 if (!strcmp("y_hot", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1454 hy = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1455 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1456 continue;
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
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1459 if (sscanf(line, "static short %s = {", name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1460 version10p = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1461 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1462 version10p = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1463 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1464 version10p = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1465 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1466 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1467
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1468 if (!(type = strrchr(name_and_type, '_')))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1469 type = name_and_type;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1470 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1471 type++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1472
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1473 if (strcmp("bits[]", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1474 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1475
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1476 if (!ww || !hh)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1477 RETURN (BitmapFileInvalid);
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 if ((ww % 16) && ((ww % 16) < 9) && version10p)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1480 padding = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1481 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1482 padding = 0;
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 bytes_per_line = (ww+7)/8 + padding;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1485
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1486 size = bytes_per_line * hh;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1487 data = (unsigned char *) Xmalloc ((unsigned int) size);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1488 if (!data)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1489 RETURN (BitmapNoMemory);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1490
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1491 if (version10p) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1492 unsigned char *ptr;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1493 int bytes;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1494
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1495 for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1496 if ((value = NextInt(fstream)) < 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1497 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1498 *(ptr++) = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1499 if (!padding || ((bytes+2) % bytes_per_line))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1500 *(ptr++) = value >> 8;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1501 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1502 } else {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1503 unsigned char *ptr;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1504 int bytes;
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 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1507 if ((value = NextInt(fstream)) < 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1508 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1509 *ptr=value;
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 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1513 } /* end while */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1514
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1515 if (data == NULL) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1516 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1517 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1518
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1519 *datap = data;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1520 data = NULL;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1521 *width = ww;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1522 *height = hh;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1523 if (x_hot) *x_hot = hx;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1524 if (y_hot) *y_hot = hy;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1525
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1526 RETURN (BitmapSuccess);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1527 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1528
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1529
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1530 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1531 unsigned int *height, unsigned char **datap,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1532 int *x_hot, int *y_hot)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1533 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1534 FILE *fstream;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1535 int status;
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 if ((fstream = fopen (filename, "r")) == NULL) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1538 return BitmapOpenFailed;
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 status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1541 fclose (fstream);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1542 return status;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1543 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1544 #endif /* HAVE_X_WINDOWS */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1545
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1546 /* this table flips four bits around. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1547 static int flip_table[] =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1548 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1549 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
1550 };
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1551
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1552 /* the bitmap data comes in the following format: Widths are padded to
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1553 a multiple of 8. Scan lines are stored in increasing byte order
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1554 from left to right, little-endian within a byte. 0 = white, 1 =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1555 black. It must be converted to the following format: Widths are
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1556 padded to a multiple of 16. Scan lines are stored in increasing
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1557 byte order from left to right, big-endian within a byte. 0 =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1558 black, 1 = white. */
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1559 HBITMAP
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1560 xbm_create_bitmap_from_data (HDC hdc, char *data,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1561 unsigned int width, unsigned int height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1562 int mask, COLORREF fg, COLORREF bg)
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1563 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1564 int old_width = (width + 7)/8;
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 357
diff changeset
1565 int new_width = 2*((width + 15)/16);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1566 unsigned char *offset;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1567 void *bmp_buf = 0;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1568 unsigned char *new_data, *new_offset;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1569 int i, j;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1570 BITMAPINFO* bmp_info =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1571 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1572 HBITMAP bitmap;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1573
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1574 if (!bmp_info)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1575 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1576
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1577 new_data = (unsigned char *) xmalloc (height * new_width);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1578
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1579 if (!new_data)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1580 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1581 xfree (bmp_info);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1582 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1583 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1584
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1585 for (i=0; i<height; i++)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1586 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1587 offset = data + i*old_width;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1588 new_offset = new_data + i*new_width;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1589
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1590 new_offset[new_width - 1] = 0; /* there may be an extra byte
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1591 that needs to be padded */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1592 for (j=0; j<old_width; j++)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1593 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1594 int byte = offset[j];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1595 new_offset[j] = ~ (unsigned char)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1596 ((flip_table[byte & 0xf] << 4) + flip_table[byte >> 4]);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1597 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1598 }
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1599
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1600 /* if we want a mask invert the bits */
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1601 if (!mask)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1602 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1603 new_offset = &new_data[height * new_width];
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1604 while (new_offset-- != new_data)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1605 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1606 *new_offset ^= 0xff;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1607 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1608 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1609
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1610 bmp_info->bmiHeader.biWidth=width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1611 bmp_info->bmiHeader.biHeight=-height;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1612 bmp_info->bmiHeader.biPlanes=1;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1613 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1614 bmp_info->bmiHeader.biBitCount=1;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1615 bmp_info->bmiHeader.biCompression=BI_RGB;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1616 bmp_info->bmiHeader.biClrUsed = 2;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1617 bmp_info->bmiHeader.biClrImportant = 2;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1618 bmp_info->bmiHeader.biSizeImage = height * new_width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1619 bmp_info->bmiColors[0].rgbRed = GetRValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1620 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1621 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1622 bmp_info->bmiColors[0].rgbReserved = 0;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1623 bmp_info->bmiColors[1].rgbRed = GetRValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1624 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1625 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1626 bmp_info->bmiColors[1].rgbReserved = 0;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1627
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1628 bitmap = CreateDIBSection (hdc,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1629 bmp_info,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1630 DIB_RGB_COLORS,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1631 &bmp_buf,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1632 0,0);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1633
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1634 xfree (bmp_info);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1635
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1636 if (!bitmap || !bmp_buf)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1637 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1638 xfree (new_data);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1639 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1640 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1641
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1642 /* copy in the actual bitmap */
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1643 memcpy (bmp_buf, new_data, height * new_width);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1644 xfree (new_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1645
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1646 return bitmap;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1647 }
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 /* Given inline data for a mono pixmap, initialize the given
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1650 image instance accordingly. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1651
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1652 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1653 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1654 int width, int height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1655 /* Note that data is in ext-format! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1656 CONST char *bits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1657 Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1658 Lisp_Object pointer_fg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1659 Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1660 int dest_mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1661 HBITMAP mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1662 Lisp_Object mask_filename)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1663 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1664 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1665 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device)));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1666 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1667 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1668 enum image_instance_type type;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1669 COLORREF black = PALETTERGB (0,0,0);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1670 COLORREF white = PALETTERGB (255,255,255);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1671
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1672 HDC hdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1673
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1674 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1675 signal_simple_error ("Not an MS-Windows device", device);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1676
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1677 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1678 (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1679 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1680 if (!NILP (foreground) || !NILP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1681 type = IMAGE_COLOR_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1682 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1683 type = IMAGE_MONO_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1684 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1685 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1686 type = IMAGE_MONO_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1687 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1688 type = IMAGE_COLOR_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1689 else if (dest_mask & IMAGE_POINTER_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1690 type = IMAGE_POINTER;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1691 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1692 incompatible_image_types (instantiator, dest_mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1693 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1694 | IMAGE_POINTER_MASK);
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 mswindows_initialize_dibitmap_image_instance (ii, type);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1697
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1698 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1699 find_keyword_in_vector (instantiator, Q_file);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1700 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1701 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1702 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1703 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1704 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1705 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask :
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1706 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1707 TRUE, black, white);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1708
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1709 switch (type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1710 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1711 case IMAGE_MONO_PIXMAP:
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1712 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1713 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1714 FALSE, black, black);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1715 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1716
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1717 case IMAGE_COLOR_PIXMAP:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1718 {
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1719 COLORREF fg = black;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1720 COLORREF bg = white;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1721
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1722 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1723 foreground =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1724 Fmake_color_instance (foreground, device,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1725 encode_error_behavior_flag (ERROR_ME));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1726
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1727 if (COLOR_INSTANCEP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1728 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1729
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1730 if (!NILP (background) && !COLOR_INSTANCEP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1731 background =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1732 Fmake_color_instance (background, device,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1733 encode_error_behavior_flag (ERROR_ME));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1734
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1735 if (COLOR_INSTANCEP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1736 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1737
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1738 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1739 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
290
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 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1742 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1743 FALSE, fg, black);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1744 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1745 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1746
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1747 case IMAGE_POINTER:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1748 {
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1749 COLORREF fg = black;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1750 COLORREF bg = white;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1751
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1752 if (NILP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1753 foreground = pointer_fg;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1754 if (NILP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1755 background = pointer_bg;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1756
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
1757 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) =
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
1758 find_keyword_in_vector (instantiator, Q_hotspot_x);
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
1759 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) =
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
1760 find_keyword_in_vector (instantiator, Q_hotspot_y);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1761 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1762 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1763 if (COLOR_INSTANCEP (foreground))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1764 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1765 if (COLOR_INSTANCEP (background))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1766 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1767
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1768 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1769 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1770 TRUE, fg, black);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1771 mswindows_initialize_image_instance_icon (ii, TRUE);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1772 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1773 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1774
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1775 default:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1776 abort ();
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1777 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1778 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1779
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1780 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1781 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1782 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1783 int dest_mask, int width, int height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1784 /* Note that data is in ext-format! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1785 CONST char *bits)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1786 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1787 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1788 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1789 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1790 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1791 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1792 HDC hdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1793 HBITMAP mask = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1794 CONST char *gcc_may_you_rot_in_hell;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1795
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1796 if (!NILP (mask_data))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1797 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1798 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (mask_data))),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1799 gcc_may_you_rot_in_hell);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1800 mask =
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1801 xbm_create_bitmap_from_data ( hdc,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1802 (unsigned char *)
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1803 gcc_may_you_rot_in_hell,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1804 XINT (XCAR (mask_data)),
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1805 XINT (XCAR (XCDR (mask_data))), FALSE,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1806 PALETTERGB (0,0,0),
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1807 PALETTERGB (255,255,255));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1808 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1809
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1810 init_image_instance_from_xbm_inline (ii, width, height, bits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1811 instantiator, pointer_fg, pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1812 dest_mask, mask, mask_file);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1813 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1814
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1815 /* Instantiate method for XBM's. */
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 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1818 mswindows_xbm_instantiate (Lisp_Object image_instance,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1819 Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1820 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1821 int dest_mask, Lisp_Object domain)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1822 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1823 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1824 CONST char *gcc_go_home;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1825
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1826 assert (!NILP (data));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1827
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1828 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (data))),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1829 gcc_go_home);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1830
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1831 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1832 pointer_bg, dest_mask, XINT (XCAR (data)),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1833 XINT (XCAR (XCDR (data))), gcc_go_home);
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
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1836
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1837 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1838 /* image instance methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1839 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1840
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1841 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1842 mswindows_print_image_instance (struct Lisp_Image_Instance *p,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1843 Lisp_Object printcharfun,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1844 int escapeflag)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1845 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1846 char buf[100];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1847
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1848 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1849 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1850 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1851 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1852 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1853 sprintf (buf, " (0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1854 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1855 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1856 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1857 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1858 sprintf (buf, "/0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1859 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1860 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1861 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1862 write_c_string (")", printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1863 break;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1864
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1865 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1866 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1867 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1868 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1869
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1870 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1871 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1872 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1873 if (DEVICE_LIVE_P (XDEVICE (p->device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1874 {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1875 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1876 ||
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1877 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1878 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1879 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1880 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1881 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1882 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1883 else if (p->data)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1884 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1885 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1886 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1887 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1888 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1889 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1890 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1891 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1892 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1893 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1894 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1895 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1896
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1897 if (p->data)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1898 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1899 xfree (p->data);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1900 p->data = 0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1901 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1902 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1903
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1904 /************************************************************************/
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1905 /* subwindow and widget support */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1906 /************************************************************************/
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1907
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1908 /* 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
1909 redisplay_unmap_subwindows */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1910 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1911 mswindows_unmap_subwindow (struct Lisp_Image_Instance *p)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1912 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1913 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1914 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1915 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1916 NULL,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1917 0, 0, 0, 0,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1918 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1919 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1920 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1921 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1922
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1923 /* map the subwindow. This is used by redisplay via
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1924 redisplay_output_subwindow */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1925 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1926 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1927 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1928 /* ShowWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), SW_SHOW);*/
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1929 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1930 NULL,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1931 x, y, 0, 0,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1932 SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOSIZE
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1933 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1934 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1935
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1936 /* 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
1937 needs to be checked and all appropriate widgets updated */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1938 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1939 mswindows_update_subwindow (struct Lisp_Image_Instance *p)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1940 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1941 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1942 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1943 /* buttons checked or otherwise */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1944 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1945 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1946 if (gui_item_selected_p (&IMAGE_INSTANCE_WIDGET_ITEM (p)))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1947 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1948 BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1949 else
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1950 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1951 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1952 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1953 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1954 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1955
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1956 /* 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
1957 callbacks. The hashtable is weak so deregistration is handled
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1958 automatically */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1959 static int
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1960 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1961 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1962 Lisp_Object frame = FW_FRAME (domain);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1963 struct frame* f = XFRAME (frame);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1964 int id = gui_item_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1965 &XIMAGE_INSTANCE_WIDGET_ITEM (instance),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1966 WIDGET_GLYPH_SLOT);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1967 Fputhash (make_int (id),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1968 XIMAGE_INSTANCE_WIDGET_CALLBACK (instance),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1969 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1970 return id;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1971 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1972
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1973 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1974 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1975 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1976 int dest_mask, Lisp_Object domain)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1977 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1978 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1979 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1980 struct device* d = XDEVICE (device);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1981 Lisp_Object frame = FW_FRAME (domain);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1982 HWND wnd;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1983
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1984 if (!DEVICE_MSWINDOWS_P (d))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1985 signal_simple_error ("Not an mswindows device", device);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1986
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1987 /* 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
1988 instantiation for a widget */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1989 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1990
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1991 wnd = CreateWindow( "STATIC",
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1992 "",
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1993 WS_CHILD,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1994 0, /* starting x position */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1995 0, /* starting y position */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1996 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1997 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1998 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), /* parent window */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
1999 0,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2000 (HINSTANCE)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2001 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2002 GWL_HINSTANCE),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2003 NULL);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2004
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2005 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2006 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2007 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2008
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2009 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2010 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2011 struct Lisp_Image_Instance *p2, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2012 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2013 switch (IMAGE_INSTANCE_TYPE (p1))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2014 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2015 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2016 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2017 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2018 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2019 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2020 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2021 break;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2022
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2023 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2024 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2025 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2026
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2027 return 1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2028 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2029
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2030 static unsigned long
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2031 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2032 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2033 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2034 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2035 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2036 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2037 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2038 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2039
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2040 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2041 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2042 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2043 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2044
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2045 /* Set all the slots in an image instance structure to reasonable
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2046 default values. This is used somewhere within an instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2047 method. It is assumed that the device slot within the image
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2048 instance is already set -- this is the case when instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2049 methods are called. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2050
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2051 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2052 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2053 enum image_instance_type type)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2054 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2055 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2056 IMAGE_INSTANCE_TYPE (ii) = type;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2057 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2058 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2059 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2060 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2061 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2062 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2063 }
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 /************************************************************************/
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2067 /* widgets */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2068 /************************************************************************/
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2069
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2070 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2071 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2072 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2073 int dest_mask, Lisp_Object domain,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2074 CONST char* class, int flags, int exflags)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2075 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2076 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2077 #if 0
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2078 struct Lisp_Image_Instance *groupii = 0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2079 Lisp_Object group = find_keyword_in_vector (instantiator, Q_group);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2080 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2081 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2082 struct device* d = XDEVICE (device);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2083 Lisp_Object frame = FW_FRAME (domain);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2084 Extbyte* nm=0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2085 HWND wnd;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2086 int id = 0xffff;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2087 struct gui_item* pgui = &IMAGE_INSTANCE_WIDGET_ITEM (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2088
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2089 if (!DEVICE_MSWINDOWS_P (d))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2090 signal_simple_error ("Not an mswindows device", device);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2091 #if 0
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2092 /* if the user specified another glyph as a group pick up the
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2093 instance in our domain. */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2094 if (!NILP (group))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2095 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2096 if (SYMBOLP (group))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2097 group = XSYMBOL (group)->value;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2098 group = glyph_image_instance (group, domain, ERROR_ME, 1);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2099 groupii = XIMAGE_INSTANCE (group);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2100 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2101 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2102 if (!gui_item_active_p (pgui))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2103 flags |= WS_DISABLED;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2104
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2105 style = pgui->style;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2106
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2107 if (!NILP (pgui->callback))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2108 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2109 id = mswindows_register_widget_instance (image_instance, domain);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2110 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2111 /* 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
2112 instantiation for a widget */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2113 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2114 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2115 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2116
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2117 wnd = CreateWindowEx(
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2118 exflags /* | WS_EX_NOPARENTNOTIFY*/,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2119 class,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2120 nm,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2121 flags | WS_CHILD,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2122 0, /* starting x position */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2123 0, /* starting y position */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2124 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2125 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2126 /* parent window */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2127 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2128 (HMENU)id, /* No menu */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2129 (HINSTANCE)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2130 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2131 GWL_HINSTANCE),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2132 NULL);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2133
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2134 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2135 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2136 /* set the widget font from the widget face */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2137 SendMessage (wnd, WM_SETFONT,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2138 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2139 (XFONT_INSTANCE (widget_face_font_info
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2140 (domain,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2141 IMAGE_INSTANCE_WIDGET_FACE (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2142 0, 0))),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2143 MAKELPARAM (TRUE, 0));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2144 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2145
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2146 /* Instantiate a button widget. Unfortunately instantiated widgets are
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2147 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
2148 like images where you just select the image into the context you
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2149 want to display it in and BitBlt it. So images instances can have a
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2150 many-to-one relationship with things you see, whereas widgets can
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2151 only be one-to-one (i.e. per frame) */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2152 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2153 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2154 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2155 int dest_mask, Lisp_Object domain)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2156 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2157 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2158 HWND wnd;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2159 int flags = BS_NOTIFY;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2160 Lisp_Object style;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2161 struct gui_item* pgui = &IMAGE_INSTANCE_WIDGET_ITEM (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2162
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2163 if (!gui_item_active_p (pgui))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2164 flags |= WS_DISABLED;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2165
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2166 style = pgui->style;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2167
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2168 if (EQ (style, Qradio))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2169 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2170 flags |= BS_RADIOBUTTON;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2171 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2172 else if (EQ (style, Qtoggle))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2173 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2174 flags |= BS_AUTOCHECKBOX;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2175 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2176 else
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2177 flags |= BS_DEFPUSHBUTTON;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2178
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2179 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2180 pointer_bg, dest_mask, domain, "BUTTON", flags,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2181 WS_EX_CONTROLPARENT);
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 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2184 /* set the checked state */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2185 if (gui_item_selected_p (pgui))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2186 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2187 else
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2188 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2189 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2190
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2191 /* instantiate an edit control */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2192 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2193 mswindows_edit_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2194 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2195 int dest_mask, Lisp_Object domain)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2196 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2197 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2198 pointer_bg, dest_mask, domain, "EDIT",
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2199 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2200 | WS_BORDER,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2201 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2202 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2203
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2204 /* instantiate a static control possible for putting other things in */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2205 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2206 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2207 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2208 int dest_mask, Lisp_Object domain)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2209 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2210 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2211 pointer_bg, dest_mask, domain, "STATIC",
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2212 0, WS_EX_STATICEDGE);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2213 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2214
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2215 #if 0
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2216 /* instantiate a static control possible for putting other things in */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2217 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2218 mswindows_group_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2219 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2220 int dest_mask, Lisp_Object domain)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2221 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2222 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2223 pointer_bg, dest_mask, domain, "BUTTON",
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2224 WS_GROUP | BS_GROUPBOX | WS_BORDER,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2225 WS_EX_CLIENTEDGE );
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2226 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2227 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2228
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2229 /* instantiate a scrollbar control */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2230 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2231 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2232 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2233 int dest_mask, Lisp_Object domain)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2234 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2235 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2236 pointer_bg, dest_mask, domain, "SCROLLBAR",
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2237 0,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2238 WS_EX_CLIENTEDGE );
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2239 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2240
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2241 /* instantiate a combo control */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2242 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2243 mswindows_combo_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2244 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2245 int dest_mask, Lisp_Object domain)
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 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2248 HANDLE wnd;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2249 Lisp_Object rest;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2250
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2251 /* 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
2252 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
2253 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
2254 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
2255 after the window is created so that redisplay does the right
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2256 thing. */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2257 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2258 pointer_bg, dest_mask, domain, "COMBOBOX",
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2259 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2260 | CBS_AUTOHSCROLL
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2261 | CBS_HASSTRINGS | WS_VSCROLL,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2262 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2263 /* reset the height */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2264 widget_text_to_pixel_conversion (domain,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2265 IMAGE_INSTANCE_WIDGET_FACE (ii), 1, 0,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2266 &IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii), 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2267 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2268 /* add items to the combo box */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2269 SendMessage (wnd, CB_RESETCONTENT, 0, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2270 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
2271 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2272 Extbyte* lparam;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2273 GET_C_STRING_OS_DATA_ALLOCA (XCAR (rest), lparam);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2274 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2275 signal_simple_error ("error adding combo entries", instantiator);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2276 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2277 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2278
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2279 /* get properties of a control */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2280 static Lisp_Object
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2281 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop)
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 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2284 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2285 /* get the text from a control */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2286 if (EQ (prop, Qtext))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2287 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2288 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2289 Extbyte* buf =alloca (len+1);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2290
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2291 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2292 return build_ext_string (buf, FORMAT_OS);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2293 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2294 return Qunbound;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2295 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2296
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2297 /* get properties of a button */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2298 static Lisp_Object
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2299 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2300 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2301 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2302 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2303 /* check the state of a button */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2304 if (EQ (prop, Qselected))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2305 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2306 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2307 return Qt;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2308 else
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2309 return Qnil;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2310 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2311 return Qunbound;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2312 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2313
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2314 /* get properties of a combo box */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2315 static Lisp_Object
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2316 mswindows_combo_property (Lisp_Object image_instance, Lisp_Object prop)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2317 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2318 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2319 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2320 /* get the text from a control */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2321 if (EQ (prop, Qtext))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2322 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2323 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2324 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2325 Extbyte* buf = alloca (len+1);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2326 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2327 return build_ext_string (buf, FORMAT_OS);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2328 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2329 return Qunbound;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2330 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2331
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2332 /* set the properties of a control */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2333 static Lisp_Object
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2334 mswindows_widget_set_property (Lisp_Object image_instance, Lisp_Object prop,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2335 Lisp_Object val)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2336 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2337 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2338
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2339 if (EQ (prop, Qtext))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2340 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2341 Extbyte* lparam=0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2342 CHECK_STRING (val);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2343 GET_C_STRING_OS_DATA_ALLOCA (val, lparam);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2344 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2345 WM_SETTEXT, 0, (LPARAM)lparam);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2346 return Qt;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2347 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2348 return Qunbound;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2349 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2350
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2351
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2352 /************************************************************************/
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2353 /* initialization */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2354 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2355
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2356 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2357 syms_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2358 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
2359 defkeyword (&Q_resource_id, ":resource-id");
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
2360 defkeyword (&Q_resource_type, ":resource-type");
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2361 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2362
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2363 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2364 console_type_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2365 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2366 /* image methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2367
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2368 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2369 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2370 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2371 CONSOLE_HAS_METHOD (mswindows, map_subwindow);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2372 CONSOLE_HAS_METHOD (mswindows, update_subwindow);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2373 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2374 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2375 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2376 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2377 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2378
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2379 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2380 image_instantiator_format_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2381 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2382 /* image-instantiator types */
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2383 #ifdef HAVE_XPM
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2384 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2385 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2386 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2387 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2388 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2389
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2390 INITIALIZE_DEVICE_IIFORMAT (mswindows, button);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2391 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2392 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2393
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2394 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2395 IIFORMAT_HAS_DEVMETHOD (mswindows, edit, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2396
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2397 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2398 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2399
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2400 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2401 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2402 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, set_property);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2403 #if 0
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2404 INITIALIZE_DEVICE_IIFORMAT (mswindows, group);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2405 IIFORMAT_HAS_DEVMETHOD (mswindows, group, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2406 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2407 INITIALIZE_DEVICE_IIFORMAT (mswindows, label);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2408 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2409
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2410 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2411 IIFORMAT_HAS_DEVMETHOD (mswindows, combo, property);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2412 IIFORMAT_HAS_DEVMETHOD (mswindows, combo, instantiate);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2413
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2414 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2415 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2416
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2417 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2418
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2419 IIFORMAT_HAS_METHOD (bmp, validate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2420 IIFORMAT_HAS_METHOD (bmp, normalize);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2421 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2422 IIFORMAT_HAS_METHOD (bmp, instantiate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2423
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2424 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2425 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
2426
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2427 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource,
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2428 "mswindows-resource");
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
2429
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2430 IIFORMAT_HAS_METHOD (mswindows_resource, validate);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2431 IIFORMAT_HAS_METHOD (mswindows_resource, normalize);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2432 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2433 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
2434
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2435 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type,
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
2436 check_valid_resource_symbol);
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2437 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2438 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2439 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2440
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2441 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2442 vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2443 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2444 Fprovide (Qbmp);
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
2445 Fprovide (Qmswindows_resource);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2446 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2447 A list of the directories in which mswindows bitmap files may be found.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2448 This is used by the `make-image-instance' function.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2449 */ );
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2450 Vmswindows_bitmap_file_path = Qnil;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2451
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2452 Fprovide (Qbutton);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2453 Fprovide (Qedit);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2454 Fprovide (Qcombo);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2455 Fprovide (Qscrollbar);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
2456 Fprovide (Qlabel);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2457 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2458
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2459 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2460 complex_vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2461 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2462 }