Mercurial > hg > xemacs-beta
comparison src/device-msw.c @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 7347b34c275b |
children | 6240c7796c7a |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
36 #include "console-stream.h" | 36 #include "console-stream.h" |
37 #include "events.h" | 37 #include "events.h" |
38 #include "faces.h" | 38 #include "faces.h" |
39 #include "frame.h" | 39 #include "frame.h" |
40 #include "sysdep.h" | 40 #include "sysdep.h" |
41 | |
42 #ifndef __CYGWIN32__ | |
43 #include <commctrl.h> | |
44 #else | |
45 #define FONTENUMPROC FONTENUMEXPROC | |
46 #define ntmTm ntmentm | |
47 #endif | |
41 | 48 |
42 /* win32 DDE management library globals */ | 49 /* win32 DDE management library globals */ |
43 #ifdef HAVE_DRAGNDROP | 50 #ifdef HAVE_DRAGNDROP |
44 DWORD mswindows_dde_mlid; | 51 DWORD mswindows_dde_mlid; |
45 HSZ mswindows_dde_service; | 52 HSZ mswindows_dde_service; |
56 are supported on NTFS volumes, this is only relevant on NT. */ | 63 are supported on NTFS volumes, this is only relevant on NT. */ |
57 Lisp_Object Vmswindows_get_true_file_attributes; | 64 Lisp_Object Vmswindows_get_true_file_attributes; |
58 | 65 |
59 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win; | 66 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win; |
60 | 67 |
68 struct font_enum_t | |
69 { | |
70 HDC hdc; | |
71 struct device *d; | |
72 }; | |
73 | |
61 | 74 |
62 /************************************************************************/ | 75 /************************************************************************/ |
63 /* helpers */ | 76 /* helpers */ |
64 /************************************************************************/ | 77 /************************************************************************/ |
78 | |
79 static int CALLBACK | |
80 font_enum_callback_2 (ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, | |
81 int FontType, struct font_enum_t *font_enum) | |
82 { | |
83 struct mswindows_font_enum *fontlist, **fonthead; | |
84 char fontname[MSW_FONTSIZE]; | |
85 | |
86 /* The enumerated font weights are not to be trusted because: | |
87 * a) lpelfe->elfStyle is only filled in for TrueType fonts. | |
88 * b) Not all Bold and Italic styles of all fonts (inluding some Vector, | |
89 * Truetype and Raster fonts) are enumerated. | |
90 * I guess that fonts for which Bold and Italic styles are generated | |
91 * 'on-the-fly' are not enumerated. It would be overly restrictive to | |
92 * disallow Bold And Italic weights for these fonts, so we just leave | |
93 * weights unspecified. This means that we have to weed out duplicates of | |
94 * those fonts that do get enumerated with different weights. */ | |
95 | |
96 if (FontType == 0 /*vector*/ || FontType == TRUETYPE_FONTTYPE) | |
97 /* Scalable, so leave pointsize blank */ | |
98 sprintf (fontname, "%s::::%s", lpelfe->elfLogFont.lfFaceName, | |
99 lpelfe->elfScript); | |
100 else | |
101 /* Formula for pointsize->height from LOGFONT docs in Platform SDK */ | |
102 sprintf (fontname, "%s::%d::%s", lpelfe->elfLogFont.lfFaceName, | |
103 MulDiv (lpntme->ntmTm.tmHeight - lpntme->ntmTm.tmInternalLeading, | |
104 72, DEVICE_MSWINDOWS_LOGPIXELSY (font_enum->d)), | |
105 lpelfe->elfScript); | |
106 | |
107 fonthead = &DEVICE_MSWINDOWS_FONTLIST (font_enum->d); | |
108 fontlist = *fonthead; | |
109 while (fontlist) | |
110 if (!strcmp (fontname, fontlist->fontname)) | |
111 return 1; /* found a duplicate */ | |
112 else | |
113 fontlist = fontlist->next; | |
114 | |
115 /* Insert entry at head */ | |
116 fontlist = *fonthead; | |
117 *fonthead = xmalloc (sizeof (struct mswindows_font_enum)); | |
118 if (*fonthead == NULL) | |
119 { | |
120 *fonthead = fontlist; | |
121 return 0; | |
122 } | |
123 strcpy ((*fonthead)->fontname, fontname); | |
124 (*fonthead)->next = fontlist; | |
125 return 1; | |
126 } | |
127 | |
128 static int CALLBACK | |
129 font_enum_callback_1 (ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, | |
130 int FontType, struct font_enum_t *font_enum) | |
131 { | |
132 /* This function gets called once per facename per character set. | |
133 * We call a second callback to enumerate the fonts in each facename */ | |
134 return EnumFontFamiliesEx (font_enum->hdc, &lpelfe->elfLogFont, | |
135 (FONTENUMPROC) font_enum_callback_2, | |
136 (LPARAM) font_enum, 0); | |
137 } | |
65 | 138 |
66 static Lisp_Object | 139 static Lisp_Object |
67 build_syscolor_string (int index) | 140 build_syscolor_string (int index) |
68 { | 141 { |
69 DWORD clr; | 142 DWORD clr; |
107 static void | 180 static void |
108 mswindows_init_device (struct device *d, Lisp_Object props) | 181 mswindows_init_device (struct device *d, Lisp_Object props) |
109 { | 182 { |
110 WNDCLASSEX wc; | 183 WNDCLASSEX wc; |
111 HDC hdc; | 184 HDC hdc; |
185 LOGFONT logfont; | |
186 struct font_enum_t font_enum; | |
112 | 187 |
113 DEVICE_CLASS (d) = Qcolor; | 188 DEVICE_CLASS (d) = Qcolor; |
114 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; | 189 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; |
115 init_baud_rate (d); | 190 init_baud_rate (d); |
116 init_one_device (d); | 191 init_one_device (d); |
127 DEVICE_MSWINDOWS_HORZRES(d) = GetDeviceCaps(hdc, HORZRES); | 202 DEVICE_MSWINDOWS_HORZRES(d) = GetDeviceCaps(hdc, HORZRES); |
128 DEVICE_MSWINDOWS_VERTRES(d) = GetDeviceCaps(hdc, VERTRES); | 203 DEVICE_MSWINDOWS_VERTRES(d) = GetDeviceCaps(hdc, VERTRES); |
129 DEVICE_MSWINDOWS_HORZSIZE(d) = GetDeviceCaps(hdc, HORZSIZE); | 204 DEVICE_MSWINDOWS_HORZSIZE(d) = GetDeviceCaps(hdc, HORZSIZE); |
130 DEVICE_MSWINDOWS_VERTSIZE(d) = GetDeviceCaps(hdc, VERTSIZE); | 205 DEVICE_MSWINDOWS_VERTSIZE(d) = GetDeviceCaps(hdc, VERTSIZE); |
131 DEVICE_MSWINDOWS_BITSPIXEL(d) = GetDeviceCaps(hdc, BITSPIXEL); | 206 DEVICE_MSWINDOWS_BITSPIXEL(d) = GetDeviceCaps(hdc, BITSPIXEL); |
207 | |
208 DEVICE_MSWINDOWS_FONTLIST (d) = NULL; | |
209 logfont.lfCharSet = DEFAULT_CHARSET; | |
210 logfont.lfFaceName[0] = '\0'; | |
211 logfont.lfPitchAndFamily = DEFAULT_PITCH; | |
212 font_enum.hdc = hdc; | |
213 font_enum.d = d; | |
214 EnumFontFamiliesEx (hdc, &logfont, (FONTENUMPROC) font_enum_callback_1, | |
215 (LPARAM) (&font_enum), 0); | |
132 DeleteDC (hdc); | 216 DeleteDC (hdc); |
133 | |
134 mswindows_enumerate_fonts (d); | |
135 | 217 |
136 /* Register the main window class */ | 218 /* Register the main window class */ |
137 wc.cbSize = sizeof (WNDCLASSEX); | 219 wc.cbSize = sizeof (WNDCLASSEX); |
138 wc.style = CS_OWNDC; /* One DC per window */ | 220 wc.style = CS_OWNDC; /* One DC per window */ |
139 wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc; | 221 wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc; |
187 free (fontlist); | 269 free (fontlist); |
188 fontlist = next; | 270 fontlist = next; |
189 } | 271 } |
190 | 272 |
191 #ifdef HAVE_DRAGNDROP | 273 #ifdef HAVE_DRAGNDROP |
192 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_UNREGISTER); | 274 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_REGISTER); |
193 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_item_open); | |
194 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_topic_system); | |
195 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_service); | |
196 DdeUninitialize (mswindows_dde_mlid); | 275 DdeUninitialize (mswindows_dde_mlid); |
197 #endif | 276 #endif |
198 | 277 |
199 free (d->device_data); | 278 free (d->device_data); |
200 } | 279 } |
301 void | 380 void |
302 syms_of_device_mswindows (void) | 381 syms_of_device_mswindows (void) |
303 { | 382 { |
304 defsymbol (&Qinit_pre_mswindows_win, "init-pre-mswindows-win"); | 383 defsymbol (&Qinit_pre_mswindows_win, "init-pre-mswindows-win"); |
305 defsymbol (&Qinit_post_mswindows_win, "init-post-mswindows-win"); | 384 defsymbol (&Qinit_post_mswindows_win, "init-post-mswindows-win"); |
385 | |
386 DEFVAR_LISP ("mswindows-downcase-file-names", &Vmswindows_downcase_file_names /* | |
387 Non-nil means convert all-upper case file names to lower case. | |
388 This applies when performing completions and file name expansion.*/ ); | |
389 Vmswindows_downcase_file_names = Qnil; | |
390 | |
391 DEFVAR_LISP ("mswindows-get-true-file-attributes", &Vmswindows_get_true_file_attributes /* | |
392 "Non-nil means determine accurate link count in file-attributes. | |
393 This option slows down file-attributes noticeably, so is disabled by | |
394 default. Note that it is only useful for files on NTFS volumes, | |
395 where hard links are supported. | |
396 */ ); | |
397 Vmswindows_get_true_file_attributes = Qnil; | |
306 } | 398 } |
307 | 399 |
308 void | 400 void |
309 console_type_create_device_mswindows (void) | 401 console_type_create_device_mswindows (void) |
310 { | 402 { |
317 } | 409 } |
318 | 410 |
319 void | 411 void |
320 vars_of_device_mswindows (void) | 412 vars_of_device_mswindows (void) |
321 { | 413 { |
322 DEFVAR_LISP ("mswindows-downcase-file-names", &Vmswindows_downcase_file_names /* | 414 } |
323 Non-nil means convert all-upper case file names to lower case. | |
324 This applies when performing completions and file name expansion. | |
325 */ ); | |
326 Vmswindows_downcase_file_names = Qnil; | |
327 | |
328 DEFVAR_LISP ("mswindows-get-true-file-attributes", &Vmswindows_get_true_file_attributes /* | |
329 Non-nil means determine accurate link count in file-attributes. | |
330 This option slows down file-attributes noticeably, so is disabled by | |
331 default. Note that it is only useful for files on NTFS volumes, | |
332 where hard links are supported. | |
333 */ ); | |
334 Vmswindows_get_true_file_attributes = Qnil; | |
335 } |