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