annotate src/glyphs-msw.c @ 434:9d177e8d4150 r21-2-25

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