Mercurial > emacs
annotate src/w32term.h @ 15423:5b9fe08fa6eb
(main): For SIGHUP, use sigblock and sigunblock,
not sigblockx and sigunblockx.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 12 Jun 1996 21:49:19 +0000 |
parents | 2dd4961cefaa |
children | 481b7874a1e9 |
rev | line source |
---|---|
13543 | 1 /* Definitions and headers for communication with Win32 GUI. |
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 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13543
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13543
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
13543 | 20 |
21 /* Added by Kevin Gallo */ | |
22 | |
23 #include <win32.h> | |
24 | |
25 /* The class of this X application. */ | |
26 #define EMACS_CLASS "Emacs" | |
27 | |
14984
e8a969370f33
(BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT): Use PALETTERGB instead of RGB.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14809
diff
changeset
|
28 #define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0) |
e8a969370f33
(BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT): Use PALETTERGB instead of RGB.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14809
diff
changeset
|
29 #define WHITE_PIX_DEFAULT(f) PALETTERGB(255,255,255) |
13543 | 30 |
14521
4ffaeb5318c0
(FONT_WIDTH): Use average character width, not maximum.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14353
diff
changeset
|
31 #define FONT_WIDTH(f) ((f)->tm.tmAveCharWidth) |
13543 | 32 #define FONT_HEIGHT(f) ((f)->tm.tmHeight) |
33 #define FONT_BASE(f) ((f)->tm.tmAscent) | |
34 | |
35 #define CHECK_WIN32_FRAME(f, frame) \ | |
36 if (NILP (frame)) \ | |
37 f = selected_frame; \ | |
38 else \ | |
39 { \ | |
40 CHECK_LIVE_FRAME (frame, 0); \ | |
41 f = XFRAME (frame); \ | |
42 } \ | |
43 if (! FRAME_WIN32_P (f)) | |
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 | |
57 /* This data type is used for the font_table field | |
58 of struct win32_display_info. */ | |
59 | |
60 struct 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 | |
69 struct win32_bitmap_record | |
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 }; | |
15152
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
78 |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
79 /* Palette book-keeping stuff for mapping requested colors into the |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
80 system palette. Keep a ref-counted list of requested colors and |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
81 regenerate the app palette whenever the requested list changes. */ |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
82 |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
83 extern Lisp_Object Vwin32_enable_palette; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
84 |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
85 struct win32_palette_entry { |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
86 struct win32_palette_entry * next; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
87 PALETTEENTRY entry; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
88 #if 0 |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
89 unsigned refcount; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
90 #endif |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
91 }; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
92 |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
93 extern void win32_regenerate_palette(struct frame *f); |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
94 |
13543 | 95 |
96 /* For each display (currently only one on win32), we have a structure that | |
97 records information about it. */ | |
98 | |
99 struct win32_display_info | |
100 { | |
101 /* Chain of all win32_display_info structures. */ | |
102 struct win32_display_info *next; | |
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 | |
15152
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
122 /* color palette information */ |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
123 int has_palette; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
124 struct win32_palette_entry * color_list; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
125 unsigned num_colors; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
126 HPALETTE palette; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
127 |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
128 /* deferred action flags checked when starting frame update */ |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
129 int regen_palette; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
130 |
13543 | 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 | |
159 char *win32_id_name; | |
160 | |
161 /* The number of fonts actually stored in win32_font_table. | |
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. */ | |
167 struct win32_bitmap_record *bitmaps; | |
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 | |
179 win32_focus_event_frame. */ | |
180 struct frame *win32_focus_frame; | |
181 | |
182 /* The last frame mentioned in a FocusIn or FocusOut event. This is | |
183 separate from win32_focus_frame, because whether or not LeaveNotify | |
184 events cause us to lose focus depends on whether or not we have | |
185 received a FocusIn event for it. */ | |
186 struct frame *win32_focus_event_frame; | |
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 | |
191 frame. It differs from win32_focus_frame when we're using a global | |
192 minibuffer. */ | |
193 struct frame *win32_highlight_frame; | |
194 }; | |
195 | |
196 /* This is a chain of structures for all the displays currently in use. */ | |
197 extern struct win32_display_info one_win32_display_info; | |
198 | |
199 /* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE), | |
200 one for each element of win32_display_list and in the same order. | |
201 NAME is the name of the frame. | |
202 FONT-LIST-CACHE records previous values returned by x-list-fonts. */ | |
203 extern Lisp_Object win32_display_name_list; | |
204 | |
205 extern struct win32_display_info *x_display_info_for_display (); | |
206 extern struct win32_display_info *x_display_info_for_name (); | |
207 | |
208 extern struct win32_display_info *win32_term_init (); | |
209 | |
210 /* Each Win32 frame object points to its own struct win32_display object | |
211 in the output_data.win32 field. The win32_display structure contains all | |
212 the information that is specific to Win32 windows. */ | |
213 | |
214 struct win32_output | |
215 { | |
15152
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
216 /* Original palette (used to deselect real palette after drawing) */ |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
217 HPALETTE old_palette; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
218 |
13543 | 219 /* Position of the Win32 window (x and y offsets in root window). */ |
220 int left_pos; | |
221 int top_pos; | |
222 | |
223 /* Border width of the Win32 window as known by the window system. */ | |
224 int border_width; | |
225 | |
226 /* Size of the Win32 window in pixels. */ | |
227 int pixel_height, pixel_width; | |
228 | |
229 /* Height of a line, in pixels. */ | |
230 int line_height; | |
231 | |
232 /* Width of the internal border. This is a line of background color | |
233 just inside the window's border. When the frame is selected, | |
234 a highlighting is displayed inside the internal border. */ | |
235 int internal_border_width; | |
236 | |
237 /* The window used for this frame. | |
238 May be zero while the frame object is being created | |
239 and the window has not yet been created. */ | |
240 Window window_desc; | |
241 | |
242 /* The window that is the parent of this window. | |
243 Usually this is a window that was made by the window manager, | |
244 but it can be the root window, and it can be explicitly specified | |
245 (see the explicit_parent field, below). */ | |
246 Window parent_desc; | |
247 | |
248 XFontStruct *font; | |
249 | |
250 /* Pixel values used for various purposes. | |
251 border_pixel may be -1 meaning use a gray tile. */ | |
252 unsigned long background_pixel; | |
253 unsigned long foreground_pixel; | |
254 unsigned long cursor_pixel; | |
255 unsigned long border_pixel; | |
256 unsigned long mouse_pixel; | |
257 unsigned long cursor_foreground_pixel; | |
258 | |
259 /* Descriptor for the cursor in use for this window. */ | |
260 Cursor text_cursor; | |
261 Cursor nontext_cursor; | |
262 Cursor modeline_cursor; | |
263 Cursor cross_cursor; | |
264 | |
265 /* Flag to set when the window needs to be completely repainted. */ | |
266 int needs_exposure; | |
267 | |
268 /* What kind of text cursor is drawn in this window right now? | |
269 (If there is no cursor (phys_cursor_x < 0), then this means nothing.) */ | |
270 enum text_cursor_kinds current_cursor; | |
271 | |
272 /* What kind of text cursor should we draw in the future? | |
273 This should always be filled_box_cursor or bar_cursor. */ | |
274 enum text_cursor_kinds desired_cursor; | |
275 | |
276 /* Width of bar cursor (if we are using that). */ | |
277 int cursor_width; | |
278 | |
279 DWORD dwStyle; | |
280 | |
281 /* The size of the extra width currently allotted for vertical | |
282 scroll bars, in pixels. */ | |
283 int vertical_scroll_bar_extra; | |
284 | |
285 /* Table of parameter faces for this frame. Any resources (pixel | |
286 values, fonts) referred to here have been allocated explicitly | |
287 for this face, and should be freed if we change the face. */ | |
288 struct face **param_faces; | |
289 int n_param_faces; | |
290 | |
291 /* Table of computed faces for this frame. These are the faces | |
292 whose indexes go into the upper bits of a glyph, computed by | |
293 combining the parameter faces specified by overlays, text | |
294 properties, and what have you. The resources mentioned here | |
295 are all shared with parameter faces. */ | |
296 struct face **computed_faces; | |
297 int n_computed_faces; /* How many are valid */ | |
298 int size_computed_faces; /* How many are allocated */ | |
299 | |
300 /* This is the gravity value for the specified window position. */ | |
301 int win_gravity; | |
302 | |
303 /* The geometry flags for this window. */ | |
304 int size_hint_flags; | |
305 | |
306 /* This is the Emacs structure for the display this frame is on. */ | |
307 /* struct win32_display_info *display_info; */ | |
308 | |
309 /* Nonzero means our parent is another application's window | |
310 and was explicitly specified. */ | |
311 char explicit_parent; | |
312 | |
313 /* Nonzero means tried already to make this frame visible. */ | |
314 char asked_for_visible; | |
315 }; | |
316 | |
317 /* Get at the computed faces of an X window frame. */ | |
318 #define FRAME_PARAM_FACES(f) ((f)->output_data.win32->param_faces) | |
319 #define FRAME_N_PARAM_FACES(f) ((f)->output_data.win32->n_param_faces) | |
320 #define FRAME_DEFAULT_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[0]) | |
321 #define FRAME_MODE_LINE_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[1]) | |
322 | |
323 #define FRAME_COMPUTED_FACES(f) ((f)->output_data.win32->computed_faces) | |
324 #define FRAME_N_COMPUTED_FACES(f) ((f)->output_data.win32->n_computed_faces) | |
325 #define FRAME_SIZE_COMPUTED_FACES(f) ((f)->output_data.win32->size_computed_faces) | |
326 #define FRAME_DEFAULT_FACE(f) ((f)->output_data.win32->computed_faces[0]) | |
327 #define FRAME_MODE_LINE_FACE(f) ((f)->output_data.win32->computed_faces[1]) | |
328 | |
329 /* Return the window associated with the frame F. */ | |
330 #define FRAME_WIN32_WINDOW(f) ((f)->output_data.win32->window_desc) | |
331 | |
332 #define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.win32->foreground_pixel) | |
333 #define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.win32->background_pixel) | |
334 #define FRAME_FONT(f) ((f)->output_data.win32->font) | |
335 #define FRAME_INTERNAL_BORDER_WIDTH(f) ((f)->output_data.win32->internal_border_width) | |
336 | |
337 /* This gives the win32_display_info structure for the display F is on. */ | |
338 #define FRAME_WIN32_DISPLAY_INFO(f) (&one_win32_display_info) | |
339 | |
340 /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}. */ | |
341 #define PIXEL_WIDTH(f) ((f)->output_data.win32->pixel_width) | |
342 #define PIXEL_HEIGHT(f) ((f)->output_data.win32->pixel_height) | |
343 #define FRAME_LINE_HEIGHT(f) ((f)->output_data.win32->line_height) | |
344 | |
345 #define FRAME_DESIRED_CURSOR(f) ((f)->output_data.win32->desired_cursor) | |
346 | |
347 | |
348 /* Win32-specific scroll bar stuff. */ | |
349 | |
350 /* We represent scroll bars as lisp vectors. This allows us to place | |
351 references to them in windows without worrying about whether we'll | |
352 end up with windows referring to dead scroll bars; the garbage | |
353 collector will free it when its time comes. | |
354 | |
355 We use struct scroll_bar as a template for accessing fields of the | |
356 vector. */ | |
357 | |
358 struct scroll_bar { | |
359 | |
360 /* These fields are shared by all vectors. */ | |
361 EMACS_INT size_from_Lisp_Vector_struct; | |
362 struct Lisp_Vector *next_from_Lisp_Vector_struct; | |
363 | |
364 /* The window we're a scroll bar for. */ | |
365 Lisp_Object window; | |
366 | |
367 /* The next and previous in the chain of scroll bars in this frame. */ | |
368 Lisp_Object next, prev; | |
369 | |
370 /* The window representing this scroll bar. Since this is a full | |
371 32-bit quantity, we store it split into two 32-bit values. */ | |
372 Lisp_Object win32_window_low, win32_window_high; | |
373 | |
374 /* The position and size of the scroll bar in pixels, relative to the | |
375 frame. */ | |
376 Lisp_Object top, left, width, height; | |
377 | |
378 /* The starting and ending positions of the handle, relative to the | |
379 handle area (i.e. zero is the top position, not | |
380 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle | |
381 hasn't been drawn yet. | |
382 | |
383 These are not actually the locations where the beginning and end | |
384 are drawn; in order to keep handles from becoming invisible when | |
385 editing large files, we establish a minimum height by always | |
386 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below | |
387 where they would be normally; the bottom and top are in a | |
388 different co-ordinate system. */ | |
389 Lisp_Object start, end; | |
390 | |
391 /* If the scroll bar handle is currently being dragged by the user, | |
392 this is the number of pixels from the top of the handle to the | |
393 place where the user grabbed it. If the handle isn't currently | |
394 being dragged, this is Qnil. */ | |
395 Lisp_Object dragging; | |
396 }; | |
397 | |
398 /* The number of elements a vector holding a struct scroll_bar needs. */ | |
399 #define SCROLL_BAR_VEC_SIZE \ | |
400 ((sizeof (struct scroll_bar) \ | |
401 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \ | |
402 / sizeof (Lisp_Object)) | |
403 | |
404 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */ | |
405 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) | |
406 | |
407 | |
408 /* Building a 32-bit C integer from two 16-bit lisp integers. */ | |
409 #define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low)) | |
410 | |
411 /* Setting two lisp integers to the low and high words of a 32-bit C int. */ | |
412 #define SCROLL_BAR_UNPACK(low, high, int32) \ | |
413 (XSETINT ((low), (int32) & 0xffff), \ | |
414 XSETINT ((high), ((int32) >> 16) & 0xffff)) | |
415 | |
416 | |
417 /* Extract the window id of the scroll bar from a struct scroll_bar. */ | |
418 #define SCROLL_BAR_WIN32_WINDOW(ptr) \ | |
419 ((Window) SCROLL_BAR_PACK ((ptr)->win32_window_low, (ptr)->win32_window_high)) | |
420 | |
421 /* Store a window id in a struct scroll_bar. */ | |
422 #define SET_SCROLL_BAR_WIN32_WINDOW(ptr, id) \ | |
423 (SCROLL_BAR_UNPACK ((ptr)->win32_window_low, (ptr)->win32_window_high, (int) id)) | |
424 | |
425 | |
426 /* Return the outside pixel height for a vertical scroll bar HEIGHT | |
427 rows high on frame F. */ | |
428 #define VERTICAL_SCROLL_BAR_PIXEL_HEIGHT(f, height) \ | |
429 ((height) * (f)->output_data.win32->line_height) | |
430 | |
431 /* Return the inside width of a vertical scroll bar, given the outside | |
432 width. */ | |
433 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(width) \ | |
434 ((width) - VERTICAL_SCROLL_BAR_LEFT_BORDER - VERTICAL_SCROLL_BAR_RIGHT_BORDER) | |
435 | |
436 /* Return the length of the rectangle within which the top of the | |
437 handle must stay. This isn't equivalent to the inside height, | |
438 because the scroll bar handle has a minimum height. | |
439 | |
440 This is the real range of motion for the scroll bar, so when we're | |
441 scaling buffer positions to scroll bar positions, we use this, not | |
442 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */ | |
443 #define VERTICAL_SCROLL_BAR_TOP_RANGE(height) \ | |
444 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (height) - VERTICAL_SCROLL_BAR_MIN_HANDLE) | |
445 | |
446 /* Return the inside height of vertical scroll bar, given the outside | |
447 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */ | |
448 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(height) \ | |
449 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER) | |
450 | |
451 | |
452 /* Border widths for scroll bars. | |
453 | |
454 Scroll bar windows don't have any borders; their border width is | |
455 set to zero, and we redraw borders ourselves. This makes the code | |
456 a bit cleaner, since we don't have to convert between outside width | |
457 (used when relating to the rest of the screen) and inside width | |
458 (used when sizing and drawing the scroll bar window itself). | |
459 | |
460 The handle moves up and down/back and forth in a rectangle inset | |
461 from the edges of the scroll bar. These are widths by which we | |
462 inset the handle boundaries from the scroll bar edges. */ | |
463 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (0) | |
464 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (0) | |
465 #define VERTICAL_SCROLL_BAR_TOP_BORDER (0) | |
466 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (0) | |
467 | |
468 /* Minimum lengths for scroll bar handles, in pixels. */ | |
469 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (0) | |
470 | |
471 | |
472 /* Manipulating pixel sizes and character sizes. | |
473 Knowledge of which factors affect the overall size of the window should | |
474 be hidden in these macros, if that's possible. | |
475 | |
476 Return the upper/left pixel position of the character cell on frame F | |
477 at ROW/COL. */ | |
478 #define CHAR_TO_PIXEL_ROW(f, row) \ | |
479 ((f)->output_data.win32->internal_border_width \ | |
480 + (row) * (f)->output_data.win32->line_height) | |
481 #define CHAR_TO_PIXEL_COL(f, col) \ | |
482 ((f)->output_data.win32->internal_border_width \ | |
483 + (col) * FONT_WIDTH ((f)->output_data.win32->font)) | |
484 | |
485 /* Return the pixel width/height of frame F if it has | |
486 WIDTH columns/HEIGHT rows. */ | |
487 #define CHAR_TO_PIXEL_WIDTH(f, width) \ | |
488 (CHAR_TO_PIXEL_COL (f, width) \ | |
489 + (f)->output_data.win32->vertical_scroll_bar_extra \ | |
490 + (f)->output_data.win32->internal_border_width) | |
491 #define CHAR_TO_PIXEL_HEIGHT(f, height) \ | |
492 (CHAR_TO_PIXEL_ROW (f, height) \ | |
493 + (f)->output_data.win32->internal_border_width) | |
494 | |
495 | |
496 /* Return the row/column (zero-based) of the character cell containing | |
497 the pixel on FRAME at ROW/COL. */ | |
498 #define PIXEL_TO_CHAR_ROW(f, row) \ | |
499 (((row) - (f)->output_data.win32->internal_border_width) \ | |
500 / (f)->output_data.win32->line_height) | |
501 #define PIXEL_TO_CHAR_COL(f, col) \ | |
502 (((col) - (f)->output_data.win32->internal_border_width) \ | |
503 / FONT_WIDTH ((f)->output_data.win32->font)) | |
504 | |
505 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on | |
506 frame F? */ | |
507 #define PIXEL_TO_CHAR_WIDTH(f, width) \ | |
508 (PIXEL_TO_CHAR_COL (f, ((width) \ | |
509 - (f)->output_data.win32->internal_border_width \ | |
510 - (f)->output_data.win32->vertical_scroll_bar_extra))) | |
511 #define PIXEL_TO_CHAR_HEIGHT(f, height) \ | |
512 (PIXEL_TO_CHAR_ROW (f, ((height) \ | |
513 - (f)->output_data.win32->internal_border_width))) | |
514 | |
515 /* Interface to the face code functions. */ | |
516 | |
517 /* Create the first two computed faces for a frame -- the ones that | |
518 have GC's. */ | |
519 extern void init_frame_faces (/* FRAME_PTR */); | |
520 | |
521 /* Free the resources for the faces associated with a frame. */ | |
522 extern void free_frame_faces (/* FRAME_PTR */); | |
523 | |
524 /* Given a computed face, find or make an equivalent display face | |
525 in face_vector, and return a pointer to it. */ | |
526 extern struct face *intern_face (/* FRAME_PTR, struct face * */); | |
527 | |
528 /* Given a frame and a face name, return the face's ID number, or | |
529 zero if it isn't a recognized face name. */ | |
530 extern int face_name_id_number (/* FRAME_PTR, Lisp_Object */); | |
531 | |
532 /* Return non-zero if FONT1 and FONT2 have the same size bounding box. | |
533 We assume that they're both character-cell fonts. */ | |
534 extern int same_size_fonts (/* XFontStruct *, XFontStruct * */); | |
535 | |
536 /* Recompute the GC's for the default and modeline faces. | |
537 We call this after changing frame parameters on which those GC's | |
538 depend. */ | |
539 extern void recompute_basic_faces (/* FRAME_PTR */); | |
540 | |
541 /* Return the face ID associated with a buffer position POS. Store | |
542 into *ENDPTR the next position at which a different face is | |
543 needed. This does not take account of glyphs that specify their | |
544 own face codes. F is the frame in use for display, and W is a | |
545 window displaying the current buffer. | |
546 | |
547 REGION_BEG, REGION_END delimit the region, so it can be highlighted. */ | |
548 extern int compute_char_face (/* FRAME_PTR frame, | |
549 struct window *w, | |
550 int pos, | |
551 int region_beg, int region_end, | |
552 int *endptr */); | |
553 /* Return the face ID to use to display a special glyph which selects | |
554 FACE_CODE as the face ID, assuming that ordinarily the face would | |
555 be BASIC_FACE. F is the frame. */ | |
556 extern int compute_glyph_face (/* FRAME_PTR, int */); | |
557 | |
558 extern void win32_fill_rect (); | |
559 extern void win32_clear_window (); | |
560 | |
561 #define win32_fill_area(f,hdc,pix,x,y,nx,ny) \ | |
562 { \ | |
563 RECT rect; \ | |
564 rect.left = x; \ | |
565 rect.top = y; \ | |
566 rect.right = x + nx; \ | |
567 rect.bottom = y + ny; \ | |
568 win32_fill_rect (f,hdc,pix,&rect); \ | |
569 } | |
570 | |
571 #define win32_clear_rect(f,hdc,lprect) \ | |
572 win32_fill_rect (f,hdc,f->output_data.win32->background_pixel,lprect) | |
573 | |
574 #define win32_clear_area(f,hdc,x,y,nx,ny) \ | |
575 win32_fill_area (f,hdc,f->output_data.win32->background_pixel,x,y,nx,ny) | |
576 | |
577 extern XFontStruct *win32_load_font (); | |
578 extern void win32_unload_font (); | |
579 | |
580 #define WM_EMACS_START (WM_USER + 1) | |
581 #define WM_EMACS_KILL (WM_EMACS_START + 0x00) | |
582 #define WM_EMACS_CREATEWINDOW (WM_EMACS_START + 0x01) | |
583 #define WM_EMACS_DONE (WM_EMACS_START + 0x02) | |
584 #define WM_EMACS_CREATESCROLLBAR (WM_EMACS_START + 0x03) | |
15152
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
585 #define WM_EMACS_SHOWWINDOW (WM_EMACS_START + 0x04) |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
586 #define WM_EMACS_SETWINDOWPOS (WM_EMACS_START + 0x05) |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
587 #define WM_EMACS_DESTROYWINDOW (WM_EMACS_START + 0x06) |
13543 | 588 #define WM_EMACS_END (WM_EMACS_START + 0x10) |
589 | |
15152
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
590 typedef struct { |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
591 HWND hwndAfter; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
592 int x; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
593 int y; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
594 int cx; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
595 int cy; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
596 int flags; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
597 } Win32WindowPos; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
598 |
13543 | 599 #define WND_X_UNITS_INDEX (0) |
600 #define WND_Y_UNITS_INDEX (4) | |
601 #define WND_BACKGROUND_INDEX (8) | |
602 | |
603 #define WND_LAST_INDEX (16) | |
604 #define WND_EXTRA_BYTES (WND_LAST_INDEX) | |
605 | |
606 extern DWORD dwWinThreadId; | |
607 extern HANDLE hWinThread; | |
608 extern DWORD dwMainThreadId; | |
609 extern HANDLE hMainThread; | |
610 | |
611 typedef struct Win32Msg { | |
612 MSG msg; | |
613 DWORD dwModifiers; | |
614 RECT rect; | |
615 } Win32Msg; | |
616 | |
15152
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
617 extern CRITICAL_SECTION critsect; |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
618 |
13543 | 619 extern void init_crit (); |
620 extern void delete_crit (); | |
621 | |
15152
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
622 #define enter_crit() EnterCriticalSection (&critsect) |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
623 #define leave_crit() LeaveCriticalSection (&critsect) |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
624 |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
625 extern void select_palette (struct frame * f, HDC hdc); |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
626 extern void deselect_palette (struct frame * f, HDC hdc); |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
627 extern HDC get_frame_dc (struct frame * f); |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
628 extern int release_frame_dc (struct frame * f, HDC hDC); |
2dd4961cefaa
(struct win32_palette_entry): New structure.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14984
diff
changeset
|
629 |
13543 | 630 extern BOOL get_next_msg (); |
631 extern BOOL post_msg (); | |
632 extern void wait_for_sync (); | |
633 | |
634 extern BOOL parse_button (); | |
14809
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
635 |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
636 /* Keypad command key support. Win32 doesn't have virtual keys defined |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
637 for the function keys on the keypad (they are mapped to the standard |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
638 fuction keys), so we define our own. */ |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
639 #define VK_NUMPAD_BEGIN 0x92 |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
640 #define VK_NUMPAD_CLEAR (VK_NUMPAD_BEGIN + 0) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
641 #define VK_NUMPAD_ENTER (VK_NUMPAD_BEGIN + 1) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
642 #define VK_NUMPAD_PRIOR (VK_NUMPAD_BEGIN + 2) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
643 #define VK_NUMPAD_NEXT (VK_NUMPAD_BEGIN + 3) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
644 #define VK_NUMPAD_END (VK_NUMPAD_BEGIN + 4) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
645 #define VK_NUMPAD_HOME (VK_NUMPAD_BEGIN + 5) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
646 #define VK_NUMPAD_LEFT (VK_NUMPAD_BEGIN + 6) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
647 #define VK_NUMPAD_UP (VK_NUMPAD_BEGIN + 7) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
648 #define VK_NUMPAD_RIGHT (VK_NUMPAD_BEGIN + 8) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
649 #define VK_NUMPAD_DOWN (VK_NUMPAD_BEGIN + 9) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
650 #define VK_NUMPAD_INSERT (VK_NUMPAD_BEGIN + 10) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
651 #define VK_NUMPAD_DELETE (VK_NUMPAD_BEGIN + 11) |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
652 |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
653 #ifndef VK_LWIN |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
654 /* Older compiler environments don't have these defined. */ |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
655 #define VK_LWIN 0x5B |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
656 #define VK_RWIN 0x5C |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
657 #define VK_APPS 0x5D |
fb9e2125fc2e
(VK_NUMPAD_*, VK_LWIN, VK_RWIN, VK_APPS):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14521
diff
changeset
|
658 #endif |