annotate src/glyphs-msw.c @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c42ec1d1cded
children 57709be46d1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1 /* mswindows-specific Lisp 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
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
23 /* written by Andy Piper <andyp@parallax.co.uk> plagerising buts from
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"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
29 #include "console-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
30 #include "glyphs-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
31 #include "objects-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
32
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
33 #include "buffer.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
34 #include "frame.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
35 #include "insdel.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
36 #include "opaque.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
37 #include "sysfile.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
38 #include "faces.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
39 #include "imgproc.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
40
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
41 #ifdef FILE_CODING
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
42 #include "file-coding.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
43 #endif
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
44
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
45 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
46 Lisp_Object Qbmp;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
47 Lisp_Object Vmswindows_bitmap_file_path;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
48 static COLORREF transparent_color = RGB (1,1,1);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
49
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
50 DEFINE_IMAGE_INSTANTIATOR_FORMAT (cursor);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
51 Lisp_Object Qcursor;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
52 Lisp_Object Q_resource_type, Q_resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
53
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
54 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
55 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
56 enum image_instance_type type);
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
57 static void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
58 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
59 struct frame* f);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
60
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
61 COLORREF mswindows_string_to_color (CONST char *name);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
62
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
63 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
64 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
65 /* proper display */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
66 /************************************************************************/
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
67 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
68 int width, int height,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
69 unsigned char *pic,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
70 int *bit_count,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
71 unsigned char** bmp_data)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
72 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
73 struct device *d = XDEVICE (device);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
74 int i,j;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
75 RGBQUAD* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
76 int ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
77 BITMAPINFO* bmp_info;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
78 unsigned char *ip, *dp;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
79
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
80 if (DEVICE_MSWINDOWS_BITSPIXEL (d) > 0)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
81 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
82 int bpline=(int)(~3UL & (unsigned long)((width*3) +3));
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
83 /* FIXME: we can do this because 24bpp implies no colour table, once
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
84 * we start paletizing this is no longer true. The X versions of
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
85 * this function quantises to 256 colours or bit masks down to a
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
86 * 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
87 * don't see much point trying to optimize down to the best
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
88 * structure - unless it has memory / color allocation implications
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
89 * .... */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
90 bmp_info=xnew_and_zero (BITMAPINFO);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
91
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
92 if (!bmp_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
93 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
94 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
95 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
96
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
97 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
98 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
99 bmp_info->bmiHeader.biSizeImage=width*height*3;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
100
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
101 /* bitmap data needs to be in blue, green, red triples - in that
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
102 order, eimage is in RGB format so we need to convert */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
103 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
104 *bit_count = bpline * height;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
105
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
106 if (!bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
107 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
108 xfree (bmp_info);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
109 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
110 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
111
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
112 ip = pic;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
113 for (i = height-1; i >= 0; i--) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
114 dp = (*bmp_data) + (i * bpline);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
115 for (j = 0; j < width; j++) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
116 dp[2] =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
117 dp[1] =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
118 *dp =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
119 dp += 3;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
120 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
121 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
122 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
123 else /* scale to 256 colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
124 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
125 int rd,gr,bl;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
126 quant_table *qtable;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
127 int bpline= (int)(~3UL & (unsigned long)(width +3));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
128 /* Quantize the image and get a histogram while we're at it.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
129 Do this first to save memory */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
130 qtable = build_EImage_quantable(pic, width, height, 256);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
131 if (qtable == NULL) return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
132
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
133 /* use our quantize table to allocate the colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
134 ncolors = qtable->num_active_colors;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
135 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) +
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
136 sizeof(RGBQUAD) * ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
137 if (!bmp_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
138 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
139 xfree (qtable);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
140 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
141 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
142
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
143 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
144
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
145 bmp_info->bmiHeader.biBitCount=8;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
146 bmp_info->bmiHeader.biCompression=BI_RGB;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
147 bmp_info->bmiHeader.biSizeImage=bpline*height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
148 bmp_info->bmiHeader.biClrUsed=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
149 bmp_info->bmiHeader.biClrImportant=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
150
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
151 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
152 *bit_count = bpline * height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
153
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
154 if (!*bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
155 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
156 xfree (qtable);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
157 xfree (bmp_info);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
158 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
159 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
160
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
161 /* build up an RGBQUAD colortable */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
162 for (i = 0; i < qtable->num_active_colors; i++) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
163 colortbl[i].rgbRed = qtable->rm[i];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
164 colortbl[i].rgbGreen = qtable->gm[i];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
165 colortbl[i].rgbBlue = qtable->bm[i];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
166 colortbl[i].rgbReserved = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
167 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
168
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
169 /* now build up the data. picture has to be upside-down and
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
170 back-to-front for msw bitmaps */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
171 ip = pic;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
172 for (i = height-1; i >= 0; i--) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
173 dp = (*bmp_data) + (i * bpline);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
174 for (j = 0; j < width; j++) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
175 rd = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
176 gr = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
177 bl = *ip++;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
178 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
179 }
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);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
182 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
183 /* fix up the standard stuff */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
184 bmp_info->bmiHeader.biWidth=width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
185 bmp_info->bmiHeader.biHeight=height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
186 bmp_info->bmiHeader.biPlanes=1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
187 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
188 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
189 bmp_info->bmiHeader.biYPelsPerMeter=0;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
190
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
191 return bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
192 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
193
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
194 /* Given a pixmap filename, look through all of the "standard" places
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
195 where the file might be located. Return a full pathname if found;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
196 otherwise, return Qnil. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
197
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
198 static Lisp_Object
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
199 mswindows_locate_pixmap_file (Lisp_Object name)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
200 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
201 /* This function can GC if IN_REDISPLAY is false */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
202 Lisp_Object found;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
203
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
204 /* Check non-absolute pathnames with a directory component relative to
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
205 the search path; that's the way Xt does it. */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
206 if (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 0)) ||
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
207 (XSTRING_BYTE (name, 0) == '.' &&
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
208 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) ||
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
209 (XSTRING_BYTE (name, 1) == '.' &&
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
210 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2)))))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
211 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
212 if (!NILP (Ffile_readable_p (name)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
213 return name;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
214 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
215 return Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
216 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
217
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
218 if (locate_file (Vmswindows_bitmap_file_path, name, "", &found, R_OK) < 0)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
219 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
220 Lisp_Object temp = list1 (Vdata_directory);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
221 struct gcpro gcpro1;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
222
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
223 GCPRO1 (temp);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
224 locate_file (temp, name, "", &found, R_OK);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
225 UNGCPRO;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
226 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
227
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
228 return found;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
229 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
230
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
231
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
232 /* Initialize an image instance from a bitmap
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
233
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
234 DEST_MASK specifies the mask of allowed image types.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
235
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
236 If this fails, signal an error. INSTANTIATOR is only used
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
237 in the error message. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
238
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
239 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
240 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
241 BITMAPINFO *bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
242 int dest_mask,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
243 void *bmp_data,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
244 int bmp_bits,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
245 Lisp_Object instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
246 int x_hot, int y_hot,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
247 int create_mask)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
248 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
249 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
250 struct device *d = XDEVICE (device);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
251 struct frame *f = XFRAME (DEVICE_SELECTED_FRAME (d));
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
252 void* bmp_buf=0;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
253 int type;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
254 HBITMAP bitmap;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
255 HDC hdc;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
256
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
257 if (!DEVICE_MSWINDOWS_P (d))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
258 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
259
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
260 if (NILP (DEVICE_SELECTED_FRAME (d)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
261 signal_simple_error ("No selected frame on mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
262
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
263 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
264 type = IMAGE_COLOR_PIXMAP;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
265 else if (dest_mask & IMAGE_POINTER_MASK)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
266 type = IMAGE_POINTER;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
267 else
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
268 incompatible_image_types (instantiator, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
269 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
270 hdc = FRAME_MSWINDOWS_DC (f);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
271
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
272 bitmap=CreateDIBSection (hdc,
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
273 bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
274 DIB_RGB_COLORS,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
275 &bmp_buf,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
276 0,0);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
277
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
278 if (!bitmap || !bmp_buf)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
279 signal_simple_error ("Unable to create bitmap", instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
280
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
281 /* copy in the actual bitmap */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
282 memcpy (bmp_buf, bmp_data, bmp_bits);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
283
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
284 mswindows_initialize_dibitmap_image_instance (ii, type);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
285
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
286 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
287 find_keyword_in_vector (instantiator, Q_file);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
288
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
289 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
290 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
291 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
292 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
293 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
294 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
295 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
296
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
297 if (create_mask)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
298 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
299 mswindows_initialize_image_instance_mask (ii, f);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
300 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
301
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
302 if (type == IMAGE_POINTER)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
303 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
304 mswindows_initialize_image_instance_icon(ii, TRUE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
305 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
306 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
307
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
308 static void
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
309 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
310 int width, int height,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
311 unsigned char *eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
312 int dest_mask,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
313 Lisp_Object instantiator,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
314 Lisp_Object domain)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
315 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
316 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
317 BITMAPINFO* bmp_info;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
318 unsigned char* bmp_data;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
319 int bmp_bits;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
320 COLORREF bkcolor;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
321
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
322 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
323 signal_simple_error ("Not an mswindows device", device);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
324
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
325 /* this is a hack but MaskBlt and TransparentBlt are not supported
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
326 on most windows variants */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
327 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
328 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
329
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
330 /* build a bitmap from the eimage */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
331 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
332 &bmp_bits, &bmp_data)))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
333 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
334 signal_simple_error ("EImage to DIBitmap conversion failed",
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
335 instantiator);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
336 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
337
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
338 /* Now create the pixmap and set up the image instance */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
339 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
340 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
341 0, 0, 0);
278
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 xfree (bmp_info);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
344 xfree (bmp_data);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
345 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
346
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
347 static void set_mono_pixel ( unsigned char* bits,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
348 int bpline, int height,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
349 int x, int y, int white )
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
350 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
351 int index;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
352 unsigned char bitnum;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
353 /* Find the byte on which this scanline begins */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
354 index = (height - y - 1) * bpline;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
355 /* Find the byte containing this pixel */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
356 index += (x >> 3);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
357 /* Which bit is it? */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
358 bitnum = (unsigned char)( 7 - (x % 8) );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
359 if( white ) /* Turn it on */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
360 bits[index] |= (1<<bitnum);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
361 else /* Turn it off */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
362 bits[index] &= ~(1<<bitnum);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
363 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
364
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
365 static void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
366 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
367 struct frame* f)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
368 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
369 HBITMAP mask;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
370 HGDIOBJ old = NULL;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
371 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
372 BITMAPINFO* bmp_info =
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
373 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
374 int i, j;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
375 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
376
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
377 void* and_bits;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
378 int bpline= (int)(~3UL & (unsigned long)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
379 (((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8) +3));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
380
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
381 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
382 bmp_info->bmiHeader.biHeight = height;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
383 bmp_info->bmiHeader.biPlanes=1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
384 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
385 bmp_info->bmiHeader.biBitCount=1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
386 bmp_info->bmiHeader.biCompression=BI_RGB;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
387 bmp_info->bmiHeader.biClrUsed = 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
388 bmp_info->bmiHeader.biClrImportant = 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
389 bmp_info->bmiHeader.biSizeImage = height * bpline;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
390 bmp_info->bmiColors[0].rgbRed = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
391 bmp_info->bmiColors[0].rgbGreen = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
392 bmp_info->bmiColors[0].rgbBlue = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
393 bmp_info->bmiColors[0].rgbReserved = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
394 bmp_info->bmiColors[1].rgbRed = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
395 bmp_info->bmiColors[1].rgbGreen = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
396 bmp_info->bmiColors[1].rgbBlue = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
397 bmp_info->bmiColors[0].rgbReserved = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
398
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
399 if (!(mask = CreateDIBSection (hcdc,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
400 bmp_info,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
401 DIB_RGB_COLORS,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
402 &and_bits,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
403 0,0)))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
404 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
405 xfree (bmp_info);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
406 return;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
407 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
408
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
409 xfree (bmp_info);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
410 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image));
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
411
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
412 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
413 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
414 for(j=0; j<height; j++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
415 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
416 if( GetPixel( hcdc, i, j ) == transparent_color )
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
417 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
418 SetPixel( hcdc, i, j, RGB (0,0,0));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
419 set_mono_pixel( and_bits, bpline, height, i, j, TRUE );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
420 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
421 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
422 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
423 set_mono_pixel( and_bits, bpline, height, i, j, FALSE );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
424 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
425 }
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
426 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
427
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
428 GdiFlush();
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
429 SelectObject(hcdc, old);
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
430
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
431 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
432 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
433
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
434 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
435 mswindows_initialize_image_instance_icon (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
436 int cursor)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
437 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
438 ICONINFO x_icon;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
439
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
440 /* we rely on windows to do any resizing necessary */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
441 x_icon.fIcon=cursor ? FALSE : TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
442 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
443 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
444 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
445 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
446
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
447 IMAGE_INSTANCE_MSWINDOWS_ICON (image)=
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
448 CreateIconIndirect (&x_icon);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
449 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
450
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
451 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
452 mswindows_resize_dibitmap_instance (struct Lisp_Image_Instance* ii,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
453 struct frame* f,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
454 int newx, int newy)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
455 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
456 HBITMAP newbmp, newmask=NULL;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
457 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
458 HDC hdcDst = CreateCompatibleDC (hcdc);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
459
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
460 SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
461
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
462 newbmp = CreateCompatibleBitmap (hcdc, newx, newy);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
463
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
464 DeleteObject (SelectObject (hdcDst, newbmp) );
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
465
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
466 if (!StretchBlt (hdcDst, 0, 0, newx, newy,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
467 hcdc, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
468 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
469 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
470 SRCCOPY))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
471 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
472 return FALSE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
473 }
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
474
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
475 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
476 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
477 SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
478 newmask = CreateCompatibleBitmap(hcdc, newx, newy);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
479 SelectObject (hdcDst, newmask);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
480
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
481 if (!StretchBlt(hdcDst, 0, 0, newx, newy,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
482 hcdc, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
483 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
484 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
485 SRCCOPY))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
486 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
487 return FALSE;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
488 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
489 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
490
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
491 SelectObject (hdcDst, 0);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
492 SelectObject (hcdc, 0);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
493
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
494 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
495 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
496 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
497 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
498
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
499 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = newbmp;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
500 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = newmask;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
501 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
502 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
503
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
504 DeleteDC (hdcDst);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
505
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
506 return TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
507 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
508
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
509 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
510 * XPM *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
511 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
512
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
513 #ifdef HAVE_XPM
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
514
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
515 struct color_symbol
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
516 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
517 char* name;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
518 COLORREF color;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
519 };
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
520
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
521 static struct color_symbol*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
522 extract_xpm_color_names (Lisp_Object device,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
523 Lisp_Object domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
524 Lisp_Object color_symbol_alist,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
525 int* nsymbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
526 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
527 /* This function can GC */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
528 Lisp_Object rest;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
529 Lisp_Object results = Qnil;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
530 int i, j;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
531 struct color_symbol *colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
532 struct gcpro gcpro1, gcpro2;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
533
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
534 GCPRO2 (results, device);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
535
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
536 /* We built up results to be (("name" . #<color>) ...) so that if an
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
537 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
538 leave any pixels allocated in the server. */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
539 i = 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
540 LIST_LOOP (rest, color_symbol_alist)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
541 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
542 Lisp_Object cons = XCAR (rest);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
543 Lisp_Object name = XCAR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
544 Lisp_Object value = XCDR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
545 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
546 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
547 if (STRINGP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
548 value =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
549 Fmake_color_instance
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
550 (value, device, encode_error_behavior_flag (ERROR_ME_NOT));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
551 else
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
552 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
553 assert (COLOR_SPECIFIERP (value));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
554 value = Fspecifier_instance (value, domain, Qnil, Qnil);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
555 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
556 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
557 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
558 results = noseeum_cons (noseeum_cons (name, value), results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
559 i++;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
560 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
561 UNGCPRO; /* no more evaluation */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
562
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
563 *nsymbols=i;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
564 if (i == 0) return 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
565
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
566 colortbl = xnew_array_and_zero (struct color_symbol, i);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
567
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
568 for (j=0; j<i; j++)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
569 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
570 Lisp_Object cons = XCAR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
571 colortbl[j].color =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
572 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
573
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
574 colortbl[j].name = (char *) XSTRING_DATA (XCAR (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
575 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
576 cons = results;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
577 results = XCDR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
578 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
579 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
580 return colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
581 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
582
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
583 static int xpm_to_eimage (Lisp_Object image, CONST Extbyte *buffer,
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
584 unsigned char** data,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
585 int* width, int* height,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
586 int* x_hot, int* y_hot,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
587 int* transp,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
588 struct color_symbol* color_symbols,
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
589 int nsymbols)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
590 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
591 XpmImage xpmimage;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
592 XpmInfo xpminfo;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
593 int result, i, j, transp_idx, maskbpline;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
594 unsigned char* dptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
595 unsigned int* sptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
596 COLORREF color; /* the american spelling virus hits again .. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
597 COLORREF* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
598
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
599 xzero (xpmimage);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
600 xzero (xpminfo);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
601 xpminfo.valuemask=XpmHotspot;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
602 *transp=FALSE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
603
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
604 result = XpmCreateXpmImageFromBuffer ((char*)buffer,
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
605 &xpmimage,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
606 &xpminfo);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
607 switch (result)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
608 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
609 case XpmSuccess:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
610 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
611 case XpmFileInvalid:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
612 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
613 signal_simple_error ("invalid XPM data", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
614 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
615 case XpmNoMemory:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
616 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
617 signal_double_file_error ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
618 "out of memory", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
619 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
620 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
621 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
622 signal_double_file_error_2 ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
623 "unknown error code",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
624 make_int (result), image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
625 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
626 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
627
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
628 *width = xpmimage.width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
629 *height = xpmimage.height;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
630 maskbpline = (int)(~3UL & (unsigned long)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
631 (((~7UL & (unsigned long)(*width + 7)) / 8) + 3));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
632
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
633 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
634
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
635 if (!*data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
636 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
637 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
638 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
639 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
640 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
641
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
642 /* build a color table to speed things up */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
643 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
644 if (!colortbl)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
645 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
646 xfree (*data);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
647 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
648 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
649 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
650 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
651
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
652 for (i=0; i<xpmimage.ncolors; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
653 {
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
654 /* pick up symbolic colors */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
655 if (xpmimage.colorTable[i].c_color == 0
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
656 &&
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
657 xpmimage.colorTable[i].symbolic != 0)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
658 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
659 if (!color_symbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
660 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
661 xfree (*data);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
662 xfree (colortbl);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
663 XpmFreeXpmImage (&xpmimage);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
664 XpmFreeXpmInfo (&xpminfo);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
665 return 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
666 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
667 for (j = 0; j<nsymbols; j++)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
668 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
669 if (!strcmp (xpmimage.colorTable[i].symbolic,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
670 color_symbols[j].name ))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
671 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
672 colortbl[i]=color_symbols[j].color;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
673 }
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 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
676 /* pick up transparencies */
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
677 else if (!strcasecmp (xpmimage.colorTable[i].c_color,"None")
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
678 ||
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
679 (xpmimage.colorTable[i].symbolic
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
680 &&
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
681 (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
682 ||
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
683 !strcasecmp (xpmimage.colorTable[i].symbolic,"None"))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
684 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
685 *transp=TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
686 colortbl[i]=transparent_color;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
687 transp_idx=i;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
688 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
689 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
690 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
691 colortbl[i]=
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
692 mswindows_string_to_color (xpmimage.colorTable[i].c_color);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
693 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
694 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
695
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
696 /* convert the image */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
697 sptr=xpmimage.data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
698 dptr=*data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
699 for (i = 0; i< *width * *height; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
700 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
701 color = colortbl[*sptr++];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
702
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
703 /* split out the 0x02bbggrr colorref into an rgb triple */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
704 *dptr++=GetRValue (color); /* red */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
705 *dptr++=GetGValue (color); /* green */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
706 *dptr++=GetBValue (color); /* blue */
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
707 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
708
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
709 *x_hot=xpminfo.x_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
710 *y_hot=xpminfo.y_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
711
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
712 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
713 XpmFreeXpmInfo (&xpminfo);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
714 xfree (colortbl);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
715 return TRUE;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
716 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
717
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
718 static void
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
719 mswindows_xpm_instantiate (Lisp_Object image_instance,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
720 Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
721 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
722 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
723 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
724 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
725 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
726 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
727 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
728 unsigned char *eimage;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
729 int width, height, x_hot, y_hot;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
730 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
731 unsigned char* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
732 int bmp_bits;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
733 int nsymbols=0, transp;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
734 struct color_symbol* color_symbols=NULL;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
735
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
736 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
737 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
738 Q_color_symbols);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
739
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
740 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
741 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
742
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
743 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
744
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
745 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
746
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
747 /* in case we have color symbols */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
748 color_symbols = extract_xpm_color_names (device, domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
749 color_symbol_alist, &nsymbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
750
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
751 /* convert to an eimage to make processing easier */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
752 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
753 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
754 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
755 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
756 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
757 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
758
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
759 if (color_symbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
760 xfree(color_symbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
761
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
762 /* build a bitmap from the eimage */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
763 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
764 &bmp_bits, &bmp_data)))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
765 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
766 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
767 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
768 }
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
769 xfree (eimage);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
770
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
771 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
772 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
773 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
774 x_hot, y_hot, transp);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
775
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
776 xfree (bmp_info);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
777 xfree (bmp_data);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
778 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
779 #endif /* HAVE_XPM */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
780
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
781 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
782 * BMP *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
783 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
784
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
785 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
786 bmp_validate (Lisp_Object instantiator)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
787 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
788 file_or_data_must_be_present (instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
789 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
790
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
791 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
792 bmp_normalize (Lisp_Object inst, Lisp_Object console_type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
793 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
794 return simple_image_type_normalize (inst, console_type, Qbmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
795 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
796
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
797 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
798 bmp_possible_dest_types (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
799 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
800 return IMAGE_COLOR_PIXMAP_MASK;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
801 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
802
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
803 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
804 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
805 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
806 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
807 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
808 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
809 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
810 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
811 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
812 BITMAPFILEHEADER* bmp_file_header;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
813 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
814 void* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
815 int bmp_bits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
816 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
817
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
818 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
819 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
820
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
821 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
822
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
823 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
824
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
825 /* Then slurp the image into memory, decoding along the way.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
826 The result is the image in a simple one-byte-per-pixel
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
827 format. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
828
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
829 bmp_file_header=(BITMAPFILEHEADER*)bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
830 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
831 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
832 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
833
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
834 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
835 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
836 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
837 0, 0, 0);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
838 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
839
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
840
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
841 /**********************************************************************
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
842 * CURSORS *
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
843 **********************************************************************/
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
844
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
845 static void
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
846 cursor_validate (Lisp_Object instantiator)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
847 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
848 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
849 &&
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
850 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
851 ||
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
852 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
853 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
854 instantiator);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
855 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
856
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
857 static Lisp_Object
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
858 cursor_normalize (Lisp_Object inst, Lisp_Object console_type)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
859 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
860 /* This function can call lisp */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
861 Lisp_Object file = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
862 struct gcpro gcpro1, gcpro2;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
863 Lisp_Object alist = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
864
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
865 GCPRO2 (file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
866
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
867 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
868 console_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
869
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
870 if (CONSP (file)) /* failure locating filename */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
871 signal_double_file_error ("Opening pixmap file",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
872 "no such file or directory",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
873 Fcar (file));
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
874
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
875 if (NILP (file)) /* no conversion necessary */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
876 RETURN_UNGCPRO (inst);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
877
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
878 alist = tagged_vector_to_alist (inst);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
879
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
880 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
881 alist = remassq_no_quit (Q_file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
882 alist = Fcons (Fcons (Q_file, file), alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
883 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
884
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
885 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
886 Lisp_Object result = alist_to_tagged_vector (Qcursor, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
887 free_alist (alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
888 RETURN_UNGCPRO (result);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
889 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
890 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
891
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
892 static int
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
893 cursor_possible_dest_types (void)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
894 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
895 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
896 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
897
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
898 typedef struct
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
899 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
900 char *name;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
901 int resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
902 } resource_t;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
903
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
904 #ifndef OCR_ICOCUR
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
905 #define OCR_ICOCUR 32647
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
906 #define OIC_SAMPLE 32512
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
907 #define OIC_HAND 32513
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
908 #define OIC_QUES 32514
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
909 #define OIC_BANG 32515
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
910 #define OIC_NOTE 32516
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
911 #define OIC_WINLOGO 32517
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
912 #define LR_SHARED 0x8000
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
913 #endif
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
914
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
915 static CONST resource_t resource_table[] =
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
916 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
917 /* bitmaps */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
918 { "close", OBM_CLOSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
919 { "uparrow", OBM_UPARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
920 { "dnarrow", OBM_DNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
921 { "rgarrow", OBM_RGARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
922 { "lfarrow", OBM_LFARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
923 { "reduce", OBM_REDUCE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
924 { "zoom", OBM_ZOOM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
925 { "restore", OBM_RESTORE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
926 { "reduced", OBM_REDUCED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
927 { "zoomd", OBM_ZOOMD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
928 { "restored", OBM_RESTORED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
929 { "uparrowd", OBM_UPARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
930 { "dnarrowd", OBM_DNARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
931 { "rgarrowd", OBM_RGARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
932 { "lfarrowd", OBM_LFARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
933 { "mnarrow", OBM_MNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
934 { "combo", OBM_COMBO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
935 { "uparrowi", OBM_UPARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
936 { "dnarrowi", OBM_DNARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
937 { "rgarrowi", OBM_RGARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
938 { "lfarrowi", OBM_LFARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
939 { "size", OBM_SIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
940 { "btsize", OBM_BTSIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
941 { "check", OBM_CHECK },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
942 { "cehckboxes", OBM_CHECKBOXES },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
943 { "btncorners" , OBM_BTNCORNERS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
944 /* cursors */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
945 { "normal", OCR_NORMAL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
946 { "ibeam", OCR_IBEAM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
947 { "wait", OCR_WAIT },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
948 { "cross", OCR_CROSS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
949 { "up", OCR_UP },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
950 /* { "icon", OCR_ICON }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
951 { "sizenwse", OCR_SIZENWSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
952 { "sizenesw", OCR_SIZENESW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
953 { "sizewe", OCR_SIZEWE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
954 { "sizens", OCR_SIZENS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
955 { "sizeall", OCR_SIZEALL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
956 /* { "icour", OCR_ICOCUR }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
957 { "no", OCR_NO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
958 /* icons */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
959 { "sample", OIC_SAMPLE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
960 { "hand", OIC_HAND },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
961 { "ques", OIC_QUES },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
962 { "bang", OIC_BANG },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
963 { "note", OIC_NOTE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
964 { "winlogo", OIC_WINLOGO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
965 {0}
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
966 };
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 static int cursor_name_to_resource (Lisp_Object name)
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 CONST resource_t* res = resource_table;
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 if (INTP (name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
973 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
974 return XINT (name);
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 else if (!STRINGP (name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
977 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
978 signal_simple_error ("invalid resource identifier", name);
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
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
981 do {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
982 if (!strcasecmp ((char*)res->name, XSTRING_DATA (name)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
983 return res->resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
984 } while ((++res)->name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
985 return 0;
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
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
988 static void
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
989 cursor_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
990 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
991 int dest_mask, Lisp_Object domain)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
992 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
993 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
994 unsigned int type = 0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
995 HANDLE himage = NULL;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
996 LPCTSTR resid=0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
997 int iitype=0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
998 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
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 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1001 Lisp_Object resource_type = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1002 Q_resource_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1003 Lisp_Object resource_id = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1004 Q_resource_id);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1005
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1006 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1007 signal_simple_error ("Not an mswindows device", device);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1008
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1009 assert (!NILP (resource_type) && !NILP (resource_id));
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 /* check the resource type */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1012 if (!SYMBOLP (resource_type))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1013 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1014 signal_simple_error ("invalid resource type", resource_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1015 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1016 if (!strcmp ((char *) string_data (XSYMBOL (resource_type)->name),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1017 "bitmap"))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1018 type = IMAGE_BITMAP;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1019 else if (!strcmp ((char *) string_data (XSYMBOL (resource_type)->name),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1020 "cursor"))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1021 type = IMAGE_CURSOR;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1022 else if (!strcmp ((char *) string_data (XSYMBOL (resource_type)->name),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1023 "icon"))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1024 type = IMAGE_ICON;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1025 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1026 signal_simple_error ("invalid resource type", resource_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1027
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1028 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1029 iitype = IMAGE_POINTER;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1030 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1031 iitype = IMAGE_COLOR_PIXMAP;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1032 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1033 incompatible_image_types (instantiator, dest_mask,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1034 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1035
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1036 if (!NILP (file))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1037 resid = (LPCTSTR)XSTRING_DATA (file);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1038 else if (!(resid = MAKEINTRESOURCE(cursor_name_to_resource (resource_id))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1039 signal_simple_error ("invalid resource id", resource_id);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1040
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1041 /* load the image */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1042 if (!(himage = LoadImage (NULL, resid, type, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1043 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1044 LR_SHARED |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1045 (!NILP (file) ? LR_LOADFROMFILE : 0))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1046 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1047 signal_simple_error ("cannot load image", instantiator);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1048 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1049
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1050 mswindows_initialize_dibitmap_image_instance (ii, iitype);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1051
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1052 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1053 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = (type==IMAGE_BITMAP ? himage : NULL);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1054 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1055 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = (type!=IMAGE_BITMAP ? himage : NULL);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1056 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1057 (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1058 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1059 (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1060 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1061 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1062 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1063 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1064
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1065 void
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1066 check_valid_symbol (Lisp_Object data)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1067 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1068 CHECK_SYMBOL (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1069 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1070
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1071 void
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1072 check_valid_string_or_int (Lisp_Object data)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1073 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1074 if (!INTP (data))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1075 CHECK_STRING (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1076 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1077 CHECK_INT (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1078 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1079
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1080
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1081 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1082 /* image instance methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1083 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1084
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1085 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1086 mswindows_print_image_instance (struct Lisp_Image_Instance *p,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1087 Lisp_Object printcharfun,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1088 int escapeflag)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1089 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1090 char buf[100];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1091
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1092 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1093 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1094 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1095 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1096 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1097 sprintf (buf, " (0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1098 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1099 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1100 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1101 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1102 sprintf (buf, "/0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1103 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1104 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1105 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1106 write_c_string (")", printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1107 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1108 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1109 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1110 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1111 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1112
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1113 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1114 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1115 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1116 if (!p->data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1117 return;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1118
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1119 if (DEVICE_LIVE_P (XDEVICE (p->device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1120 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1121 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p))
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
1122 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1123 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1124 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1125 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1126 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1127 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1128 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1129 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1130 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1131
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1132 xfree (p->data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1133 p->data = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1134 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1135
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1136 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1137 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1138 struct Lisp_Image_Instance *p2, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1139 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1140 switch (IMAGE_INSTANCE_TYPE (p1))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1141 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1142 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1143 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1144 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1145 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1146 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1147 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1148 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1149 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1150 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1151 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1152
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1153 return 1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1154 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1155
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1156 static unsigned long
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1157 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1158 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1159 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1160 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1161 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1162 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1163 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1164 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1165 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1166 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1167 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1168 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1169
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1170 /* Set all the slots in an image instance structure to reasonable
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1171 default values. This is used somewhere within an instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1172 method. It is assumed that the device slot within the image
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1173 instance is already set -- this is the case when instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1174 methods are called. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1175
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1176 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1177 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1178 enum image_instance_type type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1179 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1180 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1181 IMAGE_INSTANCE_TYPE (ii) = type;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1182 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1183 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1184 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1185 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1186 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1187 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1188 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1189
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1190
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1191 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1192 /* initialization */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1193 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1194
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1195 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1196 syms_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1197 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1198 defkeyword (&Q_resource_id, ":resource-id");
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1199 defkeyword (&Q_resource_type, ":resource-type");
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1200 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1201
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1202 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1203 console_type_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1204 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1205 /* image methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1206
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1207 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1208 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1209 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1210 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1211 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1212 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1213 #ifdef HAVE_XPM
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1214 CONSOLE_HAS_METHOD (mswindows, xpm_instantiate);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1215 #endif
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1216 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1217
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1218 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1219 image_instantiator_format_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1220 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1221 /* image-instantiator types */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1222
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1223 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1224
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1225 IIFORMAT_HAS_METHOD (bmp, validate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1226 IIFORMAT_HAS_METHOD (bmp, normalize);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1227 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1228 IIFORMAT_HAS_METHOD (bmp, instantiate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1229
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1230 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1231 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1232
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1233 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (cursor, "cursor");
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1234
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1235 IIFORMAT_HAS_METHOD (cursor, validate);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1236 IIFORMAT_HAS_METHOD (cursor, normalize);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1237 IIFORMAT_HAS_METHOD (cursor, possible_dest_types);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1238 IIFORMAT_HAS_METHOD (cursor, instantiate);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1239
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1240 IIFORMAT_VALID_KEYWORD (cursor, Q_resource_type, check_valid_symbol);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1241 IIFORMAT_VALID_KEYWORD (cursor, Q_resource_id, check_valid_string_or_int);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1242 IIFORMAT_VALID_KEYWORD (cursor, Q_file, check_valid_string);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1243 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1244
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1245 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1246 vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1247 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1248 Fprovide (Qbmp);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1249 Fprovide (Qcursor);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1250 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1251 A list of the directories in which mswindows bitmap files may be found.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1252 This is used by the `make-image-instance' function.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1253 */ );
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1254 Vmswindows_bitmap_file_path = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1255 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1256
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1257 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1258 complex_vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1259 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1260 }