#include <dlgs.h>
#define FILE_NAME_TEXT_FIELD edt1
+void syms_of_w32fns ();
+void globals_of_w32fns ();
+
extern void free_frame_menubar ();
extern void x_compute_fringe_widths P_ ((struct frame *, int));
extern double atof ();
/* Window that is tracking the mouse. */
static HWND track_mouse_window;
-FARPROC track_mouse_event_fn;
+
+typedef BOOL (WINAPI * TrackMouseEvent_Proc) (
+ IN OUT LPTRACKMOUSEEVENT lpEventTrack
+ );
+
+TrackMouseEvent_Proc track_mouse_event_fn=NULL;
/* W95 mousewheel handler */
unsigned int msh_mousewheel = 0;
ended up with. */
return NULL;
- /* Specify anti-aliasing to prevent Cleartype fonts being used,
- since those fonts leave garbage behind. */
- lf.lfQuality = ANTIALIASED_QUALITY;
+ lf.lfQuality = DEFAULT_QUALITY;
font = (XFontStruct *) xmalloc (sizeof (XFontStruct));
bzero (font, sizeof (*font));
else
{
/* Handle image type independent image attributes
- `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF',
+ `:ascent ASCENT', `:margin MARGIN', `:relief RELIEF',
`:background COLOR'. */
Lisp_Object ascent, margin, relief, bg;
#undef expect_ident
}
+static void convert_mono_to_color_image (f, img, foreground, background)
+ struct frame *f;
+ struct image *img;
+ COLORREF foreground, background;
+{
+ HDC hdc, old_img_dc, new_img_dc;
+ HGDIOBJ old_prev, new_prev;
+ HBITMAP new_pixmap;
+
+ hdc = get_frame_dc (f);
+ old_img_dc = CreateCompatibleDC (hdc);
+ new_img_dc = CreateCompatibleDC (hdc);
+ new_pixmap = CreateCompatibleBitmap (hdc, img->width, img->height);
+ release_frame_dc (f, hdc);
+ old_prev = SelectObject (old_img_dc, img->pixmap);
+ new_prev = SelectObject (new_img_dc, new_pixmap);
+ SetTextColor (new_img_dc, foreground);
+ SetBkColor (new_img_dc, background);
+
+ BitBlt (new_img_dc, 0, 0, img->width, img->height, old_img_dc,
+ 0, 0, SRCCOPY);
+
+ SelectObject (old_img_dc, old_prev);
+ SelectObject (new_img_dc, new_prev);
+ DeleteDC (old_img_dc);
+ DeleteDC (new_img_dc);
+ DeleteObject (img->pixmap);
+ if (new_pixmap == 0)
+ fprintf (stderr, "Failed to convert image to color.\n");
+ else
+ img->pixmap = new_pixmap;
+}
/* Load XBM image IMG which will be displayed on frame F from buffer
CONTENTS. END is the end of the buffer. Value is non-zero if
{
unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
unsigned long background = FRAME_BACKGROUND_PIXEL (f);
+ int non_default_colors = 0;
Lisp_Object value;
xassert (img->width > 0 && img->height > 0);
/* Get foreground and background colors, maybe allocate colors. */
value = image_spec_value (img->spec, QCforeground, NULL);
if (!NILP (value))
- foreground = x_alloc_image_color (f, img, value, foreground);
+ {
+ foreground = x_alloc_image_color (f, img, value, foreground);
+ non_default_colors = 1;
+ }
value = image_spec_value (img->spec, QCbackground, NULL);
if (!NILP (value))
{
background = x_alloc_image_color (f, img, value, background);
img->background = background;
img->background_valid = 1;
+ non_default_colors = 1;
}
img->pixmap
= w32_create_pixmap_from_bitmap_data (img->width, img->height, data);
+ /* If colors were specified, transfer the bitmap to a color one. */
+ if (non_default_colors)
+ convert_mono_to_color_image (f, img, foreground, background);
+
xfree (data);
if (img->pixmap == 0)
Lisp_Object data;
unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
unsigned long background = FRAME_BACKGROUND_PIXEL (f);
+ int non_default_colors = 0;
char *bits;
int parsed_p;
int in_memory_file_p = 0;
/* Get foreground and background colors, maybe allocate colors. */
if (fmt[XBM_FOREGROUND].count
&& STRINGP (fmt[XBM_FOREGROUND].value))
- foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value,
- foreground);
+ {
+ foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value,
+ foreground);
+ non_default_colors = 1;
+ }
+
if (fmt[XBM_BACKGROUND].count
&& STRINGP (fmt[XBM_BACKGROUND].value))
- background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value,
- background);
+ {
+ background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value,
+ background);
+ non_default_colors = 1;
+ }
if (in_memory_file_p)
success_p = xbm_load_image (f, img, SDATA (data),
= w32_create_pixmap_from_bitmap_data (img->width, img->height,
bits);
+ /* If colors were specified, transfer the bitmap to a color one. */
+ if (non_default_colors)
+ convert_mono_to_color_image (f, img, foreground, background);
+
if (img->pixmap)
success_p = 1;
else
{":type", IMAGE_SYMBOL_VALUE, 1},
{":file", IMAGE_STRING_VALUE, 0},
{":data", IMAGE_STRING_VALUE, 0},
- {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
+ {":ascent", IMAGE_ASCENT_VALUE, 0},
{":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
{":relief", IMAGE_INTEGER_VALUE, 0},
{":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
/* Either no `:color-symbols' or it's a list of conses
whose car and cdr are strings. */
&& (fmt[XPM_COLOR_SYMBOLS].count == 0
- || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value))
- && (fmt[XPM_ASCENT].count == 0
- || XFASTINT (fmt[XPM_ASCENT].value) < 100));
+ || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value)));
}
rowbytes += 4 - (rowbytes % 4);
pixel = ximg->data + y * rowbytes + x * 3;
- *pixel = GetRValue (color);
+ /* Windows bitmaps are in BGR order. */
+ *pixel = GetBValue (color);
*(pixel + 1) = GetGValue (color);
- *(pixel + 2) = GetBValue (color);
+ *(pixel + 2) = GetRValue (color);
}
{
char color_name[30];
sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
- bg = x_alloc_image_color (f, img, build_string (color_name), 0);
+ bg = x_alloc_image_color (f, img, build_string (color_name), 0)
+ & 0x00ffffff; /* Filter out palette info. */
use_img_background = 0;
}
}
{":type", IMAGE_SYMBOL_VALUE, 1},
{":file", IMAGE_STRING_VALUE, 0},
{":data", IMAGE_STRING_VALUE, 0},
- {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
+ {":ascent", IMAGE_ASCENT_VALUE, 0},
{":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
{":relief", IMAGE_INTEGER_VALUE, 0},
{":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
bcopy (pbm_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)
- || (fmt[PBM_ASCENT].count
- && XFASTINT (fmt[PBM_ASCENT].value) > 100))
+ if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))
return 0;
/* Must specify either :data or :file. */
{":type", IMAGE_SYMBOL_VALUE, 1},
{":data", IMAGE_STRING_VALUE, 0},
{":file", IMAGE_STRING_VALUE, 0},
- {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
+ {":ascent", IMAGE_ASCENT_VALUE, 0},
{":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
{":relief", IMAGE_INTEGER_VALUE, 0},
{":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
struct image_keyword fmt[PNG_LAST];
bcopy (png_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)
- || (fmt[PNG_ASCENT].count
- && XFASTINT (fmt[PNG_ASCENT].value) > 100))
+ if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))
return 0;
/* Must specify either the :data or :file keyword. */
{":type", IMAGE_SYMBOL_VALUE, 1},
{":data", IMAGE_STRING_VALUE, 0},
{":file", IMAGE_STRING_VALUE, 0},
- {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
+ {":ascent", IMAGE_ASCENT_VALUE, 0},
{":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
{":relief", IMAGE_INTEGER_VALUE, 0},
{":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
bcopy (jpeg_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)
- || (fmt[JPEG_ASCENT].count
- && XFASTINT (fmt[JPEG_ASCENT].value) > 100))
+ if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))
return 0;
/* Must specify either the :data or :file keyword. */
{":type", IMAGE_SYMBOL_VALUE, 1},
{":data", IMAGE_STRING_VALUE, 0},
{":file", IMAGE_STRING_VALUE, 0},
- {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
+ {":ascent", IMAGE_ASCENT_VALUE, 0},
{":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
{":relief", IMAGE_INTEGER_VALUE, 0},
{":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
struct image_keyword fmt[TIFF_LAST];
bcopy (tiff_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)
- || (fmt[TIFF_ASCENT].count
- && XFASTINT (fmt[TIFF_ASCENT].value) > 100))
+ if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))
return 0;
/* Must specify either the :data or :file keyword. */
{":type", IMAGE_SYMBOL_VALUE, 1},
{":data", IMAGE_STRING_VALUE, 0},
{":file", IMAGE_STRING_VALUE, 0},
- {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
+ {":ascent", IMAGE_ASCENT_VALUE, 0},
{":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
{":relief", IMAGE_INTEGER_VALUE, 0},
{":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
struct image_keyword fmt[GIF_LAST];
bcopy (gif_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)
- || (fmt[GIF_ASCENT].count
- && XFASTINT (fmt[GIF_ASCENT].value) > 100))
+ if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))
return 0;
/* Must specify either the :data or :file keyword. */
{":file", IMAGE_STRING_VALUE, 1},
{":loader", IMAGE_FUNCTION_VALUE, 0},
{":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE, 1},
- {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
+ {":ascent", IMAGE_ASCENT_VALUE, 0},
{":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
{":relief", IMAGE_INTEGER_VALUE, 0},
{":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
bcopy (gs_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)
- || (fmt[GS_ASCENT].count
- && XFASTINT (fmt[GS_ASCENT].value) > 100))
+ if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))
return 0;
/* Bounding box must be a list or vector containing 4 integers. */
void
syms_of_w32fns ()
{
- HMODULE user32_lib = GetModuleHandle ("user32.dll");
-
- /* This is zero if not using MS-Windows. */
+ globals_of_w32fns ();
+ /* This is zero if not using MS-Windows. */
w32_in_use = 0;
-
- /* TrackMouseEvent not available in all versions of Windows, so must load
- it dynamically. Do it once, here, instead of every time it is used. */
- track_mouse_event_fn = GetProcAddress (user32_lib, "TrackMouseEvent");
track_mouse_window = NULL;
w32_visible_system_caret_hwnd = NULL;
init_x_parm_symbols ();
DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
- doc: /* List of directories to search for bitmap files for w32. */);
+ doc: /* List of directories to search for window system bitmap files. */);
Vx_bitmap_file_path = decode_env_path ((char *) 0, "PATH");
DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
defsubr (&Sx_file_dialog);
}
+
+/*
+ globals_of_w32fns is used to initialize those global variables that
+ must always be initialized on startup even when the global variable
+ initialized is non zero (see the function main in emacs.c).
+ globals_of_w32fns is called from syms_of_w32fns when the global
+ variable initialized is 0 and directly from main when initialized
+ is non zero.
+ */
+void globals_of_w32fns ()
+{
+ HMODULE user32_lib = GetModuleHandle ("user32.dll");
+ /*
+ TrackMouseEvent not available in all versions of Windows, so must load
+ it dynamically. Do it once, here, instead of every time it is used.
+ */
+ track_mouse_event_fn = (TrackMouseEvent_Proc) GetProcAddress (user32_lib, "TrackMouseEvent");
+}
+
void
init_xfns ()
{