213
|
1 /* Device functions for mswindows.
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
|
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 /* Authorship:
|
|
25
|
|
26 Original authors: Jamie Zawinski and the FSF
|
|
27 Rewritten by Ben Wing and Chuck Thompson.
|
|
28 Rewritten for mswindows by Jonathan Harris, November 1997 for 20.4.
|
|
29 */
|
|
30
|
|
31
|
|
32 #include <config.h>
|
|
33 #include "lisp.h"
|
|
34
|
|
35 #include "console-msw.h"
|
|
36 #include "console-stream.h"
|
|
37 #include "events.h"
|
|
38 #include "faces.h"
|
|
39 #include "frame.h"
|
249
|
40 #include "sysdep.h"
|
|
41
|
|
42 /* win32 DDE management library globals */
|
|
43 DWORD mswindows_dde_mlid;
|
|
44 HSZ mswindows_dde_service;
|
|
45 HSZ mswindows_dde_topic_system;
|
|
46 HSZ mswindows_dde_item_open;
|
213
|
47
|
|
48 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win;
|
|
49
|
|
50 static void
|
|
51 mswindows_init_device (struct device *d, Lisp_Object props)
|
|
52 {
|
249
|
53 WNDCLASSEX wc;
|
213
|
54 HWND desktop;
|
|
55 HDC hdc;
|
|
56
|
|
57 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
|
|
58 init_baud_rate (d);
|
|
59 init_one_device (d);
|
|
60
|
|
61 d->device_data = xnew_and_zero (struct mswindows_device);
|
|
62
|
|
63 desktop = GetDesktopWindow();
|
|
64 hdc = GetDC(desktop);
|
|
65 DEVICE_MSWINDOWS_LOGPIXELSX(d) = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
66 DEVICE_MSWINDOWS_LOGPIXELSY(d) = GetDeviceCaps(hdc, LOGPIXELSY);
|
|
67 DEVICE_MSWINDOWS_PLANES(d) = GetDeviceCaps(hdc, PLANES);
|
|
68 /* FIXME: Only valid if RC_PALETTE bit set in RASTERCAPS,
|
|
69 what should we return for a non-palette-based device? */
|
|
70 DEVICE_MSWINDOWS_CELLS(d) = GetDeviceCaps(hdc, SIZEPALETTE);
|
|
71 DEVICE_MSWINDOWS_HORZRES(d) = GetDeviceCaps(hdc, HORZRES);
|
|
72 DEVICE_MSWINDOWS_VERTRES(d) = GetDeviceCaps(hdc, VERTRES);
|
|
73 DEVICE_MSWINDOWS_HORZSIZE(d) = GetDeviceCaps(hdc, HORZSIZE);
|
|
74 DEVICE_MSWINDOWS_VERTSIZE(d) = GetDeviceCaps(hdc, VERTSIZE);
|
|
75 ReleaseDC(desktop, hdc);
|
|
76
|
217
|
77 DEVICE_CLASS(d) = Qcolor;
|
223
|
78
|
|
79 /* Register the main window class */
|
249
|
80 wc.cbSize = sizeof (WNDCLASSEX);
|
223
|
81 wc.style = CS_OWNDC; /* One DC per window */
|
|
82 wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc;
|
|
83 wc.cbClsExtra = 0;
|
|
84 wc.cbWndExtra = MSWINDOWS_WINDOW_EXTRA_BYTES;
|
|
85 wc.hInstance = NULL; /* ? */
|
227
|
86 wc.hIcon = LoadIcon (GetModuleHandle(NULL), XEMACS_CLASS);
|
223
|
87 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
|
88 /* Background brush is only used during sizing, when XEmacs cannot
|
|
89 take over */
|
|
90 wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);
|
|
91 wc.lpszMenuName = NULL;
|
|
92 wc.lpszClassName = XEMACS_CLASS;
|
249
|
93 wc.hIconSm = LoadImage (GetModuleHandle (NULL), XEMACS_CLASS,
|
|
94 IMAGE_ICON, 16, 16, 0);
|
|
95 RegisterClassEx (&wc);
|
|
96 }
|
|
97
|
|
98 static void
|
|
99 mswindows_finish_init_device (struct device *d, Lisp_Object props)
|
|
100 {
|
|
101 /* Initialise DDE management library and our related globals */
|
|
102 mswindows_dde_mlid = 0;
|
|
103 DdeInitialize (&mswindows_dde_mlid, mswindows_dde_callback,
|
|
104 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|CBF_FAIL_ADVISES|
|
|
105 CBF_FAIL_POKES|CBF_FAIL_REQUESTS|CBF_SKIP_ALLNOTIFICATIONS, 0);
|
|
106
|
|
107 mswindows_dde_service = DdeCreateStringHandle (mswindows_dde_mlid, XEMACS_CLASS, 0);
|
|
108 mswindows_dde_topic_system = DdeCreateStringHandle (mswindows_dde_mlid, SZDDESYS_TOPIC, 0);
|
|
109 mswindows_dde_item_open = DdeCreateStringHandle (mswindows_dde_mlid,
|
|
110 TEXT(MSWINDOWS_DDE_ITEM_OPEN), 0);
|
|
111 DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER);
|
|
112 }
|
|
113
|
|
114 static void
|
|
115 mswindows_delete_device (struct device *d)
|
|
116 {
|
|
117 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_REGISTER);
|
|
118 DdeUninitialize (mswindows_dde_mlid);
|
213
|
119 }
|
|
120
|
|
121 static int
|
|
122 mswindows_device_pixel_width (struct device *d)
|
|
123 {
|
|
124 return(DEVICE_MSWINDOWS_HORZRES(d));
|
|
125 }
|
|
126
|
|
127 static int
|
|
128 mswindows_device_pixel_height (struct device *d)
|
|
129 {
|
|
130 return(DEVICE_MSWINDOWS_VERTRES(d));
|
|
131 }
|
|
132
|
|
133 static int
|
|
134 mswindows_device_mm_width (struct device *d)
|
|
135 {
|
|
136 return(DEVICE_MSWINDOWS_HORZSIZE(d));
|
|
137 }
|
|
138
|
|
139 static int
|
|
140 mswindows_device_mm_height (struct device *d)
|
|
141 {
|
|
142 return(DEVICE_MSWINDOWS_VERTSIZE(d));
|
|
143 }
|
|
144
|
|
145 static int
|
|
146 mswindows_device_bitplanes (struct device *d)
|
|
147 {
|
|
148 return(DEVICE_MSWINDOWS_PLANES(d));
|
|
149 }
|
|
150
|
|
151 static int
|
|
152 mswindows_device_color_cells (struct device *d)
|
|
153 {
|
|
154 return(DEVICE_MSWINDOWS_CELLS(d));
|
|
155 }
|
|
156
|
|
157
|
|
158 /************************************************************************/
|
|
159 /* initialization */
|
|
160 /************************************************************************/
|
|
161
|
|
162 void
|
|
163 syms_of_device_mswindows (void)
|
|
164 {
|
|
165 defsymbol (&Qinit_pre_mswindows_win, "init-pre-mswindows-win");
|
|
166 defsymbol (&Qinit_post_mswindows_win, "init-post-mswindows-win");
|
|
167 }
|
|
168
|
|
169 void
|
|
170 console_type_create_device_mswindows (void)
|
|
171 {
|
|
172 CONSOLE_HAS_METHOD (mswindows, init_device);
|
249
|
173 CONSOLE_HAS_METHOD (mswindows, finish_init_device);
|
213
|
174 /* CONSOLE_HAS_METHOD (mswindows, mark_device); */
|
249
|
175 CONSOLE_HAS_METHOD (mswindows, delete_device);
|
213
|
176 CONSOLE_HAS_METHOD (mswindows, device_pixel_width);
|
|
177 CONSOLE_HAS_METHOD (mswindows, device_pixel_height);
|
|
178 CONSOLE_HAS_METHOD (mswindows, device_mm_width);
|
|
179 CONSOLE_HAS_METHOD (mswindows, device_mm_height);
|
|
180 CONSOLE_HAS_METHOD (mswindows, device_bitplanes);
|
|
181 CONSOLE_HAS_METHOD (mswindows, device_color_cells);
|
|
182 }
|
|
183
|
|
184 void
|
|
185 vars_of_device_mswindows (void)
|
|
186 {
|
|
187 }
|