Leaked source code of windows server 2003
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.

268 lines
8.1 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 lcbFINDSTRINGEXACT(hWnd, bLB, pwsz) \
  134. SendMessage(hWnd, bLB ? LB_FINDSTRINGEXACT : CB_FINDSTRINGEXACT, \
  135. (DWORD)-1, (LPARAM)pwsz)
  136. #define lcbADDSTRING(hWnd, bLB, pwsz) \
  137. SendMessage(hWnd, bLB ? LB_ADDSTRING : CB_ADDSTRING, 0, (LPARAM)pwsz)
  138. #define lcbSETITEMDATA(hWnd, bLB, w, nFont) \
  139. SendMessage(hWnd, bLB ? LB_SETITEMDATA : CB_SETITEMDATA, w, nFont)
  140. #define lcbGETITEMDATA(hWnd, bLB, w) \
  141. SendMessage(hWnd, bLB ? LB_GETITEMDATA : CB_GETITEMDATA, w, 0L)
  142. #define lcbGETCOUNT(hWnd, bLB) \
  143. SendMessage(hWnd, bLB ? LB_GETCOUNT : CB_GETCOUNT, 0, 0L)
  144. #define lcbGETCURSEL(hWnd, bLB) \
  145. SendMessage(hWnd, bLB ? LB_GETCURSEL : CB_GETCURSEL, 0, 0L)
  146. #define lcbSETCURSEL(hWnd, bLB, w) \
  147. SendMessage(hWnd, bLB ? LB_SETCURSEL : CB_SETCURSEL, w, 0L)
  148. #define NELEM(array) (sizeof(array)/sizeof(array[0]))
  149. #define AttrToRGB(Attr) (pcpd->lpConsole->ColorTable[(Attr) & 0x0F])
  150. #define ScreenTextColor(pcpd) \
  151. (AttrToRGB(LOBYTE(pcpd->lpConsole->wFillAttribute) & 0x0F))
  152. #define ScreenBkColor(pcpd) \
  153. (AttrToRGB(LOBYTE(pcpd->lpConsole->wFillAttribute >> 4)))
  154. #define PopupTextColor(pcpd) \
  155. (AttrToRGB(LOBYTE(pcpd->lpConsole->wPopupFillAttribute) & 0x0F))
  156. #define PopupBkColor(pcpd) \
  157. (AttrToRGB(LOBYTE(pcpd->lpConsole->wPopupFillAttribute >> 4)))
  158. NTSTATUS InitializeFonts( CONSOLEPROP_DATA *pcpd );
  159. STDAPI_(void) DestroyFonts( CONSOLEPROP_DATA *pcpd );
  160. NTSTATUS EnumerateFonts( CONSOLEPROP_DATA *pcpd, DWORD Flags);
  161. int FindCreateFont(
  162. CONSOLEPROP_DATA *pcpd,
  163. DWORD Family,
  164. LPTSTR ptszFace,
  165. COORD Size,
  166. LONG Weight);
  167. BOOL DoFontEnum(
  168. CONSOLEPROP_DATA *pcpd,
  169. HDC hDC,
  170. LPTSTR ptszFace,
  171. PSHORT pTTPoints,
  172. UINT nTTPoints);
  173. void GetTitleFromLinkName(LPTSTR szLinkName, LPTSTR szTitle, UINT cchTitle);
  174. void SetRegistryValues(CONSOLEPROP_DATA *pcpd);
  175. void GetRegistryValues(CONSOLEPROP_DATA *pcpd);
  176. void InitRegistryValues(CONSOLEPROP_DATA *pcpd);
  177. void GetRegistryValues(CONSOLEPROP_DATA *pcpd);
  178. void SetFERegistryValues(CONSOLEPROP_DATA *pcpd);
  179. void GetFERegistryValues(CONSOLEPROP_DATA *pcpd);
  180. void InitFERegistryValues(CONSOLEPROP_DATA *pcpd);
  181. NTSTATUS MakeAltRasterFont(
  182. CONSOLEPROP_DATA *pcpd,
  183. UINT CodePage,
  184. COORD *AltFontSize,
  185. BYTE *AltFontFamily,
  186. ULONG *AltFontIndex,
  187. LPTSTR AltFaceName,
  188. UINT cchFaceName
  189. );
  190. NTSTATUS InitializeDbcsMisc(CONSOLEPROP_DATA *pcpd);
  191. BYTE CodePageToCharSet(UINT CodePage);
  192. TTFONTLIST *SearchTTFont(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace, BOOL fCodePage, UINT CodePage);
  193. BOOL IsAvailableTTFont(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace);
  194. BOOL IsAvailableTTFontCP(CONSOLEPROP_DATA *pcpd, LPTSTR pwszFace, UINT CodePage);
  195. BOOL IsDisableBoldTTFont(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace);
  196. LPTSTR GetAltFaceName(CONSOLEPROP_DATA *pcpd, LPTSTR ptszFace);
  197. int LanguageListCreate(HWND hDlg, UINT CodePage);
  198. typedef struct
  199. {
  200. LONG _cRef;
  201. // input params
  202. IShellLink *psl;
  203. // local state variables
  204. HWND hDlg;
  205. HWND hDlgAdvanced;
  206. BOOL bIsFile;
  207. BOOL bIsDirty;
  208. int iIconIndex;
  209. BOOL bLinkThreadIsAlive;
  210. BOOL bCheckRunInSep;
  211. HANDLE hCheckNow;
  212. BOOL bEnableRunInSepVDM;
  213. BOOL bRunInSepVDM;
  214. BOOL bRunAsUser;
  215. TCHAR szFile[MAX_PATH];
  216. TCHAR szIconPath[MAX_PATH];
  217. } LINKPROP_DATA;
  218. typedef struct {
  219. LINKPROP_DATA *plpd;
  220. CONSOLEPROP_DATA cpd;
  221. } LINKDATA;
  222. STDAPI SaveLink(LINKDATA *pld);
  223. STDAPI_(void) LinkConsolePagesSave(LINKDATA *pld);
  224. STDAPI_(void) AddLinkConsolePages(LINKDATA *pld, IShellLink * psl, LPCTSTR pszFile, LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam);