Mercurial > hg > xemacs-beta
annotate src/glyphs-msw.c @ 4981:4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
-------------------- ChangeLog entries follow: --------------------
modules/ChangeLog addition:
2010-02-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c:
* postgresql/postgresql.c (CHECK_LIVE_CONNECTION):
* postgresql/postgresql.c (Fpq_connectdb):
* postgresql/postgresql.c (Fpq_connect_start):
* postgresql/postgresql.c (Fpq_lo_import):
* postgresql/postgresql.c (Fpq_lo_export):
* ldap/eldap.c (Fldap_open):
* ldap/eldap.c (Fldap_search_basic):
* ldap/eldap.c (Fldap_add):
* ldap/eldap.c (Fldap_modify):
* ldap/eldap.c (Fldap_delete):
* canna/canna_api.c (Fcanna_initialize):
* canna/canna_api.c (Fcanna_store_yomi):
* canna/canna_api.c (Fcanna_parse):
* canna/canna_api.c (Fcanna_henkan_begin):
EXTERNAL_TO_C_STRING returns its argument instead of storing it
in a parameter, and is renamed to EXTERNAL_TO_ITEXT. Similar
things happen to related macros. See entry in src/ChangeLog.
More Mule-izing of postgresql.c. Extract out common code
between `pq-connectdb' and `pq-connect-start'. Fix places
that signal an error string using a formatted string to instead
follow the standard and have a fixed reason followed by the
particular error message stored as one of the frobs.
src/ChangeLog addition:
2010-02-05 Ben Wing <ben@xemacs.org>
* console-msw.c (write_string_to_mswindows_debugging_output):
* console-msw.c (Fmswindows_message_box):
* console-x.c (x_perhaps_init_unseen_key_defaults):
* console.c:
* database.c (dbm_get):
* database.c (dbm_put):
* database.c (dbm_remove):
* database.c (berkdb_get):
* database.c (berkdb_put):
* database.c (berkdb_remove):
* database.c (Fopen_database):
* device-gtk.c (gtk_init_device):
* device-msw.c (msprinter_init_device_internal):
* device-msw.c (msprinter_default_printer):
* device-msw.c (msprinter_init_device):
* device-msw.c (sync_printer_with_devmode):
* device-msw.c (Fmsprinter_select_settings):
* device-x.c (sanity_check_geometry_resource):
* device-x.c (Dynarr_add_validified_lisp_string):
* device-x.c (x_init_device):
* device-x.c (Fx_put_resource):
* device-x.c (Fx_valid_keysym_name_p):
* device-x.c (Fx_set_font_path):
* dialog-msw.c (push_lisp_string_as_unicode):
* dialog-msw.c (handle_directory_dialog_box):
* dialog-msw.c (handle_file_dialog_box):
* dialog-x.c (dbox_descriptor_to_widget_value):
* editfns.c (Fformat_time_string):
* editfns.c (Fencode_time):
* editfns.c (Fset_time_zone_rule):
* emacs.c (make_argc_argv):
* emacs.c (Fdump_emacs):
* emodules.c (emodules_load):
* eval.c:
* eval.c (maybe_signal_error_1):
* event-msw.c (Fdde_alloc_advise_item):
* event-msw.c (mswindows_dde_callback):
* event-msw.c (mswindows_wnd_proc):
* fileio.c (report_error_with_errno):
* fileio.c (Fsysnetunam):
* fileio.c (Fdo_auto_save):
* font-mgr.c (extract_fcapi_string):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_filename):
* frame-gtk.c (gtk_set_frame_text_value):
* frame-gtk.c (gtk_create_widgets):
* frame-msw.c (mswindows_init_frame_1):
* frame-msw.c (mswindows_set_title_from_ibyte):
* frame-msw.c (msprinter_init_frame_3):
* frame-x.c (x_set_frame_text_value):
* frame-x.c (x_set_frame_properties):
* frame-x.c (start_drag_internal_1):
* frame-x.c (x_cde_transfer_callback):
* frame-x.c (x_create_widgets):
* glyphs-eimage.c (my_jpeg_output_message):
* glyphs-eimage.c (jpeg_instantiate):
* glyphs-eimage.c (gif_instantiate):
* glyphs-eimage.c (png_instantiate):
* glyphs-eimage.c (tiff_instantiate):
* glyphs-gtk.c (xbm_instantiate_1):
* glyphs-gtk.c (gtk_xbm_instantiate):
* glyphs-gtk.c (gtk_xpm_instantiate):
* glyphs-gtk.c (gtk_xface_instantiate):
* glyphs-gtk.c (cursor_font_instantiate):
* glyphs-gtk.c (gtk_redisplay_widget):
* glyphs-gtk.c (gtk_widget_instantiate_1):
* glyphs-gtk.c (gtk_add_tab_item):
* glyphs-msw.c (mswindows_xpm_instantiate):
* glyphs-msw.c (bmp_instantiate):
* glyphs-msw.c (mswindows_resource_instantiate):
* glyphs-msw.c (xbm_instantiate_1):
* glyphs-msw.c (mswindows_xbm_instantiate):
* glyphs-msw.c (mswindows_xface_instantiate):
* glyphs-msw.c (mswindows_redisplay_widget):
* glyphs-msw.c (mswindows_widget_instantiate):
* glyphs-msw.c (add_tree_item):
* glyphs-msw.c (add_tab_item):
* glyphs-msw.c (mswindows_combo_box_instantiate):
* glyphs-msw.c (mswindows_widget_query_string_geometry):
* glyphs-x.c (x_locate_pixmap_file):
* glyphs-x.c (xbm_instantiate_1):
* glyphs-x.c (x_xbm_instantiate):
* glyphs-x.c (extract_xpm_color_names):
* glyphs-x.c (x_xpm_instantiate):
* glyphs-x.c (x_xface_instantiate):
* glyphs-x.c (autodetect_instantiate):
* glyphs-x.c (safe_XLoadFont):
* glyphs-x.c (cursor_font_instantiate):
* glyphs-x.c (x_redisplay_widget):
* glyphs-x.c (Fchange_subwindow_property):
* glyphs-x.c (x_widget_instantiate):
* glyphs-x.c (x_tab_control_redisplay):
* glyphs.c (pixmap_to_lisp_data):
* gui-x.c (menu_separator_style_and_to_external):
* gui-x.c (add_accel_and_to_external):
* gui-x.c (button_item_to_widget_value):
* hpplay.c (player_error_internal):
* hpplay.c (play_sound_file):
* hpplay.c (play_sound_data):
* intl.c (Fset_current_locale):
* lisp.h:
* menubar-gtk.c (gtk_xemacs_set_accel_keys):
* menubar-msw.c (populate_menu_add_item):
* menubar-msw.c (populate_or_checksum_helper):
* menubar-x.c (menu_item_descriptor_to_widget_value_1):
* nt.c (init_user_info):
* nt.c (get_long_basename):
* nt.c (nt_get_resource):
* nt.c (init_mswindows_environment):
* nt.c (get_cached_volume_information):
* nt.c (mswindows_readdir):
* nt.c (read_unc_volume):
* nt.c (mswindows_stat):
* nt.c (mswindows_getdcwd):
* nt.c (mswindows_executable_type):
* nt.c (Fmswindows_short_file_name):
* ntplay.c (nt_play_sound_file):
* objects-gtk.c:
* objects-gtk.c (gtk_valid_color_name_p):
* objects-gtk.c (gtk_initialize_font_instance):
* objects-gtk.c (gtk_font_list):
* objects-msw.c (font_enum_callback_2):
* objects-msw.c (parse_font_spec):
* objects-x.c (x_parse_nearest_color):
* objects-x.c (x_valid_color_name_p):
* objects-x.c (x_initialize_font_instance):
* objects-x.c (x_font_instance_truename):
* objects-x.c (x_font_list):
* objects-xlike-inc.c (XFUN):
* objects-xlike-inc.c (xft_find_charset_font):
* process-nt.c (mswindows_report_winsock_error):
* process-nt.c (nt_create_process):
* process-nt.c (get_internet_address):
* process-nt.c (nt_open_network_stream):
* process-unix.c:
* process-unix.c (allocate_pty):
* process-unix.c (get_internet_address):
* process-unix.c (unix_canonicalize_host_name):
* process-unix.c (unix_open_network_stream):
* realpath.c:
* select-common.h (lisp_data_to_selection_data):
* select-gtk.c (symbol_to_gtk_atom):
* select-gtk.c (atom_to_symbol):
* select-msw.c (symbol_to_ms_cf):
* select-msw.c (mswindows_register_selection_data_type):
* select-x.c (symbol_to_x_atom):
* select-x.c (x_atom_to_symbol):
* select-x.c (hack_motif_clipboard_selection):
* select-x.c (Fx_store_cutbuffer_internal):
* sound.c (Fplay_sound_file):
* sound.c (Fplay_sound):
* sound.h (sound_perror):
* sysdep.c:
* sysdep.c (qxe_allocating_getcwd):
* sysdep.c (qxe_execve):
* sysdep.c (copy_in_passwd):
* sysdep.c (qxe_getpwnam):
* sysdep.c (qxe_ctime):
* sysdll.c (dll_open):
* sysdll.c (dll_function):
* sysdll.c (dll_variable):
* sysdll.c (search_linked_libs):
* sysdll.c (dll_error):
* sysfile.h:
* sysfile.h (PATHNAME_CONVERT_OUT_TSTR):
* sysfile.h (PATHNAME_CONVERT_OUT_UTF_8):
* sysfile.h (PATHNAME_CONVERT_OUT):
* sysfile.h (LISP_PATHNAME_CONVERT_OUT):
* syswindows.h (ITEXT_TO_TSTR):
* syswindows.h (LOCAL_FILE_FORMAT_TO_TSTR):
* syswindows.h (TSTR_TO_LOCAL_FILE_FORMAT):
* syswindows.h (LOCAL_FILE_FORMAT_TO_INTERNAL_MSWIN):
* syswindows.h (LISP_LOCAL_FILE_FORMAT_MAYBE_URL_TO_TSTR):
* text.h:
* text.h (eicpy_ext_len):
* text.h (enum new_dfc_src_type):
* text.h (EXTERNAL_TO_ITEXT):
* text.h (GET_STRERROR):
* tooltalk.c (check_status):
* tooltalk.c (Fadd_tooltalk_message_arg):
* tooltalk.c (Fadd_tooltalk_pattern_attribute):
* tooltalk.c (Fadd_tooltalk_pattern_arg):
* win32.c (tstr_to_local_file_format):
* win32.c (mswindows_lisp_error_1):
* win32.c (mswindows_report_process_error):
* win32.c (Fmswindows_shell_execute):
* win32.c (mswindows_read_link_1):
Changes involving external/internal format conversion,
mostly code cleanup and renaming.
1. Eliminate the previous macros like LISP_STRING_TO_EXTERNAL
that stored its result in a parameter. The new version of
LISP_STRING_TO_EXTERNAL returns its result through the
return value, same as the previous NEW_LISP_STRING_TO_EXTERNAL.
Use the new-style macros throughout the code.
2. Rename C_STRING_TO_EXTERNAL and friends to ITEXT_TO_EXTERNAL,
in keeping with overall naming rationalization involving
Itext and related types.
Macros involved in previous two:
EXTERNAL_TO_C_STRING -> EXTERNAL_TO_ITEXT
EXTERNAL_TO_C_STRING_MALLOC -> EXTERNAL_TO_ITEXT_MALLOC
SIZED_EXTERNAL_TO_C_STRING -> SIZED_EXTERNAL_TO_ITEXT
SIZED_EXTERNAL_TO_C_STRING_MALLOC -> SIZED_EXTERNAL_TO_ITEXT_MALLOC
C_STRING_TO_EXTERNAL -> ITEXT_TO_EXTERNAL
C_STRING_TO_EXTERNAL_MALLOC -> ITEXT_TO_EXTERNAL_MALLOC
LISP_STRING_TO_EXTERNAL
LISP_STRING_TO_EXTERNAL_MALLOC
LISP_STRING_TO_TSTR
C_STRING_TO_TSTR -> ITEXT_TO_TSTR
TSTR_TO_C_STRING -> TSTR_TO_ITEXT
The following four still return their values through parameters,
since they have more than one value to return:
C_STRING_TO_SIZED_EXTERNAL -> ITEXT_TO_SIZED_EXTERNAL
LISP_STRING_TO_SIZED_EXTERNAL
C_STRING_TO_SIZED_EXTERNAL_MALLOC -> ITEXT_TO_SIZED_EXTERNAL_MALLOC
LISP_STRING_TO_SIZED_EXTERNAL_MALLOC
Sometimes additional casts had to be inserted, since the old
macros played strange games and completely defeated the type system
of the store params.
3. Rewrite many places where direct calls to TO_EXTERNAL_FORMAT
occurred with calls to one of the convenience macros listed above,
or to make_extstring().
4. Eliminate SIZED_C_STRING macros (they were hardly used, anyway)
and use a direct call to TO_EXTERNAL_FORMAT or TO_INTERNAL_FORMAT.
4. Use LISP_PATHNAME_CONVERT_OUT in many places instead of something
like LISP_STRING_TO_EXTERNAL(..., Qfile_name).
5. Eliminate some temporary variables that are no longer necessary
now that we return a value rather than storing it into a variable.
6. Some Mule-izing in database.c.
7. Error functions:
-- A bit of code cleanup in maybe_signal_error_1.
-- Eliminate report_file_type_error; it's just an alias for
signal_error_2 with params in a different order.
-- Fix some places in the hostname-handling code that directly
inserted externally-retrieved error strings into the
supposed ASCII "reason" param instead of doing the right thing
and sticking text descriptive of what was going on in "reason"
and putting the external message in a frob.
8. Use Ascbyte instead of CIbyte in process-unix.c and maybe one
or two other places.
9. Some code cleanup in copy_in_passwd() in sysdep.c.
10. Fix a real bug due to accidental variable shadowing in
tstr_to_local_file_format() in win32.c.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Feb 2010 11:02:24 -0600 |
parents | 19a72041c5ed |
children | 3c3c1d139863 |
rev | line source |
---|---|
428 | 1 /* mswindows-specific glyph objects. |
438 | 2 Copyright (C) 1998, 1999, 2000 Andy Piper. |
2959 | 3 Copyright (C) 2001, 2002, 2003, 2004, 2005 Ben Wing. |
434 | 4 |
428 | 5 This file is part of XEmacs. |
6 | |
7 XEmacs is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2, or (at your option) any | |
10 later version. | |
11 | |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with XEmacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | |
22 /* Synched up with: Not in FSF. */ | |
23 | |
771 | 24 /* This file apparently Mule-ized, 8-7-2000, but could stand review. */ |
25 | |
442 | 26 /* written by Andy Piper <andy@xemacs.org> plagiarising bits from |
428 | 27 glyphs-x.c */ |
28 | |
771 | 29 #define NEED_MSWINDOWS_COMMCTRL |
30 | |
428 | 31 #include <config.h> |
32 #include "lisp.h" | |
800 | 33 |
872 | 34 #include "device-impl.h" |
800 | 35 #include "elhash.h" |
36 #include "faces.h" | |
37 #include "file-coding.h" | |
872 | 38 #include "frame-impl.h" |
800 | 39 #include "gui.h" |
40 #include "imgproc.h" | |
41 #include "insdel.h" | |
428 | 42 #include "lstream.h" |
800 | 43 #include "opaque.h" |
44 #include "sysdep.h" | |
45 #include "sysfile.h" | |
46 #include "window.h" | |
428 | 47 |
872 | 48 #include "console-msw-impl.h" |
428 | 49 #include "glyphs-msw.h" |
872 | 50 #include "objects-msw-impl.h" |
428 | 51 |
52 #define WIDGET_GLYPH_SLOT 0 | |
53 | |
54 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); | |
55 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); | |
56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); | |
57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit); | |
58 #ifdef HAVE_JPEG | |
59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg); | |
60 #endif | |
61 #ifdef HAVE_TIFF | |
62 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff); | |
434 | 63 #endif |
428 | 64 #ifdef HAVE_PNG |
65 DECLARE_IMAGE_INSTANTIATOR_FORMAT (png); | |
434 | 66 #endif |
428 | 67 #ifdef HAVE_GIF |
68 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif); | |
434 | 69 #endif |
428 | 70 #ifdef HAVE_XPM |
71 DEFINE_DEVICE_IIFORMAT (mswindows, xpm); | |
442 | 72 DEFINE_DEVICE_IIFORMAT (msprinter, xpm); |
428 | 73 #endif |
74 DEFINE_DEVICE_IIFORMAT (mswindows, xbm); | |
442 | 75 DEFINE_DEVICE_IIFORMAT (msprinter, xbm); |
428 | 76 #ifdef HAVE_XFACE |
77 DEFINE_DEVICE_IIFORMAT (mswindows, xface); | |
442 | 78 DEFINE_DEVICE_IIFORMAT (msprinter, xface); |
428 | 79 #endif |
442 | 80 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout); |
81 DEFINE_DEVICE_IIFORMAT (mswindows, native_layout); | |
428 | 82 DEFINE_DEVICE_IIFORMAT (mswindows, button); |
83 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field); | |
84 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow); | |
85 DEFINE_DEVICE_IIFORMAT (mswindows, widget); | |
86 DEFINE_DEVICE_IIFORMAT (mswindows, label); | |
87 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar); | |
88 DEFINE_DEVICE_IIFORMAT (mswindows, combo_box); | |
89 DEFINE_DEVICE_IIFORMAT (mswindows, progress_gauge); | |
90 DEFINE_DEVICE_IIFORMAT (mswindows, tree_view); | |
91 DEFINE_DEVICE_IIFORMAT (mswindows, tab_control); | |
92 | |
93 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp); | |
94 Lisp_Object Qbmp; | |
95 Lisp_Object Vmswindows_bitmap_file_path; | |
96 static COLORREF transparent_color = RGB (1,1,1); | |
97 | |
98 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource); | |
99 Lisp_Object Qmswindows_resource; | |
100 | |
101 static void | |
440 | 102 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, |
428 | 103 int slices, |
104 enum image_instance_type type); | |
105 static void | |
771 | 106 mswindows_initialize_image_instance_mask (Lisp_Image_Instance *image, |
442 | 107 HDC hcdc); |
108 | |
109 /* | |
110 * Given device D, retrieve compatible device context. D can be either | |
111 * mswindows or an msprinter device. | |
112 */ | |
113 inline static HDC | |
114 get_device_compdc (struct device *d) | |
115 { | |
116 if (DEVICE_MSWINDOWS_P (d)) | |
117 return DEVICE_MSWINDOWS_HCDC (d); | |
118 else | |
119 return DEVICE_MSPRINTER_HCDC (d); | |
120 } | |
121 | |
122 /* | |
123 * Initialize image instance pixel sizes in II. For a display bitmap, | |
124 * these will be same as real bitmap sizes. For a printer bitmap, | |
125 * these will be scaled up so that the bitmap is proportionally enlarged | |
126 * when output to printer. Redisplay code takes care of scaling, to | |
127 * conserve memory we do not really scale bitmaps. Set the watermark | |
128 * only here. | |
129 * #### Add support for unscalable bitmaps. | |
130 */ | |
131 static void init_image_instance_geometry (Lisp_Image_Instance *ii) | |
132 { | |
133 struct device *d = DOMAIN_XDEVICE (ii->domain); | |
134 | |
135 if (/* #### Scaleable && */ DEVICE_MSPRINTER_P (d)) | |
136 { | |
137 HDC printer_dc = DEVICE_MSPRINTER_HCDC (d); | |
138 HDC display_dc = CreateCompatibleDC (NULL); | |
139 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = | |
140 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | |
141 GetDeviceCaps (printer_dc, LOGPIXELSX), | |
142 GetDeviceCaps (display_dc, LOGPIXELSX)); | |
143 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = | |
144 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | |
145 GetDeviceCaps (printer_dc, LOGPIXELSY), | |
146 GetDeviceCaps (display_dc, LOGPIXELSY)); | |
147 } | |
148 else | |
149 { | |
150 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = | |
151 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii); | |
152 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = | |
153 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii); | |
154 } | |
155 } | |
428 | 156 |
157 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) | |
158 | |
159 /************************************************************************/ | |
160 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ | |
161 /* proper display */ | |
162 /************************************************************************/ | |
771 | 163 static BITMAPINFO *convert_EImage_to_DIBitmap (Lisp_Object device, |
428 | 164 int width, int height, |
2367 | 165 Binbyte *pic, |
428 | 166 int *bit_count, |
2367 | 167 Binbyte **bmp_data) |
428 | 168 { |
169 struct device *d = XDEVICE (device); | |
771 | 170 int i, j; |
171 RGBQUAD *colortbl; | |
172 int ncolors; | |
173 BITMAPINFO *bmp_info; | |
2367 | 174 Binbyte *ip, *dp; |
428 | 175 |
442 | 176 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0) |
428 | 177 { |
178 int bpline = BPLINE(width * 3); | |
179 /* FIXME: we can do this because 24bpp implies no color table, once | |
180 * we start palettizing this is no longer true. The X versions of | |
181 * this function quantises to 256 colors or bit masks down to a | |
182 * long. Windows can actually handle rgb triples in the raw so I | |
183 * don't see much point trying to optimize down to the best | |
184 * structure - unless it has memory / color allocation implications | |
185 * .... */ | |
771 | 186 bmp_info = xnew_and_zero (BITMAPINFO); |
434 | 187 |
428 | 188 if (!bmp_info) |
189 { | |
190 return NULL; | |
191 } | |
192 | |
771 | 193 bmp_info->bmiHeader.biBitCount = 24; /* just RGB triples for now */ |
194 bmp_info->bmiHeader.biCompression = BI_RGB; /* just RGB triples | |
195 for now */ | |
196 bmp_info->bmiHeader.biSizeImage = width * height * 3; | |
428 | 197 |
198 /* bitmap data needs to be in blue, green, red triples - in that | |
199 order, eimage is in RGB format so we need to convert */ | |
2367 | 200 *bmp_data = xnew_array_and_zero (Binbyte, bpline * height); |
428 | 201 *bit_count = bpline * height; |
202 | |
203 if (!bmp_data) | |
204 { | |
1726 | 205 xfree (bmp_info, BITMAPINFO *); |
428 | 206 return NULL; |
207 } | |
208 | |
209 ip = pic; | |
210 for (i = height-1; i >= 0; i--) { | |
211 dp = (*bmp_data) + (i * bpline); | |
212 for (j = 0; j < width; j++) { | |
771 | 213 dp[2] = *ip++; |
214 dp[1] = *ip++; | |
215 *dp = *ip++; | |
428 | 216 dp += 3; |
217 } | |
218 } | |
219 } | |
220 else /* scale to 256 colors */ | |
221 { | |
222 int rd,gr,bl; | |
223 quant_table *qtable; | |
224 int bpline = BPLINE (width * 3); | |
225 /* Quantize the image and get a histogram while we're at it. | |
226 Do this first to save memory */ | |
227 qtable = build_EImage_quantable(pic, width, height, 256); | |
228 if (qtable == NULL) return NULL; | |
229 | |
230 /* use our quantize table to allocate the colors */ | |
231 ncolors = qtable->num_active_colors; | |
771 | 232 bmp_info = (BITMAPINFO *)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) + |
428 | 233 sizeof(RGBQUAD) * ncolors); |
234 if (!bmp_info) | |
235 { | |
1726 | 236 xfree (qtable, quant_table *); |
428 | 237 return NULL; |
238 } | |
239 | |
2367 | 240 colortbl = (RGBQUAD *) (((Binbyte *) bmp_info) + |
771 | 241 sizeof (BITMAPINFOHEADER)); |
242 | |
243 bmp_info->bmiHeader.biBitCount = 8; | |
244 bmp_info->bmiHeader.biCompression = BI_RGB; | |
245 bmp_info->bmiHeader.biSizeImage = bpline * height; | |
246 bmp_info->bmiHeader.biClrUsed = ncolors; | |
247 bmp_info->bmiHeader.biClrImportant = ncolors; | |
434 | 248 |
2367 | 249 *bmp_data = xnew_array_and_zero (Binbyte, bpline * height); |
428 | 250 *bit_count = bpline * height; |
251 | |
252 if (!*bmp_data) | |
253 { | |
1726 | 254 xfree (qtable, quant_table *); |
255 xfree (bmp_info, BITMAPINFO *); | |
428 | 256 return NULL; |
257 } | |
434 | 258 |
428 | 259 /* build up an RGBQUAD colortable */ |
442 | 260 for (i = 0; i < qtable->num_active_colors; i++) |
261 { | |
262 colortbl[i].rgbRed = (BYTE) qtable->rm[i]; | |
263 colortbl[i].rgbGreen = (BYTE) qtable->gm[i]; | |
264 colortbl[i].rgbBlue = (BYTE) qtable->bm[i]; | |
265 colortbl[i].rgbReserved = 0; | |
266 } | |
428 | 267 |
268 /* now build up the data. picture has to be upside-down and | |
269 back-to-front for msw bitmaps */ | |
270 ip = pic; | |
442 | 271 for (i = height-1; i >= 0; i--) |
272 { | |
273 dp = (*bmp_data) + (i * bpline); | |
274 for (j = 0; j < width; j++) | |
275 { | |
276 rd = *ip++; | |
277 gr = *ip++; | |
278 bl = *ip++; | |
279 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl); | |
280 } | |
428 | 281 } |
1726 | 282 xfree (qtable, quant_table *); |
434 | 283 } |
428 | 284 /* fix up the standard stuff */ |
771 | 285 bmp_info->bmiHeader.biWidth = width; |
286 bmp_info->bmiHeader.biHeight = height; | |
287 bmp_info->bmiHeader.biPlanes = 1; | |
288 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
289 bmp_info->bmiHeader.biXPelsPerMeter = 0; /* unless you know better */ | |
290 bmp_info->bmiHeader.biYPelsPerMeter = 0; | |
428 | 291 |
292 return bmp_info; | |
293 } | |
294 | |
295 /* Given a pixmap filename, look through all of the "standard" places | |
296 where the file might be located. Return a full pathname if found; | |
297 otherwise, return Qnil. */ | |
298 | |
299 static Lisp_Object | |
300 mswindows_locate_pixmap_file (Lisp_Object name) | |
301 { | |
302 /* This function can GC if IN_REDISPLAY is false */ | |
303 Lisp_Object found; | |
304 | |
305 /* Check non-absolute pathnames with a directory component relative to | |
306 the search path; that's the way Xt does it. */ | |
826 | 307 if (IS_DIRECTORY_SEP(string_byte (name, 0)) || |
308 (string_byte (name, 0) == '.' && | |
309 (IS_DIRECTORY_SEP(string_byte (name, 1)) || | |
310 (string_byte (name, 1) == '.' && | |
311 (IS_DIRECTORY_SEP(string_byte (name, 2))))))) | |
428 | 312 { |
313 if (!NILP (Ffile_readable_p (name))) | |
440 | 314 return Fexpand_file_name (name, Qnil); |
428 | 315 else |
316 return Qnil; | |
317 } | |
318 | |
319 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0) | |
320 { | |
321 Lisp_Object temp = list1 (Vdata_directory); | |
322 struct gcpro gcpro1; | |
323 | |
324 GCPRO1 (temp); | |
325 locate_file (temp, name, Qnil, &found, R_OK); | |
326 UNGCPRO; | |
327 } | |
434 | 328 |
428 | 329 return found; |
330 } | |
331 | |
332 | |
333 /* Initialize an image instance from a bitmap | |
334 | |
335 DEST_MASK specifies the mask of allowed image types. | |
336 | |
337 If this fails, signal an error. INSTANTIATOR is only used | |
338 in the error message. */ | |
339 | |
340 static void | |
440 | 341 init_image_instance_from_dibitmap (Lisp_Image_Instance *ii, |
428 | 342 BITMAPINFO *bmp_info, |
343 int dest_mask, | |
344 void *bmp_data, | |
345 int bmp_bits, | |
346 int slices, | |
434 | 347 Lisp_Object instantiator, |
428 | 348 int x_hot, int y_hot, |
349 int create_mask) | |
350 { | |
442 | 351 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); |
771 | 352 void *bmp_buf = 0; |
442 | 353 enum image_instance_type type; |
428 | 354 HBITMAP bitmap; |
355 HDC hdc; | |
356 | |
357 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) | |
358 type = IMAGE_COLOR_PIXMAP; | |
359 else if (dest_mask & IMAGE_POINTER_MASK) | |
360 type = IMAGE_POINTER; | |
434 | 361 else |
428 | 362 incompatible_image_types (instantiator, dest_mask, |
363 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); | |
442 | 364 |
365 hdc = get_device_compdc (d); | |
366 bitmap = CreateDIBSection (hdc, | |
367 bmp_info, | |
368 DIB_RGB_COLORS, | |
369 &bmp_buf, | |
370 0, 0); | |
428 | 371 |
372 if (!bitmap || !bmp_buf) | |
563 | 373 signal_image_error ("Unable to create bitmap", instantiator); |
428 | 374 |
375 /* copy in the actual bitmap */ | |
376 memcpy (bmp_buf, bmp_data, bmp_bits); | |
377 | |
378 mswindows_initialize_dibitmap_image_instance (ii, slices, type); | |
379 | |
380 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = | |
381 find_keyword_in_vector (instantiator, Q_file); | |
382 | |
383 /* Fixup a set of bitmaps. */ | |
384 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; | |
385 | |
386 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; | |
442 | 387 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = |
388 bmp_info->bmiHeader.biWidth; | |
389 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = | |
390 bmp_info->bmiHeader.biHeight; | |
391 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; | |
793 | 392 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (x_hot); |
393 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (y_hot); | |
442 | 394 init_image_instance_geometry (ii); |
428 | 395 |
396 if (create_mask) | |
397 { | |
442 | 398 mswindows_initialize_image_instance_mask (ii, hdc); |
428 | 399 } |
434 | 400 |
428 | 401 if (type == IMAGE_POINTER) |
402 { | |
403 mswindows_initialize_image_instance_icon(ii, TRUE); | |
404 } | |
405 } | |
406 | |
407 static void | |
440 | 408 image_instance_add_dibitmap (Lisp_Image_Instance *ii, |
428 | 409 BITMAPINFO *bmp_info, |
410 void *bmp_data, | |
411 int bmp_bits, | |
412 int slice, | |
413 Lisp_Object instantiator) | |
414 { | |
442 | 415 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); |
771 | 416 void *bmp_buf = 0; |
442 | 417 |
418 HBITMAP bitmap = CreateDIBSection (get_device_compdc (d), | |
428 | 419 bmp_info, |
420 DIB_RGB_COLORS, | |
434 | 421 &bmp_buf, |
428 | 422 0,0); |
434 | 423 |
428 | 424 if (!bitmap || !bmp_buf) |
563 | 425 signal_image_error ("Unable to create bitmap", instantiator); |
428 | 426 |
427 /* copy in the actual bitmap */ | |
428 memcpy (bmp_buf, bmp_data, bmp_bits); | |
429 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap; | |
430 } | |
431 | |
432 static void | |
440 | 433 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii, |
428 | 434 int width, int height, |
435 int slices, | |
2367 | 436 Binbyte *eimage, |
428 | 437 int dest_mask, |
438 Lisp_Object instantiator, | |
2959 | 439 Lisp_Object UNUSED (pointer_fg), |
440 Lisp_Object UNUSED (pointer_bg), | |
428 | 441 Lisp_Object domain) |
442 { | |
443 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | |
771 | 444 BITMAPINFO * bmp_info; |
2367 | 445 Binbyte * bmp_data; |
428 | 446 int bmp_bits; |
447 COLORREF bkcolor; | |
448 int slice; | |
434 | 449 |
442 | 450 CHECK_MSGDI_DEVICE (device); |
428 | 451 |
452 /* this is a hack but MaskBlt and TransparentBlt are not supported | |
453 on most windows variants */ | |
434 | 454 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR |
428 | 455 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); |
456 | |
457 for (slice = 0; slice < slices; slice++) | |
458 { | |
459 /* build a bitmap from the eimage */ | |
771 | 460 if (!(bmp_info = convert_EImage_to_DIBitmap (device, width, height, |
428 | 461 eimage + (width * height * 3 * slice), |
462 &bmp_bits, &bmp_data))) | |
463 { | |
563 | 464 signal_image_error ("EImage to DIBitmap conversion failed", |
465 instantiator); | |
428 | 466 } |
467 | |
468 /* Now create the pixmap and set up the image instance */ | |
469 if (slice == 0) | |
470 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, | |
471 bmp_data, bmp_bits, slices, instantiator, | |
472 0, 0, 0); | |
473 else | |
474 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice, | |
475 instantiator); | |
434 | 476 |
1726 | 477 xfree (bmp_info, BITMAPINFO *); |
2367 | 478 xfree (bmp_data, Binbyte *); |
428 | 479 } |
480 } | |
481 | |
442 | 482 inline static void |
2367 | 483 set_mono_pixel (Binbyte *bits, |
442 | 484 int bpline, int height, |
485 int x, int y, int white) | |
434 | 486 { |
438 | 487 int i; |
2367 | 488 Binbyte bitnum; |
428 | 489 /* Find the byte on which this scanline begins */ |
438 | 490 i = (height - y - 1) * bpline; |
428 | 491 /* Find the byte containing this pixel */ |
438 | 492 i += (x >> 3); |
428 | 493 /* Which bit is it? */ |
2367 | 494 bitnum = (Binbyte) (7 - (x & 7)); |
442 | 495 if (white) /* Turn it on */ |
496 bits[i] |= (1 << bitnum); | |
497 else /* Turn it off */ | |
498 bits[i] &= ~(1 << bitnum); | |
434 | 499 } |
428 | 500 |
501 static void | |
771 | 502 mswindows_initialize_image_instance_mask (Lisp_Image_Instance *image, |
442 | 503 HDC hcdc) |
428 | 504 { |
505 HBITMAP mask; | |
506 HGDIOBJ old = NULL; | |
2367 | 507 Binbyte *dibits, *and_bits; |
442 | 508 BITMAPINFO *bmp_info = |
771 | 509 (BITMAPINFO *) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD)); |
428 | 510 int i, j; |
442 | 511 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image); |
512 | |
513 int maskbpline = BPLINE ((IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) + 7) / 8); | |
514 int bpline = BPLINE (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) * 3); | |
428 | 515 |
516 if (!bmp_info) | |
517 return; | |
518 | |
771 | 519 bmp_info->bmiHeader.biWidth = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); |
428 | 520 bmp_info->bmiHeader.biHeight = height; |
442 | 521 bmp_info->bmiHeader.biPlanes = 1; |
771 | 522 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
442 | 523 bmp_info->bmiHeader.biBitCount = 1; |
524 bmp_info->bmiHeader.biCompression = BI_RGB; | |
434 | 525 bmp_info->bmiHeader.biClrUsed = 2; |
526 bmp_info->bmiHeader.biClrImportant = 2; | |
527 bmp_info->bmiHeader.biSizeImage = height * maskbpline; | |
428 | 528 bmp_info->bmiColors[0].rgbRed = 0; |
529 bmp_info->bmiColors[0].rgbGreen = 0; | |
530 bmp_info->bmiColors[0].rgbBlue = 0; | |
531 bmp_info->bmiColors[0].rgbReserved = 0; | |
532 bmp_info->bmiColors[1].rgbRed = 255; | |
533 bmp_info->bmiColors[1].rgbGreen = 255; | |
534 bmp_info->bmiColors[1].rgbBlue = 255; | |
535 bmp_info->bmiColors[0].rgbReserved = 0; | |
434 | 536 |
537 if (!(mask = CreateDIBSection (hcdc, | |
428 | 538 bmp_info, |
539 DIB_RGB_COLORS, | |
2367 | 540 /* The intermediate cast fools gcc into |
541 not outputting strict-aliasing | |
542 complaints */ | |
543 (void **) (void *) &and_bits, | |
428 | 544 0,0))) |
545 { | |
1726 | 546 xfree (bmp_info, BITMAPINFO *); |
428 | 547 return; |
548 } | |
549 | |
550 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image)); | |
551 /* build up an in-memory set of bits to mess with */ | |
552 xzero (*bmp_info); | |
553 | |
442 | 554 bmp_info->bmiHeader.biWidth = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); |
428 | 555 bmp_info->bmiHeader.biHeight = -height; |
442 | 556 bmp_info->bmiHeader.biPlanes = 1; |
557 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
558 bmp_info->bmiHeader.biBitCount = 24; | |
559 bmp_info->bmiHeader.biCompression = BI_RGB; | |
434 | 560 bmp_info->bmiHeader.biClrUsed = 0; |
561 bmp_info->bmiHeader.biClrImportant = 0; | |
428 | 562 bmp_info->bmiHeader.biSizeImage = height * bpline; |
563 | |
2367 | 564 dibits = xnew_array_and_zero (Binbyte, bpline * height); |
428 | 565 if (GetDIBits (hcdc, |
566 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), | |
567 0, | |
568 height, | |
569 dibits, | |
570 bmp_info, | |
571 DIB_RGB_COLORS) <= 0) | |
572 { | |
1726 | 573 xfree (bmp_info, BITMAPINFO *); |
428 | 574 return; |
575 } | |
576 | |
577 /* now set the colored bits in the mask and transparent ones to | |
578 black in the original */ | |
442 | 579 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++) |
434 | 580 { |
771 | 581 for (j = 0; j < height; j++) |
434 | 582 { |
2367 | 583 Binbyte *idx = &dibits[j * bpline + i * 3]; |
428 | 584 |
442 | 585 if (RGB (idx[2], idx[1], idx[0]) == transparent_color) |
434 | 586 { |
428 | 587 idx[0] = idx[1] = idx[2] = 0; |
442 | 588 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE); |
428 | 589 } |
434 | 590 else |
591 { | |
442 | 592 set_mono_pixel (and_bits, maskbpline, height, i, j, FALSE); |
428 | 593 } |
594 } | |
595 } | |
596 | |
597 SetDIBits (hcdc, | |
598 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), | |
599 0, | |
600 height, | |
601 dibits, | |
602 bmp_info, | |
603 DIB_RGB_COLORS); | |
604 | |
1726 | 605 xfree (bmp_info, BITMAPINFO *); |
2367 | 606 xfree (dibits, Binbyte *); |
434 | 607 |
428 | 608 SelectObject(hcdc, old); |
609 | |
610 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; | |
611 } | |
612 | |
613 void | |
771 | 614 mswindows_initialize_image_instance_icon (Lisp_Image_Instance *image, |
428 | 615 int cursor) |
616 { | |
617 ICONINFO x_icon; | |
618 | |
619 /* we rely on windows to do any resizing necessary */ | |
771 | 620 x_icon.fIcon = cursor ? FALSE : TRUE; |
621 x_icon.xHotspot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image)); | |
622 x_icon.yHotspot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image)); | |
623 x_icon.hbmMask = IMAGE_INSTANCE_MSWINDOWS_MASK (image); | |
624 x_icon.hbmColor = IMAGE_INSTANCE_MSWINDOWS_BITMAP (image); | |
434 | 625 |
428 | 626 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= |
627 CreateIconIndirect (&x_icon); | |
628 } | |
629 | |
442 | 630 static HBITMAP |
631 create_resized_bitmap (HBITMAP curbmp, struct frame *f, | |
632 int curx, int cury, | |
633 int newx, int newy) | |
428 | 634 { |
635 HBITMAP newbmp; | |
636 HGDIOBJ old1, old2; | |
442 | 637 |
638 HDC hcdc = get_device_compdc (XDEVICE (FRAME_DEVICE (f))); | |
434 | 639 HDC hdcDst = CreateCompatibleDC (hcdc); |
640 | |
442 | 641 old1 = SelectObject (hcdc, curbmp); |
434 | 642 |
428 | 643 newbmp = CreateCompatibleBitmap (hcdc, newx, newy); |
644 | |
645 old2 = SelectObject (hdcDst, newbmp); | |
434 | 646 |
428 | 647 if (!StretchBlt (hdcDst, 0, 0, newx, newy, |
434 | 648 hcdc, 0, 0, |
442 | 649 curx, |
650 cury, | |
428 | 651 SRCCOPY)) |
652 { | |
653 DeleteObject (newbmp); | |
654 DeleteDC (hdcDst); | |
655 return 0; | |
656 } | |
657 | |
658 SelectObject (hdcDst, old2); | |
659 SelectObject (hcdc, old1); | |
660 DeleteDC (hdcDst); | |
661 | |
662 return newbmp; | |
663 } | |
664 | |
665 HBITMAP | |
771 | 666 mswindows_create_resized_bitmap (Lisp_Image_Instance *ii, |
667 struct frame *f, | |
442 | 668 int newx, int newy) |
669 { | |
670 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii), | |
671 f, | |
672 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | |
673 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | |
674 newx, newy); | |
675 } | |
676 | |
677 HBITMAP | |
771 | 678 mswindows_create_resized_mask (Lisp_Image_Instance *ii, |
679 struct frame *f, | |
428 | 680 int newx, int newy) |
681 { | |
442 | 682 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii) == NULL) |
683 return NULL; | |
684 | |
685 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_MASK (ii), | |
686 f, | |
687 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | |
688 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | |
689 newx, newy); | |
428 | 690 } |
691 | |
442 | 692 #if 0 /* Currently unused */ |
693 /* #### Warning: This function is not correct anymore with | |
694 resizable printer bitmaps. If you uncomment it, clean it. --kkm */ | |
428 | 695 int |
771 | 696 mswindows_resize_dibitmap_instance (Lisp_Image_Instance *ii, |
697 struct frame *f, | |
428 | 698 int newx, int newy) |
699 { | |
700 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); | |
701 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); | |
702 | |
703 if (!newbmp) | |
704 return FALSE; | |
434 | 705 |
428 | 706 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)) |
707 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)); | |
708 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) | |
709 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)); | |
710 | |
711 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = newbmp; | |
712 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = newmask; | |
713 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx; | |
714 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy; | |
715 | |
716 return TRUE; | |
717 } | |
442 | 718 #endif |
428 | 719 |
720 /********************************************************************** | |
721 * XPM * | |
722 **********************************************************************/ | |
723 | |
724 #ifdef HAVE_XPM | |
725 | |
726 struct color_symbol | |
727 { | |
867 | 728 Ibyte * name; |
428 | 729 COLORREF color; |
730 }; | |
731 | |
771 | 732 static struct color_symbol * |
428 | 733 extract_xpm_color_names (Lisp_Object device, |
734 Lisp_Object domain, | |
735 Lisp_Object color_symbol_alist, | |
771 | 736 int *nsymbols) |
428 | 737 { |
738 /* This function can GC */ | |
739 Lisp_Object rest; | |
740 Lisp_Object results = Qnil; | |
741 int i, j; | |
742 struct color_symbol *colortbl; | |
743 struct gcpro gcpro1, gcpro2; | |
744 | |
745 GCPRO2 (results, device); | |
746 | |
747 /* We built up results to be (("name" . #<color>) ...) so that if an | |
748 error happens we don't lose any malloc()ed data, or more importantly, | |
749 leave any pixels allocated in the server. */ | |
750 i = 0; | |
751 LIST_LOOP (rest, color_symbol_alist) | |
752 { | |
753 Lisp_Object cons = XCAR (rest); | |
754 Lisp_Object name = XCAR (cons); | |
755 Lisp_Object value = XCDR (cons); | |
756 if (NILP (value)) | |
757 continue; | |
758 if (STRINGP (value)) | |
759 value = | |
760 Fmake_color_instance | |
793 | 761 (value, device, encode_error_behavior_flag (ERROR_ME_DEBUG_WARN)); |
428 | 762 else |
763 { | |
764 assert (COLOR_SPECIFIERP (value)); | |
765 value = Fspecifier_instance (value, domain, Qnil, Qnil); | |
766 } | |
767 if (NILP (value)) | |
768 continue; | |
769 results = noseeum_cons (noseeum_cons (name, value), results); | |
770 i++; | |
771 } | |
772 UNGCPRO; /* no more evaluation */ | |
773 | |
771 | 774 *nsymbols = i; |
428 | 775 if (i == 0) return 0; |
776 | |
777 colortbl = xnew_array_and_zero (struct color_symbol, i); | |
778 | |
771 | 779 for (j = 0; j < i; j++) |
428 | 780 { |
781 Lisp_Object cons = XCAR (results); | |
434 | 782 colortbl[j].color = |
428 | 783 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); |
784 | |
771 | 785 /* mustn't lose this when we return */ |
786 colortbl[j].name = qxestrdup (XSTRING_DATA (XCAR (cons))); | |
853 | 787 free_cons (cons); |
428 | 788 cons = results; |
789 results = XCDR (results); | |
853 | 790 free_cons (cons); |
428 | 791 } |
792 return colortbl; | |
793 } | |
794 | |
442 | 795 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer, |
2367 | 796 Binbyte **data, |
771 | 797 int *width, int *height, |
798 int *x_hot, int *y_hot, | |
799 int *transp, | |
800 struct color_symbol *color_symbols, | |
428 | 801 int nsymbols) |
802 { | |
803 XpmImage xpmimage; | |
804 XpmInfo xpminfo; | |
805 int result, i, j, transp_idx, maskbpline; | |
2367 | 806 Binbyte *dptr; |
771 | 807 unsigned int *sptr; |
428 | 808 COLORREF color; /* the american spelling virus hits again .. */ |
771 | 809 COLORREF *colortbl; |
428 | 810 |
811 xzero (xpmimage); | |
812 xzero (xpminfo); | |
771 | 813 xpminfo.valuemask = XpmHotspot; |
814 *transp = FALSE; | |
815 | |
816 result = XpmCreateXpmImageFromBuffer ((char *)buffer, | |
428 | 817 &xpmimage, |
818 &xpminfo); | |
819 switch (result) | |
820 { | |
821 case XpmSuccess: | |
822 break; | |
823 case XpmFileInvalid: | |
824 { | |
563 | 825 signal_image_error ("Invalid XPM data", image); |
428 | 826 } |
827 case XpmNoMemory: | |
828 { | |
563 | 829 signal_double_image_error ("Parsing pixmap data", |
830 "out of memory", image); | |
428 | 831 } |
832 default: | |
833 { | |
563 | 834 signal_double_image_error_2 ("Parsing pixmap data", |
835 "unknown error", | |
836 make_int (result), image); | |
428 | 837 } |
838 } | |
434 | 839 |
428 | 840 *width = xpmimage.width; |
841 *height = xpmimage.height; | |
434 | 842 maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8); |
843 | |
2367 | 844 *data = xnew_array_and_zero (Binbyte, *width * *height * 3); |
428 | 845 |
846 if (!*data) | |
847 { | |
848 XpmFreeXpmImage (&xpmimage); | |
849 XpmFreeXpmInfo (&xpminfo); | |
850 return 0; | |
851 } | |
852 | |
853 /* build a color table to speed things up */ | |
854 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors); | |
855 if (!colortbl) | |
856 { | |
2367 | 857 xfree (*data, Binbyte *); |
428 | 858 XpmFreeXpmImage (&xpmimage); |
859 XpmFreeXpmInfo (&xpminfo); | |
860 return 0; | |
861 } | |
862 | |
771 | 863 for (i = 0; i < (int) xpmimage.ncolors; i++) |
428 | 864 { |
865 /* goto alert!!!! */ | |
866 /* pick up symbolic colors in preference */ | |
867 if (xpmimage.colorTable[i].symbolic) | |
868 { | |
771 | 869 if (!strcasecmp (xpmimage.colorTable[i].symbolic, "BgColor") |
428 | 870 || |
771 | 871 !strcasecmp (xpmimage.colorTable[i].symbolic, "None")) |
428 | 872 { |
771 | 873 *transp = TRUE; |
874 colortbl[i] = transparent_color; | |
875 transp_idx = i; | |
428 | 876 goto label_found_color; |
877 } | |
878 else if (color_symbols) | |
879 { | |
771 | 880 for (j = 0; j < nsymbols; j++) |
428 | 881 { |
2367 | 882 if (!qxestrcmp_ascii (color_symbols[j].name, |
771 | 883 xpmimage.colorTable[i].symbolic)) |
428 | 884 { |
771 | 885 colortbl[i] = color_symbols[j].color; |
428 | 886 goto label_found_color; |
887 } | |
888 } | |
889 } | |
890 else if (xpmimage.colorTable[i].c_color == 0) | |
891 { | |
892 goto label_no_color; | |
893 } | |
894 } | |
895 /* pick up transparencies */ | |
771 | 896 if (!strcasecmp (xpmimage.colorTable[i].c_color, "None")) |
428 | 897 { |
771 | 898 *transp = TRUE; |
899 colortbl[i] = transparent_color; | |
900 transp_idx = i; | |
428 | 901 goto label_found_color; |
902 } | |
903 /* finally pick up a normal color spec */ | |
904 if (xpmimage.colorTable[i].c_color) | |
905 { | |
906 colortbl[i]= | |
867 | 907 mswindows_string_to_color ((Ibyte *) |
771 | 908 xpmimage.colorTable[i].c_color); |
428 | 909 goto label_found_color; |
910 } | |
434 | 911 |
428 | 912 label_no_color: |
2367 | 913 xfree (*data, Binbyte *); |
1726 | 914 xfree (colortbl, COLORREF *); |
428 | 915 XpmFreeXpmImage (&xpmimage); |
916 XpmFreeXpmInfo (&xpminfo); | |
917 return 0; | |
434 | 918 |
428 | 919 label_found_color:; |
920 } | |
921 | |
922 /* convert the image */ | |
771 | 923 sptr = xpmimage.data; |
924 dptr= *data; | |
428 | 925 for (i = 0; i< *width * *height; i++) |
926 { | |
927 color = colortbl[*sptr++]; | |
928 | |
929 /* split out the 0x02bbggrr colorref into an rgb triple */ | |
930 *dptr++=GetRValue (color); /* red */ | |
931 *dptr++=GetGValue (color); /* green */ | |
932 *dptr++=GetBValue (color); /* blue */ | |
933 } | |
934 | |
771 | 935 *x_hot = xpminfo.x_hotspot; |
936 *y_hot = xpminfo.y_hotspot; | |
428 | 937 |
938 XpmFreeXpmImage (&xpmimage); | |
939 XpmFreeXpmInfo (&xpminfo); | |
1726 | 940 xfree (colortbl, COLORREF *); |
428 | 941 return TRUE; |
942 } | |
943 | |
944 static void | |
945 mswindows_xpm_instantiate (Lisp_Object image_instance, | |
946 Lisp_Object instantiator, | |
2286 | 947 Lisp_Object UNUSED (pointer_fg), |
948 Lisp_Object UNUSED (pointer_bg), | |
428 | 949 int dest_mask, Lisp_Object domain) |
950 { | |
440 | 951 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
428 | 952 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
442 | 953 const Extbyte *bytes; |
665 | 954 Bytecount len; |
2367 | 955 Binbyte *eimage; |
428 | 956 int width, height, x_hot, y_hot; |
957 BITMAPINFO* bmp_info; | |
2367 | 958 Binbyte* bmp_data; |
428 | 959 int bmp_bits; |
771 | 960 int nsymbols = 0, transp; |
961 struct color_symbol* color_symbols = NULL; | |
434 | 962 |
428 | 963 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
964 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, | |
965 Q_color_symbols); | |
966 | |
442 | 967 CHECK_MSGDI_DEVICE (device); |
428 | 968 |
969 assert (!NILP (data)); | |
970 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
971 LISP_STRING_TO_SIZED_EXTERNAL (data, bytes, len, Qbinary); |
428 | 972 |
973 /* in case we have color symbols */ | |
974 color_symbols = extract_xpm_color_names (device, domain, | |
975 color_symbol_alist, &nsymbols); | |
976 | |
977 /* convert to an eimage to make processing easier */ | |
978 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height, | |
979 &x_hot, &y_hot, &transp, color_symbols, nsymbols)) | |
980 { | |
563 | 981 signal_image_error ("XPM to EImage conversion failed", |
982 image_instance); | |
428 | 983 } |
434 | 984 |
428 | 985 if (color_symbols) |
986 { | |
987 while (nsymbols--) | |
988 { | |
1726 | 989 xfree (color_symbols[nsymbols].name, Ibyte *); |
428 | 990 } |
1726 | 991 xfree(color_symbols, struct color_symbol *); |
428 | 992 } |
434 | 993 |
428 | 994 /* build a bitmap from the eimage */ |
771 | 995 if (!(bmp_info = convert_EImage_to_DIBitmap (device, width, height, eimage, |
428 | 996 &bmp_bits, &bmp_data))) |
997 { | |
563 | 998 signal_image_error ("XPM to EImage conversion failed", |
999 image_instance); | |
428 | 1000 } |
2367 | 1001 xfree (eimage, Binbyte *); |
428 | 1002 |
1003 /* Now create the pixmap and set up the image instance */ | |
1004 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, | |
1005 bmp_data, bmp_bits, 1, instantiator, | |
1006 x_hot, y_hot, transp); | |
1007 | |
1726 | 1008 xfree (bmp_info, BITMAPINFO *); |
2367 | 1009 xfree (bmp_data, Binbyte *); |
428 | 1010 } |
1011 #endif /* HAVE_XPM */ | |
1012 | |
1013 /********************************************************************** | |
1014 * BMP * | |
1015 **********************************************************************/ | |
1016 | |
1017 static void | |
1018 bmp_validate (Lisp_Object instantiator) | |
1019 { | |
1020 file_or_data_must_be_present (instantiator); | |
1021 } | |
1022 | |
1023 static Lisp_Object | |
442 | 1024 bmp_normalize (Lisp_Object inst, Lisp_Object console_type, |
2286 | 1025 Lisp_Object UNUSED (dest_mask)) |
428 | 1026 { |
1027 return simple_image_type_normalize (inst, console_type, Qbmp); | |
1028 } | |
1029 | |
1030 static int | |
1031 bmp_possible_dest_types (void) | |
1032 { | |
1033 return IMAGE_COLOR_PIXMAP_MASK; | |
1034 } | |
1035 | |
1036 static void | |
1037 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | |
2286 | 1038 Lisp_Object UNUSED (pointer_fg), |
1039 Lisp_Object UNUSED (pointer_bg), | |
1040 int dest_mask, Lisp_Object UNUSED (domain)) | |
428 | 1041 { |
440 | 1042 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
428 | 1043 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
442 | 1044 const Extbyte *bytes; |
665 | 1045 Bytecount len; |
771 | 1046 BITMAPFILEHEADER * bmp_file_header; |
1047 BITMAPINFO * bmp_info; | |
1048 void * bmp_data; | |
428 | 1049 int bmp_bits; |
1050 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | |
1051 | |
442 | 1052 CHECK_MSGDI_DEVICE (device); |
428 | 1053 |
1054 assert (!NILP (data)); | |
1055 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1056 LISP_STRING_TO_SIZED_EXTERNAL (data, bytes, len, Qbinary); |
434 | 1057 |
428 | 1058 /* Then slurp the image into memory, decoding along the way. |
1059 The result is the image in a simple one-byte-per-pixel | |
1060 format. */ | |
434 | 1061 |
771 | 1062 bmp_file_header = (BITMAPFILEHEADER *)bytes; |
1063 bmp_info = (BITMAPINFO *)(bytes + sizeof(BITMAPFILEHEADER)); | |
1064 bmp_data = (Extbyte *)bytes + bmp_file_header->bfOffBits; | |
428 | 1065 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits; |
1066 | |
1067 /* Now create the pixmap and set up the image instance */ | |
1068 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, | |
1069 bmp_data, bmp_bits, 1, instantiator, | |
1070 0, 0, 0); | |
1071 } | |
1072 | |
1073 | |
1074 /********************************************************************** | |
1075 * RESOURCES * | |
1076 **********************************************************************/ | |
1077 | |
1078 static void | |
1079 mswindows_resource_validate (Lisp_Object instantiator) | |
1080 { | |
563 | 1081 shared_resource_validate (instantiator); |
428 | 1082 } |
1083 | |
1084 static Lisp_Object | |
442 | 1085 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type, |
1086 Lisp_Object dest_mask) | |
428 | 1087 { |
563 | 1088 return shared_resource_normalize (inst, console_type, dest_mask, |
1089 Qmswindows_resource); | |
428 | 1090 } |
1091 | |
1092 static int | |
1093 mswindows_resource_possible_dest_types (void) | |
1094 { | |
1095 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK; | |
1096 } | |
1097 | |
434 | 1098 typedef struct |
428 | 1099 { |
4932 | 1100 const Ascbyte *name; |
428 | 1101 int resource_id; |
1102 } resource_t; | |
1103 | |
442 | 1104 static const resource_t bitmap_table[] = |
428 | 1105 { |
1106 /* bitmaps */ | |
1107 { "close", OBM_CLOSE }, | |
1108 { "uparrow", OBM_UPARROW }, | |
1109 { "dnarrow", OBM_DNARROW }, | |
1110 { "rgarrow", OBM_RGARROW }, | |
1111 { "lfarrow", OBM_LFARROW }, | |
1112 { "reduce", OBM_REDUCE }, | |
1113 { "zoom", OBM_ZOOM }, | |
1114 { "restore", OBM_RESTORE }, | |
1115 { "reduced", OBM_REDUCED }, | |
1116 { "zoomd", OBM_ZOOMD }, | |
1117 { "restored", OBM_RESTORED }, | |
1118 { "uparrowd", OBM_UPARROWD }, | |
1119 { "dnarrowd", OBM_DNARROWD }, | |
1120 { "rgarrowd", OBM_RGARROWD }, | |
1121 { "lfarrowd", OBM_LFARROWD }, | |
1122 { "mnarrow", OBM_MNARROW }, | |
1123 { "combo", OBM_COMBO }, | |
1124 { "uparrowi", OBM_UPARROWI }, | |
1125 { "dnarrowi", OBM_DNARROWI }, | |
1126 { "rgarrowi", OBM_RGARROWI }, | |
1127 { "lfarrowi", OBM_LFARROWI }, | |
1128 { "size", OBM_SIZE }, | |
1129 { "btsize", OBM_BTSIZE }, | |
1130 { "check", OBM_CHECK }, | |
1131 { "checkboxes", OBM_CHECKBOXES }, | |
1132 { "btncorners" , OBM_BTNCORNERS }, | |
1133 {0} | |
1134 }; | |
1135 | |
442 | 1136 static const resource_t cursor_table[] = |
428 | 1137 { |
1138 /* cursors */ | |
1139 { "normal", OCR_NORMAL }, | |
1140 { "ibeam", OCR_IBEAM }, | |
1141 { "wait", OCR_WAIT }, | |
1142 { "cross", OCR_CROSS }, | |
1143 { "up", OCR_UP }, | |
1144 /* { "icon", OCR_ICON }, */ | |
1145 { "sizenwse", OCR_SIZENWSE }, | |
1146 { "sizenesw", OCR_SIZENESW }, | |
1147 { "sizewe", OCR_SIZEWE }, | |
1148 { "sizens", OCR_SIZENS }, | |
1149 { "sizeall", OCR_SIZEALL }, | |
1150 /* { "icour", OCR_ICOCUR }, */ | |
1151 { "no", OCR_NO }, | |
1152 { 0 } | |
1153 }; | |
1154 | |
442 | 1155 static const resource_t icon_table[] = |
428 | 1156 { |
1157 /* icons */ | |
1158 { "sample", OIC_SAMPLE }, | |
1159 { "hand", OIC_HAND }, | |
1160 { "ques", OIC_QUES }, | |
1161 { "bang", OIC_BANG }, | |
1162 { "note", OIC_NOTE }, | |
1163 { "winlogo", OIC_WINLOGO }, | |
1164 {0} | |
1165 }; | |
1166 | |
771 | 1167 static int |
1168 resource_name_to_resource (Lisp_Object name, int type) | |
428 | 1169 { |
771 | 1170 const resource_t *res = (type == IMAGE_CURSOR ? cursor_table |
434 | 1171 : type == IMAGE_ICON ? icon_table |
428 | 1172 : bitmap_table); |
1173 | |
1174 if (INTP (name)) | |
771 | 1175 return XINT (name); |
1176 else if (!STRINGP (name)) | |
1177 invalid_argument ("invalid resource identifier", name); | |
1178 | |
1179 do | |
428 | 1180 { |
867 | 1181 if (!qxestrcasecmp_i18n ((Ibyte *) res->name, XSTRING_DATA (name))) |
771 | 1182 return res->resource_id; |
428 | 1183 } |
771 | 1184 while ((++res)->name); |
428 | 1185 return 0; |
1186 } | |
1187 | |
1188 static int | |
1189 resource_symbol_to_type (Lisp_Object data) | |
1190 { | |
1191 if (EQ (data, Qcursor)) | |
1192 return IMAGE_CURSOR; | |
1193 else if (EQ (data, Qicon)) | |
1194 return IMAGE_ICON; | |
1195 else if (EQ (data, Qbitmap)) | |
1196 return IMAGE_BITMAP; | |
1197 else | |
1198 return 0; | |
1199 } | |
1200 | |
1201 static void | |
502 | 1202 mswindows_resource_instantiate (Lisp_Object image_instance, |
1203 Lisp_Object instantiator, | |
2286 | 1204 Lisp_Object UNUSED (pointer_fg), |
1205 Lisp_Object UNUSED (pointer_bg), | |
1206 int dest_mask, Lisp_Object UNUSED (domain)) | |
428 | 1207 { |
440 | 1208 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
647 | 1209 int type = 0; |
428 | 1210 HANDLE himage = NULL; |
771 | 1211 Extbyte *resid = 0; |
428 | 1212 HINSTANCE hinst = NULL; |
1213 ICONINFO iconinfo; | |
442 | 1214 enum image_instance_type iitype; |
428 | 1215 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1216 | |
1217 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); | |
434 | 1218 Lisp_Object resource_type = find_keyword_in_vector (instantiator, |
428 | 1219 Q_resource_type); |
434 | 1220 Lisp_Object resource_id = find_keyword_in_vector (instantiator, |
428 | 1221 Q_resource_id); |
1222 | |
1223 xzero (iconinfo); | |
1224 | |
442 | 1225 CHECK_MSGDI_DEVICE (device); |
428 | 1226 |
1227 type = resource_symbol_to_type (resource_type); | |
1228 | |
1229 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR) | |
1230 iitype = IMAGE_POINTER; | |
1231 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) | |
1232 iitype = IMAGE_COLOR_PIXMAP; | |
434 | 1233 else |
428 | 1234 incompatible_image_types (instantiator, dest_mask, |
1235 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); | |
1236 | |
1237 /* mess with the keyword info we were provided with */ | |
1238 if (!NILP (file)) | |
1239 { | |
771 | 1240 Extbyte *fname; |
1241 | |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
2959
diff
changeset
|
1242 LISP_LOCAL_FILE_FORMAT_TO_TSTR (file, fname); |
434 | 1243 |
428 | 1244 if (NILP (resource_id)) |
771 | 1245 resid = fname; |
428 | 1246 else |
1247 { | |
771 | 1248 hinst = qxeLoadLibraryEx (fname, NULL, LOAD_LIBRARY_AS_DATAFILE); |
428 | 1249 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
771 | 1250 type)); |
434 | 1251 |
428 | 1252 if (!resid) |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1253 resid = LISP_STRING_TO_TSTR (resource_id); |
428 | 1254 } |
1255 } | |
1256 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | |
771 | 1257 type)))) |
563 | 1258 invalid_argument ("Invalid resource identifier", resource_id); |
434 | 1259 |
428 | 1260 /* load the image */ |
771 | 1261 if (!(himage = qxeLoadImage (hinst, resid, type, 0, 0, |
1262 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | | |
1263 LR_SHARED | | |
1264 (!NILP (file) ? LR_LOADFROMFILE : 0)))) | |
1265 signal_image_error ("Cannot load image", instantiator); | |
428 | 1266 |
1267 if (hinst) | |
1268 FreeLibrary (hinst); | |
1269 | |
1270 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype); | |
1271 | |
1272 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file; | |
442 | 1273 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = |
428 | 1274 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON); |
442 | 1275 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = |
428 | 1276 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON); |
1277 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; | |
442 | 1278 init_image_instance_geometry (ii); |
428 | 1279 |
1280 /* hey, we've got an icon type thing so we can reverse engineer the | |
1281 bitmap and mask */ | |
1282 if (type != IMAGE_BITMAP) | |
1283 { | |
442 | 1284 GetIconInfo ((HICON)himage, &iconinfo); |
428 | 1285 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor; |
1286 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask; | |
793 | 1287 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (iconinfo.xHotspot); |
1288 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (iconinfo.yHotspot); | |
442 | 1289 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = (HICON) himage; |
428 | 1290 } |
1291 else | |
1292 { | |
1293 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL; | |
442 | 1294 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = (HBITMAP) himage; |
428 | 1295 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; |
793 | 1296 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (0); |
1297 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (0); | |
428 | 1298 } |
1299 } | |
1300 | |
1301 static void | |
1302 check_valid_resource_symbol (Lisp_Object data) | |
1303 { | |
1304 CHECK_SYMBOL (data); | |
1305 if (!resource_symbol_to_type (data)) | |
563 | 1306 invalid_constant ("invalid resource type", data); |
428 | 1307 } |
1308 | |
1309 static void | |
1310 check_valid_resource_id (Lisp_Object data) | |
1311 { | |
1312 if (!resource_name_to_resource (data, IMAGE_CURSOR) | |
1313 && | |
1314 !resource_name_to_resource (data, IMAGE_ICON) | |
1315 && | |
1316 !resource_name_to_resource (data, IMAGE_BITMAP)) | |
563 | 1317 invalid_constant ("invalid resource identifier", data); |
428 | 1318 } |
1319 | |
771 | 1320 |
428 | 1321 /********************************************************************** |
1322 * XBM * | |
1323 **********************************************************************/ | |
771 | 1324 |
428 | 1325 /* this table flips four bits around. */ |
1326 static int flip_table[] = | |
1327 { | |
1328 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 | |
1329 }; | |
1330 | |
1331 /* the bitmap data comes in the following format: Widths are padded to | |
1332 a multiple of 8. Scan lines are stored in increasing byte order | |
1333 from left to right, little-endian within a byte. 0 = white, 1 = | |
1334 black. It must be converted to the following format: Widths are | |
1335 padded to a multiple of 16. Scan lines are stored in increasing | |
1336 byte order from left to right, big-endian within a byte. 0 = | |
1337 black, 1 = white. */ | |
438 | 1338 static HBITMAP |
2367 | 1339 xbm_create_bitmap_from_data (HDC hdc, const Binbyte *data, |
647 | 1340 int width, int height, |
428 | 1341 int mask, COLORREF fg, COLORREF bg) |
1342 { | |
1343 int old_width = (width + 7)/8; | |
771 | 1344 int new_width = BPLINE (2 * ((width + 15)/16)); |
2367 | 1345 const Binbyte *offset; |
428 | 1346 void *bmp_buf = 0; |
2367 | 1347 Binbyte *new_data, *new_offset; |
428 | 1348 int i, j; |
442 | 1349 BITMAPINFO *bmp_info = |
771 | 1350 (BITMAPINFO *) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); |
428 | 1351 HBITMAP bitmap; |
1352 | |
1353 if (!bmp_info) | |
1354 return NULL; | |
434 | 1355 |
2367 | 1356 new_data = xnew_array_and_zero (Binbyte, height * new_width); |
434 | 1357 |
428 | 1358 if (!new_data) |
1359 { | |
1726 | 1360 xfree (bmp_info, BITMAPINFO *); |
428 | 1361 return NULL; |
1362 } | |
434 | 1363 |
771 | 1364 for (i = 0; i < height; i++) |
428 | 1365 { |
771 | 1366 offset = data + i * old_width; |
1367 new_offset = new_data + i * new_width; | |
1368 | |
1369 for (j = 0; j < old_width; j++) | |
428 | 1370 { |
771 | 1371 int bite = offset[j]; |
2367 | 1372 new_offset[j] = ~ (Binbyte) |
771 | 1373 ((flip_table[bite & 0xf] << 4) + flip_table[bite >> 4]); |
428 | 1374 } |
1375 } | |
1376 | |
1377 /* if we want a mask invert the bits */ | |
1378 if (!mask) | |
1379 { | |
1380 new_offset = &new_data[height * new_width]; | |
1381 while (new_offset-- != new_data) | |
1382 { | |
1383 *new_offset ^= 0xff; | |
1384 } | |
1385 } | |
1386 | |
771 | 1387 bmp_info->bmiHeader.biWidth = width; |
428 | 1388 bmp_info->bmiHeader.biHeight=-(LONG)height; |
771 | 1389 bmp_info->bmiHeader.biPlanes = 1; |
1390 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
1391 bmp_info->bmiHeader.biBitCount = 1; | |
1392 bmp_info->bmiHeader.biCompression = BI_RGB; | |
434 | 1393 bmp_info->bmiHeader.biClrUsed = 2; |
1394 bmp_info->bmiHeader.biClrImportant = 2; | |
1395 bmp_info->bmiHeader.biSizeImage = height * new_width; | |
428 | 1396 bmp_info->bmiColors[0].rgbRed = GetRValue (fg); |
1397 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg); | |
1398 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg); | |
1399 bmp_info->bmiColors[0].rgbReserved = 0; | |
1400 bmp_info->bmiColors[1].rgbRed = GetRValue (bg); | |
1401 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg); | |
1402 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg); | |
1403 bmp_info->bmiColors[1].rgbReserved = 0; | |
434 | 1404 |
1405 bitmap = CreateDIBSection (hdc, | |
428 | 1406 bmp_info, |
1407 DIB_RGB_COLORS, | |
434 | 1408 &bmp_buf, |
428 | 1409 0,0); |
1410 | |
1726 | 1411 xfree (bmp_info, BITMAPINFO *); |
434 | 1412 |
428 | 1413 if (!bitmap || !bmp_buf) |
1414 { | |
2367 | 1415 xfree (new_data, Binbyte *); |
428 | 1416 return NULL; |
1417 } | |
434 | 1418 |
428 | 1419 /* copy in the actual bitmap */ |
1420 memcpy (bmp_buf, new_data, height * new_width); | |
2367 | 1421 xfree (new_data, Binbyte *); |
428 | 1422 |
1423 return bitmap; | |
1424 } | |
1425 | |
1426 /* Given inline data for a mono pixmap, initialize the given | |
1427 image instance accordingly. */ | |
1428 | |
1429 static void | |
440 | 1430 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii, |
428 | 1431 int width, int height, |
2367 | 1432 const Binbyte *bits, |
428 | 1433 Lisp_Object instantiator, |
1434 Lisp_Object pointer_fg, | |
1435 Lisp_Object pointer_bg, | |
1436 int dest_mask, | |
1437 HBITMAP mask, | |
2286 | 1438 Lisp_Object UNUSED (mask_filename)) |
428 | 1439 { |
1440 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | |
1441 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground); | |
1442 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background); | |
1443 enum image_instance_type type; | |
1444 COLORREF black = PALETTERGB (0,0,0); | |
1445 COLORREF white = PALETTERGB (255,255,255); | |
442 | 1446 HDC hdc; |
1447 | |
1448 CHECK_MSGDI_DEVICE (device); | |
1449 | |
1450 hdc = get_device_compdc (XDEVICE (device)); | |
428 | 1451 |
1452 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) && | |
1453 (dest_mask & IMAGE_COLOR_PIXMAP_MASK)) | |
1454 { | |
1455 if (!NILP (foreground) || !NILP (background)) | |
1456 type = IMAGE_COLOR_PIXMAP; | |
1457 else | |
1458 type = IMAGE_MONO_PIXMAP; | |
1459 } | |
1460 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK) | |
1461 type = IMAGE_MONO_PIXMAP; | |
1462 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) | |
1463 type = IMAGE_COLOR_PIXMAP; | |
1464 else if (dest_mask & IMAGE_POINTER_MASK) | |
1465 type = IMAGE_POINTER; | |
1466 else | |
1467 incompatible_image_types (instantiator, dest_mask, | |
1468 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK | |
1469 | IMAGE_POINTER_MASK); | |
1470 | |
1471 mswindows_initialize_dibitmap_image_instance (ii, 1, type); | |
434 | 1472 |
428 | 1473 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = |
1474 find_keyword_in_vector (instantiator, Q_file); | |
442 | 1475 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = width; |
1476 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = height; | |
428 | 1477 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; |
793 | 1478 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (0); |
1479 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (0); | |
442 | 1480 init_image_instance_geometry (ii); |
1481 | |
428 | 1482 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask : |
593 | 1483 xbm_create_bitmap_from_data (hdc, bits, width, height, TRUE, black, white); |
428 | 1484 |
1485 switch (type) | |
1486 { | |
1487 case IMAGE_MONO_PIXMAP: | |
434 | 1488 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = |
593 | 1489 xbm_create_bitmap_from_data (hdc, bits, width, height, |
428 | 1490 FALSE, black, black); |
1491 break; | |
1492 | |
1493 case IMAGE_COLOR_PIXMAP: | |
1494 { | |
1495 COLORREF fg = black; | |
1496 COLORREF bg = white; | |
1497 | |
1498 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground)) | |
1499 foreground = | |
1500 Fmake_color_instance (foreground, device, | |
1501 encode_error_behavior_flag (ERROR_ME)); | |
1502 | |
1503 if (COLOR_INSTANCEP (foreground)) | |
1504 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground)); | |
1505 | |
1506 if (!NILP (background) && !COLOR_INSTANCEP (background)) | |
1507 background = | |
1508 Fmake_color_instance (background, device, | |
1509 encode_error_behavior_flag (ERROR_ME)); | |
1510 | |
1511 if (COLOR_INSTANCEP (background)) | |
1512 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); | |
1513 | |
1514 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; | |
1515 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; | |
1516 | |
434 | 1517 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = |
593 | 1518 xbm_create_bitmap_from_data (hdc, bits, width, height, |
428 | 1519 FALSE, fg, black); |
1520 } | |
1521 break; | |
1522 | |
1523 case IMAGE_POINTER: | |
1524 { | |
1525 COLORREF fg = black; | |
1526 COLORREF bg = white; | |
1527 | |
1528 if (NILP (foreground)) | |
1529 foreground = pointer_fg; | |
1530 if (NILP (background)) | |
1531 background = pointer_bg; | |
1532 | |
434 | 1533 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = |
428 | 1534 find_keyword_in_vector (instantiator, Q_hotspot_x); |
434 | 1535 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = |
428 | 1536 find_keyword_in_vector (instantiator, Q_hotspot_y); |
1537 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; | |
1538 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; | |
1539 if (COLOR_INSTANCEP (foreground)) | |
1540 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground)); | |
1541 if (COLOR_INSTANCEP (background)) | |
1542 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); | |
1543 | |
434 | 1544 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = |
593 | 1545 xbm_create_bitmap_from_data (hdc, bits, width, height, |
428 | 1546 TRUE, fg, black); |
1547 mswindows_initialize_image_instance_icon (ii, TRUE); | |
1548 } | |
1549 break; | |
1550 | |
1551 default: | |
2500 | 1552 ABORT (); |
428 | 1553 } |
1554 } | |
1555 | |
1556 static void | |
1557 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, | |
1558 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
1559 int dest_mask, int width, int height, | |
2367 | 1560 const Binbyte *bits) |
428 | 1561 { |
1562 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); | |
1563 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); | |
440 | 1564 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
442 | 1565 HDC hdc = get_device_compdc (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))); |
428 | 1566 HBITMAP mask = 0; |
1567 | |
1568 if (!NILP (mask_data)) | |
1569 { | |
2367 | 1570 Binbyte *ext_data; |
440 | 1571 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1572 ext_data = |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1573 (Binbyte *) LISP_STRING_TO_EXTERNAL (XCAR (XCDR (XCDR (mask_data))), |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1574 Qbinary); |
440 | 1575 mask = xbm_create_bitmap_from_data (hdc, |
593 | 1576 ext_data, |
440 | 1577 XINT (XCAR (mask_data)), |
1578 XINT (XCAR (XCDR (mask_data))), | |
1579 FALSE, | |
1580 PALETTERGB (0,0,0), | |
1581 PALETTERGB (255,255,255)); | |
428 | 1582 } |
1583 | |
1584 init_image_instance_from_xbm_inline (ii, width, height, bits, | |
1585 instantiator, pointer_fg, pointer_bg, | |
1586 dest_mask, mask, mask_file); | |
1587 } | |
1588 | |
1589 /* Instantiate method for XBM's. */ | |
1590 | |
1591 static void | |
434 | 1592 mswindows_xbm_instantiate (Lisp_Object image_instance, |
428 | 1593 Lisp_Object instantiator, |
1594 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
2286 | 1595 int dest_mask, Lisp_Object UNUSED (domain)) |
428 | 1596 { |
1597 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | |
2367 | 1598 const Binbyte *ext_data; |
428 | 1599 |
1600 assert (!NILP (data)); | |
1601 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1602 ext_data = |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1603 (const Binbyte *) LISP_STRING_TO_EXTERNAL (XCAR (XCDR (XCDR (data))), |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1604 Qbinary); |
428 | 1605 |
1606 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, | |
1607 pointer_bg, dest_mask, XINT (XCAR (data)), | |
440 | 1608 XINT (XCAR (XCDR (data))), ext_data); |
428 | 1609 } |
1610 | |
1611 #ifdef HAVE_XFACE | |
1612 /********************************************************************** | |
1613 * X-Face * | |
1614 **********************************************************************/ | |
1615 #if defined(EXTERN) | |
1616 /* This is about to get redefined! */ | |
1617 #undef EXTERN | |
1618 #endif | |
1619 /* We have to define SYSV32 so that compface.h includes string.h | |
1620 instead of strings.h. */ | |
1621 #define SYSV32 | |
1743 | 1622 BEGIN_C_DECLS |
2500 | 1623 #ifndef __STDC__ /* Needed to avoid prototype warnings */ |
1624 #define __STDC__ | |
1625 #endif | |
428 | 1626 #include <compface.h> |
1743 | 1627 END_C_DECLS |
1628 | |
428 | 1629 /* JMP_BUF cannot be used here because if it doesn't get defined |
1630 to jmp_buf we end up with a conflicting type error with the | |
1631 definition in compface.h */ | |
1632 extern jmp_buf comp_env; | |
1633 #undef SYSV32 | |
1634 | |
1635 static void | |
502 | 1636 mswindows_xface_instantiate (Lisp_Object image_instance, |
1637 Lisp_Object instantiator, | |
428 | 1638 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2286 | 1639 int dest_mask, Lisp_Object UNUSED (domain)) |
428 | 1640 { |
1641 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | |
1642 int i, stattis; | |
2367 | 1643 Binbyte *p, *bits, *bp; |
867 | 1644 const CIbyte * volatile emsg = 0; |
2367 | 1645 const Binbyte * volatile dstring; |
428 | 1646 |
1647 assert (!NILP (data)); | |
1648 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1649 dstring = (const Binbyte *) LISP_STRING_TO_EXTERNAL (data, Qbinary); |
428 | 1650 |
2367 | 1651 if ((p = (Binbyte *) strchr ((char *) dstring, ':'))) |
428 | 1652 { |
1653 dstring = p + 1; | |
1654 } | |
1655 | |
1656 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */ | |
1657 if (!(stattis = setjmp (comp_env))) | |
1658 { | |
1659 UnCompAll ((char *) dstring); | |
1660 UnGenFace (); | |
1661 } | |
1662 | |
1663 switch (stattis) | |
1664 { | |
1665 case -2: | |
1666 emsg = "uncompface: internal error"; | |
1667 break; | |
1668 case -1: | |
1669 emsg = "uncompface: insufficient or invalid data"; | |
1670 break; | |
1671 case 1: | |
1672 emsg = "uncompface: excess data ignored"; | |
1673 break; | |
1674 } | |
1675 | |
1676 if (emsg) | |
563 | 1677 signal_image_error_2 (emsg, data, Qimage); |
428 | 1678 |
2367 | 1679 bp = bits = alloca_binbytes (PIXELS / 8); |
428 | 1680 |
1681 /* the compface library exports char F[], which uses a single byte per | |
1682 pixel to represent a 48x48 bitmap. Yuck. */ | |
2367 | 1683 for (i = 0, p = (Binbyte *) F; i < (PIXELS / 8); ++i) |
428 | 1684 { |
1685 int n, b; | |
1686 /* reverse the bit order of each byte... */ | |
1687 for (b = n = 0; b < 8; ++b) | |
1688 { | |
1689 n |= ((*p++) << b); | |
1690 } | |
2367 | 1691 *bp++ = (Binbyte) n; |
428 | 1692 } |
1693 | |
1694 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, | |
1695 pointer_bg, dest_mask, 48, 48, bits); | |
1696 } | |
1697 #endif /* HAVE_XFACE */ | |
1698 | |
1699 | |
1700 /************************************************************************/ | |
1701 /* image instance methods */ | |
1702 /************************************************************************/ | |
1703 | |
1704 static void | |
440 | 1705 mswindows_print_image_instance (Lisp_Image_Instance *p, |
428 | 1706 Lisp_Object printcharfun, |
2286 | 1707 int UNUSED (escapeflag)) |
428 | 1708 { |
1709 switch (IMAGE_INSTANCE_TYPE (p)) | |
1710 { | |
1711 case IMAGE_MONO_PIXMAP: | |
1712 case IMAGE_COLOR_PIXMAP: | |
1713 case IMAGE_POINTER: | |
800 | 1714 write_fmt_string (printcharfun, " (0x%lx", |
1715 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); | |
428 | 1716 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) |
1717 { | |
800 | 1718 write_fmt_string (printcharfun, "/0x%lx", |
1719 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p)); | |
428 | 1720 } |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1721 write_ascstring (printcharfun, ")"); |
428 | 1722 break; |
1723 | |
1724 default: | |
1725 break; | |
1726 } | |
1727 } | |
1728 | |
1729 #ifdef DEBUG_WIDGETS | |
1730 extern int debug_widget_instances; | |
1731 #endif | |
1732 | |
1733 static void | |
611 | 1734 finalize_destroy_window (void *win) |
1735 { | |
1736 DestroyWindow ((HWND) win); | |
1737 } | |
1738 | |
1739 static void | |
440 | 1740 mswindows_finalize_image_instance (Lisp_Image_Instance *p) |
428 | 1741 { |
442 | 1742 if (!p->data) |
1743 return; | |
1744 | |
1745 if (DEVICE_LIVE_P (XDEVICE (IMAGE_INSTANCE_DEVICE (p)))) | |
428 | 1746 { |
442 | 1747 if (image_instance_type_to_mask (IMAGE_INSTANCE_TYPE (p)) |
1748 & (IMAGE_WIDGET_MASK | IMAGE_SUBWINDOW_MASK)) | |
428 | 1749 { |
1750 #ifdef DEBUG_WIDGETS | |
1751 debug_widget_instances--; | |
1752 stderr_out ("widget destroyed, %d left\n", debug_widget_instances); | |
1753 #endif | |
1754 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) | |
1755 { | |
611 | 1756 /* DestroyWindow is not safe here, as it will send messages |
1757 to our window proc. */ | |
1758 register_post_gc_action | |
1759 (finalize_destroy_window, | |
1760 (void *) (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p))); | |
1761 register_post_gc_action | |
1762 (finalize_destroy_window, | |
1763 (void *) (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p))); | |
428 | 1764 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0; |
1765 } | |
1766 } | |
1767 else if (p->data) | |
1768 { | |
1769 int i; | |
1770 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p)) | |
1771 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p)); | |
1772 | |
1773 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p)) | |
1774 { | |
1775 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++) | |
1776 { | |
1777 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i)) | |
1778 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i)); | |
1779 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i) = 0; | |
1780 } | |
1726 | 1781 xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p), HBITMAP *); |
428 | 1782 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p) = 0; |
1783 } | |
1784 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) | |
1785 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p)); | |
1786 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0; | |
1787 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p)) | |
1788 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p)); | |
1789 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0; | |
1790 } | |
1791 } | |
1792 | |
1793 if (p->data) | |
1794 { | |
1726 | 1795 xfree (p->data, void *); |
428 | 1796 p->data = 0; |
1797 } | |
1798 } | |
1799 | |
1800 /************************************************************************/ | |
771 | 1801 /* subwindow and widget support */ |
428 | 1802 /************************************************************************/ |
1803 | |
771 | 1804 static Lisp_Object |
2333 | 1805 charset_of_text (Lisp_Object USED_IF_MULE (text)) |
771 | 1806 { |
1807 #ifdef MULE | |
867 | 1808 Ibyte *p; |
771 | 1809 |
1810 if (NILP (text)) | |
1811 return Vcharset_ascii; | |
1812 for (p = XSTRING_DATA (text); *p;) | |
1813 { | |
867 | 1814 Ichar c = itext_ichar (p); |
1815 if (!EQ (ichar_charset (c), Vcharset_ascii)) | |
1816 return ichar_charset (c); | |
1817 INC_IBYTEPTR (p); | |
771 | 1818 } |
1819 #endif /* MULE */ | |
1820 | |
1821 return Vcharset_ascii; | |
1822 } | |
1823 | |
1824 | |
440 | 1825 static HFONT |
771 | 1826 mswindows_widget_hfont (Lisp_Object face, |
1827 Lisp_Object domain, | |
1828 Lisp_Object text) | |
440 | 1829 { |
1830 int under = FACE_UNDERLINE_P (face, domain); | |
1831 int strike = FACE_STRIKETHRU_P (face, domain); | |
771 | 1832 Lisp_Object font; |
1833 struct face_cachel frame_cachel; | |
1834 struct face_cachel *cachel; | |
1835 Lisp_Object charset; | |
1836 | |
1837 reset_face_cachel (&frame_cachel); | |
1838 update_face_cachel_data (&frame_cachel, domain, face); | |
1839 cachel = &frame_cachel; | |
1840 /* !!#### This is a big hack. We return the first non-ASCII charset in | |
1841 the string, on the assumption that we can display ASCII characters in | |
1842 all fonts. We really need to draw the text of the widget ourselves; | |
1843 or perhaps there are fonts supporting lots of character sets? */ | |
1844 charset = charset_of_text (text); | |
1845 | |
1846 font = FACE_CACHEL_FONT (cachel, charset); | |
1847 | |
1848 if (!FONT_INSTANCEP (font)) | |
1849 font = ensure_face_cachel_contains_charset (cachel, domain, charset); | |
1850 | |
1851 if (EQ (font, Vthe_null_font_instance)) | |
1852 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii); | |
440 | 1853 |
1854 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); | |
1855 } | |
1856 | |
872 | 1857 #ifdef DEFER_WINDOW_POS |
1858 | |
442 | 1859 static HDWP |
1860 begin_defer_window_pos (struct frame *f) | |
1861 { | |
1862 if (FRAME_MSWINDOWS_DATA (f)->hdwp == 0) | |
1863 FRAME_MSWINDOWS_DATA (f)->hdwp = BeginDeferWindowPos (10); | |
1864 return FRAME_MSWINDOWS_DATA (f)->hdwp; | |
1865 } | |
1866 | |
872 | 1867 #endif |
1868 | |
428 | 1869 /* unmap the image if it is a widget. This is used by redisplay via |
1870 redisplay_unmap_subwindows */ | |
1871 static void | |
440 | 1872 mswindows_unmap_subwindow (Lisp_Image_Instance *p) |
428 | 1873 { |
1874 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) | |
1875 { | |
442 | 1876 #ifdef DEFER_WINDOW_POS |
1877 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); | |
1878 HDWP hdwp = begin_defer_window_pos (f); | |
1879 HDWP new_hdwp; | |
1880 new_hdwp = DeferWindowPos (hdwp, IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
1881 NULL, | |
1882 0, 0, 0, 0, | |
1883 SWP_HIDEWINDOW | SWP_NOACTIVATE | | |
1884 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | |
1885 /* Setting this flag causes the call to | |
1886 DeferWindowPos to fail with | |
1887 "Invalid parameter". I don't understand | |
1888 why we bother to try and set this | |
1889 anyway. -- ben */ | |
1890 /* | SWP_NOSENDCHANGING */ | |
1891 ); | |
1892 if (!new_hdwp) | |
1893 mswindows_output_last_error ("unmapping"); | |
1894 else | |
1895 hdwp = new_hdwp; | |
1896 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp; | |
1897 #else | |
434 | 1898 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), |
1899 NULL, | |
428 | 1900 0, 0, 0, 0, |
442 | 1901 SWP_HIDEWINDOW | SWP_NOACTIVATE | |
1902 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER ); | |
1903 #endif | |
440 | 1904 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)) |
1905 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p))); | |
428 | 1906 } |
1907 } | |
1908 | |
1909 /* map the subwindow. This is used by redisplay via | |
1910 redisplay_output_subwindow */ | |
1911 static void | |
440 | 1912 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y, |
771 | 1913 struct display_glyph_area *dga) |
428 | 1914 { |
442 | 1915 #ifdef DEFER_WINDOW_POS |
1916 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); | |
1917 HDWP hdwp = begin_defer_window_pos (f); | |
1918 HDWP new_hdwp; | |
1919 #endif | |
428 | 1920 /* move the window before mapping it ... */ |
1921 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
434 | 1922 NULL, |
428 | 1923 x, y, dga->width, dga->height, |
434 | 1924 SWP_NOZORDER |
428 | 1925 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); |
1926 /* ... adjust the child ... */ | |
1927 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | |
434 | 1928 NULL, |
428 | 1929 -dga->xoffset, -dga->yoffset, 0, 0, |
1930 SWP_NOZORDER | SWP_NOSIZE | |
1931 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); | |
1932 /* ... now map it - we are not allowed to move it at the same time. */ | |
442 | 1933 if (!IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (p)) |
1934 { | |
1935 #ifdef DEFER_WINDOW_POS | |
1936 new_hdwp = DeferWindowPos | |
1937 (hdwp, | |
1938 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
1939 NULL, 0, 0, 0, 0, | |
1940 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | |
1941 | SWP_SHOWWINDOW | |
1942 /* | SWP_NOCOPYBITS */ | |
1943 /* Setting this flag causes the call to | |
1944 DeferWindowPos to fail with | |
1945 "Invalid parameter". I don't understand | |
1946 why we bother to try and set this | |
1947 anyway. -- ben */ | |
1948 /* | SWP_NOSENDCHANGING */ | |
1949 | SWP_NOACTIVATE); | |
1950 if (!new_hdwp) | |
1951 mswindows_output_last_error ("mapping"); | |
1952 else | |
1953 hdwp = new_hdwp; | |
1954 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp; | |
1955 #else | |
1956 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
1957 NULL, | |
1958 0, 0, 0, 0, | |
1959 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | |
1960 | SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOACTIVATE); | |
863 | 1961 |
1962 /* Doing this once does not seem to be enough, for instance when | |
1963 mapping the search dialog this gets called four times. If we | |
1964 only set on the first time through then the subwindow never | |
1965 gets focus as intended. However, doing this everytime doesn't | |
1966 seem so bad, after all we only need to redo this after the | |
1967 focus changes - and if that happens resetting the initial | |
1968 focus doesn't seem so bad. */ | |
1969 if (IMAGE_INSTANCE_WANTS_INITIAL_FOCUS (p)) | |
1970 SetFocus (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)); | |
442 | 1971 #endif |
1972 } | |
428 | 1973 } |
1974 | |
1975 /* resize the subwindow instance */ | |
434 | 1976 static void |
771 | 1977 mswindows_resize_subwindow (Lisp_Image_Instance *ii, int w, int h) |
428 | 1978 { |
1979 /* Set the size of the control .... */ | |
442 | 1980 if (!SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
1981 NULL, | |
1982 0, 0, w, h, | |
1983 SWP_NOZORDER | SWP_NOMOVE | |
1984 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING)) | |
1985 mswindows_output_last_error ("resizing"); | |
1986 } | |
1987 | |
1988 /* Simply resize the window here. */ | |
1989 static void | |
1990 mswindows_redisplay_subwindow (Lisp_Image_Instance *p) | |
1991 { | |
1992 mswindows_resize_subwindow (p, | |
1993 IMAGE_INSTANCE_WIDTH (p), | |
1994 IMAGE_INSTANCE_HEIGHT (p)); | |
428 | 1995 } |
1996 | |
1997 /* when you click on a widget you may activate another widget this | |
1998 needs to be checked and all appropriate widgets updated */ | |
1999 static void | |
442 | 2000 mswindows_redisplay_widget (Lisp_Image_Instance *p) |
428 | 2001 { |
442 | 2002 /* Possibly update the face font and colors. */ |
2003 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (p)) | |
2004 && (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p) | |
2005 || XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed | |
2006 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))) | |
428 | 2007 { |
2008 /* set the widget font from the widget face */ | |
771 | 2009 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2010 WM_SETFONT, | |
2011 (WPARAM) mswindows_widget_hfont | |
2012 (IMAGE_INSTANCE_WIDGET_FACE (p), | |
2013 IMAGE_INSTANCE_FRAME (p), | |
2014 IMAGE_INSTANCE_WIDGET_TEXT (p)), | |
2015 MAKELPARAM (TRUE, 0)); | |
428 | 2016 } |
442 | 2017 /* Possibly update the dimensions. */ |
2018 if (IMAGE_INSTANCE_SIZE_CHANGED (p)) | |
2019 { | |
2020 mswindows_resize_subwindow (p, | |
2021 IMAGE_INSTANCE_WIDTH (p), | |
2022 IMAGE_INSTANCE_HEIGHT (p)); | |
2023 } | |
2024 /* Possibly update the text in the widget. */ | |
2025 if (IMAGE_INSTANCE_TEXT_CHANGED (p) | |
2026 && !NILP (IMAGE_INSTANCE_WIDGET_TEXT (p))) | |
2027 { | |
771 | 2028 Extbyte *lparam = 0; |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2029 lparam = LISP_STRING_TO_TSTR (IMAGE_INSTANCE_WIDGET_TEXT (p)); |
771 | 2030 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2031 WM_SETTEXT, 0, (LPARAM) lparam); | |
442 | 2032 } |
454 | 2033 /* Set active state. */ |
2034 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) | |
2035 { | |
2036 Lisp_Object item = IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p); | |
771 | 2037 LONG style = qxeGetWindowLong |
454 | 2038 (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2039 GWL_STYLE); | |
2040 | |
2041 if (CONSP (item)) | |
2042 item = XCAR (item); | |
2043 | |
1913 | 2044 if (gui_item_active_p (item)) |
771 | 2045 qxeSetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2046 GWL_STYLE, style & ~WS_DISABLED); | |
454 | 2047 else |
771 | 2048 qxeSetWindowLong (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2049 GWL_STYLE, style | WS_DISABLED); | |
454 | 2050 } |
428 | 2051 } |
2052 | |
771 | 2053 #ifdef HAVE_WIDGETS |
2054 | |
863 | 2055 /* Account for some of the limitations with widget images. */ |
2056 static int | |
2057 mswindows_widget_border_width (void) | |
2058 { | |
2059 return DEFAULT_WIDGET_BORDER_WIDTH; | |
2060 } | |
2061 | |
442 | 2062 /* register widgets into our hashtable so that we can cope with the |
428 | 2063 callbacks. The hashtable is weak so deregistration is handled |
2064 automatically */ | |
2065 static int | |
442 | 2066 mswindows_register_gui_item (Lisp_Object image_instance, |
2067 Lisp_Object gui, Lisp_Object domain) | |
428 | 2068 { |
442 | 2069 Lisp_Object frame = DOMAIN_FRAME (domain); |
771 | 2070 struct frame *f = XFRAME (frame); |
442 | 2071 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), |
428 | 2072 gui, |
2073 WIDGET_GLYPH_SLOT); | |
442 | 2074 Fputhash (make_int (id), image_instance, |
2075 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f)); | |
2076 Fputhash (make_int (id), XGUI_ITEM (gui)->callback, | |
2077 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f)); | |
2078 Fputhash (make_int (id), XGUI_ITEM (gui)->callback_ex, | |
2079 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f)); | |
428 | 2080 return id; |
2081 } | |
2082 | |
2083 static int | |
2084 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain) | |
2085 { | |
442 | 2086 return mswindows_register_gui_item (instance, |
2087 XIMAGE_INSTANCE_WIDGET_ITEM (instance), | |
428 | 2088 domain); |
2089 } | |
2090 | |
2091 static void | |
502 | 2092 mswindows_subwindow_instantiate (Lisp_Object image_instance, |
2286 | 2093 Lisp_Object UNUSED (instantiator), |
2094 Lisp_Object UNUSED (pointer_fg), | |
2095 Lisp_Object UNUSED (pointer_bg), | |
2096 int UNUSED (dest_mask), Lisp_Object domain) | |
428 | 2097 { |
440 | 2098 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
428 | 2099 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
442 | 2100 Lisp_Object frame = DOMAIN_FRAME (domain); |
428 | 2101 HWND wnd; |
2102 | |
442 | 2103 CHECK_MSWINDOWS_DEVICE (device); |
428 | 2104 |
2105 /* have to set the type this late in case there is no device | |
2106 instantiation for a widget */ | |
2107 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; | |
2108 /* Allocate space for the clip window */ | |
2109 ii->data = xnew_and_zero (struct mswindows_subwindow_data); | |
2110 | |
2111 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) | |
771 | 2112 = qxeCreateWindowEx ( |
2113 0, /* EX flags */ | |
2114 XETEXT (XEMACS_CONTROL_CLASS), | |
2115 0, /* text */ | |
2116 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, | |
2117 0, /* starting x position */ | |
2118 0, /* starting y position */ | |
2119 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2120 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2121 /* parent window */ | |
2122 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
2123 NULL, /* No menu */ | |
2124 NULL, /* must be null for this class */ | |
2125 NULL)) == NULL) | |
563 | 2126 gui_error ("window creation failed with code", |
2127 make_int (GetLastError())); | |
428 | 2128 |
771 | 2129 wnd = qxeCreateWindow (XETEXT ("STATIC"), XETEXT (""), |
2130 WS_CHILD, | |
2131 0, /* starting x position */ | |
2132 0, /* starting y position */ | |
2133 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2134 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2135 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), | |
2136 0, | |
2137 (HINSTANCE) | |
2138 qxeGetWindowLong | |
2139 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
2140 GWL_HINSTANCE), | |
2141 NULL); | |
2142 | |
2143 qxeSetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | |
428 | 2144 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2145 } | |
2146 | |
771 | 2147 #endif /* HAVE_WIDGETS */ |
2148 | |
428 | 2149 static int |
440 | 2150 mswindows_image_instance_equal (Lisp_Image_Instance *p1, |
2286 | 2151 Lisp_Image_Instance *p2, int UNUSED (depth)) |
428 | 2152 { |
2153 switch (IMAGE_INSTANCE_TYPE (p1)) | |
2154 { | |
2155 case IMAGE_MONO_PIXMAP: | |
2156 case IMAGE_COLOR_PIXMAP: | |
2157 case IMAGE_POINTER: | |
434 | 2158 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1) |
428 | 2159 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2)) |
2160 return 0; | |
2161 break; | |
434 | 2162 |
428 | 2163 default: |
2164 break; | |
2165 } | |
2166 | |
2167 return 1; | |
2168 } | |
2169 | |
665 | 2170 static Hashcode |
2286 | 2171 mswindows_image_instance_hash (Lisp_Image_Instance *p, int UNUSED (depth)) |
428 | 2172 { |
2173 switch (IMAGE_INSTANCE_TYPE (p)) | |
2174 { | |
2175 case IMAGE_MONO_PIXMAP: | |
2176 case IMAGE_COLOR_PIXMAP: | |
2177 case IMAGE_POINTER: | |
665 | 2178 return (Hashcode) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p); |
434 | 2179 |
428 | 2180 default: |
2181 return 0; | |
2182 } | |
2183 } | |
2184 | |
2185 /* Set all the slots in an image instance structure to reasonable | |
2186 default values. This is used somewhere within an instantiate | |
2187 method. It is assumed that the device slot within the image | |
2188 instance is already set -- this is the case when instantiate | |
2189 methods are called. */ | |
2190 | |
2191 static void | |
440 | 2192 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, |
428 | 2193 int slices, |
2194 enum image_instance_type type) | |
2195 { | |
2196 ii->data = xnew_and_zero (struct mswindows_image_instance_data); | |
2197 IMAGE_INSTANCE_TYPE (ii) = type; | |
2198 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil; | |
2199 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil; | |
2200 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil; | |
2201 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil; | |
2202 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil; | |
2203 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil; | |
2204 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices; | |
434 | 2205 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (ii) = |
428 | 2206 xnew_array_and_zero (HBITMAP, slices); |
2207 } | |
2208 | |
2209 | |
2210 #ifdef HAVE_WIDGETS | |
2211 | |
2212 /************************************************************************/ | |
771 | 2213 /* widgets */ |
428 | 2214 /************************************************************************/ |
2215 static void | |
502 | 2216 mswindows_widget_instantiate (Lisp_Object image_instance, |
2286 | 2217 Lisp_Object UNUSED (instantiator), |
2218 Lisp_Object UNUSED (pointer_fg), | |
2219 Lisp_Object UNUSED (pointer_bg), | |
2220 int UNUSED (dest_mask), Lisp_Object domain, | |
1204 | 2221 const CIbyte *class_, int flags, int exflags) |
428 | 2222 { |
2223 /* this function can call lisp */ | |
440 | 2224 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
428 | 2225 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; |
442 | 2226 Lisp_Object frame = DOMAIN_FRAME (domain); |
771 | 2227 Extbyte *nm = 0; |
2228 Extbyte *classext; | |
428 | 2229 HWND wnd; |
2230 int id = 0xffff; | |
2231 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | |
771 | 2232 Lisp_Gui_Item *pgui = XGUI_ITEM (gui); |
428 | 2233 |
442 | 2234 CHECK_MSWINDOWS_DEVICE (device); |
428 | 2235 |
1913 | 2236 if (!gui_item_active_p (gui)) |
428 | 2237 flags |= WS_DISABLED; |
2238 | |
2239 style = pgui->style; | |
2240 | |
442 | 2241 if (!NILP (pgui->callback) || !NILP (pgui->callback_ex)) |
428 | 2242 { |
2243 id = mswindows_register_widget_instance (image_instance, domain); | |
2244 } | |
438 | 2245 |
428 | 2246 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2247 nm = LISP_STRING_TO_TSTR (IMAGE_INSTANCE_WIDGET_TEXT (ii)); |
428 | 2248 |
2249 /* allocate space for the clip window and then allocate the clip window */ | |
2250 ii->data = xnew_and_zero (struct mswindows_subwindow_data); | |
2251 | |
2252 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) | |
771 | 2253 = qxeCreateWindowEx (WS_EX_CONTROLPARENT, /* EX flags */ |
2254 XETEXT (XEMACS_CONTROL_CLASS), | |
2255 0, /* text */ | |
2256 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, | |
428 | 2257 0, /* starting x position */ |
2258 0, /* starting y position */ | |
2259 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2260 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2261 /* parent window */ | |
771 | 2262 DOMAIN_MSWINDOWS_HANDLE (domain), |
428 | 2263 (HMENU)id, /* No menu */ |
771 | 2264 NULL, /* must be null for this class */ |
428 | 2265 NULL)) == NULL) |
563 | 2266 gui_error ("window creation failed with code", |
2267 make_int (GetLastError())); | |
428 | 2268 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2269 classext = ITEXT_TO_TSTR (class_); |
771 | 2270 |
2271 if ((wnd = qxeCreateWindowEx (exflags /* | WS_EX_NOPARENTNOTIFY*/, | |
2272 classext, | |
2273 nm, | |
2274 flags | WS_CHILD | WS_VISIBLE, | |
2275 0, /* starting x position */ | |
2276 0, /* starting y position */ | |
2277 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2278 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2279 /* parent window */ | |
2280 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), | |
2281 (HMENU)id, /* No menu */ | |
2282 (HINSTANCE) | |
2283 qxeGetWindowLong | |
2284 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
2285 GWL_HINSTANCE), | |
2286 NULL)) == NULL) | |
2287 gui_error ("window creation failed with code", | |
2288 make_int (GetLastError())); | |
2289 | |
428 | 2290 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
771 | 2291 qxeSetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
428 | 2292 /* set the widget font from the widget face */ |
442 | 2293 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
771 | 2294 qxeSendMessage (wnd, WM_SETFONT, |
2295 (WPARAM) mswindows_widget_hfont | |
2296 (IMAGE_INSTANCE_WIDGET_FACE (ii), domain, | |
2297 IMAGE_INSTANCE_WIDGET_TEXT (ii)), | |
2298 MAKELPARAM (TRUE, 0)); | |
442 | 2299 } |
2300 | |
2301 /* Instantiate a native layout widget. */ | |
2302 static void | |
2303 mswindows_native_layout_instantiate (Lisp_Object image_instance, | |
2304 Lisp_Object instantiator, | |
502 | 2305 Lisp_Object pointer_fg, |
2306 Lisp_Object pointer_bg, | |
442 | 2307 int dest_mask, Lisp_Object domain) |
2308 { | |
2309 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2310 | |
2311 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
2312 pointer_bg, dest_mask, domain, "STATIC", | |
2313 /* Approximation to styles available with | |
2314 an XEmacs layout. */ | |
2315 (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii), | |
2316 Qetched_in) || | |
2317 EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii), | |
2318 Qetched_out) || | |
2319 GLYPHP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) | |
2320 ? SS_ETCHEDFRAME : SS_SUNKEN) | DS_CONTROL, | |
2321 0); | |
428 | 2322 } |
2323 | |
2324 /* Instantiate a button widget. Unfortunately instantiated widgets are | |
2325 particular to a frame since they need to have a parent. It's not | |
2326 like images where you just select the image into the context you | |
438 | 2327 want to display it in and BitBlt it. So image instances can have a |
428 | 2328 many-to-one relationship with things you see, whereas widgets can |
2329 only be one-to-one (i.e. per frame) */ | |
2330 static void | |
502 | 2331 mswindows_button_instantiate (Lisp_Object image_instance, |
2332 Lisp_Object instantiator, | |
428 | 2333 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2334 int dest_mask, Lisp_Object domain) | |
2335 { | |
442 | 2336 /* This function can call lisp */ |
440 | 2337 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
428 | 2338 HWND wnd; |
444 | 2339 int flags = WS_TABSTOP | BS_NOTIFY; |
2340 /* BS_NOTIFY #### is needed to get exotic feedback only. Since we | |
2341 seem to want nothing beyond BN_CLICK, the style is perhaps not | |
2342 necessary -- kkm */ | |
428 | 2343 Lisp_Object style; |
2344 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | |
771 | 2345 Lisp_Gui_Item *pgui = XGUI_ITEM (gui); |
428 | 2346 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); |
2347 | |
2348 if (!NILP (glyph)) | |
2349 { | |
2350 if (!IMAGE_INSTANCEP (glyph)) | |
2351 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1); | |
2352 | |
2353 if (IMAGE_INSTANCEP (glyph)) | |
434 | 2354 flags |= XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
428 | 2355 BS_BITMAP : BS_ICON; |
2356 } | |
2357 | |
2358 style = pgui->style; | |
2359 | |
438 | 2360 /* #### consider using the default face for radio and toggle |
2361 buttons. */ | |
428 | 2362 if (EQ (style, Qradio)) |
2363 { | |
2364 flags |= BS_RADIOBUTTON; | |
2365 } | |
2366 else if (EQ (style, Qtoggle)) | |
2367 { | |
2368 flags |= BS_AUTOCHECKBOX; | |
2369 } | |
2370 else | |
438 | 2371 { |
2372 flags |= BS_DEFPUSHBUTTON; | |
2373 } | |
428 | 2374 |
2375 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
771 | 2376 pointer_bg, dest_mask, domain, |
2377 "BUTTON", flags, 0); | |
428 | 2378 |
2379 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
2380 /* set the checked state */ | |
1913 | 2381 if (gui_item_selected_p (gui)) |
771 | 2382 qxeSendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); |
428 | 2383 else |
771 | 2384 qxeSendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); |
428 | 2385 /* add the image if one was given */ |
440 | 2386 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph) |
2387 && | |
2388 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph))) | |
428 | 2389 { |
771 | 2390 qxeSendMessage (wnd, BM_SETIMAGE, |
2391 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | |
2392 IMAGE_BITMAP : IMAGE_ICON), | |
2393 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | |
2394 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : | |
2395 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); | |
428 | 2396 } |
2397 } | |
2398 | |
442 | 2399 /* Update the state of a button. */ |
2400 static void | |
2401 mswindows_button_redisplay (Lisp_Object image_instance) | |
2402 { | |
2403 /* This function can GC if IN_REDISPLAY is false. */ | |
2404 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2405 | |
2406 /* buttons checked or otherwise */ | |
1913 | 2407 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii))) |
771 | 2408 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2409 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | |
442 | 2410 else |
771 | 2411 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2412 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | |
442 | 2413 } |
2414 | |
428 | 2415 /* instantiate an edit control */ |
2416 static void | |
502 | 2417 mswindows_edit_field_instantiate (Lisp_Object image_instance, |
2418 Lisp_Object instantiator, | |
2419 Lisp_Object pointer_fg, | |
2420 Lisp_Object pointer_bg, | |
2421 int dest_mask, Lisp_Object domain) | |
428 | 2422 { |
2423 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
434 | 2424 pointer_bg, dest_mask, domain, "EDIT", |
428 | 2425 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP |
438 | 2426 | WS_BORDER, WS_EX_CLIENTEDGE); |
428 | 2427 } |
2428 | |
2429 /* instantiate a progress gauge */ | |
2430 static void | |
502 | 2431 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, |
2432 Lisp_Object instantiator, | |
2433 Lisp_Object pointer_fg, | |
2434 Lisp_Object pointer_bg, | |
2435 int dest_mask, Lisp_Object domain) | |
428 | 2436 { |
2437 HWND wnd; | |
440 | 2438 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
442 | 2439 Lisp_Object val; |
428 | 2440 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
434 | 2441 pointer_bg, dest_mask, domain, PROGRESS_CLASS, |
438 | 2442 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); |
428 | 2443 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2444 /* set the colors */ | |
502 | 2445 #if 0 /* #### fix this */ |
771 | 2446 qxeSendMessage (wnd, PBM_SETBKCOLOR, 0, |
2447 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | |
2448 (XCOLOR_INSTANCE | |
2449 (FACE_BACKGROUND | |
2450 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | |
2451 XIMAGE_INSTANCE_FRAME (ii)))))); | |
2452 qxeSendMessage (wnd, PBM_SETBARCOLOR, 0, | |
2453 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | |
2454 (XCOLOR_INSTANCE | |
2455 (FACE_FOREGROUND | |
2456 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | |
2457 XIMAGE_INSTANCE_FRAME (ii)))))); | |
428 | 2458 #endif |
442 | 2459 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEMS (ii))->value; |
2460 CHECK_INT (val); | |
771 | 2461 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2462 PBM_SETPOS, (WPARAM)XINT (val), 0); | |
428 | 2463 } |
2464 | |
2465 /* instantiate a tree view widget */ | |
2466 static HTREEITEM add_tree_item (Lisp_Object image_instance, | |
2467 HWND wnd, HTREEITEM parent, Lisp_Object item, | |
2468 int children, Lisp_Object domain) | |
2469 { | |
2470 HTREEITEM ret; | |
771 | 2471 TV_INSERTSTRUCTW tvitem; |
428 | 2472 |
2473 tvitem.hParent = parent; | |
2474 tvitem.hInsertAfter = TVI_LAST; | |
2475 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN; | |
2476 tvitem.item.cChildren = children; | |
771 | 2477 |
428 | 2478 if (GUI_ITEMP (item)) |
2479 { | |
771 | 2480 tvitem.item.lParam = |
2481 mswindows_register_gui_item (image_instance, item, domain); | |
428 | 2482 tvitem.item.mask |= TVIF_PARAM; |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2483 tvitem.item.pszText = |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2484 (LPWSTR) LISP_STRING_TO_TSTR (XGUI_ITEM (item)->name); |
428 | 2485 } |
2486 else | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2487 tvitem.item.pszText = (LPWSTR) LISP_STRING_TO_TSTR (item); |
771 | 2488 |
2421 | 2489 tvitem.item.cchTextMax = qxetcslen ((Extbyte *) tvitem.item.pszText); |
771 | 2490 |
2491 if ((ret = (HTREEITEM) qxeSendMessage (wnd, TVM_INSERTITEM, | |
2492 0, (LPARAM) &tvitem)) == 0) | |
563 | 2493 gui_error ("error adding tree view entry", item); |
428 | 2494 |
2495 return ret; | |
2496 } | |
2497 | |
2498 static void add_tree_item_list (Lisp_Object image_instance, | |
2499 HWND wnd, HTREEITEM parent, Lisp_Object list, | |
2500 Lisp_Object domain) | |
2501 { | |
2502 Lisp_Object rest; | |
2503 | |
2504 /* get the first item */ | |
2505 parent = add_tree_item (image_instance, wnd, parent, XCAR (list), TRUE, domain); | |
2506 /* recursively add items to the tree view */ | |
2507 LIST_LOOP (rest, XCDR (list)) | |
2508 { | |
2509 if (LISTP (XCAR (rest))) | |
2510 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain); | |
2511 else | |
2512 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain); | |
2513 } | |
2514 } | |
2515 | |
2516 static void | |
502 | 2517 mswindows_tree_view_instantiate (Lisp_Object image_instance, |
2518 Lisp_Object instantiator, | |
2519 Lisp_Object pointer_fg, | |
2520 Lisp_Object pointer_bg, | |
2521 int dest_mask, Lisp_Object domain) | |
428 | 2522 { |
2523 Lisp_Object rest; | |
2524 HWND wnd; | |
2525 HTREEITEM parent; | |
440 | 2526 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
428 | 2527 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
434 | 2528 pointer_bg, dest_mask, domain, WC_TREEVIEW, |
428 | 2529 WS_TABSTOP | WS_BORDER | PBS_SMOOTH |
2530 | TVS_HASLINES | TVS_HASBUTTONS, | |
438 | 2531 WS_EX_CLIENTEDGE); |
428 | 2532 |
2533 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
434 | 2534 |
428 | 2535 /* define a root */ |
434 | 2536 parent = add_tree_item (image_instance, wnd, NULL, |
2537 XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)), | |
428 | 2538 TRUE, domain); |
434 | 2539 |
428 | 2540 /* recursively add items to the tree view */ |
2541 /* add items to the tab */ | |
2542 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | |
2543 { | |
2544 if (LISTP (XCAR (rest))) | |
2545 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain); | |
2546 else | |
2547 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain); | |
2548 } | |
2549 } | |
2550 | |
442 | 2551 /* Set the properties of a tree view. */ |
2552 static void | |
2553 mswindows_tree_view_redisplay (Lisp_Object image_instance) | |
2554 { | |
2555 /* This function can GC if IN_REDISPLAY is false. */ | |
2556 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2557 | |
2558 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) | |
2559 { | |
2560 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
2561 Lisp_Object rest; | |
2562 HTREEITEM parent; | |
2563 /* Delete previous items. */ | |
771 | 2564 qxeSendMessage (wnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); |
442 | 2565 /* define a root */ |
2566 parent = add_tree_item (image_instance, wnd, NULL, | |
2567 XCAR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)), | |
2568 TRUE, IMAGE_INSTANCE_DOMAIN (ii)); | |
2569 | |
2570 /* recursively add items to the tree view */ | |
2571 /* add items to the tab */ | |
2572 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))) | |
2573 { | |
2574 if (LISTP (XCAR (rest))) | |
2575 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), | |
2576 IMAGE_INSTANCE_DOMAIN (ii)); | |
2577 else | |
2578 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, | |
2579 IMAGE_INSTANCE_DOMAIN (ii)); | |
2580 } | |
2581 } | |
2582 } | |
2583 | |
428 | 2584 /* instantiate a tab control */ |
442 | 2585 static int |
2586 add_tab_item (Lisp_Object image_instance, | |
2587 HWND wnd, Lisp_Object item, | |
2588 Lisp_Object domain, int i) | |
428 | 2589 { |
771 | 2590 TC_ITEMW tcitem; |
442 | 2591 int ret = 0; |
428 | 2592 |
771 | 2593 tcitem.mask = TCIF_TEXT; |
434 | 2594 |
428 | 2595 if (GUI_ITEMP (item)) |
2596 { | |
771 | 2597 tcitem.lParam = |
2598 mswindows_register_gui_item (image_instance, item, domain); | |
2599 tcitem.mask |= TCIF_PARAM; | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2600 tcitem.pszText = (XELPTSTR) LISP_STRING_TO_TSTR (XGUI_ITEM (item)->name); |
428 | 2601 } |
2602 else | |
2603 { | |
2604 CHECK_STRING (item); | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2605 tcitem.pszText = (XELPTSTR) LISP_STRING_TO_TSTR (item); |
428 | 2606 } |
2607 | |
2421 | 2608 tcitem.cchTextMax = qxetcslen ((Extbyte *) tcitem.pszText); |
771 | 2609 |
2610 if ((ret = qxeSendMessage (wnd, TCM_INSERTITEM, i, (LPARAM) &tcitem)) < 0) | |
563 | 2611 gui_error ("error adding tab entry", item); |
428 | 2612 |
2613 return ret; | |
2614 } | |
2615 | |
2616 static void | |
502 | 2617 mswindows_tab_control_instantiate (Lisp_Object image_instance, |
2618 Lisp_Object instantiator, | |
2619 Lisp_Object pointer_fg, | |
2620 Lisp_Object pointer_bg, | |
2621 int dest_mask, Lisp_Object domain) | |
428 | 2622 { |
442 | 2623 /* This function can call lisp */ |
428 | 2624 Lisp_Object rest; |
2625 HWND wnd; | |
442 | 2626 int i = 0, selected = 0; |
440 | 2627 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
438 | 2628 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation); |
2629 unsigned int flags = WS_TABSTOP; | |
2630 | |
2631 if (EQ (orient, Qleft) || EQ (orient, Qright)) | |
2632 { | |
2633 flags |= TCS_VERTICAL | TCS_MULTILINE; | |
2634 } | |
2635 if (EQ (orient, Qright) || EQ (orient, Qbottom)) | |
2636 { | |
2637 flags |= TCS_BOTTOM; | |
2638 } | |
2639 | |
428 | 2640 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
434 | 2641 pointer_bg, dest_mask, domain, WC_TABCONTROL, |
428 | 2642 /* borders don't suit tabs so well */ |
438 | 2643 flags, 0); |
428 | 2644 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2645 /* add items to the tab */ | |
2646 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | |
2647 { | |
442 | 2648 int idx = add_tab_item (image_instance, wnd, XCAR (rest), domain, i); |
2649 assert (idx == i); | |
1913 | 2650 if (gui_item_selected_p (XCAR (rest))) |
442 | 2651 selected = i; |
438 | 2652 i++; |
428 | 2653 } |
771 | 2654 qxeSendMessage (wnd, TCM_SETCURSEL, selected, 0); |
428 | 2655 } |
2656 | |
442 | 2657 /* Set the properties of a tab control. */ |
2658 static void | |
2659 mswindows_tab_control_redisplay (Lisp_Object image_instance) | |
428 | 2660 { |
442 | 2661 /* This function can GC if IN_REDISPLAY is false. */ |
440 | 2662 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
442 | 2663 #ifdef DEBUG_WIDGET_OUTPUT |
1318 | 2664 stderr_out ("tab control %p redisplayed\n", |
2665 IMAGE_INSTANCE_SUBWINDOW_ID (ii)); | |
442 | 2666 #endif |
2667 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) | |
2668 || | |
2669 IMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (ii)) | |
428 | 2670 { |
2671 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
454 | 2672 int i = 0, selected_idx = 0; |
428 | 2673 Lisp_Object rest; |
442 | 2674 |
2675 assert (!NILP (IMAGE_INSTANCE_WIDGET_ITEMS (ii))); | |
2676 | |
2677 /* If only the order has changed then simply select the first | |
2678 one. This stops horrendous rebuilding of the tabs each time | |
2679 you click on one. */ | |
2680 if (tab_control_order_only_changed (image_instance)) | |
428 | 2681 { |
442 | 2682 Lisp_Object selected = |
2683 gui_item_list_find_selected | |
2684 (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)) ? | |
2685 XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)) : | |
2686 XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))); | |
2687 | |
2688 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | |
2689 { | |
1913 | 2690 if (gui_item_equal_sans_selected (XCAR (rest), selected, 0)) |
442 | 2691 { |
1318 | 2692 Lisp_Object old_selected = |
2693 gui_item_list_find_selected | |
442 | 2694 (XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))); |
2695 | |
2696 /* Pick up the new selected item. */ | |
2697 XGUI_ITEM (old_selected)->selected = | |
2698 XGUI_ITEM (XCAR (rest))->selected; | |
2699 XGUI_ITEM (XCAR (rest))->selected = | |
2700 XGUI_ITEM (selected)->selected; | |
2701 /* We're not actually changing the items. */ | |
2702 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 0; | |
2703 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil; | |
2704 | |
771 | 2705 qxeSendMessage (wnd, TCM_SETCURSEL, i, 0); |
442 | 2706 #ifdef DEBUG_WIDGET_OUTPUT |
2707 stderr_out ("tab control %p selected item %d\n", | |
1318 | 2708 IMAGE_INSTANCE_SUBWINDOW_ID (ii), i); |
442 | 2709 #endif |
2710 break; | |
2711 } | |
2712 i++; | |
2713 } | |
428 | 2714 } |
442 | 2715 else |
2716 { | |
2717 /* delete the pre-existing items */ | |
771 | 2718 qxeSendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); |
442 | 2719 |
2720 /* add items to the tab */ | |
2721 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))) | |
2722 { | |
2723 add_tab_item (image_instance, wnd, XCAR (rest), | |
2724 IMAGE_INSTANCE_FRAME (ii), i); | |
1913 | 2725 if (gui_item_selected_p (XCAR (rest))) |
454 | 2726 selected_idx = i; |
442 | 2727 i++; |
2728 } | |
771 | 2729 qxeSendMessage (wnd, TCM_SETCURSEL, selected_idx, 0); |
442 | 2730 } |
428 | 2731 } |
2732 } | |
2733 | |
2734 /* instantiate a static control possible for putting other things in */ | |
2735 static void | |
502 | 2736 mswindows_label_instantiate (Lisp_Object image_instance, |
2737 Lisp_Object instantiator, | |
428 | 2738 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2739 int dest_mask, Lisp_Object domain) | |
2740 { | |
2741 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
771 | 2742 pointer_bg, dest_mask, domain, |
2743 "STATIC", 0, WS_EX_STATICEDGE); | |
428 | 2744 } |
2745 | |
2746 /* instantiate a scrollbar control */ | |
2747 static void | |
502 | 2748 mswindows_scrollbar_instantiate (Lisp_Object image_instance, |
2749 Lisp_Object instantiator, | |
2750 Lisp_Object pointer_fg, | |
2751 Lisp_Object pointer_bg, | |
428 | 2752 int dest_mask, Lisp_Object domain) |
2753 { | |
2754 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
771 | 2755 pointer_bg, dest_mask, domain, |
2756 "SCROLLBAR", WS_TABSTOP, WS_EX_CLIENTEDGE); | |
428 | 2757 } |
2758 | |
2759 /* instantiate a combo control */ | |
2760 static void | |
502 | 2761 mswindows_combo_box_instantiate (Lisp_Object image_instance, |
2762 Lisp_Object instantiator, | |
2763 Lisp_Object pointer_fg, | |
2764 Lisp_Object pointer_bg, | |
2765 int dest_mask, Lisp_Object domain) | |
428 | 2766 { |
440 | 2767 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
442 | 2768 HWND wnd; |
428 | 2769 Lisp_Object rest; |
442 | 2770 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items); |
438 | 2771 int len, height; |
428 | 2772 |
2773 /* Maybe ought to generalise this more but it may be very windows | |
2774 specific. In windows the window height of a combo box is the | |
2775 height when the combo box is open. Thus we need to set the height | |
2776 before creating the window and then reset it to a single line | |
2777 after the window is created so that redisplay does the right | |
2778 thing. */ | |
438 | 2779 widget_instantiate (image_instance, instantiator, pointer_fg, |
2780 pointer_bg, dest_mask, domain); | |
2781 | |
2782 /* We now have everything right apart from the height. */ | |
2783 default_face_font_info (domain, 0, 0, &height, 0, 0); | |
442 | 2784 GET_LIST_LENGTH (items, len); |
438 | 2785 |
863 | 2786 height = (height + DEFAULT_WIDGET_BORDER_WIDTH * 2 ) * len; |
438 | 2787 IMAGE_INSTANCE_HEIGHT (ii) = height; |
440 | 2788 |
438 | 2789 /* Now create the widget. */ |
428 | 2790 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
771 | 2791 pointer_bg, dest_mask, domain, |
2792 "COMBOBOX", | |
428 | 2793 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN |
434 | 2794 | CBS_AUTOHSCROLL |
428 | 2795 | CBS_HASSTRINGS | WS_VSCROLL, |
438 | 2796 WS_EX_CLIENTEDGE); |
2797 /* Reset the height. layout will probably do this safely, but better make sure. */ | |
440 | 2798 image_instance_layout (image_instance, |
438 | 2799 IMAGE_UNSPECIFIED_GEOMETRY, |
2800 IMAGE_UNSPECIFIED_GEOMETRY, | |
442 | 2801 IMAGE_UNCHANGED_GEOMETRY, |
2802 IMAGE_UNCHANGED_GEOMETRY, | |
438 | 2803 domain); |
2804 | |
428 | 2805 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2806 /* add items to the combo box */ | |
771 | 2807 qxeSendMessage (wnd, CB_RESETCONTENT, 0, 0); |
442 | 2808 LIST_LOOP (rest, items) |
428 | 2809 { |
771 | 2810 Extbyte *lparam; |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2811 lparam = LISP_STRING_TO_TSTR (XCAR (rest)); |
771 | 2812 if (qxeSendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) |
563 | 2813 gui_error ("error adding combo entries", instantiator); |
428 | 2814 } |
2815 } | |
2816 | |
2817 /* get properties of a control */ | |
2818 static Lisp_Object | |
2819 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) | |
2820 { | |
440 | 2821 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
442 | 2822 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
428 | 2823 /* get the text from a control */ |
2824 if (EQ (prop, Q_text)) | |
2825 { | |
771 | 2826 Charcount tchar_len = qxeSendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); |
2367 | 2827 Extbyte *buf = alloca_extbytes (XETCHAR_SIZE * (tchar_len + 1)); |
771 | 2828 |
2829 qxeSendMessage (wnd, WM_GETTEXT, (WPARAM)tchar_len + 1, (LPARAM) buf); | |
2830 return build_tstr_string (buf); | |
428 | 2831 } |
2832 return Qunbound; | |
2833 } | |
2834 | |
2835 /* get properties of a button */ | |
2836 static Lisp_Object | |
2837 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) | |
2838 { | |
440 | 2839 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
442 | 2840 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
428 | 2841 /* check the state of a button */ |
2842 if (EQ (prop, Q_selected)) | |
2843 { | |
771 | 2844 if (qxeSendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) |
428 | 2845 return Qt; |
2846 else | |
2847 return Qnil; | |
2848 } | |
2849 return Qunbound; | |
2850 } | |
2851 | |
2852 /* get properties of a combo box */ | |
2853 static Lisp_Object | |
2854 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) | |
2855 { | |
440 | 2856 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
442 | 2857 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
428 | 2858 /* get the text from a control */ |
2859 if (EQ (prop, Q_text)) | |
2860 { | |
771 | 2861 long item = qxeSendMessage (wnd, CB_GETCURSEL, 0, 0); |
2862 Charcount tchar_len = qxeSendMessage (wnd, CB_GETLBTEXTLEN, | |
2863 (WPARAM)item, 0); | |
2367 | 2864 Extbyte *buf = alloca_extbytes (XETCHAR_SIZE * (tchar_len + 1)); |
771 | 2865 qxeSendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM) buf); |
2866 return build_tstr_string (buf); | |
428 | 2867 } |
2868 return Qunbound; | |
2869 } | |
2870 | |
442 | 2871 /* set the properties of a progress gauge */ |
2872 static void | |
2873 mswindows_progress_gauge_redisplay (Lisp_Object image_instance) | |
428 | 2874 { |
440 | 2875 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
428 | 2876 |
442 | 2877 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) |
428 | 2878 { |
442 | 2879 Lisp_Object val; |
2880 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value; | |
2881 #ifdef DEBUG_WIDGET_OUTPUT | |
2882 stderr_out ("progress gauge displayed value on %p updated to %ld\n", | |
2883 WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2884 XINT(val)); | |
2885 #endif | |
428 | 2886 CHECK_INT (val); |
771 | 2887 qxeSendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2888 PBM_SETPOS, (WPARAM)XINT (val), 0); | |
428 | 2889 } |
2890 } | |
2891 | |
2892 LRESULT WINAPI | |
438 | 2893 mswindows_control_wnd_proc (HWND hwnd, UINT msg, |
428 | 2894 WPARAM wParam, LPARAM lParam) |
2895 { | |
438 | 2896 switch (msg) |
428 | 2897 { |
2898 case WM_NOTIFY: | |
2899 case WM_COMMAND: | |
2900 case WM_CTLCOLORBTN: | |
2901 case WM_CTLCOLORLISTBOX: | |
2902 case WM_CTLCOLOREDIT: | |
2903 case WM_CTLCOLORSTATIC: | |
2904 case WM_CTLCOLORSCROLLBAR: | |
2905 | |
438 | 2906 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam); |
428 | 2907 default: |
771 | 2908 return qxeDefWindowProc (hwnd, msg, wParam, lParam); |
2909 } | |
2910 } | |
2911 | |
2912 static void | |
2913 mswindows_widget_query_string_geometry (Lisp_Object string, Lisp_Object face, | |
2914 int *width, int *height, | |
2915 Lisp_Object domain) | |
2916 { | |
2917 if (height) | |
2918 query_string_geometry (string, face, 0, height, 0, domain); | |
2919 | |
2920 if (width) | |
2921 { | |
2922 HDC hdc = FRAME_MSWINDOWS_DC (DOMAIN_XFRAME (domain)); | |
2923 Extbyte *str; | |
2924 Bytecount len; | |
2925 SIZE size; | |
2926 | |
2927 SelectObject (hdc, mswindows_widget_hfont (face, domain, string)); | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2928 LISP_STRING_TO_SIZED_EXTERNAL (string, str, len, Qmswindows_tstr); |
771 | 2929 qxeGetTextExtentPoint32 (hdc, str, len / XETCHAR_SIZE, &size); |
2930 *width = size.cx; | |
428 | 2931 } |
2932 } | |
2933 | |
2934 #endif /* HAVE_WIDGETS */ | |
2935 | |
2936 | |
2937 /************************************************************************/ | |
2938 /* initialization */ | |
2939 /************************************************************************/ | |
2940 | |
2941 void | |
2942 syms_of_glyphs_mswindows (void) | |
2943 { | |
2944 } | |
2945 | |
2946 void | |
2947 console_type_create_glyphs_mswindows (void) | |
2948 { | |
442 | 2949 /* image methods - display */ |
428 | 2950 CONSOLE_HAS_METHOD (mswindows, print_image_instance); |
2951 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance); | |
2952 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow); | |
2953 CONSOLE_HAS_METHOD (mswindows, map_subwindow); | |
442 | 2954 CONSOLE_HAS_METHOD (mswindows, redisplay_subwindow); |
2955 CONSOLE_HAS_METHOD (mswindows, resize_subwindow); | |
2956 CONSOLE_HAS_METHOD (mswindows, redisplay_widget); | |
428 | 2957 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); |
2958 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); | |
2959 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); | |
2960 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); | |
771 | 2961 #ifdef HAVE_WIDGETS |
2962 CONSOLE_HAS_METHOD (mswindows, widget_query_string_geometry); | |
863 | 2963 CONSOLE_HAS_METHOD (mswindows, widget_border_width); |
771 | 2964 #endif |
442 | 2965 |
2966 /* image methods - printer */ | |
2967 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance); | |
2968 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_image_instance); | |
2969 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_equal); | |
2970 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_hash); | |
771 | 2971 CONSOLE_INHERITS_METHOD (msprinter, mswindows, |
2972 init_image_instance_from_eimage); | |
442 | 2973 CONSOLE_INHERITS_METHOD (msprinter, mswindows, locate_pixmap_file); |
428 | 2974 } |
2975 | |
2976 void | |
2977 image_instantiator_format_create_glyphs_mswindows (void) | |
2978 { | |
442 | 2979 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, nothing); |
2980 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, string); | |
2981 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, formatted_string); | |
2982 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, inherit); | |
428 | 2983 /* image-instantiator types */ |
442 | 2984 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm); |
2985 INITIALIZE_DEVICE_IIFORMAT (msprinter, xbm); | |
2986 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate); | |
2987 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xbm, instantiate); | |
428 | 2988 #ifdef HAVE_XPM |
2989 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm); | |
442 | 2990 INITIALIZE_DEVICE_IIFORMAT (msprinter, xpm); |
428 | 2991 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate); |
442 | 2992 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xpm, instantiate); |
428 | 2993 #endif |
2994 #ifdef HAVE_XFACE | |
2995 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface); | |
442 | 2996 INITIALIZE_DEVICE_IIFORMAT (msprinter, xface); |
428 | 2997 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate); |
442 | 2998 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xface, instantiate); |
428 | 2999 #endif |
3000 #ifdef HAVE_JPEG | |
442 | 3001 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, jpeg); |
428 | 3002 #endif |
3003 #ifdef HAVE_TIFF | |
442 | 3004 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, tiff); |
434 | 3005 #endif |
428 | 3006 #ifdef HAVE_PNG |
442 | 3007 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, png); |
434 | 3008 #endif |
428 | 3009 #ifdef HAVE_GIF |
442 | 3010 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, gif); |
434 | 3011 #endif |
428 | 3012 #ifdef HAVE_WIDGETS |
442 | 3013 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget); |
3014 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property); | |
3015 /* layout widget */ | |
3016 IIFORMAT_VALID_CONSOLE (mswindows, layout); | |
3017 INITIALIZE_DEVICE_IIFORMAT (mswindows, native_layout); | |
3018 IIFORMAT_HAS_DEVMETHOD (mswindows, native_layout, instantiate); | |
428 | 3019 /* button widget */ |
3020 INITIALIZE_DEVICE_IIFORMAT (mswindows, button); | |
3021 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property); | |
3022 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate); | |
442 | 3023 IIFORMAT_HAS_DEVMETHOD (mswindows, button, redisplay); |
3024 /* edit-field widget */ | |
428 | 3025 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit_field); |
3026 IIFORMAT_HAS_DEVMETHOD (mswindows, edit_field, instantiate); | |
442 | 3027 /* subwindow */ |
428 | 3028 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow); |
3029 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate); | |
3030 /* label */ | |
3031 INITIALIZE_DEVICE_IIFORMAT (mswindows, label); | |
3032 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate); | |
3033 /* combo box */ | |
3034 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo_box); | |
3035 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, property); | |
3036 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, instantiate); | |
3037 /* scrollbar */ | |
3038 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar); | |
3039 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate); | |
3040 /* progress gauge */ | |
3041 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress_gauge); | |
442 | 3042 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, redisplay); |
428 | 3043 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, instantiate); |
3044 /* tree view widget */ | |
3045 INITIALIZE_DEVICE_IIFORMAT (mswindows, tree_view); | |
3046 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, instantiate); | |
442 | 3047 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, redisplay); |
428 | 3048 /* tab control widget */ |
3049 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control); | |
3050 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate); | |
442 | 3051 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, redisplay); |
428 | 3052 #endif |
3053 /* windows bitmap format */ | |
3054 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp"); | |
3055 IIFORMAT_HAS_METHOD (bmp, validate); | |
3056 IIFORMAT_HAS_METHOD (bmp, normalize); | |
3057 IIFORMAT_HAS_METHOD (bmp, possible_dest_types); | |
3058 IIFORMAT_HAS_METHOD (bmp, instantiate); | |
3059 | |
3060 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string); | |
3061 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string); | |
442 | 3062 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, bmp); |
428 | 3063 |
3064 /* mswindows resources */ | |
3065 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource, | |
3066 "mswindows-resource"); | |
3067 | |
3068 IIFORMAT_HAS_METHOD (mswindows_resource, validate); | |
3069 IIFORMAT_HAS_METHOD (mswindows_resource, normalize); | |
3070 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types); | |
3071 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate); | |
3072 | |
434 | 3073 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type, |
428 | 3074 check_valid_resource_symbol); |
3075 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id); | |
3076 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string); | |
442 | 3077 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, mswindows_resource); |
428 | 3078 } |
3079 | |
3080 void | |
3081 vars_of_glyphs_mswindows (void) | |
3082 { | |
3083 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /* | |
3084 A list of the directories in which mswindows bitmap files may be found. | |
3085 This is used by the `make-image-instance' function. | |
3086 */ ); | |
3087 Vmswindows_bitmap_file_path = Qnil; | |
3088 } | |
3089 | |
3090 void | |
3091 complex_vars_of_glyphs_mswindows (void) | |
3092 { | |
3093 } |