comparison src/objects-msw.c @ 286:57709be46d1b r21-0b41

Import from CVS: tag r21-0b41
author cvs
date Mon, 13 Aug 2007 10:35:03 +0200
parents c42ec1d1cded
children e11d67e05968
comparison
equal deleted inserted replaced
285:9a3756523c1b 286:57709be46d1b
813 color = mswindows_string_to_color(extname); 813 color = mswindows_string_to_color(extname);
814 if (color != -1) 814 if (color != -1)
815 { 815 {
816 c->data = xnew (struct mswindows_color_instance_data); 816 c->data = xnew (struct mswindows_color_instance_data);
817 COLOR_INSTANCE_MSWINDOWS_COLOR (c) = color; 817 COLOR_INSTANCE_MSWINDOWS_COLOR (c) = color;
818 COLOR_INSTANCE_MSWINDOWS_BRUSH (c) = CreateSolidBrush (color);
819 return 1; 818 return 1;
820 } 819 }
821 maybe_signal_simple_error ("unrecognized color", name, Qcolor, errb); 820 maybe_signal_simple_error ("unrecognized color", name, Qcolor, errb);
822 return(0); 821 return(0);
823 } 822 }
845 static void 844 static void
846 mswindows_finalize_color_instance (struct Lisp_Color_Instance *c) 845 mswindows_finalize_color_instance (struct Lisp_Color_Instance *c)
847 { 846 {
848 if (c->data) 847 if (c->data)
849 { 848 {
850 DeleteObject (COLOR_INSTANCE_MSWINDOWS_BRUSH (c));
851 xfree (c->data); 849 xfree (c->data);
852 c->data = 0; 850 c->data = 0;
853 } 851 }
854 } 852 }
855 853
911 909
912 /* 910 /*
913 * mswindows fonts look like: 911 * mswindows fonts look like:
914 * fontname[:[weight ][style][:pointsize[:effects[:charset]]]] 912 * fontname[:[weight ][style][:pointsize[:effects[:charset]]]]
915 * The font name field shouldn't be empty. 913 * The font name field shouldn't be empty.
916 * XXX Windows will substitute a default (monospace) font if the font name 914 * #### Windows will substitute a default (monospace) font if the font name
917 * specifies a non-existent font. We don't catch this. 915 * specifies a non-existent font. We don't catch this.
918 * effects and charset are currently ignored. 916 * effects and charset are currently ignored.
919 * 917 *
920 * ie: 918 * ie:
921 * Lucida Console:Regular:10 919 * Lucida Console:Regular:10
1003 } 1001 }
1004 } 1002 }
1005 1003
1006 if (style) 1004 if (style)
1007 { 1005 {
1008 /* XXX what about oblique? */ 1006 /* #### what about oblique? */
1009 if (stricmp (style,"italic") == 0) 1007 if (stricmp (style,"italic") == 0)
1010 logfont.lfItalic = TRUE; 1008 logfont.lfItalic = TRUE;
1011 else if (stricmp (style,"roman") == 0) 1009 else if (stricmp (style,"roman") == 0)
1012 logfont.lfItalic = FALSE; 1010 logfont.lfItalic = FALSE;
1013 else 1011 else
1026 { 1024 {
1027 logfont.lfWeight = FW_NORMAL; 1025 logfont.lfWeight = FW_NORMAL;
1028 logfont.lfItalic = FALSE; 1026 logfont.lfItalic = FALSE;
1029 } 1027 }
1030 1028
1031 /* XXX Should we reject strings that don't specify a size? */ 1029 /* #### Should we reject strings that don't specify a size? */
1032 if (fields < 3 || !strlen(points) || (pt=atoi(points))==0) 1030 if (fields < 3 || !strlen(points) || (pt=atoi(points))==0)
1033 pt = 10; 1031 pt = 10;
1034 1032
1035 /* Formula for pointsize->height from LOGFONT docs in MSVC5 Platform SDK */ 1033 /* Formula for pointsize->height from LOGFONT docs in MSVC5 Platform SDK */
1036 logfont.lfHeight = -MulDiv(pt, DEVICE_MSWINDOWS_LOGPIXELSY(XDEVICE (device)), 72); 1034 logfont.lfHeight = -MulDiv(pt, DEVICE_MSWINDOWS_LOGPIXELSY(XDEVICE (device)), 72);
1037 logfont.lfWidth = 0; 1035 logfont.lfWidth = 0;
1038 1036
1039 /* Default to monospaced if the specified font name is not found */ 1037 /* Default to monospaced if the specified font name is not found */
1040 logfont.lfPitchAndFamily = FF_MODERN; 1038 logfont.lfPitchAndFamily = FF_MODERN;
1041 1039
1042 /* XXX: FIXME? */ 1040 /* ####: FIXME? */
1043 logfont.lfUnderline = FALSE; 1041 logfont.lfUnderline = FALSE;
1044 logfont.lfStrikeOut = FALSE; 1042 logfont.lfStrikeOut = FALSE;
1045 1043
1046 /* XXX: FIXME: we ignore charset */ 1044
1047 logfont.lfCharSet = DEFAULT_CHARSET; 1045 #define FROB(cs) \
1048 1046 else if (stricmp (charset, #cs) == 0) \
1047 logfont.lfCharSet = cs##_CHARSET
1048
1049 /* Charset aliases. Hangeul = Hangul is defined in windows.h.
1050 We do not use the name "russian", only "cyrillic", as it is
1051 the common name of this charset, used in other languages
1052 than Russian. */
1053 #define CYRILLIC_CHARSET RUSSIAN_CHARSET
1054 #define CENTRALEUROPEAN_CHARSET EASTEUROPE_CHARSET
1055
1056 if (fields > 4)
1057 {
1058 if (charset[0] == '\0' || stricmp (charset, "ansi") == 0)
1059 logfont.lfCharSet = ANSI_CHARSET;
1060 FROB (DEFAULT); /* #### Should we alow this? */
1061 FROB (SYMBOL);
1062 FROB (SHIFTJIS);
1063 FROB (GB2312);
1064 FROB (HANGEUL);
1065 FROB (CHINESEBIG5);
1066 FROB (OEM);
1067 FROB (JOHAB);
1068 FROB (HEBREW);
1069 FROB (ARABIC);
1070 FROB (GREEK);
1071 FROB (TURKISH);
1072 FROB (THAI);
1073 FROB (EASTEUROPE);
1074 FROB (CENTRALEUROPEAN);
1075 FROB (CYRILLIC);
1076 FROB (MAC);
1077 FROB (BALTIC);
1078 else
1079 {
1080 maybe_signal_simple_error ("Invalid charset name", f->name, Qfont, errb);
1081 return 0;
1082 }
1083 }
1084 else
1085 logfont.lfCharSet = ANSI_CHARSET;
1086
1087 #undef FROB
1088
1049 /* Misc crud */ 1089 /* Misc crud */
1050 logfont.lfEscapement = logfont.lfOrientation = 0; 1090 logfont.lfEscapement = logfont.lfOrientation = 0;
1051 #if 1 1091 #if 1
1052 logfont.lfOutPrecision = OUT_DEFAULT_PRECIS; 1092 logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
1053 logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; 1093 logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1109 } 1149 }
1110 1150
1111 static Lisp_Object 1151 static Lisp_Object
1112 mswindows_list_fonts (Lisp_Object pattern, Lisp_Object device) 1152 mswindows_list_fonts (Lisp_Object pattern, Lisp_Object device)
1113 { 1153 {
1114 /* XXX Implement me */ 1154 /* #### Implement me */
1115 return list1 (build_string ("Courier New:Regular:10")); 1155 return list1 (build_string ("Courier New:Regular:10"));
1116 } 1156 }
1117 1157
1118 #ifdef MULE 1158 #ifdef MULE
1119 1159
1120 static int 1160 static int
1121 mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset, 1161 mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset,
1122 CONST Bufbyte *nonreloc, Lisp_Object reloc, 1162 CONST Bufbyte *nonreloc, Lisp_Object reloc,
1123 Bytecount offset, Bytecount length) 1163 Bytecount offset, Bytecount length)
1124 { 1164 {
1125 /* XXX Implement me */ 1165 /* #### Implement me */
1126 if (UNBOUNDP (charset)) 1166 if (UNBOUNDP (charset))
1127 return 1; 1167 return 1;
1128 1168
1129 return 1; 1169 return 1;
1130 } 1170 }
1133 (the registry of) CHARSET. */ 1173 (the registry of) CHARSET. */
1134 static Lisp_Object 1174 static Lisp_Object
1135 mswindows_find_charset_font (Lisp_Object device, Lisp_Object font, 1175 mswindows_find_charset_font (Lisp_Object device, Lisp_Object font,
1136 Lisp_Object charset) 1176 Lisp_Object charset)
1137 { 1177 {
1138 /* XXX Implement me */ 1178 /* #### Implement me */
1139 return build_string ("Courier New:Regular:10"); 1179 return build_string ("Courier New:Regular:10");
1140 } 1180 }
1141 1181
1142 #endif /* MULE */ 1182 #endif /* MULE */
1143 1183