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.
5 This file is part of XEmacs.
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
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
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. */
22 /* Synched up with: Not in FSF. */
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.
32 #ifndef INCLUDED_console_msw_h_
33 #define INCLUDED_console_msw_h_
36 #include "syswindows.h"
37 #include "syscommctrl.h"
43 /* The name of the main window class */
44 #define XEMACS_CLASS "XEmacs"
46 #define XEMACS_CONTROL_CLASS "XEmacsControl"
52 DECLARE_CONSOLE_TYPE (mswindows);
54 struct mswindows_console
59 DECLARE_CONSOLE_TYPE (msprinter);
62 * Printer settings, aka devmode
65 typedef struct Lisp_Devmode
67 struct lcrecord_header header;
69 /* Pointer to the DEVMODE structure */
72 /* Full printer name. It can be longer than devmode->dmDeviceName
73 can accommodate, so need to keep it separately */
76 /* Printer device this object is currently selected in, or Qnil
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)
90 #define DEVMODE_SIZE(dm) ((dm)->dmSize + (dm)->dmDriverExtra)
91 #define XDEVMODE_SIZE(x) ((x)->devmode ? DEVMODE_SIZE((x)->devmode) : 0)
97 #define MSW_FONTSIZE (LF_FACESIZE*4+12)
99 struct mswindows_device
101 Lisp_Object fontlist; /* List of strings, device fonts */
102 HDC hcdc; /* Compatible DC */
103 DWORD update_tick; /* Used when device is modified through
104 Windows messages, see WM_DISPLAYCHANGE
108 #define DEVICE_MSWINDOWS_DATA(d) DEVICE_TYPE_DATA (d, mswindows)
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)
113 struct msprinter_device
115 HDC hdc, hcdc; /* Printer and the comp. DCs */
119 Lisp_Object fontlist;
122 #define DEVICE_MSPRINTER_DATA(d) DEVICE_TYPE_DATA (d, msprinter)
123 #define DEVICE_MSPRINTER_HDC(d) (DEVICE_MSPRINTER_DATA (d)->hdc)
124 #define DEVICE_MSPRINTER_HCDC(d) (DEVICE_MSPRINTER_DATA (d)->hcdc)
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)
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)
135 /* Printer functions in frame-msw.c */
136 void msprinter_start_page (struct frame *f);
140 #define DEVICE_MSGDI_P(dev) (DEVICE_MSWINDOWS_P(dev) || DEVICE_MSPRINTER_P(dev))
141 #define CHECK_MSGDI_DEVICE(d) \
144 if (!(DEVICEP (d) && DEVICE_MSGDI_P(XDEVICE(d)))) \
145 dead_wrong_type_argument \
146 (list3 (Qor, Qmswindows, Qmsprinter), d); \
148 #define CONCHECK_MSGDI_DEVICE(d) \
151 if (!(DEVICEP (d) && DEVICE_MSGDI_P(XDEVICE(d)))) \
152 wrong_type_argument \
153 (list3 (Qor, Qmswindows, Qmsprinter), d); \
167 struct mswindows_frame
169 /* win32 window handle */
172 /* DC for this win32 window */
175 /* Used with DeferWindowPos */
178 /* Time of last click event, for button 2 emul */
179 DWORD last_click_time;
181 /* Mods of last click event */
182 DWORD last_click_mods;
184 /* Coordinates of last click event, screen-relative */
185 POINTS last_click_point;
187 /* Toolbar hash table. See toolbar-msw.c */
188 Lisp_Object toolbar_hash_table;
189 unsigned int toolbar_checksum[4];
192 /* Menu hash table. See menubar-msw.c */
193 Lisp_Object menu_hash_table;
195 /* Menu checksum. See menubar-msw.c */
196 unsigned int menu_checksum;
198 /* Widget glyphs attached to this frame. See glyphs-msw.c */
199 Lisp_Object widget_hash_table1, widget_hash_table2, widget_hash_table3;
201 /* Frame title hash value. See frame-msw.c */
202 unsigned int title_checksum;
204 /* Real character width and height of the frame.
205 FRAME_{HEIGHT,WIDTH} do not work for pixel geometry! */
206 int charheight, charwidth;
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;
215 int paint_pending : 1; /* Whether a WM_PAINT magic event has been queued */
216 int popup : 1; /* frame is a popup frame */
218 /* Geometry, in characters, as specified by proplist during frame
219 creation. Members are set to -1 for unspecified */
220 XEMACS_RECT_WH* target_rect;
223 #define FRAME_MSWINDOWS_DATA(f) FRAME_TYPE_DATA (f, mswindows)
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)
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)
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)
243 #define FRAME_MSWINDOWS_POPUP(f) (FRAME_MSWINDOWS_DATA (f)->popup)
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)
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)
256 * Printer frame, aka printer job
259 struct msprinter_frame
261 int left_margin, top_margin, /* All in twips */
262 right_margin, bottom_margin;
263 int charheight, charwidth; /* As per proplist or -1 if not given */
264 int pix_left, pix_top; /* Calculated in init_frame_*, VP offset */
266 int page_started : 1;
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)
275 #define FRAME_MSPRINTER_PAGE_STARTED(f) (FRAME_MSPRINTER_DATA (f)->page_started)
276 #define FRAME_MSPRINTER_CHARWIDTH(f) (FRAME_MSPRINTER_DATA (f)->charheight)
277 #define FRAME_MSPRINTER_CHARHEIGHT(f) (FRAME_MSPRINTER_DATA (f)->charwidth)
278 #define FRAME_MSPRINTER_PIXLEFT(f) (FRAME_MSPRINTER_DATA (f)->pix_left)
279 #define FRAME_MSPRINTER_PIXTOP(f) (FRAME_MSPRINTER_DATA (f)->pix_top)
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)
297 /* win32 "Windows" procedure */
298 LRESULT WINAPI mswindows_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam,
300 LRESULT WINAPI mswindows_control_wnd_proc (HWND hwnd,
301 UINT msg, WPARAM wParam,
304 void mswindows_redraw_exposed_area (struct frame *f, int x, int y,
305 int width, int height);
306 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest);
307 HWND mswindows_get_selected_frame_hwnd (void);
308 void mswindows_enqueue_magic_event (HWND hwnd, UINT msg);
309 int mswindows_is_dialog_msg (MSG *msg);
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,
318 HSZ hszTopic, HSZ hszItem,
320 DWORD dwData1, DWORD dwData2);
322 void mswindows_enqueue_dispatch_event (Lisp_Object event);
323 void mswindows_enqueue_misc_user_event (Lisp_Object channel,
324 Lisp_Object function,
326 Lisp_Object mswindows_cancel_dispatch_event (Lisp_Event* event);
327 Lisp_Object mswindows_pump_outstanding_events (void);
328 Lisp_Object mswindows_protect_modal_loop (Lisp_Object (*bfun)
331 void mswindows_unmodalize_signal_maybe (void);
333 COLORREF mswindows_string_to_color (const char *name);
334 USID emacs_mswindows_create_stream_pair (void* inhandle, void* outhandle,
335 Lisp_Object* instream,
336 Lisp_Object* outstream,
338 USID emacs_mswindows_delete_stream_pair (Lisp_Object instream,
339 Lisp_Object outstream);
341 #ifdef HAVE_WIN32_PROCESSES
342 HANDLE get_nt_process_handle (Lisp_Process *p);
345 extern Lisp_Object Vmswindows_frame_being_created;
346 extern Lisp_Object mswindows_frame_being_created;
348 void mswindows_get_workspace_coords (RECT *rc);
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);
355 Lisp_Object mswindows_enumerate_fonts (HDC hdc);
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);
363 Lisp_Object mswindows_get_toolbar_button_text (struct frame* f,
365 Lisp_Object mswindows_handle_toolbar_wm_command (struct frame* f,
368 Lisp_Object mswindows_handle_gui_wm_command (struct frame* f,
369 HWND ctrl, LPARAM id);
371 int mswindows_windows9x_p (void);
373 void mswindows_output_last_error (char *frob);
375 Lisp_Object mswindows_handle_print_dialog_box (struct frame *f,
377 Lisp_Object mswindows_handle_page_setup_dialog_box (struct frame *f,
379 Lisp_Object mswindows_handle_print_setup_dialog_box (struct frame *f,
382 void mswindows_register_popup_frame (Lisp_Object frame);
383 void mswindows_unregister_popup_frame (Lisp_Object frame);
385 void mswindows_destroy_selection (Lisp_Object selection);
387 Lisp_Object msprinter_default_printer (void);
389 struct mswindows_dialog_id
391 struct lcrecord_header header;
394 Lisp_Object callbacks;
398 DECLARE_LRECORD (mswindows_dialog_id, struct mswindows_dialog_id);
399 #define XMSWINDOWS_DIALOG_ID(x) XRECORD (x, mswindows_dialog_id, struct mswindows_dialog_id)
400 #define XSETMSWINDOWS_DIALOG_ID(x, p) XSETRECORD (x, p, mswindows_dialog_id)
401 #define MSWINDOWS_DIALOG_IDP(x) RECORDP (x, mswindows_dialog_id)
402 #define CHECK_MSWINDOWS_DIALOG_ID(x) CHECK_RECORD (x, mswindows_dialog_id)
403 #define CONCHECK_MSWINDOWS_DIALOG_ID(x) CONCHECK_RECORD (x, mswindows_dialog_id)
405 #endif /* INCLUDED_console_msw_h_ */