annotate src/glyphs-msw.c @ 418:e804706bfb8c r21-2-17

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