428
|
1 /* Define mswindows-specific console, device, and frame object for XEmacs.
|
|
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
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 in FSF. */
|
|
23
|
|
24
|
|
25 /* Authorship:
|
|
26
|
|
27 Ultimately based on FSF, then later on JWZ work for Lemacs.
|
|
28 Rewritten over time by Ben Wing and Chuck Thompson.
|
|
29 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
|
|
30 */
|
|
31
|
440
|
32 #ifndef INCLUDED_console_msw_h_
|
|
33 #define INCLUDED_console_msw_h_
|
428
|
34
|
|
35 #include "console.h"
|
442
|
36 #include "syswindows.h"
|
|
37 #include "syscommctrl.h"
|
428
|
38
|
|
39 #ifdef HAVE_XPM
|
|
40 #include <X11/xpm.h>
|
|
41 #endif
|
|
42
|
|
43 /* The name of the main window class */
|
|
44 #define XEMACS_CLASS "XEmacs"
|
|
45
|
|
46 #define XEMACS_CONTROL_CLASS "XEmacsControl"
|
|
47
|
|
48 /*
|
442
|
49 * Consoles
|
428
|
50 */
|
|
51
|
|
52 DECLARE_CONSOLE_TYPE (mswindows);
|
|
53
|
|
54 struct mswindows_console
|
|
55 {
|
|
56 int infd, outfd;
|
|
57 };
|
|
58
|
440
|
59 DECLARE_CONSOLE_TYPE (msprinter);
|
428
|
60
|
|
61 /*
|
442
|
62 * Printer settings, aka devmode
|
|
63 */
|
|
64
|
|
65 typedef struct Lisp_Devmode
|
|
66 {
|
|
67 struct lcrecord_header header;
|
|
68
|
|
69 /* Pointer to the DEVMODE structure */
|
|
70 DEVMODE* devmode;
|
|
71
|
|
72 /* Full printer name. It can be longer than devmode->dmDeviceName
|
|
73 can accommodate, so need to keep it separately */
|
|
74 char* printer_name;
|
|
75
|
|
76 /* Printer device this object is currently selected in, or Qnil
|
|
77 if not selected */
|
|
78 Lisp_Object device;
|
|
79
|
|
80 } Lisp_Devmode;
|
|
81
|
|
82
|
|
83 DECLARE_LRECORD (devmode, Lisp_Devmode);
|
|
84 #define XDEVMODE(x) XRECORD (x, devmode, Lisp_Devmode)
|
|
85 #define XSETDEVMODE(x, p) XSETRECORD (x, p, devmode)
|
|
86 #define DEVMODEP(x) RECORDP (x, devmode)
|
|
87 #define CHECK_DEVMODE(x) CHECK_RECORD (x, devmode)
|
|
88 #define CONCHECK_DEVMODE(x) CONCHECK_RECORD (x, devmode)
|
|
89
|
|
90 #define DEVMODE_SIZE(dm) ((dm)->dmSize + (dm)->dmDriverExtra)
|
|
91 #define XDEVMODE_SIZE(x) ((x)->devmode ? DEVMODE_SIZE((x)->devmode) : 0)
|
|
92
|
|
93 /*
|
|
94 * Devices
|
428
|
95 */
|
|
96
|
|
97 #define MSW_FONTSIZE (LF_FACESIZE*4+12)
|
|
98
|
|
99 struct mswindows_device
|
|
100 {
|
440
|
101 Lisp_Object fontlist; /* List of strings, device fonts */
|
442
|
102 HDC hcdc; /* Compatible DC */
|
|
103 DWORD update_tick; /* Used when device is modified through
|
|
104 Windows messages, see WM_DISPLAYCHANGE
|
|
105 in event-msw.c */
|
428
|
106 };
|
|
107
|
|
108 #define DEVICE_MSWINDOWS_DATA(d) DEVICE_TYPE_DATA (d, mswindows)
|
442
|
109 #define DEVICE_MSWINDOWS_FONTLIST(d) (DEVICE_MSWINDOWS_DATA (d)->fontlist)
|
|
110 #define DEVICE_MSWINDOWS_HCDC(d) (DEVICE_MSWINDOWS_DATA (d)->hcdc)
|
|
111 #define DEVICE_MSWINDOWS_UPDATE_TICK(d) (DEVICE_MSWINDOWS_DATA (d)->update_tick)
|
428
|
112
|
440
|
113 struct msprinter_device
|
|
114 {
|
442
|
115 HDC hdc, hcdc; /* Printer and the comp. DCs */
|
440
|
116 HANDLE hprinter;
|
442
|
117 char* name;
|
|
118 Lisp_Object devmode;
|
440
|
119 Lisp_Object fontlist;
|
|
120 };
|
|
121
|
|
122 #define DEVICE_MSPRINTER_DATA(d) DEVICE_TYPE_DATA (d, msprinter)
|
|
123 #define DEVICE_MSPRINTER_HDC(d) (DEVICE_MSPRINTER_DATA (d)->hdc)
|
442
|
124 #define DEVICE_MSPRINTER_HCDC(d) (DEVICE_MSPRINTER_DATA (d)->hcdc)
|
440
|
125 #define DEVICE_MSPRINTER_HPRINTER(d) (DEVICE_MSPRINTER_DATA (d)->hprinter)
|
|
126 #define DEVICE_MSPRINTER_FONTLIST(d) (DEVICE_MSPRINTER_DATA (d)->fontlist)
|
|
127 #define DEVICE_MSPRINTER_NAME(d) (DEVICE_MSPRINTER_DATA (d)->name)
|
|
128 #define DEVICE_MSPRINTER_DEVMODE(d) (DEVICE_MSPRINTER_DATA (d)->devmode)
|
|
129
|
|
130 #define CONSOLE_TYPESYM_MSPRINTER_P(typesym) EQ (typesym, Qmsprinter)
|
|
131 #define DEVICE_MSPRINTER_P(dev) CONSOLE_TYPESYM_MSPRINTER_P (DEVICE_TYPE (dev))
|
|
132 #define CHECK_MSPRINTER_DEVICE(z) CHECK_DEVICE_TYPE (z, msprinter)
|
|
133 #define CONCHECK_MSPRINTER_DEVICE(z) CONCHECK_DEVICE_TYPE (z, msprinter)
|
|
134
|
442
|
135 /* Printer functions in frame-msw.c */
|
|
136 void msprinter_start_page (struct frame *f);
|
|
137
|
|
138 /* Common checks */
|
|
139
|
|
140 #define DEVICE_MSGDI_P(dev) (DEVICE_MSWINDOWS_P(dev) || DEVICE_MSPRINTER_P(dev))
|
|
141 #define CHECK_MSGDI_DEVICE(d) \
|
|
142 do { \
|
|
143 CHECK_DEVICE (d); \
|
|
144 if (!(DEVICEP (d) && DEVICE_MSGDI_P(XDEVICE(d)))) \
|
|
145 dead_wrong_type_argument \
|
|
146 (list3 (Qor, Qmswindows, Qmsprinter), d); \
|
|
147 } while (0)
|
|
148 #define CONCHECK_MSGDI_DEVICE(d) \
|
|
149 do { \
|
|
150 CHECK_DEVICE (d); \
|
|
151 if (!(DEVICEP (d) && DEVICE_MSGDI_P(XDEVICE(d)))) \
|
|
152 wrong_type_argument \
|
|
153 (list3 (Qor, Qmswindows, Qmsprinter), d); \
|
|
154 } while (0)
|
428
|
155
|
|
156 /*
|
442
|
157 * Frames
|
428
|
158 */
|
|
159 typedef struct
|
|
160 {
|
|
161 int left;
|
|
162 int top;
|
|
163 int width;
|
|
164 int height;
|
|
165 } XEMACS_RECT_WH;
|
|
166
|
|
167 struct mswindows_frame
|
|
168 {
|
|
169 /* win32 window handle */
|
|
170 HWND hwnd;
|
|
171
|
|
172 /* DC for this win32 window */
|
|
173 HDC hdc;
|
|
174
|
442
|
175 /* Used with DeferWindowPos */
|
|
176 HDWP hdwp;
|
428
|
177
|
|
178 /* Time of last click event, for button 2 emul */
|
|
179 DWORD last_click_time;
|
|
180
|
442
|
181 /* Mods of last click event */
|
|
182 DWORD last_click_mods;
|
|
183
|
428
|
184 /* Coordinates of last click event, screen-relative */
|
|
185 POINTS last_click_point;
|
|
186 #ifdef HAVE_TOOLBARS
|
|
187 /* Toolbar hash table. See toolbar-msw.c */
|
|
188 Lisp_Object toolbar_hash_table;
|
|
189 unsigned int toolbar_checksum[4];
|
|
190 #endif
|
|
191
|
|
192 /* Menu hash table. See menubar-msw.c */
|
|
193 Lisp_Object menu_hash_table;
|
|
194
|
|
195 /* Menu checksum. See menubar-msw.c */
|
|
196 unsigned int menu_checksum;
|
|
197
|
|
198 /* Widget glyphs attached to this frame. See glyphs-msw.c */
|
442
|
199 Lisp_Object widget_hash_table1, widget_hash_table2, widget_hash_table3;
|
428
|
200
|
|
201 /* Frame title hash value. See frame-msw.c */
|
|
202 unsigned int title_checksum;
|
|
203
|
|
204 /* Real character width and height of the frame.
|
|
205 FRAME_{HEIGHT,WIDTH} do not work for pixel geometry! */
|
|
206 int charheight, charwidth;
|
|
207
|
|
208 /* Misc flags */
|
|
209 int button2_need_lbutton : 1;
|
|
210 int button2_need_rbutton : 1;
|
|
211 int button2_is_down : 1;
|
|
212 int ignore_next_lbutton_up : 1;
|
|
213 int ignore_next_rbutton_up : 1;
|
|
214 int sizing : 1;
|
442
|
215 int paint_pending : 1; /* Whether a WM_PAINT magic event has been queued */
|
|
216 int popup : 1; /* frame is a popup frame */
|
428
|
217
|
|
218 /* Geometry, in characters, as specified by proplist during frame
|
442
|
219 creation. Members are set to -1 for unspecified */
|
428
|
220 XEMACS_RECT_WH* target_rect;
|
|
221 };
|
|
222
|
|
223 #define FRAME_MSWINDOWS_DATA(f) FRAME_TYPE_DATA (f, mswindows)
|
|
224
|
|
225 #define FRAME_MSWINDOWS_HANDLE(f) (FRAME_MSWINDOWS_DATA (f)->hwnd)
|
|
226 #define FRAME_MSWINDOWS_DC(f) (FRAME_MSWINDOWS_DATA (f)->hdc)
|
|
227 #define FRAME_MSWINDOWS_MENU_HASH_TABLE(f) (FRAME_MSWINDOWS_DATA (f)->menu_hash_table)
|
|
228 #define FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f) \
|
|
229 (FRAME_MSWINDOWS_DATA (f)->toolbar_hash_table)
|
442
|
230 #define FRAME_MSWINDOWS_WIDGET_HASH_TABLE1(f) \
|
|
231 (FRAME_MSWINDOWS_DATA (f)->widget_hash_table1)
|
|
232 #define FRAME_MSWINDOWS_WIDGET_HASH_TABLE2(f) \
|
|
233 (FRAME_MSWINDOWS_DATA (f)->widget_hash_table2)
|
|
234 #define FRAME_MSWINDOWS_WIDGET_HASH_TABLE3(f) \
|
|
235 (FRAME_MSWINDOWS_DATA (f)->widget_hash_table3)
|
428
|
236 #define FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos) \
|
|
237 (FRAME_MSWINDOWS_DATA (f)->toolbar_checksum[pos])
|
|
238 #define FRAME_MSWINDOWS_MENU_CHECKSUM(f) (FRAME_MSWINDOWS_DATA (f)->menu_checksum)
|
|
239 #define FRAME_MSWINDOWS_TITLE_CHECKSUM(f) (FRAME_MSWINDOWS_DATA (f)->title_checksum)
|
|
240 #define FRAME_MSWINDOWS_CHARWIDTH(f) (FRAME_MSWINDOWS_DATA (f)->charwidth)
|
|
241 #define FRAME_MSWINDOWS_CHARHEIGHT(f) (FRAME_MSWINDOWS_DATA (f)->charheight)
|
|
242 #define FRAME_MSWINDOWS_TARGET_RECT(f) (FRAME_MSWINDOWS_DATA (f)->target_rect)
|
442
|
243 #define FRAME_MSWINDOWS_POPUP(f) (FRAME_MSWINDOWS_DATA (f)->popup)
|
428
|
244
|
|
245 /* Frame check and validation macros */
|
|
246 #define FRAME_MSWINDOWS_P(frm) CONSOLE_TYPESYM_MSWINDOWS_P (FRAME_TYPE (frm))
|
|
247 #define CHECK_MSWINDOWS_FRAME(z) CHECK_FRAME_TYPE (z, mswindows)
|
|
248 #define CONCHECK_MSWINDOWS_FRAME(z) CONCHECK_FRAME_TYPE (z, mswindows)
|
|
249
|
|
250 /* win32 window LONG indices */
|
|
251 #define XWL_FRAMEOBJ 0
|
|
252 #define XWL_COUNT 1 /* Number of LONGs that we use */
|
|
253 #define MSWINDOWS_WINDOW_EXTRA_BYTES (XWL_COUNT*4)
|
|
254
|
440
|
255 /*
|
|
256 * Printer frame, aka printer job
|
|
257 */
|
|
258
|
|
259 struct msprinter_frame
|
|
260 {
|
|
261 int left_margin, top_margin, /* All in twips */
|
|
262 right_margin, bottom_margin;
|
442
|
263 int charheight, charwidth; /* As per proplist or -1 if not given */
|
|
264 int pix_left, pix_top; /* Calculated in init_frame_*, VP offset */
|
440
|
265 int job_started : 1;
|
442
|
266 int page_started : 1;
|
440
|
267 };
|
|
268
|
|
269 #define FRAME_MSPRINTER_DATA(f) FRAME_TYPE_DATA (f, msprinter)
|
|
270 #define FRAME_MSPRINTER_LEFT_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->left_margin)
|
|
271 #define FRAME_MSPRINTER_RIGHT_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->top_margin)
|
|
272 #define FRAME_MSPRINTER_TOP_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->right_margin)
|
|
273 #define FRAME_MSPRINTER_BOTTOM_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->bottom_margin)
|
|
274 #define FRAME_MSPRINTER_JOB_STARTED(f) (FRAME_MSPRINTER_DATA (f)->job_started)
|
442
|
275 #define FRAME_MSPRINTER_PAGE_STARTED(f) (FRAME_MSPRINTER_DATA (f)->page_started)
|
440
|
276 #define FRAME_MSPRINTER_CHARWIDTH(f) (FRAME_MSPRINTER_DATA (f)->charheight)
|
|
277 #define FRAME_MSPRINTER_CHARHEIGHT(f) (FRAME_MSPRINTER_DATA (f)->charwidth)
|
442
|
278 #define FRAME_MSPRINTER_PIXLEFT(f) (FRAME_MSPRINTER_DATA (f)->pix_left)
|
|
279 #define FRAME_MSPRINTER_PIXTOP(f) (FRAME_MSPRINTER_DATA (f)->pix_top)
|
428
|
280
|
|
281 /*
|
|
282 * Events
|
|
283 */
|
|
284
|
|
285 /* win32 messages / magic event types */
|
|
286 #define EVENT_MSWINDOWS_MAGIC_TYPE(e) \
|
|
287 ((e)->event.magic.underlying_mswindows_event)
|
|
288 #define XM_BUMPQUEUE (WM_USER + 101)
|
|
289 #define XM_MAPFRAME (WM_USER + 102)
|
|
290 #define XM_UNMAPFRAME (WM_USER + 103)
|
|
291
|
|
292
|
|
293 /*
|
|
294 * Random globals
|
|
295 */
|
|
296
|
|
297 /* win32 "Windows" procedure */
|
|
298 LRESULT WINAPI mswindows_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam,
|
|
299 LPARAM lParam);
|
|
300 LRESULT WINAPI mswindows_control_wnd_proc (HWND hwnd,
|
|
301 UINT msg, WPARAM wParam,
|
|
302 LPARAM lParam);
|
|
303
|
442
|
304 void mswindows_redraw_exposed_area (struct frame *f, int x, int y,
|
428
|
305 int width, int height);
|
|
306 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest);
|
442
|
307 HWND mswindows_get_selected_frame_hwnd (void);
|
440
|
308 void mswindows_enqueue_magic_event (HWND hwnd, UINT msg);
|
442
|
309 int mswindows_is_dialog_msg (MSG *msg);
|
428
|
310
|
|
311 /* win32 DDE management library */
|
|
312 #define MSWINDOWS_DDE_ITEM_OPEN "Open"
|
|
313 extern DWORD mswindows_dde_mlid;
|
|
314 extern HSZ mswindows_dde_service;
|
|
315 extern HSZ mswindows_dde_topic_system;
|
|
316 extern HSZ mswindows_dde_item_open;
|
|
317 HDDEDATA CALLBACK mswindows_dde_callback (UINT uType, UINT uFmt, HCONV hconv,
|
442
|
318 HSZ hszTopic, HSZ hszItem,
|
|
319 HDDEDATA hdata,
|
428
|
320 DWORD dwData1, DWORD dwData2);
|
|
321
|
442
|
322 void mswindows_enqueue_dispatch_event (Lisp_Object event);
|
428
|
323 void mswindows_enqueue_misc_user_event (Lisp_Object channel,
|
|
324 Lisp_Object function,
|
|
325 Lisp_Object object);
|
440
|
326 Lisp_Object mswindows_cancel_dispatch_event (Lisp_Event* event);
|
428
|
327 Lisp_Object mswindows_pump_outstanding_events (void);
|
442
|
328 Lisp_Object mswindows_protect_modal_loop (Lisp_Object (*bfun)
|
|
329 (Lisp_Object barg),
|
428
|
330 Lisp_Object barg);
|
|
331 void mswindows_unmodalize_signal_maybe (void);
|
|
332
|
442
|
333 COLORREF mswindows_string_to_color (const char *name);
|
440
|
334 USID emacs_mswindows_create_stream_pair (void* inhandle, void* outhandle,
|
|
335 Lisp_Object* instream,
|
|
336 Lisp_Object* outstream,
|
|
337 int flags);
|
|
338 USID emacs_mswindows_delete_stream_pair (Lisp_Object instream,
|
|
339 Lisp_Object outstream);
|
|
340
|
428
|
341 #ifdef HAVE_WIN32_PROCESSES
|
440
|
342 HANDLE get_nt_process_handle (Lisp_Process *p);
|
428
|
343 #endif
|
|
344
|
|
345 extern Lisp_Object Vmswindows_frame_being_created;
|
|
346 extern Lisp_Object mswindows_frame_being_created;
|
|
347
|
442
|
348 void mswindows_get_workspace_coords (RECT *rc);
|
|
349
|
|
350 HWND mswindows_get_console_hwnd (void);
|
|
351 void mswindows_hide_console (void);
|
|
352 void mswindows_show_console (void);
|
|
353 int mswindows_output_console_string (CONST Extbyte *str, Extcount len);
|
|
354
|
440
|
355 Lisp_Object mswindows_enumerate_fonts (HDC hdc);
|
428
|
356
|
442
|
357 int mswindows_char_is_accelerator (struct frame *f, Emchar ch);
|
|
358 Bytecount mswindows_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
|
|
359 Bytecount maxlen, Emchar *accel,
|
|
360 Lisp_Object error_name);
|
|
361
|
|
362 #ifdef HAVE_TOOLBARS
|
440
|
363 Lisp_Object mswindows_get_toolbar_button_text (struct frame* f,
|
|
364 int command_id);
|
|
365 Lisp_Object mswindows_handle_toolbar_wm_command (struct frame* f,
|
|
366 HWND ctrl, WORD id);
|
442
|
367 #endif
|
440
|
368 Lisp_Object mswindows_handle_gui_wm_command (struct frame* f,
|
442
|
369 HWND ctrl, LPARAM id);
|
|
370
|
|
371 int mswindows_windows9x_p (void);
|
|
372
|
|
373 void mswindows_output_last_error (char *frob);
|
|
374
|
|
375 Lisp_Object mswindows_handle_print_dialog_box (struct frame *f,
|
|
376 Lisp_Object keys);
|
|
377 Lisp_Object mswindows_handle_page_setup_dialog_box (struct frame *f,
|
|
378 Lisp_Object keys);
|
506
|
379 int mswindows_get_default_margin (Lisp_Object prop);
|
442
|
380
|
|
381 void mswindows_register_popup_frame (Lisp_Object frame);
|
|
382 void mswindows_unregister_popup_frame (Lisp_Object frame);
|
|
383
|
|
384 void mswindows_destroy_selection (Lisp_Object selection);
|
|
385
|
|
386 Lisp_Object msprinter_default_printer (void);
|
|
387
|
546
|
388 Lisp_Object mswindows_find_frame (HWND hwnd);
|
|
389
|
442
|
390 struct mswindows_dialog_id
|
|
391 {
|
|
392 struct lcrecord_header header;
|
|
393
|
|
394 Lisp_Object frame;
|
|
395 Lisp_Object callbacks;
|
|
396 HWND hwnd;
|
|
397 };
|
|
398
|
|
399 DECLARE_LRECORD (mswindows_dialog_id, struct mswindows_dialog_id);
|
|
400 #define XMSWINDOWS_DIALOG_ID(x) XRECORD (x, mswindows_dialog_id, struct mswindows_dialog_id)
|
|
401 #define XSETMSWINDOWS_DIALOG_ID(x, p) XSETRECORD (x, p, mswindows_dialog_id)
|
|
402 #define MSWINDOWS_DIALOG_IDP(x) RECORDP (x, mswindows_dialog_id)
|
|
403 #define CHECK_MSWINDOWS_DIALOG_ID(x) CHECK_RECORD (x, mswindows_dialog_id)
|
|
404 #define CONCHECK_MSWINDOWS_DIALOG_ID(x) CONCHECK_RECORD (x, mswindows_dialog_id)
|
440
|
405
|
|
406 #endif /* INCLUDED_console_msw_h_ */
|