249
|
1 /* Define mswindows-specific console, device, and frame object for XEmacs.
|
213
|
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.
|
272
|
29 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
|
213
|
30 */
|
|
31
|
398
|
32 #ifndef INCLUDED_console_msw_h_
|
|
33 #define INCLUDED_console_msw_h_
|
213
|
34
|
|
35 #include "console.h"
|
286
|
36 #include <windows.h>
|
|
37 #include <ddeml.h> /* DDE management library */
|
398
|
38 #if !defined(__CYGWIN32__) && !defined(__MINGW32__) \
|
|
39 || CYGWIN_VERSION_DLL_MAJOR > 20
|
286
|
40 #include <shellapi.h> /* FileManager/Explorer drag and drop */
|
|
41 #include <commctrl.h>
|
276
|
42 #endif
|
|
43
|
|
44 #ifdef HAVE_XPM
|
|
45 #include <X11/xpm.h>
|
251
|
46 #endif
|
249
|
47
|
|
48 /* The name of the main window class */
|
|
49 #define XEMACS_CLASS "XEmacs"
|
|
50
|
398
|
51 #define XEMACS_CONTROL_CLASS "XEmacsControl"
|
249
|
52
|
|
53 /*
|
|
54 * Console
|
|
55 */
|
213
|
56
|
|
57 DECLARE_CONSOLE_TYPE (mswindows);
|
|
58
|
|
59 struct mswindows_console
|
|
60 {
|
|
61 int infd, outfd;
|
|
62 };
|
|
63
|
398
|
64 DECLARE_CONSOLE_TYPE (msprinter);
|
213
|
65
|
249
|
66 /*
|
|
67 * Device
|
|
68 */
|
|
69
|
294
|
70 #define MSW_FONTSIZE (LF_FACESIZE*4+12)
|
|
71
|
213
|
72 struct mswindows_device
|
|
73 {
|
|
74 int logpixelsx, logpixelsy;
|
|
75 int planes, cells;
|
|
76 int horzres, vertres; /* Size in pixels */
|
|
77 int horzsize, vertsize; /* Size in mm */
|
267
|
78 int bitspixel;
|
398
|
79 Lisp_Object fontlist; /* List of strings, device fonts */
|
404
|
80 HDC hcdc; /* Compatible DC */
|
213
|
81 };
|
|
82
|
|
83 #define DEVICE_MSWINDOWS_DATA(d) DEVICE_TYPE_DATA (d, mswindows)
|
|
84 #define DEVICE_MSWINDOWS_LOGPIXELSX(d) (DEVICE_MSWINDOWS_DATA (d)->logpixelsx)
|
|
85 #define DEVICE_MSWINDOWS_LOGPIXELSY(d) (DEVICE_MSWINDOWS_DATA (d)->logpixelsy)
|
|
86 #define DEVICE_MSWINDOWS_PLANES(d) (DEVICE_MSWINDOWS_DATA (d)->planes)
|
|
87 #define DEVICE_MSWINDOWS_CELLS(d) (DEVICE_MSWINDOWS_DATA (d)->cells)
|
|
88 #define DEVICE_MSWINDOWS_HORZRES(d) (DEVICE_MSWINDOWS_DATA (d)->horzres)
|
|
89 #define DEVICE_MSWINDOWS_VERTRES(d) (DEVICE_MSWINDOWS_DATA (d)->vertres)
|
|
90 #define DEVICE_MSWINDOWS_HORZSIZE(d) (DEVICE_MSWINDOWS_DATA (d)->horzsize)
|
|
91 #define DEVICE_MSWINDOWS_VERTSIZE(d) (DEVICE_MSWINDOWS_DATA (d)->vertsize)
|
267
|
92 #define DEVICE_MSWINDOWS_BITSPIXEL(d) (DEVICE_MSWINDOWS_DATA (d)->bitspixel)
|
294
|
93 #define DEVICE_MSWINDOWS_FONTLIST(d) (DEVICE_MSWINDOWS_DATA (d)->fontlist)
|
404
|
94 #define DEVICE_MSWINDOWS_HCDC(d) (DEVICE_MSWINDOWS_DATA (d)->hcdc)
|
213
|
95
|
398
|
96 struct msprinter_device
|
|
97 {
|
404
|
98 HDC hdc, hcdc; /* Printer and the comp. DCs */
|
398
|
99 HANDLE hprinter;
|
|
100 Lisp_Object fontlist;
|
|
101 char* name;
|
|
102 DEVMODE *devmode, *devmode_mirror;
|
|
103 size_t devmode_size;
|
|
104 };
|
|
105
|
|
106 #define DEVICE_MSPRINTER_DATA(d) DEVICE_TYPE_DATA (d, msprinter)
|
|
107 #define DEVICE_MSPRINTER_HDC(d) (DEVICE_MSPRINTER_DATA (d)->hdc)
|
404
|
108 #define DEVICE_MSPRINTER_HCDC(d) (DEVICE_MSPRINTER_DATA (d)->hcdc)
|
398
|
109 #define DEVICE_MSPRINTER_HPRINTER(d) (DEVICE_MSPRINTER_DATA (d)->hprinter)
|
|
110 #define DEVICE_MSPRINTER_FONTLIST(d) (DEVICE_MSPRINTER_DATA (d)->fontlist)
|
|
111 #define DEVICE_MSPRINTER_NAME(d) (DEVICE_MSPRINTER_DATA (d)->name)
|
|
112 #define DEVICE_MSPRINTER_DEVMODE(d) (DEVICE_MSPRINTER_DATA (d)->devmode)
|
|
113 #define DEVICE_MSPRINTER_DEVMODE_MIRROR(d) \
|
|
114 (DEVICE_MSPRINTER_DATA (d)->devmode_mirror)
|
|
115 #define DEVICE_MSPRINTER_DEVMODE_SIZE(d) \
|
|
116 (DEVICE_MSPRINTER_DATA (d)->devmode_size)
|
|
117
|
|
118 #define CONSOLE_TYPESYM_MSPRINTER_P(typesym) EQ (typesym, Qmsprinter)
|
|
119 #define DEVICE_MSPRINTER_P(dev) CONSOLE_TYPESYM_MSPRINTER_P (DEVICE_TYPE (dev))
|
|
120 #define CHECK_MSPRINTER_DEVICE(z) CHECK_DEVICE_TYPE (z, msprinter)
|
|
121 #define CONCHECK_MSPRINTER_DEVICE(z) CONCHECK_DEVICE_TYPE (z, msprinter)
|
|
122
|
|
123 /* Printer functions in device-msw.c */
|
|
124 DEVMODE* msprinter_get_devmode_copy (struct device *d);
|
|
125 void msprinter_apply_devmode (struct device *d, DEVMODE *devmode);
|
|
126
|
|
127 /* Printer functions in frame-msw.c */
|
|
128 void msprinter_start_page (struct frame *f);
|
213
|
129
|
404
|
130 /* Common checks */
|
|
131
|
|
132 #define DEVICE_MSGDI_P(dev) (DEVICE_MSWINDOWS_P(dev) || DEVICE_MSPRINTER_P(dev))
|
|
133 #define CHECK_MSGDI_DEVICE(d) \
|
|
134 do { \
|
|
135 CHECK_DEVICE (d); \
|
|
136 if (!(DEVICEP (d) && DEVICE_MSGDI_P(XDEVICE(d)))) \
|
|
137 dead_wrong_type_argument \
|
|
138 (list3 (Qor, Qmswindows, Qmsprinter), d); \
|
|
139 } while (0)
|
|
140 #define CONCHECK_MSGDI_DEVICE(d) \
|
|
141 do { \
|
|
142 CHECK_DEVICE (d); \
|
|
143 if (!(DEVICEP (d) && DEVICE_MSGDI_P(XDEVICE(d)))) \
|
|
144 wrong_type_argument \
|
|
145 (list3 (Qor, Qmswindows, Qmsprinter), d); \
|
|
146 } while (0)
|
|
147
|
249
|
148 /*
|
|
149 * Frame
|
|
150 */
|
294
|
151 typedef struct
|
|
152 {
|
|
153 int left;
|
|
154 int top;
|
|
155 int width;
|
|
156 int height;
|
|
157 } XEMACS_RECT_WH;
|
249
|
158
|
213
|
159 struct mswindows_frame
|
|
160 {
|
|
161 /* win32 window handle */
|
|
162 HWND hwnd;
|
|
163
|
|
164 /* DC for this win32 window */
|
|
165 HDC hdc;
|
223
|
166
|
|
167 /* Time of last click event, for button 2 emul */
|
|
168 DWORD last_click_time;
|
|
169
|
|
170 /* Coordinates of last click event, screen-relative */
|
|
171 POINTS last_click_point;
|
276
|
172 #ifdef HAVE_TOOLBARS
|
380
|
173 /* Toolbar hash table. See toolbar-msw.c */
|
|
174 Lisp_Object toolbar_hash_table;
|
278
|
175 unsigned int toolbar_checksum[4];
|
276
|
176 #endif
|
223
|
177
|
380
|
178 /* Menu hash table. See menubar-msw.c */
|
|
179 Lisp_Object menu_hash_table;
|
233
|
180
|
|
181 /* Menu checksum. See menubar-msw.c */
|
|
182 unsigned int menu_checksum;
|
231
|
183
|
384
|
184 /* Widget glyphs attached to this frame. See glyphs-msw.c */
|
406
|
185 Lisp_Object widget_hash_table1, widget_hash_table2, widget_hash_table3;
|
384
|
186
|
274
|
187 /* Frame title hash value. See frame-msw.c */
|
|
188 unsigned int title_checksum;
|
|
189
|
269
|
190 /* Real character width and height of the frame.
|
|
191 FRAME_{HEIGHT,WIDTH} do not work for pixel geometry! */
|
|
192 int charheight, charwidth;
|
|
193
|
223
|
194 /* Misc flags */
|
|
195 int button2_need_lbutton : 1;
|
|
196 int button2_need_rbutton : 1;
|
|
197 int button2_is_down : 1;
|
|
198 int ignore_next_lbutton_up : 1;
|
|
199 int ignore_next_rbutton_up : 1;
|
|
200 int sizing : 1;
|
404
|
201 int paint_pending : 1; /* Whether a WM_PAINT magic event has been queued */
|
294
|
202
|
|
203 /* Geometry, in characters, as specified by proplist during frame
|
|
204 creation. Memebers are set to -1 for unspecified */
|
|
205 XEMACS_RECT_WH* target_rect;
|
213
|
206 };
|
|
207
|
|
208 #define FRAME_MSWINDOWS_DATA(f) FRAME_TYPE_DATA (f, mswindows)
|
|
209
|
380
|
210 #define FRAME_MSWINDOWS_HANDLE(f) (FRAME_MSWINDOWS_DATA (f)->hwnd)
|
|
211 #define FRAME_MSWINDOWS_DC(f) (FRAME_MSWINDOWS_DATA (f)->hdc)
|
|
212 #define FRAME_MSWINDOWS_MENU_HASH_TABLE(f) (FRAME_MSWINDOWS_DATA (f)->menu_hash_table)
|
|
213 #define FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f) \
|
|
214 (FRAME_MSWINDOWS_DATA (f)->toolbar_hash_table)
|
406
|
215 #define FRAME_MSWINDOWS_WIDGET_HASH_TABLE1(f) \
|
|
216 (FRAME_MSWINDOWS_DATA (f)->widget_hash_table1)
|
|
217 #define FRAME_MSWINDOWS_WIDGET_HASH_TABLE2(f) \
|
|
218 (FRAME_MSWINDOWS_DATA (f)->widget_hash_table2)
|
|
219 #define FRAME_MSWINDOWS_WIDGET_HASH_TABLE3(f) \
|
|
220 (FRAME_MSWINDOWS_DATA (f)->widget_hash_table3)
|
278
|
221 #define FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos) \
|
|
222 (FRAME_MSWINDOWS_DATA (f)->toolbar_checksum[pos])
|
233
|
223 #define FRAME_MSWINDOWS_MENU_CHECKSUM(f) (FRAME_MSWINDOWS_DATA (f)->menu_checksum)
|
274
|
224 #define FRAME_MSWINDOWS_TITLE_CHECKSUM(f) (FRAME_MSWINDOWS_DATA (f)->title_checksum)
|
|
225 #define FRAME_MSWINDOWS_CHARWIDTH(f) (FRAME_MSWINDOWS_DATA (f)->charwidth)
|
|
226 #define FRAME_MSWINDOWS_CHARHEIGHT(f) (FRAME_MSWINDOWS_DATA (f)->charheight)
|
294
|
227 #define FRAME_MSWINDOWS_TARGET_RECT(f) (FRAME_MSWINDOWS_DATA (f)->target_rect)
|
269
|
228
|
|
229 /* Frame check and validation macros */
|
|
230 #define FRAME_MSWINDOWS_P(frm) CONSOLE_TYPESYM_MSWINDOWS_P (FRAME_TYPE (frm))
|
|
231 #define CHECK_MSWINDOWS_FRAME(z) CHECK_FRAME_TYPE (z, mswindows)
|
|
232 #define CONCHECK_MSWINDOWS_FRAME(z) CONCHECK_FRAME_TYPE (z, mswindows)
|
213
|
233
|
249
|
234 /* win32 window LONG indices */
|
|
235 #define XWL_FRAMEOBJ 0
|
|
236 #define XWL_COUNT 1 /* Number of LONGs that we use */
|
|
237 #define MSWINDOWS_WINDOW_EXTRA_BYTES (XWL_COUNT*4)
|
|
238
|
398
|
239 /*
|
|
240 * Printer frame, aka printer job
|
|
241 */
|
|
242
|
|
243 struct msprinter_frame
|
|
244 {
|
|
245 int left_margin, top_margin, /* All in twips */
|
|
246 right_margin, bottom_margin;
|
|
247 int charheight, charwidth; /* As per proplist or -1 if not gven */
|
|
248 Lisp_Object orientation, duplex; /* nil for printer's default */
|
|
249 int job_started : 1;
|
|
250 int page_started : 1;
|
|
251 };
|
|
252
|
|
253 #define FRAME_MSPRINTER_DATA(f) FRAME_TYPE_DATA (f, msprinter)
|
|
254 #define FRAME_MSPRINTER_LEFT_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->left_margin)
|
|
255 #define FRAME_MSPRINTER_RIGHT_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->top_margin)
|
|
256 #define FRAME_MSPRINTER_TOP_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->right_margin)
|
|
257 #define FRAME_MSPRINTER_BOTTOM_MARGIN(f) (FRAME_MSPRINTER_DATA (f)->bottom_margin)
|
|
258 #define FRAME_MSPRINTER_JOB_STARTED(f) (FRAME_MSPRINTER_DATA (f)->job_started)
|
|
259 #define FRAME_MSPRINTER_PAGE_STARTED(f) (FRAME_MSPRINTER_DATA (f)->page_started)
|
|
260 #define FRAME_MSPRINTER_ORIENTATION(f) (FRAME_MSPRINTER_DATA (f)->orientation)
|
|
261 #define FRAME_MSPRINTER_DUPLEX(f) (FRAME_MSPRINTER_DATA (f)->duplex)
|
|
262 #define FRAME_MSPRINTER_CHARWIDTH(f) (FRAME_MSPRINTER_DATA (f)->charheight)
|
|
263 #define FRAME_MSPRINTER_CHARHEIGHT(f) (FRAME_MSPRINTER_DATA (f)->charwidth)
|
249
|
264
|
213
|
265 /*
|
249
|
266 * Events
|
|
267 */
|
|
268
|
|
269 /* win32 messages / magic event types */
|
|
270 #define EVENT_MSWINDOWS_MAGIC_TYPE(e) \
|
|
271 ((e)->event.magic.underlying_mswindows_event)
|
|
272 #define XM_BUMPQUEUE (WM_USER + 101)
|
|
273 #define XM_MAPFRAME (WM_USER + 102)
|
|
274 #define XM_UNMAPFRAME (WM_USER + 103)
|
|
275
|
|
276
|
|
277 /*
|
|
278 * Random globals
|
213
|
279 */
|
249
|
280
|
|
281 /* win32 "Windows" procedure */
|
|
282 LRESULT WINAPI mswindows_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam,
|
|
283 LPARAM lParam);
|
398
|
284 LRESULT WINAPI mswindows_control_wnd_proc (HWND hwnd,
|
|
285 UINT msg, WPARAM wParam,
|
|
286 LPARAM lParam);
|
249
|
287
|
213
|
288 void mswindows_redraw_exposed_area (struct frame *f, int x, int y,
|
249
|
289 int width, int height);
|
294
|
290 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest);
|
398
|
291 void mswindows_enqueue_magic_event (HWND hwnd, UINT msg);
|
249
|
292
|
|
293 /* win32 DDE management library */
|
|
294 #define MSWINDOWS_DDE_ITEM_OPEN "Open"
|
|
295 extern DWORD mswindows_dde_mlid;
|
|
296 extern HSZ mswindows_dde_service;
|
|
297 extern HSZ mswindows_dde_topic_system;
|
|
298 extern HSZ mswindows_dde_item_open;
|
|
299 HDDEDATA CALLBACK mswindows_dde_callback (UINT uType, UINT uFmt, HCONV hconv,
|
404
|
300 HSZ hszTopic, HSZ hszItem,
|
|
301 HDDEDATA hdata,
|
249
|
302 DWORD dwData1, DWORD dwData2);
|
|
303
|
406
|
304 void mswindows_enqueue_dispatch_event (Lisp_Object event);
|
288
|
305 void mswindows_enqueue_misc_user_event (Lisp_Object channel,
|
|
306 Lisp_Object function,
|
|
307 Lisp_Object object);
|
398
|
308 Lisp_Object mswindows_cancel_dispatch_event (Lisp_Event* event);
|
249
|
309 Lisp_Object mswindows_pump_outstanding_events (void);
|
404
|
310 Lisp_Object mswindows_protect_modal_loop (Lisp_Object (*bfun)
|
|
311 (Lisp_Object barg),
|
269
|
312 Lisp_Object barg);
|
|
313 void mswindows_unmodalize_signal_maybe (void);
|
|
314
|
398
|
315 COLORREF mswindows_string_to_color (const char *name);
|
|
316 USID emacs_mswindows_create_stream_pair (void* inhandle, void* outhandle,
|
|
317 Lisp_Object* instream,
|
|
318 Lisp_Object* outstream,
|
|
319 int flags);
|
|
320 USID emacs_mswindows_delete_stream_pair (Lisp_Object instream,
|
|
321 Lisp_Object outstream);
|
|
322
|
276
|
323 #ifdef HAVE_WIN32_PROCESSES
|
398
|
324 HANDLE get_nt_process_handle (Lisp_Process *p);
|
276
|
325 #endif
|
|
326
|
|
327 extern Lisp_Object Vmswindows_frame_being_created;
|
269
|
328 extern Lisp_Object mswindows_frame_being_created;
|
213
|
329
|
404
|
330 void msw_get_workspace_coords (RECT *rc);
|
|
331
|
|
332 HWND msw_get_console_hwnd (void);
|
|
333 void msw_hide_console (void);
|
|
334 void msw_show_console (void);
|
|
335 int msw_output_console_string (CONST Extbyte *str, Extcount len);
|
|
336
|
398
|
337 Lisp_Object mswindows_enumerate_fonts (HDC hdc);
|
373
|
338
|
404
|
339 int msw_char_is_accelerator (struct frame *f, Emchar ch);
|
|
340 Bytecount msw_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
|
|
341 Bytecount maxlen, Emchar *accel,
|
|
342 Lisp_Object error_name);
|
|
343
|
|
344 #ifdef HAVE_TOOLBARS
|
398
|
345 Lisp_Object mswindows_get_toolbar_button_text (struct frame* f,
|
|
346 int command_id);
|
|
347 Lisp_Object mswindows_handle_toolbar_wm_command (struct frame* f,
|
|
348 HWND ctrl, WORD id);
|
404
|
349 #endif
|
398
|
350 Lisp_Object mswindows_handle_gui_wm_command (struct frame* f,
|
404
|
351 HWND ctrl, LPARAM id);
|
|
352
|
|
353 int msw_windows9x_p (void);
|
398
|
354
|
|
355 #endif /* INCLUDED_console_msw_h_ */
|