comparison src/device-msw.c @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c42ec1d1cded
children e11d67e05968
comparison
equal deleted inserted replaced
283:fa3d41851a08 284:558f606b08ae
42 #ifndef __CYGWIN32__ 42 #ifndef __CYGWIN32__
43 #include <commctrl.h> 43 #include <commctrl.h>
44 #endif 44 #endif
45 45
46 /* win32 DDE management library globals */ 46 /* win32 DDE management library globals */
47 #ifdef HAVE_DRAGNDROP
47 DWORD mswindows_dde_mlid; 48 DWORD mswindows_dde_mlid;
48 HSZ mswindows_dde_service; 49 HSZ mswindows_dde_service;
49 HSZ mswindows_dde_topic_system; 50 HSZ mswindows_dde_topic_system;
50 HSZ mswindows_dde_item_open; 51 HSZ mswindows_dde_item_open;
52 #endif
51 53
52 /* Control conversion of upper case file names to lower case. 54 /* Control conversion of upper case file names to lower case.
53 nil means no, t means yes. */ 55 nil means no, t means yes. */
54 Lisp_Object Vmswindows_downcase_file_names; 56 Lisp_Object Vmswindows_downcase_file_names;
55 57
113 } 115 }
114 116
115 static void 117 static void
116 mswindows_finish_init_device (struct device *d, Lisp_Object props) 118 mswindows_finish_init_device (struct device *d, Lisp_Object props)
117 { 119 {
118 /* Initialise DDE management library and our related globals */ 120 /* Initialise DDE management library and our related globals. We execute a
121 * dde Open("file") by simulating a drop, so this depends on dnd support. */
122 #ifdef HAVE_DRAGNDROP
119 mswindows_dde_mlid = 0; 123 mswindows_dde_mlid = 0;
120 DdeInitialize (&mswindows_dde_mlid, (PFNCALLBACK)mswindows_dde_callback, 124 DdeInitialize (&mswindows_dde_mlid, (PFNCALLBACK)mswindows_dde_callback,
121 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|CBF_FAIL_ADVISES| 125 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|CBF_FAIL_ADVISES|
122 CBF_FAIL_POKES|CBF_FAIL_REQUESTS|CBF_SKIP_ALLNOTIFICATIONS, 0); 126 CBF_FAIL_POKES|CBF_FAIL_REQUESTS|CBF_SKIP_ALLNOTIFICATIONS, 0);
123 127
124 mswindows_dde_service = DdeCreateStringHandle (mswindows_dde_mlid, XEMACS_CLASS, 0); 128 mswindows_dde_service = DdeCreateStringHandle (mswindows_dde_mlid, XEMACS_CLASS, 0);
125 mswindows_dde_topic_system = DdeCreateStringHandle (mswindows_dde_mlid, SZDDESYS_TOPIC, 0); 129 mswindows_dde_topic_system = DdeCreateStringHandle (mswindows_dde_mlid, SZDDESYS_TOPIC, 0);
126 mswindows_dde_item_open = DdeCreateStringHandle (mswindows_dde_mlid, 130 mswindows_dde_item_open = DdeCreateStringHandle (mswindows_dde_mlid,
127 TEXT(MSWINDOWS_DDE_ITEM_OPEN), 0); 131 TEXT(MSWINDOWS_DDE_ITEM_OPEN), 0);
128 DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER); 132 DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER);
133 #endif
129 } 134 }
130 135
131 static void 136 static void
132 mswindows_delete_device (struct device *d) 137 mswindows_delete_device (struct device *d)
133 { 138 {
139 #ifdef HAVE_DRAGNDROP
134 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_REGISTER); 140 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_REGISTER);
135 DdeUninitialize (mswindows_dde_mlid); 141 DdeUninitialize (mswindows_dde_mlid);
142 #endif
143 }
144
145 static Lisp_Object
146 build_syscolor_string (int index)
147 {
148 DWORD clr;
149 char buf[16];
150
151 if (index < 0)
152 return Qnil;
153
154 clr = GetSysColor (index);
155 sprintf (buf, "#%02X%02X%02X",
156 GetRValue (clr),
157 GetGValue (clr),
158 GetBValue (clr));
159 return build_string (buf);
160 }
161
162 static Lisp_Object
163 build_syscolor_cons (int index1, int index2)
164 {
165 Lisp_Object color1, color2;
166 struct gcpro gcpro1;
167 GCPRO1 (color1);
168 color1 = build_syscolor_string (index1);
169 color2 = build_syscolor_string (index2);
170 RETURN_UNGCPRO (Fcons (color1, color2));
171 }
172
173 static Lisp_Object
174 build_sysmetrics_cons (int index1, int index2)
175 {
176 return Fcons (index1 < 0 ? Qnil : make_int (GetSystemMetrics (index1)),
177 index2 < 0 ? Qnil : make_int (GetSystemMetrics (index2)));
136 } 178 }
137 179
138 static Lisp_Object 180 static Lisp_Object
139 mswindows_device_system_metrics (struct device *d, 181 mswindows_device_system_metrics (struct device *d,
140 enum device_metrics m) 182 enum device_metrics m)
141 { 183 {
142 switch (m) 184 switch (m)
143 { 185 {
144 case size_device: 186 case DM_size_device:
145 return Fcons (make_int (DEVICE_MSWINDOWS_HORZRES(d)), 187 return Fcons (make_int (DEVICE_MSWINDOWS_HORZRES(d)),
146 make_int (DEVICE_MSWINDOWS_VERTRES(d))); 188 make_int (DEVICE_MSWINDOWS_VERTRES(d)));
147 break; 189 break;
148 case size_device_mm: 190 case DM_size_device_mm:
149 return Fcons (make_int (DEVICE_MSWINDOWS_HORZSIZE(d)), 191 return Fcons (make_int (DEVICE_MSWINDOWS_HORZSIZE(d)),
150 make_int (DEVICE_MSWINDOWS_VERTSIZE(d))); 192 make_int (DEVICE_MSWINDOWS_VERTSIZE(d)));
151 break; 193 break;
152 case num_bit_planes: 194 case DM_num_bit_planes:
153 return make_int (DEVICE_MSWINDOWS_PLANES(d)); 195 return make_int (DEVICE_MSWINDOWS_PLANES(d));
154 break; 196 break;
155 case num_color_cells: 197 case DM_num_color_cells:
156 return make_int (DEVICE_MSWINDOWS_CELLS(d)); 198 return make_int (DEVICE_MSWINDOWS_CELLS(d));
157 break; 199 break;
200
201 /*** Colors ***/
202 #define FROB(met, index1, index2) \
203 case DM_##met: \
204 return build_syscolor_cons (index1, index2);
205
206 FROB (color_default, COLOR_WINDOW, COLOR_WINDOWTEXT);
207 FROB (color_select, COLOR_HIGHLIGHT, COLOR_HIGHLIGHTTEXT);
208 FROB (color_balloon, COLOR_INFOBK, COLOR_INFOTEXT);
209 FROB (color_3d_face, COLOR_3DFACE, COLOR_BTNTEXT);
210 FROB (color_3d_light, COLOR_3DLIGHT, COLOR_3DHILIGHT);
211 FROB (color_3d_dark, COLOR_3DSHADOW, COLOR_3DDKSHADOW);
212 FROB (color_menu, COLOR_MENU, COLOR_MENUTEXT);
213 FROB (color_menu_highlight, COLOR_HIGHLIGHT, COLOR_HIGHLIGHTTEXT);
214 FROB (color_menu_button, COLOR_MENU, COLOR_MENUTEXT);
215 FROB (color_menu_disabled, COLOR_MENU, COLOR_GRAYTEXT);
216 FROB (color_toolbar, COLOR_BTNFACE, COLOR_BTNTEXT);
217 FROB (color_scrollbar, COLOR_SCROLLBAR, COLOR_CAPTIONTEXT);
218 FROB (color_desktop, -1, COLOR_DESKTOP);
219 FROB (color_workspace, -1, COLOR_APPWORKSPACE);
220 #undef FROB
221
222 /*** Sizes ***/
223 #define FROB(met, index1, index2) \
224 case DM_##met: \
225 return build_sysmetrics_cons (index1, index2);
226
227 FROB (size_cursor, SM_CXCURSOR, SM_CYCURSOR);
228 FROB (size_scrollbar, SM_CXVSCROLL, SM_CYHSCROLL);
229 FROB (size_menu, -1, SM_CYMENU);
230 FROB (size_icon, SM_CXICON, SM_CYICON);
231 FROB (size_icon_small, SM_CXSMICON, SM_CYSMICON);
232 #undef FROB
233
234 case DM_size_workspace:
235 {
236 RECT rc;
237 SystemParametersInfo (SPI_GETWORKAREA, 0, &rc, 0);
238 return Fcons (make_int (rc.right - rc.left),
239 make_int (rc.bottom - rc.top));
240 }
241 /*
242 case DM_size_toolbar:
243 case DM_size_toolbar_button:
244 case DM_size_toolbar_border:
245 */
246
247 /*** Features ***/
248 #define FROB(met, index) \
249 case DM_##met: \
250 return make_int (GetSystemMetrics (index));
251
252 FROB (mouse_buttons, SM_CMOUSEBUTTONS);
253 FROB (swap_buttons, SM_SWAPBUTTON);
254 FROB (show_sounds, SM_SHOWSOUNDS);
255 FROB (slow_device, SM_SLOWMACHINE);
256 FROB (security, SM_SECURE);
257 #undef FROB
258
158 } 259 }
159 260
160 /* Do not know such property */ 261 /* Do not know such property */
161 return Qnil; 262 return Qunbound;
162 } 263 }
163 264
164 static unsigned int 265 static unsigned int
165 mswindows_device_implementation_flags (void) 266 mswindows_device_implementation_flags (void)
166 { 267 {