Mercurial > hg > xemacs-beta
comparison src/glyphs-msw.c @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | fdefd0186b75 |
children | e38acbeb1cae |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
1 /* mswindows-specific glyph objects. | 1 /* mswindows-specific glyph objects. |
2 Copyright (C) 1998, 1999, 2000 Andy Piper. | 2 Copyright (C) 1998, 1999, 2000 Andy Piper. |
3 Copyright (C) 2001, 2002 Ben Wing. | |
3 | 4 |
4 This file is part of XEmacs. | 5 This file is part of XEmacs. |
5 | 6 |
6 XEmacs is free software; you can redistribute it and/or modify it | 7 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 | 8 under the terms of the GNU General Public License as published by the |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02111-1307, USA. */ |
20 | 21 |
21 /* Synched up with: Not in FSF. */ | 22 /* Synched up with: Not in FSF. */ |
22 | 23 |
24 /* This file apparently Mule-ized, 8-7-2000, but could stand review. */ | |
25 | |
23 /* written by Andy Piper <andy@xemacs.org> plagiarising bits from | 26 /* written by Andy Piper <andy@xemacs.org> plagiarising bits from |
24 glyphs-x.c */ | 27 glyphs-x.c */ |
28 | |
29 #define NEED_MSWINDOWS_COMMCTRL | |
25 | 30 |
26 #include <config.h> | 31 #include <config.h> |
27 #include "lisp.h" | 32 #include "lisp.h" |
28 #include "lstream.h" | 33 #include "lstream.h" |
29 | 34 |
30 #define OEMRESOURCE /* Define OCR_ and friend constants */ | |
31 #include "console-msw.h" | 35 #include "console-msw.h" |
32 #include "glyphs-msw.h" | 36 #include "glyphs-msw.h" |
33 #include "objects-msw.h" | 37 #include "objects-msw.h" |
34 | 38 |
35 #include "window.h" | 39 #include "window.h" |
40 #include "opaque.h" | 44 #include "opaque.h" |
41 #include "sysdep.h" | 45 #include "sysdep.h" |
42 #include "sysfile.h" | 46 #include "sysfile.h" |
43 #include "faces.h" | 47 #include "faces.h" |
44 #include "imgproc.h" | 48 #include "imgproc.h" |
45 | |
46 #ifdef FILE_CODING | |
47 #include "file-coding.h" | 49 #include "file-coding.h" |
48 #endif | |
49 | 50 |
50 #define WIDGET_GLYPH_SLOT 0 | 51 #define WIDGET_GLYPH_SLOT 0 |
51 | 52 |
52 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); | 53 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); |
53 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); | 54 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); |
99 static void | 100 static void |
100 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, | 101 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, |
101 int slices, | 102 int slices, |
102 enum image_instance_type type); | 103 enum image_instance_type type); |
103 static void | 104 static void |
104 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, | 105 mswindows_initialize_image_instance_mask (Lisp_Image_Instance *image, |
105 HDC hcdc); | 106 HDC hcdc); |
106 | 107 |
107 /* | 108 /* |
108 * Given device D, retrieve compatible device context. D can be either | 109 * Given device D, retrieve compatible device context. D can be either |
109 * mswindows or an msprinter device. | 110 * mswindows or an msprinter device. |
156 | 157 |
157 /************************************************************************/ | 158 /************************************************************************/ |
158 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ | 159 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ |
159 /* proper display */ | 160 /* proper display */ |
160 /************************************************************************/ | 161 /************************************************************************/ |
161 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device, | 162 static BITMAPINFO *convert_EImage_to_DIBitmap (Lisp_Object device, |
162 int width, int height, | 163 int width, int height, |
163 UChar_Binary *pic, | 164 UChar_Binary *pic, |
164 int *bit_count, | 165 int *bit_count, |
165 UChar_Binary** bmp_data) | 166 UChar_Binary **bmp_data) |
166 { | 167 { |
167 struct device *d = XDEVICE (device); | 168 struct device *d = XDEVICE (device); |
168 int i,j; | 169 int i, j; |
169 RGBQUAD* colortbl; | 170 RGBQUAD *colortbl; |
170 int ncolors; | 171 int ncolors; |
171 BITMAPINFO* bmp_info; | 172 BITMAPINFO *bmp_info; |
172 UChar_Binary *ip, *dp; | 173 UChar_Binary *ip, *dp; |
173 | 174 |
174 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0) | 175 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0) |
175 { | 176 { |
176 int bpline = BPLINE(width * 3); | 177 int bpline = BPLINE(width * 3); |
179 * this function quantises to 256 colors or bit masks down to a | 180 * this function quantises to 256 colors or bit masks down to a |
180 * long. Windows can actually handle rgb triples in the raw so I | 181 * long. Windows can actually handle rgb triples in the raw so I |
181 * don't see much point trying to optimize down to the best | 182 * don't see much point trying to optimize down to the best |
182 * structure - unless it has memory / color allocation implications | 183 * structure - unless it has memory / color allocation implications |
183 * .... */ | 184 * .... */ |
184 bmp_info=xnew_and_zero (BITMAPINFO); | 185 bmp_info = xnew_and_zero (BITMAPINFO); |
185 | 186 |
186 if (!bmp_info) | 187 if (!bmp_info) |
187 { | 188 { |
188 return NULL; | 189 return NULL; |
189 } | 190 } |
190 | 191 |
191 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */ | 192 bmp_info->bmiHeader.biBitCount = 24; /* just RGB triples for now */ |
192 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */ | 193 bmp_info->bmiHeader.biCompression = BI_RGB; /* just RGB triples |
193 bmp_info->bmiHeader.biSizeImage=width*height*3; | 194 for now */ |
195 bmp_info->bmiHeader.biSizeImage = width * height * 3; | |
194 | 196 |
195 /* bitmap data needs to be in blue, green, red triples - in that | 197 /* bitmap data needs to be in blue, green, red triples - in that |
196 order, eimage is in RGB format so we need to convert */ | 198 order, eimage is in RGB format so we need to convert */ |
197 *bmp_data = xnew_array_and_zero (UChar_Binary, bpline * height); | 199 *bmp_data = xnew_array_and_zero (UChar_Binary, bpline * height); |
198 *bit_count = bpline * height; | 200 *bit_count = bpline * height; |
205 | 207 |
206 ip = pic; | 208 ip = pic; |
207 for (i = height-1; i >= 0; i--) { | 209 for (i = height-1; i >= 0; i--) { |
208 dp = (*bmp_data) + (i * bpline); | 210 dp = (*bmp_data) + (i * bpline); |
209 for (j = 0; j < width; j++) { | 211 for (j = 0; j < width; j++) { |
210 dp[2] =*ip++; | 212 dp[2] = *ip++; |
211 dp[1] =*ip++; | 213 dp[1] = *ip++; |
212 *dp =*ip++; | 214 *dp = *ip++; |
213 dp += 3; | 215 dp += 3; |
214 } | 216 } |
215 } | 217 } |
216 } | 218 } |
217 else /* scale to 256 colors */ | 219 else /* scale to 256 colors */ |
224 qtable = build_EImage_quantable(pic, width, height, 256); | 226 qtable = build_EImage_quantable(pic, width, height, 256); |
225 if (qtable == NULL) return NULL; | 227 if (qtable == NULL) return NULL; |
226 | 228 |
227 /* use our quantize table to allocate the colors */ | 229 /* use our quantize table to allocate the colors */ |
228 ncolors = qtable->num_active_colors; | 230 ncolors = qtable->num_active_colors; |
229 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) + | 231 bmp_info = (BITMAPINFO *)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) + |
230 sizeof(RGBQUAD) * ncolors); | 232 sizeof(RGBQUAD) * ncolors); |
231 if (!bmp_info) | 233 if (!bmp_info) |
232 { | 234 { |
233 xfree (qtable); | 235 xfree (qtable); |
234 return NULL; | 236 return NULL; |
235 } | 237 } |
236 | 238 |
237 colortbl=(RGBQUAD*)(((UChar_Binary*)bmp_info)+sizeof(BITMAPINFOHEADER)); | 239 colortbl = (RGBQUAD *) (((UChar_Binary *) bmp_info) + |
238 | 240 sizeof (BITMAPINFOHEADER)); |
239 bmp_info->bmiHeader.biBitCount=8; | 241 |
240 bmp_info->bmiHeader.biCompression=BI_RGB; | 242 bmp_info->bmiHeader.biBitCount = 8; |
241 bmp_info->bmiHeader.biSizeImage=bpline*height; | 243 bmp_info->bmiHeader.biCompression = BI_RGB; |
242 bmp_info->bmiHeader.biClrUsed=ncolors; | 244 bmp_info->bmiHeader.biSizeImage = bpline * height; |
243 bmp_info->bmiHeader.biClrImportant=ncolors; | 245 bmp_info->bmiHeader.biClrUsed = ncolors; |
246 bmp_info->bmiHeader.biClrImportant = ncolors; | |
244 | 247 |
245 *bmp_data = (UChar_Binary *) xmalloc_and_zero (bpline * height); | 248 *bmp_data = (UChar_Binary *) xmalloc_and_zero (bpline * height); |
246 *bit_count = bpline * height; | 249 *bit_count = bpline * height; |
247 | 250 |
248 if (!*bmp_data) | 251 if (!*bmp_data) |
276 } | 279 } |
277 } | 280 } |
278 xfree (qtable); | 281 xfree (qtable); |
279 } | 282 } |
280 /* fix up the standard stuff */ | 283 /* fix up the standard stuff */ |
281 bmp_info->bmiHeader.biWidth=width; | 284 bmp_info->bmiHeader.biWidth = width; |
282 bmp_info->bmiHeader.biHeight=height; | 285 bmp_info->bmiHeader.biHeight = height; |
283 bmp_info->bmiHeader.biPlanes=1; | 286 bmp_info->bmiHeader.biPlanes = 1; |
284 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 287 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
285 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */ | 288 bmp_info->bmiHeader.biXPelsPerMeter = 0; /* unless you know better */ |
286 bmp_info->bmiHeader.biYPelsPerMeter=0; | 289 bmp_info->bmiHeader.biYPelsPerMeter = 0; |
287 | 290 |
288 return bmp_info; | 291 return bmp_info; |
289 } | 292 } |
290 | 293 |
291 /* Given a pixmap filename, look through all of the "standard" places | 294 /* Given a pixmap filename, look through all of the "standard" places |
343 Lisp_Object instantiator, | 346 Lisp_Object instantiator, |
344 int x_hot, int y_hot, | 347 int x_hot, int y_hot, |
345 int create_mask) | 348 int create_mask) |
346 { | 349 { |
347 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); | 350 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); |
348 void* bmp_buf=0; | 351 void *bmp_buf = 0; |
349 enum image_instance_type type; | 352 enum image_instance_type type; |
350 HBITMAP bitmap; | 353 HBITMAP bitmap; |
351 HDC hdc; | 354 HDC hdc; |
352 | 355 |
353 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) | 356 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) |
407 int bmp_bits, | 410 int bmp_bits, |
408 int slice, | 411 int slice, |
409 Lisp_Object instantiator) | 412 Lisp_Object instantiator) |
410 { | 413 { |
411 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); | 414 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); |
412 void* bmp_buf=0; | 415 void *bmp_buf = 0; |
413 | 416 |
414 HBITMAP bitmap = CreateDIBSection (get_device_compdc (d), | 417 HBITMAP bitmap = CreateDIBSection (get_device_compdc (d), |
415 bmp_info, | 418 bmp_info, |
416 DIB_RGB_COLORS, | 419 DIB_RGB_COLORS, |
417 &bmp_buf, | 420 &bmp_buf, |
433 int dest_mask, | 436 int dest_mask, |
434 Lisp_Object instantiator, | 437 Lisp_Object instantiator, |
435 Lisp_Object domain) | 438 Lisp_Object domain) |
436 { | 439 { |
437 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 440 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
438 BITMAPINFO* bmp_info; | 441 BITMAPINFO * bmp_info; |
439 UChar_Binary* bmp_data; | 442 UChar_Binary * bmp_data; |
440 int bmp_bits; | 443 int bmp_bits; |
441 COLORREF bkcolor; | 444 COLORREF bkcolor; |
442 int slice; | 445 int slice; |
443 | 446 |
444 CHECK_MSGDI_DEVICE (device); | 447 CHECK_MSGDI_DEVICE (device); |
449 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); | 452 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); |
450 | 453 |
451 for (slice = 0; slice < slices; slice++) | 454 for (slice = 0; slice < slices; slice++) |
452 { | 455 { |
453 /* build a bitmap from the eimage */ | 456 /* build a bitmap from the eimage */ |
454 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, | 457 if (!(bmp_info = convert_EImage_to_DIBitmap (device, width, height, |
455 eimage + (width * height * 3 * slice), | 458 eimage + (width * height * 3 * slice), |
456 &bmp_bits, &bmp_data))) | 459 &bmp_bits, &bmp_data))) |
457 { | 460 { |
458 signal_image_error ("EImage to DIBitmap conversion failed", | 461 signal_image_error ("EImage to DIBitmap conversion failed", |
459 instantiator); | 462 instantiator); |
472 xfree (bmp_data); | 475 xfree (bmp_data); |
473 } | 476 } |
474 } | 477 } |
475 | 478 |
476 inline static void | 479 inline static void |
477 set_mono_pixel (UChar_Binary* bits, | 480 set_mono_pixel (UChar_Binary *bits, |
478 int bpline, int height, | 481 int bpline, int height, |
479 int x, int y, int white) | 482 int x, int y, int white) |
480 { | 483 { |
481 int i; | 484 int i; |
482 UChar_Binary bitnum; | 485 UChar_Binary bitnum; |
491 else /* Turn it off */ | 494 else /* Turn it off */ |
492 bits[i] &= ~(1 << bitnum); | 495 bits[i] &= ~(1 << bitnum); |
493 } | 496 } |
494 | 497 |
495 static void | 498 static void |
496 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, | 499 mswindows_initialize_image_instance_mask (Lisp_Image_Instance *image, |
497 HDC hcdc) | 500 HDC hcdc) |
498 { | 501 { |
499 HBITMAP mask; | 502 HBITMAP mask; |
500 HGDIOBJ old = NULL; | 503 HGDIOBJ old = NULL; |
501 UChar_Binary *dibits, *and_bits; | 504 UChar_Binary *dibits, *and_bits; |
502 BITMAPINFO *bmp_info = | 505 BITMAPINFO *bmp_info = |
503 (BITMAPINFO*) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD)); | 506 (BITMAPINFO *) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD)); |
504 int i, j; | 507 int i, j; |
505 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image); | 508 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image); |
506 | 509 |
507 int maskbpline = BPLINE ((IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) + 7) / 8); | 510 int maskbpline = BPLINE ((IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) + 7) / 8); |
508 int bpline = BPLINE (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) * 3); | 511 int bpline = BPLINE (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) * 3); |
509 | 512 |
510 if (!bmp_info) | 513 if (!bmp_info) |
511 return; | 514 return; |
512 | 515 |
513 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); | 516 bmp_info->bmiHeader.biWidth = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); |
514 bmp_info->bmiHeader.biHeight = height; | 517 bmp_info->bmiHeader.biHeight = height; |
515 bmp_info->bmiHeader.biPlanes = 1; | 518 bmp_info->bmiHeader.biPlanes = 1; |
516 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 519 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
517 bmp_info->bmiHeader.biBitCount = 1; | 520 bmp_info->bmiHeader.biBitCount = 1; |
518 bmp_info->bmiHeader.biCompression = BI_RGB; | 521 bmp_info->bmiHeader.biCompression = BI_RGB; |
519 bmp_info->bmiHeader.biClrUsed = 2; | 522 bmp_info->bmiHeader.biClrUsed = 2; |
520 bmp_info->bmiHeader.biClrImportant = 2; | 523 bmp_info->bmiHeader.biClrImportant = 2; |
521 bmp_info->bmiHeader.biSizeImage = height * maskbpline; | 524 bmp_info->bmiHeader.biSizeImage = height * maskbpline; |
529 bmp_info->bmiColors[0].rgbReserved = 0; | 532 bmp_info->bmiColors[0].rgbReserved = 0; |
530 | 533 |
531 if (!(mask = CreateDIBSection (hcdc, | 534 if (!(mask = CreateDIBSection (hcdc, |
532 bmp_info, | 535 bmp_info, |
533 DIB_RGB_COLORS, | 536 DIB_RGB_COLORS, |
534 (void**)&and_bits, | 537 (void **)&and_bits, |
535 0,0))) | 538 0,0))) |
536 { | 539 { |
537 xfree (bmp_info); | 540 xfree (bmp_info); |
538 return; | 541 return; |
539 } | 542 } |
550 bmp_info->bmiHeader.biCompression = BI_RGB; | 553 bmp_info->bmiHeader.biCompression = BI_RGB; |
551 bmp_info->bmiHeader.biClrUsed = 0; | 554 bmp_info->bmiHeader.biClrUsed = 0; |
552 bmp_info->bmiHeader.biClrImportant = 0; | 555 bmp_info->bmiHeader.biClrImportant = 0; |
553 bmp_info->bmiHeader.biSizeImage = height * bpline; | 556 bmp_info->bmiHeader.biSizeImage = height * bpline; |
554 | 557 |
555 dibits = (UChar_Binary*) xmalloc_and_zero (bpline * height); | 558 dibits = (UChar_Binary *) xmalloc_and_zero (bpline * height); |
556 if (GetDIBits (hcdc, | 559 if (GetDIBits (hcdc, |
557 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), | 560 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), |
558 0, | 561 0, |
559 height, | 562 height, |
560 dibits, | 563 dibits, |
567 | 570 |
568 /* now set the colored bits in the mask and transparent ones to | 571 /* now set the colored bits in the mask and transparent ones to |
569 black in the original */ | 572 black in the original */ |
570 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++) | 573 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++) |
571 { | 574 { |
572 for (j=0; j<height; j++) | 575 for (j = 0; j < height; j++) |
573 { | 576 { |
574 UChar_Binary* idx = &dibits[j * bpline + i * 3]; | 577 UChar_Binary *idx = &dibits[j * bpline + i * 3]; |
575 | 578 |
576 if (RGB (idx[2], idx[1], idx[0]) == transparent_color) | 579 if (RGB (idx[2], idx[1], idx[0]) == transparent_color) |
577 { | 580 { |
578 idx[0] = idx[1] = idx[2] = 0; | 581 idx[0] = idx[1] = idx[2] = 0; |
579 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE); | 582 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE); |
600 | 603 |
601 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; | 604 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; |
602 } | 605 } |
603 | 606 |
604 void | 607 void |
605 mswindows_initialize_image_instance_icon (Lisp_Image_Instance* image, | 608 mswindows_initialize_image_instance_icon (Lisp_Image_Instance *image, |
606 int cursor) | 609 int cursor) |
607 { | 610 { |
608 ICONINFO x_icon; | 611 ICONINFO x_icon; |
609 | 612 |
610 /* we rely on windows to do any resizing necessary */ | 613 /* we rely on windows to do any resizing necessary */ |
611 x_icon.fIcon=cursor ? FALSE : TRUE; | 614 x_icon.fIcon = cursor ? FALSE : TRUE; |
612 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image)); | 615 x_icon.xHotspot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image)); |
613 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image)); | 616 x_icon.yHotspot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image)); |
614 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image); | 617 x_icon.hbmMask = IMAGE_INSTANCE_MSWINDOWS_MASK (image); |
615 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image); | 618 x_icon.hbmColor = IMAGE_INSTANCE_MSWINDOWS_BITMAP (image); |
616 | 619 |
617 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= | 620 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= |
618 CreateIconIndirect (&x_icon); | 621 CreateIconIndirect (&x_icon); |
619 } | 622 } |
620 | 623 |
652 | 655 |
653 return newbmp; | 656 return newbmp; |
654 } | 657 } |
655 | 658 |
656 HBITMAP | 659 HBITMAP |
657 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii, | 660 mswindows_create_resized_bitmap (Lisp_Image_Instance *ii, |
658 struct frame* f, | 661 struct frame *f, |
659 int newx, int newy) | 662 int newx, int newy) |
660 { | 663 { |
661 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii), | 664 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii), |
662 f, | 665 f, |
663 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | 666 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), |
664 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | 667 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), |
665 newx, newy); | 668 newx, newy); |
666 } | 669 } |
667 | 670 |
668 HBITMAP | 671 HBITMAP |
669 mswindows_create_resized_mask (Lisp_Image_Instance* ii, | 672 mswindows_create_resized_mask (Lisp_Image_Instance *ii, |
670 struct frame* f, | 673 struct frame *f, |
671 int newx, int newy) | 674 int newx, int newy) |
672 { | 675 { |
673 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii) == NULL) | 676 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii) == NULL) |
674 return NULL; | 677 return NULL; |
675 | 678 |
682 | 685 |
683 #if 0 /* Currently unused */ | 686 #if 0 /* Currently unused */ |
684 /* #### Warning: This function is not correct anymore with | 687 /* #### Warning: This function is not correct anymore with |
685 resizable printer bitmaps. If you uncomment it, clean it. --kkm */ | 688 resizable printer bitmaps. If you uncomment it, clean it. --kkm */ |
686 int | 689 int |
687 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii, | 690 mswindows_resize_dibitmap_instance (Lisp_Image_Instance *ii, |
688 struct frame* f, | 691 struct frame *f, |
689 int newx, int newy) | 692 int newx, int newy) |
690 { | 693 { |
691 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); | 694 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); |
692 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); | 695 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); |
693 | 696 |
714 | 717 |
715 #ifdef HAVE_XPM | 718 #ifdef HAVE_XPM |
716 | 719 |
717 struct color_symbol | 720 struct color_symbol |
718 { | 721 { |
719 char* name; | 722 Intbyte * name; |
720 COLORREF color; | 723 COLORREF color; |
721 }; | 724 }; |
722 | 725 |
723 static struct color_symbol* | 726 static struct color_symbol * |
724 extract_xpm_color_names (Lisp_Object device, | 727 extract_xpm_color_names (Lisp_Object device, |
725 Lisp_Object domain, | 728 Lisp_Object domain, |
726 Lisp_Object color_symbol_alist, | 729 Lisp_Object color_symbol_alist, |
727 int* nsymbols) | 730 int *nsymbols) |
728 { | 731 { |
729 /* This function can GC */ | 732 /* This function can GC */ |
730 Lisp_Object rest; | 733 Lisp_Object rest; |
731 Lisp_Object results = Qnil; | 734 Lisp_Object results = Qnil; |
732 int i, j; | 735 int i, j; |
760 results = noseeum_cons (noseeum_cons (name, value), results); | 763 results = noseeum_cons (noseeum_cons (name, value), results); |
761 i++; | 764 i++; |
762 } | 765 } |
763 UNGCPRO; /* no more evaluation */ | 766 UNGCPRO; /* no more evaluation */ |
764 | 767 |
765 *nsymbols=i; | 768 *nsymbols = i; |
766 if (i == 0) return 0; | 769 if (i == 0) return 0; |
767 | 770 |
768 colortbl = xnew_array_and_zero (struct color_symbol, i); | 771 colortbl = xnew_array_and_zero (struct color_symbol, i); |
769 | 772 |
770 for (j=0; j<i; j++) | 773 for (j = 0; j < i; j++) |
771 { | 774 { |
772 Lisp_Object cons = XCAR (results); | 775 Lisp_Object cons = XCAR (results); |
773 colortbl[j].color = | 776 colortbl[j].color = |
774 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); | 777 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); |
775 | 778 |
776 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons), | 779 /* mustn't lose this when we return */ |
777 C_STRING_ALLOCA, colortbl[j].name, | 780 colortbl[j].name = qxestrdup (XSTRING_DATA (XCAR (cons))); |
778 Qnative); | |
779 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */ | |
780 free_cons (XCONS (cons)); | 781 free_cons (XCONS (cons)); |
781 cons = results; | 782 cons = results; |
782 results = XCDR (results); | 783 results = XCDR (results); |
783 free_cons (XCONS (cons)); | 784 free_cons (XCONS (cons)); |
784 } | 785 } |
785 return colortbl; | 786 return colortbl; |
786 } | 787 } |
787 | 788 |
788 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer, | 789 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer, |
789 UChar_Binary** data, | 790 UChar_Binary **data, |
790 int* width, int* height, | 791 int *width, int *height, |
791 int* x_hot, int* y_hot, | 792 int *x_hot, int *y_hot, |
792 int* transp, | 793 int *transp, |
793 struct color_symbol* color_symbols, | 794 struct color_symbol *color_symbols, |
794 int nsymbols) | 795 int nsymbols) |
795 { | 796 { |
796 XpmImage xpmimage; | 797 XpmImage xpmimage; |
797 XpmInfo xpminfo; | 798 XpmInfo xpminfo; |
798 int result, i, j, transp_idx, maskbpline; | 799 int result, i, j, transp_idx, maskbpline; |
799 UChar_Binary* dptr; | 800 UChar_Binary *dptr; |
800 unsigned int* sptr; | 801 unsigned int *sptr; |
801 COLORREF color; /* the american spelling virus hits again .. */ | 802 COLORREF color; /* the american spelling virus hits again .. */ |
802 COLORREF* colortbl; | 803 COLORREF *colortbl; |
803 | 804 |
804 xzero (xpmimage); | 805 xzero (xpmimage); |
805 xzero (xpminfo); | 806 xzero (xpminfo); |
806 xpminfo.valuemask=XpmHotspot; | 807 xpminfo.valuemask = XpmHotspot; |
807 *transp=FALSE; | 808 *transp = FALSE; |
808 | 809 |
809 result = XpmCreateXpmImageFromBuffer ((char*)buffer, | 810 result = XpmCreateXpmImageFromBuffer ((char *)buffer, |
810 &xpmimage, | 811 &xpmimage, |
811 &xpminfo); | 812 &xpminfo); |
812 switch (result) | 813 switch (result) |
813 { | 814 { |
814 case XpmSuccess: | 815 case XpmSuccess: |
851 XpmFreeXpmImage (&xpmimage); | 852 XpmFreeXpmImage (&xpmimage); |
852 XpmFreeXpmInfo (&xpminfo); | 853 XpmFreeXpmInfo (&xpminfo); |
853 return 0; | 854 return 0; |
854 } | 855 } |
855 | 856 |
856 for (i=0; i<(int)xpmimage.ncolors; i++) | 857 for (i = 0; i < (int) xpmimage.ncolors; i++) |
857 { | 858 { |
858 /* goto alert!!!! */ | 859 /* goto alert!!!! */ |
859 /* pick up symbolic colors in preference */ | 860 /* pick up symbolic colors in preference */ |
860 if (xpmimage.colorTable[i].symbolic) | 861 if (xpmimage.colorTable[i].symbolic) |
861 { | 862 { |
862 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor") | 863 if (!strcasecmp (xpmimage.colorTable[i].symbolic, "BgColor") |
863 || | 864 || |
864 !strcasecmp (xpmimage.colorTable[i].symbolic,"None")) | 865 !strcasecmp (xpmimage.colorTable[i].symbolic, "None")) |
865 { | 866 { |
866 *transp=TRUE; | 867 *transp = TRUE; |
867 colortbl[i]=transparent_color; | 868 colortbl[i] = transparent_color; |
868 transp_idx=i; | 869 transp_idx = i; |
869 goto label_found_color; | 870 goto label_found_color; |
870 } | 871 } |
871 else if (color_symbols) | 872 else if (color_symbols) |
872 { | 873 { |
873 for (j = 0; j<nsymbols; j++) | 874 for (j = 0; j < nsymbols; j++) |
874 { | 875 { |
875 if (!strcmp (xpmimage.colorTable[i].symbolic, | 876 if (!qxestrcmp_c (color_symbols[j].name, |
876 color_symbols[j].name )) | 877 xpmimage.colorTable[i].symbolic)) |
877 { | 878 { |
878 colortbl[i]=color_symbols[j].color; | 879 colortbl[i] = color_symbols[j].color; |
879 goto label_found_color; | 880 goto label_found_color; |
880 } | 881 } |
881 } | 882 } |
882 } | 883 } |
883 else if (xpmimage.colorTable[i].c_color == 0) | 884 else if (xpmimage.colorTable[i].c_color == 0) |
884 { | 885 { |
885 goto label_no_color; | 886 goto label_no_color; |
886 } | 887 } |
887 } | 888 } |
888 /* pick up transparencies */ | 889 /* pick up transparencies */ |
889 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None")) | 890 if (!strcasecmp (xpmimage.colorTable[i].c_color, "None")) |
890 { | 891 { |
891 *transp=TRUE; | 892 *transp = TRUE; |
892 colortbl[i]=transparent_color; | 893 colortbl[i] = transparent_color; |
893 transp_idx=i; | 894 transp_idx = i; |
894 goto label_found_color; | 895 goto label_found_color; |
895 } | 896 } |
896 /* finally pick up a normal color spec */ | 897 /* finally pick up a normal color spec */ |
897 if (xpmimage.colorTable[i].c_color) | 898 if (xpmimage.colorTable[i].c_color) |
898 { | 899 { |
899 colortbl[i]= | 900 colortbl[i]= |
900 mswindows_string_to_color (xpmimage.colorTable[i].c_color); | 901 mswindows_string_to_color ((Intbyte *) |
902 xpmimage.colorTable[i].c_color); | |
901 goto label_found_color; | 903 goto label_found_color; |
902 } | 904 } |
903 | 905 |
904 label_no_color: | 906 label_no_color: |
905 xfree (*data); | 907 xfree (*data); |
910 | 912 |
911 label_found_color:; | 913 label_found_color:; |
912 } | 914 } |
913 | 915 |
914 /* convert the image */ | 916 /* convert the image */ |
915 sptr=xpmimage.data; | 917 sptr = xpmimage.data; |
916 dptr=*data; | 918 dptr= *data; |
917 for (i = 0; i< *width * *height; i++) | 919 for (i = 0; i< *width * *height; i++) |
918 { | 920 { |
919 color = colortbl[*sptr++]; | 921 color = colortbl[*sptr++]; |
920 | 922 |
921 /* split out the 0x02bbggrr colorref into an rgb triple */ | 923 /* split out the 0x02bbggrr colorref into an rgb triple */ |
922 *dptr++=GetRValue (color); /* red */ | 924 *dptr++=GetRValue (color); /* red */ |
923 *dptr++=GetGValue (color); /* green */ | 925 *dptr++=GetGValue (color); /* green */ |
924 *dptr++=GetBValue (color); /* blue */ | 926 *dptr++=GetBValue (color); /* blue */ |
925 } | 927 } |
926 | 928 |
927 *x_hot=xpminfo.x_hotspot; | 929 *x_hot = xpminfo.x_hotspot; |
928 *y_hot=xpminfo.y_hotspot; | 930 *y_hot = xpminfo.y_hotspot; |
929 | 931 |
930 XpmFreeXpmImage (&xpmimage); | 932 XpmFreeXpmImage (&xpmimage); |
931 XpmFreeXpmInfo (&xpminfo); | 933 XpmFreeXpmInfo (&xpminfo); |
932 xfree (colortbl); | 934 xfree (colortbl); |
933 return TRUE; | 935 return TRUE; |
946 UChar_Binary *eimage; | 948 UChar_Binary *eimage; |
947 int width, height, x_hot, y_hot; | 949 int width, height, x_hot, y_hot; |
948 BITMAPINFO* bmp_info; | 950 BITMAPINFO* bmp_info; |
949 UChar_Binary* bmp_data; | 951 UChar_Binary* bmp_data; |
950 int bmp_bits; | 952 int bmp_bits; |
951 int nsymbols=0, transp; | 953 int nsymbols = 0, transp; |
952 struct color_symbol* color_symbols=NULL; | 954 struct color_symbol* color_symbols = NULL; |
953 | 955 |
954 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 956 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
955 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, | 957 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, |
956 Q_color_symbols); | 958 Q_color_symbols); |
957 | 959 |
983 } | 985 } |
984 xfree(color_symbols); | 986 xfree(color_symbols); |
985 } | 987 } |
986 | 988 |
987 /* build a bitmap from the eimage */ | 989 /* build a bitmap from the eimage */ |
988 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, | 990 if (!(bmp_info = convert_EImage_to_DIBitmap (device, width, height, eimage, |
989 &bmp_bits, &bmp_data))) | 991 &bmp_bits, &bmp_data))) |
990 { | 992 { |
991 signal_image_error ("XPM to EImage conversion failed", | 993 signal_image_error ("XPM to EImage conversion failed", |
992 image_instance); | 994 image_instance); |
993 } | 995 } |
1033 { | 1035 { |
1034 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1036 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1035 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1037 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1036 const Extbyte *bytes; | 1038 const Extbyte *bytes; |
1037 Bytecount len; | 1039 Bytecount len; |
1038 BITMAPFILEHEADER* bmp_file_header; | 1040 BITMAPFILEHEADER * bmp_file_header; |
1039 BITMAPINFO* bmp_info; | 1041 BITMAPINFO * bmp_info; |
1040 void* bmp_data; | 1042 void * bmp_data; |
1041 int bmp_bits; | 1043 int bmp_bits; |
1042 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1044 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1043 | 1045 |
1044 CHECK_MSGDI_DEVICE (device); | 1046 CHECK_MSGDI_DEVICE (device); |
1045 | 1047 |
1051 | 1053 |
1052 /* Then slurp the image into memory, decoding along the way. | 1054 /* Then slurp the image into memory, decoding along the way. |
1053 The result is the image in a simple one-byte-per-pixel | 1055 The result is the image in a simple one-byte-per-pixel |
1054 format. */ | 1056 format. */ |
1055 | 1057 |
1056 bmp_file_header=(BITMAPFILEHEADER*)bytes; | 1058 bmp_file_header = (BITMAPFILEHEADER *)bytes; |
1057 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER)); | 1059 bmp_info = (BITMAPINFO *)(bytes + sizeof(BITMAPFILEHEADER)); |
1058 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits; | 1060 bmp_data = (Extbyte *)bytes + bmp_file_header->bfOffBits; |
1059 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits; | 1061 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits; |
1060 | 1062 |
1061 /* Now create the pixmap and set up the image instance */ | 1063 /* Now create the pixmap and set up the image instance */ |
1062 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, | 1064 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, |
1063 bmp_data, bmp_bits, 1, instantiator, | 1065 bmp_data, bmp_bits, 1, instantiator, |
1089 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK; | 1091 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK; |
1090 } | 1092 } |
1091 | 1093 |
1092 typedef struct | 1094 typedef struct |
1093 { | 1095 { |
1094 char *name; | 1096 CIntbyte *name; |
1095 int resource_id; | 1097 int resource_id; |
1096 } resource_t; | 1098 } resource_t; |
1097 | |
1098 #ifndef OCR_ICOCUR | |
1099 #define OCR_ICOCUR 32647 | |
1100 #define OIC_SAMPLE 32512 | |
1101 #define OIC_HAND 32513 | |
1102 #define OIC_QUES 32514 | |
1103 #define OIC_BANG 32515 | |
1104 #define OIC_NOTE 32516 | |
1105 #define OIC_WINLOGO 32517 | |
1106 #if defined (CYGWIN) && CYGWIN_VERSION_DLL_MAJOR < 21 | |
1107 #define LR_SHARED 0x8000 | |
1108 #endif | |
1109 #endif | |
1110 | 1099 |
1111 static const resource_t bitmap_table[] = | 1100 static const resource_t bitmap_table[] = |
1112 { | 1101 { |
1113 /* bitmaps */ | 1102 /* bitmaps */ |
1114 { "close", OBM_CLOSE }, | 1103 { "close", OBM_CLOSE }, |
1169 { "note", OIC_NOTE }, | 1158 { "note", OIC_NOTE }, |
1170 { "winlogo", OIC_WINLOGO }, | 1159 { "winlogo", OIC_WINLOGO }, |
1171 {0} | 1160 {0} |
1172 }; | 1161 }; |
1173 | 1162 |
1174 static int resource_name_to_resource (Lisp_Object name, int type) | 1163 static int |
1175 { | 1164 resource_name_to_resource (Lisp_Object name, int type) |
1176 const resource_t* res = (type == IMAGE_CURSOR ? cursor_table | 1165 { |
1166 const resource_t *res = (type == IMAGE_CURSOR ? cursor_table | |
1177 : type == IMAGE_ICON ? icon_table | 1167 : type == IMAGE_ICON ? icon_table |
1178 : bitmap_table); | 1168 : bitmap_table); |
1179 | 1169 |
1180 if (INTP (name)) | 1170 if (INTP (name)) |
1181 { | 1171 return XINT (name); |
1182 return XINT (name); | |
1183 } | |
1184 else if (!STRINGP (name)) | 1172 else if (!STRINGP (name)) |
1185 { | 1173 invalid_argument ("invalid resource identifier", name); |
1186 invalid_argument ("invalid resource identifier", name); | 1174 |
1187 } | 1175 do |
1188 | 1176 { |
1189 do { | 1177 if (!qxestrcasecmp_i18n ((Intbyte *) res->name, XSTRING_DATA (name))) |
1190 Extbyte* nm=0; | 1178 return res->resource_id; |
1191 TO_EXTERNAL_FORMAT (LISP_STRING, name, | 1179 } |
1192 C_STRING_ALLOCA, nm, | 1180 while ((++res)->name); |
1193 Qnative); | |
1194 if (!strcasecmp ((char*)res->name, nm)) | |
1195 return res->resource_id; | |
1196 } while ((++res)->name); | |
1197 return 0; | 1181 return 0; |
1198 } | 1182 } |
1199 | 1183 |
1200 static int | 1184 static int |
1201 resource_symbol_to_type (Lisp_Object data) | 1185 resource_symbol_to_type (Lisp_Object data) |
1217 int dest_mask, Lisp_Object domain) | 1201 int dest_mask, Lisp_Object domain) |
1218 { | 1202 { |
1219 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1203 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1220 int type = 0; | 1204 int type = 0; |
1221 HANDLE himage = NULL; | 1205 HANDLE himage = NULL; |
1222 LPCTSTR resid=0; | 1206 Extbyte *resid = 0; |
1223 HINSTANCE hinst = NULL; | 1207 HINSTANCE hinst = NULL; |
1224 ICONINFO iconinfo; | 1208 ICONINFO iconinfo; |
1225 enum image_instance_type iitype; | 1209 enum image_instance_type iitype; |
1226 char* fname=0; | |
1227 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1210 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1228 | 1211 |
1229 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); | 1212 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); |
1230 Lisp_Object resource_type = find_keyword_in_vector (instantiator, | 1213 Lisp_Object resource_type = find_keyword_in_vector (instantiator, |
1231 Q_resource_type); | 1214 Q_resource_type); |
1247 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); | 1230 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); |
1248 | 1231 |
1249 /* mess with the keyword info we were provided with */ | 1232 /* mess with the keyword info we were provided with */ |
1250 if (!NILP (file)) | 1233 if (!NILP (file)) |
1251 { | 1234 { |
1252 Extbyte* f=0; | 1235 Extbyte *fname; |
1253 TO_EXTERNAL_FORMAT (LISP_STRING, file, | 1236 |
1254 C_STRING_ALLOCA, f, | 1237 LOCAL_FILE_FORMAT_TO_TSTR (file, fname); |
1255 Qfile_name); | |
1256 #ifdef CYGWIN | |
1257 CYGWIN_WIN32_PATH (f, fname); | |
1258 #else | |
1259 fname = f; | |
1260 #endif | |
1261 | 1238 |
1262 if (NILP (resource_id)) | 1239 if (NILP (resource_id)) |
1263 resid = (LPCTSTR)fname; | 1240 resid = fname; |
1264 else | 1241 else |
1265 { | 1242 { |
1266 hinst = LoadLibraryEx (fname, NULL, | 1243 hinst = qxeLoadLibraryEx (fname, NULL, LOAD_LIBRARY_AS_DATAFILE); |
1267 LOAD_LIBRARY_AS_DATAFILE); | |
1268 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | 1244 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
1269 type)); | 1245 type)); |
1270 | 1246 |
1271 if (!resid) | 1247 if (!resid) |
1272 TO_EXTERNAL_FORMAT (LISP_STRING, resource_id, | 1248 LISP_STRING_TO_TSTR (resource_id, resid); |
1273 C_STRING_ALLOCA, resid, | |
1274 Qnative); | |
1275 } | 1249 } |
1276 } | 1250 } |
1277 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | 1251 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
1278 type)))) | 1252 type)))) |
1279 invalid_argument ("Invalid resource identifier", resource_id); | 1253 invalid_argument ("Invalid resource identifier", resource_id); |
1280 | 1254 |
1281 /* load the image */ | 1255 /* load the image */ |
1282 if (xLoadImageA) /* not in NT 3.5 */ | 1256 if (!(himage = qxeLoadImage (hinst, resid, type, 0, 0, |
1283 { | 1257 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | |
1284 if (!(himage = xLoadImageA (hinst, resid, type, 0, 0, | 1258 LR_SHARED | |
1285 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | | 1259 (!NILP (file) ? LR_LOADFROMFILE : 0)))) |
1286 LR_SHARED | | 1260 signal_image_error ("Cannot load image", instantiator); |
1287 (!NILP (file) ? LR_LOADFROMFILE : 0)))) | |
1288 signal_image_error ("Cannot load image", instantiator); | |
1289 } | |
1290 else | |
1291 { | |
1292 /* Is this correct? I don't really care. */ | |
1293 switch (type) | |
1294 { | |
1295 case IMAGE_BITMAP: | |
1296 himage = LoadBitmap (hinst, resid); | |
1297 break; | |
1298 case IMAGE_CURSOR: | |
1299 himage = LoadCursor (hinst, resid); | |
1300 break; | |
1301 case IMAGE_ICON: | |
1302 himage = LoadIcon (hinst, resid); | |
1303 break; | |
1304 } | |
1305 | |
1306 if (!himage) | |
1307 signal_image_error ("Cannot load image", instantiator); | |
1308 } | |
1309 | 1261 |
1310 if (hinst) | 1262 if (hinst) |
1311 FreeLibrary (hinst); | 1263 FreeLibrary (hinst); |
1312 | 1264 |
1313 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype); | 1265 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype); |
1358 && | 1310 && |
1359 !resource_name_to_resource (data, IMAGE_BITMAP)) | 1311 !resource_name_to_resource (data, IMAGE_BITMAP)) |
1360 invalid_constant ("invalid resource identifier", data); | 1312 invalid_constant ("invalid resource identifier", data); |
1361 } | 1313 } |
1362 | 1314 |
1315 | |
1363 /********************************************************************** | 1316 /********************************************************************** |
1364 * XBM * | 1317 * XBM * |
1365 **********************************************************************/ | 1318 **********************************************************************/ |
1319 | |
1366 /* this table flips four bits around. */ | 1320 /* this table flips four bits around. */ |
1367 static int flip_table[] = | 1321 static int flip_table[] = |
1368 { | 1322 { |
1369 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 | 1323 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 |
1370 }; | 1324 }; |
1380 xbm_create_bitmap_from_data (HDC hdc, const UChar_Binary *data, | 1334 xbm_create_bitmap_from_data (HDC hdc, const UChar_Binary *data, |
1381 int width, int height, | 1335 int width, int height, |
1382 int mask, COLORREF fg, COLORREF bg) | 1336 int mask, COLORREF fg, COLORREF bg) |
1383 { | 1337 { |
1384 int old_width = (width + 7)/8; | 1338 int old_width = (width + 7)/8; |
1385 int new_width = BPLINE (2*((width + 15)/16)); | 1339 int new_width = BPLINE (2 * ((width + 15)/16)); |
1386 const UChar_Binary *offset; | 1340 const UChar_Binary *offset; |
1387 void *bmp_buf = 0; | 1341 void *bmp_buf = 0; |
1388 UChar_Binary *new_data, *new_offset; | 1342 UChar_Binary *new_data, *new_offset; |
1389 int i, j; | 1343 int i, j; |
1390 BITMAPINFO *bmp_info = | 1344 BITMAPINFO *bmp_info = |
1391 (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); | 1345 (BITMAPINFO *) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); |
1392 HBITMAP bitmap; | 1346 HBITMAP bitmap; |
1393 | 1347 |
1394 if (!bmp_info) | 1348 if (!bmp_info) |
1395 return NULL; | 1349 return NULL; |
1396 | 1350 |
1400 { | 1354 { |
1401 xfree (bmp_info); | 1355 xfree (bmp_info); |
1402 return NULL; | 1356 return NULL; |
1403 } | 1357 } |
1404 | 1358 |
1405 for (i=0; i<height; i++) | 1359 for (i = 0; i < height; i++) |
1406 { | 1360 { |
1407 offset = data + i*old_width; | 1361 offset = data + i * old_width; |
1408 new_offset = new_data + i*new_width; | 1362 new_offset = new_data + i * new_width; |
1409 | 1363 |
1410 for (j=0; j<old_width; j++) | 1364 for (j = 0; j < old_width; j++) |
1411 { | 1365 { |
1412 int byte = offset[j]; | 1366 int bite = offset[j]; |
1413 new_offset[j] = ~ (UChar_Binary) | 1367 new_offset[j] = ~ (UChar_Binary) |
1414 ((flip_table[byte & 0xf] << 4) + flip_table[byte >> 4]); | 1368 ((flip_table[bite & 0xf] << 4) + flip_table[bite >> 4]); |
1415 } | 1369 } |
1416 } | 1370 } |
1417 | 1371 |
1418 /* if we want a mask invert the bits */ | 1372 /* if we want a mask invert the bits */ |
1419 if (!mask) | 1373 if (!mask) |
1423 { | 1377 { |
1424 *new_offset ^= 0xff; | 1378 *new_offset ^= 0xff; |
1425 } | 1379 } |
1426 } | 1380 } |
1427 | 1381 |
1428 bmp_info->bmiHeader.biWidth=width; | 1382 bmp_info->bmiHeader.biWidth = width; |
1429 bmp_info->bmiHeader.biHeight=-(LONG)height; | 1383 bmp_info->bmiHeader.biHeight=-(LONG)height; |
1430 bmp_info->bmiHeader.biPlanes=1; | 1384 bmp_info->bmiHeader.biPlanes = 1; |
1431 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 1385 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
1432 bmp_info->bmiHeader.biBitCount=1; | 1386 bmp_info->bmiHeader.biBitCount = 1; |
1433 bmp_info->bmiHeader.biCompression=BI_RGB; | 1387 bmp_info->bmiHeader.biCompression = BI_RGB; |
1434 bmp_info->bmiHeader.biClrUsed = 2; | 1388 bmp_info->bmiHeader.biClrUsed = 2; |
1435 bmp_info->bmiHeader.biClrImportant = 2; | 1389 bmp_info->bmiHeader.biClrImportant = 2; |
1436 bmp_info->bmiHeader.biSizeImage = height * new_width; | 1390 bmp_info->bmiHeader.biSizeImage = height * new_width; |
1437 bmp_info->bmiColors[0].rgbRed = GetRValue (fg); | 1391 bmp_info->bmiColors[0].rgbRed = GetRValue (fg); |
1438 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg); | 1392 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg); |
1843 p->data = 0; | 1797 p->data = 0; |
1844 } | 1798 } |
1845 } | 1799 } |
1846 | 1800 |
1847 /************************************************************************/ | 1801 /************************************************************************/ |
1848 /* subwindow and widget support */ | 1802 /* subwindow and widget support */ |
1849 /************************************************************************/ | 1803 /************************************************************************/ |
1850 | 1804 |
1805 static Lisp_Object | |
1806 charset_of_text (Lisp_Object text) | |
1807 { | |
1808 #ifdef MULE | |
1809 Intbyte *p; | |
1810 | |
1811 if (NILP (text)) | |
1812 return Vcharset_ascii; | |
1813 for (p = XSTRING_DATA (text); *p;) | |
1814 { | |
1815 Emchar c = charptr_emchar (p); | |
1816 if (!EQ (CHAR_CHARSET (c), Vcharset_ascii)) | |
1817 return CHAR_CHARSET (c); | |
1818 INC_CHARPTR (p); | |
1819 } | |
1820 #endif /* MULE */ | |
1821 | |
1822 return Vcharset_ascii; | |
1823 } | |
1824 | |
1825 | |
1851 static HFONT | 1826 static HFONT |
1852 mswindows_widget_hfont (Lisp_Image_Instance *p, | 1827 mswindows_widget_hfont (Lisp_Object face, |
1853 Lisp_Object domain) | 1828 Lisp_Object domain, |
1854 { | 1829 Lisp_Object text) |
1855 Lisp_Object face = IMAGE_INSTANCE_WIDGET_FACE (p); | 1830 { |
1856 int under = FACE_UNDERLINE_P (face, domain); | 1831 int under = FACE_UNDERLINE_P (face, domain); |
1857 int strike = FACE_STRIKETHRU_P (face, domain); | 1832 int strike = FACE_STRIKETHRU_P (face, domain); |
1858 Lisp_Object font = query_string_font (IMAGE_INSTANCE_WIDGET_TEXT (p), | 1833 Lisp_Object font; |
1859 face, domain); | 1834 struct face_cachel frame_cachel; |
1835 struct face_cachel *cachel; | |
1836 Lisp_Object charset; | |
1837 | |
1838 reset_face_cachel (&frame_cachel); | |
1839 update_face_cachel_data (&frame_cachel, domain, face); | |
1840 cachel = &frame_cachel; | |
1841 /* !!#### This is a big hack. We return the first non-ASCII charset in | |
1842 the string, on the assumption that we can display ASCII characters in | |
1843 all fonts. We really need to draw the text of the widget ourselves; | |
1844 or perhaps there are fonts supporting lots of character sets? */ | |
1845 charset = charset_of_text (text); | |
1846 | |
1847 font = FACE_CACHEL_FONT (cachel, charset); | |
1848 | |
1849 if (!FONT_INSTANCEP (font)) | |
1850 font = ensure_face_cachel_contains_charset (cachel, domain, charset); | |
1851 | |
1852 if (EQ (font, Vthe_null_font_instance)) | |
1853 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii); | |
1860 | 1854 |
1861 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); | 1855 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); |
1862 } | 1856 } |
1863 | 1857 |
1864 static HDWP | 1858 static HDWP |
1913 | 1907 |
1914 /* map the subwindow. This is used by redisplay via | 1908 /* map the subwindow. This is used by redisplay via |
1915 redisplay_output_subwindow */ | 1909 redisplay_output_subwindow */ |
1916 static void | 1910 static void |
1917 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y, | 1911 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y, |
1918 struct display_glyph_area* dga) | 1912 struct display_glyph_area *dga) |
1919 { | 1913 { |
1920 #ifdef DEFER_WINDOW_POS | 1914 #ifdef DEFER_WINDOW_POS |
1921 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); | 1915 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); |
1922 HDWP hdwp = begin_defer_window_pos (f); | 1916 HDWP hdwp = begin_defer_window_pos (f); |
1923 HDWP new_hdwp; | 1917 HDWP new_hdwp; |
1967 } | 1961 } |
1968 } | 1962 } |
1969 | 1963 |
1970 /* resize the subwindow instance */ | 1964 /* resize the subwindow instance */ |
1971 static void | 1965 static void |
1972 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h) | 1966 mswindows_resize_subwindow (Lisp_Image_Instance *ii, int w, int h) |
1973 { | 1967 { |
1974 /* Set the size of the control .... */ | 1968 /* Set the size of the control .... */ |
1975 if (!SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 1969 if (!SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
1976 NULL, | 1970 NULL, |
1977 0, 0, w, h, | 1971 0, 0, w, h, |
1999 && (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p) | 1993 && (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p) |
2000 || XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed | 1994 || XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed |
2001 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))) | 1995 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))) |
2002 { | 1996 { |
2003 /* set the widget font from the widget face */ | 1997 /* set the widget font from the widget face */ |
2004 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | 1998 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2005 WM_SETFONT, | 1999 WM_SETFONT, |
2006 (WPARAM) mswindows_widget_hfont | 2000 (WPARAM) mswindows_widget_hfont |
2007 (p, IMAGE_INSTANCE_FRAME (p)), | 2001 (IMAGE_INSTANCE_WIDGET_FACE (p), |
2008 MAKELPARAM (TRUE, 0)); | 2002 IMAGE_INSTANCE_FRAME (p), |
2003 IMAGE_INSTANCE_WIDGET_TEXT (p)), | |
2004 MAKELPARAM (TRUE, 0)); | |
2009 } | 2005 } |
2010 /* Possibly update the dimensions. */ | 2006 /* Possibly update the dimensions. */ |
2011 if (IMAGE_INSTANCE_SIZE_CHANGED (p)) | 2007 if (IMAGE_INSTANCE_SIZE_CHANGED (p)) |
2012 { | 2008 { |
2013 mswindows_resize_subwindow (p, | 2009 mswindows_resize_subwindow (p, |
2016 } | 2012 } |
2017 /* Possibly update the text in the widget. */ | 2013 /* Possibly update the text in the widget. */ |
2018 if (IMAGE_INSTANCE_TEXT_CHANGED (p) | 2014 if (IMAGE_INSTANCE_TEXT_CHANGED (p) |
2019 && !NILP (IMAGE_INSTANCE_WIDGET_TEXT (p))) | 2015 && !NILP (IMAGE_INSTANCE_WIDGET_TEXT (p))) |
2020 { | 2016 { |
2021 Extbyte* lparam=0; | 2017 Extbyte *lparam = 0; |
2022 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (p), | 2018 LISP_STRING_TO_TSTR (IMAGE_INSTANCE_WIDGET_TEXT (p), lparam); |
2023 C_STRING_ALLOCA, lparam, | 2019 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2024 Qnative); | 2020 WM_SETTEXT, 0, (LPARAM) lparam); |
2025 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | |
2026 WM_SETTEXT, 0, (LPARAM)lparam); | |
2027 } | 2021 } |
2028 /* Set active state. */ | 2022 /* Set active state. */ |
2029 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) | 2023 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) |
2030 { | 2024 { |
2031 Lisp_Object item = IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p); | 2025 Lisp_Object item = IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p); |
2032 LONG style = GetWindowLong | 2026 LONG style = qxeGetWindowLong |
2033 (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | 2027 (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2034 GWL_STYLE); | 2028 GWL_STYLE); |
2035 | 2029 |
2036 if (CONSP (item)) | 2030 if (CONSP (item)) |
2037 item = XCAR (item); | 2031 item = XCAR (item); |
2038 | 2032 |
2039 if (gui_item_active_p (item)) | 2033 if (gui_item_active_p (item)) |
2040 SetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | 2034 qxeSetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2041 GWL_STYLE, style & ~WS_DISABLED); | 2035 GWL_STYLE, style & ~WS_DISABLED); |
2042 else | 2036 else |
2043 SetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | 2037 qxeSetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2044 GWL_STYLE, style | WS_DISABLED); | 2038 GWL_STYLE, style | WS_DISABLED); |
2045 } | 2039 } |
2046 } | 2040 } |
2041 | |
2042 #ifdef HAVE_WIDGETS | |
2047 | 2043 |
2048 /* register widgets into our hashtable so that we can cope with the | 2044 /* register widgets into our hashtable so that we can cope with the |
2049 callbacks. The hashtable is weak so deregistration is handled | 2045 callbacks. The hashtable is weak so deregistration is handled |
2050 automatically */ | 2046 automatically */ |
2051 static int | 2047 static int |
2052 mswindows_register_gui_item (Lisp_Object image_instance, | 2048 mswindows_register_gui_item (Lisp_Object image_instance, |
2053 Lisp_Object gui, Lisp_Object domain) | 2049 Lisp_Object gui, Lisp_Object domain) |
2054 { | 2050 { |
2055 Lisp_Object frame = DOMAIN_FRAME (domain); | 2051 Lisp_Object frame = DOMAIN_FRAME (domain); |
2056 struct frame* f = XFRAME (frame); | 2052 struct frame *f = XFRAME (frame); |
2057 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), | 2053 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), |
2058 gui, | 2054 gui, |
2059 WIDGET_GLYPH_SLOT); | 2055 WIDGET_GLYPH_SLOT); |
2060 Fputhash (make_int (id), image_instance, | 2056 Fputhash (make_int (id), image_instance, |
2061 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f)); | 2057 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f)); |
2093 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; | 2089 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; |
2094 /* Allocate space for the clip window */ | 2090 /* Allocate space for the clip window */ |
2095 ii->data = xnew_and_zero (struct mswindows_subwindow_data); | 2091 ii->data = xnew_and_zero (struct mswindows_subwindow_data); |
2096 | 2092 |
2097 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) | 2093 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) |
2098 = CreateWindowEx( | 2094 = qxeCreateWindowEx ( |
2099 0, /* EX flags */ | 2095 0, /* EX flags */ |
2100 XEMACS_CONTROL_CLASS, | 2096 XETEXT (XEMACS_CONTROL_CLASS), |
2101 0, /* text */ | 2097 0, /* text */ |
2102 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, | 2098 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, |
2103 0, /* starting x position */ | 2099 0, /* starting x position */ |
2104 0, /* starting y position */ | 2100 0, /* starting y position */ |
2105 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | 2101 IMAGE_INSTANCE_WIDGET_WIDTH (ii), |
2106 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | 2102 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), |
2107 /* parent window */ | 2103 /* parent window */ |
2108 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | 2104 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), |
2109 NULL, /* No menu */ | 2105 NULL, /* No menu */ |
2110 NULL, /* must be null for this class */ | 2106 NULL, /* must be null for this class */ |
2111 NULL)) == NULL) | 2107 NULL)) == NULL) |
2112 gui_error ("window creation failed with code", | 2108 gui_error ("window creation failed with code", |
2113 make_int (GetLastError())); | 2109 make_int (GetLastError())); |
2114 | 2110 |
2115 wnd = CreateWindow( "STATIC", | 2111 wnd = qxeCreateWindow (XETEXT ("STATIC"), XETEXT (""), |
2116 "", | 2112 WS_CHILD, |
2117 WS_CHILD, | 2113 0, /* starting x position */ |
2118 0, /* starting x position */ | 2114 0, /* starting y position */ |
2119 0, /* starting y position */ | 2115 IMAGE_INSTANCE_WIDGET_WIDTH (ii), |
2120 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | 2116 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), |
2121 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | 2117 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), |
2122 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), | 2118 0, |
2123 0, | 2119 (HINSTANCE) |
2124 (HINSTANCE) | 2120 qxeGetWindowLong |
2125 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | 2121 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), |
2126 GWL_HINSTANCE), | 2122 GWL_HINSTANCE), |
2127 NULL); | 2123 NULL); |
2128 | 2124 |
2129 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | 2125 qxeSetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
2130 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; | 2126 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2131 } | 2127 } |
2128 | |
2129 #endif /* HAVE_WIDGETS */ | |
2132 | 2130 |
2133 static int | 2131 static int |
2134 mswindows_image_instance_equal (Lisp_Image_Instance *p1, | 2132 mswindows_image_instance_equal (Lisp_Image_Instance *p1, |
2135 Lisp_Image_Instance *p2, int depth) | 2133 Lisp_Image_Instance *p2, int depth) |
2136 { | 2134 { |
2192 | 2190 |
2193 | 2191 |
2194 #ifdef HAVE_WIDGETS | 2192 #ifdef HAVE_WIDGETS |
2195 | 2193 |
2196 /************************************************************************/ | 2194 /************************************************************************/ |
2197 /* widgets */ | 2195 /* widgets */ |
2198 /************************************************************************/ | 2196 /************************************************************************/ |
2199 static void | 2197 static void |
2200 mswindows_widget_instantiate (Lisp_Object image_instance, | 2198 mswindows_widget_instantiate (Lisp_Object image_instance, |
2201 Lisp_Object instantiator, | 2199 Lisp_Object instantiator, |
2202 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2200 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2203 int dest_mask, Lisp_Object domain, | 2201 int dest_mask, Lisp_Object domain, |
2204 const char* class, int flags, int exflags) | 2202 const CIntbyte *class, int flags, int exflags) |
2205 { | 2203 { |
2206 /* this function can call lisp */ | 2204 /* this function can call lisp */ |
2207 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2205 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2208 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; | 2206 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; |
2209 Lisp_Object frame = DOMAIN_FRAME (domain); | 2207 Lisp_Object frame = DOMAIN_FRAME (domain); |
2210 Extbyte* nm=0; | 2208 Extbyte *nm = 0; |
2209 Extbyte *classext; | |
2211 HWND wnd; | 2210 HWND wnd; |
2212 int id = 0xffff; | 2211 int id = 0xffff; |
2213 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2212 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2214 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); | 2213 Lisp_Gui_Item *pgui = XGUI_ITEM (gui); |
2215 | 2214 |
2216 CHECK_MSWINDOWS_DEVICE (device); | 2215 CHECK_MSWINDOWS_DEVICE (device); |
2217 | 2216 |
2218 if (!gui_item_active_p (gui)) | 2217 if (!gui_item_active_p (gui)) |
2219 flags |= WS_DISABLED; | 2218 flags |= WS_DISABLED; |
2224 { | 2223 { |
2225 id = mswindows_register_widget_instance (image_instance, domain); | 2224 id = mswindows_register_widget_instance (image_instance, domain); |
2226 } | 2225 } |
2227 | 2226 |
2228 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) | 2227 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
2229 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii), | 2228 LISP_STRING_TO_TSTR (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm); |
2230 C_STRING_ALLOCA, nm, | |
2231 Qnative); | |
2232 | 2229 |
2233 /* allocate space for the clip window and then allocate the clip window */ | 2230 /* allocate space for the clip window and then allocate the clip window */ |
2234 ii->data = xnew_and_zero (struct mswindows_subwindow_data); | 2231 ii->data = xnew_and_zero (struct mswindows_subwindow_data); |
2235 | 2232 |
2236 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) | 2233 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) |
2237 = CreateWindowEx( | 2234 = qxeCreateWindowEx (WS_EX_CONTROLPARENT, /* EX flags */ |
2238 WS_EX_CONTROLPARENT, /* EX flags */ | 2235 XETEXT (XEMACS_CONTROL_CLASS), |
2239 XEMACS_CONTROL_CLASS, | 2236 0, /* text */ |
2240 0, /* text */ | 2237 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, |
2241 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, | |
2242 0, /* starting x position */ | |
2243 0, /* starting y position */ | |
2244 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2245 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2246 /* parent window */ | |
2247 DOMAIN_MSWINDOWS_HANDLE (domain), | |
2248 (HMENU)id, /* No menu */ | |
2249 NULL, /* must be null for this class */ | |
2250 NULL)) == NULL) | |
2251 gui_error ("window creation failed with code", | |
2252 make_int (GetLastError())); | |
2253 | |
2254 if ((wnd = CreateWindowEx( | |
2255 exflags /* | WS_EX_NOPARENTNOTIFY*/, | |
2256 class, | |
2257 nm, | |
2258 flags | WS_CHILD | WS_VISIBLE, | |
2259 0, /* starting x position */ | 2238 0, /* starting x position */ |
2260 0, /* starting y position */ | 2239 0, /* starting y position */ |
2261 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | 2240 IMAGE_INSTANCE_WIDGET_WIDTH (ii), |
2262 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | 2241 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), |
2263 /* parent window */ | 2242 /* parent window */ |
2264 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), | 2243 DOMAIN_MSWINDOWS_HANDLE (domain), |
2265 (HMENU)id, /* No menu */ | 2244 (HMENU)id, /* No menu */ |
2266 (HINSTANCE) | 2245 NULL, /* must be null for this class */ |
2267 GetWindowLong | |
2268 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
2269 GWL_HINSTANCE), | |
2270 NULL)) == NULL) | 2246 NULL)) == NULL) |
2271 gui_error ("window creation failed with code", | 2247 gui_error ("window creation failed with code", |
2272 make_int (GetLastError())); | 2248 make_int (GetLastError())); |
2273 | 2249 |
2250 C_STRING_TO_TSTR (class, classext); | |
2251 | |
2252 if ((wnd = qxeCreateWindowEx (exflags /* | WS_EX_NOPARENTNOTIFY*/, | |
2253 classext, | |
2254 nm, | |
2255 flags | WS_CHILD | WS_VISIBLE, | |
2256 0, /* starting x position */ | |
2257 0, /* starting y position */ | |
2258 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2259 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2260 /* parent window */ | |
2261 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), | |
2262 (HMENU)id, /* No menu */ | |
2263 (HINSTANCE) | |
2264 qxeGetWindowLong | |
2265 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
2266 GWL_HINSTANCE), | |
2267 NULL)) == NULL) | |
2268 gui_error ("window creation failed with code", | |
2269 make_int (GetLastError())); | |
2270 | |
2274 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; | 2271 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2275 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | 2272 qxeSetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
2276 /* set the widget font from the widget face */ | 2273 /* set the widget font from the widget face */ |
2277 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) | 2274 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
2278 SendMessage (wnd, WM_SETFONT, | 2275 qxeSendMessage (wnd, WM_SETFONT, |
2279 (WPARAM) mswindows_widget_hfont (ii, domain), | 2276 (WPARAM) mswindows_widget_hfont |
2280 MAKELPARAM (TRUE, 0)); | 2277 (IMAGE_INSTANCE_WIDGET_FACE (ii), domain, |
2278 IMAGE_INSTANCE_WIDGET_TEXT (ii)), | |
2279 MAKELPARAM (TRUE, 0)); | |
2281 #if 0 | 2280 #if 0 |
2282 /* #### doesn't work. need to investigate more closely. */ | 2281 /* #### doesn't work. need to investigate more closely. */ |
2283 if (IMAGE_INSTANCE_WANTS_INITIAL_FOCUS (ii)) | 2282 if (IMAGE_INSTANCE_WANTS_INITIAL_FOCUS (ii)) |
2284 SetFocus (wnd); | 2283 SetFocus (wnd); |
2285 #endif | 2284 #endif |
2327 /* BS_NOTIFY #### is needed to get exotic feedback only. Since we | 2326 /* BS_NOTIFY #### is needed to get exotic feedback only. Since we |
2328 seem to want nothing beyond BN_CLICK, the style is perhaps not | 2327 seem to want nothing beyond BN_CLICK, the style is perhaps not |
2329 necessary -- kkm */ | 2328 necessary -- kkm */ |
2330 Lisp_Object style; | 2329 Lisp_Object style; |
2331 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2330 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2332 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); | 2331 Lisp_Gui_Item *pgui = XGUI_ITEM (gui); |
2333 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); | 2332 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); |
2334 | 2333 |
2335 if (!NILP (glyph)) | 2334 if (!NILP (glyph)) |
2336 { | 2335 { |
2337 if (!IMAGE_INSTANCEP (glyph)) | 2336 if (!IMAGE_INSTANCEP (glyph)) |
2358 { | 2357 { |
2359 flags |= BS_DEFPUSHBUTTON; | 2358 flags |= BS_DEFPUSHBUTTON; |
2360 } | 2359 } |
2361 | 2360 |
2362 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2361 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2363 pointer_bg, dest_mask, domain, "BUTTON", | 2362 pointer_bg, dest_mask, domain, |
2364 flags, 0); | 2363 "BUTTON", flags, 0); |
2365 | 2364 |
2366 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2365 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2367 /* set the checked state */ | 2366 /* set the checked state */ |
2368 if (gui_item_selected_p (gui)) | 2367 if (gui_item_selected_p (gui)) |
2369 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | 2368 qxeSendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); |
2370 else | 2369 else |
2371 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | 2370 qxeSendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); |
2372 /* add the image if one was given */ | 2371 /* add the image if one was given */ |
2373 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph) | 2372 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph) |
2374 && | 2373 && |
2375 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph))) | 2374 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph))) |
2376 { | 2375 { |
2377 SendMessage (wnd, BM_SETIMAGE, | 2376 qxeSendMessage (wnd, BM_SETIMAGE, |
2378 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | 2377 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
2379 IMAGE_BITMAP : IMAGE_ICON), | 2378 IMAGE_BITMAP : IMAGE_ICON), |
2380 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | 2379 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
2381 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : | 2380 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : |
2382 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); | 2381 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); |
2383 } | 2382 } |
2384 } | 2383 } |
2385 | 2384 |
2386 /* Update the state of a button. */ | 2385 /* Update the state of a button. */ |
2387 static void | 2386 static void |
2390 /* This function can GC if IN_REDISPLAY is false. */ | 2389 /* This function can GC if IN_REDISPLAY is false. */ |
2391 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2390 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2392 | 2391 |
2393 /* buttons checked or otherwise */ | 2392 /* buttons checked or otherwise */ |
2394 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii))) | 2393 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii))) |
2395 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2394 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2396 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | 2395 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); |
2397 else | 2396 else |
2398 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2397 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2399 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | 2398 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); |
2400 } | 2399 } |
2401 | 2400 |
2402 /* instantiate an edit control */ | 2401 /* instantiate an edit control */ |
2403 static void | 2402 static void |
2404 mswindows_edit_field_instantiate (Lisp_Object image_instance, | 2403 mswindows_edit_field_instantiate (Lisp_Object image_instance, |
2428 pointer_bg, dest_mask, domain, PROGRESS_CLASS, | 2427 pointer_bg, dest_mask, domain, PROGRESS_CLASS, |
2429 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); | 2428 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); |
2430 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2429 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2431 /* set the colors */ | 2430 /* set the colors */ |
2432 #if 0 /* #### fix this */ | 2431 #if 0 /* #### fix this */ |
2433 SendMessage (wnd, PBM_SETBKCOLOR, 0, | 2432 qxeSendMessage (wnd, PBM_SETBKCOLOR, 0, |
2434 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | 2433 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR |
2435 (XCOLOR_INSTANCE | 2434 (XCOLOR_INSTANCE |
2436 (FACE_BACKGROUND | 2435 (FACE_BACKGROUND |
2437 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | 2436 (XIMAGE_INSTANCE_WIDGET_FACE (ii), |
2438 XIMAGE_INSTANCE_FRAME (ii)))))); | 2437 XIMAGE_INSTANCE_FRAME (ii)))))); |
2439 SendMessage (wnd, PBM_SETBARCOLOR, 0, | 2438 qxeSendMessage (wnd, PBM_SETBARCOLOR, 0, |
2440 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | 2439 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR |
2441 (XCOLOR_INSTANCE | 2440 (XCOLOR_INSTANCE |
2442 (FACE_FOREGROUND | 2441 (FACE_FOREGROUND |
2443 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | 2442 (XIMAGE_INSTANCE_WIDGET_FACE (ii), |
2444 XIMAGE_INSTANCE_FRAME (ii)))))); | 2443 XIMAGE_INSTANCE_FRAME (ii)))))); |
2445 #endif | 2444 #endif |
2446 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEMS (ii))->value; | 2445 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEMS (ii))->value; |
2447 CHECK_INT (val); | 2446 CHECK_INT (val); |
2448 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2447 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2449 PBM_SETPOS, (WPARAM)XINT (val), 0); | 2448 PBM_SETPOS, (WPARAM)XINT (val), 0); |
2450 } | 2449 } |
2451 | 2450 |
2452 /* instantiate a tree view widget */ | 2451 /* instantiate a tree view widget */ |
2453 static HTREEITEM add_tree_item (Lisp_Object image_instance, | 2452 static HTREEITEM add_tree_item (Lisp_Object image_instance, |
2454 HWND wnd, HTREEITEM parent, Lisp_Object item, | 2453 HWND wnd, HTREEITEM parent, Lisp_Object item, |
2455 int children, Lisp_Object domain) | 2454 int children, Lisp_Object domain) |
2456 { | 2455 { |
2457 TV_INSERTSTRUCT tvitem; | |
2458 HTREEITEM ret; | 2456 HTREEITEM ret; |
2457 TV_INSERTSTRUCTW tvitem; | |
2459 | 2458 |
2460 tvitem.hParent = parent; | 2459 tvitem.hParent = parent; |
2461 tvitem.hInsertAfter = TVI_LAST; | 2460 tvitem.hInsertAfter = TVI_LAST; |
2462 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN; | 2461 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN; |
2463 tvitem.item.cChildren = children; | 2462 tvitem.item.cChildren = children; |
2464 | 2463 |
2465 if (GUI_ITEMP (item)) | 2464 if (GUI_ITEMP (item)) |
2466 { | 2465 { |
2467 tvitem.item.lParam = mswindows_register_gui_item (image_instance, | 2466 tvitem.item.lParam = |
2468 item, domain); | 2467 mswindows_register_gui_item (image_instance, item, domain); |
2469 tvitem.item.mask |= TVIF_PARAM; | 2468 tvitem.item.mask |= TVIF_PARAM; |
2470 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, | 2469 LISP_STRING_TO_TSTR (XGUI_ITEM (item)->name, tvitem.item.pszText); |
2471 C_STRING_ALLOCA, tvitem.item.pszText, | |
2472 Qnative); | |
2473 } | 2470 } |
2474 else | 2471 else |
2475 TO_EXTERNAL_FORMAT (LISP_STRING, item, | 2472 LISP_STRING_TO_TSTR (item, tvitem.item.pszText); |
2476 C_STRING_ALLOCA, tvitem.item.pszText, | 2473 |
2477 Qnative); | 2474 tvitem.item.cchTextMax = xetcslen ((Extbyte *) tvitem.item.pszText); |
2478 | 2475 |
2479 tvitem.item.cchTextMax = strlen (tvitem.item.pszText); | 2476 if ((ret = (HTREEITEM) qxeSendMessage (wnd, TVM_INSERTITEM, |
2480 | 2477 0, (LPARAM) &tvitem)) == 0) |
2481 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM, | |
2482 0, (LPARAM)&tvitem)) == 0) | |
2483 gui_error ("error adding tree view entry", item); | 2478 gui_error ("error adding tree view entry", item); |
2484 | 2479 |
2485 return ret; | 2480 return ret; |
2486 } | 2481 } |
2487 | 2482 |
2549 { | 2544 { |
2550 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2545 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2551 Lisp_Object rest; | 2546 Lisp_Object rest; |
2552 HTREEITEM parent; | 2547 HTREEITEM parent; |
2553 /* Delete previous items. */ | 2548 /* Delete previous items. */ |
2554 SendMessage (wnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); | 2549 qxeSendMessage (wnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); |
2555 /* define a root */ | 2550 /* define a root */ |
2556 parent = add_tree_item (image_instance, wnd, NULL, | 2551 parent = add_tree_item (image_instance, wnd, NULL, |
2557 XCAR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)), | 2552 XCAR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)), |
2558 TRUE, IMAGE_INSTANCE_DOMAIN (ii)); | 2553 TRUE, IMAGE_INSTANCE_DOMAIN (ii)); |
2559 | 2554 |
2575 static int | 2570 static int |
2576 add_tab_item (Lisp_Object image_instance, | 2571 add_tab_item (Lisp_Object image_instance, |
2577 HWND wnd, Lisp_Object item, | 2572 HWND wnd, Lisp_Object item, |
2578 Lisp_Object domain, int i) | 2573 Lisp_Object domain, int i) |
2579 { | 2574 { |
2580 TC_ITEM tvitem; | 2575 TC_ITEMW tcitem; |
2581 int ret = 0; | 2576 int ret = 0; |
2582 | 2577 |
2583 tvitem.mask = TCIF_TEXT; | 2578 tcitem.mask = TCIF_TEXT; |
2584 | 2579 |
2585 if (GUI_ITEMP (item)) | 2580 if (GUI_ITEMP (item)) |
2586 { | 2581 { |
2587 tvitem.lParam = mswindows_register_gui_item (image_instance, | 2582 tcitem.lParam = |
2588 item, domain); | 2583 mswindows_register_gui_item (image_instance, item, domain); |
2589 tvitem.mask |= TCIF_PARAM; | 2584 tcitem.mask |= TCIF_PARAM; |
2590 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, | 2585 LISP_STRING_TO_TSTR (XGUI_ITEM (item)->name, tcitem.pszText); |
2591 C_STRING_ALLOCA, tvitem.pszText, | |
2592 Qnative); | |
2593 } | 2586 } |
2594 else | 2587 else |
2595 { | 2588 { |
2596 CHECK_STRING (item); | 2589 CHECK_STRING (item); |
2597 TO_EXTERNAL_FORMAT (LISP_STRING, item, | 2590 LISP_STRING_TO_TSTR (item, tcitem.pszText); |
2598 C_STRING_ALLOCA, tvitem.pszText, | 2591 } |
2599 Qnative); | 2592 |
2600 } | 2593 tcitem.cchTextMax = xetcslen ((Extbyte *) tcitem.pszText); |
2601 | 2594 |
2602 tvitem.cchTextMax = strlen (tvitem.pszText); | 2595 if ((ret = qxeSendMessage (wnd, TCM_INSERTITEM, i, (LPARAM) &tcitem)) < 0) |
2603 | |
2604 if ((ret = SendMessage (wnd, TCM_INSERTITEM, | |
2605 i, (LPARAM)&tvitem)) < 0) | |
2606 gui_error ("error adding tab entry", item); | 2596 gui_error ("error adding tab entry", item); |
2607 | 2597 |
2608 return ret; | 2598 return ret; |
2609 } | 2599 } |
2610 | 2600 |
2644 assert (idx == i); | 2634 assert (idx == i); |
2645 if (gui_item_selected_p (XCAR (rest))) | 2635 if (gui_item_selected_p (XCAR (rest))) |
2646 selected = i; | 2636 selected = i; |
2647 i++; | 2637 i++; |
2648 } | 2638 } |
2649 SendMessage (wnd, TCM_SETCURSEL, selected, 0); | 2639 qxeSendMessage (wnd, TCM_SETCURSEL, selected, 0); |
2650 } | 2640 } |
2651 | 2641 |
2652 /* Set the properties of a tab control. */ | 2642 /* Set the properties of a tab control. */ |
2653 static void | 2643 static void |
2654 mswindows_tab_control_redisplay (Lisp_Object image_instance) | 2644 mswindows_tab_control_redisplay (Lisp_Object image_instance) |
2693 XGUI_ITEM (selected)->selected; | 2683 XGUI_ITEM (selected)->selected; |
2694 /* We're not actually changing the items. */ | 2684 /* We're not actually changing the items. */ |
2695 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 0; | 2685 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 0; |
2696 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil; | 2686 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil; |
2697 | 2687 |
2698 SendMessage (wnd, TCM_SETCURSEL, i, 0); | 2688 qxeSendMessage (wnd, TCM_SETCURSEL, i, 0); |
2699 #ifdef DEBUG_WIDGET_OUTPUT | 2689 #ifdef DEBUG_WIDGET_OUTPUT |
2700 stderr_out ("tab control %p selected item %d\n", | 2690 stderr_out ("tab control %p selected item %d\n", |
2701 IMAGE_INSTANCE_SUBWINDOW_ID (ii), i); | 2691 IMAGE_INSTANCE_SUBWINDOW_ID (ii), i); |
2702 #endif | 2692 #endif |
2703 break; | 2693 break; |
2706 } | 2696 } |
2707 } | 2697 } |
2708 else | 2698 else |
2709 { | 2699 { |
2710 /* delete the pre-existing items */ | 2700 /* delete the pre-existing items */ |
2711 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); | 2701 qxeSendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); |
2712 | 2702 |
2713 /* add items to the tab */ | 2703 /* add items to the tab */ |
2714 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))) | 2704 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))) |
2715 { | 2705 { |
2716 add_tab_item (image_instance, wnd, XCAR (rest), | 2706 add_tab_item (image_instance, wnd, XCAR (rest), |
2717 IMAGE_INSTANCE_FRAME (ii), i); | 2707 IMAGE_INSTANCE_FRAME (ii), i); |
2718 if (gui_item_selected_p (XCAR (rest))) | 2708 if (gui_item_selected_p (XCAR (rest))) |
2719 selected_idx = i; | 2709 selected_idx = i; |
2720 i++; | 2710 i++; |
2721 } | 2711 } |
2722 SendMessage (wnd, TCM_SETCURSEL, selected_idx, 0); | 2712 qxeSendMessage (wnd, TCM_SETCURSEL, selected_idx, 0); |
2723 } | 2713 } |
2724 } | 2714 } |
2725 } | 2715 } |
2726 | 2716 |
2727 /* instantiate a static control possible for putting other things in */ | 2717 /* instantiate a static control possible for putting other things in */ |
2730 Lisp_Object instantiator, | 2720 Lisp_Object instantiator, |
2731 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2721 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2732 int dest_mask, Lisp_Object domain) | 2722 int dest_mask, Lisp_Object domain) |
2733 { | 2723 { |
2734 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2724 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2735 pointer_bg, dest_mask, domain, "STATIC", | 2725 pointer_bg, dest_mask, domain, |
2736 0, WS_EX_STATICEDGE); | 2726 "STATIC", 0, WS_EX_STATICEDGE); |
2737 } | 2727 } |
2738 | 2728 |
2739 /* instantiate a scrollbar control */ | 2729 /* instantiate a scrollbar control */ |
2740 static void | 2730 static void |
2741 mswindows_scrollbar_instantiate (Lisp_Object image_instance, | 2731 mswindows_scrollbar_instantiate (Lisp_Object image_instance, |
2743 Lisp_Object pointer_fg, | 2733 Lisp_Object pointer_fg, |
2744 Lisp_Object pointer_bg, | 2734 Lisp_Object pointer_bg, |
2745 int dest_mask, Lisp_Object domain) | 2735 int dest_mask, Lisp_Object domain) |
2746 { | 2736 { |
2747 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2737 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2748 pointer_bg, dest_mask, domain, "SCROLLBAR", | 2738 pointer_bg, dest_mask, domain, |
2749 WS_TABSTOP, WS_EX_CLIENTEDGE); | 2739 "SCROLLBAR", WS_TABSTOP, WS_EX_CLIENTEDGE); |
2750 } | 2740 } |
2751 | 2741 |
2752 /* instantiate a combo control */ | 2742 /* instantiate a combo control */ |
2753 static void | 2743 static void |
2754 mswindows_combo_box_instantiate (Lisp_Object image_instance, | 2744 mswindows_combo_box_instantiate (Lisp_Object image_instance, |
2779 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len; | 2769 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len; |
2780 IMAGE_INSTANCE_HEIGHT (ii) = height; | 2770 IMAGE_INSTANCE_HEIGHT (ii) = height; |
2781 | 2771 |
2782 /* Now create the widget. */ | 2772 /* Now create the widget. */ |
2783 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2773 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2784 pointer_bg, dest_mask, domain, "COMBOBOX", | 2774 pointer_bg, dest_mask, domain, |
2775 "COMBOBOX", | |
2785 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN | 2776 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN |
2786 | CBS_AUTOHSCROLL | 2777 | CBS_AUTOHSCROLL |
2787 | CBS_HASSTRINGS | WS_VSCROLL, | 2778 | CBS_HASSTRINGS | WS_VSCROLL, |
2788 WS_EX_CLIENTEDGE); | 2779 WS_EX_CLIENTEDGE); |
2789 /* Reset the height. layout will probably do this safely, but better make sure. */ | 2780 /* Reset the height. layout will probably do this safely, but better make sure. */ |
2794 IMAGE_UNCHANGED_GEOMETRY, | 2785 IMAGE_UNCHANGED_GEOMETRY, |
2795 domain); | 2786 domain); |
2796 | 2787 |
2797 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2788 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2798 /* add items to the combo box */ | 2789 /* add items to the combo box */ |
2799 SendMessage (wnd, CB_RESETCONTENT, 0, 0); | 2790 qxeSendMessage (wnd, CB_RESETCONTENT, 0, 0); |
2800 LIST_LOOP (rest, items) | 2791 LIST_LOOP (rest, items) |
2801 { | 2792 { |
2802 Extbyte* lparam; | 2793 Extbyte *lparam; |
2803 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest), | 2794 LISP_STRING_TO_TSTR (XCAR (rest), lparam); |
2804 C_STRING_ALLOCA, lparam, | 2795 if (qxeSendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) |
2805 Qnative); | |
2806 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) | |
2807 gui_error ("error adding combo entries", instantiator); | 2796 gui_error ("error adding combo entries", instantiator); |
2808 } | 2797 } |
2809 } | 2798 } |
2810 | 2799 |
2811 /* get properties of a control */ | 2800 /* get properties of a control */ |
2815 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2804 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2816 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2805 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2817 /* get the text from a control */ | 2806 /* get the text from a control */ |
2818 if (EQ (prop, Q_text)) | 2807 if (EQ (prop, Q_text)) |
2819 { | 2808 { |
2820 Bytecount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); | 2809 Charcount tchar_len = qxeSendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); |
2821 Extbyte *buf = (Extbyte*) alloca (len+1); | 2810 Extbyte *buf = (Extbyte *) alloca (XETCHAR_SIZE * (tchar_len + 1)); |
2822 | 2811 |
2823 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); | 2812 qxeSendMessage (wnd, WM_GETTEXT, (WPARAM)tchar_len + 1, (LPARAM) buf); |
2824 return build_ext_string (buf, Qnative); | 2813 return build_tstr_string (buf); |
2825 } | 2814 } |
2826 return Qunbound; | 2815 return Qunbound; |
2827 } | 2816 } |
2828 | 2817 |
2829 /* get properties of a button */ | 2818 /* get properties of a button */ |
2833 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2822 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2834 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2823 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2835 /* check the state of a button */ | 2824 /* check the state of a button */ |
2836 if (EQ (prop, Q_selected)) | 2825 if (EQ (prop, Q_selected)) |
2837 { | 2826 { |
2838 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) | 2827 if (qxeSendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) |
2839 return Qt; | 2828 return Qt; |
2840 else | 2829 else |
2841 return Qnil; | 2830 return Qnil; |
2842 } | 2831 } |
2843 return Qunbound; | 2832 return Qunbound; |
2850 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2839 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2851 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2840 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2852 /* get the text from a control */ | 2841 /* get the text from a control */ |
2853 if (EQ (prop, Q_text)) | 2842 if (EQ (prop, Q_text)) |
2854 { | 2843 { |
2855 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); | 2844 long item = qxeSendMessage (wnd, CB_GETCURSEL, 0, 0); |
2856 Bytecount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); | 2845 Charcount tchar_len = qxeSendMessage (wnd, CB_GETLBTEXTLEN, |
2857 Extbyte* buf = (Extbyte*) alloca (len+1); | 2846 (WPARAM)item, 0); |
2858 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); | 2847 Extbyte *buf = (Extbyte *) alloca (XETCHAR_SIZE * (tchar_len + 1)); |
2859 return build_ext_string (buf, Qnative); | 2848 qxeSendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM) buf); |
2849 return build_tstr_string (buf); | |
2860 } | 2850 } |
2861 return Qunbound; | 2851 return Qunbound; |
2862 } | 2852 } |
2863 | 2853 |
2864 /* set the properties of a progress gauge */ | 2854 /* set the properties of a progress gauge */ |
2878 stderr_out ("progress gauge displayed value on %p updated to %ld\n", | 2868 stderr_out ("progress gauge displayed value on %p updated to %ld\n", |
2879 WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2869 WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2880 XINT(val)); | 2870 XINT(val)); |
2881 #endif | 2871 #endif |
2882 CHECK_INT (val); | 2872 CHECK_INT (val); |
2883 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2873 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2884 PBM_SETPOS, (WPARAM)XINT (val), 0); | 2874 PBM_SETPOS, (WPARAM)XINT (val), 0); |
2885 } | 2875 } |
2886 } | 2876 } |
2887 | 2877 |
2888 LRESULT WINAPI | 2878 LRESULT WINAPI |
2889 mswindows_control_wnd_proc (HWND hwnd, UINT msg, | 2879 mswindows_control_wnd_proc (HWND hwnd, UINT msg, |
2899 case WM_CTLCOLORSTATIC: | 2889 case WM_CTLCOLORSTATIC: |
2900 case WM_CTLCOLORSCROLLBAR: | 2890 case WM_CTLCOLORSCROLLBAR: |
2901 | 2891 |
2902 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam); | 2892 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam); |
2903 default: | 2893 default: |
2904 return DefWindowProc (hwnd, msg, wParam, lParam); | 2894 return qxeDefWindowProc (hwnd, msg, wParam, lParam); |
2895 } | |
2896 } | |
2897 | |
2898 static void | |
2899 mswindows_widget_query_string_geometry (Lisp_Object string, Lisp_Object face, | |
2900 int *width, int *height, | |
2901 Lisp_Object domain) | |
2902 { | |
2903 if (height) | |
2904 query_string_geometry (string, face, 0, height, 0, domain); | |
2905 | |
2906 if (width) | |
2907 { | |
2908 HDC hdc = FRAME_MSWINDOWS_DC (DOMAIN_XFRAME (domain)); | |
2909 Extbyte *str; | |
2910 Bytecount len; | |
2911 SIZE size; | |
2912 | |
2913 SelectObject (hdc, mswindows_widget_hfont (face, domain, string)); | |
2914 TO_EXTERNAL_FORMAT (LISP_STRING, string, ALLOCA, (str, len), | |
2915 Qmswindows_tstr); | |
2916 qxeGetTextExtentPoint32 (hdc, str, len / XETCHAR_SIZE, &size); | |
2917 *width = size.cx; | |
2905 } | 2918 } |
2906 } | 2919 } |
2907 | 2920 |
2908 #endif /* HAVE_WIDGETS */ | 2921 #endif /* HAVE_WIDGETS */ |
2909 | 2922 |
2930 CONSOLE_HAS_METHOD (mswindows, redisplay_widget); | 2943 CONSOLE_HAS_METHOD (mswindows, redisplay_widget); |
2931 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); | 2944 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); |
2932 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); | 2945 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); |
2933 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); | 2946 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); |
2934 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); | 2947 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); |
2948 #ifdef HAVE_WIDGETS | |
2949 CONSOLE_HAS_METHOD (mswindows, widget_query_string_geometry); | |
2950 #endif | |
2935 | 2951 |
2936 /* image methods - printer */ | 2952 /* image methods - printer */ |
2937 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance); | 2953 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance); |
2938 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_image_instance); | 2954 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_image_instance); |
2939 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_equal); | 2955 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_equal); |
2940 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_hash); | 2956 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_hash); |
2941 CONSOLE_INHERITS_METHOD (msprinter, mswindows, init_image_instance_from_eimage); | 2957 CONSOLE_INHERITS_METHOD (msprinter, mswindows, |
2958 init_image_instance_from_eimage); | |
2942 CONSOLE_INHERITS_METHOD (msprinter, mswindows, locate_pixmap_file); | 2959 CONSOLE_INHERITS_METHOD (msprinter, mswindows, locate_pixmap_file); |
2943 } | 2960 } |
2944 | 2961 |
2945 void | 2962 void |
2946 image_instantiator_format_create_glyphs_mswindows (void) | 2963 image_instantiator_format_create_glyphs_mswindows (void) |