comparison src/glyphs-msw.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 6719134a07c2
children a86b2b5e0111
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
1 /* mswindows-specific glyph objects. 1 /* mswindows-specific glyph objects.
2 Copyright (C) 1998 Andy Piper. 2 Copyright (C) 1998, 1999, 2000 Andy Piper.
3 3
4 This file is part of XEmacs. 4 This file is part of XEmacs.
5 5
6 XEmacs is free software; you can redistribute it and/or modify it 6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any 8 Free Software Foundation; either version 2, or (at your option) any
51 #include <setjmp.h> 51 #include <setjmp.h>
52 #endif 52 #endif
53 53
54 #define WIDGET_GLYPH_SLOT 0 54 #define WIDGET_GLYPH_SLOT 0
55 55
56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
58 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
60 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout);
61 #ifdef HAVE_JPEG
62 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
63 #endif
64 #ifdef HAVE_TIFF
65 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
66 #endif
67 #ifdef HAVE_PNG
68 DECLARE_IMAGE_INSTANTIATOR_FORMAT (png);
69 #endif
70 #ifdef HAVE_GIF
71 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
72 #endif
56 #ifdef HAVE_XPM 73 #ifdef HAVE_XPM
57 DEFINE_DEVICE_IIFORMAT (mswindows, xpm); 74 DEFINE_DEVICE_IIFORMAT (mswindows, xpm);
58 #endif 75 #endif
59 DEFINE_DEVICE_IIFORMAT (mswindows, xbm); 76 DEFINE_DEVICE_IIFORMAT (mswindows, xbm);
60 #ifdef HAVE_XFACE 77 #ifdef HAVE_XFACE
61 DEFINE_DEVICE_IIFORMAT (mswindows, xface); 78 DEFINE_DEVICE_IIFORMAT (mswindows, xface);
62 #endif 79 #endif
63 DEFINE_DEVICE_IIFORMAT (mswindows, button); 80 DEFINE_DEVICE_IIFORMAT (mswindows, button);
64 DEFINE_DEVICE_IIFORMAT (mswindows, edit); 81 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field);
65 #if 0
66 DEFINE_DEVICE_IIFORMAT (mswindows, group);
67 #endif
68 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow); 82 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow);
69 DEFINE_DEVICE_IIFORMAT (mswindows, widget); 83 DEFINE_DEVICE_IIFORMAT (mswindows, widget);
70 DEFINE_DEVICE_IIFORMAT (mswindows, label); 84 DEFINE_DEVICE_IIFORMAT (mswindows, label);
71 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar); 85 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar);
72 DEFINE_DEVICE_IIFORMAT (mswindows, combo); 86 DEFINE_DEVICE_IIFORMAT (mswindows, combo_box);
73 DEFINE_DEVICE_IIFORMAT (mswindows, progress); 87 DEFINE_DEVICE_IIFORMAT (mswindows, progress_gauge);
88 DEFINE_DEVICE_IIFORMAT (mswindows, tree_view);
89 DEFINE_DEVICE_IIFORMAT (mswindows, tab_control);
74 90
75 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp); 91 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp);
76 Lisp_Object Qbmp; 92 Lisp_Object Qbmp;
77 Lisp_Object Vmswindows_bitmap_file_path; 93 Lisp_Object Vmswindows_bitmap_file_path;
78 static COLORREF transparent_color = RGB (1,1,1); 94 static COLORREF transparent_color = RGB (1,1,1);
80 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource); 96 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource);
81 Lisp_Object Q_resource_type, Q_resource_id; 97 Lisp_Object Q_resource_type, Q_resource_id;
82 Lisp_Object Qmswindows_resource; 98 Lisp_Object Qmswindows_resource;
83 99
84 static void 100 static void
85 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, 101 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii,
86 enum image_instance_type type); 102 int slices,
87 static void 103 enum image_instance_type type);
88 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, 104 static void
105 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image,
89 struct frame* f); 106 struct frame* f);
90
91 COLORREF mswindows_string_to_color (CONST char *name);
92 107
93 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) 108 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3)))
94 109
95 /************************************************************************/ 110 /************************************************************************/
96 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ 111 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
118 * long. Windows can actually handle rgb triples in the raw so I 133 * long. Windows can actually handle rgb triples in the raw so I
119 * don't see much point trying to optimize down to the best 134 * don't see much point trying to optimize down to the best
120 * structure - unless it has memory / color allocation implications 135 * structure - unless it has memory / color allocation implications
121 * .... */ 136 * .... */
122 bmp_info=xnew_and_zero (BITMAPINFO); 137 bmp_info=xnew_and_zero (BITMAPINFO);
123 138
124 if (!bmp_info) 139 if (!bmp_info)
125 { 140 {
126 return NULL; 141 return NULL;
127 } 142 }
128 143
129 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */ 144 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */
130 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */ 145 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */
131 bmp_info->bmiHeader.biSizeImage=width*height*3; 146 bmp_info->bmiHeader.biSizeImage=width*height*3;
132 147
133 /* bitmap data needs to be in blue, green, red triples - in that 148 /* bitmap data needs to be in blue, green, red triples - in that
134 order, eimage is in RGB format so we need to convert */ 149 order, eimage is in RGB format so we need to convert */
135 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height); 150 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
136 *bit_count = bpline * height; 151 *bit_count = bpline * height;
162 qtable = build_EImage_quantable(pic, width, height, 256); 177 qtable = build_EImage_quantable(pic, width, height, 256);
163 if (qtable == NULL) return NULL; 178 if (qtable == NULL) return NULL;
164 179
165 /* use our quantize table to allocate the colors */ 180 /* use our quantize table to allocate the colors */
166 ncolors = qtable->num_active_colors; 181 ncolors = qtable->num_active_colors;
167 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) + 182 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) +
168 sizeof(RGBQUAD) * ncolors); 183 sizeof(RGBQUAD) * ncolors);
169 if (!bmp_info) 184 if (!bmp_info)
170 { 185 {
171 xfree (qtable); 186 xfree (qtable);
172 return NULL; 187 return NULL;
173 } 188 }
174 189
175 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER)); 190 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
176 191
177 bmp_info->bmiHeader.biBitCount=8; 192 bmp_info->bmiHeader.biBitCount=8;
178 bmp_info->bmiHeader.biCompression=BI_RGB; 193 bmp_info->bmiHeader.biCompression=BI_RGB;
179 bmp_info->bmiHeader.biSizeImage=bpline*height; 194 bmp_info->bmiHeader.biSizeImage=bpline*height;
180 bmp_info->bmiHeader.biClrUsed=ncolors; 195 bmp_info->bmiHeader.biClrUsed=ncolors;
181 bmp_info->bmiHeader.biClrImportant=ncolors; 196 bmp_info->bmiHeader.biClrImportant=ncolors;
182 197
183 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height); 198 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
184 *bit_count = bpline * height; 199 *bit_count = bpline * height;
185 200
186 if (!*bmp_data) 201 if (!*bmp_data)
187 { 202 {
188 xfree (qtable); 203 xfree (qtable);
189 xfree (bmp_info); 204 xfree (bmp_info);
190 return NULL; 205 return NULL;
191 } 206 }
192 207
193 /* build up an RGBQUAD colortable */ 208 /* build up an RGBQUAD colortable */
194 for (i = 0; i < qtable->num_active_colors; i++) { 209 for (i = 0; i < qtable->num_active_colors; i++) {
195 colortbl[i].rgbRed = (BYTE) qtable->rm[i]; 210 colortbl[i].rgbRed = (BYTE) qtable->rm[i];
196 colortbl[i].rgbGreen = (BYTE) qtable->gm[i]; 211 colortbl[i].rgbGreen = (BYTE) qtable->gm[i];
197 colortbl[i].rgbBlue = (BYTE) qtable->bm[i]; 212 colortbl[i].rgbBlue = (BYTE) qtable->bm[i];
209 bl = *ip++; 224 bl = *ip++;
210 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl); 225 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl);
211 } 226 }
212 } 227 }
213 xfree (qtable); 228 xfree (qtable);
214 } 229 }
215 /* fix up the standard stuff */ 230 /* fix up the standard stuff */
216 bmp_info->bmiHeader.biWidth=width; 231 bmp_info->bmiHeader.biWidth=width;
217 bmp_info->bmiHeader.biHeight=height; 232 bmp_info->bmiHeader.biHeight=height;
218 bmp_info->bmiHeader.biPlanes=1; 233 bmp_info->bmiHeader.biPlanes=1;
219 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); 234 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
220 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */ 235 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */
221 bmp_info->bmiHeader.biYPelsPerMeter=0; 236 bmp_info->bmiHeader.biYPelsPerMeter=0;
222 237
223 return bmp_info; 238 return bmp_info;
224 } 239 }
225 240
226 /* Given a pixmap filename, look through all of the "standard" places 241 /* Given a pixmap filename, look through all of the "standard" places
240 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) || 255 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) ||
241 (XSTRING_BYTE (name, 1) == '.' && 256 (XSTRING_BYTE (name, 1) == '.' &&
242 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2))))))) 257 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2)))))))
243 { 258 {
244 if (!NILP (Ffile_readable_p (name))) 259 if (!NILP (Ffile_readable_p (name)))
245 return name; 260 return Fexpand_file_name (name, Qnil);
246 else 261 else
247 return Qnil; 262 return Qnil;
248 } 263 }
249 264
250 if (locate_file (Vmswindows_bitmap_file_path, name, "", &found, R_OK) < 0) 265 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0)
251 { 266 {
252 Lisp_Object temp = list1 (Vdata_directory); 267 Lisp_Object temp = list1 (Vdata_directory);
253 struct gcpro gcpro1; 268 struct gcpro gcpro1;
254 269
255 GCPRO1 (temp); 270 GCPRO1 (temp);
256 locate_file (temp, name, "", &found, R_OK); 271 locate_file (temp, name, Qnil, &found, R_OK);
257 UNGCPRO; 272 UNGCPRO;
258 } 273 }
259 274
260 return found; 275 return found;
261 } 276 }
262 277
263 278
264 /* Initialize an image instance from a bitmap 279 /* Initialize an image instance from a bitmap
267 282
268 If this fails, signal an error. INSTANTIATOR is only used 283 If this fails, signal an error. INSTANTIATOR is only used
269 in the error message. */ 284 in the error message. */
270 285
271 static void 286 static void
272 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii, 287 init_image_instance_from_dibitmap (Lisp_Image_Instance *ii,
273 BITMAPINFO *bmp_info, 288 BITMAPINFO *bmp_info,
274 int dest_mask, 289 int dest_mask,
275 void *bmp_data, 290 void *bmp_data,
276 int bmp_bits, 291 int bmp_bits,
277 Lisp_Object instantiator, 292 int slices,
293 Lisp_Object instantiator,
278 int x_hot, int y_hot, 294 int x_hot, int y_hot,
279 int create_mask) 295 int create_mask)
280 { 296 {
281 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 297 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
282 struct device *d = XDEVICE (device); 298 struct device *d = XDEVICE (device);
283 struct frame *f; 299 struct frame *f;
284 void* bmp_buf=0; 300 void* bmp_buf=0;
285 int type; 301 int type = 0;
286 HBITMAP bitmap; 302 HBITMAP bitmap;
287 HDC hdc; 303 HDC hdc;
288 304
289 if (!DEVICE_MSWINDOWS_P (d)) 305 if (!DEVICE_MSWINDOWS_P (d))
290 signal_simple_error ("Not an mswindows device", device); 306 signal_simple_error ("Not an mswindows device", device);
291 307
292 if (NILP (DEVICE_SELECTED_FRAME (d))) 308 if (NILP (DEVICE_SELECTED_FRAME (d)))
293 signal_simple_error ("No selected frame on mswindows device", device); 309 signal_simple_error ("No selected frame on mswindows device", device);
294 310
295 f = XFRAME (DEVICE_SELECTED_FRAME (d)); 311 f = XFRAME (DEVICE_SELECTED_FRAME (d));
296 312
297 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) 313 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
298 type = IMAGE_COLOR_PIXMAP; 314 type = IMAGE_COLOR_PIXMAP;
299 else if (dest_mask & IMAGE_POINTER_MASK) 315 else if (dest_mask & IMAGE_POINTER_MASK)
300 type = IMAGE_POINTER; 316 type = IMAGE_POINTER;
301 else 317 else
302 incompatible_image_types (instantiator, dest_mask, 318 incompatible_image_types (instantiator, dest_mask,
303 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); 319 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
304 hdc = FRAME_MSWINDOWS_CDC (f); 320 hdc = FRAME_MSWINDOWS_CDC (f);
305 321
306 bitmap=CreateDIBSection (hdc, 322 bitmap=CreateDIBSection (hdc,
307 bmp_info, 323 bmp_info,
308 DIB_RGB_COLORS, 324 DIB_RGB_COLORS,
309 &bmp_buf, 325 &bmp_buf,
310 0,0); 326 0,0);
311 327
312 if (!bitmap || !bmp_buf) 328 if (!bitmap || !bmp_buf)
313 signal_simple_error ("Unable to create bitmap", instantiator); 329 signal_simple_error ("Unable to create bitmap", instantiator);
314 330
315 /* copy in the actual bitmap */ 331 /* copy in the actual bitmap */
316 memcpy (bmp_buf, bmp_data, bmp_bits); 332 memcpy (bmp_buf, bmp_data, bmp_bits);
317 333
318 mswindows_initialize_dibitmap_image_instance (ii, type); 334 mswindows_initialize_dibitmap_image_instance (ii, slices, type);
319 335
320 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = 336 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
321 find_keyword_in_vector (instantiator, Q_file); 337 find_keyword_in_vector (instantiator, Q_file);
322 338
339 /* Fixup a set of bitmaps. */
323 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; 340 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
341
324 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; 342 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
325 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth; 343 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
326 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight; 344 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
327 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; 345 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
328 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot); 346 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot);
330 348
331 if (create_mask) 349 if (create_mask)
332 { 350 {
333 mswindows_initialize_image_instance_mask (ii, f); 351 mswindows_initialize_image_instance_mask (ii, f);
334 } 352 }
335 353
336 if (type == IMAGE_POINTER) 354 if (type == IMAGE_POINTER)
337 { 355 {
338 mswindows_initialize_image_instance_icon(ii, TRUE); 356 mswindows_initialize_image_instance_icon(ii, TRUE);
339 } 357 }
340 } 358 }
341 359
342 static void 360 static void
343 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii, 361 image_instance_add_dibitmap (Lisp_Image_Instance *ii,
362 BITMAPINFO *bmp_info,
363 void *bmp_data,
364 int bmp_bits,
365 int slice,
366 Lisp_Object instantiator)
367 {
368 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
369 struct device *d = XDEVICE (device);
370 struct frame *f = XFRAME (DEVICE_SELECTED_FRAME (d));
371 void* bmp_buf=0;
372 HDC hdc = FRAME_MSWINDOWS_CDC (f);
373 HBITMAP bitmap = CreateDIBSection (hdc,
374 bmp_info,
375 DIB_RGB_COLORS,
376 &bmp_buf,
377 0,0);
378
379 if (!bitmap || !bmp_buf)
380 signal_simple_error ("Unable to create bitmap", instantiator);
381
382 /* copy in the actual bitmap */
383 memcpy (bmp_buf, bmp_data, bmp_bits);
384 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap;
385 }
386
387 static void
388 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii,
344 int width, int height, 389 int width, int height,
345 unsigned char *eimage, 390 int slices,
391 unsigned char *eimage,
346 int dest_mask, 392 int dest_mask,
347 Lisp_Object instantiator, 393 Lisp_Object instantiator,
348 Lisp_Object domain) 394 Lisp_Object domain)
349 { 395 {
350 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 396 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
351 BITMAPINFO* bmp_info; 397 BITMAPINFO* bmp_info;
352 unsigned char* bmp_data; 398 unsigned char* bmp_data;
353 int bmp_bits; 399 int bmp_bits;
354 COLORREF bkcolor; 400 COLORREF bkcolor;
355 401 int slice;
402
356 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) 403 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
357 signal_simple_error ("Not an mswindows device", device); 404 signal_simple_error ("Not an mswindows device", device);
358 405
359 /* this is a hack but MaskBlt and TransparentBlt are not supported 406 /* this is a hack but MaskBlt and TransparentBlt are not supported
360 on most windows variants */ 407 on most windows variants */
361 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR 408 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
362 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); 409 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
363 410
364 /* build a bitmap from the eimage */ 411 for (slice = 0; slice < slices; slice++)
365 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, 412 {
366 &bmp_bits, &bmp_data))) 413 /* build a bitmap from the eimage */
367 { 414 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height,
368 signal_simple_error ("EImage to DIBitmap conversion failed", 415 eimage + (width * height * 3 * slice),
369 instantiator); 416 &bmp_bits, &bmp_data)))
370 } 417 {
371 418 signal_simple_error ("EImage to DIBitmap conversion failed",
372 /* Now create the pixmap and set up the image instance */ 419 instantiator);
373 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 420 }
374 bmp_data, bmp_bits, instantiator, 421
375 0, 0, 0); 422 /* Now create the pixmap and set up the image instance */
376 423 if (slice == 0)
377 xfree (bmp_info); 424 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
378 xfree (bmp_data); 425 bmp_data, bmp_bits, slices, instantiator,
379 } 426 0, 0, 0);
380 427 else
381 static void set_mono_pixel ( unsigned char* bits, 428 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice,
382 int bpline, int height, 429 instantiator);
383 int x, int y, int white ) 430
384 { 431 xfree (bmp_info);
385 int index; 432 xfree (bmp_data);
386 unsigned char bitnum; 433 }
434 }
435
436 static void set_mono_pixel ( unsigned char* bits,
437 int bpline, int height,
438 int x, int y, int white )
439 {
440 int i;
441 unsigned char bitnum;
387 /* Find the byte on which this scanline begins */ 442 /* Find the byte on which this scanline begins */
388 index = (height - y - 1) * bpline; 443 i = (height - y - 1) * bpline;
389 /* Find the byte containing this pixel */ 444 /* Find the byte containing this pixel */
390 index += (x >> 3); 445 i += (x >> 3);
391 /* Which bit is it? */ 446 /* Which bit is it? */
392 bitnum = (unsigned char)( 7 - (x % 8) ); 447 bitnum = (unsigned char)( 7 - (x % 8) );
393 if( white ) /* Turn it on */ 448 if( white ) /* Turn it on */
394 bits[index] |= (1<<bitnum); 449 bits[i] |= (1<<bitnum);
395 else /* Turn it off */ 450 else /* Turn it off */
396 bits[index] &= ~(1<<bitnum); 451 bits[i] &= ~(1<<bitnum);
397 } 452 }
398 453
399 static void 454 static void
400 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, 455 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image,
401 struct frame* f) 456 struct frame* f)
402 { 457 {
403 HBITMAP mask; 458 HBITMAP mask;
404 HGDIOBJ old = NULL; 459 HGDIOBJ old = NULL;
405 HDC hcdc = FRAME_MSWINDOWS_CDC (f); 460 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
406 unsigned char* dibits; 461 unsigned char* dibits;
407 BITMAPINFO* bmp_info = 462 BITMAPINFO* bmp_info =
408 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); 463 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
409 int i, j; 464 int i, j;
410 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image); 465 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image);
411 466
412 void* and_bits; 467 void* and_bits;
413 int maskbpline = BPLINE (((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8)); 468 int maskbpline = BPLINE ((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8);
414 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3); 469 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3);
415 470
416 if (!bmp_info) 471 if (!bmp_info)
417 return; 472 return;
418 473
419 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image); 474 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
420 bmp_info->bmiHeader.biHeight = height; 475 bmp_info->bmiHeader.biHeight = height;
421 bmp_info->bmiHeader.biPlanes=1; 476 bmp_info->bmiHeader.biPlanes=1;
422 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); 477 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
423 bmp_info->bmiHeader.biBitCount=1; 478 bmp_info->bmiHeader.biBitCount=1;
424 bmp_info->bmiHeader.biCompression=BI_RGB; 479 bmp_info->bmiHeader.biCompression=BI_RGB;
425 bmp_info->bmiHeader.biClrUsed = 2; 480 bmp_info->bmiHeader.biClrUsed = 2;
426 bmp_info->bmiHeader.biClrImportant = 2; 481 bmp_info->bmiHeader.biClrImportant = 2;
427 bmp_info->bmiHeader.biSizeImage = height * maskbpline; 482 bmp_info->bmiHeader.biSizeImage = height * maskbpline;
428 bmp_info->bmiColors[0].rgbRed = 0; 483 bmp_info->bmiColors[0].rgbRed = 0;
429 bmp_info->bmiColors[0].rgbGreen = 0; 484 bmp_info->bmiColors[0].rgbGreen = 0;
430 bmp_info->bmiColors[0].rgbBlue = 0; 485 bmp_info->bmiColors[0].rgbBlue = 0;
431 bmp_info->bmiColors[0].rgbReserved = 0; 486 bmp_info->bmiColors[0].rgbReserved = 0;
432 bmp_info->bmiColors[1].rgbRed = 255; 487 bmp_info->bmiColors[1].rgbRed = 255;
433 bmp_info->bmiColors[1].rgbGreen = 255; 488 bmp_info->bmiColors[1].rgbGreen = 255;
434 bmp_info->bmiColors[1].rgbBlue = 255; 489 bmp_info->bmiColors[1].rgbBlue = 255;
435 bmp_info->bmiColors[0].rgbReserved = 0; 490 bmp_info->bmiColors[0].rgbReserved = 0;
436 491
437 if (!(mask = CreateDIBSection (hcdc, 492 if (!(mask = CreateDIBSection (hcdc,
438 bmp_info, 493 bmp_info,
439 DIB_RGB_COLORS, 494 DIB_RGB_COLORS,
440 &and_bits, 495 &and_bits,
441 0,0))) 496 0,0)))
442 { 497 {
443 xfree (bmp_info); 498 xfree (bmp_info);
444 return; 499 return;
445 } 500 }
450 505
451 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image); 506 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
452 bmp_info->bmiHeader.biHeight = -height; 507 bmp_info->bmiHeader.biHeight = -height;
453 bmp_info->bmiHeader.biPlanes=1; 508 bmp_info->bmiHeader.biPlanes=1;
454 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); 509 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
455 bmp_info->bmiHeader.biBitCount=24; 510 bmp_info->bmiHeader.biBitCount=24;
456 bmp_info->bmiHeader.biCompression=BI_RGB; 511 bmp_info->bmiHeader.biCompression=BI_RGB;
457 bmp_info->bmiHeader.biClrUsed = 0; 512 bmp_info->bmiHeader.biClrUsed = 0;
458 bmp_info->bmiHeader.biClrImportant = 0; 513 bmp_info->bmiHeader.biClrImportant = 0;
459 bmp_info->bmiHeader.biSizeImage = height * bpline; 514 bmp_info->bmiHeader.biSizeImage = height * bpline;
460 515
461 dibits = xmalloc_and_zero (bpline * height); 516 dibits = xmalloc_and_zero (bpline * height);
462 if (GetDIBits (hcdc, 517 if (GetDIBits (hcdc,
463 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), 518 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
471 return; 526 return;
472 } 527 }
473 528
474 /* now set the colored bits in the mask and transparent ones to 529 /* now set the colored bits in the mask and transparent ones to
475 black in the original */ 530 black in the original */
476 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++) 531 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++)
477 { 532 {
478 for(j=0; j<height; j++) 533 for(j=0; j<height; j++)
479 { 534 {
480 unsigned char* idx = &dibits[j * bpline + i * 3]; 535 unsigned char* idx = &dibits[j * bpline + i * 3];
481 536
482 if( RGB (idx[2], idx[1], idx[0]) == transparent_color ) 537 if( RGB (idx[2], idx[1], idx[0]) == transparent_color )
483 { 538 {
484 idx[0] = idx[1] = idx[2] = 0; 539 idx[0] = idx[1] = idx[2] = 0;
485 set_mono_pixel( and_bits, maskbpline, height, i, j, TRUE ); 540 set_mono_pixel( and_bits, maskbpline, height, i, j, TRUE );
486 } 541 }
487 else 542 else
488 { 543 {
489 set_mono_pixel( and_bits, maskbpline, height, i, j, FALSE ); 544 set_mono_pixel( and_bits, maskbpline, height, i, j, FALSE );
490 } 545 }
491 } 546 }
492 } 547 }
493 548
499 bmp_info, 554 bmp_info,
500 DIB_RGB_COLORS); 555 DIB_RGB_COLORS);
501 556
502 xfree (bmp_info); 557 xfree (bmp_info);
503 xfree (dibits); 558 xfree (dibits);
504 559
505 SelectObject(hcdc, old); 560 SelectObject(hcdc, old);
506 561
507 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; 562 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask;
508 } 563 }
509 564
510 void 565 void
511 mswindows_initialize_image_instance_icon (struct Lisp_Image_Instance* image, 566 mswindows_initialize_image_instance_icon (Lisp_Image_Instance* image,
512 int cursor) 567 int cursor)
513 { 568 {
514 ICONINFO x_icon; 569 ICONINFO x_icon;
515 570
516 /* we rely on windows to do any resizing necessary */ 571 /* we rely on windows to do any resizing necessary */
517 x_icon.fIcon=cursor ? FALSE : TRUE; 572 x_icon.fIcon=cursor ? FALSE : TRUE;
518 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image)); 573 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image));
519 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image)); 574 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image));
520 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image); 575 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image);
521 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image); 576 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image);
522 577
523 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= 578 IMAGE_INSTANCE_MSWINDOWS_ICON (image)=
524 CreateIconIndirect (&x_icon); 579 CreateIconIndirect (&x_icon);
525 } 580 }
526 581
527 HBITMAP 582 HBITMAP
528 mswindows_create_resized_bitmap (struct Lisp_Image_Instance* ii, 583 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii,
529 struct frame* f, 584 struct frame* f,
530 int newx, int newy) 585 int newx, int newy)
531 { 586 {
532 HBITMAP newbmp; 587 HBITMAP newbmp;
533 HGDIOBJ old1, old2; 588 HGDIOBJ old1, old2;
534 HDC hcdc = FRAME_MSWINDOWS_CDC (f); 589 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
535 HDC hdcDst = CreateCompatibleDC (hcdc); 590 HDC hdcDst = CreateCompatibleDC (hcdc);
536 591
537 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)); 592 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
538 593
539 newbmp = CreateCompatibleBitmap (hcdc, newx, newy); 594 newbmp = CreateCompatibleBitmap (hcdc, newx, newy);
540 595
541 old2 = SelectObject (hdcDst, newbmp); 596 old2 = SelectObject (hdcDst, newbmp);
542 597
543 if (!StretchBlt (hdcDst, 0, 0, newx, newy, 598 if (!StretchBlt (hdcDst, 0, 0, newx, newy,
544 hcdc, 0, 0, 599 hcdc, 0, 0,
545 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), 600 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
546 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii), 601 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
547 SRCCOPY)) 602 SRCCOPY))
548 { 603 {
549 DeleteObject (newbmp); 604 DeleteObject (newbmp);
550 DeleteDC (hdcDst); 605 DeleteDC (hdcDst);
551 return 0; 606 return 0;
557 612
558 return newbmp; 613 return newbmp;
559 } 614 }
560 615
561 HBITMAP 616 HBITMAP
562 mswindows_create_resized_mask (struct Lisp_Image_Instance* ii, 617 mswindows_create_resized_mask (Lisp_Image_Instance* ii,
563 struct frame* f, 618 struct frame* f,
564 int newx, int newy) 619 int newx, int newy)
565 { 620 {
566 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) 621 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
567 { 622 {
568 HBITMAP newmask; 623 HBITMAP newmask;
569 HGDIOBJ old1, old2; 624 HGDIOBJ old1, old2;
570 HDC hcdc = FRAME_MSWINDOWS_CDC (f); 625 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
571 HDC hdcDst = CreateCompatibleDC (hcdc); 626 HDC hdcDst = CreateCompatibleDC (hcdc);
572 627
573 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii)); 628 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
574 newmask = CreateCompatibleBitmap(hcdc, newx, newy); 629 newmask = CreateCompatibleBitmap(hcdc, newx, newy);
575 old2 = SelectObject (hdcDst, newmask); 630 old2 = SelectObject (hdcDst, newmask);
576 631
577 if (!StretchBlt(hdcDst, 0, 0, newx, newy, 632 if (!StretchBlt(hdcDst, 0, 0, newx, newy,
578 hcdc, 0, 0, 633 hcdc, 0, 0,
579 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), 634 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
580 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii), 635 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
581 SRCCOPY)) 636 SRCCOPY))
582 { 637 {
583 DeleteObject (newmask); 638 DeleteObject (newmask);
584 DeleteDC (hdcDst); 639 DeleteDC (hdcDst);
585 return NULL; 640 return NULL;
586 } 641 }
587 642
588 SelectObject (hdcDst, old2); 643 SelectObject (hdcDst, old2);
589 SelectObject (hcdc, old1); 644 SelectObject (hcdc, old1);
590 645
591 DeleteDC (hdcDst); 646 DeleteDC (hdcDst);
592 647
595 650
596 return NULL; 651 return NULL;
597 } 652 }
598 653
599 int 654 int
600 mswindows_resize_dibitmap_instance (struct Lisp_Image_Instance* ii, 655 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii,
601 struct frame* f, 656 struct frame* f,
602 int newx, int newy) 657 int newx, int newy)
603 { 658 {
604 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); 659 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy);
605 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); 660 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy);
606 661
607 if (!newbmp) 662 if (!newbmp)
608 return FALSE; 663 return FALSE;
609 664
610 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)) 665 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii))
611 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)); 666 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
612 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) 667 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
613 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)); 668 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
614 669
680 colortbl = xnew_array_and_zero (struct color_symbol, i); 735 colortbl = xnew_array_and_zero (struct color_symbol, i);
681 736
682 for (j=0; j<i; j++) 737 for (j=0; j<i; j++)
683 { 738 {
684 Lisp_Object cons = XCAR (results); 739 Lisp_Object cons = XCAR (results);
685 colortbl[j].color = 740 colortbl[j].color =
686 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); 741 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
687 742
688 GET_C_STRING_OS_DATA_ALLOCA (XCAR (cons), colortbl[j].name); 743 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons),
744 C_STRING_ALLOCA, colortbl[j].name,
745 Qnative);
689 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */ 746 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */
690 free_cons (XCONS (cons)); 747 free_cons (XCONS (cons));
691 cons = results; 748 cons = results;
692 results = XCDR (results); 749 results = XCDR (results);
693 free_cons (XCONS (cons)); 750 free_cons (XCONS (cons));
694 } 751 }
695 return colortbl; 752 return colortbl;
696 } 753 }
697 754
698 static int xpm_to_eimage (Lisp_Object image, CONST Extbyte *buffer, 755 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer,
699 unsigned char** data, 756 unsigned char** data,
700 int* width, int* height, 757 int* width, int* height,
701 int* x_hot, int* y_hot, 758 int* x_hot, int* y_hot,
702 int* transp, 759 int* transp,
703 struct color_symbol* color_symbols, 760 struct color_symbol* color_symbols,
707 XpmInfo xpminfo; 764 XpmInfo xpminfo;
708 int result, i, j, transp_idx, maskbpline; 765 int result, i, j, transp_idx, maskbpline;
709 unsigned char* dptr; 766 unsigned char* dptr;
710 unsigned int* sptr; 767 unsigned int* sptr;
711 COLORREF color; /* the american spelling virus hits again .. */ 768 COLORREF color; /* the american spelling virus hits again .. */
712 COLORREF* colortbl; 769 COLORREF* colortbl;
713 770
714 xzero (xpmimage); 771 xzero (xpmimage);
715 xzero (xpminfo); 772 xzero (xpminfo);
716 xpminfo.valuemask=XpmHotspot; 773 xpminfo.valuemask=XpmHotspot;
717 *transp=FALSE; 774 *transp=FALSE;
737 signal_double_file_error_2 ("Parsing pixmap data", 794 signal_double_file_error_2 ("Parsing pixmap data",
738 "unknown error code", 795 "unknown error code",
739 make_int (result), image); 796 make_int (result), image);
740 } 797 }
741 } 798 }
742 799
743 *width = xpmimage.width; 800 *width = xpmimage.width;
744 *height = xpmimage.height; 801 *height = xpmimage.height;
745 maskbpline = BPLINE (((~7UL & (unsigned long)(*width + 7)) / 8)); 802 maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8);
746 803
747 *data = xnew_array_and_zero (unsigned char, *width * *height * 3); 804 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
748 805
749 if (!*data) 806 if (!*data)
750 { 807 {
751 XpmFreeXpmImage (&xpmimage); 808 XpmFreeXpmImage (&xpmimage);
772 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor") 829 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor")
773 || 830 ||
774 !strcasecmp (xpmimage.colorTable[i].symbolic,"None")) 831 !strcasecmp (xpmimage.colorTable[i].symbolic,"None"))
775 { 832 {
776 *transp=TRUE; 833 *transp=TRUE;
777 colortbl[i]=transparent_color; 834 colortbl[i]=transparent_color;
778 transp_idx=i; 835 transp_idx=i;
779 goto label_found_color; 836 goto label_found_color;
780 } 837 }
781 else if (color_symbols) 838 else if (color_symbols)
782 { 839 {
797 } 854 }
798 /* pick up transparencies */ 855 /* pick up transparencies */
799 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None")) 856 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None"))
800 { 857 {
801 *transp=TRUE; 858 *transp=TRUE;
802 colortbl[i]=transparent_color; 859 colortbl[i]=transparent_color;
803 transp_idx=i; 860 transp_idx=i;
804 goto label_found_color; 861 goto label_found_color;
805 } 862 }
806 /* finally pick up a normal color spec */ 863 /* finally pick up a normal color spec */
807 if (xpmimage.colorTable[i].c_color) 864 if (xpmimage.colorTable[i].c_color)
808 { 865 {
809 colortbl[i]= 866 colortbl[i]=
810 mswindows_string_to_color (xpmimage.colorTable[i].c_color); 867 mswindows_string_to_color (xpmimage.colorTable[i].c_color);
811 goto label_found_color; 868 goto label_found_color;
812 } 869 }
813 870
814 label_no_color: 871 label_no_color:
815 xfree (*data); 872 xfree (*data);
816 xfree (colortbl); 873 xfree (colortbl);
817 XpmFreeXpmImage (&xpmimage); 874 XpmFreeXpmImage (&xpmimage);
818 XpmFreeXpmInfo (&xpminfo); 875 XpmFreeXpmInfo (&xpminfo);
819 return 0; 876 return 0;
820 877
821 label_found_color:; 878 label_found_color:;
822 } 879 }
823 880
824 /* convert the image */ 881 /* convert the image */
825 sptr=xpmimage.data; 882 sptr=xpmimage.data;
847 mswindows_xpm_instantiate (Lisp_Object image_instance, 904 mswindows_xpm_instantiate (Lisp_Object image_instance,
848 Lisp_Object instantiator, 905 Lisp_Object instantiator,
849 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 906 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
850 int dest_mask, Lisp_Object domain) 907 int dest_mask, Lisp_Object domain)
851 { 908 {
852 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 909 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
853 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 910 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
854 CONST Extbyte *bytes; 911 const Extbyte *bytes;
855 Extcount len; 912 Extcount len;
856 unsigned char *eimage; 913 unsigned char *eimage;
857 int width, height, x_hot, y_hot; 914 int width, height, x_hot, y_hot;
858 BITMAPINFO* bmp_info; 915 BITMAPINFO* bmp_info;
859 unsigned char* bmp_data; 916 unsigned char* bmp_data;
860 int bmp_bits; 917 int bmp_bits;
861 int nsymbols=0, transp; 918 int nsymbols=0, transp;
862 struct color_symbol* color_symbols=NULL; 919 struct color_symbol* color_symbols=NULL;
863 920
864 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 921 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
865 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, 922 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
866 Q_color_symbols); 923 Q_color_symbols);
867 924
868 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) 925 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
869 signal_simple_error ("Not an mswindows device", device); 926 signal_simple_error ("Not an mswindows device", device);
870 927
871 assert (!NILP (data)); 928 assert (!NILP (data));
872 929
873 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); 930 TO_EXTERNAL_FORMAT (LISP_STRING, data,
931 ALLOCA, (bytes, len),
932 Qbinary);
874 933
875 /* in case we have color symbols */ 934 /* in case we have color symbols */
876 color_symbols = extract_xpm_color_names (device, domain, 935 color_symbols = extract_xpm_color_names (device, domain,
877 color_symbol_alist, &nsymbols); 936 color_symbol_alist, &nsymbols);
878 937
879 /* convert to an eimage to make processing easier */ 938 /* convert to an eimage to make processing easier */
880 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height, 939 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
881 &x_hot, &y_hot, &transp, color_symbols, nsymbols)) 940 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
882 { 941 {
883 signal_simple_error ("XPM to EImage conversion failed", 942 signal_simple_error ("XPM to EImage conversion failed",
884 image_instance); 943 image_instance);
885 } 944 }
886 945
887 if (color_symbols) 946 if (color_symbols)
888 { 947 {
889 while (nsymbols--) 948 while (nsymbols--)
890 { 949 {
891 xfree (color_symbols[nsymbols].name); 950 xfree (color_symbols[nsymbols].name);
892 } 951 }
893 xfree(color_symbols); 952 xfree(color_symbols);
894 } 953 }
895 954
896 /* build a bitmap from the eimage */ 955 /* build a bitmap from the eimage */
897 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, 956 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
898 &bmp_bits, &bmp_data))) 957 &bmp_bits, &bmp_data)))
899 { 958 {
900 signal_simple_error ("XPM to EImage conversion failed", 959 signal_simple_error ("XPM to EImage conversion failed",
902 } 961 }
903 xfree (eimage); 962 xfree (eimage);
904 963
905 /* Now create the pixmap and set up the image instance */ 964 /* Now create the pixmap and set up the image instance */
906 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 965 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
907 bmp_data, bmp_bits, instantiator, 966 bmp_data, bmp_bits, 1, instantiator,
908 x_hot, y_hot, transp); 967 x_hot, y_hot, transp);
909 968
910 xfree (bmp_info); 969 xfree (bmp_info);
911 xfree (bmp_data); 970 xfree (bmp_data);
912 } 971 }
937 static void 996 static void
938 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 997 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
939 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 998 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
940 int dest_mask, Lisp_Object domain) 999 int dest_mask, Lisp_Object domain)
941 { 1000 {
942 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1001 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
943 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1002 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
944 CONST Extbyte *bytes; 1003 const Extbyte *bytes;
945 Extcount len; 1004 Extcount len;
946 BITMAPFILEHEADER* bmp_file_header; 1005 BITMAPFILEHEADER* bmp_file_header;
947 BITMAPINFO* bmp_info; 1006 BITMAPINFO* bmp_info;
948 void* bmp_data; 1007 void* bmp_data;
949 int bmp_bits; 1008 int bmp_bits;
952 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) 1011 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
953 signal_simple_error ("Not an mswindows device", device); 1012 signal_simple_error ("Not an mswindows device", device);
954 1013
955 assert (!NILP (data)); 1014 assert (!NILP (data));
956 1015
957 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); 1016 TO_EXTERNAL_FORMAT (LISP_STRING, data,
958 1017 ALLOCA, (bytes, len),
1018 Qbinary);
1019
959 /* Then slurp the image into memory, decoding along the way. 1020 /* Then slurp the image into memory, decoding along the way.
960 The result is the image in a simple one-byte-per-pixel 1021 The result is the image in a simple one-byte-per-pixel
961 format. */ 1022 format. */
962 1023
963 bmp_file_header=(BITMAPFILEHEADER*)bytes; 1024 bmp_file_header=(BITMAPFILEHEADER*)bytes;
964 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER)); 1025 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
965 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits; 1026 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
966 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits; 1027 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
967 1028
968 /* Now create the pixmap and set up the image instance */ 1029 /* Now create the pixmap and set up the image instance */
969 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 1030 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
970 bmp_data, bmp_bits, instantiator, 1031 bmp_data, bmp_bits, 1, instantiator,
971 0, 0, 0); 1032 0, 0, 0);
972 } 1033 }
973 1034
974 1035
975 /********************************************************************** 1036 /**********************************************************************
977 **********************************************************************/ 1038 **********************************************************************/
978 1039
979 static void 1040 static void
980 mswindows_resource_validate (Lisp_Object instantiator) 1041 mswindows_resource_validate (Lisp_Object instantiator)
981 { 1042 {
982 if ((NILP (find_keyword_in_vector (instantiator, Q_file)) 1043 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
983 && 1044 &&
984 NILP (find_keyword_in_vector (instantiator, Q_resource_id))) 1045 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
985 || 1046 ||
986 NILP (find_keyword_in_vector (instantiator, Q_resource_type))) 1047 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
987 signal_simple_error ("Must supply :file, :resource-id and :resource-type", 1048 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
988 instantiator); 1049 instantiator);
989 } 1050 }
996 struct gcpro gcpro1, gcpro2; 1057 struct gcpro gcpro1, gcpro2;
997 Lisp_Object alist = Qnil; 1058 Lisp_Object alist = Qnil;
998 1059
999 GCPRO2 (file, alist); 1060 GCPRO2 (file, alist);
1000 1061
1001 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data, 1062 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
1002 console_type); 1063 console_type);
1003 1064
1004 if (CONSP (file)) /* failure locating filename */ 1065 if (CONSP (file)) /* failure locating filename */
1005 signal_double_file_error ("Opening pixmap file", 1066 signal_double_file_error ("Opening pixmap file",
1006 "no such file or directory", 1067 "no such file or directory",
1027 mswindows_resource_possible_dest_types (void) 1088 mswindows_resource_possible_dest_types (void)
1028 { 1089 {
1029 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK; 1090 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
1030 } 1091 }
1031 1092
1032 typedef struct 1093 typedef struct
1033 { 1094 {
1034 char *name; 1095 char *name;
1035 int resource_id; 1096 int resource_id;
1036 } resource_t; 1097 } resource_t;
1037 1098
1041 #define OIC_HAND 32513 1102 #define OIC_HAND 32513
1042 #define OIC_QUES 32514 1103 #define OIC_QUES 32514
1043 #define OIC_BANG 32515 1104 #define OIC_BANG 32515
1044 #define OIC_NOTE 32516 1105 #define OIC_NOTE 32516
1045 #define OIC_WINLOGO 32517 1106 #define OIC_WINLOGO 32517
1107 #if defined (__CYGWIN32__) && CYGWIN_VERSION_DLL_MAJOR < 21
1046 #define LR_SHARED 0x8000 1108 #define LR_SHARED 0x8000
1047 #endif 1109 #endif
1048 1110 #endif
1049 static CONST resource_t bitmap_table[] = 1111
1112 static const resource_t bitmap_table[] =
1050 { 1113 {
1051 /* bitmaps */ 1114 /* bitmaps */
1052 { "close", OBM_CLOSE }, 1115 { "close", OBM_CLOSE },
1053 { "uparrow", OBM_UPARROW }, 1116 { "uparrow", OBM_UPARROW },
1054 { "dnarrow", OBM_DNARROW }, 1117 { "dnarrow", OBM_DNARROW },
1076 { "checkboxes", OBM_CHECKBOXES }, 1139 { "checkboxes", OBM_CHECKBOXES },
1077 { "btncorners" , OBM_BTNCORNERS }, 1140 { "btncorners" , OBM_BTNCORNERS },
1078 {0} 1141 {0}
1079 }; 1142 };
1080 1143
1081 static CONST resource_t cursor_table[] = 1144 static const resource_t cursor_table[] =
1082 { 1145 {
1083 /* cursors */ 1146 /* cursors */
1084 { "normal", OCR_NORMAL }, 1147 { "normal", OCR_NORMAL },
1085 { "ibeam", OCR_IBEAM }, 1148 { "ibeam", OCR_IBEAM },
1086 { "wait", OCR_WAIT }, 1149 { "wait", OCR_WAIT },
1095 /* { "icour", OCR_ICOCUR }, */ 1158 /* { "icour", OCR_ICOCUR }, */
1096 { "no", OCR_NO }, 1159 { "no", OCR_NO },
1097 { 0 } 1160 { 0 }
1098 }; 1161 };
1099 1162
1100 static CONST resource_t icon_table[] = 1163 static const resource_t icon_table[] =
1101 { 1164 {
1102 /* icons */ 1165 /* icons */
1103 { "sample", OIC_SAMPLE }, 1166 { "sample", OIC_SAMPLE },
1104 { "hand", OIC_HAND }, 1167 { "hand", OIC_HAND },
1105 { "ques", OIC_QUES }, 1168 { "ques", OIC_QUES },
1109 {0} 1172 {0}
1110 }; 1173 };
1111 1174
1112 static int resource_name_to_resource (Lisp_Object name, int type) 1175 static int resource_name_to_resource (Lisp_Object name, int type)
1113 { 1176 {
1114 CONST resource_t* res = (type == IMAGE_CURSOR ? cursor_table 1177 const resource_t* res = (type == IMAGE_CURSOR ? cursor_table
1115 : type == IMAGE_ICON ? icon_table 1178 : type == IMAGE_ICON ? icon_table
1116 : bitmap_table); 1179 : bitmap_table);
1117 1180
1118 if (INTP (name)) 1181 if (INTP (name))
1119 { 1182 {
1120 return XINT (name); 1183 return XINT (name);
1121 } 1184 }
1122 else if (!STRINGP (name)) 1185 else if (!STRINGP (name))
1123 { 1186 {
1124 signal_simple_error ("invalid resource identifier", name); 1187 signal_simple_error ("invalid resource identifier", name);
1125 } 1188 }
1126 1189
1127 do { 1190 do {
1128 Extbyte* nm=0; 1191 Extbyte* nm=0;
1129 GET_C_STRING_OS_DATA_ALLOCA (name, nm); 1192 TO_EXTERNAL_FORMAT (LISP_STRING, name,
1193 C_STRING_ALLOCA, nm,
1194 Qnative);
1130 if (!strcasecmp ((char*)res->name, nm)) 1195 if (!strcasecmp ((char*)res->name, nm))
1131 return res->resource_id; 1196 return res->resource_id;
1132 } while ((++res)->name); 1197 } while ((++res)->name);
1133 return 0; 1198 return 0;
1134 } 1199 }
1149 static void 1214 static void
1150 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1215 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1151 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1216 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1152 int dest_mask, Lisp_Object domain) 1217 int dest_mask, Lisp_Object domain)
1153 { 1218 {
1154 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1219 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1155 unsigned int type = 0; 1220 unsigned int type = 0;
1156 HANDLE himage = NULL; 1221 HANDLE himage = NULL;
1157 LPCTSTR resid=0; 1222 LPCTSTR resid=0;
1158 HINSTANCE hinst = NULL; 1223 HINSTANCE hinst = NULL;
1159 ICONINFO iconinfo; 1224 ICONINFO iconinfo;
1160 int iitype=0; 1225 int iitype=0;
1161 char* fname=0; 1226 char* fname=0;
1162 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1227 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1163 1228
1164 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); 1229 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
1165 Lisp_Object resource_type = find_keyword_in_vector (instantiator, 1230 Lisp_Object resource_type = find_keyword_in_vector (instantiator,
1166 Q_resource_type); 1231 Q_resource_type);
1167 Lisp_Object resource_id = find_keyword_in_vector (instantiator, 1232 Lisp_Object resource_id = find_keyword_in_vector (instantiator,
1168 Q_resource_id); 1233 Q_resource_id);
1169 1234
1170 xzero (iconinfo); 1235 xzero (iconinfo);
1171 1236
1172 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) 1237 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
1176 1241
1177 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR) 1242 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR)
1178 iitype = IMAGE_POINTER; 1243 iitype = IMAGE_POINTER;
1179 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) 1244 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
1180 iitype = IMAGE_COLOR_PIXMAP; 1245 iitype = IMAGE_COLOR_PIXMAP;
1181 else 1246 else
1182 incompatible_image_types (instantiator, dest_mask, 1247 incompatible_image_types (instantiator, dest_mask,
1183 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); 1248 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
1184 1249
1185 /* mess with the keyword info we were provided with */ 1250 /* mess with the keyword info we were provided with */
1186 if (!NILP (file)) 1251 if (!NILP (file))
1187 { 1252 {
1188 Extbyte* f=0; 1253 Extbyte* f=0;
1189 GET_C_STRING_FILENAME_DATA_ALLOCA (file, f); 1254 TO_EXTERNAL_FORMAT (LISP_STRING, file,
1255 C_STRING_ALLOCA, f,
1256 Qfile_name);
1190 #ifdef __CYGWIN32__ 1257 #ifdef __CYGWIN32__
1191 CYGWIN_WIN32_PATH (f, fname); 1258 CYGWIN_WIN32_PATH (f, fname);
1192 #else 1259 #else
1193 fname = f; 1260 fname = f;
1194 #endif 1261 #endif
1195 1262
1196 if (NILP (resource_id)) 1263 if (NILP (resource_id))
1197 resid = (LPCTSTR)fname; 1264 resid = (LPCTSTR)fname;
1198 else 1265 else
1199 { 1266 {
1200 hinst = LoadLibraryEx (fname, NULL, 1267 hinst = LoadLibraryEx (fname, NULL,
1201 LOAD_LIBRARY_AS_DATAFILE); 1268 LOAD_LIBRARY_AS_DATAFILE);
1202 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, 1269 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
1203 type)); 1270 type));
1204 1271
1205 if (!resid) 1272 if (!resid)
1206 GET_C_STRING_OS_DATA_ALLOCA (resource_id, resid); 1273 TO_EXTERNAL_FORMAT (LISP_STRING, resource_id,
1274 C_STRING_ALLOCA, resid,
1275 Qnative);
1207 } 1276 }
1208 } 1277 }
1209 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, 1278 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
1210 type)))) 1279 type))))
1211 signal_simple_error ("Invalid resource identifier", resource_id); 1280 signal_simple_error ("Invalid resource identifier", resource_id);
1212 1281
1213 /* load the image */ 1282 /* load the image */
1214 if (!(himage = LoadImage (hinst, resid, type, 0, 0, 1283 if (!(himage = LoadImage (hinst, resid, type, 0, 0,
1215 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | 1284 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
1216 LR_SHARED | 1285 LR_SHARED |
1217 (!NILP (file) ? LR_LOADFROMFILE : 0)))) 1286 (!NILP (file) ? LR_LOADFROMFILE : 0))))
1218 { 1287 {
1219 signal_simple_error ("Cannot load image", instantiator); 1288 signal_simple_error ("Cannot load image", instantiator);
1220 } 1289 }
1221 1290
1222 if (hinst) 1291 if (hinst)
1223 FreeLibrary (hinst); 1292 FreeLibrary (hinst);
1224 1293
1225 mswindows_initialize_dibitmap_image_instance (ii, iitype); 1294 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype);
1226 1295
1227 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file; 1296 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
1228 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = 1297 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
1229 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON); 1298 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
1230 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = 1299 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
1231 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON); 1300 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON);
1232 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; 1301 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
1233 1302
1234 /* hey, we've got an icon type thing so we can reverse engineer the 1303 /* hey, we've got an icon type thing so we can reverse engineer the
1235 bitmap and mask */ 1304 bitmap and mask */
1267 && 1336 &&
1268 !resource_name_to_resource (data, IMAGE_ICON) 1337 !resource_name_to_resource (data, IMAGE_ICON)
1269 && 1338 &&
1270 !resource_name_to_resource (data, IMAGE_BITMAP)) 1339 !resource_name_to_resource (data, IMAGE_BITMAP))
1271 signal_simple_error ("invalid resource identifier", data); 1340 signal_simple_error ("invalid resource identifier", data);
1272 }
1273
1274 void
1275 check_valid_string_or_int (Lisp_Object data)
1276 {
1277 if (!INTP (data))
1278 CHECK_STRING (data);
1279 else
1280 CHECK_INT (data);
1281 } 1341 }
1282 1342
1283 /********************************************************************** 1343 /**********************************************************************
1284 * XBM * 1344 * XBM *
1285 **********************************************************************/ 1345 **********************************************************************/
1322 * XmuReadBitmapData read data from FILE descriptor 1382 * XmuReadBitmapData read data from FILE descriptor
1323 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files 1383 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
1324 * and return data 1384 * and return data
1325 * 1385 *
1326 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them 1386 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
1327 * that way (but don't use common source code so that people can have one 1387 * that way (but don't use common source code so that people can have one
1328 * without the other). 1388 * without the other).
1329 */ 1389 */
1330 1390
1331 1391
1332 /* 1392 /*
1372 1432
1373 /* delimiters of significance are flagged w/ negative value */ 1433 /* delimiters of significance are flagged w/ negative value */
1374 hexTable[' '] = -1; hexTable[','] = -1; 1434 hexTable[' '] = -1; hexTable[','] = -1;
1375 hexTable['}'] = -1; hexTable['\n'] = -1; 1435 hexTable['}'] = -1; hexTable['\n'] = -1;
1376 hexTable['\t'] = -1; 1436 hexTable['\t'] = -1;
1377 1437
1378 initialized = TRUE; 1438 initialized = TRUE;
1379 } 1439 }
1380 1440
1381 /* 1441 /*
1382 * read next hex value in the input stream, return -1 if EOF 1442 * read next hex value in the input stream, return -1 if EOF
1385 { 1445 {
1386 int ch; 1446 int ch;
1387 int value = 0; 1447 int value = 0;
1388 int gotone = 0; 1448 int gotone = 0;
1389 int done = 0; 1449 int done = 0;
1390 1450
1391 /* loop, accumulate hex value until find delimiter */ 1451 /* loop, accumulate hex value until find delimiter */
1392 /* skip any initial delimiters found in read stream */ 1452 /* skip any initial delimiters found in read stream */
1393 1453
1394 while (!done) { 1454 while (!done) {
1395 ch = getc(fstream); 1455 ch = getc(fstream);
1466 if (!strcmp("y_hot", type)) 1526 if (!strcmp("y_hot", type))
1467 hy = value; 1527 hy = value;
1468 } 1528 }
1469 continue; 1529 continue;
1470 } 1530 }
1471 1531
1472 if (sscanf(line, "static short %s = {", name_and_type) == 1) 1532 if (sscanf(line, "static short %s = {", name_and_type) == 1)
1473 version10p = 1; 1533 version10p = 1;
1474 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) 1534 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
1475 version10p = 0; 1535 version10p = 0;
1476 else if (sscanf(line, "static char %s = {", name_and_type) == 1) 1536 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
1483 else 1543 else
1484 type++; 1544 type++;
1485 1545
1486 if (strcmp("bits[]", type)) 1546 if (strcmp("bits[]", type))
1487 continue; 1547 continue;
1488 1548
1489 if (!ww || !hh) 1549 if (!ww || !hh)
1490 RETURN (BitmapFileInvalid); 1550 RETURN (BitmapFileInvalid);
1491 1551
1492 if ((ww % 16) && ((ww % 16) < 9) && version10p) 1552 if ((ww % 16) && ((ww % 16) < 9) && version10p)
1493 padding = 1; 1553 padding = 1;
1496 1556
1497 bytes_per_line = (ww+7)/8 + padding; 1557 bytes_per_line = (ww+7)/8 + padding;
1498 1558
1499 size = bytes_per_line * hh; 1559 size = bytes_per_line * hh;
1500 data = (unsigned char *) Xmalloc ((unsigned int) size); 1560 data = (unsigned char *) Xmalloc ((unsigned int) size);
1501 if (!data) 1561 if (!data)
1502 RETURN (BitmapNoMemory); 1562 RETURN (BitmapNoMemory);
1503 1563
1504 if (version10p) { 1564 if (version10p) {
1505 unsigned char *ptr; 1565 unsigned char *ptr;
1506 int bytes; 1566 int bytes;
1515 } else { 1575 } else {
1516 unsigned char *ptr; 1576 unsigned char *ptr;
1517 int bytes; 1577 int bytes;
1518 1578
1519 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { 1579 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
1520 if ((value = NextInt(fstream)) < 0) 1580 if ((value = NextInt(fstream)) < 0)
1521 RETURN (BitmapFileInvalid); 1581 RETURN (BitmapFileInvalid);
1522 *ptr=value; 1582 *ptr=value;
1523 } 1583 }
1524 } 1584 }
1525 break; 1585 break;
1538 1598
1539 RETURN (BitmapSuccess); 1599 RETURN (BitmapSuccess);
1540 } 1600 }
1541 1601
1542 1602
1543 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width, 1603 int read_bitmap_data_from_file (const char *filename, unsigned int *width,
1544 unsigned int *height, unsigned char **datap, 1604 unsigned int *height, unsigned char **datap,
1545 int *x_hot, int *y_hot) 1605 int *x_hot, int *y_hot)
1546 { 1606 {
1547 FILE *fstream; 1607 FILE *fstream;
1548 int status; 1608 int status;
1567 from left to right, little-endian within a byte. 0 = white, 1 = 1627 from left to right, little-endian within a byte. 0 = white, 1 =
1568 black. It must be converted to the following format: Widths are 1628 black. It must be converted to the following format: Widths are
1569 padded to a multiple of 16. Scan lines are stored in increasing 1629 padded to a multiple of 16. Scan lines are stored in increasing
1570 byte order from left to right, big-endian within a byte. 0 = 1630 byte order from left to right, big-endian within a byte. 0 =
1571 black, 1 = white. */ 1631 black, 1 = white. */
1572 HBITMAP 1632 static HBITMAP
1573 xbm_create_bitmap_from_data (HDC hdc, char *data, 1633 xbm_create_bitmap_from_data (HDC hdc, char *data,
1574 unsigned int width, unsigned int height, 1634 unsigned int width, unsigned int height,
1575 int mask, COLORREF fg, COLORREF bg) 1635 int mask, COLORREF fg, COLORREF bg)
1576 { 1636 {
1577 int old_width = (width + 7)/8; 1637 int old_width = (width + 7)/8;
1578 int new_width = BPLINE (2*((width + 15)/16)); 1638 int new_width = BPLINE (2*((width + 15)/16));
1579 unsigned char *offset; 1639 unsigned char *offset;
1580 void *bmp_buf = 0; 1640 void *bmp_buf = 0;
1581 unsigned char *new_data, *new_offset; 1641 unsigned char *new_data, *new_offset;
1582 int i, j; 1642 int i, j;
1583 BITMAPINFO* bmp_info = 1643 BITMAPINFO* bmp_info =
1584 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); 1644 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
1585 HBITMAP bitmap; 1645 HBITMAP bitmap;
1586 1646
1587 if (!bmp_info) 1647 if (!bmp_info)
1588 return NULL; 1648 return NULL;
1589 1649
1590 new_data = (unsigned char *) xmalloc_and_zero (height * new_width); 1650 new_data = (unsigned char *) xmalloc_and_zero (height * new_width);
1591 1651
1592 if (!new_data) 1652 if (!new_data)
1593 { 1653 {
1594 xfree (bmp_info); 1654 xfree (bmp_info);
1595 return NULL; 1655 return NULL;
1596 } 1656 }
1597 1657
1598 for (i=0; i<height; i++) 1658 for (i=0; i<height; i++)
1599 { 1659 {
1600 offset = data + i*old_width; 1660 offset = data + i*old_width;
1601 new_offset = new_data + i*new_width; 1661 new_offset = new_data + i*new_width;
1602 1662
1620 1680
1621 bmp_info->bmiHeader.biWidth=width; 1681 bmp_info->bmiHeader.biWidth=width;
1622 bmp_info->bmiHeader.biHeight=-(LONG)height; 1682 bmp_info->bmiHeader.biHeight=-(LONG)height;
1623 bmp_info->bmiHeader.biPlanes=1; 1683 bmp_info->bmiHeader.biPlanes=1;
1624 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); 1684 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
1625 bmp_info->bmiHeader.biBitCount=1; 1685 bmp_info->bmiHeader.biBitCount=1;
1626 bmp_info->bmiHeader.biCompression=BI_RGB; 1686 bmp_info->bmiHeader.biCompression=BI_RGB;
1627 bmp_info->bmiHeader.biClrUsed = 2; 1687 bmp_info->bmiHeader.biClrUsed = 2;
1628 bmp_info->bmiHeader.biClrImportant = 2; 1688 bmp_info->bmiHeader.biClrImportant = 2;
1629 bmp_info->bmiHeader.biSizeImage = height * new_width; 1689 bmp_info->bmiHeader.biSizeImage = height * new_width;
1630 bmp_info->bmiColors[0].rgbRed = GetRValue (fg); 1690 bmp_info->bmiColors[0].rgbRed = GetRValue (fg);
1631 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg); 1691 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg);
1632 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg); 1692 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg);
1633 bmp_info->bmiColors[0].rgbReserved = 0; 1693 bmp_info->bmiColors[0].rgbReserved = 0;
1634 bmp_info->bmiColors[1].rgbRed = GetRValue (bg); 1694 bmp_info->bmiColors[1].rgbRed = GetRValue (bg);
1635 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg); 1695 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg);
1636 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg); 1696 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg);
1637 bmp_info->bmiColors[1].rgbReserved = 0; 1697 bmp_info->bmiColors[1].rgbReserved = 0;
1638 1698
1639 bitmap = CreateDIBSection (hdc, 1699 bitmap = CreateDIBSection (hdc,
1640 bmp_info, 1700 bmp_info,
1641 DIB_RGB_COLORS, 1701 DIB_RGB_COLORS,
1642 &bmp_buf, 1702 &bmp_buf,
1643 0,0); 1703 0,0);
1644 1704
1645 xfree (bmp_info); 1705 xfree (bmp_info);
1646 1706
1647 if (!bitmap || !bmp_buf) 1707 if (!bitmap || !bmp_buf)
1648 { 1708 {
1649 xfree (new_data); 1709 xfree (new_data);
1650 return NULL; 1710 return NULL;
1651 } 1711 }
1652 1712
1653 /* copy in the actual bitmap */ 1713 /* copy in the actual bitmap */
1654 memcpy (bmp_buf, new_data, height * new_width); 1714 memcpy (bmp_buf, new_data, height * new_width);
1655 xfree (new_data); 1715 xfree (new_data);
1656 1716
1657 return bitmap; 1717 return bitmap;
1659 1719
1660 /* Given inline data for a mono pixmap, initialize the given 1720 /* Given inline data for a mono pixmap, initialize the given
1661 image instance accordingly. */ 1721 image instance accordingly. */
1662 1722
1663 static void 1723 static void
1664 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii, 1724 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii,
1665 int width, int height, 1725 int width, int height,
1666 /* Note that data is in ext-format! */ 1726 /* Note that data is in ext-format! */
1667 CONST char *bits, 1727 const char *bits,
1668 Lisp_Object instantiator, 1728 Lisp_Object instantiator,
1669 Lisp_Object pointer_fg, 1729 Lisp_Object pointer_fg,
1670 Lisp_Object pointer_bg, 1730 Lisp_Object pointer_bg,
1671 int dest_mask, 1731 int dest_mask,
1672 HBITMAP mask, 1732 HBITMAP mask,
1702 else 1762 else
1703 incompatible_image_types (instantiator, dest_mask, 1763 incompatible_image_types (instantiator, dest_mask,
1704 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK 1764 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
1705 | IMAGE_POINTER_MASK); 1765 | IMAGE_POINTER_MASK);
1706 1766
1707 mswindows_initialize_dibitmap_image_instance (ii, type); 1767 mswindows_initialize_dibitmap_image_instance (ii, 1, type);
1708 1768
1709 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = 1769 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
1710 find_keyword_in_vector (instantiator, Q_file); 1770 find_keyword_in_vector (instantiator, Q_file);
1711 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width; 1771 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
1712 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height; 1772 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
1713 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; 1773 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
1714 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); 1774 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
1715 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); 1775 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
1716 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask : 1776 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask :
1717 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, 1777 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1718 TRUE, black, white); 1778 TRUE, black, white);
1719 1779
1720 switch (type) 1780 switch (type)
1721 { 1781 {
1722 case IMAGE_MONO_PIXMAP: 1782 case IMAGE_MONO_PIXMAP:
1723 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = 1783 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
1724 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, 1784 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1725 FALSE, black, black); 1785 FALSE, black, black);
1726 break; 1786 break;
1727 1787
1728 case IMAGE_COLOR_PIXMAP: 1788 case IMAGE_COLOR_PIXMAP:
1729 { 1789 {
1747 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); 1807 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
1748 1808
1749 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; 1809 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
1750 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; 1810 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
1751 1811
1752 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = 1812 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
1753 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, 1813 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1754 FALSE, fg, black); 1814 FALSE, fg, black);
1755 } 1815 }
1756 break; 1816 break;
1757 1817
1758 case IMAGE_POINTER: 1818 case IMAGE_POINTER:
1763 if (NILP (foreground)) 1823 if (NILP (foreground))
1764 foreground = pointer_fg; 1824 foreground = pointer_fg;
1765 if (NILP (background)) 1825 if (NILP (background))
1766 background = pointer_bg; 1826 background = pointer_bg;
1767 1827
1768 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = 1828 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) =
1769 find_keyword_in_vector (instantiator, Q_hotspot_x); 1829 find_keyword_in_vector (instantiator, Q_hotspot_x);
1770 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = 1830 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) =
1771 find_keyword_in_vector (instantiator, Q_hotspot_y); 1831 find_keyword_in_vector (instantiator, Q_hotspot_y);
1772 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; 1832 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
1773 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; 1833 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
1774 if (COLOR_INSTANCEP (foreground)) 1834 if (COLOR_INSTANCEP (foreground))
1775 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground)); 1835 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
1776 if (COLOR_INSTANCEP (background)) 1836 if (COLOR_INSTANCEP (background))
1777 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); 1837 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
1778 1838
1779 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = 1839 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
1780 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, 1840 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1781 TRUE, fg, black); 1841 TRUE, fg, black);
1782 mswindows_initialize_image_instance_icon (ii, TRUE); 1842 mswindows_initialize_image_instance_icon (ii, TRUE);
1783 } 1843 }
1784 break; 1844 break;
1785 1845
1791 static void 1851 static void
1792 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, 1852 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
1793 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1853 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1794 int dest_mask, int width, int height, 1854 int dest_mask, int width, int height,
1795 /* Note that data is in ext-format! */ 1855 /* Note that data is in ext-format! */
1796 CONST char *bits) 1856 const char *bits)
1797 { 1857 {
1798 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); 1858 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
1799 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); 1859 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
1800 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1860 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1801 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME 1861 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME
1802 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)))); 1862 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))));
1803 HDC hdc = FRAME_MSWINDOWS_CDC (f); 1863 HDC hdc = FRAME_MSWINDOWS_CDC (f);
1804 HBITMAP mask = 0; 1864 HBITMAP mask = 0;
1805 CONST char *gcc_may_you_rot_in_hell;
1806 1865
1807 if (!NILP (mask_data)) 1866 if (!NILP (mask_data))
1808 { 1867 {
1809 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (mask_data))), 1868 const char *ext_data;
1810 gcc_may_you_rot_in_hell); 1869
1811 mask = 1870 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
1812 xbm_create_bitmap_from_data ( hdc, 1871 C_STRING_ALLOCA, ext_data,
1813 (unsigned char *) 1872 Qbinary);
1814 gcc_may_you_rot_in_hell, 1873 mask = xbm_create_bitmap_from_data (hdc,
1815 XINT (XCAR (mask_data)), 1874 (unsigned char *) ext_data,
1816 XINT (XCAR (XCDR (mask_data))), FALSE, 1875 XINT (XCAR (mask_data)),
1817 PALETTERGB (0,0,0), 1876 XINT (XCAR (XCDR (mask_data))),
1818 PALETTERGB (255,255,255)); 1877 FALSE,
1878 PALETTERGB (0,0,0),
1879 PALETTERGB (255,255,255));
1819 } 1880 }
1820 1881
1821 init_image_instance_from_xbm_inline (ii, width, height, bits, 1882 init_image_instance_from_xbm_inline (ii, width, height, bits,
1822 instantiator, pointer_fg, pointer_bg, 1883 instantiator, pointer_fg, pointer_bg,
1823 dest_mask, mask, mask_file); 1884 dest_mask, mask, mask_file);
1824 } 1885 }
1825 1886
1826 /* Instantiate method for XBM's. */ 1887 /* Instantiate method for XBM's. */
1827 1888
1828 static void 1889 static void
1829 mswindows_xbm_instantiate (Lisp_Object image_instance, 1890 mswindows_xbm_instantiate (Lisp_Object image_instance,
1830 Lisp_Object instantiator, 1891 Lisp_Object instantiator,
1831 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1892 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1832 int dest_mask, Lisp_Object domain) 1893 int dest_mask, Lisp_Object domain)
1833 { 1894 {
1834 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1895 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1835 CONST char *gcc_go_home; 1896 const char *ext_data;
1836 1897
1837 assert (!NILP (data)); 1898 assert (!NILP (data));
1838 1899
1839 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (data))), 1900 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))),
1840 gcc_go_home); 1901 C_STRING_ALLOCA, ext_data,
1902 Qbinary);
1841 1903
1842 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, 1904 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
1843 pointer_bg, dest_mask, XINT (XCAR (data)), 1905 pointer_bg, dest_mask, XINT (XCAR (data)),
1844 XINT (XCAR (XCDR (data))), gcc_go_home); 1906 XINT (XCAR (XCDR (data))), ext_data);
1845 } 1907 }
1846 1908
1847 #ifdef HAVE_XFACE 1909 #ifdef HAVE_XFACE
1848 /********************************************************************** 1910 /**********************************************************************
1849 * X-Face * 1911 * X-Face *
1874 int dest_mask, Lisp_Object domain) 1936 int dest_mask, Lisp_Object domain)
1875 { 1937 {
1876 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1938 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1877 int i, stattis; 1939 int i, stattis;
1878 char *p, *bits, *bp; 1940 char *p, *bits, *bp;
1879 CONST char * volatile emsg = 0; 1941 const char * volatile emsg = 0;
1880 CONST char * volatile dstring; 1942 const char * volatile dstring;
1881 1943
1882 assert (!NILP (data)); 1944 assert (!NILP (data));
1883 1945
1884 GET_C_STRING_BINARY_DATA_ALLOCA (data, dstring); 1946 TO_EXTERNAL_FORMAT (LISP_STRING, data,
1947 C_STRING_ALLOCA, dstring,
1948 Qbinary);
1885 1949
1886 if ((p = strchr (dstring, ':'))) 1950 if ((p = strchr (dstring, ':')))
1887 { 1951 {
1888 dstring = p + 1; 1952 dstring = p + 1;
1889 } 1953 }
1935 /************************************************************************/ 1999 /************************************************************************/
1936 /* image instance methods */ 2000 /* image instance methods */
1937 /************************************************************************/ 2001 /************************************************************************/
1938 2002
1939 static void 2003 static void
1940 mswindows_print_image_instance (struct Lisp_Image_Instance *p, 2004 mswindows_print_image_instance (Lisp_Image_Instance *p,
1941 Lisp_Object printcharfun, 2005 Lisp_Object printcharfun,
1942 int escapeflag) 2006 int escapeflag)
1943 { 2007 {
1944 char buf[100]; 2008 char buf[100];
1945 2009
1946 switch (IMAGE_INSTANCE_TYPE (p)) 2010 switch (IMAGE_INSTANCE_TYPE (p))
1947 { 2011 {
1948 case IMAGE_MONO_PIXMAP: 2012 case IMAGE_MONO_PIXMAP:
1949 case IMAGE_COLOR_PIXMAP: 2013 case IMAGE_COLOR_PIXMAP:
1950 case IMAGE_POINTER: 2014 case IMAGE_POINTER:
1951 sprintf (buf, " (0x%lx", 2015 sprintf (buf, " (0x%lx",
1952 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); 2016 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
1953 write_c_string (buf, printcharfun); 2017 write_c_string (buf, printcharfun);
1954 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) 2018 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
1955 { 2019 {
1956 sprintf (buf, "/0x%lx", 2020 sprintf (buf, "/0x%lx",
1957 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p)); 2021 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
1958 write_c_string (buf, printcharfun); 2022 write_c_string (buf, printcharfun);
1959 } 2023 }
1960 write_c_string (")", printcharfun); 2024 write_c_string (")", printcharfun);
1961 break; 2025 break;
1963 default: 2027 default:
1964 break; 2028 break;
1965 } 2029 }
1966 } 2030 }
1967 2031
1968 static void 2032 #ifdef DEBUG_WIDGETS
1969 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p) 2033 extern int debug_widget_instances;
2034 #endif
2035
2036 static void
2037 mswindows_finalize_image_instance (Lisp_Image_Instance *p)
1970 { 2038 {
1971 if (DEVICE_LIVE_P (XDEVICE (p->device))) 2039 if (DEVICE_LIVE_P (XDEVICE (p->device)))
1972 { 2040 {
1973 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET 2041 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET
1974 || 2042 ||
1975 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW) 2043 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
1976 { 2044 {
2045 #ifdef DEBUG_WIDGETS
2046 debug_widget_instances--;
2047 stderr_out ("widget destroyed, %d left\n", debug_widget_instances);
2048 #endif
1977 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) 2049 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
1978 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)); 2050 {
1979 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0; 2051 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p));
2052 DestroyWindow (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p));
2053 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
2054 }
1980 } 2055 }
1981 else if (p->data) 2056 else if (p->data)
1982 { 2057 {
1983 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)) 2058 int i;
1984 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); 2059 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p))
1985 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0; 2060 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p));
2061
2062 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p))
2063 {
2064 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++)
2065 {
2066 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i))
2067 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i));
2068 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i) = 0;
2069 }
2070 xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p));
2071 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p) = 0;
2072 }
1986 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) 2073 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
1987 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p)); 2074 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
1988 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0; 2075 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
1989 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p)) 2076 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
1990 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p)); 2077 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
2001 2088
2002 /************************************************************************/ 2089 /************************************************************************/
2003 /* subwindow and widget support */ 2090 /* subwindow and widget support */
2004 /************************************************************************/ 2091 /************************************************************************/
2005 2092
2093 static HFONT
2094 mswindows_widget_hfont (Lisp_Image_Instance *p,
2095 Lisp_Object domain)
2096 {
2097 Lisp_Object face = IMAGE_INSTANCE_WIDGET_FACE (p);
2098 int under = FACE_UNDERLINE_P (face, domain);
2099 int strike = FACE_STRIKETHRU_P (face, domain);
2100 Lisp_Object font = query_string_font (IMAGE_INSTANCE_WIDGET_TEXT (p),
2101 face, domain);
2102
2103 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike);
2104 }
2105
2006 /* unmap the image if it is a widget. This is used by redisplay via 2106 /* unmap the image if it is a widget. This is used by redisplay via
2007 redisplay_unmap_subwindows */ 2107 redisplay_unmap_subwindows */
2008 static void 2108 static void
2009 mswindows_unmap_subwindow (struct Lisp_Image_Instance *p) 2109 mswindows_unmap_subwindow (Lisp_Image_Instance *p)
2010 { 2110 {
2011 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) 2111 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
2012 { 2112 {
2013 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2113 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2014 NULL, 2114 NULL,
2015 0, 0, 0, 0, 2115 0, 0, 0, 0,
2016 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE 2116 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE
2017 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); 2117 | SWP_NOSENDCHANGING);
2118 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p))
2119 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p)));
2018 } 2120 }
2019 } 2121 }
2020 2122
2021 /* map the subwindow. This is used by redisplay via 2123 /* map the subwindow. This is used by redisplay via
2022 redisplay_output_subwindow */ 2124 redisplay_output_subwindow */
2023 static void 2125 static void
2024 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y) 2126 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y,
2025 { 2127 struct display_glyph_area* dga)
2026 /* ShowWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), SW_SHOW);*/ 2128 {
2027 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2129 /* move the window before mapping it ... */
2028 NULL, 2130 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2029 x, y, 0, 0, 2131 NULL,
2030 SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOSIZE 2132 x, y, dga->width, dga->height,
2133 SWP_NOZORDER
2031 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); 2134 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2135 /* ... adjust the child ... */
2136 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2137 NULL,
2138 -dga->xoffset, -dga->yoffset, 0, 0,
2139 SWP_NOZORDER | SWP_NOSIZE
2140 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2141 /* ... now map it - we are not allowed to move it at the same time. */
2142 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2143 NULL,
2144 0, 0, 0, 0,
2145 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE
2146 | SWP_SHOWWINDOW | SWP_NOCOPYBITS
2147 | SWP_NOSENDCHANGING);
2148 }
2149
2150 /* resize the subwindow instance */
2151 static void
2152 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h)
2153 {
2154 /* Set the size of the control .... */
2155 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2156 NULL,
2157 0, 0, w, h,
2158 SWP_NOZORDER | SWP_NOMOVE
2159 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2160 }
2161
2162 /* Simply resize the window here. */
2163 static void
2164 mswindows_update_subwindow (Lisp_Image_Instance *p)
2165 {
2166 mswindows_resize_subwindow (p,
2167 IMAGE_INSTANCE_WIDTH (p),
2168 IMAGE_INSTANCE_HEIGHT (p));
2032 } 2169 }
2033 2170
2034 /* when you click on a widget you may activate another widget this 2171 /* when you click on a widget you may activate another widget this
2035 needs to be checked and all appropriate widgets updated */ 2172 needs to be checked and all appropriate widgets updated */
2036 static void 2173 static void
2037 mswindows_update_subwindow (struct Lisp_Image_Instance *p) 2174 mswindows_update_widget (Lisp_Image_Instance *p)
2038 { 2175 {
2039 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) 2176 /* Possibly update the face font and colors. */
2040 { 2177 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p))
2041 /* buttons checked or otherwise */ 2178 {
2042 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton)) 2179 /* set the widget font from the widget face */
2043 { 2180 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2044 if (gui_item_selected_p (&IMAGE_INSTANCE_WIDGET_ITEM (p))) 2181 WM_SETFONT,
2045 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2182 (WPARAM) mswindows_widget_hfont
2046 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); 2183 (p, IMAGE_INSTANCE_SUBWINDOW_FRAME (p)),
2047 else 2184 MAKELPARAM (TRUE, 0));
2048 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2185 }
2049 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); 2186 /* Possibly update the dimensions. */
2050 } 2187 if (IMAGE_INSTANCE_SIZE_CHANGED (p))
2188 {
2189 mswindows_resize_subwindow (p,
2190 IMAGE_INSTANCE_WIDTH (p),
2191 IMAGE_INSTANCE_HEIGHT (p));
2192 }
2193 /* Possibly update the text in the widget. */
2194 if (IMAGE_INSTANCE_TEXT_CHANGED (p))
2195 {
2196 Extbyte* lparam=0;
2197 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (p),
2198 C_STRING_ALLOCA, lparam,
2199 Qnative);
2200 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2201 WM_SETTEXT, 0, (LPARAM)lparam);
2051 } 2202 }
2052 } 2203 }
2053 2204
2054 /* register widgets into our hastable so that we can cope with the 2205 /* register widgets into our hastable so that we can cope with the
2055 callbacks. The hashtable is weak so deregistration is handled 2206 callbacks. The hashtable is weak so deregistration is handled
2056 automatically */ 2207 automatically */
2057 static int 2208 static int
2058 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain) 2209 mswindows_register_gui_item (Lisp_Object gui, Lisp_Object domain)
2059 { 2210 {
2060 Lisp_Object frame = FW_FRAME (domain); 2211 Lisp_Object frame = FW_FRAME (domain);
2061 struct frame* f = XFRAME (frame); 2212 struct frame* f = XFRAME (frame);
2062 int id = gui_item_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f), 2213 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f),
2063 &XIMAGE_INSTANCE_WIDGET_ITEM (instance), 2214 gui,
2064 WIDGET_GLYPH_SLOT); 2215 WIDGET_GLYPH_SLOT);
2065 Fputhash (make_int (id), 2216 Fputhash (make_int (id),
2066 XIMAGE_INSTANCE_WIDGET_CALLBACK (instance), 2217 XGUI_ITEM (gui)->callback,
2067 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f)); 2218 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f));
2068 return id; 2219 return id;
2220 }
2221
2222 static int
2223 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain)
2224 {
2225 return mswindows_register_gui_item (XIMAGE_INSTANCE_WIDGET_ITEM (instance),
2226 domain);
2069 } 2227 }
2070 2228
2071 static void 2229 static void
2072 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2230 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2073 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2231 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2074 int dest_mask, Lisp_Object domain) 2232 int dest_mask, Lisp_Object domain)
2075 { 2233 {
2076 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2234 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2077 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 2235 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
2078 struct device* d = XDEVICE (device); 2236 struct device* d = XDEVICE (device);
2079 Lisp_Object frame = FW_FRAME (domain); 2237 Lisp_Object frame = FW_FRAME (domain);
2080 HWND wnd; 2238 HWND wnd;
2081 2239
2083 signal_simple_error ("Not an mswindows device", device); 2241 signal_simple_error ("Not an mswindows device", device);
2084 2242
2085 /* have to set the type this late in case there is no device 2243 /* have to set the type this late in case there is no device
2086 instantiation for a widget */ 2244 instantiation for a widget */
2087 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; 2245 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
2088 2246 /* Allocate space for the clip window */
2089 wnd = CreateWindow( "STATIC", 2247 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
2248
2249 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
2250 = CreateWindowEx(
2251 0, /* EX flags */
2252 XEMACS_CONTROL_CLASS,
2253 0, /* text */
2254 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
2255 0, /* starting x position */
2256 0, /* starting y position */
2257 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2258 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2259 /* parent window */
2260 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2261 NULL, /* No menu */
2262 NULL, /* must be null for this class */
2263 NULL)) == NULL)
2264 signal_simple_error ("window creation failed with code",
2265 make_int (GetLastError()));
2266
2267 wnd = CreateWindow( "STATIC",
2090 "", 2268 "",
2091 WS_CHILD, 2269 WS_CHILD,
2092 0, /* starting x position */ 2270 0, /* starting x position */
2093 0, /* starting y position */ 2271 0, /* starting y position */
2094 IMAGE_INSTANCE_WIDGET_WIDTH (ii), 2272 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2095 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), 2273 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2096 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), /* parent window */ 2274 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
2097 0, 2275 0,
2098 (HINSTANCE) 2276 (HINSTANCE)
2099 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2277 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2100 GWL_HINSTANCE), 2278 GWL_HINSTANCE),
2101 NULL); 2279 NULL);
2102 2280
2103 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); 2281 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
2104 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; 2282 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
2105 } 2283 }
2106 2284
2107 static int 2285 static int
2108 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1, 2286 mswindows_image_instance_equal (Lisp_Image_Instance *p1,
2109 struct Lisp_Image_Instance *p2, int depth) 2287 Lisp_Image_Instance *p2, int depth)
2110 { 2288 {
2111 switch (IMAGE_INSTANCE_TYPE (p1)) 2289 switch (IMAGE_INSTANCE_TYPE (p1))
2112 { 2290 {
2113 case IMAGE_MONO_PIXMAP: 2291 case IMAGE_MONO_PIXMAP:
2114 case IMAGE_COLOR_PIXMAP: 2292 case IMAGE_COLOR_PIXMAP:
2115 case IMAGE_POINTER: 2293 case IMAGE_POINTER:
2116 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1) 2294 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
2117 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2)) 2295 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
2118 return 0; 2296 return 0;
2119 break; 2297 break;
2120 2298
2121 default: 2299 default:
2122 break; 2300 break;
2123 } 2301 }
2124 2302
2125 return 1; 2303 return 1;
2126 } 2304 }
2127 2305
2128 static unsigned long 2306 static unsigned long
2129 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth) 2307 mswindows_image_instance_hash (Lisp_Image_Instance *p, int depth)
2130 { 2308 {
2131 switch (IMAGE_INSTANCE_TYPE (p)) 2309 switch (IMAGE_INSTANCE_TYPE (p))
2132 { 2310 {
2133 case IMAGE_MONO_PIXMAP: 2311 case IMAGE_MONO_PIXMAP:
2134 case IMAGE_COLOR_PIXMAP: 2312 case IMAGE_COLOR_PIXMAP:
2135 case IMAGE_POINTER: 2313 case IMAGE_POINTER:
2136 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p); 2314 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
2137 2315
2138 default: 2316 default:
2139 return 0; 2317 return 0;
2140 } 2318 }
2141 } 2319 }
2142 2320
2145 method. It is assumed that the device slot within the image 2323 method. It is assumed that the device slot within the image
2146 instance is already set -- this is the case when instantiate 2324 instance is already set -- this is the case when instantiate
2147 methods are called. */ 2325 methods are called. */
2148 2326
2149 static void 2327 static void
2150 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, 2328 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii,
2329 int slices,
2151 enum image_instance_type type) 2330 enum image_instance_type type)
2152 { 2331 {
2153 ii->data = xnew_and_zero (struct mswindows_image_instance_data); 2332 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
2154 IMAGE_INSTANCE_TYPE (ii) = type; 2333 IMAGE_INSTANCE_TYPE (ii) = type;
2155 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil; 2334 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
2156 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil; 2335 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
2157 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil; 2336 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
2158 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil; 2337 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
2159 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil; 2338 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
2160 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil; 2339 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
2340 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices;
2341 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (ii) =
2342 xnew_array_and_zero (HBITMAP, slices);
2161 } 2343 }
2162 2344
2163 2345
2346 #ifdef HAVE_WIDGETS
2347
2164 /************************************************************************/ 2348 /************************************************************************/
2165 /* widgets */ 2349 /* widgets */
2166 /************************************************************************/ 2350 /************************************************************************/
2167
2168 static void 2351 static void
2169 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2352 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2170 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2353 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2171 int dest_mask, Lisp_Object domain, 2354 int dest_mask, Lisp_Object domain,
2172 CONST char* class, int flags, int exflags) 2355 const char* class, int flags, int exflags)
2173 { 2356 {
2174 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2357 /* this function can call lisp */
2175 #if 0 2358 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2176 struct Lisp_Image_Instance *groupii = 0;
2177 Lisp_Object group = find_keyword_in_vector (instantiator, Q_group);
2178 #endif
2179 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; 2359 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style;
2180 struct device* d = XDEVICE (device); 2360 struct device* d = XDEVICE (device);
2181 Lisp_Object frame = FW_FRAME (domain); 2361 Lisp_Object frame = FW_FRAME (domain);
2182 Extbyte* nm=0; 2362 Extbyte* nm=0;
2183 HWND wnd; 2363 HWND wnd;
2184 int id = 0xffff; 2364 int id = 0xffff;
2185 struct gui_item* pgui = &IMAGE_INSTANCE_WIDGET_ITEM (ii); 2365 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2366 Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
2186 2367
2187 if (!DEVICE_MSWINDOWS_P (d)) 2368 if (!DEVICE_MSWINDOWS_P (d))
2188 signal_simple_error ("Not an mswindows device", device); 2369 signal_simple_error ("Not an mswindows device", device);
2189 #if 0 2370
2190 /* if the user specified another glyph as a group pick up the 2371 if (!gui_item_active_p (gui))
2191 instance in our domain. */
2192 if (!NILP (group))
2193 {
2194 if (SYMBOLP (group))
2195 group = XSYMBOL (group)->value;
2196 group = glyph_image_instance (group, domain, ERROR_ME, 1);
2197 groupii = XIMAGE_INSTANCE (group);
2198 }
2199 #endif
2200 if (!gui_item_active_p (pgui))
2201 flags |= WS_DISABLED; 2372 flags |= WS_DISABLED;
2202 2373
2203 style = pgui->style; 2374 style = pgui->style;
2204 2375
2205 if (!NILP (pgui->callback)) 2376 if (!NILP (pgui->callback))
2206 { 2377 {
2207 id = mswindows_register_widget_instance (image_instance, domain); 2378 id = mswindows_register_widget_instance (image_instance, domain);
2208 } 2379 }
2209 /* have to set the type this late in case there is no device 2380
2210 instantiation for a widget */
2211 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
2212 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) 2381 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
2213 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm); 2382 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii),
2214 2383 C_STRING_ALLOCA, nm,
2215 wnd = CreateWindowEx( 2384 Qnative);
2216 exflags /* | WS_EX_NOPARENTNOTIFY*/, 2385
2217 class, 2386 /* allocate space for the clip window and then allocate the clip window */
2218 nm, 2387 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
2219 flags | WS_CHILD, 2388
2220 0, /* starting x position */ 2389 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
2221 0, /* starting y position */ 2390 = CreateWindowEx(
2222 IMAGE_INSTANCE_WIDGET_WIDTH (ii), 2391 WS_EX_CONTROLPARENT, /* EX flags */
2223 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), 2392 XEMACS_CONTROL_CLASS,
2224 /* parent window */ 2393 0, /* text */
2225 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2394 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
2226 (HMENU)id, /* No menu */ 2395 0, /* starting x position */
2227 (HINSTANCE) 2396 0, /* starting y position */
2228 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2397 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2229 GWL_HINSTANCE), 2398 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2230 NULL); 2399 /* parent window */
2400 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2401 (HMENU)id, /* No menu */
2402 NULL, /* must be null for this class */
2403 NULL)) == NULL)
2404 signal_simple_error ("window creation failed with code",
2405 make_int (GetLastError()));
2406
2407 if ((wnd = CreateWindowEx(
2408 exflags /* | WS_EX_NOPARENTNOTIFY*/,
2409 class,
2410 nm,
2411 flags | WS_CHILD | WS_VISIBLE,
2412 0, /* starting x position */
2413 0, /* starting y position */
2414 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2415 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2416 /* parent window */
2417 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
2418 (HMENU)id, /* No menu */
2419 (HINSTANCE)
2420 GetWindowLong
2421 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2422 GWL_HINSTANCE),
2423 NULL)) == NULL)
2424 signal_simple_error ("window creation failed with code",
2425 make_int (GetLastError()));
2231 2426
2232 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; 2427 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
2233 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); 2428 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
2234 /* set the widget font from the widget face */ 2429 /* set the widget font from the widget face */
2235 SendMessage (wnd, WM_SETFONT, 2430 SendMessage (wnd, WM_SETFONT,
2236 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT 2431 (WPARAM) mswindows_widget_hfont (ii, domain),
2237 (XFONT_INSTANCE (widget_face_font_info
2238 (domain,
2239 IMAGE_INSTANCE_WIDGET_FACE (ii),
2240 0, 0))),
2241 MAKELPARAM (TRUE, 0)); 2432 MAKELPARAM (TRUE, 0));
2242 } 2433 }
2243 2434
2244 /* Instantiate a button widget. Unfortunately instantiated widgets are 2435 /* Instantiate a button widget. Unfortunately instantiated widgets are
2245 particular to a frame since they need to have a parent. It's not 2436 particular to a frame since they need to have a parent. It's not
2246 like images where you just select the image into the context you 2437 like images where you just select the image into the context you
2247 want to display it in and BitBlt it. So images instances can have a 2438 want to display it in and BitBlt it. So image instances can have a
2248 many-to-one relationship with things you see, whereas widgets can 2439 many-to-one relationship with things you see, whereas widgets can
2249 only be one-to-one (i.e. per frame) */ 2440 only be one-to-one (i.e. per frame) */
2250 static void 2441 static void
2251 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2442 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2252 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2443 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2253 int dest_mask, Lisp_Object domain) 2444 int dest_mask, Lisp_Object domain)
2254 { 2445 {
2255 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2446 /* this function can call lisp */
2447 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2256 HWND wnd; 2448 HWND wnd;
2257 int flags = BS_NOTIFY; 2449 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback
2450 only. Since we seem to want nothing beyond BN_CLICK,
2451 the style is perhaps not necessary -- kkm */
2258 Lisp_Object style; 2452 Lisp_Object style;
2259 struct gui_item* pgui = &IMAGE_INSTANCE_WIDGET_ITEM (ii); 2453 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2454 Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
2260 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); 2455 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
2261
2262 if (!gui_item_active_p (pgui))
2263 flags |= WS_DISABLED;
2264 2456
2265 if (!NILP (glyph)) 2457 if (!NILP (glyph))
2266 { 2458 {
2267 if (!IMAGE_INSTANCEP (glyph)) 2459 if (!IMAGE_INSTANCEP (glyph))
2268 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1); 2460 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1);
2269 2461
2270 if (IMAGE_INSTANCEP (glyph)) 2462 if (IMAGE_INSTANCEP (glyph))
2271 flags |= XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? 2463 flags |= XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2272 BS_BITMAP : BS_ICON; 2464 BS_BITMAP : BS_ICON;
2273 } 2465 }
2274 2466
2275 style = pgui->style; 2467 style = pgui->style;
2276 2468
2469 /* #### consider using the default face for radio and toggle
2470 buttons. */
2277 if (EQ (style, Qradio)) 2471 if (EQ (style, Qradio))
2278 { 2472 {
2279 flags |= BS_RADIOBUTTON; 2473 flags |= BS_RADIOBUTTON;
2280 } 2474 }
2281 else if (EQ (style, Qtoggle)) 2475 else if (EQ (style, Qtoggle))
2282 { 2476 {
2283 flags |= BS_AUTOCHECKBOX; 2477 flags |= BS_AUTOCHECKBOX;
2284 } 2478 }
2285 else 2479 else
2286 flags |= BS_DEFPUSHBUTTON; 2480 {
2481 flags |= BS_DEFPUSHBUTTON;
2482 }
2287 2483
2288 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2484 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2289 pointer_bg, dest_mask, domain, "BUTTON", flags, 2485 pointer_bg, dest_mask, domain, "BUTTON",
2290 WS_EX_CONTROLPARENT); 2486 flags, 0);
2291 2487
2292 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2488 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2293 /* set the checked state */ 2489 /* set the checked state */
2294 if (gui_item_selected_p (pgui)) 2490 if (gui_item_selected_p (gui))
2295 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); 2491 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
2296 else 2492 else
2297 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); 2493 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
2298 /* add the image if one was given */ 2494 /* add the image if one was given */
2299 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)) 2495 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)
2300 { 2496 &&
2301 SendMessage (wnd, BM_SETIMAGE, 2497 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph)))
2302 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? 2498 {
2499 SendMessage (wnd, BM_SETIMAGE,
2500 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2303 IMAGE_BITMAP : IMAGE_ICON), 2501 IMAGE_BITMAP : IMAGE_ICON),
2304 (LPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? 2502 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2305 XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : 2503 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) :
2306 XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); 2504 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph)));
2307 } 2505 }
2506 }
2507
2508 /* Update the state of a button. */
2509 static void
2510 mswindows_button_update (Lisp_Object image_instance)
2511 {
2512 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2513 /* buttons checked or otherwise */
2514 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii)))
2515 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2516 BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
2517 else
2518 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2519 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
2308 } 2520 }
2309 2521
2310 /* instantiate an edit control */ 2522 /* instantiate an edit control */
2311 static void 2523 static void
2312 mswindows_edit_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2524 mswindows_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2313 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2525 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2314 int dest_mask, Lisp_Object domain) 2526 int dest_mask, Lisp_Object domain)
2315 { 2527 {
2316 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2528 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2317 pointer_bg, dest_mask, domain, "EDIT", 2529 pointer_bg, dest_mask, domain, "EDIT",
2318 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP 2530 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP
2319 | WS_BORDER, 2531 | WS_BORDER, WS_EX_CLIENTEDGE);
2320 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); 2532 }
2321 } 2533
2322 2534 /* instantiate a progress gauge */
2323 /* instantiate an edit control */ 2535 static void
2324 static void 2536 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2325 mswindows_progress_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2326 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2537 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2327 int dest_mask, Lisp_Object domain) 2538 int dest_mask, Lisp_Object domain)
2328 { 2539 {
2329 HWND wnd; 2540 HWND wnd;
2330 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2541 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2331 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2542 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2332 pointer_bg, dest_mask, domain, PROGRESS_CLASS, 2543 pointer_bg, dest_mask, domain, PROGRESS_CLASS,
2333 WS_TABSTOP | WS_BORDER | PBS_SMOOTH, 2544 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE);
2334 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT);
2335 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2545 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2336 /* set the colors */ 2546 /* set the colors */
2337 #ifdef PBS_SETBKCOLOR 2547 #ifdef PBS_SETBKCOLOR
2338 SendMessage (wnd, PBS_SETBKCOLOR, 0, 2548 SendMessage (wnd, PBS_SETBKCOLOR, 0,
2339 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR 2549 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR
2340 (XCOLOR_INSTANCE 2550 (XCOLOR_INSTANCE
2341 (FACE_BACKGROUND 2551 (FACE_BACKGROUND
2342 (XIMAGE_INSTANCE_WIDGET_FACE (ii), 2552 (XIMAGE_INSTANCE_WIDGET_FACE (ii),
2343 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii)))))); 2553 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii))))));
2344 #endif 2554 #endif
2345 #ifdef PBS_SETBARCOLOR 2555 #ifdef PBS_SETBARCOLOR
2346 SendMessage (wnd, PBS_SETBARCOLOR, 0, 2556 SendMessage (wnd, PBS_SETBARCOLOR, 0,
2347 (L:PARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR 2557 (L:PARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR
2348 (XCOLOR_INSTANCE 2558 (XCOLOR_INSTANCE
2349 (FACE_FOREGROUND 2559 (FACE_FOREGROUND
2350 (XIMAGE_INSTANCE_WIDGET_FACE (ii), 2560 (XIMAGE_INSTANCE_WIDGET_FACE (ii),
2351 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii)))))); 2561 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii))))));
2352 #endif 2562 #endif
2353 } 2563 }
2354 2564
2565 /* instantiate a tree view widget */
2566 static HTREEITEM add_tree_item (Lisp_Object image_instance,
2567 HWND wnd, HTREEITEM parent, Lisp_Object item,
2568 int children, Lisp_Object domain)
2569 {
2570 TV_INSERTSTRUCT tvitem;
2571 HTREEITEM ret;
2572
2573 tvitem.hParent = parent;
2574 tvitem.hInsertAfter = TVI_LAST;
2575 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN;
2576 tvitem.item.cChildren = children;
2577
2578 if (GUI_ITEMP (item))
2579 {
2580 tvitem.item.lParam = mswindows_register_gui_item (item, domain);
2581 tvitem.item.mask |= TVIF_PARAM;
2582 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
2583 C_STRING_ALLOCA, tvitem.item.pszText,
2584 Qnative);
2585 }
2586 else
2587 TO_EXTERNAL_FORMAT (LISP_STRING, item,
2588 C_STRING_ALLOCA, tvitem.item.pszText,
2589 Qnative);
2590
2591 tvitem.item.cchTextMax = strlen (tvitem.item.pszText);
2592
2593 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM,
2594 0, (LPARAM)&tvitem)) == 0)
2595 signal_simple_error ("error adding tree view entry", item);
2596
2597 return ret;
2598 }
2599
2600 static void add_tree_item_list (Lisp_Object image_instance,
2601 HWND wnd, HTREEITEM parent, Lisp_Object list,
2602 Lisp_Object domain)
2603 {
2604 Lisp_Object rest;
2605
2606 /* get the first item */
2607 parent = add_tree_item (image_instance, wnd, parent, XCAR (list), TRUE, domain);
2608 /* recursively add items to the tree view */
2609 LIST_LOOP (rest, XCDR (list))
2610 {
2611 if (LISTP (XCAR (rest)))
2612 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain);
2613 else
2614 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain);
2615 }
2616 }
2617
2618 static void
2619 mswindows_tree_view_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2620 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2621 int dest_mask, Lisp_Object domain)
2622 {
2623 Lisp_Object rest;
2624 HWND wnd;
2625 HTREEITEM parent;
2626 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2627 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2628 pointer_bg, dest_mask, domain, WC_TREEVIEW,
2629 WS_TABSTOP | WS_BORDER | PBS_SMOOTH
2630 | TVS_HASLINES | TVS_HASBUTTONS,
2631 WS_EX_CLIENTEDGE);
2632
2633 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2634
2635 /* define a root */
2636 parent = add_tree_item (image_instance, wnd, NULL,
2637 XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)),
2638 TRUE, domain);
2639
2640 /* recursively add items to the tree view */
2641 /* add items to the tab */
2642 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2643 {
2644 if (LISTP (XCAR (rest)))
2645 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain);
2646 else
2647 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain);
2648 }
2649 }
2650
2651 /* instantiate a tab control */
2652 static TC_ITEM* add_tab_item (Lisp_Object image_instance,
2653 HWND wnd, Lisp_Object item,
2654 Lisp_Object domain, int i)
2655 {
2656 TC_ITEM tvitem, *ret;
2657
2658 tvitem.mask = TCIF_TEXT;
2659
2660 if (GUI_ITEMP (item))
2661 {
2662 tvitem.lParam = mswindows_register_gui_item (item, domain);
2663 tvitem.mask |= TCIF_PARAM;
2664 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
2665 C_STRING_ALLOCA, tvitem.pszText,
2666 Qnative);
2667 }
2668 else
2669 {
2670 CHECK_STRING (item);
2671 TO_EXTERNAL_FORMAT (LISP_STRING, item,
2672 C_STRING_ALLOCA, tvitem.pszText,
2673 Qnative);
2674 }
2675
2676 tvitem.cchTextMax = strlen (tvitem.pszText);
2677
2678 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM,
2679 i, (LPARAM)&tvitem)) < 0)
2680 signal_simple_error ("error adding tab entry", item);
2681
2682 return ret;
2683 }
2684
2685 static void
2686 mswindows_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2687 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2688 int dest_mask, Lisp_Object domain)
2689 {
2690 Lisp_Object rest;
2691 HWND wnd;
2692 int i = 0;
2693 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2694 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
2695 unsigned int flags = WS_TABSTOP;
2696
2697 if (EQ (orient, Qleft) || EQ (orient, Qright))
2698 {
2699 flags |= TCS_VERTICAL | TCS_MULTILINE;
2700 }
2701 if (EQ (orient, Qright) || EQ (orient, Qbottom))
2702 {
2703 flags |= TCS_BOTTOM;
2704 }
2705
2706 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2707 pointer_bg, dest_mask, domain, WC_TABCONTROL,
2708 /* borders don't suit tabs so well */
2709 flags, 0);
2710
2711 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2712 /* add items to the tab */
2713 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2714 {
2715 add_tab_item (image_instance, wnd, XCAR (rest), domain, i);
2716 i++;
2717 }
2718 }
2719
2720 /* set the properties of a tab control */
2721 static void
2722 mswindows_tab_control_update (Lisp_Object image_instance)
2723 {
2724 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2725
2726 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii));
2727 {
2728 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2729 int i = 0;
2730 Lisp_Object rest;
2731
2732 /* delete the pre-existing items */
2733 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0);
2734
2735 /* add items to the tab */
2736 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2737 {
2738 add_tab_item (image_instance, wnd, XCAR (rest),
2739 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), i);
2740 i++;
2741 }
2742 }
2743 }
2744
2355 /* instantiate a static control possible for putting other things in */ 2745 /* instantiate a static control possible for putting other things in */
2356 static void 2746 static void
2357 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2747 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2358 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2748 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2359 int dest_mask, Lisp_Object domain) 2749 int dest_mask, Lisp_Object domain)
2360 { 2750 {
2361 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2751 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2362 pointer_bg, dest_mask, domain, "STATIC", 2752 pointer_bg, dest_mask, domain, "STATIC",
2363 0, WS_EX_STATICEDGE); 2753 0, WS_EX_STATICEDGE);
2364 } 2754 }
2365
2366 #if 0
2367 /* instantiate a static control possible for putting other things in */
2368 static void
2369 mswindows_group_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2370 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2371 int dest_mask, Lisp_Object domain)
2372 {
2373 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2374 pointer_bg, dest_mask, domain, "BUTTON",
2375 WS_GROUP | BS_GROUPBOX | WS_BORDER,
2376 WS_EX_CLIENTEDGE );
2377 }
2378 #endif
2379 2755
2380 /* instantiate a scrollbar control */ 2756 /* instantiate a scrollbar control */
2381 static void 2757 static void
2382 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2758 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2383 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2759 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2384 int dest_mask, Lisp_Object domain) 2760 int dest_mask, Lisp_Object domain)
2385 { 2761 {
2386 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2762 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2387 pointer_bg, dest_mask, domain, "SCROLLBAR", 2763 pointer_bg, dest_mask, domain, "SCROLLBAR",
2388 0, 2764 WS_TABSTOP, WS_EX_CLIENTEDGE);
2389 WS_EX_CLIENTEDGE );
2390 } 2765 }
2391 2766
2392 /* instantiate a combo control */ 2767 /* instantiate a combo control */
2393 static void 2768 static void
2394 mswindows_combo_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2769 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2395 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2770 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2396 int dest_mask, Lisp_Object domain) 2771 int dest_mask, Lisp_Object domain)
2397 { 2772 {
2398 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2773 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2399 HANDLE wnd; 2774 HANDLE wnd;
2400 Lisp_Object rest; 2775 Lisp_Object rest;
2776 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties),
2777 Q_items, Qnil);
2778 int len, height;
2401 2779
2402 /* Maybe ought to generalise this more but it may be very windows 2780 /* Maybe ought to generalise this more but it may be very windows
2403 specific. In windows the window height of a combo box is the 2781 specific. In windows the window height of a combo box is the
2404 height when the combo box is open. Thus we need to set the height 2782 height when the combo box is open. Thus we need to set the height
2405 before creating the window and then reset it to a single line 2783 before creating the window and then reset it to a single line
2406 after the window is created so that redisplay does the right 2784 after the window is created so that redisplay does the right
2407 thing. */ 2785 thing. */
2786 widget_instantiate (image_instance, instantiator, pointer_fg,
2787 pointer_bg, dest_mask, domain);
2788
2789 /* We now have everything right apart from the height. */
2790 default_face_font_info (domain, 0, 0, &height, 0, 0);
2791 GET_LIST_LENGTH (data, len);
2792
2793 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len;
2794 IMAGE_INSTANCE_HEIGHT (ii) = height;
2795
2796 /* Now create the widget. */
2408 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2797 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2409 pointer_bg, dest_mask, domain, "COMBOBOX", 2798 pointer_bg, dest_mask, domain, "COMBOBOX",
2410 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN 2799 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN
2411 | CBS_AUTOHSCROLL 2800 | CBS_AUTOHSCROLL
2412 | CBS_HASSTRINGS | WS_VSCROLL, 2801 | CBS_HASSTRINGS | WS_VSCROLL,
2413 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); 2802 WS_EX_CLIENTEDGE);
2414 /* reset the height */ 2803 /* Reset the height. layout will probably do this safely, but better make sure. */
2415 widget_text_to_pixel_conversion (domain, 2804 image_instance_layout (image_instance,
2416 IMAGE_INSTANCE_WIDGET_FACE (ii), 1, 0, 2805 IMAGE_UNSPECIFIED_GEOMETRY,
2417 &IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii), 0); 2806 IMAGE_UNSPECIFIED_GEOMETRY,
2807 domain);
2808
2418 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2809 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2419 /* add items to the combo box */ 2810 /* add items to the combo box */
2420 SendMessage (wnd, CB_RESETCONTENT, 0, 0); 2811 SendMessage (wnd, CB_RESETCONTENT, 0, 0);
2421 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) 2812 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil))
2422 { 2813 {
2423 Extbyte* lparam; 2814 Extbyte* lparam;
2424 GET_C_STRING_OS_DATA_ALLOCA (XCAR (rest), lparam); 2815 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest),
2816 C_STRING_ALLOCA, lparam,
2817 Qnative);
2425 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) 2818 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR)
2426 signal_simple_error ("error adding combo entries", instantiator); 2819 signal_simple_error ("error adding combo entries", instantiator);
2427 } 2820 }
2428 } 2821 }
2429 2822
2430 /* get properties of a control */ 2823 /* get properties of a control */
2431 static Lisp_Object 2824 static Lisp_Object
2432 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) 2825 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop)
2433 { 2826 {
2434 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2827 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2435 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2828 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2436 /* get the text from a control */ 2829 /* get the text from a control */
2437 if (EQ (prop, Q_text)) 2830 if (EQ (prop, Q_text))
2438 { 2831 {
2439 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); 2832 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0);
2440 Extbyte* buf =alloca (len+1); 2833 Extbyte* buf =alloca (len+1);
2441 2834
2442 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); 2835 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf);
2443 return build_ext_string (buf, FORMAT_OS); 2836 return build_ext_string (buf, Qnative);
2444 } 2837 }
2445 return Qunbound; 2838 return Qunbound;
2446 } 2839 }
2447 2840
2448 /* get properties of a button */ 2841 /* get properties of a button */
2449 static Lisp_Object 2842 static Lisp_Object
2450 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) 2843 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop)
2451 { 2844 {
2452 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2845 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2453 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2846 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2454 /* check the state of a button */ 2847 /* check the state of a button */
2455 if (EQ (prop, Q_selected)) 2848 if (EQ (prop, Q_selected))
2456 { 2849 {
2457 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) 2850 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED)
2462 return Qunbound; 2855 return Qunbound;
2463 } 2856 }
2464 2857
2465 /* get properties of a combo box */ 2858 /* get properties of a combo box */
2466 static Lisp_Object 2859 static Lisp_Object
2467 mswindows_combo_property (Lisp_Object image_instance, Lisp_Object prop) 2860 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop)
2468 { 2861 {
2469 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2862 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2470 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2863 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2471 /* get the text from a control */ 2864 /* get the text from a control */
2472 if (EQ (prop, Q_text)) 2865 if (EQ (prop, Q_text))
2473 { 2866 {
2474 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); 2867 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0);
2475 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); 2868 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0);
2476 Extbyte* buf = alloca (len+1); 2869 Extbyte* buf = alloca (len+1);
2477 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); 2870 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf);
2478 return build_ext_string (buf, FORMAT_OS); 2871 return build_ext_string (buf, Qnative);
2479 } 2872 }
2480 return Qunbound; 2873 return Qunbound;
2481 } 2874 }
2482 2875
2483 /* set the properties of a control */
2484 static Lisp_Object
2485 mswindows_widget_set_property (Lisp_Object image_instance, Lisp_Object prop,
2486 Lisp_Object val)
2487 {
2488 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2489
2490 if (EQ (prop, Q_text))
2491 {
2492 Extbyte* lparam=0;
2493 CHECK_STRING (val);
2494 GET_C_STRING_OS_DATA_ALLOCA (val, lparam);
2495 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2496 WM_SETTEXT, 0, (LPARAM)lparam);
2497 return Qt;
2498 }
2499 return Qunbound;
2500 }
2501
2502 /* set the properties of a progres guage */ 2876 /* set the properties of a progres guage */
2503 static Lisp_Object 2877 static void
2504 mswindows_progress_set_property (Lisp_Object image_instance, Lisp_Object prop, 2878 mswindows_progress_gauge_update (Lisp_Object image_instance)
2505 Lisp_Object val) 2879 {
2506 { 2880 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2507 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2881
2508 2882 if (IMAGE_INSTANCE_WIDGET_PERCENT_CHANGED (ii))
2509 if (EQ (prop, Q_percent)) 2883 {
2510 { 2884 /* #### I'm not convinced we should store this in the plist. */
2885 Lisp_Object val = Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii),
2886 Q_percent, Qnil);
2511 CHECK_INT (val); 2887 CHECK_INT (val);
2512 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), 2888 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2513 PBM_SETPOS, (WPARAM)XINT (val), 0); 2889 PBM_SETPOS, (WPARAM)XINT (val), 0);
2514 return Qt; 2890 }
2515 } 2891 }
2516 return Qunbound; 2892
2517 } 2893 LRESULT WINAPI
2894 mswindows_control_wnd_proc (HWND hwnd, UINT msg,
2895 WPARAM wParam, LPARAM lParam)
2896 {
2897 switch (msg)
2898 {
2899 case WM_NOTIFY:
2900 case WM_COMMAND:
2901 case WM_CTLCOLORBTN:
2902 case WM_CTLCOLORLISTBOX:
2903 case WM_CTLCOLOREDIT:
2904 case WM_CTLCOLORSTATIC:
2905 case WM_CTLCOLORSCROLLBAR:
2906
2907 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam);
2908 default:
2909 return DefWindowProc (hwnd, msg, wParam, lParam);
2910 }
2911 }
2912
2913 #endif /* HAVE_WIDGETS */
2518 2914
2519 2915
2520 /************************************************************************/ 2916 /************************************************************************/
2521 /* initialization */ 2917 /* initialization */
2522 /************************************************************************/ 2918 /************************************************************************/
2536 CONSOLE_HAS_METHOD (mswindows, print_image_instance); 2932 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
2537 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance); 2933 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
2538 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow); 2934 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow);
2539 CONSOLE_HAS_METHOD (mswindows, map_subwindow); 2935 CONSOLE_HAS_METHOD (mswindows, map_subwindow);
2540 CONSOLE_HAS_METHOD (mswindows, update_subwindow); 2936 CONSOLE_HAS_METHOD (mswindows, update_subwindow);
2937 CONSOLE_HAS_METHOD (mswindows, update_widget);
2541 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); 2938 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
2542 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); 2939 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
2543 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); 2940 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
2544 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); 2941 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
2942 CONSOLE_HAS_METHOD (mswindows, resize_subwindow);
2545 } 2943 }
2546 2944
2547 void 2945 void
2548 image_instantiator_format_create_glyphs_mswindows (void) 2946 image_instantiator_format_create_glyphs_mswindows (void)
2549 { 2947 {
2948 IIFORMAT_VALID_CONSOLE (mswindows, nothing);
2949 IIFORMAT_VALID_CONSOLE (mswindows, string);
2950 IIFORMAT_VALID_CONSOLE (mswindows, layout);
2951 IIFORMAT_VALID_CONSOLE (mswindows, formatted_string);
2952 IIFORMAT_VALID_CONSOLE (mswindows, inherit);
2550 /* image-instantiator types */ 2953 /* image-instantiator types */
2551 #ifdef HAVE_XPM 2954 #ifdef HAVE_XPM
2552 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm); 2955 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm);
2553 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate); 2956 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate);
2554 #endif 2957 #endif
2556 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate); 2959 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate);
2557 #ifdef HAVE_XFACE 2960 #ifdef HAVE_XFACE
2558 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface); 2961 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface);
2559 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate); 2962 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate);
2560 #endif 2963 #endif
2964 #ifdef HAVE_JPEG
2965 IIFORMAT_VALID_CONSOLE (mswindows, jpeg);
2966 #endif
2967 #ifdef HAVE_TIFF
2968 IIFORMAT_VALID_CONSOLE (mswindows, tiff);
2969 #endif
2970 #ifdef HAVE_PNG
2971 IIFORMAT_VALID_CONSOLE (mswindows, png);
2972 #endif
2973 #ifdef HAVE_GIF
2974 IIFORMAT_VALID_CONSOLE (mswindows, gif);
2975 #endif
2976 #ifdef HAVE_WIDGETS
2977 /* button widget */
2561 INITIALIZE_DEVICE_IIFORMAT (mswindows, button); 2978 INITIALIZE_DEVICE_IIFORMAT (mswindows, button);
2562 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property); 2979 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property);
2563 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate); 2980 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate);
2564 2981 IIFORMAT_HAS_DEVMETHOD (mswindows, button, update);
2565 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit); 2982
2566 IIFORMAT_HAS_DEVMETHOD (mswindows, edit, instantiate); 2983 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit_field);
2567 2984 IIFORMAT_HAS_DEVMETHOD (mswindows, edit_field, instantiate);
2985
2568 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow); 2986 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow);
2569 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate); 2987 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate);
2570 2988
2571 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget); 2989 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget);
2572 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property); 2990 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property);
2573 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, set_property); 2991
2574 #if 0 2992 /* label */
2575 INITIALIZE_DEVICE_IIFORMAT (mswindows, group);
2576 IIFORMAT_HAS_DEVMETHOD (mswindows, group, instantiate);
2577 #endif
2578 INITIALIZE_DEVICE_IIFORMAT (mswindows, label); 2993 INITIALIZE_DEVICE_IIFORMAT (mswindows, label);
2579 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate); 2994 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate);
2580 2995
2581 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo); 2996 /* combo box */
2582 IIFORMAT_HAS_DEVMETHOD (mswindows, combo, property); 2997 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo_box);
2583 IIFORMAT_HAS_DEVMETHOD (mswindows, combo, instantiate); 2998 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, property);
2584 2999 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, instantiate);
3000
3001 /* scrollbar */
2585 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar); 3002 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar);
2586 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate); 3003 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate);
2587 3004
2588 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress); 3005 /* progress gauge */
2589 IIFORMAT_HAS_DEVMETHOD (mswindows, progress, set_property); 3006 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress_gauge);
2590 IIFORMAT_HAS_DEVMETHOD (mswindows, progress, instantiate); 3007 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, update);
2591 3008 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, instantiate);
3009
3010 /* tree view widget */
3011 INITIALIZE_DEVICE_IIFORMAT (mswindows, tree_view);
3012 /* IIFORMAT_HAS_DEVMETHOD (mswindows, progress, set_property);*/
3013 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, instantiate);
3014
3015 /* tab control widget */
3016 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control);
3017 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate);
3018 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, update);
3019 #endif
3020 /* windows bitmap format */
2592 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp"); 3021 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
2593
2594 IIFORMAT_HAS_METHOD (bmp, validate); 3022 IIFORMAT_HAS_METHOD (bmp, validate);
2595 IIFORMAT_HAS_METHOD (bmp, normalize); 3023 IIFORMAT_HAS_METHOD (bmp, normalize);
2596 IIFORMAT_HAS_METHOD (bmp, possible_dest_types); 3024 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
2597 IIFORMAT_HAS_METHOD (bmp, instantiate); 3025 IIFORMAT_HAS_METHOD (bmp, instantiate);
2598 3026
2599 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string); 3027 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
2600 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string); 3028 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
2601 3029 IIFORMAT_VALID_CONSOLE (mswindows, bmp);
3030
3031 /* mswindows resources */
2602 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource, 3032 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource,
2603 "mswindows-resource"); 3033 "mswindows-resource");
2604 3034
2605 IIFORMAT_HAS_METHOD (mswindows_resource, validate); 3035 IIFORMAT_HAS_METHOD (mswindows_resource, validate);
2606 IIFORMAT_HAS_METHOD (mswindows_resource, normalize); 3036 IIFORMAT_HAS_METHOD (mswindows_resource, normalize);
2607 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types); 3037 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types);
2608 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate); 3038 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate);
2609 3039
2610 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type, 3040 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type,
2611 check_valid_resource_symbol); 3041 check_valid_resource_symbol);
2612 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id); 3042 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id);
2613 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string); 3043 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string);
3044 IIFORMAT_VALID_CONSOLE (mswindows, mswindows_resource);
2614 } 3045 }
2615 3046
2616 void 3047 void
2617 vars_of_glyphs_mswindows (void) 3048 vars_of_glyphs_mswindows (void)
2618 { 3049 {
2619 Fprovide (Qbmp);
2620 Fprovide (Qmswindows_resource);
2621 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /* 3050 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
2622 A list of the directories in which mswindows bitmap files may be found. 3051 A list of the directories in which mswindows bitmap files may be found.
2623 This is used by the `make-image-instance' function. 3052 This is used by the `make-image-instance' function.
2624 */ ); 3053 */ );
2625 Vmswindows_bitmap_file_path = Qnil; 3054 Vmswindows_bitmap_file_path = Qnil;
2626
2627 Fprovide (Qbutton);
2628 Fprovide (Qedit);
2629 Fprovide (Qcombo);
2630 Fprovide (Qscrollbar);
2631 Fprovide (Qlabel);
2632 Fprovide (Qprogress);
2633 } 3055 }
2634 3056
2635 void 3057 void
2636 complex_vars_of_glyphs_mswindows (void) 3058 complex_vars_of_glyphs_mswindows (void)
2637 { 3059 {