annotate src/glyphs-msw.c @ 396:6719134a07c2 r21-2-13

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