213
|
1 /* Functions for the mswindows window system.
|
|
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not synched with FSF. */
|
|
23
|
|
24 /* Authorship:
|
|
25
|
|
26 Ultimately based on FSF.
|
|
27 Substantially rewritten for XEmacs by Ben Wing.
|
|
28 Rewritten for mswindows by Jonathan Harris, November 1997 for 20.4.
|
|
29 */
|
|
30
|
|
31 #include <config.h>
|
|
32 #include "lisp.h"
|
|
33
|
|
34 #include "console-msw.h"
|
|
35 #include "event-msw.h"
|
|
36
|
|
37 #include "buffer.h"
|
231
|
38 #include "faces.h"
|
213
|
39 #include "frame.h"
|
|
40 #include "events.h"
|
|
41
|
223
|
42 #define MSWINDOWS_FRAME_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_OVERLAPPEDWINDOW
|
|
43 #define MSWINDOWS_POPUP_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_CAPTION|WS_POPUP
|
|
44
|
|
45 #define MSWINDOWS_FRAME_EXSTYLE WS_EX_OVERLAPPEDWINDOW
|
|
46 #define MSWINDOWS_POPUP_EXSTYLE WS_EX_OVERLAPPEDWINDOW
|
|
47
|
|
48 #ifdef HAVE_MENUBARS
|
|
49 #define ADJR_MENUFLAG TRUE
|
|
50 #else
|
|
51 #define ADJR_MENUFLAG FALSE
|
|
52 #endif
|
|
53
|
213
|
54 /* Default properties to use when creating frames. */
|
|
55 Lisp_Object Vdefault_mswindows_frame_plist;
|
|
56 /* Lisp_Object Qname, Qheight, Qwidth, Qinitially_unmapped, Qpopup, Qtop, Qleft; */
|
|
57 Lisp_Object Qinitially_unmapped, Qpopup;
|
|
58
|
|
59 static void
|
|
60 mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
|
|
61 {
|
|
62 Lisp_Object device = FRAME_DEVICE (f);
|
|
63 struct device *d = XDEVICE (device);
|
231
|
64 Lisp_Object initially_unmapped;
|
223
|
65 Lisp_Object name, height, width, popup, top, left;
|
|
66 Lisp_Object frame_obj;
|
|
67 RECT rect;
|
|
68 DWORD style, exstyle;
|
213
|
69
|
223
|
70 initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
|
|
71 name = Fplist_get (props, Qname, Qnil);
|
|
72 height = Fplist_get (props, Qheight, Qnil);
|
|
73 width = Fplist_get (props, Qwidth, Qnil);
|
|
74 popup = Fplist_get (props, Qpopup, Qnil);
|
|
75 top = Fplist_get (props, Qtop, Qnil);
|
|
76 left = Fplist_get (props, Qleft, Qnil);
|
213
|
77
|
225
|
78 /* These shouldn't be here, but the window is created too early.
|
|
79 The initialization of scrollbar resources is done between
|
|
80 init_frame_1 and init_frame_2 in make_frame. jsparkes */
|
|
81 f->scrollbar_width = make_int (15);
|
|
82 f->scrollbar_height = make_int (15);
|
|
83
|
213
|
84 f->frame_data = xnew_and_zero (struct mswindows_frame);
|
223
|
85 FRAME_WIDTH (f) = INTP(width) ? XINT(width) : 80;
|
|
86 FRAME_HEIGHT (f) = INTP(height) ? XINT(height) : 30;
|
|
87 char_to_pixel_size (f, FRAME_WIDTH(f), FRAME_HEIGHT (f),
|
|
88 &FRAME_PIXWIDTH (f), &FRAME_PIXHEIGHT (f));
|
|
89
|
|
90 style = (NILP(popup)) ? MSWINDOWS_FRAME_STYLE : MSWINDOWS_POPUP_STYLE;
|
|
91 exstyle = (NILP(popup)) ? MSWINDOWS_FRAME_EXSTYLE : MSWINDOWS_POPUP_EXSTYLE;
|
|
92 rect.left = rect.top = 0;
|
|
93 rect.right = FRAME_PIXWIDTH (f);
|
|
94 rect.bottom = FRAME_PIXHEIGHT (f);
|
|
95
|
|
96 FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0;
|
|
97 FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0;
|
|
98 FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0;
|
|
99 FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0;
|
|
100 FRAME_MSWINDOWS_DATA(f)->ignore_next_rbutton_up = 0;
|
|
101 FRAME_MSWINDOWS_DATA(f)->sizing = 0;
|
|
102
|
231
|
103 FRAME_MSWINDOWS_MENU_HASHTABLE(f) = Qnil;
|
|
104
|
223
|
105 AdjustWindowRectEx(&rect, style, ADJR_MENUFLAG, exstyle);
|
|
106
|
|
107 FRAME_MSWINDOWS_HANDLE(f) =
|
|
108 CreateWindowEx (exstyle,
|
|
109 XEMACS_CLASS,
|
|
110 STRINGP(f->name) ? XSTRING_DATA(f->name) :
|
|
111 (STRINGP(name) ? XSTRING_DATA(name) : XEMACS_CLASS),
|
|
112 style,
|
|
113 INTP(left) ? XINT(left) : CW_USEDEFAULT,
|
|
114 INTP(top) ? XINT(top) : CW_USEDEFAULT,
|
|
115 rect.right-rect.left, rect.bottom-rect.top,
|
|
116 NULL, NULL, NULL, NULL);
|
|
117 XSETFRAME (frame_obj, f);
|
|
118 SetWindowLong (FRAME_MSWINDOWS_HANDLE(f), XWL_FRAMEOBJ, (LONG)frame_obj);
|
213
|
119 FRAME_MSWINDOWS_DC(f) = GetDC(FRAME_MSWINDOWS_HANDLE(f));
|
|
120 SetTextAlign(FRAME_MSWINDOWS_DC(f), TA_BASELINE|TA_LEFT|TA_NOUPDATECP);
|
|
121 }
|
|
122
|
215
|
123 /* Called just before frame's properties are set, size is 10x10 or something */
|
213
|
124 static void
|
|
125 mswindows_init_frame_2 (struct frame *f, Lisp_Object props)
|
|
126 {
|
|
127 }
|
|
128
|
|
129 /* Called after frame's properties are set */
|
|
130 static void
|
|
131 mswindows_init_frame_3 (struct frame *f)
|
|
132 {
|
|
133 /* Don't do this earlier or we get a WM_PAINT before the frame is ready*/
|
219
|
134 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
|
135 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
|
136 }
|
|
137
|
|
138 static void
|
231
|
139 mswindows_mark_frame (struct frame *f, void (*markobj) (Lisp_Object))
|
|
140 {
|
|
141 ((markobj) (FRAME_MSWINDOWS_MENU_HASHTABLE (f)));
|
|
142 }
|
|
143
|
|
144 static void
|
219
|
145 mswindows_focus_on_frame (struct frame *f)
|
|
146 {
|
|
147 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
213
|
148 }
|
|
149
|
|
150 static void
|
|
151 mswindows_delete_frame (struct frame *f)
|
|
152 {
|
|
153 if (f->frame_data)
|
|
154 {
|
223
|
155 ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
|
|
156 DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
|
213
|
157 }
|
|
158 }
|
|
159
|
|
160 static void
|
|
161 mswindows_set_frame_size (struct frame *f, int cols, int rows)
|
|
162 {
|
219
|
163 RECT rect1, rect2;
|
|
164
|
|
165 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect1);
|
|
166 rect2.left = rect2.top = 0;
|
|
167 char_to_pixel_size (f, cols, rows, &rect2.right, &rect2.bottom);
|
223
|
168
|
|
169 AdjustWindowRectEx (&rect2,
|
|
170 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
171 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
172 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
|
173
|
219
|
174 MoveWindow (FRAME_MSWINDOWS_HANDLE(f), rect1.left, rect1.top,
|
|
175 rect2.right-rect2.left, rect2.bottom-rect2.top, TRUE);
|
213
|
176 }
|
|
177
|
|
178 static void
|
|
179 mswindows_set_frame_position (struct frame *f, int xoff, int yoff)
|
|
180 {
|
219
|
181 RECT rect;
|
|
182
|
|
183 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
184 MoveWindow (FRAME_MSWINDOWS_HANDLE(f), xoff, yoff,
|
|
185 rect.right-rect.left, rect.bottom-rect.top, TRUE);
|
|
186 }
|
|
187
|
|
188 static void
|
|
189 mswindows_make_frame_visible (struct frame *f)
|
|
190 {
|
|
191 if (f->iconified)
|
|
192 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
|
193 else
|
|
194 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
|
195 f->visible = 1;
|
|
196 f->iconified = 0;
|
|
197 }
|
|
198
|
|
199 static void
|
|
200 mswindows_make_frame_invisible (struct frame *f)
|
|
201 {
|
|
202 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_HIDE);
|
|
203 f->visible = -1;
|
|
204 }
|
|
205
|
|
206 static int
|
|
207 mswindows_frame_visible_p (struct frame *f)
|
|
208 {
|
|
209 return IsWindowVisible (FRAME_MSWINDOWS_HANDLE(f))
|
|
210 && !IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
211 }
|
|
212
|
|
213
|
|
214 static void
|
|
215 mswindows_iconify_frame (struct frame *f)
|
|
216 {
|
|
217 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_MINIMIZE);
|
|
218 f->visible = 0;
|
|
219 f->iconified = 1;
|
|
220 }
|
|
221
|
|
222 static int
|
|
223 mswindows_frame_iconified_p (struct frame *f)
|
|
224 {
|
|
225 return IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
226 }
|
|
227
|
|
228 static void
|
|
229 mswindows_raise_frame (struct frame *f)
|
|
230 {
|
|
231 BringWindowToTop (FRAME_MSWINDOWS_HANDLE(f));
|
|
232 /* XXX Should we do SetWindowForeground too ? */
|
|
233 }
|
|
234
|
|
235 static void
|
|
236 mswindows_lower_frame (struct frame *f)
|
|
237 {
|
|
238 RECT rect;
|
|
239
|
|
240 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
241 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), HWND_BOTTOM, rect.top, rect.left,
|
|
242 rect.right-rect.left, rect.bottom-rect.top, 0);
|
|
243 }
|
|
244
|
|
245 static void
|
|
246 mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title)
|
|
247 {
|
|
248 SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title);
|
213
|
249 }
|
|
250
|
|
251 static void
|
|
252 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
253 {
|
|
254 int x, y;
|
|
255 int width = 0, height = 0;
|
|
256 BOOL width_specified_p = FALSE;
|
|
257 BOOL height_specified_p = FALSE;
|
|
258 BOOL x_specified_p = FALSE;
|
|
259 BOOL y_specified_p = FALSE;
|
|
260 Lisp_Object tail;
|
|
261
|
|
262 /* Extract the properties from plist */
|
|
263 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
264 {
|
|
265 Lisp_Object prop = Fcar (tail);
|
|
266 Lisp_Object val = Fcar (Fcdr (tail));
|
|
267
|
|
268 if (SYMBOLP (prop))
|
|
269 {
|
|
270 /* Kludge to handle the font property. */
|
|
271 if (EQ (prop, Qfont))
|
|
272 {
|
|
273 /* If the value is not a string we silently ignore it. */
|
|
274 if (STRINGP (val))
|
|
275 {
|
|
276 Lisp_Object frm, font_spec;
|
|
277
|
|
278 XSETFRAME (frm, f);
|
|
279 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil);
|
|
280
|
|
281 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil);
|
|
282 update_frame_face_values (f);
|
|
283 }
|
|
284 }
|
|
285 else if (EQ (prop, Qwidth))
|
|
286 {
|
|
287 CHECK_INT (val);
|
|
288 width = XINT (val);
|
|
289 width_specified_p = TRUE;
|
|
290 }
|
|
291 else if (EQ (prop, Qheight))
|
|
292 {
|
|
293 CHECK_INT (val);
|
|
294 height = XINT (val);
|
|
295 height_specified_p = TRUE;
|
|
296 }
|
|
297 else if (EQ (prop, Qleft))
|
|
298 {
|
|
299 CHECK_INT (val);
|
|
300 x = XINT (val);
|
|
301 x_specified_p = TRUE;
|
|
302 }
|
|
303 else if (EQ (prop, Qtop))
|
|
304 {
|
|
305 CHECK_INT (val);
|
|
306 y = XINT (val);
|
|
307 y_specified_p = TRUE;
|
|
308 }
|
|
309 }
|
|
310 }
|
|
311
|
|
312 /* Now we've extracted the properties, apply them */
|
|
313 if (width_specified_p || height_specified_p || x_specified_p || y_specified_p)
|
|
314 {
|
|
315 Lisp_Object frame;
|
|
316 RECT rect;
|
|
317 int pixel_width, pixel_height;
|
|
318 XSETFRAME (frame, f);
|
|
319
|
|
320 if (!width_specified_p)
|
|
321 width = FRAME_WIDTH (f);
|
|
322 if (!height_specified_p)
|
|
323 height = FRAME_HEIGHT (f);
|
|
324 char_to_pixel_size (f, width, height, &pixel_width, &pixel_height);
|
|
325
|
|
326 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
327 if (!x_specified_p)
|
|
328 x = rect.left;
|
|
329 if (!y_specified_p)
|
|
330 y = rect.top;
|
219
|
331
|
223
|
332 AdjustWindowRectEx (&rect,
|
|
333 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
334 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
335 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
|
336
|
213
|
337 MoveWindow (FRAME_MSWINDOWS_HANDLE(f), x, y, pixel_width, pixel_height,
|
|
338 (width_specified_p || height_specified_p));
|
|
339 }
|
|
340 }
|
|
341
|
|
342
|
|
343 void
|
|
344 console_type_create_frame_mswindows (void)
|
|
345 {
|
|
346 /* frame methods */
|
|
347 CONSOLE_HAS_METHOD (mswindows, init_frame_1);
|
|
348 CONSOLE_HAS_METHOD (mswindows, init_frame_2);
|
|
349 CONSOLE_HAS_METHOD (mswindows, init_frame_3);
|
231
|
350 CONSOLE_HAS_METHOD (mswindows, mark_frame);
|
219
|
351 CONSOLE_HAS_METHOD (mswindows, focus_on_frame);
|
213
|
352 CONSOLE_HAS_METHOD (mswindows, delete_frame);
|
|
353 /* CONSOLE_HAS_METHOD (mswindows, get_mouse_position); */
|
|
354 /* CONSOLE_HAS_METHOD (mswindows, set_mouse_position); */
|
219
|
355 CONSOLE_HAS_METHOD (mswindows, raise_frame);
|
|
356 CONSOLE_HAS_METHOD (mswindows, lower_frame);
|
|
357 CONSOLE_HAS_METHOD (mswindows, make_frame_visible);
|
|
358 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible);
|
|
359 CONSOLE_HAS_METHOD (mswindows, iconify_frame);
|
213
|
360 CONSOLE_HAS_METHOD (mswindows, set_frame_size);
|
|
361 CONSOLE_HAS_METHOD (mswindows, set_frame_position);
|
|
362 /* CONSOLE_HAS_METHOD (mswindows, frame_property); */
|
|
363 /* CONSOLE_HAS_METHOD (mswindows, internal_frame_property_p); */
|
|
364 /* CONSOLE_HAS_METHOD (mswindows, frame_properties); */
|
|
365 CONSOLE_HAS_METHOD (mswindows, set_frame_properties);
|
219
|
366 CONSOLE_HAS_METHOD (mswindows, set_title_from_bufbyte);
|
213
|
367 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_bufbyte); */
|
219
|
368 CONSOLE_HAS_METHOD (mswindows, frame_visible_p);
|
213
|
369 /* CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p); */
|
219
|
370 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p);
|
213
|
371 /* CONSOLE_HAS_METHOD (mswindows, set_frame_pointer); */
|
|
372 /* CONSOLE_HAS_METHOD (mswindows, set_frame_icon); */
|
|
373 /* CONSOLE_HAS_METHOD (mswindows, get_frame_parent); */
|
|
374 }
|
|
375
|
|
376 void
|
|
377 syms_of_frame_mswindows (void)
|
|
378 {
|
|
379 #if 0 /* XXX these are in general.c */
|
|
380 defsymbol (&Qname, "name");
|
|
381 defsymbol (&Qheight, "height");
|
|
382 defsymbol (&Qwidth, "width");
|
|
383 defsymbol (&Qtop, "top");
|
|
384 defsymbol (&Qleft, "left");
|
|
385 #endif
|
|
386 defsymbol (&Qinitially_unmapped, "initially-unmapped");
|
|
387 defsymbol (&Qpopup, "popup");
|
|
388 }
|
|
389
|
|
390 void
|
|
391 vars_of_frame_mswindows (void)
|
|
392 {
|
|
393 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /*
|
|
394 Plist of default frame-creation properties for mswindows frames.
|
|
395 These override what is specified in `default-frame-plist', but are
|
|
396 overridden by the arguments to the particular call to `make-frame'.
|
|
397
|
|
398 Note: In many cases, properties of a frame are available as specifiers
|
|
399 instead of through the frame-properties mechanism.
|
|
400
|
|
401 Here is a list of recognized frame properties, other than those
|
|
402 documented in `set-frame-properties' (they can be queried and
|
|
403 set at any time, except as otherwise noted):
|
|
404
|
|
405 initially-unmapped If non-nil, the frame will not be visible
|
|
406 when it is created. In this case, you
|
|
407 need to call `make-frame-visible' to make
|
|
408 the frame appear.
|
|
409 popup If non-nil, it should be a frame, and this
|
|
410 frame will be created as a "popup" frame
|
|
411 whose parent is the given frame. This
|
|
412 will make the window manager treat the
|
|
413 frame as a dialog box, which may entail
|
|
414 doing different things (e.g. not asking
|
|
415 for positioning, and not iconifying
|
|
416 separate from its parent).
|
|
417 top Y position (in pixels) of the upper-left
|
|
418 outermost corner of the frame (i.e. the
|
|
419 upper-left of the window-manager
|
|
420 decorations).
|
|
421 left X position (in pixels) of the upper-left
|
|
422 outermost corner of the frame (i.e. the
|
|
423 upper-left of the window-manager
|
|
424 decorations).
|
|
425
|
|
426 See also `default-frame-plist', which specifies properties which apply
|
|
427 to all frames, not just mswindows frames.
|
|
428 */ );
|
|
429 Vdefault_mswindows_frame_plist = Qnil;
|
|
430
|
|
431 mswindows_console_methods->device_specific_frame_props =
|
|
432 &Vdefault_mswindows_frame_plist;
|
|
433 }
|