Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

271 lines
8.0 KiB

  1. /*
  2. * The distinction between the desired and actual font dimensions obtained
  3. * is important in the case of TrueType fonts, in which there is no guarantee
  4. * that what you ask for is what you will get.
  5. *
  6. * Note that the correspondence between "Desired" and "Actual" is broken
  7. * whenever the user changes his display driver, because GDI uses driver
  8. * parameters to control the font rasterization.
  9. *
  10. * The SizeDesired is {0, 0} if the font is a raster font.
  11. */
  12. typedef struct {
  13. HFONT hFont;
  14. COORD Size; // font size obtained
  15. COORD SizeWant; // 0;0 if Raster font
  16. LONG Weight;
  17. LPTSTR FaceName;
  18. BYTE Family;
  19. BYTE tmCharSet;
  20. } FONT_INFO;
  21. typedef struct tagFACENODE {
  22. struct tagFACENODE *pNext;
  23. DWORD dwFlag;
  24. TCHAR atch[];
  25. } FACENODE;
  26. //
  27. // TrueType font list
  28. // This structure shares in windows\inc\wincon.w file
  29. //
  30. // we don't make bold available if BOLD_MARK is in the face name.
  31. #define BOLD_MARK (L'*')
  32. typedef struct _TT_FONT_LIST {
  33. SINGLE_LIST_ENTRY List;
  34. UINT CodePage;
  35. BOOL fDisableBold;
  36. TCHAR FaceName1[LF_FACESIZE];
  37. TCHAR FaceName2[LF_FACESIZE];
  38. } TTFONTLIST;
  39. #ifdef MAX_TITLE_LEN
  40. #undef MAX_TITLE_LEN
  41. #endif
  42. #define MAX_TITLE_LEN 256
  43. #define MAXDIMENSTRING 40 // max text in combo box
  44. #define DX_TTBITMAP 20
  45. #define DY_TTBITMAP 12
  46. #define CCH_RASTERFONTS 24
  47. #define CCH_SELECTEDFONT 30
  48. typedef struct {
  49. IShellLink * psl;
  50. LPNT_CONSOLE_PROPS lpConsole;
  51. LPNT_FE_CONSOLE_PROPS lpFEConsole;
  52. BOOL bConDirty;
  53. int xScreen;
  54. int yScreen;
  55. POINT NonClientSize;
  56. RECT WindowRect;
  57. DWORD PreviewFlags;
  58. FONT_INFO *FontInfo;
  59. ULONG FontInfoLength;
  60. ULONG NumberOfFonts;
  61. BOOL gbEnumerateFaces;
  62. BOOL gbPointSizeError;
  63. BOOL gbBold;
  64. BOOL bFontInit;
  65. BOOL bColorInit;
  66. FACENODE *gpFaceNames;
  67. TCHAR DefaultFaceName[LF_FACESIZE];
  68. LPTSTR lpFaceName;
  69. #ifndef UNICODE
  70. CHAR szFaceName[LF_FACESIZE];
  71. #endif
  72. COORD DefaultFontSize;
  73. BYTE DefaultFontFamily;
  74. ULONG DefaultFontIndex;
  75. ULONG CurrentFontIndex;
  76. LONG FontLong;
  77. int Index;
  78. BYTE ColorArray[4];
  79. TCHAR ConsoleTitle[ MAX_TITLE_LEN + 1 ];
  80. BOOL fChangeCodePage;
  81. UINT uOEMCP;
  82. SINGLE_LIST_ENTRY gTTFontList; // This list contain TTFONTLIST data.
  83. } CONSOLEPROP_DATA;
  84. // got this from wingdip.h so we don't have to compile it all
  85. #define IS_ANY_DBCS_CHARSET( CharSet ) \
  86. ( ((CharSet) == SHIFTJIS_CHARSET) ? TRUE : \
  87. ((CharSet) == HANGEUL_CHARSET) ? TRUE : \
  88. ((CharSet) == CHINESEBIG5_CHARSET) ? TRUE : \
  89. ((CharSet) == GB2312_CHARSET) ? TRUE : FALSE )
  90. #define TM_IS_TT_FONT(x) (((x) & TMPF_TRUETYPE) == TMPF_TRUETYPE)
  91. #define IS_BOLD(w) ((w) >= FW_SEMIBOLD)
  92. #define SIZE_EQUAL(s1, s2) (((s1).X == (s2).X) && ((s1).Y == (s2).Y))
  93. #define POINTS_PER_INCH 72
  94. #define MIN_PIXEL_HEIGHT 5
  95. #define MAX_PIXEL_HEIGHT 72
  96. #define CONSOLE_REGISTRY_CURRENTPAGE (L"CurrentPage")
  97. #define MAX_SCRBUF_WIDTH 9999
  98. #define MAX_SCRBUF_HEIGHT 9999
  99. #define INITIAL_FONTS 20
  100. #define FONT_INCREMENT 3
  101. #define CONSOLE_MAX_FONT_NAME_LENGTH 256
  102. #define CM_SETCOLOR (WM_USER+1)
  103. #define CM_PREVIEW_UPDATE (WM_USER+2)
  104. #define CM_PREVIEW_INIT (WM_USER+3)
  105. #define CM_COLOR_INIT (WM_USER+4)
  106. #define PREVIEW_HSCROLL 0x01
  107. #define PREVIEW_VSCROLL 0x02
  108. #define FE_ABANDONFONT 0
  109. #define FE_SKIPFONT 1
  110. #define FE_FONTOK 2
  111. #define EF_NEW 0x0001 // a newly available face
  112. #define EF_OLD 0x0002 // a previously available face
  113. #define EF_ENUMERATED 0x0004 // all sizes have been enumerated
  114. #define EF_OEMFONT 0x0008 // an OEM face
  115. #define EF_TTFONT 0x0010 // a TT face
  116. #define EF_DEFFACE 0x0020 // the default face
  117. #define EF_DBCSFONT 0x0040 // the DBCS font
  118. /* ----- Macros ----- */
  119. /*
  120. * High-level macros
  121. *
  122. * These macros handle the SendMessages that go tofrom list boxes
  123. * and combo boxes.
  124. *
  125. * The "xxx_lcb" prefix stands for leaves CritSect & "list or combo box".
  126. *
  127. * Basically, we're providing mnemonic names for what would otherwise
  128. * look like a whole slew of confusing SendMessage's.
  129. *
  130. */
  131. #define lcbRESETCONTENT(hWnd, bLB) \
  132. SendMessage(hWnd, bLB ? LB_RESETCONTENT : CB_RESETCONTENT, 0, 0L)
  133. #define lcbGETTEXT(hWnd, bLB, w) \
  134. SendMessage(hWnd, bLB ? LB_GETTEXT : CB_GETLBTEXT, w, 0L)
  135. #define lcbFINDSTRINGEXACT(hWnd, bLB, pwsz) \
  136. SendMessage(hWnd, bLB ? LB_FINDSTRINGEXACT : CB_FINDSTRINGEXACT, \
  137. (DWORD)-1, (LPARAM)pwsz)
  138. #define lcbADDSTRING(hWnd, bLB, pwsz) \
  139. SendMessage(hWnd, bLB ? LB_ADDSTRING : CB_ADDSTRING, 0, (LPARAM)pwsz)
  140. #define lcbSETITEMDATA(hWnd, bLB, w, nFont) \
  141. SendMessage(hWnd, bLB ? LB_SETITEMDATA : CB_SETITEMDATA, w, nFont)
  142. #define lcbGETITEMDATA(hWnd, bLB, w) \
  143. SendMessage(hWnd, bLB ? LB_GETITEMDATA : CB_GETITEMDATA, w, 0L)
  144. #define lcbGETCOUNT(hWnd, bLB) \
  145. SendMessage(hWnd, bLB ? LB_GETCOUNT : CB_GETCOUNT, 0, 0L)
  146. #define lcbGETCURSEL(hWnd, bLB) \
  147. SendMessage(hWnd, bLB ? LB_GETCURSEL : CB_GETCURSEL, 0, 0L)
  148. #define lcbSETCURSEL(hWnd, bLB, w) \
  149. SendMessage(hWnd, bLB ? LB_SETCURSEL : CB_SETCURSEL, w, 0L)
  150. #define NELEM(array) (sizeof(array)/sizeof(array[0]))
  151. #define AttrToRGB(Attr) (pcpd->lpConsole->ColorTable[(Attr) & 0x0F])
  152. #define ScreenTextColor(pcpd) \
  153. (AttrToRGB(LOBYTE(pcpd->lpConsole->wFillAttribute) & 0x0F))
  154. #define ScreenBkColor(pcpd) \
  155. (AttrToRGB(LOBYTE(pcpd->lpConsole->wFillAttribute >> 4)))
  156. #define PopupTextColor(pcpd) \
  157. (AttrToRGB(LOBYTE(pcpd->lpConsole->wPopupFillAttribute) & 0x0F))
  158. #define PopupBkColor(pcpd) \
  159. (AttrToRGB(LOBYTE(pcpd->lpConsole->wPopupFillAttribute >> 4)))
  160. NTSTATUS InitializeFonts( CONSOLEPROP_DATA *pcpd );
  161. STDAPI_(void) DestroyFonts( CONSOLEPROP_DATA *pcpd );
  162. NTSTATUS EnumerateFonts( CONSOLEPROP_DATA *pcpd, DWORD Flags);
  163. int FindCreateFont(
  164. CONSOLEPROP_DATA *pcpd,
  165. DWORD Family,
  166. LPTSTR ptszFace,
  167. COORD Size,
  168. LONG Weight);
  169. BOOL DoFontEnum(
  170. CONSOLEPROP_DATA *pcpd,
  171. HDC hDC,
  172. LPTSTR ptszFace,
  173. PSHORT pTTPoints,
  174. UINT nTTPoints);
  175. void GetTitleFromLinkName(LPTSTR szLinkName, LPTSTR szTitle);
  176. void SetRegistryValues(CONSOLEPROP_DATA *pcpd);
  177. void GetRegistryValues(CONSOLEPROP_DATA *pcpd);
  178. void InitRegistryValues(CONSOLEPROP_DATA *pcpd);
  179. void GetRegistryValues(CONSOLEPROP_DATA *pcpd);
  180. void SetFERegistryValues(CONSOLEPROP_DATA *pcpd);
  181. void GetFERegistryValues(CONSOLEPROP_DATA *pcpd);
  182. void InitFERegistryValues(CONSOLEPROP_DATA *pcpd);
  183. NTSTATUS MakeAltRasterFont(
  184. CONSOLEPROP_DATA *pcpd,
  185. UINT CodePage,
  186. COORD *AltFontSize,
  187. BYTE *AltFontFamily,
  188. ULONG *AltFontIndex,
  189. LPTSTR AltFaceName
  190. );
  191. NTSTATUS InitializeDbcsMisc(CONSOLEPROP_DATA *pcpd);
  192. BYTE CodePageToCharSet(UINT CodePage);
  193. TTFONTLIST *SearchTTFont(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace, BOOL fCodePage, UINT CodePage);
  194. BOOL IsAvailableTTFont(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace);
  195. BOOL IsAvailableTTFontCP(CONSOLEPROP_DATA *pcpd, LPTSTR pwszFace, UINT CodePage);
  196. BOOL IsDisableBoldTTFont(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace);
  197. LPTSTR GetAltFaceName(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace);
  198. NTSTATUS DestroyDbcsMisc(CONSOLEPROP_DATA *pcpd);
  199. int LanguageListCreate(HWND hDlg, UINT CodePage);
  200. typedef struct
  201. {
  202. LONG _cRef;
  203. // input params
  204. IShellLink *psl;
  205. // local state variables
  206. HWND hDlg;
  207. HWND hDlgAdvanced;
  208. BOOL bIsFile;
  209. BOOL bIsDirty;
  210. int iIconIndex;
  211. BOOL bLinkThreadIsAlive;
  212. BOOL bCheckRunInSep;
  213. HANDLE hCheckNow;
  214. BOOL bEnableRunInSepVDM;
  215. BOOL bRunInSepVDM;
  216. BOOL bRunAsUser;
  217. TCHAR szFile[MAX_PATH];
  218. TCHAR szIconPath[MAX_PATH];
  219. } LINKPROP_DATA;
  220. typedef struct {
  221. LINKPROP_DATA *plpd;
  222. CONSOLEPROP_DATA cpd;
  223. } LINKDATA;
  224. STDAPI SaveLink(LINKDATA *pld);
  225. STDAPI_(void) LinkConsolePagesSave(LINKDATA *pld);
  226. STDAPI_(void) AddLinkConsolePages(LINKDATA *pld, IShellLink * psl, LPCTSTR pszFile, LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam);