(msh_mousewheel): Declare.
[bpt/emacs.git] / src / w32term.h
CommitLineData
de31b97a 1/* Definitions and headers for communication on the Microsoft W32 API.
c3b8ccce
GV
2 Copyright (C) 1995 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
3b7ad313
EN
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
c3b8ccce
GV
20
21/* Added by Kevin Gallo */
22
07bc5c0b 23#include <w32gui.h>
c3b8ccce
GV
24
25/* The class of this X application. */
26#define EMACS_CLASS "Emacs"
27\f
3fed86ff
GV
28#define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0)
29#define WHITE_PIX_DEFAULT(f) PALETTERGB(255,255,255)
c3b8ccce 30
9c35997b 31#define FONT_WIDTH(f) ((f)->tm.tmAveCharWidth)
c3b8ccce
GV
32#define FONT_HEIGHT(f) ((f)->tm.tmHeight)
33#define FONT_BASE(f) ((f)->tm.tmAscent)
34
fbd6baed 35#define CHECK_W32_FRAME(f, frame) \
c3b8ccce
GV
36 if (NILP (frame)) \
37 f = selected_frame; \
38 else \
39 { \
40 CHECK_LIVE_FRAME (frame, 0); \
41 f = XFRAME (frame); \
42 } \
fbd6baed 43 if (! FRAME_W32_P (f))
c3b8ccce
GV
44
45/* Indicates whether we are in the readsocket call and the message we
46 are processing in the current loop */
47
48extern MSG CurMsg;
49extern BOOL bUseDflt;
50
51extern struct frame *x_window_to_frame ();
52
53enum text_cursor_kinds {
54 filled_box_cursor, hollow_box_cursor, bar_cursor
55};
56
57/* This data type is used for the font_table field
fbd6baed 58 of struct w32_display_info. */
c3b8ccce
GV
59
60struct font_info
61{
62 XFontStruct *font;
63 char *name;
64};
65
66/* Structure recording bitmaps and reference count.
67 If REFCOUNT is 0 then this record is free to be reused. */
68
fbd6baed 69struct w32_bitmap_record
c3b8ccce
GV
70{
71 Pixmap pixmap;
72 char *file;
73 HINSTANCE hinst; /* Used to load the file */
74 int refcount;
75 /* Record some info about this pixmap. */
76 int height, width, depth;
77};
aba66c88
GV
78
79/* Palette book-keeping stuff for mapping requested colors into the
80 system palette. Keep a ref-counted list of requested colors and
81 regenerate the app palette whenever the requested list changes. */
82
fbd6baed 83extern Lisp_Object Vw32_enable_palette;
aba66c88 84
fbd6baed
GV
85struct w32_palette_entry {
86 struct w32_palette_entry * next;
aba66c88
GV
87 PALETTEENTRY entry;
88#if 0
89 unsigned refcount;
90#endif
91};
92
fbd6baed 93extern void w32_regenerate_palette(struct frame *f);
aba66c88 94
c3b8ccce 95\f
fbd6baed 96/* For each display (currently only one on w32), we have a structure that
c3b8ccce
GV
97 records information about it. */
98
fbd6baed 99struct w32_display_info
c3b8ccce 100{
fbd6baed
GV
101 /* Chain of all w32_display_info structures. */
102 struct w32_display_info *next;
c3b8ccce
GV
103 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
104 The same cons cell also appears in x_display_name_list. */
105 Lisp_Object name_list_element;
106 /* Number of frames that are on this display. */
107 int reference_count;
108 /* Number of planes on this screen. */
109 int n_planes;
110 /* Number of bits per pixel on this screen. */
111 int n_cbits;
112 /* Dimensions of this screen. */
113 int height, width;
114 int height_in,width_in;
115 /* Mask of things that cause the mouse to be grabbed. */
116 int grabbed;
117 /* The root window of this screen. */
118 Window root_window;
119 /* The cursor to use for vertical scroll bars. */
120 Cursor vertical_scroll_bar_cursor;
121
aba66c88
GV
122 /* color palette information */
123 int has_palette;
fbd6baed 124 struct w32_palette_entry * color_list;
aba66c88
GV
125 unsigned num_colors;
126 HPALETTE palette;
127
128 /* deferred action flags checked when starting frame update */
129 int regen_palette;
130
c3b8ccce
GV
131 /* A table of all the fonts we have already loaded. */
132 struct font_info *font_table;
133
134 /* The current capacity of x_font_table. */
135 int font_table_size;
136
137 /* These variables describe the range of text currently shown
138 in its mouse-face, together with the window they apply to.
139 As long as the mouse stays within this range, we need not
140 redraw anything on its account. */
141 int mouse_face_beg_row, mouse_face_beg_col;
142 int mouse_face_end_row, mouse_face_end_col;
143 int mouse_face_past_end;
144 Lisp_Object mouse_face_window;
145 int mouse_face_face_id;
146
147 /* 1 if a mouse motion event came and we didn't handle it right away because
148 gc was in progress. */
149 int mouse_face_deferred_gc;
150
151 /* FRAME and X, Y position of mouse when last checked for
152 highlighting. X and Y can be negative or out of range for the frame. */
153 struct frame *mouse_face_mouse_frame;
154 int mouse_face_mouse_x, mouse_face_mouse_y;
155
156 /* Nonzero means defer mouse-motion highlighting. */
157 int mouse_face_defer;
158
fbd6baed 159 char *w32_id_name;
c3b8ccce 160
fbd6baed 161 /* The number of fonts actually stored in w32_font_table.
c3b8ccce
GV
162 font_table[n] is used and valid iff 0 <= n < n_fonts.
163 0 <= n_fonts <= font_table_size. */
164 int n_fonts;
165
166 /* Pointer to bitmap records. */
fbd6baed 167 struct w32_bitmap_record *bitmaps;
c3b8ccce
GV
168
169 /* Allocated size of bitmaps field. */
170 int bitmaps_size;
171
172 /* Last used bitmap index. */
173 int bitmaps_last;
174
175 /* The frame (if any) which has the window that has keyboard focus.
176 Zero if none. This is examined by Ffocus_frame in w32fns.c. Note
177 that a mere EnterNotify event can set this; if you need to know the
178 last frame specified in a FocusIn or FocusOut event, use
fbd6baed
GV
179 w32_focus_event_frame. */
180 struct frame *w32_focus_frame;
c3b8ccce
GV
181
182 /* The last frame mentioned in a FocusIn or FocusOut event. This is
fbd6baed 183 separate from w32_focus_frame, because whether or not LeaveNotify
c3b8ccce
GV
184 events cause us to lose focus depends on whether or not we have
185 received a FocusIn event for it. */
fbd6baed 186 struct frame *w32_focus_event_frame;
c3b8ccce
GV
187
188 /* The frame which currently has the visual highlight, and should get
189 keyboard input (other sorts of input have the frame encoded in the
190 event). It points to the focus frame's selected window's
fbd6baed 191 frame. It differs from w32_focus_frame when we're using a global
c3b8ccce 192 minibuffer. */
fbd6baed 193 struct frame *w32_highlight_frame;
c3b8ccce
GV
194};
195
196/* This is a chain of structures for all the displays currently in use. */
fbd6baed 197extern struct w32_display_info one_w32_display_info;
c3b8ccce
GV
198
199/* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE),
fbd6baed 200 one for each element of w32_display_list and in the same order.
c3b8ccce
GV
201 NAME is the name of the frame.
202 FONT-LIST-CACHE records previous values returned by x-list-fonts. */
fbd6baed 203extern Lisp_Object w32_display_name_list;
c3b8ccce 204
fbd6baed
GV
205extern struct w32_display_info *x_display_info_for_display ();
206extern struct w32_display_info *x_display_info_for_name ();
c3b8ccce 207
fbd6baed 208extern struct w32_display_info *w32_term_init ();
c3b8ccce 209\f
fbd6baed
GV
210/* Each W32 frame object points to its own struct w32_display object
211 in the output_data.w32 field. The w32_display structure contains all
212 the information that is specific to W32 windows. */
c3b8ccce 213
fbd6baed 214struct w32_output
c3b8ccce 215{
8694f11b
GV
216 /* Menubar "widget" handle. */
217 HMENU menubar_widget;
218
aba66c88
GV
219 /* Original palette (used to deselect real palette after drawing) */
220 HPALETTE old_palette;
221
fbd6baed 222 /* Position of the W32 window (x and y offsets in root window). */
c3b8ccce
GV
223 int left_pos;
224 int top_pos;
225
fbd6baed 226 /* Border width of the W32 window as known by the window system. */
c3b8ccce
GV
227 int border_width;
228
fbd6baed 229 /* Size of the W32 window in pixels. */
c3b8ccce
GV
230 int pixel_height, pixel_width;
231
232 /* Height of a line, in pixels. */
233 int line_height;
234
235 /* Width of the internal border. This is a line of background color
236 just inside the window's border. When the frame is selected,
237 a highlighting is displayed inside the internal border. */
238 int internal_border_width;
239
240 /* The window used for this frame.
241 May be zero while the frame object is being created
242 and the window has not yet been created. */
243 Window window_desc;
244
245 /* The window that is the parent of this window.
246 Usually this is a window that was made by the window manager,
247 but it can be the root window, and it can be explicitly specified
248 (see the explicit_parent field, below). */
249 Window parent_desc;
250
251 XFontStruct *font;
252
253 /* Pixel values used for various purposes.
254 border_pixel may be -1 meaning use a gray tile. */
255 unsigned long background_pixel;
256 unsigned long foreground_pixel;
257 unsigned long cursor_pixel;
258 unsigned long border_pixel;
259 unsigned long mouse_pixel;
260 unsigned long cursor_foreground_pixel;
261
262 /* Descriptor for the cursor in use for this window. */
263 Cursor text_cursor;
264 Cursor nontext_cursor;
265 Cursor modeline_cursor;
266 Cursor cross_cursor;
267
268 /* Flag to set when the window needs to be completely repainted. */
269 int needs_exposure;
270
271 /* What kind of text cursor is drawn in this window right now?
272 (If there is no cursor (phys_cursor_x < 0), then this means nothing.) */
273 enum text_cursor_kinds current_cursor;
274
275 /* What kind of text cursor should we draw in the future?
276 This should always be filled_box_cursor or bar_cursor. */
277 enum text_cursor_kinds desired_cursor;
278
279 /* Width of bar cursor (if we are using that). */
280 int cursor_width;
281
282 DWORD dwStyle;
283
284 /* The size of the extra width currently allotted for vertical
285 scroll bars, in pixels. */
286 int vertical_scroll_bar_extra;
287
288 /* Table of parameter faces for this frame. Any resources (pixel
289 values, fonts) referred to here have been allocated explicitly
290 for this face, and should be freed if we change the face. */
291 struct face **param_faces;
292 int n_param_faces;
293
294 /* Table of computed faces for this frame. These are the faces
295 whose indexes go into the upper bits of a glyph, computed by
296 combining the parameter faces specified by overlays, text
297 properties, and what have you. The resources mentioned here
298 are all shared with parameter faces. */
299 struct face **computed_faces;
300 int n_computed_faces; /* How many are valid */
301 int size_computed_faces; /* How many are allocated */
302
303 /* This is the gravity value for the specified window position. */
304 int win_gravity;
305
306 /* The geometry flags for this window. */
307 int size_hint_flags;
308
309 /* This is the Emacs structure for the display this frame is on. */
fbd6baed 310 /* struct w32_display_info *display_info; */
c3b8ccce
GV
311
312 /* Nonzero means our parent is another application's window
313 and was explicitly specified. */
314 char explicit_parent;
315
316 /* Nonzero means tried already to make this frame visible. */
317 char asked_for_visible;
8694f11b
GV
318
319 /* Nonzero means menubar is currently active. */
320 char menubar_active;
321
322 /* Nonzero means menubar is about to become active, but should be
323 brought up to date first. */
324 volatile char pending_menu_activation;
c3b8ccce
GV
325};
326
327/* Get at the computed faces of an X window frame. */
fbd6baed
GV
328#define FRAME_PARAM_FACES(f) ((f)->output_data.w32->param_faces)
329#define FRAME_N_PARAM_FACES(f) ((f)->output_data.w32->n_param_faces)
c3b8ccce
GV
330#define FRAME_DEFAULT_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[0])
331#define FRAME_MODE_LINE_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[1])
332
fbd6baed
GV
333#define FRAME_COMPUTED_FACES(f) ((f)->output_data.w32->computed_faces)
334#define FRAME_N_COMPUTED_FACES(f) ((f)->output_data.w32->n_computed_faces)
335#define FRAME_SIZE_COMPUTED_FACES(f) ((f)->output_data.w32->size_computed_faces)
336#define FRAME_DEFAULT_FACE(f) ((f)->output_data.w32->computed_faces[0])
337#define FRAME_MODE_LINE_FACE(f) ((f)->output_data.w32->computed_faces[1])
c3b8ccce
GV
338
339/* Return the window associated with the frame F. */
fbd6baed 340#define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc)
c3b8ccce 341
fbd6baed
GV
342#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.w32->foreground_pixel)
343#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.w32->background_pixel)
344#define FRAME_FONT(f) ((f)->output_data.w32->font)
345#define FRAME_INTERNAL_BORDER_WIDTH(f) ((f)->output_data.w32->internal_border_width)
c3b8ccce 346
fbd6baed
GV
347/* This gives the w32_display_info structure for the display F is on. */
348#define FRAME_W32_DISPLAY_INFO(f) (&one_w32_display_info)
c3b8ccce
GV
349
350/* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}. */
fbd6baed
GV
351#define PIXEL_WIDTH(f) ((f)->output_data.w32->pixel_width)
352#define PIXEL_HEIGHT(f) ((f)->output_data.w32->pixel_height)
353#define FRAME_LINE_HEIGHT(f) ((f)->output_data.w32->line_height)
c3b8ccce 354
fbd6baed 355#define FRAME_DESIRED_CURSOR(f) ((f)->output_data.w32->desired_cursor)
c3b8ccce
GV
356
357\f
fbd6baed 358/* W32-specific scroll bar stuff. */
c3b8ccce
GV
359
360/* We represent scroll bars as lisp vectors. This allows us to place
361 references to them in windows without worrying about whether we'll
362 end up with windows referring to dead scroll bars; the garbage
363 collector will free it when its time comes.
364
365 We use struct scroll_bar as a template for accessing fields of the
366 vector. */
367
368struct scroll_bar {
369
370 /* These fields are shared by all vectors. */
371 EMACS_INT size_from_Lisp_Vector_struct;
372 struct Lisp_Vector *next_from_Lisp_Vector_struct;
373
374 /* The window we're a scroll bar for. */
375 Lisp_Object window;
376
377 /* The next and previous in the chain of scroll bars in this frame. */
378 Lisp_Object next, prev;
379
380 /* The window representing this scroll bar. Since this is a full
381 32-bit quantity, we store it split into two 32-bit values. */
fbd6baed 382 Lisp_Object w32_window_low, w32_window_high;
c3b8ccce
GV
383
384 /* The position and size of the scroll bar in pixels, relative to the
385 frame. */
386 Lisp_Object top, left, width, height;
387
388 /* The starting and ending positions of the handle, relative to the
389 handle area (i.e. zero is the top position, not
390 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
391 hasn't been drawn yet.
392
393 These are not actually the locations where the beginning and end
394 are drawn; in order to keep handles from becoming invisible when
395 editing large files, we establish a minimum height by always
396 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
397 where they would be normally; the bottom and top are in a
398 different co-ordinate system. */
399 Lisp_Object start, end;
400
401 /* If the scroll bar handle is currently being dragged by the user,
402 this is the number of pixels from the top of the handle to the
403 place where the user grabbed it. If the handle isn't currently
404 being dragged, this is Qnil. */
405 Lisp_Object dragging;
406};
407
408/* The number of elements a vector holding a struct scroll_bar needs. */
409#define SCROLL_BAR_VEC_SIZE \
410 ((sizeof (struct scroll_bar) \
411 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \
412 / sizeof (Lisp_Object))
413
414/* Turning a lisp vector value into a pointer to a struct scroll_bar. */
415#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
416
417
418/* Building a 32-bit C integer from two 16-bit lisp integers. */
419#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
420
421/* Setting two lisp integers to the low and high words of a 32-bit C int. */
422#define SCROLL_BAR_UNPACK(low, high, int32) \
423 (XSETINT ((low), (int32) & 0xffff), \
424 XSETINT ((high), ((int32) >> 16) & 0xffff))
425
426
427/* Extract the window id of the scroll bar from a struct scroll_bar. */
fbd6baed
GV
428#define SCROLL_BAR_W32_WINDOW(ptr) \
429 ((Window) SCROLL_BAR_PACK ((ptr)->w32_window_low, (ptr)->w32_window_high))
c3b8ccce
GV
430
431/* Store a window id in a struct scroll_bar. */
fbd6baed
GV
432#define SET_SCROLL_BAR_W32_WINDOW(ptr, id) \
433 (SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (int) id))
c3b8ccce
GV
434
435
436/* Return the outside pixel height for a vertical scroll bar HEIGHT
437 rows high on frame F. */
438#define VERTICAL_SCROLL_BAR_PIXEL_HEIGHT(f, height) \
fbd6baed 439 ((height) * (f)->output_data.w32->line_height)
c3b8ccce
GV
440
441/* Return the inside width of a vertical scroll bar, given the outside
442 width. */
443#define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(width) \
444 ((width) - VERTICAL_SCROLL_BAR_LEFT_BORDER - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
445
446/* Return the length of the rectangle within which the top of the
447 handle must stay. This isn't equivalent to the inside height,
448 because the scroll bar handle has a minimum height.
449
450 This is the real range of motion for the scroll bar, so when we're
451 scaling buffer positions to scroll bar positions, we use this, not
452 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
453#define VERTICAL_SCROLL_BAR_TOP_RANGE(height) \
454 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
455
456/* Return the inside height of vertical scroll bar, given the outside
457 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
458#define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(height) \
459 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
460
461
462/* Border widths for scroll bars.
463
464 Scroll bar windows don't have any borders; their border width is
465 set to zero, and we redraw borders ourselves. This makes the code
466 a bit cleaner, since we don't have to convert between outside width
467 (used when relating to the rest of the screen) and inside width
468 (used when sizing and drawing the scroll bar window itself).
469
470 The handle moves up and down/back and forth in a rectangle inset
471 from the edges of the scroll bar. These are widths by which we
472 inset the handle boundaries from the scroll bar edges. */
473#define VERTICAL_SCROLL_BAR_LEFT_BORDER (0)
474#define VERTICAL_SCROLL_BAR_RIGHT_BORDER (0)
8694f11b
GV
475#define VERTICAL_SCROLL_BAR_TOP_BORDER (vertical_scroll_bar_top_border)
476#define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (vertical_scroll_bar_bottom_border)
c3b8ccce
GV
477
478/* Minimum lengths for scroll bar handles, in pixels. */
8694f11b
GV
479#define VERTICAL_SCROLL_BAR_MIN_HANDLE (vertical_scroll_bar_min_handle)
480
c3b8ccce
GV
481
482\f
483/* Manipulating pixel sizes and character sizes.
484 Knowledge of which factors affect the overall size of the window should
485 be hidden in these macros, if that's possible.
486
487 Return the upper/left pixel position of the character cell on frame F
488 at ROW/COL. */
489#define CHAR_TO_PIXEL_ROW(f, row) \
fbd6baed
GV
490 ((f)->output_data.w32->internal_border_width \
491 + (row) * (f)->output_data.w32->line_height)
c3b8ccce 492#define CHAR_TO_PIXEL_COL(f, col) \
fbd6baed
GV
493 ((f)->output_data.w32->internal_border_width \
494 + (col) * FONT_WIDTH ((f)->output_data.w32->font))
c3b8ccce
GV
495
496/* Return the pixel width/height of frame F if it has
497 WIDTH columns/HEIGHT rows. */
498#define CHAR_TO_PIXEL_WIDTH(f, width) \
499 (CHAR_TO_PIXEL_COL (f, width) \
fbd6baed
GV
500 + (f)->output_data.w32->vertical_scroll_bar_extra \
501 + (f)->output_data.w32->internal_border_width)
c3b8ccce
GV
502#define CHAR_TO_PIXEL_HEIGHT(f, height) \
503 (CHAR_TO_PIXEL_ROW (f, height) \
fbd6baed 504 + (f)->output_data.w32->internal_border_width)
c3b8ccce
GV
505
506
507/* Return the row/column (zero-based) of the character cell containing
508 the pixel on FRAME at ROW/COL. */
509#define PIXEL_TO_CHAR_ROW(f, row) \
fbd6baed
GV
510 (((row) - (f)->output_data.w32->internal_border_width) \
511 / (f)->output_data.w32->line_height)
c3b8ccce 512#define PIXEL_TO_CHAR_COL(f, col) \
fbd6baed
GV
513 (((col) - (f)->output_data.w32->internal_border_width) \
514 / FONT_WIDTH ((f)->output_data.w32->font))
c3b8ccce
GV
515
516/* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
517 frame F? */
518#define PIXEL_TO_CHAR_WIDTH(f, width) \
519 (PIXEL_TO_CHAR_COL (f, ((width) \
fbd6baed
GV
520 - (f)->output_data.w32->internal_border_width \
521 - (f)->output_data.w32->vertical_scroll_bar_extra)))
c3b8ccce
GV
522#define PIXEL_TO_CHAR_HEIGHT(f, height) \
523 (PIXEL_TO_CHAR_ROW (f, ((height) \
fbd6baed 524 - (f)->output_data.w32->internal_border_width)))
c3b8ccce
GV
525\f
526/* Interface to the face code functions. */
527
528/* Create the first two computed faces for a frame -- the ones that
529 have GC's. */
530extern void init_frame_faces (/* FRAME_PTR */);
531
532/* Free the resources for the faces associated with a frame. */
533extern void free_frame_faces (/* FRAME_PTR */);
534
535/* Given a computed face, find or make an equivalent display face
536 in face_vector, and return a pointer to it. */
537extern struct face *intern_face (/* FRAME_PTR, struct face * */);
538
539/* Given a frame and a face name, return the face's ID number, or
540 zero if it isn't a recognized face name. */
541extern int face_name_id_number (/* FRAME_PTR, Lisp_Object */);
542
543/* Return non-zero if FONT1 and FONT2 have the same size bounding box.
544 We assume that they're both character-cell fonts. */
545extern int same_size_fonts (/* XFontStruct *, XFontStruct * */);
546
547/* Recompute the GC's for the default and modeline faces.
548 We call this after changing frame parameters on which those GC's
549 depend. */
550extern void recompute_basic_faces (/* FRAME_PTR */);
551
552/* Return the face ID associated with a buffer position POS. Store
553 into *ENDPTR the next position at which a different face is
554 needed. This does not take account of glyphs that specify their
555 own face codes. F is the frame in use for display, and W is a
556 window displaying the current buffer.
557
558 REGION_BEG, REGION_END delimit the region, so it can be highlighted. */
559extern int compute_char_face (/* FRAME_PTR frame,
560 struct window *w,
561 int pos,
562 int region_beg, int region_end,
563 int *endptr */);
564/* Return the face ID to use to display a special glyph which selects
565 FACE_CODE as the face ID, assuming that ordinarily the face would
566 be BASIC_FACE. F is the frame. */
567extern int compute_glyph_face (/* FRAME_PTR, int */);
568
fbd6baed
GV
569extern void w32_fill_rect ();
570extern void w32_clear_window ();
c3b8ccce 571
fbd6baed 572#define w32_fill_area(f,hdc,pix,x,y,nx,ny) \
c3b8ccce
GV
573{ \
574 RECT rect; \
575 rect.left = x; \
576 rect.top = y; \
577 rect.right = x + nx; \
578 rect.bottom = y + ny; \
fbd6baed 579 w32_fill_rect (f,hdc,pix,&rect); \
c3b8ccce
GV
580}
581
fbd6baed
GV
582#define w32_clear_rect(f,hdc,lprect) \
583w32_fill_rect (f,hdc,f->output_data.w32->background_pixel,lprect)
c3b8ccce 584
fbd6baed
GV
585#define w32_clear_area(f,hdc,x,y,nx,ny) \
586w32_fill_area (f,hdc,f->output_data.w32->background_pixel,x,y,nx,ny)
c3b8ccce 587
fbd6baed
GV
588extern XFontStruct *w32_load_font ();
589extern void w32_unload_font ();
c3b8ccce 590
8694f11b
GV
591/* Define for earlier versions of Visual C */
592#ifndef WM_MOUSEWHEEL
593#define WM_MOUSEWHEEL (0x020A)
594#endif /* WM_MOUSEWHEEL */
595
c3b8ccce
GV
596#define WM_EMACS_START (WM_USER + 1)
597#define WM_EMACS_KILL (WM_EMACS_START + 0x00)
598#define WM_EMACS_CREATEWINDOW (WM_EMACS_START + 0x01)
599#define WM_EMACS_DONE (WM_EMACS_START + 0x02)
600#define WM_EMACS_CREATESCROLLBAR (WM_EMACS_START + 0x03)
aba66c88
GV
601#define WM_EMACS_SHOWWINDOW (WM_EMACS_START + 0x04)
602#define WM_EMACS_SETWINDOWPOS (WM_EMACS_START + 0x05)
603#define WM_EMACS_DESTROYWINDOW (WM_EMACS_START + 0x06)
8694f11b
GV
604#define WM_EMACS_TRACKPOPUPMENU (WM_EMACS_START + 0x07)
605#define WM_EMACS_SETFOCUS (WM_EMACS_START + 0x08)
614c350c
GV
606#define WM_EMACS_SETFOREGROUND (WM_EMACS_START + 0x09)
607#define WM_EMACS_SETLOCALE (WM_EMACS_START + 0x0a)
608#define WM_EMACS_END (WM_EMACS_START + 0x0b)
c3b8ccce 609
8694f11b
GV
610#define WND_FONTWIDTH_INDEX (0)
611#define WND_LINEHEIGHT_INDEX (4)
612#define WND_BORDER_INDEX (8)
613#define WND_SCROLLBAR_INDEX (12)
614#define WND_BACKGROUND_INDEX (16)
615#define WND_LAST_INDEX (20)
c3b8ccce 616
c3b8ccce
GV
617#define WND_EXTRA_BYTES (WND_LAST_INDEX)
618
de31b97a
GV
619extern DWORD dwWindowsThreadId;
620extern HANDLE hWindowsThread;
c3b8ccce
GV
621extern DWORD dwMainThreadId;
622extern HANDLE hMainThread;
623
fbd6baed 624typedef struct W32Msg {
c3b8ccce
GV
625 MSG msg;
626 DWORD dwModifiers;
627 RECT rect;
fbd6baed 628} W32Msg;
c3b8ccce 629
8694f11b
GV
630/* Structure for recording message when input thread must return a
631 result that depends on lisp thread to compute. Lisp thread can
632 complete deferred messages out of order. */
633typedef struct deferred_msg
634{
635 struct deferred_msg * next;
636 W32Msg w32msg;
637 LRESULT result;
638 int completed;
639} deferred_msg;
640
aba66c88
GV
641extern CRITICAL_SECTION critsect;
642
c3b8ccce 643extern void init_crit ();
c3b8ccce
GV
644extern void delete_crit ();
645
aba66c88
GV
646#define enter_crit() EnterCriticalSection (&critsect)
647#define leave_crit() LeaveCriticalSection (&critsect)
648
649extern void select_palette (struct frame * f, HDC hdc);
650extern void deselect_palette (struct frame * f, HDC hdc);
651extern HDC get_frame_dc (struct frame * f);
652extern int release_frame_dc (struct frame * f, HDC hDC);
653
c3b8ccce
GV
654extern BOOL get_next_msg ();
655extern BOOL post_msg ();
8694f11b 656extern void complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result);
c3b8ccce
GV
657extern void wait_for_sync ();
658
659extern BOOL parse_button ();
c684f475 660
fbd6baed 661/* Keypad command key support. W32 doesn't have virtual keys defined
c684f475
GV
662 for the function keys on the keypad (they are mapped to the standard
663 fuction keys), so we define our own. */
664#define VK_NUMPAD_BEGIN 0x92
665#define VK_NUMPAD_CLEAR (VK_NUMPAD_BEGIN + 0)
666#define VK_NUMPAD_ENTER (VK_NUMPAD_BEGIN + 1)
667#define VK_NUMPAD_PRIOR (VK_NUMPAD_BEGIN + 2)
668#define VK_NUMPAD_NEXT (VK_NUMPAD_BEGIN + 3)
669#define VK_NUMPAD_END (VK_NUMPAD_BEGIN + 4)
670#define VK_NUMPAD_HOME (VK_NUMPAD_BEGIN + 5)
671#define VK_NUMPAD_LEFT (VK_NUMPAD_BEGIN + 6)
672#define VK_NUMPAD_UP (VK_NUMPAD_BEGIN + 7)
673#define VK_NUMPAD_RIGHT (VK_NUMPAD_BEGIN + 8)
674#define VK_NUMPAD_DOWN (VK_NUMPAD_BEGIN + 9)
675#define VK_NUMPAD_INSERT (VK_NUMPAD_BEGIN + 10)
676#define VK_NUMPAD_DELETE (VK_NUMPAD_BEGIN + 11)
677
678#ifndef VK_LWIN
679/* Older compiler environments don't have these defined. */
680#define VK_LWIN 0x5B
681#define VK_RWIN 0x5C
682#define VK_APPS 0x5D
683#endif