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.

514 lines
15 KiB

  1. //// GLOBAL.H - Global variables for CSSAMP
  2. //
  3. //
  4. //// Constants
  5. //
  6. //
  7. #define APPNAMEA "TextTest"
  8. #define APPTITLEA "TextTest - GdipPlus Text support (Text+) Tests"
  9. #define APPNAMEW L"TextTest"
  10. #define APPTITLEW L"TextTest - GdipPlus Text support (Text+) Tests"
  11. const int MAX_STYLES = 5; // Better implementation would use dynamic memory
  12. const int MAX_TEXT = 10000; // Fixed buffer size in Unicode characters
  13. const int MAX_AUTO_FONTS = 20; // Maximum number of fonts to sequence through
  14. const int MAX_AUTO_HEIGHTS = 20; // Maximum number of heights to sequence through
  15. const int MAX_RANGE_COUNT = 10; // Maximum number of ranges
  16. const int CARET_SECTION_LOGICAL = 0;
  17. const int CARET_SECTION_PLAINTEXT = 1;
  18. const int CARET_SECTION_FORMATTED = 2;
  19. //// RUN - A run of characters with similar attributes
  20. //
  21. //
  22. struct RUN {
  23. struct RUN *pNext;
  24. int iLen;
  25. int iStyle; // Index to style sheet (global 'g_style').
  26. SCRIPT_ANALYSIS analysis; // Uniscribe analysis
  27. };
  28. //// STYLE - Text attribute
  29. //
  30. struct STYLE {
  31. WCHAR faceName[LF_FACESIZE];
  32. REAL emSize;
  33. INT style;
  34. //HFONT hf; // Handle to font described by lf
  35. //SCRIPT_CACHE sc; // Uniscribe cache associated with this style
  36. };
  37. //// Global variables
  38. //
  39. //
  40. #ifdef GLOBALS_HERE
  41. #define GLOBAL
  42. #define GLOBALINIT(a) = a
  43. #else
  44. #define GLOBAL extern
  45. #define GLOBALINIT(a)
  46. #endif
  47. // Read these from the settings file (command line) - auto-drive for profiling
  48. GLOBAL char g_szProfileName[MAX_PATH]; // Profile File name
  49. GLOBAL BOOL g_AutoDrive GLOBALINIT(FALSE); // Automatically run suite and exit
  50. GLOBAL int g_iNumIterations GLOBALINIT(1); // Number of test iterations to execute
  51. GLOBAL int g_iNumRepaints GLOBALINIT(1); // Number of re-paints to execute
  52. GLOBAL int g_iNumRenders GLOBALINIT(1); // Number of API Render calls to execute
  53. GLOBAL char g_szSourceTextFile[MAX_PATH]; // Source Text Filename
  54. GLOBAL BOOL g_Offscreen GLOBALINIT(FALSE); // Use offscreen surface
  55. GLOBAL ARGB g_TextColor GLOBALINIT(0xFF000000); // Text color
  56. GLOBAL ARGB g_BackColor GLOBALINIT(0xFFFFFFFF); // Background color
  57. // Automatic cycling data for font height/face
  58. GLOBAL BOOL g_AutoFont GLOBALINIT(FALSE); // Sequence through fonts
  59. GLOBAL BOOL g_AutoHeight GLOBALINIT(FALSE); // Sequence through all font heights
  60. GLOBAL int g_iAutoFonts GLOBALINIT(0); // Number of fonts to sequence through
  61. GLOBAL int g_iAutoHeights GLOBALINIT(0); // Number of heights to sequence through
  62. GLOBAL TCHAR g_rgszAutoFontFacenames[MAX_AUTO_FONTS][MAX_PATH]; // Array of auto-font facenames
  63. GLOBAL int g_rgiAutoHeights[MAX_AUTO_HEIGHTS]; // Array of auto-height sizes
  64. // These correspond to bits in g_DriverOptions (enumeration)
  65. GLOBAL BOOL g_CMapLookup GLOBALINIT(TRUE);
  66. GLOBAL BOOL g_Vertical GLOBALINIT(FALSE);
  67. GLOBAL BOOL g_RealizedAdvance GLOBALINIT(TRUE);
  68. GLOBAL BOOL g_CompensateRes GLOBALINIT(FALSE);
  69. // These correspond to bits in g_formatFlags
  70. GLOBAL BOOL g_NoFitBB GLOBALINIT(FALSE);
  71. GLOBAL BOOL g_NoWrap GLOBALINIT(FALSE);
  72. GLOBAL BOOL g_NoClip GLOBALINIT(FALSE);
  73. // Initial Font controls
  74. GLOBAL BOOL g_FontOverride GLOBALINIT(FALSE); // Over-ride default font settings
  75. GLOBAL TCHAR g_szFaceName[MAX_PATH]; // Font Face name
  76. GLOBAL int g_iFontHeight GLOBALINIT(8); // Font Height
  77. GLOBAL BOOL g_Bold GLOBALINIT(FALSE); // Bold flag
  78. GLOBAL BOOL g_Italic GLOBALINIT(FALSE); // Italic flag
  79. GLOBAL BOOL g_Underline GLOBALINIT(FALSE); // Underline
  80. GLOBAL BOOL g_Strikeout GLOBALINIT(FALSE); // Strikeout
  81. GLOBAL HINSTANCE g_hInstance GLOBALINIT(NULL); // The one and only instance
  82. GLOBAL char g_szAppDir[MAX_PATH]; // Application directory
  83. GLOBAL HWND g_hSettingsDlg GLOBALINIT(NULL); // Settings panel
  84. GLOBAL HWND g_hGlyphSettingsDlg GLOBALINIT(NULL); // Settings panel
  85. GLOBAL HWND g_hDriverSettingsDlg GLOBALINIT(NULL); // Settings panel
  86. GLOBAL HWND g_hTextWnd GLOBALINIT(NULL); // Text display/editing panel
  87. GLOBAL BOOL g_bUnicodeWnd GLOBALINIT(FALSE); // If text window is Unicode
  88. GLOBAL int g_iSettingsWidth;
  89. GLOBAL int g_iSettingsHeight;
  90. GLOBAL BOOL g_fShowLevels GLOBALINIT(FALSE); // Show bidi levels for each codepoint
  91. GLOBAL int g_iMinWidth; // Main window minimum size
  92. GLOBAL int g_iMinHeight;
  93. GLOBAL BOOL g_fPresentation GLOBALINIT(FALSE); // Hide settings, show text very large
  94. GLOBAL BOOL g_ShowLogical GLOBALINIT(FALSE);
  95. GLOBAL BOOL g_ShowGDI GLOBALINIT(FALSE); // Render text using GDI
  96. GLOBAL BOOL g_UseDrawText GLOBALINIT(TRUE); // Render using DrawText
  97. GLOBAL BOOL g_fOverrideDx GLOBALINIT(FALSE); // Provide UI for changing logical widths
  98. GLOBAL SCRIPT_CONTROL g_ScriptControl GLOBALINIT({0});
  99. GLOBAL SCRIPT_STATE g_ScriptState GLOBALINIT({0});
  100. GLOBAL BOOL g_fNullState GLOBALINIT(FALSE);
  101. GLOBAL DWORD g_dwSSAflags GLOBALINIT(SSA_FALLBACK);
  102. GLOBAL STYLE g_style[MAX_STYLES]; // 0 for plaintext, 1-4 for formatted text
  103. GLOBAL WCHAR g_wcBuf[MAX_TEXT];
  104. GLOBAL int g_iWidthBuf[MAX_TEXT];
  105. GLOBAL RUN *g_pFirstFormatRun GLOBALINIT(NULL); // Formatting info
  106. GLOBAL int g_iTextLen GLOBALINIT(0);
  107. GLOBAL int g_iCaretX GLOBALINIT(0); // Caret position in text window
  108. GLOBAL int g_iCaretY GLOBALINIT(0); // Caret position in text window
  109. GLOBAL int g_iCaretHeight GLOBALINIT(0); // Caret height in pixels
  110. GLOBAL int g_fUpdateCaret GLOBALINIT(TRUE); // Caret requires updating
  111. GLOBAL int g_iCaretSection GLOBALINIT(CARET_SECTION_LOGICAL); // Whether caret is in logical, plain or formatted text
  112. GLOBAL int g_iCurChar GLOBALINIT(0); // Caret sits on leading edge of buffer[iCurChar]
  113. GLOBAL int g_iMouseDownX GLOBALINIT(0);
  114. GLOBAL int g_iMouseDownY GLOBALINIT(0);
  115. GLOBAL BOOL g_fMouseDown GLOBALINIT(FALSE);
  116. GLOBAL int g_iMouseUpX GLOBALINIT(0);
  117. GLOBAL int g_iMouseUpY GLOBALINIT(0);
  118. GLOBAL BOOL g_fMouseUp GLOBALINIT(FALSE);
  119. GLOBAL int g_iFrom GLOBALINIT(0); // Highlight start
  120. GLOBAL int g_iTo GLOBALINIT(0); // Highlight end
  121. GLOBAL HFONT g_hfCaption GLOBALINIT(NULL); // Caption font
  122. GLOBAL int g_iLogPixelsY GLOBALINIT(0);
  123. GLOBAL Matrix g_WorldTransform;
  124. GLOBAL Matrix g_FontTransform;
  125. GLOBAL Matrix g_DriverTransform;
  126. GLOBAL SmoothingMode g_SmoothingMode GLOBALINIT(SmoothingModeDefault);
  127. // Font families
  128. // Enumerate available families
  129. GLOBAL InstalledFontCollection g_InstalledFontCollection;
  130. GLOBAL FontFamily *g_families;
  131. GLOBAL INT g_familyCount;
  132. GLOBAL BOOL g_ShowFamilies GLOBALINIT(FALSE);
  133. // Glyphs
  134. GLOBAL BOOL g_ShowGlyphs GLOBALINIT(FALSE);
  135. GLOBAL int g_GlyphRows GLOBALINIT(16);
  136. GLOBAL int g_GlyphColumns GLOBALINIT(16);
  137. GLOBAL int g_GlyphFirst GLOBALINIT(0);
  138. GLOBAL BOOL g_CmapLookup GLOBALINIT(FALSE);
  139. GLOBAL BOOL g_HorizontalChart GLOBALINIT(FALSE);
  140. GLOBAL BOOL g_ShowCell GLOBALINIT(FALSE);
  141. GLOBAL BOOL g_VerticalForms GLOBALINIT(FALSE);
  142. // Driver string
  143. GLOBAL BOOL g_ShowDriver GLOBALINIT(FALSE);
  144. GLOBAL INT g_DriverOptions GLOBALINIT( DriverStringOptionsCmapLookup
  145. | DriverStringOptionsRealizedAdvance);
  146. GLOBAL REAL g_DriverDx GLOBALINIT(15.0);
  147. GLOBAL REAL g_DriverDy GLOBALINIT(0.0);
  148. GLOBAL REAL g_DriverPixels GLOBALINIT(13.0);
  149. // DrawString
  150. GLOBAL BOOL g_ShowDrawString GLOBALINIT(FALSE);
  151. GLOBAL TextRenderingHint g_TextMode GLOBALINIT(TextRenderingHintSystemDefault);
  152. GLOBAL UINT g_GammaValue GLOBALINIT(4);
  153. GLOBAL INT g_formatFlags GLOBALINIT(0);
  154. GLOBAL BOOL g_typographic GLOBALINIT(FALSE);
  155. GLOBAL StringAlignment g_align GLOBALINIT(StringAlignmentNear);
  156. GLOBAL HotkeyPrefix g_hotkey GLOBALINIT(HotkeyPrefixNone);
  157. GLOBAL StringAlignment g_lineAlign GLOBALINIT(StringAlignmentNear);
  158. GLOBAL StringTrimming g_lineTrim GLOBALINIT(StringTrimmingNone);
  159. GLOBAL Unit g_fontUnit GLOBALINIT(UnitPoint);
  160. GLOBAL Brush * g_textBrush GLOBALINIT(NULL);
  161. GLOBAL Brush * g_textBackBrush GLOBALINIT(NULL);
  162. GLOBAL BOOL g_testMetafile GLOBALINIT(FALSE);
  163. // Path
  164. GLOBAL BOOL g_ShowPath GLOBALINIT(FALSE);
  165. // Metrics
  166. GLOBAL BOOL g_ShowMetric GLOBALINIT(FALSE);
  167. // Performance
  168. GLOBAL BOOL g_ShowPerformance GLOBALINIT(FALSE);
  169. GLOBAL INT g_PerfRepeat GLOBALINIT(2000);
  170. // Scaling
  171. GLOBAL BOOL g_ShowScaling GLOBALINIT(FALSE);
  172. // String format digit substitution
  173. GLOBAL StringDigitSubstitute g_DigitSubstituteMode GLOBALINIT(StringDigitSubstituteUser);
  174. GLOBAL LANGID g_Language GLOBALINIT(LANG_NEUTRAL);
  175. GLOBAL INT g_RangeCount GLOBALINIT(0);
  176. GLOBAL CharacterRange g_Ranges[MAX_RANGE_COUNT];
  177. /* obsolete
  178. GLOBAL BOOL g_fFillLines GLOBALINIT(TRUE);
  179. GLOBAL BOOL g_fLogicalOrder GLOBALINIT(FALSE);
  180. GLOBAL BOOL g_fNoGlyphIndex GLOBALINIT(FALSE);
  181. GLOBAL BOOL g_fShowWidths GLOBALINIT(FALSE);
  182. GLOBAL BOOL g_fShowStyles GLOBALINIT(FALSE);
  183. GLOBAL BOOL g_fShowPlainText GLOBALINIT(TRUE);
  184. GLOBAL BOOL g_fShowFancyText GLOBALINIT(FALSE);
  185. */
  186. //// Function prototypes
  187. //
  188. //
  189. // DspGDI.cpp
  190. void PaintGDI(
  191. HDC hdc,
  192. int *piY,
  193. RECT *prc,
  194. int iLineHeight);
  195. // DspFamly.cpp
  196. void PaintFamilies(
  197. HDC hdc,
  198. int *piY,
  199. RECT *prc,
  200. int iLineHeight);
  201. void InitializeLegacyFamilies();
  202. // DspLogcl.cpp
  203. void PaintLogical(
  204. HDC hdc,
  205. int *piY,
  206. RECT *prc,
  207. int iLineHeight);
  208. // DspDraws.cpp
  209. void PaintDrawString(
  210. HDC hdc,
  211. int *piY,
  212. RECT *prc,
  213. int iLineHeight);
  214. // DspDriver.cpp
  215. void PaintDrawDriverString(
  216. HDC hdc,
  217. int *piY,
  218. RECT *prc,
  219. int iLineHeight);
  220. // DspPerf.cpp
  221. void PaintPerformance(
  222. HDC hdc,
  223. int *piY,
  224. RECT *prc,
  225. int iLineHeight);
  226. // DspPath.cpp
  227. void PaintPath(
  228. HDC hdc,
  229. int *piY,
  230. RECT *prc,
  231. int iLineHeight);
  232. // DspGlyph.cpp
  233. void PaintGlyphs(
  234. HDC hdc,
  235. int *piY,
  236. RECT *prc,
  237. int iLineHeight);
  238. // DspMetric.cpp
  239. void PaintMetrics(
  240. HDC hdc,
  241. int *piY,
  242. RECT *prc,
  243. int iLineHeight);
  244. // DspScaling.cpp
  245. void PaintScaling(
  246. HDC hdc,
  247. int *piY,
  248. RECT *prc,
  249. int iLineHeight);
  250. // Settings.cpp
  251. INT_PTR CALLBACK SettingsDlgProc(
  252. HWND hDlg,
  253. UINT uMsg,
  254. WPARAM wParam,
  255. LPARAM lParam);
  256. INT_PTR CALLBACK GlyphSettingsDlgProc(
  257. HWND hDlg,
  258. UINT uMsg,
  259. WPARAM wParam,
  260. LPARAM lParam);
  261. INT_PTR CALLBACK DriverSettingsDlgProc(
  262. HWND hDlg,
  263. UINT uMsg,
  264. WPARAM wParam,
  265. LPARAM lParam);
  266. void InsertText(HWND hDlg, char *textId);
  267. // ReadSettings.cpp
  268. void ReadProfileInfo(char *szProfileName);
  269. // Text.cpp
  270. void InitText(INT id);
  271. BOOL TextInsert(
  272. int iPos,
  273. PWCH pwc,
  274. int iLen);
  275. BOOL TextDelete(
  276. int iPos,
  277. int iLen);
  278. // TextWnd.cpp
  279. HWND CreateTextWindow();
  280. void ResetCaret(int iX, int iY, int iHeight);
  281. LRESULT CALLBACK TextWndProc(
  282. HWND hWnd,
  283. UINT uMsg,
  284. WPARAM wParam,
  285. LPARAM lParam);
  286. void InvalidateText();
  287. void PrintPage();
  288. // Edit.cpp
  289. BOOL EditChar(WCHAR wc);
  290. BOOL EditKeyDown(WCHAR wc);
  291. void EditFreeCaches();
  292. void EditInsertUnicode();
  293. // Style.cpp
  294. void SetStyle(
  295. int iStyle,
  296. int iHeight,
  297. int iWeight,
  298. int iItalic,
  299. int iUnderline,
  300. int iStrikeout,
  301. TCHAR *pcFaceName);
  302. void InitStyles();
  303. void FreeStyles();
  304. void SetLogFont(
  305. PLOGFONTA plf,
  306. int iHeight,
  307. int iWeight,
  308. int iItalic,
  309. int iUnderline,
  310. char *pcFaceName);
  311. void StyleDeleteRange(
  312. int iDelPos,
  313. int iDelLen);
  314. void StyleExtendRange(
  315. int iExtPos,
  316. int iExtLen);
  317. void StyleSetRange(
  318. int iSetStyle,
  319. int iSetPos,
  320. int iSetLen);
  321. BOOL StyleCheckRange();
  322. // Debugging support
  323. #define TRACEMSG(a) {DG.psFile=__FILE__; DG.iLine=__LINE__; DebugMsg a;}
  324. #define ASSERT(a) {if (!(a)) TRACEMSG(("Assertion failure: "#a));}
  325. #define ASSERTS(a,b) {if (!(a)) TRACEMSG(("Assertion failure: "#a" - "#b));}
  326. #define ASSERTHR(a,b) {if (!SUCCEEDED(a)) {DG.psFile=__FILE__; \
  327. DG.iLine=__LINE__; DG.hrLastError=a; DebugHr b;}}
  328. /// Debug variables
  329. //
  330. struct DebugGlobals {
  331. char *psFile;
  332. int iLine;
  333. HRESULT hrLastError; // Last hresult from GDI
  334. CHAR sLastError[100]; // Last error string
  335. };
  336. /// Debug function prototypes
  337. //
  338. extern "C" void WINAPIV DebugMsg(char *fmt, ...);
  339. extern "C" void WINAPIV DebugHr(char *fmt, ...);
  340. GLOBAL DebugGlobals DG GLOBALINIT({0});
  341. GLOBAL UINT debug GLOBALINIT(0);